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