annotate Sprites.cpp @ 2317:345b1ff000bb

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