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