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"
|
|
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
|
|
28
|
|
29
|
|
30 //----- (004418B1) --------------------------------------------------------
|
|
31 int OtherOverlayList::_4418B1(int a2, int a3, int a4, int a5)
|
|
32 {
|
|
33 return 0;
|
|
34 }
|
|
35
|
|
36 //----- (004418B6) --------------------------------------------------------
|
|
37 int OtherOverlayList::_4418B6(int uOverlayID, __int16 a3, int a4, int a5, __int16 a6)
|
|
38 {
|
|
39 signed int v6; // edx@1
|
|
40 OtherOverlayList *v7; // eax@1
|
142
|
41 //signed int result; // eax@4
|
0
|
42 signed int v9; // esi@6
|
|
43 __int16 v10; // dx@9
|
|
44 __int16 v11; // dx@11
|
|
45
|
|
46 v6 = 0;
|
|
47 v7 = this;
|
|
48 while ( v7->pOverlays[0].field_6 > 0 )
|
|
49 {
|
|
50 ++v6;
|
|
51 v7 = (OtherOverlayList *)((char *)v7 + 20);
|
|
52 if ( v6 >= 50 )
|
|
53 return 0;
|
|
54 }
|
|
55 v7->pOverlays[0].field_0 = 0;
|
|
56 v7->pOverlays[0].field_A = 0;
|
|
57 v7->pOverlays[0].field_8 = 0;
|
|
58 v7->pOverlays[0].field_C = a3;
|
|
59 v9 = 0;
|
|
60 if ( (signed int)pOverlayList->uNumOverlays <= 0 )
|
|
61 {
|
|
62 LABEL_9:
|
|
63 v10 = 0;
|
|
64 }
|
|
65 else
|
|
66 {
|
|
67 while ( uOverlayID != pOverlayList->pOverlays[v9].uOverlayID )
|
|
68 {
|
|
69 ++v9;
|
|
70 if ( v9 >= (signed int)pOverlayList->uNumOverlays )
|
|
71 goto LABEL_9;
|
|
72 }
|
|
73 v10 = v9;
|
|
74 }
|
|
75 v7->pOverlays[0].field_2 = v10;
|
|
76 v7->pOverlays[0].field_4 = 0;
|
|
77 if ( a4 )
|
|
78 v11 = a4;
|
|
79 else
|
|
80 v11 = 8 * pSpriteFrameTable->pSpriteSFrames[pOverlayList->pOverlays[v10].uSpriteFramesetID].uAnimLength;
|
|
81 v7->pOverlays[0].field_6 = v11;
|
|
82 v7->pOverlays[0].field_10 = a5;
|
|
83 v7->pOverlays[0].field_E = a6;
|
142
|
84
|
|
85 bRedraw = true;
|
|
86 return true;
|
0
|
87 }
|
|
88
|
|
89 //----- (00441964) --------------------------------------------------------
|
|
90 unsigned int OtherOverlayList::_441964(int a2)
|
|
91 {
|
|
92 unsigned int result; // eax@1
|
|
93 IconFrameTable *v3; // ecx@6
|
|
94 void *v4; // eax@12
|
|
95 unsigned int v5; // [sp-8h] [bp-Ch]@4
|
|
96 int v6; // [sp-4h] [bp-8h]@4
|
|
97 Texture *v7; // [sp-4h] [bp-8h]@14
|
|
98
|
|
99 result = pCurrentScreen;
|
|
100 if ( pCurrentScreen
|
|
101 || pParty->bTurnBasedModeOn != 1 )
|
|
102 return result;
|
|
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 return result;
|
|
146 }
|
|
147 // 4E28F8: using guessed type int pCurrentScreen;
|
|
148 // 50C994: using guessed type int dword_50C994;
|
|
149 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A;
|
|
150
|
|
151
|
|
152 //----- (00458D97) --------------------------------------------------------
|
|
153 void OverlayList::InitializeSprites()
|
|
154 {
|
|
155 OverlayList *v1; // esi@1
|
|
156 signed int i; // edi@1
|
|
157
|
|
158 v1 = this;
|
|
159 for ( i = 0; i < (signed int)v1->uNumOverlays; ++i )
|
|
160 pSpriteFrameTable->InitializeSprite(v1->pOverlays[i].uSpriteFramesetID);
|
|
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 )
|
|
174 Abortf("Unable to save doverlay.bin!");
|
|
175 fwrite(v1, 4u, 1u, v2);
|
|
176 fwrite(v1->pOverlays, 8u, v1->uNumOverlays, v3);
|
|
177 fclose(v3);
|
|
178 }
|
|
179
|
|
180 //----- (00458E08) --------------------------------------------------------
|
|
181 void OverlayList::FromFile(void *pSerialized)
|
|
182 {
|
|
183 uNumOverlays = *(int *)pSerialized;
|
|
184 pOverlays = (OverlayDesc *)pAllocator->AllocNamedChunk(pOverlays, 8 * uNumOverlays, "Ovl Des.");
|
|
185 memcpy(pOverlays, (char *)pSerialized + 4, 8 * uNumOverlays);
|
|
186 }
|
|
187
|
|
188 //----- (00458E4F) --------------------------------------------------------
|
|
189 bool OverlayList::FromFileTxt(const char *Args)
|
|
190 {
|
|
191 OverlayList *v2; // ebx@1
|
|
192 __int32 v3; // edi@1
|
|
193 FILE *v4; // eax@1
|
|
194 unsigned int v5; // esi@3
|
|
195 const void *v6; // ST18_4@9
|
|
196 void *v7; // eax@9
|
|
197 FILE *v8; // ST0C_4@11
|
|
198 char *i; // eax@11
|
|
199 unsigned __int16 v10; // ax@14
|
|
200 const char *v11; // ST1C_4@14
|
|
201 int v12; // eax@16
|
|
202 OverlayDesc *v13; // ecx@16
|
|
203 char v14; // zf@16
|
|
204 unsigned int v15; // eax@16
|
|
205 char Buf; // [sp+10h] [bp-2F0h]@3
|
|
206 FrameTableTxtLine v18; // [sp+204h] [bp-FCh]@4
|
|
207 FrameTableTxtLine v19; // [sp+280h] [bp-80h]@4
|
|
208 FILE *File; // [sp+2FCh] [bp-4h]@1
|
|
209 unsigned int Argsa; // [sp+308h] [bp+8h]@3
|
|
210
|
|
211 v2 = this;
|
|
212 pAllocator->FreeChunk(this->pOverlays);
|
|
213 v3 = 0;
|
|
214 v2->pOverlays = 0;
|
|
215 v2->uNumOverlays = 0;
|
|
216 v4 = fopen(Args, "r");
|
|
217 File = v4;
|
|
218 if ( !v4 )
|
|
219 Abortf("ObjectDescriptionList::load - Unable to open file: %s.");
|
|
220 v5 = 0;
|
|
221 Argsa = 0;
|
|
222 if ( fgets(&Buf, 490, v4) )
|
|
223 {
|
|
224 do
|
|
225 {
|
|
226 *strchr(&Buf, 10) = 0;
|
|
227 memcpy(&v19, texture_frame_table_txt_parser(&Buf, &v18), sizeof(v19));
|
|
228 if ( v19.field_0 && *v19.pProperties[0] != 47 )
|
|
229 ++Argsa;
|
|
230 }
|
|
231 while ( fgets(&Buf, 490, File) );
|
|
232 v5 = Argsa;
|
|
233 v3 = 0;
|
|
234 }
|
|
235 v6 = v2->pOverlays;
|
|
236 v2->uNumOverlays = v5;
|
|
237 v7 = pAllocator->AllocNamedChunk(v6, 8 * v5, "Ovl Des.");
|
|
238 v2->pOverlays = (OverlayDesc *)v7;
|
|
239 if ( v7 == (void *)v3 )
|
|
240 Abortf("OverlayDescriptionList::load - Out of Memory!");
|
|
241 memset(v7, v3, 8 * v2->uNumOverlays);
|
|
242 v8 = File;
|
|
243 v2->uNumOverlays = v3;
|
|
244 fseek(v8, v3, v3);
|
|
245 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
|
|
246 {
|
|
247 *strchr(&Buf, 10) = 0;
|
|
248 memcpy(&v19, texture_frame_table_txt_parser(&Buf, &v18), sizeof(v19));
|
|
249 if ( v19.field_0 && *v19.pProperties[0] != 47 )
|
|
250 {
|
|
251 v10 = atoi(v19.pProperties[0]);
|
|
252 v11 = v19.pProperties[1];
|
|
253 v2->pOverlays[v2->uNumOverlays].uOverlayID = v10;
|
|
254 if ( _strcmpi(v11, "center") )
|
|
255 {
|
|
256 v12 = _strcmpi(v19.pProperties[1], "transparent");
|
|
257 v13 = v2->pOverlays;
|
|
258 v14 = v12 == 0;
|
|
259 v15 = v2->uNumOverlays;
|
|
260 if ( v14 )
|
|
261 v13[v15].uOverlayType = 2;
|
|
262 else
|
|
263 v13[v15].uOverlayType = 1;
|
|
264 }
|
|
265 else
|
|
266 {
|
|
267 v2->pOverlays[v2->uNumOverlays].uOverlayType = 0;
|
|
268 }
|
|
269 v2->pOverlays[v2->uNumOverlays++].uSpriteFramesetID = pSpriteFrameTable->FastFindSprite(
|
|
270 (char *)v19.pProperties[2]);
|
|
271 }
|
|
272 }
|
|
273 fclose(File);
|
|
274 return 1;
|
|
275 }
|
|
276
|
|
277
|
|
278 //----- (0045855F) --------------------------------------------------------
|
|
279 void OtherOverlay::Reset()
|
|
280 {
|
|
281 this->field_10 = 65536;
|
|
282 this->field_A = 0;
|
|
283 this->field_8 = 0;
|
|
284 this->field_6 = 0;
|
|
285 this->field_4 = 0;
|
|
286 this->field_2 = 0;
|
|
287 this->field_C = 0;
|
|
288 this->field_E = 0;
|
|
289 }
|
|
290
|
|
291 //----- (004584B8) --------------------------------------------------------
|
|
292 OtherOverlay::OtherOverlay()
|
|
293 {
|
|
294 this->field_A = 0;
|
|
295 this->field_8 = 0;
|
|
296 this->field_6 = 0;
|
|
297 this->field_4 = 0;
|
|
298 this->field_2 = 0;
|
|
299 this->field_C = 0;
|
|
300 this->field_E = 0;
|
|
301 this->field_10 = 65536;
|
|
302 } |