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