0
|
1 #include <string.h>
|
|
2
|
|
3 #include "Allocator.h"
|
|
4 #include "Sprites.h"
|
|
5 #include "PaletteManager.h"
|
|
6 #include "LOD.h"
|
|
7 #include "FrameTableInc.h"
|
|
8
|
|
9 #include "mm7_data.h"
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14 struct SpriteFrameTable *pSpriteFrameTable;
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19 //----- (0044D4D8) --------------------------------------------------------
|
|
20 void SpriteFrameTable::ReleaseSFrames()
|
|
21 {
|
|
22 SpriteFrameTable *v1; // esi@1
|
|
23
|
|
24 v1 = this;
|
|
25 if ( this->pSpriteSFrames )
|
|
26 {
|
|
27 pAllocator->FreeChunk(this->pSpriteSFrames);
|
|
28 v1->pSpriteSFrames = 0;
|
|
29 }
|
|
30 v1->uNumSpriteFrames = 0;
|
|
31 }
|
|
32
|
|
33 //----- (0044D4F6) --------------------------------------------------------
|
|
34 void SpriteFrameTable::ResetSomeSpriteFlags()
|
|
35 {
|
|
36 int v1; // esi@1
|
|
37 signed int i; // edx@1
|
|
38 char *v3; // eax@2
|
|
39
|
|
40 v1 = 0;
|
|
41 for ( i = 0; i < (signed int)this->uNumSpriteFrames; ++i )
|
|
42 {
|
|
43 v3 = (char *)&this->pSpriteSFrames[v1].uFlags;
|
|
44 ++v1;
|
|
45 *v3 &= 0x7Fu;
|
|
46 }
|
|
47 }
|
|
48
|
|
49 //----- (0044D513) --------------------------------------------------------
|
|
50 void SpriteFrameTable::InitializeSprite(unsigned int uSpriteID)
|
|
51 {
|
|
52 //SpriteFrameTable *v2; // esi@1
|
|
53 unsigned int v3; // ebx@3
|
|
54 //char *v4; // edx@3
|
|
55 //int v5; // eax@3
|
|
56 SpriteFrame *v6; // ecx@5
|
|
57 int v7; // eax@5
|
|
58 __int16 v8; // ax@6
|
|
59 //signed int v9; // edx@6
|
|
60 //int v10; // ecx@6
|
|
61 signed int v11; // edi@10
|
|
62 __int16 v12; // ax@16
|
|
63 int v13; // ecx@16
|
|
64 size_t v14; // eax@19
|
|
65 signed int v15; // edi@19
|
|
66 __int16 v16; // ax@27
|
|
67 int v17; // ecx@27
|
|
68 signed int v18; // edi@29
|
|
69 SpriteFrame *v19; // eax@30
|
|
70 __int16 v20; // ax@45
|
|
71 int v21; // ecx@45
|
|
72 const char *v22; // [sp-8h] [bp-50h]@12
|
|
73 const char *v23; // [sp-8h] [bp-50h]@21
|
|
74 const char *v24; // [sp-8h] [bp-50h]@37
|
|
75 const char *v25; // [sp-4h] [bp-4Ch]@12
|
|
76 char *v26; // [sp-4h] [bp-4Ch]@21
|
|
77 const char *v27; // [sp-4h] [bp-4Ch]@37
|
|
78 char v28[3]; // [sp+9h] [bp-3Fh]@19
|
|
79 char Str; // [sp+Ch] [bp-3Ch]@19
|
|
80 char Size[20]; // [sp+2Ch] [bp-1Ch]@15
|
|
81 char Source[4]; // [sp+40h] [bp-8h]@19
|
|
82 int v32; // [sp+44h] [bp-4h]@19
|
|
83 unsigned int uSpriteIDa; // [sp+50h] [bp+8h]@4
|
|
84
|
|
85 //v2 = this;
|
|
86 if ( (signed int)uSpriteID <= (signed int)this->uNumSpriteFrames )
|
|
87 {
|
|
88 if ( (uSpriteID & 0x80000000u) == 0 )
|
|
89 {
|
|
90 v3 = uSpriteID;
|
|
91
|
|
92 auto uFlags = pSpriteSFrames[uSpriteID].uFlags;
|
|
93 if (uFlags & 0x7F)
|
|
94 {
|
|
95 pSpriteSFrames[uSpriteID].uFlags |= 0x80;
|
|
96
|
|
97 uSpriteIDa = 30 * uSpriteID + 12;
|
|
98 while ( 1 )
|
|
99 {
|
|
100 pSpriteSFrames[v3].uPaletteIndex = pPaletteManager->LoadPalette(pSpriteSFrames[uSpriteID].uPaletteID);
|
|
101 v6 = &pSpriteSFrames[uSpriteID];
|
|
102 v7 = v6->uFlags;
|
|
103 if ( v7 & 0x10 )
|
|
104 {
|
|
105 v8 = pSprites_LOD->LoadSprite(v6->pTextureName, v6->uPaletteID);
|
|
106
|
|
107 for (uint i = 0; i < 8; ++i)
|
|
108 pSpriteSFrames[v3].pHwSpriteIDs[i] = v8;
|
|
109 goto LABEL_46;
|
|
110 }
|
|
111 if ( v7 & 0x10000 )
|
|
112 {
|
|
113 v11 = 0;
|
|
114 do
|
|
115 {
|
|
116 switch ( v11 )
|
|
117 {
|
|
118 case 3:
|
|
119 case 4:
|
|
120 case 5:
|
|
121 v25 = pSpriteSFrames[v3].pTextureName;
|
|
122 v22 = "%s4";
|
|
123 goto LABEL_15;
|
|
124 case 2:
|
|
125 case 6:
|
|
126 v25 = pSpriteSFrames[v3].pTextureName;
|
|
127 v22 = "%s2";
|
|
128 goto LABEL_15;
|
|
129 case 0:
|
|
130 case 1:
|
|
131 case 7:
|
|
132 v25 = pSpriteSFrames[v3].pTextureName;
|
|
133 v22 = "%s0";
|
|
134 LABEL_15:
|
|
135 sprintf(Size, v22, v25);
|
|
136 break;
|
|
137 default:
|
|
138 break;
|
|
139 }
|
|
140 v12 = pSprites_LOD->LoadSprite(Size, pSpriteSFrames[v3].uPaletteID);
|
|
141 v13 = v11++ + uSpriteIDa;
|
|
142 *(short *)&pSpriteSFrames->pIconName[2 * v13] = v12;
|
|
143 }
|
|
144 while ( v11 < 8 );
|
|
145 goto LABEL_46;
|
|
146 }
|
|
147 if ( !(v7 & 0x40) )
|
|
148 break;
|
|
149 strcpy(Source, "stA");
|
|
150 v32 = 0;
|
|
151 strcpy(&Str, v6->pTextureName);
|
|
152 v14 = strlen(&Str);
|
|
153 strcpy(&v28[v14], Source);
|
|
154 v15 = 0;
|
|
155 do
|
|
156 {
|
|
157 switch ( v15 )
|
|
158 {
|
|
159 case 0:
|
|
160 v26 = pSpriteSFrames[v3].pTextureName;
|
|
161 v23 = "%s0";
|
|
162 goto LABEL_26;
|
|
163 case 4:
|
|
164 v26 = &Str;
|
|
165 v23 = "%s4";
|
|
166 goto LABEL_26;
|
|
167 case 3:
|
|
168 case 5:
|
|
169 v26 = &Str;
|
|
170 v23 = "%s3";
|
|
171 goto LABEL_26;
|
|
172 case 2:
|
|
173 case 6:
|
|
174 v26 = pSpriteSFrames[v3].pTextureName;
|
|
175 v23 = "%s2";
|
|
176 goto LABEL_26;
|
|
177 case 1:
|
|
178 case 7:
|
|
179 v26 = pSpriteSFrames[v3].pTextureName;
|
|
180 v23 = "%s1";
|
|
181 LABEL_26:
|
|
182 sprintf(Size, v23, v26);
|
|
183 break;
|
|
184 default:
|
|
185 break;
|
|
186 }
|
|
187 v16 = pSprites_LOD->LoadSprite(Size, pSpriteSFrames[v3].uPaletteID);
|
|
188 v17 = v15++ + uSpriteIDa;
|
|
189 *(short *)&pSpriteSFrames->pIconName[2 * v17] = v16;
|
|
190 }
|
|
191 while ( v15 < 8 );
|
|
192 LABEL_46:
|
|
193 if ( !(pSpriteSFrames[v3].uFlags & 1) )
|
|
194 return;
|
|
195 uSpriteIDa += 30;
|
|
196 ++v3;
|
|
197 }
|
|
198 v18 = 0;
|
|
199 while ( 1 )
|
|
200 {
|
|
201 v19 = &pSpriteSFrames[v3];
|
|
202 if ( !((256 << v18) & v19->uFlags) )
|
|
203 {
|
|
204 sprintf(Size, "%s%i", v19->pTextureName, v18);
|
|
205 goto LABEL_45;
|
|
206 }
|
|
207 if ( v18 == 1 )
|
|
208 {
|
|
209 v27 = v19->pTextureName;
|
|
210 v24 = "%s7";
|
|
211 goto LABEL_42;
|
|
212 }
|
|
213 if ( v18 == 2 )
|
|
214 {
|
|
215 v27 = v19->pTextureName;
|
|
216 v24 = "%s6";
|
|
217 goto LABEL_42;
|
|
218 }
|
|
219 if ( v18 == 3 )
|
|
220 {
|
|
221 v27 = v19->pTextureName;
|
|
222 v24 = "%s5";
|
|
223 goto LABEL_42;
|
|
224 }
|
|
225 if ( v18 == 5 )
|
|
226 {
|
|
227 v27 = v19->pTextureName;
|
|
228 v24 = "%s3";
|
|
229 goto LABEL_42;
|
|
230 }
|
|
231 if ( v18 == 6 )
|
|
232 break;
|
|
233 if ( v18 == 7 )
|
|
234 {
|
|
235 v27 = v19->pTextureName;
|
|
236 v24 = "%s1";
|
|
237 LABEL_42:
|
|
238 sprintf(Size, v24, v27);
|
|
239 }
|
|
240 LABEL_45:
|
|
241 v20 = pSprites_LOD->LoadSprite(Size, pSpriteSFrames[v3].uPaletteID);
|
|
242 v21 = v18++ + uSpriteIDa;
|
|
243 *(short *)&pSpriteSFrames->pIconName[2 * v21] = v20;
|
|
244 if ( v18 >= 8 )
|
|
245 goto LABEL_46;
|
|
246 }
|
|
247 v27 = v19->pTextureName;
|
|
248 v24 = "%s2";
|
|
249 goto LABEL_42;
|
|
250 }
|
|
251 }
|
|
252 }
|
|
253 }
|
|
254
|
|
255 //----- (0044D813) --------------------------------------------------------
|
|
256 unsigned int SpriteFrameTable::FastFindSprite(char *pSpriteName)
|
|
257 {
|
|
258 SpriteFrameTable *v2; // esi@1
|
|
259 int v3; // eax@1
|
|
260 unsigned int result; // eax@2
|
|
261
|
|
262 v2 = this;
|
|
263 BinarySearch(0, this->uNumEFrames, pSpriteName);
|
|
264 v3 = v2->field_8;
|
|
265 if ( v3 < 0 )
|
|
266 result = 0;
|
|
267 else
|
|
268 result = v2->pSpriteEFrames[v3];
|
|
269 return result;
|
|
270 }
|
|
271
|
|
272 //----- (0044D83A) --------------------------------------------------------
|
|
273 void SpriteFrameTable::BinarySearch(int a2, int a3, const char *pSpriteName)
|
|
274 {
|
|
275 int v4; // ebx@1
|
|
276 SpriteFrameTable *v5; // edi@1
|
|
277 int v6; // esi@2
|
|
278 int v7; // eax@2
|
|
279 int a2a; // [sp+14h] [bp+8h]@2
|
|
280
|
|
281 v4 = a2;
|
|
282 v5 = this;
|
|
283 while ( 1 )
|
|
284 {
|
|
285 a2a = a3 - v4;
|
|
286 v6 = (a3 - v4) / 2 + v4;
|
|
287 v7 = _strcmpi(pSpriteName, v5->pSpritePFrames[v6]->pIconName);
|
|
288 if ( !v7 )
|
|
289 v5->field_8 = v6;
|
|
290 if ( v4 == a3 )
|
|
291 break;
|
|
292 if ( v7 >= 0 )
|
|
293 {
|
|
294 if ( a2a <= 4 )
|
|
295 {
|
|
296 while ( v4 < a3 )
|
|
297 {
|
|
298 if ( !_strcmpi(pSpriteName, v5->pSpritePFrames[v4]->pIconName) )
|
|
299 {
|
|
300 LABEL_19:
|
|
301 v5->field_8 = v4;
|
|
302 return;
|
|
303 }
|
|
304 ++v4;
|
|
305 }
|
|
306 break;
|
|
307 }
|
|
308 v4 += (a3 - v4) / 2;
|
|
309 }
|
|
310 else
|
|
311 {
|
|
312 if ( a2a <= 4 )
|
|
313 {
|
|
314 while ( v4 < a3 )
|
|
315 {
|
|
316 if ( !_strcmpi(pSpriteName, v5->pSpritePFrames[v4]->pIconName) )
|
|
317 goto LABEL_19;
|
|
318 ++v4;
|
|
319 }
|
|
320 break;
|
|
321 }
|
|
322 a3 = (a3 - v4) / 2 + v4;
|
|
323 }
|
|
324 }
|
|
325 v5->field_8 = -1;
|
|
326 }
|
|
327
|
|
328 //----- (0044D8D0) --------------------------------------------------------
|
|
329 SpriteFrame *SpriteFrameTable::GetFrame(unsigned int uSpriteID, unsigned int uFrameID)
|
|
330 {
|
|
331 SpriteFrame *v3; // edi@1
|
|
332 SpriteFrame *v4; // ecx@1
|
|
333 __int16 v5; // dx@2
|
|
334 int v6; // edx@3
|
|
335 unsigned int v7; // eax@3
|
|
336 char *i; // ecx@3
|
|
337 int v9; // esi@5
|
|
338 SpriteFrame *result; // eax@6
|
|
339
|
|
340 v3 = this->pSpriteSFrames;
|
|
341 v4 = &v3[uSpriteID];
|
|
342 if ( v4->uFlags & 1 && (v5 = v4->uAnimLength) != 0 )
|
|
343 {
|
|
344 v6 = ((signed int)uFrameID >> 3) % v5;
|
|
345 v7 = uSpriteID;
|
|
346 for ( i = (char *)&v4->uAnimTime; ; i += 60 )
|
|
347 {
|
|
348 v9 = *(short *)i;
|
|
349 if ( v6 <= v9 )
|
|
350 break;
|
|
351 v6 -= v9;
|
|
352 ++v7;
|
|
353 }
|
|
354 result = &v3[v7];
|
|
355 }
|
|
356 else
|
|
357 {
|
|
358 result = &v3[uSpriteID];
|
|
359 }
|
|
360 return result;
|
|
361 }
|
|
362
|
|
363 //----- (0044D91F) --------------------------------------------------------
|
|
364 SpriteFrame *SpriteFrameTable::GetFrameBy_x(unsigned int uSpriteID, signed int a3)
|
|
365 {
|
|
366 SpriteFrame *v3; // edi@1
|
|
367 SpriteFrame *v4; // esi@1
|
|
368 __int16 v5; // ax@2
|
|
369 int v6; // ecx@3
|
|
370 int v7; // edx@3
|
|
371 unsigned int v8; // eax@3
|
|
372 int v9; // ecx@3
|
|
373 char *i; // edx@3
|
|
374 int v11; // esi@5
|
|
375 SpriteFrame *result; // eax@6
|
|
376
|
|
377 v3 = this->pSpriteSFrames;
|
|
378 v4 = &v3[uSpriteID];
|
|
379 if ( v4->uFlags & 1 && (v5 = v4->uAnimLength) != 0 )
|
|
380 {
|
|
381 v6 = v5;
|
|
382 v7 = a3 % v5;
|
|
383 v8 = uSpriteID;
|
|
384 v9 = v6 - v7;
|
|
385 for ( i = (char *)&v4->uAnimTime; ; i += 60 )
|
|
386 {
|
|
387 v11 = *(short *)i;
|
|
388 if ( v9 <= v11 )
|
|
389 break;
|
|
390 v9 -= v11;
|
|
391 ++v8;
|
|
392 }
|
|
393 result = &v3[v8];
|
|
394 }
|
|
395 else
|
|
396 {
|
|
397 result = &v3[uSpriteID];
|
|
398 }
|
|
399 return result;
|
|
400 }
|
|
401
|
|
402 //----- (0044D96D) --------------------------------------------------------
|
|
403 void SpriteFrameTable::ToFile()
|
|
404 {
|
|
405 SpriteFrameTable *v1; // esi@1
|
|
406 FILE *v2; // eax@1
|
|
407 FILE *v3; // edi@1
|
|
408
|
|
409 v1 = this;
|
|
410 v2 = fopen("data\\dsft.bin", "wb");
|
|
411 v3 = v2;
|
|
412 if ( !v2 )
|
|
413 Abortf("Unable to save dsft.bin!");
|
|
414 fwrite(v1, 4u, 1u, v2);
|
|
415 fwrite(&v1->uNumEFrames, 4u, 1u, v3);
|
|
416 fwrite(v1->pSpriteSFrames, 0x3Cu, v1->uNumSpriteFrames, v3);
|
|
417 fwrite(v1->pSpriteEFrames, 2u, v1->uNumEFrames, v3);
|
|
418 fclose(v3);
|
|
419 }
|
|
420
|
|
421 //----- (0044D9D7) --------------------------------------------------------
|
|
422 void SpriteFrameTable::FromFile(void *pSerialized)
|
|
423 {
|
|
424 //v2 = this;
|
|
425 uNumSpriteFrames = *(int *)pSerialized;
|
|
426 uNumEFrames = *((int *)pSerialized + 1);
|
|
427 //memcpy(this, pSerialized, 4u);
|
|
428 //memcpy(&v2->field_4, (char *)pSerialized + 4, 4u);
|
|
429 pSpriteSFrames = (SpriteFrame *)pAllocator->AllocNamedChunk(pSpriteSFrames, 60 * uNumSpriteFrames, "S Frames");
|
|
430 pSpriteEFrames = (__int16 *)pAllocator->AllocNamedChunk(pSpriteEFrames, 2 * uNumSpriteFrames, "E Frames");
|
|
431 //v3 = pAllocator->AllocNamedChunk(pSpritePFrames, 4 * uNumSpriteFrames, "P Frames");
|
|
432 //v4 = v2->uNumSpriteFrames;
|
|
433 pSpritePFrames = (SpriteFrame **)pAllocator->AllocNamedChunk(pSpritePFrames, 4 * uNumSpriteFrames, "P Frames");
|
|
434 auto uSpriteFramesSize = 60 * uNumSpriteFrames;
|
|
435 memcpy(pSpriteSFrames, (char *)pSerialized + 8, uSpriteFramesSize);
|
|
436 memcpy(pSpriteEFrames, (char *)pSerialized + uSpriteFramesSize + 8, 2 * uNumEFrames);
|
|
437 for (uint i = 0; i < uNumSpriteFrames; ++i)
|
|
438 pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i]];
|
|
439 }
|
|
440
|
|
441 //----- (0044DA92) --------------------------------------------------------
|
|
442 bool SpriteFrameTable::FromFileTxt(const char *Args)
|
|
443 {
|
|
444 SpriteFrameTable *v2; // ebx@1
|
|
445 FILE *v3; // eax@1
|
|
446 unsigned int v4; // esi@3
|
|
447 signed int result; // eax@10
|
|
448 FILE *v6; // ST18_4@11
|
|
449 char *i; // eax@11
|
|
450 const char *v8; // ST20_4@14
|
|
451 __int16 v9; // ax@14
|
|
452 const char *v10; // ST0C_4@14
|
|
453 double v11; // st7@14
|
|
454 int v12; // eax@14
|
|
455 const char *v13; // ST04_4@14
|
|
456 __int16 v14; // ax@14
|
|
457 const char *v15; // ST00_4@14
|
|
458 int v16; // eax@14
|
|
459 int v17; // eax@17
|
|
460 int v18; // eax@23
|
|
461 int v19; // eax@24
|
|
462 int v20; // eax@25
|
|
463 int v21; // eax@28
|
|
464 int v22; // eax@29
|
|
465 int j; // edi@30
|
|
466 const char *v24; // esi@31
|
|
467 int v25; // eax@32
|
|
468 int v26; // edx@53
|
|
469 int v27; // ecx@54
|
|
470 int v28; // eax@55
|
|
471 signed int k; // edx@58
|
|
472 SpriteFrame *v30; // ecx@59
|
|
473 int v31; // esi@59
|
|
474 int l; // eax@60
|
|
475 signed int v33; // eax@65
|
|
476 int v34; // edi@66
|
|
477 int v35; // esi@66
|
|
478 SpriteFrame **v36; // eax@69
|
|
479 int v37; // ecx@69
|
|
480 SpriteFrame *v38; // edx@69
|
|
481 __int16 *v39; // eax@69
|
|
482 int v40; // ecx@69
|
|
483 char Buf[500]; // [sp+Ch] [bp-2F0h]@3
|
|
484 FrameTableTxtLine v42; // [sp+200h] [bp-FCh]@4
|
|
485 FrameTableTxtLine v43; // [sp+27Ch] [bp-80h]@4
|
|
486 FILE *File; // [sp+2F8h] [bp-4h]@1
|
|
487 unsigned int Argsa; // [sp+304h] [bp+8h]@3
|
|
488 int Argsb; // [sp+304h] [bp+8h]@59
|
|
489 FILE *Argsc; // [sp+304h] [bp+8h]@67
|
|
490
|
|
491 v2 = this;
|
|
492 ReleaseSFrames();
|
|
493 v3 = fopen(Args, "r");
|
|
494 File = v3;
|
|
495 if ( !v3 )
|
|
496 Abortf("CSpriteFrameTable::load - Unable to open file: %s.", Args);
|
|
497 v4 = 0;
|
|
498 Argsa = 0;
|
|
499 if ( fgets(Buf, 490, v3) )
|
|
500 {
|
|
501 do
|
|
502 {
|
|
503 *strchr(Buf, '\n') = 0;
|
|
504 memcpy(&v43, frame_table_txt_parser(Buf, &v42), sizeof(v43));
|
|
505 if ( v43.field_0 && *v43.pProperties[0] != '/' )
|
|
506 ++Argsa;
|
|
507 }
|
|
508 while ( fgets(Buf, 490, File) );
|
|
509 v4 = Argsa;
|
|
510 }
|
|
511 v2->uNumSpriteFrames = v4;
|
|
512 v2->pSpriteSFrames = (SpriteFrame *)pAllocator->AllocNamedChunk(v2->pSpriteSFrames, 60 * v4, "S Frames");
|
|
513 v2->pSpriteEFrames = (__int16 *)pAllocator->AllocNamedChunk(
|
|
514 v2->pSpriteEFrames,
|
|
515 2 * v2->uNumSpriteFrames,
|
|
516 "E Frames");
|
|
517 v2->pSpritePFrames = (SpriteFrame **)pAllocator->AllocNamedChunk(
|
|
518 v2->pSpritePFrames,
|
|
519 4 * v2->uNumSpriteFrames,
|
|
520 "P Frames");
|
|
521 if ( v2->pSpriteSFrames )
|
|
522 {
|
|
523 v6 = File;
|
|
524 v2->uNumSpriteFrames = 0;
|
|
525 fseek(v6, 0, 0);
|
|
526 for ( i = fgets(Buf, 490, File); i; i = fgets(Buf, 490, File) )
|
|
527 {
|
|
528 *strchr(Buf, 10) = 0;
|
|
529 memcpy(&v43, frame_table_txt_parser(Buf, &v42), sizeof(v43));
|
|
530 if ( v43.field_0 && *v43.pProperties[0] != '/' )
|
|
531 {
|
|
532 v8 = v43.pProperties[0];
|
|
533 v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags = 0;
|
|
534 v2->pSpriteSFrames[v2->uNumSpriteFrames].uPaletteIndex = 0;
|
|
535 strcpy(v2->pSpriteSFrames[v2->uNumSpriteFrames].pIconName, v8);
|
|
536 strcpy(v2->pSpriteSFrames[v2->uNumSpriteFrames].pTextureName, v43.pProperties[1]);
|
|
537 v9 = atoi(v43.pProperties[3]);
|
|
538 v10 = v43.pProperties[4];
|
|
539 v2->pSpriteSFrames[v2->uNumSpriteFrames].uPaletteID = v9;
|
|
540 v11 = atof(v10) * 65536.0;
|
|
541 v12 = abs((signed __int64)v11);
|
|
542 v13 = v43.pProperties[5];
|
|
543 v2->pSpriteSFrames[v2->uNumSpriteFrames].scale = v12;
|
|
544 v14 = atoi(v13);
|
|
545 v15 = v43.pProperties[6];
|
|
546 v2->pSpriteSFrames[v2->uNumSpriteFrames].uGlowRadius = v14;
|
|
547 v2->pSpriteSFrames[v2->uNumSpriteFrames].uAnimTime = atoi(v15);
|
|
548 v16 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames];
|
|
549 if ( *(short *)(v16 + 48) )
|
|
550 *(int *)(v16 + 44) |= 2u;
|
|
551 if ( !_strcmpi(v43.pProperties[2], "new") )
|
|
552 {
|
|
553 v17 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags;
|
|
554 *(int *)v17 |= 4u;
|
|
555 v2->pSpritePFrames[v2->uNumEFrames] = &v2->pSpriteSFrames[v2->uNumSpriteFrames];
|
|
556 v2->pSpriteEFrames[v2->uNumEFrames++] = LOWORD(v2->uNumSpriteFrames);
|
|
557 }
|
|
558 if ( !_strcmpi(v43.pProperties[10], "1") )
|
|
559 BYTE2(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 4u;
|
|
560 if ( !_strcmpi(v43.pProperties[11], "1") )
|
|
561 BYTE2(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 2u;
|
|
562 if ( !_strcmpi(v43.pProperties[12], "1") )
|
|
563 {
|
|
564 v18 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags;
|
|
565 *(int *)v18 |= 0x20u;
|
|
566 }
|
|
567 v19 = atoi(v43.pProperties[7]) - 1;
|
|
568 if ( v19 )
|
|
569 {
|
|
570 v20 = v19 - 2;
|
|
571 if ( v20 )
|
|
572 {
|
|
573 if ( v20 == 2 )
|
|
574 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 0xE0u;
|
|
575 }
|
|
576 else
|
|
577 {
|
|
578 v21 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags;
|
|
579 *(int *)v21 |= 0x1E000u;
|
|
580 }
|
|
581 }
|
|
582 else
|
|
583 {
|
|
584 v22 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags;
|
|
585 *(int *)v22 |= 0x10u;
|
|
586 }
|
|
587 for ( j = 13; j < v43.field_0; ++j )
|
|
588 {
|
|
589 v24 = v43.pProperties[j];
|
|
590 if ( _strcmpi(v43.pProperties[j], "Luminous") )
|
|
591 {
|
|
592 if ( _strcmpi(v24, "Mirror0") )
|
|
593 {
|
|
594 if ( _strcmpi(v24, "Mirror1") )
|
|
595 {
|
|
596 if ( _strcmpi(v24, "Mirror2") )
|
|
597 {
|
|
598 if ( _strcmpi(v24, "Mirror3") )
|
|
599 {
|
|
600 if ( _strcmpi(v24, "Mirror4") )
|
|
601 {
|
|
602 if ( _strcmpi(v24, "Mirror5") )
|
|
603 {
|
|
604 if ( _strcmpi(v24, "Mirror6") )
|
|
605 {
|
|
606 if ( !_strcmpi(v24, "Mirror7") )
|
|
607 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 0x80u;
|
|
608 }
|
|
609 else
|
|
610 {
|
|
611 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 0x40u;
|
|
612 }
|
|
613 }
|
|
614 else
|
|
615 {
|
|
616 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 0x20u;
|
|
617 }
|
|
618 }
|
|
619 else
|
|
620 {
|
|
621 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 0x10u;
|
|
622 }
|
|
623 }
|
|
624 else
|
|
625 {
|
|
626 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 8u;
|
|
627 }
|
|
628 }
|
|
629 else
|
|
630 {
|
|
631 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 4u;
|
|
632 }
|
|
633 }
|
|
634 else
|
|
635 {
|
|
636 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 2u;
|
|
637 }
|
|
638 }
|
|
639 else
|
|
640 {
|
|
641 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 1u;
|
|
642 }
|
|
643 }
|
|
644 else
|
|
645 {
|
|
646 v25 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags;
|
|
647 *(int *)v25 |= 2u;
|
|
648 }
|
|
649 }
|
|
650 ++v2->uNumSpriteFrames;
|
|
651 }
|
|
652 }
|
|
653 fclose(File);
|
|
654 v26 = 0;
|
|
655 if ( (signed int)(v2->uNumSpriteFrames - 1) > 0 )
|
|
656 {
|
|
657 v27 = 0;
|
|
658 do
|
|
659 {
|
|
660 v28 = (int)&v2->pSpriteSFrames[v27];
|
|
661 if ( !(*(char *)(v28 + 104) & 4) )
|
|
662 *(int *)(v28 + 44) |= 1u;
|
|
663 ++v26;
|
|
664 ++v27;
|
|
665 }
|
|
666 while ( v26 < (signed int)(v2->uNumSpriteFrames - 1) );
|
|
667 }
|
|
668 for ( k = 0; k < (signed int)v2->uNumSpriteFrames; *(short *)(Argsb + 56) = v31 )
|
|
669 {
|
|
670 v30 = v2->pSpriteSFrames;
|
|
671 Argsb = (int)&v30[k];
|
|
672 v31 = *(short *)(Argsb + 54);
|
|
673 if ( *(char *)(Argsb + 44) & 1 )
|
|
674 {
|
|
675 ++k;
|
|
676 for ( l = (int)&v30[k]; *(char *)(l + 44) & 1; l += 60 )
|
|
677 {
|
|
678 v31 += *(short *)(l + 54);
|
|
679 ++k;
|
|
680 }
|
|
681 LOWORD(v31) = v30[k].uAnimTime + v31;
|
|
682 }
|
|
683 ++k;
|
|
684 }
|
|
685 v33 = v2->uNumEFrames;
|
|
686 if ( v33 > 0 )
|
|
687 {
|
|
688 v34 = 0;
|
|
689 v35 = 0;
|
|
690 File = (FILE *)1;
|
|
691 do
|
|
692 {
|
|
693 Argsc = File;
|
|
694 if ( (signed int)File < v33 )
|
|
695 {
|
|
696 do
|
|
697 {
|
|
698 if ( _strcmpi(v2->pSpritePFrames[(int)Argsc]->pIconName, v2->pSpritePFrames[v35]->pIconName) < 0 )
|
|
699 {
|
|
700 v36 = v2->pSpritePFrames;
|
|
701 v37 = (int)&v36[(int)Argsc];
|
|
702 v38 = *(SpriteFrame **)v37;
|
|
703 *(int *)v37 = (int)v36[v35];
|
|
704 v2->pSpritePFrames[v35] = v38;
|
|
705 v39 = v2->pSpriteEFrames;
|
|
706 v40 = (int)&v39[(int)Argsc];
|
|
707 LOWORD(v38) = *(short *)v40;
|
|
708 *(short *)v40 = v39[v34];
|
|
709 v2->pSpriteEFrames[v34] = (signed __int16)v38;
|
|
710 }
|
|
711 Argsc = (FILE *)((char *)Argsc + 1);
|
|
712 }
|
|
713 while ( (signed int)Argsc < v2->uNumEFrames );
|
|
714 }
|
|
715 File = (FILE *)((char *)File + 1);
|
|
716 v33 = v2->uNumEFrames;
|
|
717 ++v35;
|
|
718 ++v34;
|
|
719 }
|
|
720 while ( (signed int)((char *)File - 1) < v33 );
|
|
721 }
|
|
722 result = 1;
|
|
723 }
|
|
724 else
|
|
725 {
|
|
726 MessageBoxW(nullptr, L"CSpriteFrameTable::load - Out of Memory!", nullptr, 0);
|
|
727 fclose(File);
|
|
728 result = 0;
|
|
729 }
|
|
730 return result;
|
|
731 } |