annotate Sprites.cpp @ 810:f5156b8c61ad

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