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