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