annotate Sprites.cpp @ 1162:79fd2fb7a3ab

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