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