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