Mercurial > mm7
annotate Overlays.cpp @ 1301:18665b8f66b2
yellow points remove
author | Ritor1 |
---|---|
date | Mon, 24 Jun 2013 13:47:13 +0600 |
parents | 29a8defbad9e |
children | 22cb507446a4 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
4 |
0 | 5 #include <stdlib.h> |
6 | |
7 #include "Overlays.h" | |
8 #include "Sprites.h" | |
9 #include "FrameTableInc.h" | |
10 #include "Allocator.h" | |
11 #include "IconFrameTable.h" | |
12 #include "Time.h" | |
13 #include "Party.h" | |
14 #include "TurnEngine.h" | |
15 #include "LOD.h" | |
16 #include "Render.h" | |
569 | 17 #include "GUIWindow.h" |
0 | 18 |
19 #include "mm7_data.h" | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 struct OtherOverlayList *pOtherOverlayList = new OtherOverlayList; // idb | |
26 struct OverlayList *pOverlayList = new OverlayList; | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
783 | 33 // inlined |
34 //----- (mm6c::0045BD50) -------------------------------------------------- | |
35 void OtherOverlayList::Reset() | |
36 { | |
37 for (uint i = 0; i < 50; ++i) | |
38 pOverlays[i].Reset(); | |
39 } | |
0 | 40 |
41 //----- (004418B1) -------------------------------------------------------- | |
42 int OtherOverlayList::_4418B1(int a2, int a3, int a4, int a5) | |
43 { | |
44 return 0; | |
45 } | |
46 | |
47 //----- (004418B6) -------------------------------------------------------- | |
48 int OtherOverlayList::_4418B6(int uOverlayID, __int16 a3, int a4, int a5, __int16 a6) | |
49 { | |
50 signed int v6; // edx@1 | |
51 OtherOverlayList *v7; // eax@1 | |
142 | 52 //signed int result; // eax@4 |
0 | 53 signed int v9; // esi@6 |
54 __int16 v10; // dx@9 | |
55 __int16 v11; // dx@11 | |
56 | |
57 v6 = 0; | |
58 v7 = this; | |
59 while ( v7->pOverlays[0].field_6 > 0 ) | |
60 { | |
61 ++v6; | |
62 v7 = (OtherOverlayList *)((char *)v7 + 20); | |
63 if ( v6 >= 50 ) | |
64 return 0; | |
65 } | |
66 v7->pOverlays[0].field_0 = 0; | |
67 v7->pOverlays[0].field_A = 0; | |
68 v7->pOverlays[0].field_8 = 0; | |
69 v7->pOverlays[0].field_C = a3; | |
70 v9 = 0; | |
71 if ( (signed int)pOverlayList->uNumOverlays <= 0 ) | |
72 { | |
73 LABEL_9: | |
74 v10 = 0; | |
75 } | |
76 else | |
77 { | |
78 while ( uOverlayID != pOverlayList->pOverlays[v9].uOverlayID ) | |
79 { | |
80 ++v9; | |
81 if ( v9 >= (signed int)pOverlayList->uNumOverlays ) | |
82 goto LABEL_9; | |
83 } | |
84 v10 = v9; | |
85 } | |
86 v7->pOverlays[0].field_2 = v10; | |
87 v7->pOverlays[0].field_4 = 0; | |
88 if ( a4 ) | |
89 v11 = a4; | |
90 else | |
91 v11 = 8 * pSpriteFrameTable->pSpriteSFrames[pOverlayList->pOverlays[v10].uSpriteFramesetID].uAnimLength; | |
92 v7->pOverlays[0].field_6 = v11; | |
93 v7->pOverlays[0].field_10 = a5; | |
94 v7->pOverlays[0].field_E = a6; | |
142 | 95 |
96 bRedraw = true; | |
97 return true; | |
0 | 98 } |
99 | |
100 //----- (00441964) -------------------------------------------------------- | |
569 | 101 void OtherOverlayList::DrawTurnBasedIcon(int a2) |
0 | 102 { |
103 unsigned int result; // eax@1 | |
104 IconFrameTable *v3; // ecx@6 | |
105 void *v4; // eax@12 | |
106 unsigned int v5; // [sp-8h] [bp-Ch]@4 | |
107 int v6; // [sp-4h] [bp-8h]@4 | |
108 Texture *v7; // [sp-4h] [bp-8h]@14 | |
109 | |
569 | 110 if ( pCurrentScreen != SCREEN_GAME || !pParty->bTurnBasedModeOn) |
111 return; | |
112 | |
0 | 113 if ( pTurnEngine->field_4 == 3 ) |
114 { | |
115 v6 = pEventTimer->uStartTime; | |
116 v5 = pIconIDs_Turn[5 - pTurnEngine->uActionPointsLeft / 26]; | |
117 } | |
118 else | |
119 { | |
120 if ( pTurnEngine->field_4 == 1 ) | |
121 { | |
122 v6 = dword_50C994; | |
123 v3 = pIconsFrameTable; | |
124 if ( dword_50C998_turnbased_icon_1A ) | |
125 v5 = uIconID_TurnStart; | |
126 else | |
127 v5 = uIconID_TurnHour; | |
128 goto LABEL_12; | |
129 } | |
130 if ( pTurnEngine->field_4 != 2 ) | |
131 { | |
132 v4 = this; | |
133 goto LABEL_14; | |
134 } | |
135 v6 = pEventTimer->uStartTime; | |
136 v5 = uIconID_TurnStop; | |
137 } | |
138 v3 = pIconsFrameTable; | |
139 LABEL_12: | |
140 v4 = pIconsFrameTable->GetFrame(v5, v6); | |
141 LABEL_14: | |
142 v7 = &pIcons_LOD->pTextures[*((short *)v4 + 15)]; | |
143 if ( pRenderer->pRenderD3D ) | |
144 pRenderer->DrawTextureIndexed(0x18Au, 0x120u, v7); | |
145 else | |
146 pRenderer->DrawTextureTransparent(0x18Au, 0x120u, v7); | |
147 result = dword_50C994; | |
148 if ( dword_50C994 < dword_50C998_turnbased_icon_1A ) | |
149 { | |
150 result = pEventTimer->uTimeElapsed + dword_50C994; | |
151 dword_50C994 = result; | |
152 if ( (signed int)result >= dword_50C998_turnbased_icon_1A ) | |
153 dword_50C998_turnbased_icon_1A = 0; | |
154 } | |
155 } | |
156 // 4E28F8: using guessed type int pCurrentScreen; | |
157 // 50C994: using guessed type int dword_50C994; | |
158 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A; | |
159 | |
160 | |
161 //----- (00458D97) -------------------------------------------------------- | |
162 void OverlayList::InitializeSprites() | |
163 { | |
472 | 164 for (uint i = 0; i < uNumOverlays; ++i) |
165 pSpriteFrameTable->InitializeSprite(pOverlays[i].uSpriteFramesetID); | |
0 | 166 } |
167 | |
168 //----- (00458DBC) -------------------------------------------------------- | |
169 void OverlayList::ToFile() | |
170 { | |
171 OverlayList *v1; // esi@1 | |
172 FILE *v2; // eax@1 | |
173 FILE *v3; // edi@1 | |
174 | |
175 v1 = this; | |
176 v2 = fopen("data\\doverlay.bin", "wb"); | |
177 v3 = v2; | |
178 if ( !v2 ) | |
179 Abortf("Unable to save doverlay.bin!"); | |
180 fwrite(v1, 4u, 1u, v2); | |
181 fwrite(v1->pOverlays, 8u, v1->uNumOverlays, v3); | |
182 fclose(v3); | |
183 } | |
184 | |
185 //----- (00458E08) -------------------------------------------------------- | |
186 void OverlayList::FromFile(void *pSerialized) | |
187 { | |
188 uNumOverlays = *(int *)pSerialized; | |
189 pOverlays = (OverlayDesc *)pAllocator->AllocNamedChunk(pOverlays, 8 * uNumOverlays, "Ovl Des."); | |
190 memcpy(pOverlays, (char *)pSerialized + 4, 8 * uNumOverlays); | |
191 } | |
192 | |
193 //----- (00458E4F) -------------------------------------------------------- | |
194 bool OverlayList::FromFileTxt(const char *Args) | |
195 { | |
196 OverlayList *v2; // ebx@1 | |
197 __int32 v3; // edi@1 | |
198 FILE *v4; // eax@1 | |
199 unsigned int v5; // esi@3 | |
200 const void *v6; // ST18_4@9 | |
201 void *v7; // eax@9 | |
202 FILE *v8; // ST0C_4@11 | |
203 char *i; // eax@11 | |
204 unsigned __int16 v10; // ax@14 | |
205 const char *v11; // ST1C_4@14 | |
206 int v12; // eax@16 | |
207 OverlayDesc *v13; // ecx@16 | |
208 char v14; // zf@16 | |
209 unsigned int v15; // eax@16 | |
210 char Buf; // [sp+10h] [bp-2F0h]@3 | |
211 FrameTableTxtLine v18; // [sp+204h] [bp-FCh]@4 | |
212 FrameTableTxtLine v19; // [sp+280h] [bp-80h]@4 | |
213 FILE *File; // [sp+2FCh] [bp-4h]@1 | |
214 unsigned int Argsa; // [sp+308h] [bp+8h]@3 | |
215 | |
216 v2 = this; | |
217 pAllocator->FreeChunk(this->pOverlays); | |
218 v3 = 0; | |
219 v2->pOverlays = 0; | |
220 v2->uNumOverlays = 0; | |
221 v4 = fopen(Args, "r"); | |
222 File = v4; | |
223 if ( !v4 ) | |
224 Abortf("ObjectDescriptionList::load - Unable to open file: %s."); | |
225 v5 = 0; | |
226 Argsa = 0; | |
227 if ( fgets(&Buf, 490, v4) ) | |
228 { | |
229 do | |
230 { | |
231 *strchr(&Buf, 10) = 0; | |
703 | 232 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); |
701 | 233 if ( v19.uPropCount && *v19.pProperties[0] != 47 ) |
0 | 234 ++Argsa; |
235 } | |
236 while ( fgets(&Buf, 490, File) ); | |
237 v5 = Argsa; | |
238 v3 = 0; | |
239 } | |
240 v6 = v2->pOverlays; | |
241 v2->uNumOverlays = v5; | |
242 v7 = pAllocator->AllocNamedChunk(v6, 8 * v5, "Ovl Des."); | |
243 v2->pOverlays = (OverlayDesc *)v7; | |
244 if ( v7 == (void *)v3 ) | |
245 Abortf("OverlayDescriptionList::load - Out of Memory!"); | |
246 memset(v7, v3, 8 * v2->uNumOverlays); | |
247 v8 = File; | |
248 v2->uNumOverlays = v3; | |
249 fseek(v8, v3, v3); | |
250 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) | |
251 { | |
252 *strchr(&Buf, 10) = 0; | |
703 | 253 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); |
701 | 254 if ( v19.uPropCount && *v19.pProperties[0] != 47 ) |
0 | 255 { |
256 v10 = atoi(v19.pProperties[0]); | |
257 v11 = v19.pProperties[1]; | |
258 v2->pOverlays[v2->uNumOverlays].uOverlayID = v10; | |
1104 | 259 if ( _stricmp(v11, "center") ) |
0 | 260 { |
1104 | 261 v12 = _stricmp(v19.pProperties[1], "transparent"); |
0 | 262 v13 = v2->pOverlays; |
263 v14 = v12 == 0; | |
264 v15 = v2->uNumOverlays; | |
265 if ( v14 ) | |
266 v13[v15].uOverlayType = 2; | |
267 else | |
268 v13[v15].uOverlayType = 1; | |
269 } | |
270 else | |
271 { | |
272 v2->pOverlays[v2->uNumOverlays].uOverlayType = 0; | |
273 } | |
274 v2->pOverlays[v2->uNumOverlays++].uSpriteFramesetID = pSpriteFrameTable->FastFindSprite( | |
275 (char *)v19.pProperties[2]); | |
276 } | |
277 } | |
278 fclose(File); | |
279 return 1; | |
280 } | |
281 | |
282 | |
283 //----- (0045855F) -------------------------------------------------------- | |
284 void OtherOverlay::Reset() | |
285 { | |
286 this->field_10 = 65536; | |
287 this->field_A = 0; | |
288 this->field_8 = 0; | |
289 this->field_6 = 0; | |
290 this->field_4 = 0; | |
291 this->field_2 = 0; | |
292 this->field_C = 0; | |
293 this->field_E = 0; | |
294 } | |
295 | |
296 //----- (004584B8) -------------------------------------------------------- | |
297 OtherOverlay::OtherOverlay() | |
298 { | |
299 this->field_A = 0; | |
300 this->field_8 = 0; | |
301 this->field_6 = 0; | |
302 this->field_4 = 0; | |
303 this->field_2 = 0; | |
304 this->field_C = 0; | |
305 this->field_E = 0; | |
306 this->field_10 = 65536; | |
307 } |