annotate Sprites.cpp @ 319:5a66be213cff

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