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