annotate LOD.cpp @ 764:90bcfb56c8f9

sound cleaning
author Gloval
date Sat, 23 Mar 2013 21:39:21 +0400
parents 225d92620998
children cf2fbac6edc9
rev   line source
0
Ritor1
parents:
diff changeset
1 #include "LOD.h"
Ritor1
parents:
diff changeset
2 #include "Render.h"
Ritor1
parents:
diff changeset
3 #include "Allocator.h"
Ritor1
parents:
diff changeset
4 #include "PaletteManager.h"
Ritor1
parents:
diff changeset
5 #include "Viewport.h"
Ritor1
parents:
diff changeset
6 #include "Log.h"
Ritor1
parents:
diff changeset
7
Ritor1
parents:
diff changeset
8 #include "mm7_data.h"
Ritor1
parents:
diff changeset
9
Ritor1
parents:
diff changeset
10
Ritor1
parents:
diff changeset
11
Ritor1
parents:
diff changeset
12
Ritor1
parents:
diff changeset
13
Ritor1
parents:
diff changeset
14
Ritor1
parents:
diff changeset
15
Ritor1
parents:
diff changeset
16 LODFile_IconsBitmaps *pEvents_LOD;
Ritor1
parents:
diff changeset
17 LODFile_IconsBitmaps *pIcons_LOD;
Ritor1
parents:
diff changeset
18 LODFile_Sprites *pSprites_LOD;
Ritor1
parents:
diff changeset
19 LODFile_IconsBitmaps *pBitmaps_LOD;
Ritor1
parents:
diff changeset
20
Ritor1
parents:
diff changeset
21 LODWriteableFile *pNew_LOD;
Ritor1
parents:
diff changeset
22 LODWriteableFile *pGames_LOD;
Ritor1
parents:
diff changeset
23
Ritor1
parents:
diff changeset
24
Ritor1
parents:
diff changeset
25
Ritor1
parents:
diff changeset
26
Ritor1
parents:
diff changeset
27 int _6A0CA4_lod_binary_search; // weak
Ritor1
parents:
diff changeset
28 int _6A0CA8_lod_unused; // weak
Ritor1
parents:
diff changeset
29
Ritor1
parents:
diff changeset
30
Ritor1
parents:
diff changeset
31
Ritor1
parents:
diff changeset
32
Ritor1
parents:
diff changeset
33
Ritor1
parents:
diff changeset
34 //----- (004355F7) --------------------------------------------------------
Ritor1
parents:
diff changeset
35 void LODFile_IconsBitmaps::_4355F7()
Ritor1
parents:
diff changeset
36 {
Ritor1
parents:
diff changeset
37 LODFile_IconsBitmaps *v1; // esi@1
Ritor1
parents:
diff changeset
38 int v2; // edi@2
Ritor1
parents:
diff changeset
39 Texture *v3; // ebp@3
Ritor1
parents:
diff changeset
40 struct IDirect3DTexture2 **v4; // eax@4
Ritor1
parents:
diff changeset
41 struct IDirect3DTexture2 *v5; // eax@5
Ritor1
parents:
diff changeset
42 struct IDirectDrawSurface **v6; // eax@7
Ritor1
parents:
diff changeset
43 struct IDirectDrawSurface *v7; // eax@8
Ritor1
parents:
diff changeset
44 int v8; // eax@11
Ritor1
parents:
diff changeset
45
Ritor1
parents:
diff changeset
46 v1 = this;
Ritor1
parents:
diff changeset
47 if ( this->uTexturePacksCount )
Ritor1
parents:
diff changeset
48 {
Ritor1
parents:
diff changeset
49 v2 = this->uNumLoadedFiles - 1;
Ritor1
parents:
diff changeset
50 if ( v2 >= this->uNumPrevLoadedFiles )
Ritor1
parents:
diff changeset
51 {
Ritor1
parents:
diff changeset
52 v3 = &this->pTextures[v2];
Ritor1
parents:
diff changeset
53 do
Ritor1
parents:
diff changeset
54 {
Ritor1
parents:
diff changeset
55 v3->Release();
Ritor1
parents:
diff changeset
56 v4 = v1->pHardwareTextures;
Ritor1
parents:
diff changeset
57 if ( v4 )
Ritor1
parents:
diff changeset
58 {
Ritor1
parents:
diff changeset
59 v5 = v4[v2];
Ritor1
parents:
diff changeset
60 if ( v5 )
Ritor1
parents:
diff changeset
61 {
Ritor1
parents:
diff changeset
62 v5->Release();
Ritor1
parents:
diff changeset
63 v1->pHardwareTextures[v2] = 0;
Ritor1
parents:
diff changeset
64 }
Ritor1
parents:
diff changeset
65 }
Ritor1
parents:
diff changeset
66 v6 = v1->pHardwareSurfaces;
Ritor1
parents:
diff changeset
67 if ( v6 )
Ritor1
parents:
diff changeset
68 {
Ritor1
parents:
diff changeset
69 v7 = v6[v2];
Ritor1
parents:
diff changeset
70 if ( v7 )
Ritor1
parents:
diff changeset
71 {
Ritor1
parents:
diff changeset
72 v7->Release();
Ritor1
parents:
diff changeset
73 v1->pHardwareSurfaces[v2] = 0;
Ritor1
parents:
diff changeset
74 }
Ritor1
parents:
diff changeset
75 }
Ritor1
parents:
diff changeset
76 --v2;
Ritor1
parents:
diff changeset
77 --v3;
Ritor1
parents:
diff changeset
78 }
Ritor1
parents:
diff changeset
79 while ( v2 >= v1->uNumPrevLoadedFiles );
Ritor1
parents:
diff changeset
80 }
Ritor1
parents:
diff changeset
81 v8 = v1->uNumPrevLoadedFiles;
Ritor1
parents:
diff changeset
82 v1->uNumPrevLoadedFiles = 0;
Ritor1
parents:
diff changeset
83 v1->uNumLoadedFiles = v8;
Ritor1
parents:
diff changeset
84 v1->uTexturePacksCount = 0;
Ritor1
parents:
diff changeset
85 }
Ritor1
parents:
diff changeset
86 }
Ritor1
parents:
diff changeset
87
Ritor1
parents:
diff changeset
88 //----- (004114F2) --------------------------------------------------------
Ritor1
parents:
diff changeset
89 void LODFile_IconsBitmaps::_4114F2()
Ritor1
parents:
diff changeset
90 {
Ritor1
parents:
diff changeset
91 LODFile_IconsBitmaps *v1; // esi@1
Ritor1
parents:
diff changeset
92 int *pTexturePacksCount; // eax@1
Ritor1
parents:
diff changeset
93 int v3; // ecx@1
Ritor1
parents:
diff changeset
94 int v4; // ecx@2
Ritor1
parents:
diff changeset
95 int v5; // edi@3
Ritor1
parents:
diff changeset
96 Texture *v6; // ebx@4
Ritor1
parents:
diff changeset
97 struct IDirect3DTexture2 **v7; // eax@5
Ritor1
parents:
diff changeset
98 struct IDirect3DTexture2 *v8; // eax@6
Ritor1
parents:
diff changeset
99 struct IDirectDrawSurface **v9; // eax@8
Ritor1
parents:
diff changeset
100 struct IDirectDrawSurface *v10; // eax@9
Ritor1
parents:
diff changeset
101 int v11; // eax@12
Ritor1
parents:
diff changeset
102
Ritor1
parents:
diff changeset
103 v1 = this;
Ritor1
parents:
diff changeset
104 pTexturePacksCount = &this->uTexturePacksCount;
Ritor1
parents:
diff changeset
105 v3 = this->uTexturePacksCount;
Ritor1
parents:
diff changeset
106 if ( v3 )
Ritor1
parents:
diff changeset
107 {
Ritor1
parents:
diff changeset
108 v4 = v3 - 1;
Ritor1
parents:
diff changeset
109 *pTexturePacksCount = v4;
Ritor1
parents:
diff changeset
110 if ( !v4 )
Ritor1
parents:
diff changeset
111 {
Ritor1
parents:
diff changeset
112 v5 = v1->uNumLoadedFiles - 1;
Ritor1
parents:
diff changeset
113 if ( v5 >= v1->uNumPrevLoadedFiles )
Ritor1
parents:
diff changeset
114 {
Ritor1
parents:
diff changeset
115 v6 = &v1->pTextures[v5];
Ritor1
parents:
diff changeset
116 do
Ritor1
parents:
diff changeset
117 {
Ritor1
parents:
diff changeset
118 v6->Release();
Ritor1
parents:
diff changeset
119 v7 = v1->pHardwareTextures;
Ritor1
parents:
diff changeset
120 if ( v7 )
Ritor1
parents:
diff changeset
121 {
Ritor1
parents:
diff changeset
122 v8 = v7[v5];
Ritor1
parents:
diff changeset
123 if ( v8 )
Ritor1
parents:
diff changeset
124 {
Ritor1
parents:
diff changeset
125 v8->Release();
Ritor1
parents:
diff changeset
126 v1->pHardwareTextures[v5] = 0;
Ritor1
parents:
diff changeset
127 }
Ritor1
parents:
diff changeset
128 }
Ritor1
parents:
diff changeset
129 v9 = v1->pHardwareSurfaces;
Ritor1
parents:
diff changeset
130 if ( v9 )
Ritor1
parents:
diff changeset
131 {
Ritor1
parents:
diff changeset
132 v10 = v9[v5];
Ritor1
parents:
diff changeset
133 if ( v10 )
Ritor1
parents:
diff changeset
134 {
Ritor1
parents:
diff changeset
135 v10->Release();
Ritor1
parents:
diff changeset
136 v1->pHardwareSurfaces[v5] = 0;
Ritor1
parents:
diff changeset
137 }
Ritor1
parents:
diff changeset
138 }
Ritor1
parents:
diff changeset
139 --v5;
Ritor1
parents:
diff changeset
140 --v6;
Ritor1
parents:
diff changeset
141 }
Ritor1
parents:
diff changeset
142 while ( v5 >= v1->uNumPrevLoadedFiles );
Ritor1
parents:
diff changeset
143 }
Ritor1
parents:
diff changeset
144 v11 = v1->uNumPrevLoadedFiles;
Ritor1
parents:
diff changeset
145 v1->uNumPrevLoadedFiles = 0;
Ritor1
parents:
diff changeset
146 v1->uNumLoadedFiles = v11;
Ritor1
parents:
diff changeset
147 }
Ritor1
parents:
diff changeset
148 }
Ritor1
parents:
diff changeset
149 }
Ritor1
parents:
diff changeset
150
Ritor1
parents:
diff changeset
151 //----- (004AC67E) --------------------------------------------------------
Ritor1
parents:
diff changeset
152 int LODFile_Sprites::LoadSpriteFromFile(LODSprite *pSpriteHeader, const char *pContainer)
Ritor1
parents:
diff changeset
153 {
Ritor1
parents:
diff changeset
154 FILE *v3; // eax@1
Ritor1
parents:
diff changeset
155 FILE *v4; // ebx@1
Ritor1
parents:
diff changeset
156 int result; // eax@2
Ritor1
parents:
diff changeset
157 LODSprite *v6; // esi@3
Ritor1
parents:
diff changeset
158 LODSprite_stru0 *v7; // eax@3
Ritor1
parents:
diff changeset
159 size_t v8; // ST10_4@3
Ritor1
parents:
diff changeset
160 int *v9; // ebx@3
Ritor1
parents:
diff changeset
161 int v10; // eax@3
Ritor1
parents:
diff changeset
162 void *v11; // eax@5
Ritor1
parents:
diff changeset
163 LODSprite_stru0 *v12; // eax@6
Ritor1
parents:
diff changeset
164 void *v13; // ecx@6
Ritor1
parents:
diff changeset
165 LODSprite_stru0 *i; // edx@6
Ritor1
parents:
diff changeset
166 FILE *File; // [sp+4h] [bp-4h]@1
Ritor1
parents:
diff changeset
167 void *DstBufa; // [sp+10h] [bp+8h]@4
Ritor1
parents:
diff changeset
168 int Sizea; // [sp+14h] [bp+Ch]@3
Ritor1
parents:
diff changeset
169
Ritor1
parents:
diff changeset
170 v3 = FindContainer(pContainer, 0);
Ritor1
parents:
diff changeset
171 v4 = v3;
Ritor1
parents:
diff changeset
172 File = v3;
Ritor1
parents:
diff changeset
173 if ( v3 )
Ritor1
parents:
diff changeset
174 {
Ritor1
parents:
diff changeset
175 v6 = pSpriteHeader;
Ritor1
parents:
diff changeset
176 fread(pSpriteHeader, 1u, 0x20u, v3);
Ritor1
parents:
diff changeset
177 strcpy(pSpriteHeader->pName, pContainer);
Ritor1
parents:
diff changeset
178 Sizea = pSpriteHeader->uSpriteSize;
Ritor1
parents:
diff changeset
179 v7 = (LODSprite_stru0 *)pAllocator->AllocNamedChunk(v6->pSpriteLines, 8 * v6->uHeight, v6->pName);
Ritor1
parents:
diff changeset
180 v8 = 8 * pSpriteHeader->uHeight;
Ritor1
parents:
diff changeset
181 pSpriteHeader->pSpriteLines = v7;
Ritor1
parents:
diff changeset
182 fread(v7, 1u, v8, v4);
Ritor1
parents:
diff changeset
183 v9 = &pSpriteHeader->uDecompressedSize;
Ritor1
parents:
diff changeset
184 v10 = pSpriteHeader->uDecompressedSize;
Ritor1
parents:
diff changeset
185 if ( v10 )
Ritor1
parents:
diff changeset
186 {
Ritor1
parents:
diff changeset
187 pSpriteHeader->pDecompressedBytes = pAllocator->AllocNamedChunk(
Ritor1
parents:
diff changeset
188 pSpriteHeader->pDecompressedBytes,
Ritor1
parents:
diff changeset
189 v10,
Ritor1
parents:
diff changeset
190 pSpriteHeader->pName);
Ritor1
parents:
diff changeset
191 DstBufa = pAllocator->AllocNamedChunk(0, Sizea, pSpriteHeader->pName);
Ritor1
parents:
diff changeset
192 fread(DstBufa, 1u, Sizea, File);
Ritor1
parents:
diff changeset
193 zlib::MemUnzip(v6->pDecompressedBytes, (unsigned int *)&v6->uDecompressedSize, DstBufa, v6->uSpriteSize);
Ritor1
parents:
diff changeset
194 v6->uSpriteSize = *v9;
Ritor1
parents:
diff changeset
195 pAllocator->FreeChunk(DstBufa);
Ritor1
parents:
diff changeset
196 }
Ritor1
parents:
diff changeset
197 else
Ritor1
parents:
diff changeset
198 {
Ritor1
parents:
diff changeset
199 v11 = pAllocator->AllocNamedChunk(pSpriteHeader->pDecompressedBytes, Sizea, pSpriteHeader->pName);
Ritor1
parents:
diff changeset
200 pSpriteHeader->pDecompressedBytes = v11;
Ritor1
parents:
diff changeset
201 fread(v11, 1u, Sizea, File);
Ritor1
parents:
diff changeset
202 }
Ritor1
parents:
diff changeset
203 v12 = v6->pSpriteLines;
Ritor1
parents:
diff changeset
204 v13 = v6->pDecompressedBytes;
Ritor1
parents:
diff changeset
205 for ( i = &v12[v6->uHeight]; v12 < i; i = &v6->pSpriteLines[v6->uHeight] )
Ritor1
parents:
diff changeset
206 {
Ritor1
parents:
diff changeset
207 v12->ptr_4 = (char *)v12->ptr_4 + (unsigned int)v13;
Ritor1
parents:
diff changeset
208 ++v12;
Ritor1
parents:
diff changeset
209 }
Ritor1
parents:
diff changeset
210 result = 1;
Ritor1
parents:
diff changeset
211 }
Ritor1
parents:
diff changeset
212 else
Ritor1
parents:
diff changeset
213 {
Ritor1
parents:
diff changeset
214 result = -1;
Ritor1
parents:
diff changeset
215 }
Ritor1
parents:
diff changeset
216 return result;
Ritor1
parents:
diff changeset
217 }
Ritor1
parents:
diff changeset
218
Ritor1
parents:
diff changeset
219 //----- (004AC795) --------------------------------------------------------
Ritor1
parents:
diff changeset
220 bool LODFile_Sprites::LoadSprites(const char *pFilename)
Ritor1
parents:
diff changeset
221 {
Ritor1
parents:
diff changeset
222 if (LoadHeader(pFilename, 1))
Ritor1
parents:
diff changeset
223 return false;
Ritor1
parents:
diff changeset
224 else
Ritor1
parents:
diff changeset
225 return LoadSubIndices("sprites08") == 0;
Ritor1
parents:
diff changeset
226 }
Ritor1
parents:
diff changeset
227
Ritor1
parents:
diff changeset
228 //----- (004AC7C0) --------------------------------------------------------
Ritor1
parents:
diff changeset
229 int LODFile_Sprites::LoadSprite(const char *pContainerName, unsigned int uPaletteID)
670
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
230 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
231
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
232 FILE *sprite_file; // eax@12
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
233 LODSprite temp_sprite_hdr; // [sp+Ch] [bp-3Ch]@12
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
234 int i, sprite_indx;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
235
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
236 //find if already loaded
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
237 if ( pRenderer->pRenderD3D )
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
238 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
239 for (i=0; i<uNumLoadedSprites;++i)
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
240 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
241 if (!(_strcmpi(pHardwareSprites[i].pName, pContainerName)))
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
242 return i;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
243 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
244 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
245 else
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
246 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
247 for (i=0; i<uNumLoadedSprites;++i)
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
248 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
249 if (!(_strcmpi(pSpriteHeaders[i].pName, pContainerName)))
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
250 return i;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
251 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
252 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
253
700
1d05543f522d Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents: 670
diff changeset
254 if (uNumLoadedSprites >= 1500 )
670
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
255 return -1;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
256 //if not loaded - load from file
0
Ritor1
parents:
diff changeset
257
670
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
258 if ( pRenderer->pRenderD3D && field_ECAC )
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
259 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
260 if ( !pHardwareSprites )
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
261 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
262 pHardwareSprites = (Sprite *)pAllocator->AllocNamedChunk(0, 1500*sizeof(Sprite) , "hardSprites");//0xEA60u
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
263 for (i=0; i<1500;++i)
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
264 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
265 pHardwareSprites[i].pName=NULL;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
266 pHardwareSprites[i].pTextureSurface=NULL;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
267 pHardwareSprites[i].pTexture=NULL;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
268 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
269 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
270 temp_sprite_hdr.uHeight = 0;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
271 temp_sprite_hdr.uPaletteId = 0;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
272 temp_sprite_hdr.word_1A = 0;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
273 temp_sprite_hdr.pSpriteLines = 0;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
274 temp_sprite_hdr.pDecompressedBytes = 0;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
275 sprite_file = FindContainer(pContainerName, 0);
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
276 if ( !sprite_file )
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
277 return -1;
700
1d05543f522d Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents: 670
diff changeset
278 //fread(&temp_sprite_hdr, 1, sizeof(LODSprite), sprite_file);
1d05543f522d Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents: 670
diff changeset
279 fread(&temp_sprite_hdr, 1, 0x20, sprite_file);
670
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
280 pHardwareSprites[uNumLoadedSprites].uBufferWidth = temp_sprite_hdr.uWidth;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
281 pHardwareSprites[uNumLoadedSprites].uBufferHeight = temp_sprite_hdr.uHeight;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
282 pSpriteHeaders[uNumLoadedSprites].uWidth = temp_sprite_hdr.uWidth;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
283 pSpriteHeaders[uNumLoadedSprites].uHeight = temp_sprite_hdr.uHeight;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
284 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
285 else
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
286 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
287 sprite_indx = LoadSpriteFromFile( &pSpriteHeaders[uNumLoadedSprites], pContainerName);
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
288 pSpriteHeaders[uNumLoadedSprites].word_1A = 0;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
289
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
290 if ( sprite_indx != -1 )
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
291 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
292 pSpriteHeaders[uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId);
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
293 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
294 else
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
295 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
296 if ( uNumLoadedSprites<=0 )
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
297 uNumLoadedSprites=0;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
298 else
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
299 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
300 for (i=0; i<uNumLoadedSprites;++i)
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
301 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
302 if (!(_strcmpi(pSpriteHeaders[i].pName, "pending")))
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
303 return i;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
304 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
305 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
306 if ( LoadSpriteFromFile(&pSpriteHeaders[uNumLoadedSprites], "pending") == -1 )
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
307 return -1;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
308 pSpriteHeaders[uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId);
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
309 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
310 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
311
0
Ritor1
parents:
diff changeset
312 if ( pRenderer->pRenderD3D )
670
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
313 {
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
314 pHardwareSprites[uNumLoadedSprites].pName = (const char *)pAllocator->AllocNamedChunk(pHardwareSprites[uNumLoadedSprites].pName, 20, pContainerName);
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
315 strcpy((char *)pHardwareSprites[uNumLoadedSprites].pName, pContainerName);
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
316 pHardwareSprites[uNumLoadedSprites].uPaletteID = uPaletteID;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
317 pRenderer->MoveSpriteToDevice(&pHardwareSprites[uNumLoadedSprites]);
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
318 }
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
319 ++uNumLoadedSprites;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
320 return uNumLoadedSprites - 1;
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
321
9824e2eeee30 fixed decorations animation
Gloval
parents: 649
diff changeset
322 }
0
Ritor1
parents:
diff changeset
323
Ritor1
parents:
diff changeset
324 //----- (004ACADA) --------------------------------------------------------
Ritor1
parents:
diff changeset
325 void LODFile_Sprites::ReleaseLostHardwareSprites()
Ritor1
parents:
diff changeset
326 {
Ritor1
parents:
diff changeset
327 LODFile_Sprites *v1; // esi@1
Ritor1
parents:
diff changeset
328 signed int v2; // ebx@2
Ritor1
parents:
diff changeset
329 int v3; // edi@3
Ritor1
parents:
diff changeset
330 IDirectDrawSurface *v4; // eax@4
Ritor1
parents:
diff changeset
331 IDirect3DTexture2 *v5; // eax@6
Ritor1
parents:
diff changeset
332 IDirectDrawSurface *v6; // ST00_4@8
Ritor1
parents:
diff changeset
333
Ritor1
parents:
diff changeset
334 v1 = this;
Ritor1
parents:
diff changeset
335 if ( this->pHardwareSprites )
Ritor1
parents:
diff changeset
336 {
Ritor1
parents:
diff changeset
337 v2 = 0;
Ritor1
parents:
diff changeset
338 if ( (signed int)this->uNumLoadedSprites > 0 )
Ritor1
parents:
diff changeset
339 {
Ritor1
parents:
diff changeset
340 v3 = 0;
Ritor1
parents:
diff changeset
341 do
Ritor1
parents:
diff changeset
342 {
Ritor1
parents:
diff changeset
343 v4 = (IDirectDrawSurface *)v1->pHardwareSprites[v3].pTextureSurface;
Ritor1
parents:
diff changeset
344 if ( v4 && v4->IsLost() == DDERR_SURFACELOST )
Ritor1
parents:
diff changeset
345 {
Ritor1
parents:
diff changeset
346 v5 = v1->pHardwareSprites[v3].pTexture;
Ritor1
parents:
diff changeset
347 if ( v5 )
Ritor1
parents:
diff changeset
348 {
Ritor1
parents:
diff changeset
349 v5->Release();
Ritor1
parents:
diff changeset
350 v1->pHardwareSprites[v3].pTexture = 0;
Ritor1
parents:
diff changeset
351 }
Ritor1
parents:
diff changeset
352 v6 = (IDirectDrawSurface *)v1->pHardwareSprites[v3].pTextureSurface;
Ritor1
parents:
diff changeset
353 v6->Release();
Ritor1
parents:
diff changeset
354 v1->pHardwareSprites[v3].pTextureSurface = 0;
Ritor1
parents:
diff changeset
355 pRenderer->MoveSpriteToDevice(&v1->pHardwareSprites[v3]);
Ritor1
parents:
diff changeset
356 }
Ritor1
parents:
diff changeset
357 ++v2;
Ritor1
parents:
diff changeset
358 ++v3;
Ritor1
parents:
diff changeset
359 }
Ritor1
parents:
diff changeset
360 while ( v2 < (signed int)v1->uNumLoadedSprites );
Ritor1
parents:
diff changeset
361 }
Ritor1
parents:
diff changeset
362 }
Ritor1
parents:
diff changeset
363 }
Ritor1
parents:
diff changeset
364
Ritor1
parents:
diff changeset
365 //----- (004ACB70) --------------------------------------------------------
Ritor1
parents:
diff changeset
366 void LODFile_Sprites::ReleaseAll()
Ritor1
parents:
diff changeset
367 {
Ritor1
parents:
diff changeset
368 LODFile_Sprites *v1; // esi@1
Ritor1
parents:
diff changeset
369 signed int v2; // ebx@2
Ritor1
parents:
diff changeset
370 int v3; // edi@3
Ritor1
parents:
diff changeset
371 Sprite *v4; // eax@4
Ritor1
parents:
diff changeset
372 IDirect3DTexture2 *v5; // eax@5
Ritor1
parents:
diff changeset
373 Sprite *v6; // eax@7
Ritor1
parents:
diff changeset
374 IDirectDrawSurface *v7; // eax@8
Ritor1
parents:
diff changeset
375
Ritor1
parents:
diff changeset
376 v1 = this;
Ritor1
parents:
diff changeset
377 if ( this->pHardwareSprites )
Ritor1
parents:
diff changeset
378 {
Ritor1
parents:
diff changeset
379 v2 = 0;
Ritor1
parents:
diff changeset
380 if ( (signed int)this->uNumLoadedSprites > 0 )
Ritor1
parents:
diff changeset
381 {
Ritor1
parents:
diff changeset
382 v3 = 0;
Ritor1
parents:
diff changeset
383 do
Ritor1
parents:
diff changeset
384 {
Ritor1
parents:
diff changeset
385 v4 = v1->pHardwareSprites;
Ritor1
parents:
diff changeset
386 if ( v4 )
Ritor1
parents:
diff changeset
387 {
Ritor1
parents:
diff changeset
388 v5 = v4[v3].pTexture;
Ritor1
parents:
diff changeset
389 if ( v5 )
Ritor1
parents:
diff changeset
390 {
Ritor1
parents:
diff changeset
391 v5->Release();
Ritor1
parents:
diff changeset
392 v1->pHardwareSprites[v3].pTexture = 0;
Ritor1
parents:
diff changeset
393 }
Ritor1
parents:
diff changeset
394 v6 = v1->pHardwareSprites;
Ritor1
parents:
diff changeset
395 if ( v6 )
Ritor1
parents:
diff changeset
396 {
Ritor1
parents:
diff changeset
397 v7 = (IDirectDrawSurface *)v6[v3].pTextureSurface;
Ritor1
parents:
diff changeset
398 if ( v7 )
Ritor1
parents:
diff changeset
399 {
Ritor1
parents:
diff changeset
400 v7->Release();
Ritor1
parents:
diff changeset
401 v1->pHardwareSprites[v3].pTextureSurface = 0;
Ritor1
parents:
diff changeset
402 }
Ritor1
parents:
diff changeset
403 }
Ritor1
parents:
diff changeset
404 }
Ritor1
parents:
diff changeset
405 ++v2;
Ritor1
parents:
diff changeset
406 ++v3;
Ritor1
parents:
diff changeset
407 }
Ritor1
parents:
diff changeset
408 while ( v2 < (signed int)v1->uNumLoadedSprites );
Ritor1
parents:
diff changeset
409 }
Ritor1
parents:
diff changeset
410 }
Ritor1
parents:
diff changeset
411 }
Ritor1
parents:
diff changeset
412
Ritor1
parents:
diff changeset
413 //----- (004ACBE0) --------------------------------------------------------
Ritor1
parents:
diff changeset
414 void LODFile_Sprites::MoveSpritesToVideoMemory()
Ritor1
parents:
diff changeset
415 {
Ritor1
parents:
diff changeset
416 LODFile_Sprites *v1; // esi@1
Ritor1
parents:
diff changeset
417 int v2; // ebx@1
Ritor1
parents:
diff changeset
418 signed int v3; // edi@2
Ritor1
parents:
diff changeset
419
Ritor1
parents:
diff changeset
420 v1 = this;
Ritor1
parents:
diff changeset
421 v2 = 0;
Ritor1
parents:
diff changeset
422 if ( this->pHardwareSprites )
Ritor1
parents:
diff changeset
423 {
Ritor1
parents:
diff changeset
424 v3 = 0;
Ritor1
parents:
diff changeset
425 if ( (signed int)this->uNumLoadedSprites > 0 )
Ritor1
parents:
diff changeset
426 {
Ritor1
parents:
diff changeset
427 do
Ritor1
parents:
diff changeset
428 {
Ritor1
parents:
diff changeset
429 pRenderer->MoveSpriteToDevice(&v1->pHardwareSprites[v2]);
Ritor1
parents:
diff changeset
430 ++v3;
Ritor1
parents:
diff changeset
431 ++v2;
Ritor1
parents:
diff changeset
432 }
Ritor1
parents:
diff changeset
433 while ( v3 < (signed int)v1->uNumLoadedSprites );
Ritor1
parents:
diff changeset
434 }
Ritor1
parents:
diff changeset
435 }
Ritor1
parents:
diff changeset
436 }
Ritor1
parents:
diff changeset
437
Ritor1
parents:
diff changeset
438 //----- (004ACC38) --------------------------------------------------------
733
700b58aac975 MonsterPopup preview doll fixed
Nomad
parents: 710
diff changeset
439 int LODSprite::DrawSprite_sw(RenderBillboardTransform_local0 *a2, char a3)
0
Ritor1
parents:
diff changeset
440 {
Ritor1
parents:
diff changeset
441 RenderBillboardTransform_local0 *v3; // edi@1
Ritor1
parents:
diff changeset
442 int result; // eax@1
Ritor1
parents:
diff changeset
443 int v5; // esi@2
Ritor1
parents:
diff changeset
444 int v6; // ST18_4@2
Ritor1
parents:
diff changeset
445 signed int v7; // eax@2
Ritor1
parents:
diff changeset
446 signed int v8; // ebx@2
Ritor1
parents:
diff changeset
447 int v9; // ebx@2
Ritor1
parents:
diff changeset
448 int *v10; // ecx@2
Ritor1
parents:
diff changeset
449 int v11; // esi@2
Ritor1
parents:
diff changeset
450 unsigned int v12; // edx@4
Ritor1
parents:
diff changeset
451 int v13; // esi@13
Ritor1
parents:
diff changeset
452 int v14; // esi@17
Ritor1
parents:
diff changeset
453 int v15; // ecx@17
Ritor1
parents:
diff changeset
454 char *v16; // edx@17
Ritor1
parents:
diff changeset
455 int v17; // esi@17
Ritor1
parents:
diff changeset
456 int v18; // ecx@18
Ritor1
parents:
diff changeset
457 int v19; // esi@18
Ritor1
parents:
diff changeset
458 LODSprite_stru0 *v20; // edx@21
Ritor1
parents:
diff changeset
459 int v21; // eax@22
Ritor1
parents:
diff changeset
460 int v22; // esi@22
Ritor1
parents:
diff changeset
461 int v23; // eax@25
Ritor1
parents:
diff changeset
462 int v24; // ecx@25
Ritor1
parents:
diff changeset
463 signed __int64 v25; // qtt@27
Ritor1
parents:
diff changeset
464 int v26; // eax@27
Ritor1
parents:
diff changeset
465 unsigned __int16 *v27; // eax@29
Ritor1
parents:
diff changeset
466 LODSprite_stru0 *v28; // edx@29
Ritor1
parents:
diff changeset
467 signed int v29; // ecx@30
Ritor1
parents:
diff changeset
468 int v30; // ecx@37
Ritor1
parents:
diff changeset
469 int v31; // ecx@38
Ritor1
parents:
diff changeset
470 signed int v32; // ecx@41
Ritor1
parents:
diff changeset
471 int v33; // ecx@47
Ritor1
parents:
diff changeset
472 int v34; // ecx@56
Ritor1
parents:
diff changeset
473 int v35; // esi@58
Ritor1
parents:
diff changeset
474 __int16 v36; // ax@58
Ritor1
parents:
diff changeset
475 int v37; // ecx@59
Ritor1
parents:
diff changeset
476 int v38; // eax@59
Ritor1
parents:
diff changeset
477 int v39; // ecx@62
Ritor1
parents:
diff changeset
478 signed int v40; // ST30_4@64
Ritor1
parents:
diff changeset
479 signed __int64 v41; // qtt@64
Ritor1
parents:
diff changeset
480 int v42; // ecx@64
Ritor1
parents:
diff changeset
481 unsigned __int16 *v43; // eax@66
Ritor1
parents:
diff changeset
482 LODSprite_stru0 *v44; // ecx@66
Ritor1
parents:
diff changeset
483 int v45; // edx@69
Ritor1
parents:
diff changeset
484 int v46; // edx@77
Ritor1
parents:
diff changeset
485 unsigned __int16 *pTarget; // [sp+Ch] [bp-50h]@2
Ritor1
parents:
diff changeset
486 signed int v48; // [sp+10h] [bp-4Ch]@2
Ritor1
parents:
diff changeset
487 signed int v49; // [sp+14h] [bp-48h]@2
Ritor1
parents:
diff changeset
488 int v50; // [sp+14h] [bp-48h]@19
Ritor1
parents:
diff changeset
489 int v51; // [sp+14h] [bp-48h]@57
Ritor1
parents:
diff changeset
490 int v52; // [sp+18h] [bp-44h]@13
Ritor1
parents:
diff changeset
491 int v53; // [sp+1Ch] [bp-40h]@2
Ritor1
parents:
diff changeset
492 int v54; // [sp+1Ch] [bp-40h]@22
Ritor1
parents:
diff changeset
493 int v55; // [sp+1Ch] [bp-40h]@32
Ritor1
parents:
diff changeset
494 int v56; // [sp+1Ch] [bp-40h]@69
Ritor1
parents:
diff changeset
495 int v57; // [sp+20h] [bp-3Ch]@2
Ritor1
parents:
diff changeset
496 int v58; // [sp+24h] [bp-38h]@1
Ritor1
parents:
diff changeset
497 int v59; // [sp+28h] [bp-34h]@2
Ritor1
parents:
diff changeset
498 int v60; // [sp+28h] [bp-34h]@13
Ritor1
parents:
diff changeset
499 unsigned __int16 *v61; // [sp+2Ch] [bp-30h]@2
Ritor1
parents:
diff changeset
500 int v62; // [sp+30h] [bp-2Ch]@2
Ritor1
parents:
diff changeset
501 void *v63; // [sp+30h] [bp-2Ch]@29
Ritor1
parents:
diff changeset
502 void *v64; // [sp+30h] [bp-2Ch]@66
Ritor1
parents:
diff changeset
503 int v65; // [sp+34h] [bp-28h]@2
Ritor1
parents:
diff changeset
504 int v66; // [sp+34h] [bp-28h]@22
Ritor1
parents:
diff changeset
505 int v67; // [sp+34h] [bp-28h]@59
Ritor1
parents:
diff changeset
506 int v68; // [sp+38h] [bp-24h]@13
Ritor1
parents:
diff changeset
507 unsigned int v69; // [sp+3Ch] [bp-20h]@2
Ritor1
parents:
diff changeset
508 int v70; // [sp+40h] [bp-1Ch]@2
Ritor1
parents:
diff changeset
509 signed int v71; // [sp+40h] [bp-1Ch]@15
Ritor1
parents:
diff changeset
510 int v72; // [sp+44h] [bp-18h]@2
Ritor1
parents:
diff changeset
511 unsigned __int16 *v73; // [sp+44h] [bp-18h]@29
Ritor1
parents:
diff changeset
512 unsigned __int16 *v74; // [sp+44h] [bp-18h]@66
Ritor1
parents:
diff changeset
513 int v75; // [sp+48h] [bp-14h]@4
Ritor1
parents:
diff changeset
514 int v76; // [sp+48h] [bp-14h]@22
Ritor1
parents:
diff changeset
515 int v77; // [sp+48h] [bp-14h]@59
Ritor1
parents:
diff changeset
516 LODSprite *v78; // [sp+4Ch] [bp-10h]@1
Ritor1
parents:
diff changeset
517 int v79; // [sp+50h] [bp-Ch]@4
Ritor1
parents:
diff changeset
518 int v80; // [sp+50h] [bp-Ch]@21
Ritor1
parents:
diff changeset
519 int v81; // [sp+50h] [bp-Ch]@62
Ritor1
parents:
diff changeset
520 int v82; // [sp+50h] [bp-Ch]@67
Ritor1
parents:
diff changeset
521 int v83; // [sp+50h] [bp-Ch]@75
Ritor1
parents:
diff changeset
522 int *pTargetZ; // [sp+54h] [bp-8h]@4
Ritor1
parents:
diff changeset
523 int v85; // [sp+58h] [bp-4h]@18
Ritor1
parents:
diff changeset
524 int v86; // [sp+58h] [bp-4h]@56
Ritor1
parents:
diff changeset
525 signed int v87; // [sp+64h] [bp+8h]@2
Ritor1
parents:
diff changeset
526 int v88; // [sp+68h] [bp+Ch]@18
Ritor1
parents:
diff changeset
527 int v89; // [sp+68h] [bp+Ch]@56
Ritor1
parents:
diff changeset
528
Ritor1
parents:
diff changeset
529 v3 = a2;
Ritor1
parents:
diff changeset
530 v78 = this;
144
8ab4484c22e0 Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents: 17
diff changeset
531 result = a2->_screenspace_x_scaler_packedfloat;
8ab4484c22e0 Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents: 17
diff changeset
532 v58 = a2->_screenspace_x_scaler_packedfloat;
0
Ritor1
parents:
diff changeset
533 if ( result <= 0 )
Ritor1
parents:
diff changeset
534 return result;
144
8ab4484c22e0 Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents: 17
diff changeset
535 v5 = a2->_screenspace_y_scaler_packedfloat;
8ab4484c22e0 Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents: 17
diff changeset
536 v6 = a2->_screenspace_x_scaler_packedfloat;
0
Ritor1
parents:
diff changeset
537 v87 = (signed __int64)0x100000000ui64 / result;
Ritor1
parents:
diff changeset
538 v48 = (signed __int64)0x100000000ui64 / result;
Ritor1
parents:
diff changeset
539 v62 = (signed __int64)0x100000000ui64 / v5;
Ritor1
parents:
diff changeset
540 v7 = this->uHeight;
Ritor1
parents:
diff changeset
541 v8 = (signed int)((signed __int64)0x100000000ui64 / v5) >> 1;
Ritor1
parents:
diff changeset
542 v53 = v8;
Ritor1
parents:
diff changeset
543 v70 = (this->uHeight << 16) - v8;
Ritor1
parents:
diff changeset
544 v49 = v7;
Ritor1
parents:
diff changeset
545 v69 = v3->uTargetPitch;
Ritor1
parents:
diff changeset
546 pTarget = v3->pTarget;
Ritor1
parents:
diff changeset
547 v57 = v3->sZValue;
Ritor1
parents:
diff changeset
548 v61 = v3->pPalette;
Ritor1
parents:
diff changeset
549 v9 = (v6 * this->uWidth + 32768) >> 16;
Ritor1
parents:
diff changeset
550 v72 = v3->uScreenSpaceY;
Ritor1
parents:
diff changeset
551 result = (v5 * v7 + 32768) >> 16;
Ritor1
parents:
diff changeset
552 v10 = (int *)(v72 - result + 1);
Ritor1
parents:
diff changeset
553 v11 = v3->uScreenSpaceX - (v9 >> 1) + 1;
Ritor1
parents:
diff changeset
554 v65 = v72 - result + 1;
Ritor1
parents:
diff changeset
555 v59 = v11 + v9 - 1;
Ritor1
parents:
diff changeset
556 if ( BYTE1(v3->uFlags) & 8 )
Ritor1
parents:
diff changeset
557 {
Ritor1
parents:
diff changeset
558 v10 = (int *)((char *)v10 + (v49 >> 1));
Ritor1
parents:
diff changeset
559 v72 += v49 >> 1;
Ritor1
parents:
diff changeset
560 v65 = (int)v10;
Ritor1
parents:
diff changeset
561 }
Ritor1
parents:
diff changeset
562 v12 = v72;
Ritor1
parents:
diff changeset
563 pTargetZ = v10;
Ritor1
parents:
diff changeset
564 v75 = v3->uScreenSpaceX - (v9 >> 1) + 1;
Ritor1
parents:
diff changeset
565 v79 = v11 + v9 - 1;
Ritor1
parents:
diff changeset
566 if ( !(v3->uFlags & 8) )
Ritor1
parents:
diff changeset
567 {
Ritor1
parents:
diff changeset
568 if ( v65 < (signed int)v3->uViewportY )
Ritor1
parents:
diff changeset
569 pTargetZ = (int *)v3->uViewportY;
Ritor1
parents:
diff changeset
570 if ( v72 > (signed int)v3->uViewportW )
Ritor1
parents:
diff changeset
571 v12 = v3->uViewportW;
Ritor1
parents:
diff changeset
572 if ( v11 < (signed int)v3->uViewportX )
Ritor1
parents:
diff changeset
573 v75 = v3->uViewportX;
Ritor1
parents:
diff changeset
574 if ( v59 > (signed int)v3->uViewportZ )
Ritor1
parents:
diff changeset
575 v79 = v3->uViewportZ;
Ritor1
parents:
diff changeset
576 }
Ritor1
parents:
diff changeset
577 v68 = v75 - v11;
Ritor1
parents:
diff changeset
578 v13 = -v62;
Ritor1
parents:
diff changeset
579 v60 = v59 - v79;
Ritor1
parents:
diff changeset
580 v52 = -v62;
Ritor1
parents:
diff changeset
581 if ( v3->uFlags & 1 )
Ritor1
parents:
diff changeset
582 {
Ritor1
parents:
diff changeset
583 v13 = v62;
Ritor1
parents:
diff changeset
584 v70 = v53;
Ritor1
parents:
diff changeset
585 v52 = v62;
Ritor1
parents:
diff changeset
586 }
Ritor1
parents:
diff changeset
587 v71 = v13 * (v72 - v12) + v70;
Ritor1
parents:
diff changeset
588 if ( LOBYTE(viewparams->field_20) )
Ritor1
parents:
diff changeset
589 {
Ritor1
parents:
diff changeset
590 if ( a3 )
Ritor1
parents:
diff changeset
591 return result;
Ritor1
parents:
diff changeset
592 }
Ritor1
parents:
diff changeset
593 v14 = 5 * v12;
Ritor1
parents:
diff changeset
594 v15 = v69 * v12;
Ritor1
parents:
diff changeset
595 result = v12 - v72 + result - 1;
Ritor1
parents:
diff changeset
596 v16 = (char *)pTargetZ - v65;
Ritor1
parents:
diff changeset
597 v17 = v14 << 7;
Ritor1
parents:
diff changeset
598 if ( v3->uFlags & 4 )
Ritor1
parents:
diff changeset
599 {
Ritor1
parents:
diff changeset
600 v34 = v79 + v15;
Ritor1
parents:
diff changeset
601 v89 = v34;
Ritor1
parents:
diff changeset
602 v86 = v79 + v17;
Ritor1
parents:
diff changeset
603 if ( result < (signed int)v16 )
Ritor1
parents:
diff changeset
604 return result;
Ritor1
parents:
diff changeset
605 v51 = result - (int)v16 + 1;
Ritor1
parents:
diff changeset
606 while ( 1 )
Ritor1
parents:
diff changeset
607 {
Ritor1
parents:
diff changeset
608 v35 = v71 >> 16;
Ritor1
parents:
diff changeset
609 v36 = LOWORD(v78->pSpriteLines[v35].dword_0);
Ritor1
parents:
diff changeset
610 if ( v36 == -1 )
Ritor1
parents:
diff changeset
611 {
Ritor1
parents:
diff changeset
612 v34 -= v69;
Ritor1
parents:
diff changeset
613 v89 = v34;
Ritor1
parents:
diff changeset
614 goto LABEL_84;
Ritor1
parents:
diff changeset
615 }
Ritor1
parents:
diff changeset
616 v37 = v9 - ((unsigned __int64)(v36 * (signed __int64)v58) >> 16);
Ritor1
parents:
diff changeset
617 v67 = v87 * ((unsigned __int64)(LOWORD(v78->pSpriteLines[v35].dword_0) * (signed __int64)v58) >> 16);
Ritor1
parents:
diff changeset
618 v38 = v9 - v60;
Ritor1
parents:
diff changeset
619 v77 = v9 - v60;
Ritor1
parents:
diff changeset
620 if ( v9 - v60 <= (signed int)(v9
Ritor1
parents:
diff changeset
621 - ((unsigned __int64)(HIWORD(v78->pSpriteLines[v35].dword_0) * (signed __int64)v58) >> 16))
Ritor1
parents:
diff changeset
622 || v68 >= v37 )
Ritor1
parents:
diff changeset
623 {
Ritor1
parents:
diff changeset
624 v89 -= v69;
Ritor1
parents:
diff changeset
625 v34 = v89;
Ritor1
parents:
diff changeset
626 LABEL_84:
Ritor1
parents:
diff changeset
627 v86 -= 640;
Ritor1
parents:
diff changeset
628 goto LABEL_85;
Ritor1
parents:
diff changeset
629 }
Ritor1
parents:
diff changeset
630 if ( v38 < v37 )
Ritor1
parents:
diff changeset
631 {
Ritor1
parents:
diff changeset
632 v81 = (v87 >> 1) + v87 * (v37 - v38);
Ritor1
parents:
diff changeset
633 }
Ritor1
parents:
diff changeset
634 else
Ritor1
parents:
diff changeset
635 {
Ritor1
parents:
diff changeset
636 v77 = v37;
Ritor1
parents:
diff changeset
637 v81 = v87 >> 1;
Ritor1
parents:
diff changeset
638 v39 = v37 - v9;
Ritor1
parents:
diff changeset
639 v89 += v39 + v60;
Ritor1
parents:
diff changeset
640 v86 += v60 + v39;
Ritor1
parents:
diff changeset
641 }
Ritor1
parents:
diff changeset
642 v40 = ((HIWORD(v78->pSpriteLines[v35].dword_0) + 1) << 16) - v81 - v67;
Ritor1
parents:
diff changeset
643 LODWORD(v41) = v40 << 16;
Ritor1
parents:
diff changeset
644 HIDWORD(v41) = v40 >> 16;
Ritor1
parents:
diff changeset
645 v42 = v77 - (((signed int)((unsigned __int64)(v41 / v48) - 32768) >> 16) + 1);
Ritor1
parents:
diff changeset
646 if ( v68 >= v42 )
Ritor1
parents:
diff changeset
647 v42 = v68;
Ritor1
parents:
diff changeset
648 v43 = &pTarget[v89];
Ritor1
parents:
diff changeset
649 v74 = &v43[v42 - v77 + 1];
Ritor1
parents:
diff changeset
650 v44 = &v78->pSpriteLines[v35];
Ritor1
parents:
diff changeset
651 v64 = v44->ptr_4;
Ritor1
parents:
diff changeset
652 if ( !v57 )
Ritor1
parents:
diff changeset
653 {
Ritor1
parents:
diff changeset
654 v83 = v67 + v81;
Ritor1
parents:
diff changeset
655 if ( ((v83 - (LOWORD(v44->dword_0) << 16)) & 0xFFFF0000) < 0 )
Ritor1
parents:
diff changeset
656 {
Ritor1
parents:
diff changeset
657 v83 += v87;
Ritor1
parents:
diff changeset
658 --v43;
Ritor1
parents:
diff changeset
659 --pTargetZ;
Ritor1
parents:
diff changeset
660 }
Ritor1
parents:
diff changeset
661 while ( v43 >= v74 )
Ritor1
parents:
diff changeset
662 {
Ritor1
parents:
diff changeset
663 v46 = (v83 - ((signed int)LOWORD(v78->pSpriteLines[v35].dword_0) << 16)) >> 16;
Ritor1
parents:
diff changeset
664 if ( *((char *)v64 + v46) )
Ritor1
parents:
diff changeset
665 *v43 = v61[*((char *)v64 + v46)];
Ritor1
parents:
diff changeset
666 v83 += v87;
Ritor1
parents:
diff changeset
667 --v43;
Ritor1
parents:
diff changeset
668 }
Ritor1
parents:
diff changeset
669 goto LABEL_81;
Ritor1
parents:
diff changeset
670 }
Ritor1
parents:
diff changeset
671 pTargetZ = &v3->pTargetZ[v86];
Ritor1
parents:
diff changeset
672 v82 = v67 + v81;
Ritor1
parents:
diff changeset
673 if ( ((v82 - (LOWORD(v44->dword_0) << 16)) & 0xFFFF0000) < 0 )
Ritor1
parents:
diff changeset
674 goto LABEL_72;
Ritor1
parents:
diff changeset
675 LABEL_73:
Ritor1
parents:
diff changeset
676 if ( v43 >= v74 )
Ritor1
parents:
diff changeset
677 break;
Ritor1
parents:
diff changeset
678 LABEL_81:
Ritor1
parents:
diff changeset
679 v89 += v9 - v77 - v60 - v69;
Ritor1
parents:
diff changeset
680 v34 = v89;
Ritor1
parents:
diff changeset
681 v86 = v86 + v9 - v77 - v60 - 640;
Ritor1
parents:
diff changeset
682 LABEL_85:
Ritor1
parents:
diff changeset
683 result = v52;
Ritor1
parents:
diff changeset
684 v71 += v52;
Ritor1
parents:
diff changeset
685 --v51;
Ritor1
parents:
diff changeset
686 if ( !v51 )
Ritor1
parents:
diff changeset
687 return result;
Ritor1
parents:
diff changeset
688 }
Ritor1
parents:
diff changeset
689 v45 = (v82 - ((signed int)LOWORD(v78->pSpriteLines[v35].dword_0) << 16)) >> 16;
Ritor1
parents:
diff changeset
690 v56 = *((char *)v64 + v45);
Ritor1
parents:
diff changeset
691 if ( *((char *)v64 + v45) && v57 <= (unsigned int)*pTargetZ )
Ritor1
parents:
diff changeset
692 {
Ritor1
parents:
diff changeset
693 *pTargetZ = v57;
Ritor1
parents:
diff changeset
694 *v43 = v61[v56];
Ritor1
parents:
diff changeset
695 }
Ritor1
parents:
diff changeset
696 LABEL_72:
Ritor1
parents:
diff changeset
697 v82 += v87;
Ritor1
parents:
diff changeset
698 --v43;
Ritor1
parents:
diff changeset
699 --pTargetZ;
Ritor1
parents:
diff changeset
700 goto LABEL_73;
Ritor1
parents:
diff changeset
701 }
Ritor1
parents:
diff changeset
702 v18 = v75 + v15;
Ritor1
parents:
diff changeset
703 v19 = v75 + v17;
Ritor1
parents:
diff changeset
704 v88 = v18;
Ritor1
parents:
diff changeset
705 v85 = v19;
Ritor1
parents:
diff changeset
706 if ( result >= (signed int)v16 )
Ritor1
parents:
diff changeset
707 {
Ritor1
parents:
diff changeset
708 v50 = result - (int)v16 + 1;
Ritor1
parents:
diff changeset
709 while ( 1 )
Ritor1
parents:
diff changeset
710 {
Ritor1
parents:
diff changeset
711 v20 = &v78->pSpriteLines[v71 >> 16];
Ritor1
parents:
diff changeset
712 v80 = v71 >> 16;
Ritor1
parents:
diff changeset
713 if ( LOWORD(v20->dword_0) != -1 )
Ritor1
parents:
diff changeset
714 break;
Ritor1
parents:
diff changeset
715 v18 -= v69;
Ritor1
parents:
diff changeset
716 v85 = v19 - 640;
Ritor1
parents:
diff changeset
717 v88 = v18;
Ritor1
parents:
diff changeset
718 LABEL_54:
Ritor1
parents:
diff changeset
719 result = v52;
Ritor1
parents:
diff changeset
720 v71 += v52;
Ritor1
parents:
diff changeset
721 --v50;
Ritor1
parents:
diff changeset
722 if ( !v50 )
Ritor1
parents:
diff changeset
723 return result;
Ritor1
parents:
diff changeset
724 v19 = v85;
Ritor1
parents:
diff changeset
725 }
Ritor1
parents:
diff changeset
726 v21 = (v58 * LOWORD(v20->dword_0) + 32768) >> 16;
Ritor1
parents:
diff changeset
727 v66 = v21 * v87;
Ritor1
parents:
diff changeset
728 v76 = v68;
Ritor1
parents:
diff changeset
729 v54 = HIWORD(v20->dword_0);
Ritor1
parents:
diff changeset
730 v22 = v9 - v60;
Ritor1
parents:
diff changeset
731 if ( v68 >= (v58 * v54 + 32768) >> 16 || v22 <= v21 )
Ritor1
parents:
diff changeset
732 {
Ritor1
parents:
diff changeset
733 v88 -= v69;
Ritor1
parents:
diff changeset
734 v85 -= 640;
Ritor1
parents:
diff changeset
735 goto LABEL_51;
Ritor1
parents:
diff changeset
736 }
Ritor1
parents:
diff changeset
737 if ( v68 > v21 )
Ritor1
parents:
diff changeset
738 {
Ritor1
parents:
diff changeset
739 v24 = (v87 >> 1) + v87 * (v68 - v21);
Ritor1
parents:
diff changeset
740 }
Ritor1
parents:
diff changeset
741 else
Ritor1
parents:
diff changeset
742 {
Ritor1
parents:
diff changeset
743 v76 = (v58 * LOWORD(v20->dword_0) + 32768) >> 16;
Ritor1
parents:
diff changeset
744 v23 = v21 - v68;
Ritor1
parents:
diff changeset
745 v88 += v23;
Ritor1
parents:
diff changeset
746 v24 = v87 >> 1;
Ritor1
parents:
diff changeset
747 v85 += v23;
Ritor1
parents:
diff changeset
748 }
Ritor1
parents:
diff changeset
749 LODWORD(v25) = (((v54 + 1) << 16) - v24 - v66) << 16;
Ritor1
parents:
diff changeset
750 HIDWORD(v25) = (((v54 + 1) << 16) - v24 - v66) >> 16;
Ritor1
parents:
diff changeset
751 v26 = v76 + ((signed int)(v25 / v48) >> 16) + 1;
Ritor1
parents:
diff changeset
752 if ( v22 > v26 )
Ritor1
parents:
diff changeset
753 v22 = v26;
Ritor1
parents:
diff changeset
754 v27 = &pTarget[v88];
Ritor1
parents:
diff changeset
755 v73 = &v27[v22 - v76 - 1];
Ritor1
parents:
diff changeset
756 v28 = &v78->pSpriteLines[v80];
Ritor1
parents:
diff changeset
757 v63 = v28->ptr_4;
Ritor1
parents:
diff changeset
758 if ( v57 )
Ritor1
parents:
diff changeset
759 {
Ritor1
parents:
diff changeset
760 pTargetZ = &v3->pTargetZ[v85];
Ritor1
parents:
diff changeset
761 v29 = v66 - (LOWORD(v28->dword_0) << 16) + v24;
Ritor1
parents:
diff changeset
762 if ( (v29 & 0xFFFF0000) >= 0 )
Ritor1
parents:
diff changeset
763 goto LABEL_36;
Ritor1
parents:
diff changeset
764 while ( 1 )
Ritor1
parents:
diff changeset
765 {
Ritor1
parents:
diff changeset
766 v29 += v87;
Ritor1
parents:
diff changeset
767 ++v27;
Ritor1
parents:
diff changeset
768 ++pTargetZ;
Ritor1
parents:
diff changeset
769 LABEL_36:
Ritor1
parents:
diff changeset
770 if ( v27 >= v73 )
Ritor1
parents:
diff changeset
771 break;
Ritor1
parents:
diff changeset
772 v55 = *((char *)v63 + (v29 >> 16));
Ritor1
parents:
diff changeset
773 if ( *((char *)v63 + (v29 >> 16)) && v57 <= (unsigned int)*pTargetZ )
Ritor1
parents:
diff changeset
774 {
Ritor1
parents:
diff changeset
775 *pTargetZ = v57;
Ritor1
parents:
diff changeset
776 *v27 = v61[v55];
Ritor1
parents:
diff changeset
777 }
Ritor1
parents:
diff changeset
778 }
Ritor1
parents:
diff changeset
779 v30 = v29 >> 16;
Ritor1
parents:
diff changeset
780 if ( v30 > HIWORD(v78->pSpriteLines[v80].dword_0) - (signed int)LOWORD(v78->pSpriteLines[v80].dword_0)
Ritor1
parents:
diff changeset
781 || (v31 = *((char *)v63 + v30)) == 0
Ritor1
parents:
diff changeset
782 || v57 > (unsigned int)*pTargetZ )
Ritor1
parents:
diff changeset
783 goto LABEL_50;
Ritor1
parents:
diff changeset
784 *pTargetZ = v57;
Ritor1
parents:
diff changeset
785 }
Ritor1
parents:
diff changeset
786 else
Ritor1
parents:
diff changeset
787 {
Ritor1
parents:
diff changeset
788 v32 = v66 - (LOWORD(v28->dword_0) << 16) + v24;
Ritor1
parents:
diff changeset
789 if ( (v32 & 0xFFFF0000) < 0 )
Ritor1
parents:
diff changeset
790 {
Ritor1
parents:
diff changeset
791 v32 += v87;
Ritor1
parents:
diff changeset
792 ++v27;
Ritor1
parents:
diff changeset
793 ++pTargetZ;
Ritor1
parents:
diff changeset
794 }
Ritor1
parents:
diff changeset
795 while ( v27 < v73 )
Ritor1
parents:
diff changeset
796 {
Ritor1
parents:
diff changeset
797 if ( *((char *)v63 + (v32 >> 16)) )
Ritor1
parents:
diff changeset
798 *v27 = v61[*((char *)v63 + (v32 >> 16))];
Ritor1
parents:
diff changeset
799 v32 += v87;
Ritor1
parents:
diff changeset
800 ++v27;
Ritor1
parents:
diff changeset
801 }
Ritor1
parents:
diff changeset
802 v33 = v32 >> 16;
Ritor1
parents:
diff changeset
803 if ( v33 > HIWORD(v78->pSpriteLines[v80].dword_0) - (signed int)LOWORD(v78->pSpriteLines[v80].dword_0)
Ritor1
parents:
diff changeset
804 || (v31 = *((char *)v63 + v33)) == 0 )
Ritor1
parents:
diff changeset
805 goto LABEL_50;
Ritor1
parents:
diff changeset
806 }
Ritor1
parents:
diff changeset
807 *v27 = v61[v31];
Ritor1
parents:
diff changeset
808 LABEL_50:
Ritor1
parents:
diff changeset
809 v88 += v68 - v76 - v69;
Ritor1
parents:
diff changeset
810 v85 = v85 + v68 - v76 - 640;
Ritor1
parents:
diff changeset
811 LABEL_51:
Ritor1
parents:
diff changeset
812 v18 = v88;
Ritor1
parents:
diff changeset
813 goto LABEL_54;
Ritor1
parents:
diff changeset
814 }
Ritor1
parents:
diff changeset
815 return result;
Ritor1
parents:
diff changeset
816 }
Ritor1
parents:
diff changeset
817
Ritor1
parents:
diff changeset
818 //----- (004AD2D1) --------------------------------------------------------
Ritor1
parents:
diff changeset
819 int LODSprite::_4AD2D1(struct RenderBillboardTransform_local0 *a2, int a3)
Ritor1
parents:
diff changeset
820 {
Ritor1
parents:
diff changeset
821 int result; // eax@1
Ritor1
parents:
diff changeset
822 unsigned int v4; // esi@1
Ritor1
parents:
diff changeset
823 int v5; // edi@1
Ritor1
parents:
diff changeset
824 LODSprite_stru0 *v6; // edx@2
Ritor1
parents:
diff changeset
825 __int16 v7; // bx@2
Ritor1
parents:
diff changeset
826 int v8; // ecx@3
Ritor1
parents:
diff changeset
827 unsigned __int16 *v9; // esi@3
Ritor1
parents:
diff changeset
828 int v10; // ebx@3
Ritor1
parents:
diff changeset
829 void *v11; // edx@3
Ritor1
parents:
diff changeset
830 unsigned __int16 *v12; // ecx@3
Ritor1
parents:
diff changeset
831 int v13; // ebx@4
Ritor1
parents:
diff changeset
832 LODSprite *v14; // [sp+8h] [bp-10h]@1
Ritor1
parents:
diff changeset
833 unsigned __int16 *v15; // [sp+10h] [bp-8h]@1
Ritor1
parents:
diff changeset
834 unsigned __int16 *v16; // [sp+14h] [bp-4h]@1
Ritor1
parents:
diff changeset
835 int i; // [sp+20h] [bp+8h]@1
Ritor1
parents:
diff changeset
836
Ritor1
parents:
diff changeset
837 result = (int)a2;
Ritor1
parents:
diff changeset
838 v14 = this;
Ritor1
parents:
diff changeset
839 v4 = a2->uTargetPitch;
Ritor1
parents:
diff changeset
840 v16 = a2->pTarget;
Ritor1
parents:
diff changeset
841 v15 = a2->pPalette;
Ritor1
parents:
diff changeset
842 v5 = this->uHeight - 1;
Ritor1
parents:
diff changeset
843 for ( i = v4 * a2->uScreenSpaceY - (this->uWidth >> 1) + a2->uScreenSpaceX + 1; v5 >= 0; --v5 )
Ritor1
parents:
diff changeset
844 {
Ritor1
parents:
diff changeset
845 v6 = &this->pSpriteLines[v5];
Ritor1
parents:
diff changeset
846 v7 = LOWORD(v6->dword_0);
Ritor1
parents:
diff changeset
847 if ( LOWORD(v6->dword_0) != -1 )
Ritor1
parents:
diff changeset
848 {
Ritor1
parents:
diff changeset
849 v8 = v7;
Ritor1
parents:
diff changeset
850 v9 = &v16[v7 + i];
Ritor1
parents:
diff changeset
851 v10 = HIWORD(v6->dword_0);
Ritor1
parents:
diff changeset
852 v11 = v6->ptr_4;
Ritor1
parents:
diff changeset
853 v12 = &v9[v10 - v8];
Ritor1
parents:
diff changeset
854 while ( v9 <= v12 )
Ritor1
parents:
diff changeset
855 {
Ritor1
parents:
diff changeset
856 v13 = *(char *)v11;
Ritor1
parents:
diff changeset
857 v11 = (char *)v11 + 1;
Ritor1
parents:
diff changeset
858 if ( v13 )
Ritor1
parents:
diff changeset
859 *v9 = v15[v13];
Ritor1
parents:
diff changeset
860 ++v9;
Ritor1
parents:
diff changeset
861 }
Ritor1
parents:
diff changeset
862 v4 = *(int *)(result + 48);
Ritor1
parents:
diff changeset
863 //this = v14;
Ritor1
parents:
diff changeset
864 }
Ritor1
parents:
diff changeset
865 i -= v4;
Ritor1
parents:
diff changeset
866 }
Ritor1
parents:
diff changeset
867 return result;
Ritor1
parents:
diff changeset
868 }
Ritor1
parents:
diff changeset
869
Ritor1
parents:
diff changeset
870 //----- (0046454B) --------------------------------------------------------
Ritor1
parents:
diff changeset
871 void LODFile_IconsBitmaps::ReleaseAll2()
Ritor1
parents:
diff changeset
872 {
Ritor1
parents:
diff changeset
873 LODFile_IconsBitmaps *v1; // esi@1
Ritor1
parents:
diff changeset
874 int v2; // edi@1
Ritor1
parents:
diff changeset
875 Texture *v3; // ebx@2
Ritor1
parents:
diff changeset
876 struct IDirect3DTexture2 **v4; // eax@3
Ritor1
parents:
diff changeset
877 struct IDirect3DTexture2 *v5; // eax@4
Ritor1
parents:
diff changeset
878 struct IDirectDrawSurface **v6; // eax@6
Ritor1
parents:
diff changeset
879 struct IDirectDrawSurface *v7; // eax@7
Ritor1
parents:
diff changeset
880 int v8; // eax@10
Ritor1
parents:
diff changeset
881
Ritor1
parents:
diff changeset
882 v1 = this;
Ritor1
parents:
diff changeset
883 v2 = this->uNumLoadedFiles - 1;
Ritor1
parents:
diff changeset
884 if ( v2 >= this->dword_11B84 )
Ritor1
parents:
diff changeset
885 {
Ritor1
parents:
diff changeset
886 v3 = &this->pTextures[v2];
Ritor1
parents:
diff changeset
887 do
Ritor1
parents:
diff changeset
888 {
Ritor1
parents:
diff changeset
889 v3->Release();
Ritor1
parents:
diff changeset
890 v4 = v1->pHardwareTextures;
Ritor1
parents:
diff changeset
891 if ( v4 )
Ritor1
parents:
diff changeset
892 {
Ritor1
parents:
diff changeset
893 v5 = v4[v2];
Ritor1
parents:
diff changeset
894 if ( v5 )
Ritor1
parents:
diff changeset
895 {
Ritor1
parents:
diff changeset
896 v5->Release();
Ritor1
parents:
diff changeset
897 v1->pHardwareTextures[v2] = 0;
Ritor1
parents:
diff changeset
898 }
Ritor1
parents:
diff changeset
899 }
Ritor1
parents:
diff changeset
900 v6 = v1->pHardwareSurfaces;
Ritor1
parents:
diff changeset
901 if ( v6 )
Ritor1
parents:
diff changeset
902 {
Ritor1
parents:
diff changeset
903 v7 = v6[v2];
Ritor1
parents:
diff changeset
904 if ( v7 )
Ritor1
parents:
diff changeset
905 {
Ritor1
parents:
diff changeset
906 v7->Release();
Ritor1
parents:
diff changeset
907 v1->pHardwareSurfaces[v2] = 0;
Ritor1
parents:
diff changeset
908 }
Ritor1
parents:
diff changeset
909 }
Ritor1
parents:
diff changeset
910 --v2;
Ritor1
parents:
diff changeset
911 --v3;
Ritor1
parents:
diff changeset
912 }
Ritor1
parents:
diff changeset
913 while ( v2 >= v1->dword_11B84 );
Ritor1
parents:
diff changeset
914 }
Ritor1
parents:
diff changeset
915 v8 = v1->dword_11B84;
Ritor1
parents:
diff changeset
916 v1->uTexturePacksCount = 0;
Ritor1
parents:
diff changeset
917 v1->uNumPrevLoadedFiles = 0;
Ritor1
parents:
diff changeset
918 v1->uNumLoadedFiles = v8;
Ritor1
parents:
diff changeset
919 }
Ritor1
parents:
diff changeset
920
Ritor1
parents:
diff changeset
921 //----- (004645DC) --------------------------------------------------------
Ritor1
parents:
diff changeset
922 void LODFile_Sprites::DeleteSomeOtherSprites()
Ritor1
parents:
diff changeset
923 {
Ritor1
parents:
diff changeset
924 int *v1; // esi@1
Ritor1
parents:
diff changeset
925 int *v2; // edi@1
Ritor1
parents:
diff changeset
926
Ritor1
parents:
diff changeset
927 v1 = (int *)&this->uNumLoadedSprites;
Ritor1
parents:
diff changeset
928 v2 = &this->field_ECA0;
Ritor1
parents:
diff changeset
929 DeleteSpritesRange(field_ECA0, uNumLoadedSprites);
Ritor1
parents:
diff changeset
930 *v1 = *v2;
Ritor1
parents:
diff changeset
931 }
Ritor1
parents:
diff changeset
932
Ritor1
parents:
diff changeset
933
Ritor1
parents:
diff changeset
934 //----- (00461431) --------------------------------------------------------
Ritor1
parents:
diff changeset
935 void LOD::File::Close()
Ritor1
parents:
diff changeset
936 {
Ritor1
parents:
diff changeset
937 LOD::File *v1; // esi@1
Ritor1
parents:
diff changeset
938 LOD::Directory **v2; // edi@2
Ritor1
parents:
diff changeset
939 FILE *v3; // ST00_4@2
Ritor1
parents:
diff changeset
940
Ritor1
parents:
diff changeset
941 v1 = this;
Ritor1
parents:
diff changeset
942 if ( this->isFileOpened )
Ritor1
parents:
diff changeset
943 {
Ritor1
parents:
diff changeset
944 this->pContainerName[0] = 0;
Ritor1
parents:
diff changeset
945 this->uCurrentIndexDir = 0;
Ritor1
parents:
diff changeset
946 v2 = &this->pSubIndices;
Ritor1
parents:
diff changeset
947 pAllocator->FreeChunk(this->pSubIndices);
Ritor1
parents:
diff changeset
948 pAllocator->FreeChunk(v1->pRoot);
Ritor1
parents:
diff changeset
949 v3 = v1->pFile;
Ritor1
parents:
diff changeset
950 *v2 = 0;
Ritor1
parents:
diff changeset
951 v1->pRoot = 0;
Ritor1
parents:
diff changeset
952 fclose(v3);
Ritor1
parents:
diff changeset
953 v1->isFileOpened = 0;
Ritor1
parents:
diff changeset
954 _6A0CA8_lod_unused = 0;
Ritor1
parents:
diff changeset
955 }
Ritor1
parents:
diff changeset
956 }
Ritor1
parents:
diff changeset
957
Ritor1
parents:
diff changeset
958
Ritor1
parents:
diff changeset
959
Ritor1
parents:
diff changeset
960 //----- (00461492) --------------------------------------------------------
Ritor1
parents:
diff changeset
961 int LODWriteableFile::_461492(LOD::FileHeader *pHeader, LOD::Directory *pDir, const char *Source)
Ritor1
parents:
diff changeset
962 {
Ritor1
parents:
diff changeset
963 if (isFileOpened)
Ritor1
parents:
diff changeset
964 return 1;
Ritor1
parents:
diff changeset
965 if ( !pDir->pFilename[0] )
Ritor1
parents:
diff changeset
966 return 2;
Ritor1
parents:
diff changeset
967 strcpy(pHeader->pSignature, "LOD");
Ritor1
parents:
diff changeset
968 pHeader->LODSize = 100;
Ritor1
parents:
diff changeset
969 pHeader->uNumIndices = 1;
Ritor1
parents:
diff changeset
970 pDir->pFilename[15] = 0;
Ritor1
parents:
diff changeset
971 pDir->uDataSize = 0;
Ritor1
parents:
diff changeset
972 pDir->uOfsetFromSubindicesStart = 288;
Ritor1
parents:
diff changeset
973 strcpy(pLODName, Source);
Ritor1
parents:
diff changeset
974
Ritor1
parents:
diff changeset
975 pFile = fopen(pLODName, "wb+");
Ritor1
parents:
diff changeset
976 if (!pFile)
Ritor1
parents:
diff changeset
977 return 3;
Ritor1
parents:
diff changeset
978
Ritor1
parents:
diff changeset
979 fwrite(pHeader, 0x100, 1, pFile);
Ritor1
parents:
diff changeset
980 fwrite(pDir, 0x20, 1, pFile);
Ritor1
parents:
diff changeset
981 fclose(pFile);
Ritor1
parents:
diff changeset
982 pFile = 0;
Ritor1
parents:
diff changeset
983 return 0;
Ritor1
parents:
diff changeset
984 }
Ritor1
parents:
diff changeset
985
Ritor1
parents:
diff changeset
986 //----- (0046153F) --------------------------------------------------------
Ritor1
parents:
diff changeset
987 void LOD::File::ResetSubIndices()
Ritor1
parents:
diff changeset
988 {
Ritor1
parents:
diff changeset
989 LOD::Directory **pSubIndices_dup2; // esi@2
Ritor1
parents:
diff changeset
990 LOD::Directory *pSubIndices_dup; // ST00_4@2
Ritor1
parents:
diff changeset
991
Ritor1
parents:
diff changeset
992 if ( this->isFileOpened )
Ritor1
parents:
diff changeset
993 {
Ritor1
parents:
diff changeset
994 pSubIndices_dup2 = &this->pSubIndices;
Ritor1
parents:
diff changeset
995 this->pContainerName[0] = 0;
Ritor1
parents:
diff changeset
996 this->uCurrentIndexDir = 0;
Ritor1
parents:
diff changeset
997 pSubIndices_dup = this->pSubIndices;
Ritor1
parents:
diff changeset
998 this->uOffsetToSubIndex = 0;
Ritor1
parents:
diff changeset
999 this->uNumSubIndices = 0;
Ritor1
parents:
diff changeset
1000 this->uLODDataSize = 0;
Ritor1
parents:
diff changeset
1001 pAllocator->FreeChunk(pSubIndices_dup);
Ritor1
parents:
diff changeset
1002 *pSubIndices_dup2 = 0;
Ritor1
parents:
diff changeset
1003 }
Ritor1
parents:
diff changeset
1004 }
Ritor1
parents:
diff changeset
1005
Ritor1
parents:
diff changeset
1006
Ritor1
parents:
diff changeset
1007
Ritor1
parents:
diff changeset
1008
Ritor1
parents:
diff changeset
1009
Ritor1
parents:
diff changeset
1010
Ritor1
parents:
diff changeset
1011
Ritor1
parents:
diff changeset
1012 //----- (00450C8B) --------------------------------------------------------
Ritor1
parents:
diff changeset
1013 void LODFile_Sprites::DeleteSomeSprites()
Ritor1
parents:
diff changeset
1014 {
Ritor1
parents:
diff changeset
1015 int *v1; // esi@1
Ritor1
parents:
diff changeset
1016 int *v2; // edi@1
Ritor1
parents:
diff changeset
1017
Ritor1
parents:
diff changeset
1018 v1 = (int *)&this->uNumLoadedSprites;
Ritor1
parents:
diff changeset
1019 v2 = &this->field_ECA8;
Ritor1
parents:
diff changeset
1020 DeleteSpritesRange(this->field_ECA8, this->uNumLoadedSprites);
Ritor1
parents:
diff changeset
1021 *v1 = *v2;
Ritor1
parents:
diff changeset
1022 }
Ritor1
parents:
diff changeset
1023
Ritor1
parents:
diff changeset
1024 //----- (00450CA9) --------------------------------------------------------
Ritor1
parents:
diff changeset
1025 void LODFile_Sprites::DeleteSpritesRange(int uStartIndex, int uStopIndex)
Ritor1
parents:
diff changeset
1026 {
Ritor1
parents:
diff changeset
1027 LODFile_Sprites *v3; // edi@1
Ritor1
parents:
diff changeset
1028 int v4; // esi@3
Ritor1
parents:
diff changeset
1029 LODSprite *v5; // ebx@3
Ritor1
parents:
diff changeset
1030 LODSprite *v6; // esi@7
Ritor1
parents:
diff changeset
1031 int v7; // edi@7
Ritor1
parents:
diff changeset
1032 int a2a; // [sp+10h] [bp+8h]@3
Ritor1
parents:
diff changeset
1033
Ritor1
parents:
diff changeset
1034 v3 = this;
Ritor1
parents:
diff changeset
1035 if ( this->pHardwareSprites )
Ritor1
parents:
diff changeset
1036 {
Ritor1
parents:
diff changeset
1037 if ( uStartIndex < uStopIndex )
Ritor1
parents:
diff changeset
1038 {
Ritor1
parents:
diff changeset
1039 v4 = uStartIndex;
Ritor1
parents:
diff changeset
1040 v5 = &this->pSpriteHeaders[uStartIndex];
Ritor1
parents:
diff changeset
1041 a2a = uStopIndex - uStartIndex;
Ritor1
parents:
diff changeset
1042 do
Ritor1
parents:
diff changeset
1043 {
Ritor1
parents:
diff changeset
1044 v5->Release();
Ritor1
parents:
diff changeset
1045 pHardwareSprites[v4].Release();
Ritor1
parents:
diff changeset
1046 ++v4;
Ritor1
parents:
diff changeset
1047 ++v5;
Ritor1
parents:
diff changeset
1048 --a2a;
Ritor1
parents:
diff changeset
1049 }
Ritor1
parents:
diff changeset
1050 while ( a2a );
Ritor1
parents:
diff changeset
1051 }
Ritor1
parents:
diff changeset
1052 }
Ritor1
parents:
diff changeset
1053 else
Ritor1
parents:
diff changeset
1054 {
Ritor1
parents:
diff changeset
1055 if ( uStartIndex < uStopIndex )
Ritor1
parents:
diff changeset
1056 {
Ritor1
parents:
diff changeset
1057 v6 = &this->pSpriteHeaders[uStartIndex];
Ritor1
parents:
diff changeset
1058 v7 = uStopIndex - uStartIndex;
Ritor1
parents:
diff changeset
1059 do
Ritor1
parents:
diff changeset
1060 {
Ritor1
parents:
diff changeset
1061 v6->Release();
Ritor1
parents:
diff changeset
1062 ++v6;
Ritor1
parents:
diff changeset
1063 --v7;
Ritor1
parents:
diff changeset
1064 }
Ritor1
parents:
diff changeset
1065 while ( v7 );
Ritor1
parents:
diff changeset
1066 }
Ritor1
parents:
diff changeset
1067 }
Ritor1
parents:
diff changeset
1068 }
Ritor1
parents:
diff changeset
1069
Ritor1
parents:
diff changeset
1070 //----- (00450D1D) --------------------------------------------------------
Ritor1
parents:
diff changeset
1071 void LODSprite::Release()
Ritor1
parents:
diff changeset
1072 {
Ritor1
parents:
diff changeset
1073 LODSprite *v1; // esi@1
Ritor1
parents:
diff changeset
1074
Ritor1
parents:
diff changeset
1075 v1 = this;
Ritor1
parents:
diff changeset
1076 if ( !(HIBYTE(this->word_1A) & 4) )
Ritor1
parents:
diff changeset
1077 {
Ritor1
parents:
diff changeset
1078 pAllocator->FreeChunk(this->pDecompressedBytes);
Ritor1
parents:
diff changeset
1079 pAllocator->FreeChunk(v1->pSpriteLines);
Ritor1
parents:
diff changeset
1080 }
Ritor1
parents:
diff changeset
1081 v1->word_1A = 0;
Ritor1
parents:
diff changeset
1082 v1->pDecompressedBytes = 0;
Ritor1
parents:
diff changeset
1083 v1->pSpriteLines = 0;
Ritor1
parents:
diff changeset
1084 v1->pName[0] = 0;
Ritor1
parents:
diff changeset
1085 v1->word_16 = 0;
Ritor1
parents:
diff changeset
1086 v1->uPaletteId = 0;
Ritor1
parents:
diff changeset
1087 v1->uTexturePitch = 0;
Ritor1
parents:
diff changeset
1088 v1->uHeight = 0;
Ritor1
parents:
diff changeset
1089 v1->uWidth = 0;
Ritor1
parents:
diff changeset
1090 v1->uSpriteSize = 0;
Ritor1
parents:
diff changeset
1091 }
Ritor1
parents:
diff changeset
1092
Ritor1
parents:
diff changeset
1093 //----- (00450D68) --------------------------------------------------------
Ritor1
parents:
diff changeset
1094 void Sprite::Release()
Ritor1
parents:
diff changeset
1095 {
Ritor1
parents:
diff changeset
1096 if (pName)
Ritor1
parents:
diff changeset
1097 pAllocator->FreeChunk((void *)pName);
Ritor1
parents:
diff changeset
1098 pName = nullptr;
Ritor1
parents:
diff changeset
1099
Ritor1
parents:
diff changeset
1100 if (pTextureSurface)
Ritor1
parents:
diff changeset
1101 pTextureSurface->Release();
Ritor1
parents:
diff changeset
1102 pTextureSurface = nullptr;
Ritor1
parents:
diff changeset
1103
Ritor1
parents:
diff changeset
1104 if (pTexture)
Ritor1
parents:
diff changeset
1105 pTexture->Release();
Ritor1
parents:
diff changeset
1106 pTexture = nullptr;
Ritor1
parents:
diff changeset
1107 }
Ritor1
parents:
diff changeset
1108
Ritor1
parents:
diff changeset
1109
Ritor1
parents:
diff changeset
1110
Ritor1
parents:
diff changeset
1111
Ritor1
parents:
diff changeset
1112 //----- (0040FA2E) --------------------------------------------------------
Ritor1
parents:
diff changeset
1113 bool LODFile_IconsBitmaps::LoadBitmaps(const char *pFilename)
Ritor1
parents:
diff changeset
1114 {
Ritor1
parents:
diff changeset
1115 ReleaseAll();
Ritor1
parents:
diff changeset
1116 if (LoadHeader(pFilename, 1))
Ritor1
parents:
diff changeset
1117 return false;
Ritor1
parents:
diff changeset
1118 else
Ritor1
parents:
diff changeset
1119 return LoadSubIndices("bitmaps") == 0;
Ritor1
parents:
diff changeset
1120 }
Ritor1
parents:
diff changeset
1121
Ritor1
parents:
diff changeset
1122
Ritor1
parents:
diff changeset
1123 //----- (0040FAEE) --------------------------------------------------------
Ritor1
parents:
diff changeset
1124 bool LODFile_IconsBitmaps::LoadIconsOrEvents(const char *pLODFilename)
Ritor1
parents:
diff changeset
1125 {
Ritor1
parents:
diff changeset
1126 ReleaseAll();
Ritor1
parents:
diff changeset
1127
Ritor1
parents:
diff changeset
1128 if (LoadHeader(pLODFilename, 1))
Ritor1
parents:
diff changeset
1129 return false;
Ritor1
parents:
diff changeset
1130 else
Ritor1
parents:
diff changeset
1131 return LoadSubIndices("icons") == 0;
Ritor1
parents:
diff changeset
1132 }
Ritor1
parents:
diff changeset
1133
Ritor1
parents:
diff changeset
1134
Ritor1
parents:
diff changeset
1135 //----- (0040FA60) --------------------------------------------------------
Ritor1
parents:
diff changeset
1136 void LODFile_IconsBitmaps::ReleaseAll()
Ritor1
parents:
diff changeset
1137 {
Ritor1
parents:
diff changeset
1138 LODFile_IconsBitmaps *v1; // esi@1
Ritor1
parents:
diff changeset
1139 unsigned int v2; // edi@1
Ritor1
parents:
diff changeset
1140 Texture *v3; // ebp@2
Ritor1
parents:
diff changeset
1141 struct IDirect3DTexture2 **v4; // eax@3
Ritor1
parents:
diff changeset
1142 struct IDirect3DTexture2 *v5; // eax@4
Ritor1
parents:
diff changeset
1143 struct IDirectDrawSurface **v6; // eax@6
Ritor1
parents:
diff changeset
1144 struct IDirectDrawSurface *v7; // eax@7
Ritor1
parents:
diff changeset
1145
Ritor1
parents:
diff changeset
1146 v1 = this;
Ritor1
parents:
diff changeset
1147 v2 = this->uNumLoadedFiles - 1;
Ritor1
parents:
diff changeset
1148 if ( (v2 & 0x80000000u) == 0 )
Ritor1
parents:
diff changeset
1149 {
Ritor1
parents:
diff changeset
1150 v3 = &this->pTextures[v2];
Ritor1
parents:
diff changeset
1151 do
Ritor1
parents:
diff changeset
1152 {
Ritor1
parents:
diff changeset
1153 v3->Release();
Ritor1
parents:
diff changeset
1154 v4 = v1->pHardwareTextures;
Ritor1
parents:
diff changeset
1155 if ( v4 )
Ritor1
parents:
diff changeset
1156 {
Ritor1
parents:
diff changeset
1157 v5 = v4[v2];
Ritor1
parents:
diff changeset
1158 if ( v5 )
Ritor1
parents:
diff changeset
1159 {
Ritor1
parents:
diff changeset
1160 v5->Release();
Ritor1
parents:
diff changeset
1161 v1->pHardwareTextures[v2] = 0;
Ritor1
parents:
diff changeset
1162 }
Ritor1
parents:
diff changeset
1163 }
Ritor1
parents:
diff changeset
1164 v6 = v1->pHardwareSurfaces;
Ritor1
parents:
diff changeset
1165 if ( v6 )
Ritor1
parents:
diff changeset
1166 {
Ritor1
parents:
diff changeset
1167 v7 = v6[v2];
Ritor1
parents:
diff changeset
1168 if ( v7 )
Ritor1
parents:
diff changeset
1169 {
Ritor1
parents:
diff changeset
1170 v7->Release();
Ritor1
parents:
diff changeset
1171 v1->pHardwareSurfaces[v2] = 0;
Ritor1
parents:
diff changeset
1172 }
Ritor1
parents:
diff changeset
1173 }
Ritor1
parents:
diff changeset
1174 --v2;
Ritor1
parents:
diff changeset
1175 --v3;
Ritor1
parents:
diff changeset
1176 }
Ritor1
parents:
diff changeset
1177 while ( (v2 & 0x80000000u) == 0 );
Ritor1
parents:
diff changeset
1178 }
Ritor1
parents:
diff changeset
1179 v1->uTexturePacksCount = 0;
Ritor1
parents:
diff changeset
1180 v1->uNumPrevLoadedFiles = 0;
Ritor1
parents:
diff changeset
1181 v1->dword_11B84 = 0;
Ritor1
parents:
diff changeset
1182 v1->dword_11B80 = 0;
Ritor1
parents:
diff changeset
1183 v1->uNumLoadedFiles = 0;
Ritor1
parents:
diff changeset
1184 }
Ritor1
parents:
diff changeset
1185
Ritor1
parents:
diff changeset
1186 //----- (0040F9F0) --------------------------------------------------------
Ritor1
parents:
diff changeset
1187 unsigned int LODFile_IconsBitmaps::FindTextureByName(const char *pName)
Ritor1
parents:
diff changeset
1188 {
Ritor1
parents:
diff changeset
1189 LODFile_IconsBitmaps *v2; // esi@1
Ritor1
parents:
diff changeset
1190 unsigned int v3; // edi@1
Ritor1
parents:
diff changeset
1191 Texture *v4; // ebx@2
Ritor1
parents:
diff changeset
1192 unsigned int result; // eax@5
Ritor1
parents:
diff changeset
1193
Ritor1
parents:
diff changeset
1194 v2 = this;
Ritor1
parents:
diff changeset
1195 v3 = 0;
Ritor1
parents:
diff changeset
1196 if ( (signed int)this->uNumLoadedFiles <= 0 )
Ritor1
parents:
diff changeset
1197 {
Ritor1
parents:
diff changeset
1198 LABEL_5:
Ritor1
parents:
diff changeset
1199 result = -1;
Ritor1
parents:
diff changeset
1200 }
Ritor1
parents:
diff changeset
1201 else
Ritor1
parents:
diff changeset
1202 {
Ritor1
parents:
diff changeset
1203 v4 = this->pTextures;
Ritor1
parents:
diff changeset
1204 while ( _strcmpi(v4->pName, pName) )
Ritor1
parents:
diff changeset
1205 {
Ritor1
parents:
diff changeset
1206 ++v3;
Ritor1
parents:
diff changeset
1207 ++v4;
Ritor1
parents:
diff changeset
1208 if ( (signed int)v3 >= (signed int)v2->uNumLoadedFiles )
Ritor1
parents:
diff changeset
1209 goto LABEL_5;
Ritor1
parents:
diff changeset
1210 }
Ritor1
parents:
diff changeset
1211 result = v3;
Ritor1
parents:
diff changeset
1212 }
Ritor1
parents:
diff changeset
1213 return result;
Ritor1
parents:
diff changeset
1214 }
Ritor1
parents:
diff changeset
1215
Ritor1
parents:
diff changeset
1216 //----- (0040F9C5) --------------------------------------------------------
Ritor1
parents:
diff changeset
1217 int LODFile_IconsBitmaps::_40F9C5()
Ritor1
parents:
diff changeset
1218 {
Ritor1
parents:
diff changeset
1219 signed int result; // eax@1
Ritor1
parents:
diff changeset
1220 Texture *pTex; // edx@1
Ritor1
parents:
diff changeset
1221
Ritor1
parents:
diff changeset
1222 result = this->uNumLoadedFiles;
Ritor1
parents:
diff changeset
1223 for ( pTex = &this->pTextures[result]; !pTex->pName[0]; --pTex )
Ritor1
parents:
diff changeset
1224 --result;
Ritor1
parents:
diff changeset
1225 if ( result < (signed int)this->uNumLoadedFiles )
Ritor1
parents:
diff changeset
1226 {
Ritor1
parents:
diff changeset
1227 ++result;
Ritor1
parents:
diff changeset
1228 this->uNumLoadedFiles = result;
Ritor1
parents:
diff changeset
1229 }
Ritor1
parents:
diff changeset
1230 return result;
Ritor1
parents:
diff changeset
1231 }
Ritor1
parents:
diff changeset
1232
Ritor1
parents:
diff changeset
1233
Ritor1
parents:
diff changeset
1234
Ritor1
parents:
diff changeset
1235 //----- (0046249B) --------------------------------------------------------
Ritor1
parents:
diff changeset
1236 LODFile_Sprites::~LODFile_Sprites()
Ritor1
parents:
diff changeset
1237 {
Ritor1
parents:
diff changeset
1238 LODFile_Sprites *v1; // esi@1
Ritor1
parents:
diff changeset
1239 signed int v2; // ebx@1
Ritor1
parents:
diff changeset
1240 LODSprite *v3; // edi@3
Ritor1
parents:
diff changeset
1241 char *v4; // edi@6
Ritor1
parents:
diff changeset
1242 int thisa; // [sp+4h] [bp-10h]@3
Ritor1
parents:
diff changeset
1243 LODSprite *thisb; // [sp+4h] [bp-10h]@7
Ritor1
parents:
diff changeset
1244
Ritor1
parents:
diff changeset
1245 v1 = this;
Ritor1
parents:
diff changeset
1246 v2 = 0;
Ritor1
parents:
diff changeset
1247 if ( this->pHardwareSprites )
Ritor1
parents:
diff changeset
1248 {
Ritor1
parents:
diff changeset
1249 if ( (signed int)this->uNumLoadedSprites > 0 )
Ritor1
parents:
diff changeset
1250 {
Ritor1
parents:
diff changeset
1251 thisa = 0;
Ritor1
parents:
diff changeset
1252 v3 = this->pSpriteHeaders;
Ritor1
parents:
diff changeset
1253 do
Ritor1
parents:
diff changeset
1254 {
Ritor1
parents:
diff changeset
1255 v3->Release();
Ritor1
parents:
diff changeset
1256 v1->pHardwareSprites[thisa].Release();
Ritor1
parents:
diff changeset
1257 ++thisa;
Ritor1
parents:
diff changeset
1258 ++v2;
Ritor1
parents:
diff changeset
1259 ++v3;
Ritor1
parents:
diff changeset
1260 }
Ritor1
parents:
diff changeset
1261 while ( v2 < (signed int)v1->uNumLoadedSprites );
Ritor1
parents:
diff changeset
1262 }
Ritor1
parents:
diff changeset
1263 }
Ritor1
parents:
diff changeset
1264 else
Ritor1
parents:
diff changeset
1265 {
Ritor1
parents:
diff changeset
1266 v4 = (char *)&this->uNumLoadedSprites;
Ritor1
parents:
diff changeset
1267 if ( (signed int)this->uNumLoadedSprites > 0 )
Ritor1
parents:
diff changeset
1268 {
Ritor1
parents:
diff changeset
1269 thisb = this->pSpriteHeaders;
Ritor1
parents:
diff changeset
1270 do
Ritor1
parents:
diff changeset
1271 {
Ritor1
parents:
diff changeset
1272 thisb->Release();
Ritor1
parents:
diff changeset
1273 ++thisb;
Ritor1
parents:
diff changeset
1274 ++v2;
Ritor1
parents:
diff changeset
1275 }
Ritor1
parents:
diff changeset
1276 while ( v2 < *(int *)v4 );
Ritor1
parents:
diff changeset
1277 }
Ritor1
parents:
diff changeset
1278 }
Ritor1
parents:
diff changeset
1279 //_eh_vector_destructor_iterator_(v1->pSpriteHeaders, 40, 1500, LODSprite::dtor);
Ritor1
parents:
diff changeset
1280 //LOD::File::vdtor((LOD::File *)v1);
Ritor1
parents:
diff changeset
1281 }
Ritor1
parents:
diff changeset
1282 // 4CC2B4: using guessed type int __stdcall _eh vector destructor iterator_(int, int, int, int);
Ritor1
parents:
diff changeset
1283
Ritor1
parents:
diff changeset
1284
Ritor1
parents:
diff changeset
1285 //----- (00462463) --------------------------------------------------------
Ritor1
parents:
diff changeset
1286 LODSprite::~LODSprite()
Ritor1
parents:
diff changeset
1287 {
Ritor1
parents:
diff changeset
1288 LODSprite *v1; // esi@1
Ritor1
parents:
diff changeset
1289
Ritor1
parents:
diff changeset
1290 v1 = this;
Ritor1
parents:
diff changeset
1291 if ( !(HIBYTE(this->word_1A) & 4) )
Ritor1
parents:
diff changeset
1292 {
Ritor1
parents:
diff changeset
1293 pAllocator->FreeChunk(this->pDecompressedBytes);
Ritor1
parents:
diff changeset
1294 pAllocator->FreeChunk(v1->pSpriteLines);
Ritor1
parents:
diff changeset
1295 }
Ritor1
parents:
diff changeset
1296 v1->pDecompressedBytes = 0;
Ritor1
parents:
diff changeset
1297 v1->pSpriteLines = 0;
Ritor1
parents:
diff changeset
1298 }
Ritor1
parents:
diff changeset
1299
Ritor1
parents:
diff changeset
1300 //----- (004623E5) --------------------------------------------------------
Ritor1
parents:
diff changeset
1301 LODFile_Sprites::LODFile_Sprites():
Ritor1
parents:
diff changeset
1302 LOD::File()
Ritor1
parents:
diff changeset
1303 {
Ritor1
parents:
diff changeset
1304 /*_eh_vector_constructor_iterator_(
Ritor1
parents:
diff changeset
1305 v1->pSpriteHeaders,
Ritor1
parents:
diff changeset
1306 40,
Ritor1
parents:
diff changeset
1307 1500,
Ritor1
parents:
diff changeset
1308 (void (__thiscall *)(void *))LODSprite::LODSprite,
Ritor1
parents:
diff changeset
1309 (void (__thiscall *)(void *))LODSprite::dtor);*/
Ritor1
parents:
diff changeset
1310 field_ECA4 = 0;
Ritor1
parents:
diff changeset
1311 field_ECA0 = 0;
Ritor1
parents:
diff changeset
1312 pHardwareSprites = 0;
Ritor1
parents:
diff changeset
1313 field_ECAC = 0;
Ritor1
parents:
diff changeset
1314 field_ECB4 = 0;
Ritor1
parents:
diff changeset
1315 uNumLoadedSprites = 0;
Ritor1
parents:
diff changeset
1316 }
Ritor1
parents:
diff changeset
1317
Ritor1
parents:
diff changeset
1318 //----- (00462303) --------------------------------------------------------
Ritor1
parents:
diff changeset
1319 LODFile_IconsBitmaps::~LODFile_IconsBitmaps()
Ritor1
parents:
diff changeset
1320 {
Ritor1
parents:
diff changeset
1321 LODFile_IconsBitmaps *v1; // esi@1
Ritor1
parents:
diff changeset
1322 unsigned int v2; // edi@1
Ritor1
parents:
diff changeset
1323 struct IDirect3DTexture2 **v3; // eax@3
Ritor1
parents:
diff changeset
1324 struct IDirect3DTexture2 *v4; // eax@4
Ritor1
parents:
diff changeset
1325 struct IDirectDrawSurface **v5; // eax@6
Ritor1
parents:
diff changeset
1326 struct IDirectDrawSurface *v6; // eax@7
Ritor1
parents:
diff changeset
1327 Texture *thisa; // [sp+4h] [bp-10h]@2
Ritor1
parents:
diff changeset
1328
Ritor1
parents:
diff changeset
1329 v1 = this;
Ritor1
parents:
diff changeset
1330 v2 = this->uNumLoadedFiles - 1;
Ritor1
parents:
diff changeset
1331 if ( (v2 & 0x80000000u) == 0 )
Ritor1
parents:
diff changeset
1332 {
Ritor1
parents:
diff changeset
1333 thisa = &this->pTextures[v2];
Ritor1
parents:
diff changeset
1334 do
Ritor1
parents:
diff changeset
1335 {
Ritor1
parents:
diff changeset
1336 thisa->Release();
Ritor1
parents:
diff changeset
1337 v3 = v1->pHardwareTextures;
Ritor1
parents:
diff changeset
1338 if ( v3 )
Ritor1
parents:
diff changeset
1339 {
Ritor1
parents:
diff changeset
1340 v4 = v3[v2];
Ritor1
parents:
diff changeset
1341 if ( v4 )
Ritor1
parents:
diff changeset
1342 {
Ritor1
parents:
diff changeset
1343 v4->Release();
Ritor1
parents:
diff changeset
1344 v1->pHardwareTextures[v2] = 0;
Ritor1
parents:
diff changeset
1345 }
Ritor1
parents:
diff changeset
1346 }
Ritor1
parents:
diff changeset
1347 v5 = v1->pHardwareSurfaces;
Ritor1
parents:
diff changeset
1348 if ( v5 )
Ritor1
parents:
diff changeset
1349 {
Ritor1
parents:
diff changeset
1350 v6 = v5[v2];
Ritor1
parents:
diff changeset
1351 if ( v6 )
Ritor1
parents:
diff changeset
1352 {
Ritor1
parents:
diff changeset
1353 v6->Release();
Ritor1
parents:
diff changeset
1354 v1->pHardwareSurfaces[v2] = 0;
Ritor1
parents:
diff changeset
1355 }
Ritor1
parents:
diff changeset
1356 }
Ritor1
parents:
diff changeset
1357 --thisa;
Ritor1
parents:
diff changeset
1358 --v2;
Ritor1
parents:
diff changeset
1359 }
Ritor1
parents:
diff changeset
1360 while ( (v2 & 0x80000000u) == 0 );
Ritor1
parents:
diff changeset
1361 }
Ritor1
parents:
diff changeset
1362 if ( v1->pHardwareSurfaces )
Ritor1
parents:
diff changeset
1363 free(v1->pHardwareSurfaces);
Ritor1
parents:
diff changeset
1364 if ( v1->pHardwareTextures )
Ritor1
parents:
diff changeset
1365 free(v1->pHardwareTextures);
Ritor1
parents:
diff changeset
1366 if ( v1->ptr_011BB4 )
Ritor1
parents:
diff changeset
1367 free(v1->ptr_011BB4);
Ritor1
parents:
diff changeset
1368 //LOD::File::vdtor((LOD::File *)v1);
Ritor1
parents:
diff changeset
1369 }
Ritor1
parents:
diff changeset
1370
Ritor1
parents:
diff changeset
1371 //----- (00462272) --------------------------------------------------------
Ritor1
parents:
diff changeset
1372 LODFile_IconsBitmaps::LODFile_IconsBitmaps():
Ritor1
parents:
diff changeset
1373 LOD::File()
Ritor1
parents:
diff changeset
1374 {
Ritor1
parents:
diff changeset
1375 LODFile_IconsBitmaps *v1; // esi@1
Ritor1
parents:
diff changeset
1376 Texture *v2; // ebx@1
Ritor1
parents:
diff changeset
1377 signed int v3; // [sp+4h] [bp-10h]@1
Ritor1
parents:
diff changeset
1378
Ritor1
parents:
diff changeset
1379 v1 = this;
Ritor1
parents:
diff changeset
1380 /*v2 = v1->pTextures;
Ritor1
parents:
diff changeset
1381 v3 = 1000;
Ritor1
parents:
diff changeset
1382 do
Ritor1
parents:
diff changeset
1383 {
Ritor1
parents:
diff changeset
1384 Texture::Texture(v2);
Ritor1
parents:
diff changeset
1385 ++v2;
Ritor1
parents:
diff changeset
1386 --v3;
Ritor1
parents:
diff changeset
1387 }
Ritor1
parents:
diff changeset
1388 while ( v3 );*/
Ritor1
parents:
diff changeset
1389 v1->uTexturePacksCount = 0;
Ritor1
parents:
diff changeset
1390 v1->uNumPrevLoadedFiles = 0;
Ritor1
parents:
diff changeset
1391 v1->dword_11B84 = 0;
Ritor1
parents:
diff changeset
1392 v1->dword_11B80 = 0;
Ritor1
parents:
diff changeset
1393 v1->uNumLoadedFiles = 0;
Ritor1
parents:
diff changeset
1394 v1->dword_011BA4 = 0;
Ritor1
parents:
diff changeset
1395 v1->dword_011BA8 = 0;
Ritor1
parents:
diff changeset
1396 v1->pHardwareSurfaces = 0;
Ritor1
parents:
diff changeset
1397 v1->pHardwareTextures = 0;
Ritor1
parents:
diff changeset
1398 v1->ptr_011BB4 = 0;
Ritor1
parents:
diff changeset
1399 }
Ritor1
parents:
diff changeset
1400
Ritor1
parents:
diff changeset
1401
Ritor1
parents:
diff changeset
1402 //----- (004621A7) --------------------------------------------------------
Ritor1
parents:
diff changeset
1403 bool LODWriteableFile::_4621A7()
Ritor1
parents:
diff changeset
1404 {
Ritor1
parents:
diff changeset
1405 CloseWriteFile();
Ritor1
parents:
diff changeset
1406 return LoadFile(pLODName, 0);
Ritor1
parents:
diff changeset
1407 }
Ritor1
parents:
diff changeset
1408
Ritor1
parents:
diff changeset
1409
Ritor1
parents:
diff changeset
1410 //----- (00461FD4) --------------------------------------------------------
Ritor1
parents:
diff changeset
1411 int LODWriteableFile::Save()
Ritor1
parents:
diff changeset
1412 {
Ritor1
parents:
diff changeset
1413 LODWriteableFile *v1; // esi@1
Ritor1
parents:
diff changeset
1414 int v2; // edi@1
Ritor1
parents:
diff changeset
1415 unsigned int v3; // edx@1
Ritor1
parents:
diff changeset
1416 LOD::Directory *v4; // eax@2
Ritor1
parents:
diff changeset
1417 unsigned int v5; // ecx@2
Ritor1
parents:
diff changeset
1418 int v6; // eax@2
Ritor1
parents:
diff changeset
1419 signed int v7; // ebx@5
Ritor1
parents:
diff changeset
1420 int v8; // ecx@5
Ritor1
parents:
diff changeset
1421 LOD::Directory **v9; // edi@6
Ritor1
parents:
diff changeset
1422 int v10; // edx@6
Ritor1
parents:
diff changeset
1423 LOD::Directory *v11; // eax@6
Ritor1
parents:
diff changeset
1424 FILE *v12; // eax@9
Ritor1
parents:
diff changeset
1425 FILE *v13; // ebx@9
Ritor1
parents:
diff changeset
1426 signed int result; // eax@10
Ritor1
parents:
diff changeset
1427 unsigned int v15; // eax@11
Ritor1
parents:
diff changeset
1428 FILE *v16; // ST00_4@11
Ritor1
parents:
diff changeset
1429 size_t v17; // edi@12
Ritor1
parents:
diff changeset
1430 char OldFilename[256]; // [sp+Ch] [bp-228h]@9
Ritor1
parents:
diff changeset
1431 char NewFilename[256]; // [sp+10Ch] [bp-128h]@15
Ritor1
parents:
diff changeset
1432 //LOD::Directory v0; // [sp+20Ch] [bp-28h]@11
Ritor1
parents:
diff changeset
1433 unsigned int v21; // [sp+22Ch] [bp-8h]@5
Ritor1
parents:
diff changeset
1434 int v22; // [sp+230h] [bp-4h]@1
Ritor1
parents:
diff changeset
1435
Ritor1
parents:
diff changeset
1436 v1 = this;
Ritor1
parents:
diff changeset
1437 v2 = 0;
Ritor1
parents:
diff changeset
1438 v3 = this->uNumSubIndices;
Ritor1
parents:
diff changeset
1439 v22 = 0;
Ritor1
parents:
diff changeset
1440 if ( (signed int)v3 > 0 )
Ritor1
parents:
diff changeset
1441 {
Ritor1
parents:
diff changeset
1442 v4 = this->pSubIndices;
Ritor1
parents:
diff changeset
1443 v5 = v3;
Ritor1
parents:
diff changeset
1444 v6 = (int)&v4->uDataSize;
Ritor1
parents:
diff changeset
1445 do
Ritor1
parents:
diff changeset
1446 {
Ritor1
parents:
diff changeset
1447 v2 += *(int *)v6;
Ritor1
parents:
diff changeset
1448 v6 += 32;
Ritor1
parents:
diff changeset
1449 --v5;
Ritor1
parents:
diff changeset
1450 }
Ritor1
parents:
diff changeset
1451 while ( v5 );
Ritor1
parents:
diff changeset
1452 v22 = v2;
Ritor1
parents:
diff changeset
1453 }
Ritor1
parents:
diff changeset
1454 v7 = 0;
Ritor1
parents:
diff changeset
1455 v21 = 32 * v3 + v2;
Ritor1
parents:
diff changeset
1456 v8 = 32 * v3;
Ritor1
parents:
diff changeset
1457 if ( (signed int)v3 > 0 )
Ritor1
parents:
diff changeset
1458 {
Ritor1
parents:
diff changeset
1459 v9 = &v1->pSubIndices;
Ritor1
parents:
diff changeset
1460 v10 = 0;
Ritor1
parents:
diff changeset
1461 v11 = v1->pSubIndices;
Ritor1
parents:
diff changeset
1462 do
Ritor1
parents:
diff changeset
1463 {
Ritor1
parents:
diff changeset
1464 v11[v10].uOfsetFromSubindicesStart = v8;
Ritor1
parents:
diff changeset
1465 v11 = *v9;
Ritor1
parents:
diff changeset
1466 v8 += (*v9)[v10].uDataSize;
Ritor1
parents:
diff changeset
1467 ++v7;
Ritor1
parents:
diff changeset
1468 ++v10;
Ritor1
parents:
diff changeset
1469 }
Ritor1
parents:
diff changeset
1470 while ( v7 < (signed int)v1->uNumSubIndices );
Ritor1
parents:
diff changeset
1471 v2 = v22;
Ritor1
parents:
diff changeset
1472 }
Ritor1
parents:
diff changeset
1473 strcpy(OldFilename, "lod.tmp");
Ritor1
parents:
diff changeset
1474 v12 = fopen(OldFilename, "wb+");
Ritor1
parents:
diff changeset
1475 v13 = v12;
Ritor1
parents:
diff changeset
1476 if ( v12 )
Ritor1
parents:
diff changeset
1477 {
Ritor1
parents:
diff changeset
1478 fwrite(&v1->header, 0x100, 1, v12);
Ritor1
parents:
diff changeset
1479
Ritor1
parents:
diff changeset
1480 LOD::Directory v0; // [sp+20Ch] [bp-28h]@11
Ritor1
parents:
diff changeset
1481 //LOD::Directory::LOD::Directory(&v0);
Ritor1
parents:
diff changeset
1482
Ritor1
parents:
diff changeset
1483 strcpy((char *)&v0, "chapter");
Ritor1
parents:
diff changeset
1484 v15 = v1->uOffsetToSubIndex;
Ritor1
parents:
diff changeset
1485 v0.dword_000018 = 0;
Ritor1
parents:
diff changeset
1486 v0.uOfsetFromSubindicesStart = v15;
Ritor1
parents:
diff changeset
1487 v0.word_00001E = 0;
Ritor1
parents:
diff changeset
1488 v0.uDataSize = v21;
Ritor1
parents:
diff changeset
1489 v0.uNumSubIndices = LOWORD(v1->uNumSubIndices);
Ritor1
parents:
diff changeset
1490 fwrite(&v0, 0x20, 1, v13);
Ritor1
parents:
diff changeset
1491 fwrite(v1->pSubIndices, 0x20, v1->uNumSubIndices, v13);
Ritor1
parents:
diff changeset
1492 v16 = v1->pOutputFileHandle;
Ritor1
parents:
diff changeset
1493 v22 = v2;
Ritor1
parents:
diff changeset
1494 fseek(v16, 0, 0);
Ritor1
parents:
diff changeset
1495 if ( v2 > 0 )
Ritor1
parents:
diff changeset
1496 {
Ritor1
parents:
diff changeset
1497 do
Ritor1
parents:
diff changeset
1498 {
Ritor1
parents:
diff changeset
1499 v17 = v1->uIOBufferSize;
Ritor1
parents:
diff changeset
1500 if ( v22 <= (signed int)v17 )
Ritor1
parents:
diff changeset
1501 v17 = v22;
Ritor1
parents:
diff changeset
1502 fread(v1->pIOBuffer, 1, v17, v1->pOutputFileHandle);
Ritor1
parents:
diff changeset
1503 fwrite(v1->pIOBuffer, 1, v17, v13);
Ritor1
parents:
diff changeset
1504 v22 -= v17;
Ritor1
parents:
diff changeset
1505 }
Ritor1
parents:
diff changeset
1506 while ( v22 > 0 );
Ritor1
parents:
diff changeset
1507 }
Ritor1
parents:
diff changeset
1508 strcpy(NewFilename, (const char *)v1->pLODName);
Ritor1
parents:
diff changeset
1509 fclose(v13);
Ritor1
parents:
diff changeset
1510 fclose(v1->pOutputFileHandle);
Ritor1
parents:
diff changeset
1511 v1->CloseWriteFile();
Ritor1
parents:
diff changeset
1512 remove("lodapp.tmp");
Ritor1
parents:
diff changeset
1513 remove(NewFilename);
Ritor1
parents:
diff changeset
1514 rename(OldFilename, NewFilename);
Ritor1
parents:
diff changeset
1515 v1->CloseWriteFile();
Ritor1
parents:
diff changeset
1516 v1->LoadFile(v1->pLODName, 0);
Ritor1
parents:
diff changeset
1517 result = 0;
Ritor1
parents:
diff changeset
1518 }
Ritor1
parents:
diff changeset
1519 else
Ritor1
parents:
diff changeset
1520 {
Ritor1
parents:
diff changeset
1521 result = 5;
Ritor1
parents:
diff changeset
1522 }
Ritor1
parents:
diff changeset
1523 return result;
Ritor1
parents:
diff changeset
1524 }
Ritor1
parents:
diff changeset
1525
Ritor1
parents:
diff changeset
1526
Ritor1
parents:
diff changeset
1527 //----- (00461F71) --------------------------------------------------------
Ritor1
parents:
diff changeset
1528 bool LOD::File::AppendDirectory(LOD::Directory *pDir, const void *pData)
Ritor1
parents:
diff changeset
1529 {
Ritor1
parents:
diff changeset
1530 unsigned int v3; // edi@1
Ritor1
parents:
diff changeset
1531 bool result; // eax@2
Ritor1
parents:
diff changeset
1532 FILE *v5; // ST0C_4@3
Ritor1
parents:
diff changeset
1533
Ritor1
parents:
diff changeset
1534 v3 = this->uNumSubIndices;
Ritor1
parents:
diff changeset
1535 if ( (signed int)v3 < 299 )
Ritor1
parents:
diff changeset
1536 {
Ritor1
parents:
diff changeset
1537 memcpy(&this->pSubIndices[v3], pDir, sizeof(this->pSubIndices[v3]));
Ritor1
parents:
diff changeset
1538 v5 = this->pOutputFileHandle;
Ritor1
parents:
diff changeset
1539 ++this->uNumSubIndices;
Ritor1
parents:
diff changeset
1540 fwrite(pData, 1u, pDir->uDataSize, v5);
Ritor1
parents:
diff changeset
1541 result = 1;
Ritor1
parents:
diff changeset
1542 }
Ritor1
parents:
diff changeset
1543 else
Ritor1
parents:
diff changeset
1544 {
Ritor1
parents:
diff changeset
1545 MessageBoxA(0, "Unable to append item!", "LOD::File", 0x30u);
Ritor1
parents:
diff changeset
1546 result = 0;
Ritor1
parents:
diff changeset
1547 }
Ritor1
parents:
diff changeset
1548 return result;
Ritor1
parents:
diff changeset
1549 }
Ritor1
parents:
diff changeset
1550
Ritor1
parents:
diff changeset
1551
Ritor1
parents:
diff changeset
1552 //----- (00461F1E) --------------------------------------------------------
Ritor1
parents:
diff changeset
1553 int LODWriteableFile::CreateTempFile()
Ritor1
parents:
diff changeset
1554 {
Ritor1
parents:
diff changeset
1555 LODWriteableFile *v1; // esi@1
Ritor1
parents:
diff changeset
1556 int result; // eax@2
Ritor1
parents:
diff changeset
1557 FILE *pFile; // eax@5
Ritor1
parents:
diff changeset
1558 int v4; // eax@5
Ritor1
parents:
diff changeset
1559
Ritor1
parents:
diff changeset
1560 v1 = this;
Ritor1
parents:
diff changeset
1561 if ( this->isFileOpened )
Ritor1
parents:
diff changeset
1562 {
Ritor1
parents:
diff changeset
1563 if ( this->pIOBuffer && this->uIOBufferSize )
Ritor1
parents:
diff changeset
1564 {
Ritor1
parents:
diff changeset
1565 this->uCurrentIndexDir = 0;
Ritor1
parents:
diff changeset
1566 this->uNumSubIndices = 0;
Ritor1
parents:
diff changeset
1567 pFile = fopen("lodapp.tmp", "wb+");
Ritor1
parents:
diff changeset
1568 v1->pOutputFileHandle = pFile;
Ritor1
parents:
diff changeset
1569 v4 = -(pFile != 0);
Ritor1
parents:
diff changeset
1570 LOBYTE(v4) = v4 & 0xF9;
Ritor1
parents:
diff changeset
1571 result = v4 + 7;
Ritor1
parents:
diff changeset
1572 }
Ritor1
parents:
diff changeset
1573 else
Ritor1
parents:
diff changeset
1574 {
Ritor1
parents:
diff changeset
1575 result = 5;
Ritor1
parents:
diff changeset
1576 }
Ritor1
parents:
diff changeset
1577 }
Ritor1
parents:
diff changeset
1578 else
Ritor1
parents:
diff changeset
1579 {
Ritor1
parents:
diff changeset
1580 result = 1;
Ritor1
parents:
diff changeset
1581 }
Ritor1
parents:
diff changeset
1582 return result;
Ritor1
parents:
diff changeset
1583 }
Ritor1
parents:
diff changeset
1584
Ritor1
parents:
diff changeset
1585
Ritor1
parents:
diff changeset
1586
Ritor1
parents:
diff changeset
1587 //----- (00461EE9) --------------------------------------------------------
Ritor1
parents:
diff changeset
1588 void LODWriteableFile::CloseWriteFile()
Ritor1
parents:
diff changeset
1589 {
Ritor1
parents:
diff changeset
1590 if (isFileOpened)
Ritor1
parents:
diff changeset
1591 {
Ritor1
parents:
diff changeset
1592 pContainerName[0] = 0;
Ritor1
parents:
diff changeset
1593 uCurrentIndexDir = 0;
Ritor1
parents:
diff changeset
1594 _6A0CA8_lod_unused = 0;
Ritor1
parents:
diff changeset
1595
Ritor1
parents:
diff changeset
1596 isFileOpened = false;
Ritor1
parents:
diff changeset
1597 fflush(pFile);
Ritor1
parents:
diff changeset
1598 fclose(pFile);
Ritor1
parents:
diff changeset
1599 pFile = 0;
Ritor1
parents:
diff changeset
1600 }
Ritor1
parents:
diff changeset
1601 }
Ritor1
parents:
diff changeset
1602 // 6A0CA8: using guessed type int 6A0CA8_lod_unused;
Ritor1
parents:
diff changeset
1603
Ritor1
parents:
diff changeset
1604
Ritor1
parents:
diff changeset
1605 //----- (00461B48) --------------------------------------------------------
Ritor1
parents:
diff changeset
1606 unsigned int LODWriteableFile::Write(const LOD::Directory *pDir, const void *pDirData, int a4)
Ritor1
parents:
diff changeset
1607 {
Ritor1
parents:
diff changeset
1608 LODWriteableFile *v4; // ebx@1
Ritor1
parents:
diff changeset
1609 int v5; // esi@1
Ritor1
parents:
diff changeset
1610 unsigned __int8 v7; // zf@7
Ritor1
parents:
diff changeset
1611 unsigned __int8 v8; // sf@7
Ritor1
parents:
diff changeset
1612 const LOD::Directory *v9; // edi@9
Ritor1
parents:
diff changeset
1613 int v10; // eax@9
Ritor1
parents:
diff changeset
1614 unsigned __int8 v11; // of@15
Ritor1
parents:
diff changeset
1615 unsigned __int16 v12; // dx@17
Ritor1
parents:
diff changeset
1616 LOD::Directory *v13; // eax@17
Ritor1
parents:
diff changeset
1617 unsigned __int16 v14; // cx@17
Ritor1
parents:
diff changeset
1618 int v15; // edi@27
Ritor1
parents:
diff changeset
1619 unsigned int v16; // eax@27
Ritor1
parents:
diff changeset
1620 int v17; // eax@29
Ritor1
parents:
diff changeset
1621 int v18; // edx@31
Ritor1
parents:
diff changeset
1622 int v19; // eax@31
Ritor1
parents:
diff changeset
1623 void *v20; // edi@32
Ritor1
parents:
diff changeset
1624 LOD::Directory *v21; // edi@34
Ritor1
parents:
diff changeset
1625 signed int v22; // esi@34
Ritor1
parents:
diff changeset
1626 int v23; // eax@34
Ritor1
parents:
diff changeset
1627 LOD::Directory *v24; // ecx@35
Ritor1
parents:
diff changeset
1628 int v25; // edx@35
Ritor1
parents:
diff changeset
1629 __int32 v26; // eax@37
Ritor1
parents:
diff changeset
1630 int i; // esi@39
Ritor1
parents:
diff changeset
1631 __int32 v28; // esi@46
Ritor1
parents:
diff changeset
1632 char pFilename[256]; // [sp+Ch] [bp-230h]@22
Ritor1
parents:
diff changeset
1633 char NewFilename[256]; // [sp+10Ch] [bp-130h]@51
Ritor1
parents:
diff changeset
1634 //LOD::Directory Str; // [sp+20Ch] [bp-30h]@27
Ritor1
parents:
diff changeset
1635 size_t v33; // [sp+22Ch] [bp-10h]@27
Ritor1
parents:
diff changeset
1636 int v34; // [sp+230h] [bp-Ch]@7
Ritor1
parents:
diff changeset
1637 __int32 v35; // [sp+234h] [bp-8h]@8
Ritor1
parents:
diff changeset
1638 int v36; // [sp+238h] [bp-4h]@7
Ritor1
parents:
diff changeset
1639 size_t Count; // [sp+244h] [bp+8h]@40
Ritor1
parents:
diff changeset
1640 __int32 Countc; // [sp+244h] [bp+8h]@46
Ritor1
parents:
diff changeset
1641 size_t Countb; // [sp+244h] [bp+8h]@47
Ritor1
parents:
diff changeset
1642 FILE *pFile; // [sp+24Ch] [bp+10h]@22
Ritor1
parents:
diff changeset
1643
Ritor1
parents:
diff changeset
1644 v4 = this;
Ritor1
parents:
diff changeset
1645 v5 = 0;
Ritor1
parents:
diff changeset
1646 if ( !this->isFileOpened )
Ritor1
parents:
diff changeset
1647 return 1;
Ritor1
parents:
diff changeset
1648 if ( !this->pSubIndices )
Ritor1
parents:
diff changeset
1649 return 2;
Ritor1
parents:
diff changeset
1650 if ( !this->pIOBuffer || !this->uIOBufferSize )
Ritor1
parents:
diff changeset
1651 return 3;
Ritor1
parents:
diff changeset
1652 v7 = this->uNumSubIndices == 0;
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 415
diff changeset
1653 v8 = false;//this->uNumSubIndices != 0; // v8 = (this->uNumSubIndices & 0x80000000u) != 0;
0
Ritor1
parents:
diff changeset
1654 v36 = 0;
Ritor1
parents:
diff changeset
1655 v34 = 0;
Ritor1
parents:
diff changeset
1656 if ( v8 | v7 )
Ritor1
parents:
diff changeset
1657 {
Ritor1
parents:
diff changeset
1658 v9 = pDir;
Ritor1
parents:
diff changeset
1659 goto LABEL_22;
Ritor1
parents:
diff changeset
1660 }
Ritor1
parents:
diff changeset
1661 v35 = 0;
Ritor1
parents:
diff changeset
1662 while ( 1 )
Ritor1
parents:
diff changeset
1663 {
Ritor1
parents:
diff changeset
1664 v9 = pDir;
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 415
diff changeset
1665 v10 = _strcmpi(v4->pSubIndices[v5].pFilename + v35, pDir->pFilename);
0
Ritor1
parents:
diff changeset
1666 if ( v10 )
Ritor1
parents:
diff changeset
1667 {
Ritor1
parents:
diff changeset
1668 if ( v10 > 0 )
Ritor1
parents:
diff changeset
1669 goto LABEL_22;
Ritor1
parents:
diff changeset
1670 goto LABEL_15;
Ritor1
parents:
diff changeset
1671 }
Ritor1
parents:
diff changeset
1672 if ( !a4 )
Ritor1
parents:
diff changeset
1673 goto LABEL_20;
Ritor1
parents:
diff changeset
1674 if ( a4 == 1 )
Ritor1
parents:
diff changeset
1675 break;
Ritor1
parents:
diff changeset
1676 if ( a4 == 2 )
Ritor1
parents:
diff changeset
1677 return 4;
Ritor1
parents:
diff changeset
1678 LABEL_15:
Ritor1
parents:
diff changeset
1679 v35 += 32;
Ritor1
parents:
diff changeset
1680 ++v5;
Ritor1
parents:
diff changeset
1681 v11 = v5 >= v4->uNumSubIndices;
17
fe0d9a98213f 17.01.13 (fix Hint error)
Ritor1
parents: 0
diff changeset
1682 v8 = (v5 - v4->uNumSubIndices) != 0;//v8 = ((v5 - v4->uNumSubIndices) & 0x80000000u) != 0;
0
Ritor1
parents:
diff changeset
1683 v34 = v5;
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 415
diff changeset
1684 //if ( !(v8 ^ v11) )
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 415
diff changeset
1685 if (v5 >= v4->uNumSubIndices)
0
Ritor1
parents:
diff changeset
1686 goto LABEL_22;
Ritor1
parents:
diff changeset
1687 }
Ritor1
parents:
diff changeset
1688 v12 = pDir->uNumSubIndices;
Ritor1
parents:
diff changeset
1689 v13 = &v4->pSubIndices[v5];
Ritor1
parents:
diff changeset
1690 v14 = v13->uNumSubIndices;
Ritor1
parents:
diff changeset
1691 if ( v14 >= v12 && (v14 != v12 || (unsigned __int16)v13->word_00001E >= pDir->word_00001E) )
Ritor1
parents:
diff changeset
1692 return 4;
Ritor1
parents:
diff changeset
1693 LABEL_20:
Ritor1
parents:
diff changeset
1694 v36 = 1;
Ritor1
parents:
diff changeset
1695 LABEL_22:
Ritor1
parents:
diff changeset
1696 strcpy(pFilename, "lod.tmp");
Ritor1
parents:
diff changeset
1697 pFile = fopen(pFilename, "wb+");
Ritor1
parents:
diff changeset
1698 if ( !pFile )
Ritor1
parents:
diff changeset
1699 return 5;
Ritor1
parents:
diff changeset
1700 if ( v36 )
Ritor1
parents:
diff changeset
1701 v35 = v4->pSubIndices[v5].uDataSize;
Ritor1
parents:
diff changeset
1702 else
Ritor1
parents:
diff changeset
1703 v35 = 0;
Ritor1
parents:
diff changeset
1704 v33 = v9->uDataSize;
Ritor1
parents:
diff changeset
1705 v15 = v33 - v35;
Ritor1
parents:
diff changeset
1706
Ritor1
parents:
diff changeset
1707 LOD::Directory Str; // [sp+20Ch] [bp-30h]@27
Ritor1
parents:
diff changeset
1708 //LOD::Directory::LOD::Directory(&Str);
Ritor1
parents:
diff changeset
1709
Ritor1
parents:
diff changeset
1710 strcpy((char *)&Str, "chapter");
Ritor1
parents:
diff changeset
1711 v16 = v4->uLODDataSize;
Ritor1
parents:
diff changeset
1712 Str.uNumSubIndices = LOWORD(v4->uNumSubIndices);
Ritor1
parents:
diff changeset
1713 Str.dword_000018 = 0;
Ritor1
parents:
diff changeset
1714 Str.word_00001E = 0;
Ritor1
parents:
diff changeset
1715 if ( !v36 )
Ritor1
parents:
diff changeset
1716 {
Ritor1
parents:
diff changeset
1717 ++Str.uNumSubIndices;
Ritor1
parents:
diff changeset
1718 v15 += 32;
Ritor1
parents:
diff changeset
1719 }
Ritor1
parents:
diff changeset
1720 v7 = v36 == 0;
Ritor1
parents:
diff changeset
1721 Str.uDataSize = v15 + v16;
Ritor1
parents:
diff changeset
1722 Str.uOfsetFromSubindicesStart = 288;
Ritor1
parents:
diff changeset
1723 v17 = (signed __int16)Str.uNumSubIndices;
Ritor1
parents:
diff changeset
1724 v4->uNumSubIndices = (signed __int16)Str.uNumSubIndices;
Ritor1
parents:
diff changeset
1725 if ( v7 && v17 > v5 )
Ritor1
parents:
diff changeset
1726 {
Ritor1
parents:
diff changeset
1727 v18 = v17;
Ritor1
parents:
diff changeset
1728 v19 = v17 - v5;
Ritor1
parents:
diff changeset
1729 do
Ritor1
parents:
diff changeset
1730 {
Ritor1
parents:
diff changeset
1731 v20 = &v4->pSubIndices[v18];
Ritor1
parents:
diff changeset
1732 --v18;
Ritor1
parents:
diff changeset
1733 --v19;
Ritor1
parents:
diff changeset
1734 memcpy(v20, (char *)v20 - 32, 0x20u);
Ritor1
parents:
diff changeset
1735 }
Ritor1
parents:
diff changeset
1736 while ( v19 );
Ritor1
parents:
diff changeset
1737 v5 = v34;
Ritor1
parents:
diff changeset
1738 }
Ritor1
parents:
diff changeset
1739 v21 = v4->pSubIndices;
Ritor1
parents:
diff changeset
1740 v34 = 32 * v5;
Ritor1
parents:
diff changeset
1741 memcpy(&v21[v5], pDir, sizeof(v21[v5]));
Ritor1
parents:
diff changeset
1742 v22 = 0;
Ritor1
parents:
diff changeset
1743 v23 = 32 * v4->uNumSubIndices;
Ritor1
parents:
diff changeset
1744 if ( (signed int)v4->uNumSubIndices > 0 )
Ritor1
parents:
diff changeset
1745 {
Ritor1
parents:
diff changeset
1746 v24 = v4->pSubIndices;
Ritor1
parents:
diff changeset
1747 v25 = 0;
Ritor1
parents:
diff changeset
1748 do
Ritor1
parents:
diff changeset
1749 {
Ritor1
parents:
diff changeset
1750 v24[v25].uOfsetFromSubindicesStart = v23;
Ritor1
parents:
diff changeset
1751 v24 = v4->pSubIndices;
Ritor1
parents:
diff changeset
1752 v23 += v24[v25].uDataSize;
Ritor1
parents:
diff changeset
1753 ++v22;
Ritor1
parents:
diff changeset
1754 ++v25;
Ritor1
parents:
diff changeset
1755 }
Ritor1
parents:
diff changeset
1756 while ( v22 < (signed int)v4->uNumSubIndices );
Ritor1
parents:
diff changeset
1757 }
Ritor1
parents:
diff changeset
1758 fwrite(&v4->header, 0x100u, 1u, pFile);
Ritor1
parents:
diff changeset
1759 fwrite(&Str, 0x20, 1, pFile);
Ritor1
parents:
diff changeset
1760 fseek(v4->pFile, Str.uOfsetFromSubindicesStart, 0);
Ritor1
parents:
diff changeset
1761 fwrite(v4->pSubIndices, 0x20u, v4->uNumSubIndices, pFile);
Ritor1
parents:
diff changeset
1762 v26 = 32 * v4->uNumSubIndices;
Ritor1
parents:
diff changeset
1763 if ( !v36 )
Ritor1
parents:
diff changeset
1764 v26 -= 32;
Ritor1
parents:
diff changeset
1765 fseek(v4->pFile, v26, 1);
Ritor1
parents:
diff changeset
1766 for ( i = *(unsigned int *)((char *)&v4->pSubIndices->uOfsetFromSubindicesStart + v34)
Ritor1
parents:
diff changeset
1767 - v4->pSubIndices->uOfsetFromSubindicesStart; i > 0; i -= Count )
Ritor1
parents:
diff changeset
1768 {
Ritor1
parents:
diff changeset
1769 Count = v4->uIOBufferSize;
Ritor1
parents:
diff changeset
1770 if ( i <= (signed int)v4->uIOBufferSize )
Ritor1
parents:
diff changeset
1771 Count = i;
Ritor1
parents:
diff changeset
1772 fread(v4->pIOBuffer, 1u, Count, v4->pFile);
Ritor1
parents:
diff changeset
1773 fwrite(v4->pIOBuffer, 1u, Count, pFile);
Ritor1
parents:
diff changeset
1774 }
Ritor1
parents:
diff changeset
1775 fwrite(pDirData, 1u, v33, pFile);
Ritor1
parents:
diff changeset
1776 if ( v36 )
Ritor1
parents:
diff changeset
1777 fseek(v4->pFile, v35, 1);
Ritor1
parents:
diff changeset
1778 Countc = ftell(v4->pFile);
Ritor1
parents:
diff changeset
1779 fseek(v4->pFile, 0, 2);
Ritor1
parents:
diff changeset
1780 v28 = ftell(v4->pFile) - Countc;
Ritor1
parents:
diff changeset
1781 fseek(v4->pFile, Countc, 0);
Ritor1
parents:
diff changeset
1782 while ( v28 > 0 )
Ritor1
parents:
diff changeset
1783 {
Ritor1
parents:
diff changeset
1784 Countb = v4->uIOBufferSize;
Ritor1
parents:
diff changeset
1785 if ( v28 <= (signed int)v4->uIOBufferSize )
Ritor1
parents:
diff changeset
1786 Countb = v28;
Ritor1
parents:
diff changeset
1787 fread(v4->pIOBuffer, 1u, Countb, v4->pFile);
Ritor1
parents:
diff changeset
1788 fwrite(v4->pIOBuffer, 1u, Countb, pFile);
Ritor1
parents:
diff changeset
1789 v28 -= Countb;
Ritor1
parents:
diff changeset
1790 }
Ritor1
parents:
diff changeset
1791 strcpy(NewFilename, (const char *)v4->pLODName);
Ritor1
parents:
diff changeset
1792 fclose(pFile);
Ritor1
parents:
diff changeset
1793 v4->CloseWriteFile();
Ritor1
parents:
diff changeset
1794 remove(NewFilename);
Ritor1
parents:
diff changeset
1795 rename(pFilename, NewFilename);
Ritor1
parents:
diff changeset
1796 v4->CloseWriteFile();
Ritor1
parents:
diff changeset
1797 v4->LoadFile(v4->pLODName, 0);
Ritor1
parents:
diff changeset
1798 return 0;
Ritor1
parents:
diff changeset
1799 }
Ritor1
parents:
diff changeset
1800
Ritor1
parents:
diff changeset
1801
Ritor1
parents:
diff changeset
1802 //----- (00461A43) --------------------------------------------------------
Ritor1
parents:
diff changeset
1803 bool LODWriteableFile::LoadFile(const char *pFilename, bool bWriting)
Ritor1
parents:
diff changeset
1804 {
Ritor1
parents:
diff changeset
1805 LODWriteableFile *v3; // esi@1
Ritor1
parents:
diff changeset
1806 FILE *pFile_dup; // eax@4
Ritor1
parents:
diff changeset
1807 unsigned int v5; // ecx@5
Ritor1
parents:
diff changeset
1808 __int32 v6; // eax@5
Ritor1
parents:
diff changeset
1809 FILE *v7; // ST00_4@5
Ritor1
parents:
diff changeset
1810 size_t v8; // edi@5
Ritor1
parents:
diff changeset
1811 const char *v10; // [sp-4h] [bp-30h]@2
Ritor1
parents:
diff changeset
1812
Ritor1
parents:
diff changeset
1813 v3 = this;
Ritor1
parents:
diff changeset
1814 if ( bWriting & 1 )
Ritor1
parents:
diff changeset
1815 v10 = "rb";
Ritor1
parents:
diff changeset
1816 else
Ritor1
parents:
diff changeset
1817 v10 = "rb+";
Ritor1
parents:
diff changeset
1818 pFile_dup = fopen(pFilename, v10);
Ritor1
parents:
diff changeset
1819 v3->pFile = pFile_dup;
Ritor1
parents:
diff changeset
1820 if ( !pFile_dup )
Ritor1
parents:
diff changeset
1821 {
Ritor1
parents:
diff changeset
1822 isFileOpened = false;
Ritor1
parents:
diff changeset
1823 return 0;
Ritor1
parents:
diff changeset
1824 }
Ritor1
parents:
diff changeset
1825 strcpy(pLODName, pFilename);
Ritor1
parents:
diff changeset
1826 fread(&header, 0x100u, 1u, v3->pFile);
Ritor1
parents:
diff changeset
1827
Ritor1
parents:
diff changeset
1828 LOD::Directory dir; // [sp+Ch] [bp-20h]@5
Ritor1
parents:
diff changeset
1829 //LOD::Directory::LOD::Directory(&dir);
Ritor1
parents:
diff changeset
1830
Ritor1
parents:
diff changeset
1831 fread(&dir, 0x20u, 1u, v3->pFile);
Ritor1
parents:
diff changeset
1832 fseek(v3->pFile, 0, 0);
Ritor1
parents:
diff changeset
1833 isFileOpened = 1;
Ritor1
parents:
diff changeset
1834 strcpy((char *)v3->pContainerName, "chapter");
Ritor1
parents:
diff changeset
1835 v5 = (signed __int16)dir.uNumSubIndices;
Ritor1
parents:
diff changeset
1836 v6 = dir.uOfsetFromSubindicesStart;
Ritor1
parents:
diff changeset
1837 v3->uCurrentIndexDir = 0;
Ritor1
parents:
diff changeset
1838 v3->uOffsetToSubIndex = v6;
Ritor1
parents:
diff changeset
1839 v7 = v3->pFile;
Ritor1
parents:
diff changeset
1840 v3->uNumSubIndices = v5;
Ritor1
parents:
diff changeset
1841 v3->uLODDataSize = dir.uDataSize;
Ritor1
parents:
diff changeset
1842 fseek(v7, v6, SEEK_SET);
Ritor1
parents:
diff changeset
1843 v8 = v3->uNumSubIndices;
Ritor1
parents:
diff changeset
1844 if ( (signed int)v8 > 300 )
Ritor1
parents:
diff changeset
1845 {
Ritor1
parents:
diff changeset
1846 MessageBoxA(0, "LODchapterPages exceed 300", "LOD::File", MB_ICONEXCLAMATION);
Ritor1
parents:
diff changeset
1847 fclose(v3->pFile);
Ritor1
parents:
diff changeset
1848 return 0;
Ritor1
parents:
diff changeset
1849 }
Ritor1
parents:
diff changeset
1850 fread(pSubIndices, 0x20u, v8, v3->pFile);
Ritor1
parents:
diff changeset
1851 return 1;
Ritor1
parents:
diff changeset
1852 }
Ritor1
parents:
diff changeset
1853
Ritor1
parents:
diff changeset
1854
Ritor1
parents:
diff changeset
1855 //----- (00461A11) --------------------------------------------------------
Ritor1
parents:
diff changeset
1856 void LOD::File::FreeSubIndexAndIO()
Ritor1
parents:
diff changeset
1857 {
Ritor1
parents:
diff changeset
1858 void *v1; // edi@1
Ritor1
parents:
diff changeset
1859 LOD::Directory **v2; // esi@1
Ritor1
parents:
diff changeset
1860
Ritor1
parents:
diff changeset
1861 v1 = this;
Ritor1
parents:
diff changeset
1862 v2 = &this->pSubIndices;
Ritor1
parents:
diff changeset
1863 pAllocator->FreeChunk(this->pSubIndices);
Ritor1
parents:
diff changeset
1864 v1 = (char *)v1 + 264;
Ritor1
parents:
diff changeset
1865 pAllocator->FreeChunk(pIOBuffer);// delete [] pIOBuffer;
Ritor1
parents:
diff changeset
1866 pIOBuffer = nullptr;
Ritor1
parents:
diff changeset
1867 pSubIndices = nullptr;
Ritor1
parents:
diff changeset
1868 }
Ritor1
parents:
diff changeset
1869
Ritor1
parents:
diff changeset
1870
Ritor1
parents:
diff changeset
1871 //----- (00461954) --------------------------------------------------------
Ritor1
parents:
diff changeset
1872 void LOD::File::AllocSubIndicesAndIO(unsigned int uNumSubIndices, unsigned int uBufferSize)
Ritor1
parents:
diff changeset
1873 {
Ritor1
parents:
diff changeset
1874 //LOD::File *v3; // esi@1
Ritor1
parents:
diff changeset
1875 LOD::Directory *pSubIndices_dup; // eax@3
Ritor1
parents:
diff changeset
1876 char v5; // zf@3
Ritor1
parents:
diff changeset
1877
Ritor1
parents:
diff changeset
1878 //v3 = this;
Ritor1
parents:
diff changeset
1879 if (pSubIndices)
Ritor1
parents:
diff changeset
1880 {
Ritor1
parents:
diff changeset
1881 MessageBoxA(0, "Attempt to reset a LOD subindex!", "MM6", MB_ICONEXCLAMATION);
Ritor1
parents:
diff changeset
1882 pAllocator->FreeChunk(pSubIndices);
Ritor1
parents:
diff changeset
1883 pSubIndices = nullptr;
Ritor1
parents:
diff changeset
1884 }
Ritor1
parents:
diff changeset
1885 pSubIndices_dup = (LOD::Directory *)pAllocator->AllocNamedChunk(
Ritor1
parents:
diff changeset
1886 pSubIndices,
Ritor1
parents:
diff changeset
1887 32 * uNumSubIndices,
Ritor1
parents:
diff changeset
1888 "LODsub");
Ritor1
parents:
diff changeset
1889 v5 = pIOBuffer == 0;
Ritor1
parents:
diff changeset
1890 pSubIndices = pSubIndices_dup;
Ritor1
parents:
diff changeset
1891 if ( !v5 )
Ritor1
parents:
diff changeset
1892 {
Ritor1
parents:
diff changeset
1893 MessageBoxA(0, "Attempt to reset a LOD IObuffer!", "MM6", MB_ICONEXCLAMATION);
Ritor1
parents:
diff changeset
1894 pAllocator->FreeChunk(pIOBuffer);
Ritor1
parents:
diff changeset
1895 pIOBuffer = 0;
Ritor1
parents:
diff changeset
1896 uIOBufferSize = 0;
Ritor1
parents:
diff changeset
1897 }
Ritor1
parents:
diff changeset
1898 if ( uBufferSize )
Ritor1
parents:
diff changeset
1899 {
Ritor1
parents:
diff changeset
1900 pIOBuffer = (unsigned __int8 *)pAllocator->AllocNamedChunk(pIOBuffer, uBufferSize, "LODio");
Ritor1
parents:
diff changeset
1901 uIOBufferSize = uBufferSize;
Ritor1
parents:
diff changeset
1902 }
Ritor1
parents:
diff changeset
1903 }
Ritor1
parents:
diff changeset
1904
Ritor1
parents:
diff changeset
1905
Ritor1
parents:
diff changeset
1906
Ritor1
parents:
diff changeset
1907 //----- (0046188A) --------------------------------------------------------
Ritor1
parents:
diff changeset
1908 int LOD::File::LoadSubIndices(const char *pContainer)
Ritor1
parents:
diff changeset
1909 {
415
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1910
0
Ritor1
parents:
diff changeset
1911 unsigned int uDir; // edi@1
415
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1912 LOD::Directory *curr_index; // eax@7
0
Ritor1
parents:
diff changeset
1913
415
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1914
0
Ritor1
parents:
diff changeset
1915 ResetSubIndices();
Ritor1
parents:
diff changeset
1916 uDir = 0;
415
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1917
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1918 if ( header.uNumIndices <= 0)
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1919 return 3;
0
Ritor1
parents:
diff changeset
1920 else
415
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1921 {
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1922 while (stricmp(pContainer, pRoot[uDir].pFilename))
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1923 {
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1924 ++uDir;
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1925 if (uDir >= header.uNumIndices )
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1926 return 3;
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1927 }
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1928 strcpy( pContainerName, pContainer);
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1929 uCurrentIndexDir = uDir;
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1930 curr_index=(LOD::Directory *)&pRoot[uDir];
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1931 uOffsetToSubIndex =curr_index->uOfsetFromSubindicesStart ;
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1932 uNumSubIndices =curr_index->uNumSubIndices;// *(_WORD *)(v8 + 28);
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1933 fseek( pFile, uOffsetToSubIndex, 0);
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1934 pSubIndices = (LOD::Directory *)pAllocator->AllocNamedChunk(pSubIndices, sizeof(LOD::Directory)*(uNumSubIndices + 5), "LOD Index");
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1935
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1936 if ( pSubIndices)
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1937 fread( pSubIndices, sizeof(LOD::Directory), uNumSubIndices, pFile);
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1938 return 0;
49158f2cc88d little lod refactor
Gloval
parents: 265
diff changeset
1939 }
0
Ritor1
parents:
diff changeset
1940 }
Ritor1
parents:
diff changeset
1941
Ritor1
parents:
diff changeset
1942 //----- (004617D5) --------------------------------------------------------
Ritor1
parents:
diff changeset
1943 bool LOD::File::LoadHeader(const char *pFilename, bool bWriting)
Ritor1
parents:
diff changeset
1944 {
Ritor1
parents:
diff changeset
1945 LOD::File *this_dup; // esi@1
Ritor1
parents:
diff changeset
1946 FILE *pFile_dup; // eax@6
Ritor1
parents:
diff changeset
1947 void *pRoot_dup; // eax@7
Ritor1
parents:
diff changeset
1948 const char *v6; // [sp-4h] [bp-Ch]@4
Ritor1
parents:
diff changeset
1949 FILE *v7; // [sp-4h] [bp-Ch]@7
Ritor1
parents:
diff changeset
1950
Ritor1
parents:
diff changeset
1951 this_dup = this;
Ritor1
parents:
diff changeset
1952 if ( this->isFileOpened )
Ritor1
parents:
diff changeset
1953 Close();
Ritor1
parents:
diff changeset
1954 if ( bWriting & 1 )
Ritor1
parents:
diff changeset
1955 v6 = "rb";
Ritor1
parents:
diff changeset
1956 else
Ritor1
parents:
diff changeset
1957 v6 = "rb+";
Ritor1
parents:
diff changeset
1958 pFile_dup = fopen(pFilename, v6);
Ritor1
parents:
diff changeset
1959 this_dup->pFile = pFile_dup;
Ritor1
parents:
diff changeset
1960 if ( pFile_dup )
Ritor1
parents:
diff changeset
1961 {
Ritor1
parents:
diff changeset
1962 strcpy(this_dup->pLODName, pFilename);
Ritor1
parents:
diff changeset
1963 fread(&this_dup->header, 0x100u, 1u, this_dup->pFile);
Ritor1
parents:
diff changeset
1964 pRoot_dup = pAllocator->AllocNamedChunk(this_dup->pRoot, 0xA0u, "LOD CArray");
Ritor1
parents:
diff changeset
1965 this_dup->pRoot = (LOD::Directory *)pRoot_dup;
Ritor1
parents:
diff changeset
1966 v7 = this_dup->pFile;
Ritor1
parents:
diff changeset
1967 if ( pRoot_dup )
Ritor1
parents:
diff changeset
1968 {
Ritor1
parents:
diff changeset
1969 fread(pRoot_dup, 0x20u, this_dup->header.uNumIndices, v7);
Ritor1
parents:
diff changeset
1970 fseek(this_dup->pFile, 0, 0);
Ritor1
parents:
diff changeset
1971 this_dup->isFileOpened = 1;
Ritor1
parents:
diff changeset
1972 return false;
Ritor1
parents:
diff changeset
1973 }
Ritor1
parents:
diff changeset
1974 else
Ritor1
parents:
diff changeset
1975 {
Ritor1
parents:
diff changeset
1976 fclose(v7);
Ritor1
parents:
diff changeset
1977 return true;
Ritor1
parents:
diff changeset
1978 }
Ritor1
parents:
diff changeset
1979 }
Ritor1
parents:
diff changeset
1980 return true;
Ritor1
parents:
diff changeset
1981 }
Ritor1
parents:
diff changeset
1982
Ritor1
parents:
diff changeset
1983
Ritor1
parents:
diff changeset
1984 //----- (004617B6) --------------------------------------------------------
Ritor1
parents:
diff changeset
1985 void LOD::FileHeader::Reset()
Ritor1
parents:
diff changeset
1986 {
Ritor1
parents:
diff changeset
1987 this->pSignature[0] = 0;
Ritor1
parents:
diff changeset
1988 this->LodVersion[0] = 0;
Ritor1
parents:
diff changeset
1989 this->LodDescription[0] = 0;
Ritor1
parents:
diff changeset
1990 this->LODSize = 0;
Ritor1
parents:
diff changeset
1991 this->dword_0000A8 = 0;
Ritor1
parents:
diff changeset
1992 this->uNumIndices = 0;
Ritor1
parents:
diff changeset
1993 }
Ritor1
parents:
diff changeset
1994
Ritor1
parents:
diff changeset
1995 //----- (00461790) --------------------------------------------------------
Ritor1
parents:
diff changeset
1996 LOD::File::~File()
Ritor1
parents:
diff changeset
1997 {
Ritor1
parents:
diff changeset
1998 LOD::File *v1; // esi@1
Ritor1
parents:
diff changeset
1999
Ritor1
parents:
diff changeset
2000 v1 = this;
Ritor1
parents:
diff changeset
2001 if ( this->isFileOpened )
Ritor1
parents:
diff changeset
2002 {
Ritor1
parents:
diff changeset
2003 fclose(this->pFile);
Ritor1
parents:
diff changeset
2004 pAllocator->FreeChunk(v1->pSubIndices);
Ritor1
parents:
diff changeset
2005 }
Ritor1
parents:
diff changeset
2006 }
Ritor1
parents:
diff changeset
2007
Ritor1
parents:
diff changeset
2008
Ritor1
parents:
diff changeset
2009 //----- (0046175B) --------------------------------------------------------
Ritor1
parents:
diff changeset
2010 LOD::File::File():
Ritor1
parents:
diff changeset
2011 pRoot(nullptr),
Ritor1
parents:
diff changeset
2012 isFileOpened(false)
Ritor1
parents:
diff changeset
2013 {
Ritor1
parents:
diff changeset
2014 LOD::File *v1; // esi@1
Ritor1
parents:
diff changeset
2015
Ritor1
parents:
diff changeset
2016 memset(pLODName, 0, 256);
Ritor1
parents:
diff changeset
2017 memset(pContainerName, 0, 16);
Ritor1
parents:
diff changeset
2018 v1 = this;
Ritor1
parents:
diff changeset
2019 v1->pFile = 0;
Ritor1
parents:
diff changeset
2020 v1->pSubIndices = 0;
Ritor1
parents:
diff changeset
2021 v1->pIOBuffer = 0;
Ritor1
parents:
diff changeset
2022 v1->isFileOpened = 0;
Ritor1
parents:
diff changeset
2023 v1->uIOBufferSize = 0;
Ritor1
parents:
diff changeset
2024 Close();
Ritor1
parents:
diff changeset
2025 }
Ritor1
parents:
diff changeset
2026
Ritor1
parents:
diff changeset
2027
Ritor1
parents:
diff changeset
2028 //----- (00461743) --------------------------------------------------------
Ritor1
parents:
diff changeset
2029 LOD::Directory *LOD::Directory::Reset()
Ritor1
parents:
diff changeset
2030 {
Ritor1
parents:
diff changeset
2031 LOD::Directory *result; // eax@1
Ritor1
parents:
diff changeset
2032
Ritor1
parents:
diff changeset
2033 result = this;
Ritor1
parents:
diff changeset
2034 this->pFilename[0] = 0;
Ritor1
parents:
diff changeset
2035 this->uOfsetFromSubindicesStart = 0;
Ritor1
parents:
diff changeset
2036 this->uDataSize = 0;
Ritor1
parents:
diff changeset
2037 this->dword_000018 = 0;
Ritor1
parents:
diff changeset
2038 this->uNumSubIndices = 0;
Ritor1
parents:
diff changeset
2039 this->word_00001E = 0;
Ritor1
parents:
diff changeset
2040 return result;
Ritor1
parents:
diff changeset
2041 }
Ritor1
parents:
diff changeset
2042
Ritor1
parents:
diff changeset
2043
Ritor1
parents:
diff changeset
2044 //----- (0046172B) --------------------------------------------------------
Ritor1
parents:
diff changeset
2045 LOD::Directory::Directory()
Ritor1
parents:
diff changeset
2046 {
Ritor1
parents:
diff changeset
2047 memset(pFilename, 0, 16);
Ritor1
parents:
diff changeset
2048 this->pFilename[0] = 0;
Ritor1
parents:
diff changeset
2049 this->uOfsetFromSubindicesStart = 0;
Ritor1
parents:
diff changeset
2050 this->uDataSize = 0;
Ritor1
parents:
diff changeset
2051 this->uNumSubIndices = 0;
Ritor1
parents:
diff changeset
2052 this->dword_000018 = 0;
Ritor1
parents:
diff changeset
2053 this->word_00001E = 0;
Ritor1
parents:
diff changeset
2054 }
Ritor1
parents:
diff changeset
2055
Ritor1
parents:
diff changeset
2056 //----- (0046165E) --------------------------------------------------------
Ritor1
parents:
diff changeset
2057 int LOD::File::CalcIndexFast(int startIndex, int maxIndex, const char *pContainerName)
Ritor1
parents:
diff changeset
2058 {
Ritor1
parents:
diff changeset
2059 int v4; // esi@1
Ritor1
parents:
diff changeset
2060 int v5; // ebx@2
Ritor1
parents:
diff changeset
2061 int result; // eax@2
Ritor1
parents:
diff changeset
2062 int v7; // edi@10
Ritor1
parents:
diff changeset
2063 int v8; // esi@11
Ritor1
parents:
diff changeset
2064 int v9; // esi@17
Ritor1
parents:
diff changeset
2065 LOD::File *v10; // [sp+Ch] [bp-4h]@1
Ritor1
parents:
diff changeset
2066
Ritor1
parents:
diff changeset
2067 v4 = startIndex;
Ritor1
parents:
diff changeset
2068 v10 = this;
Ritor1
parents:
diff changeset
2069 while ( 1 ) // binary search in LOD indices
Ritor1
parents:
diff changeset
2070 {
Ritor1
parents:
diff changeset
2071 while ( 1 )
Ritor1
parents:
diff changeset
2072 {
Ritor1
parents:
diff changeset
2073 v5 = maxIndex - v4;
Ritor1
parents:
diff changeset
2074 result = _strcmpi((const char *)pContainerName, (const char *)(&v10->pSubIndices[(maxIndex - v4) / 2] + v4));
Ritor1
parents:
diff changeset
2075 if ( !result )
Ritor1
parents:
diff changeset
2076 _6A0CA4_lod_binary_search = (maxIndex - v4) / 2 + v4;
Ritor1
parents:
diff changeset
2077 if ( v4 == maxIndex )
Ritor1
parents:
diff changeset
2078 goto LABEL_14;
Ritor1
parents:
diff changeset
2079 if ( result < 0 )
Ritor1
parents:
diff changeset
2080 break;
Ritor1
parents:
diff changeset
2081 if ( v5 <= 4 )
Ritor1
parents:
diff changeset
2082 {
Ritor1
parents:
diff changeset
2083 v7 = v4;
Ritor1
parents:
diff changeset
2084 if ( v4 < maxIndex )
Ritor1
parents:
diff changeset
2085 {
Ritor1
parents:
diff changeset
2086 v9 = v4;
Ritor1
parents:
diff changeset
2087 do
Ritor1
parents:
diff changeset
2088 {
Ritor1
parents:
diff changeset
2089 result = _strcmpi((const char *)pContainerName, (const char *)&v10->pSubIndices[v9]);
Ritor1
parents:
diff changeset
2090 if ( !result )
Ritor1
parents:
diff changeset
2091 goto LABEL_21;
Ritor1
parents:
diff changeset
2092 ++v7;
Ritor1
parents:
diff changeset
2093 ++v9;
Ritor1
parents:
diff changeset
2094 }
Ritor1
parents:
diff changeset
2095 while ( v7 < maxIndex );
Ritor1
parents:
diff changeset
2096 }
Ritor1
parents:
diff changeset
2097 LABEL_14:
Ritor1
parents:
diff changeset
2098 _6A0CA4_lod_binary_search = -1;
Ritor1
parents:
diff changeset
2099 return result;
Ritor1
parents:
diff changeset
2100 }
Ritor1
parents:
diff changeset
2101 v4 += (maxIndex - v4) / 2;
Ritor1
parents:
diff changeset
2102 }
Ritor1
parents:
diff changeset
2103 if ( v5 <= 4 )
Ritor1
parents:
diff changeset
2104 break;
Ritor1
parents:
diff changeset
2105 maxIndex = (maxIndex - v4) / 2 + v4;
Ritor1
parents:
diff changeset
2106 }
Ritor1
parents:
diff changeset
2107 v7 = v4;
Ritor1
parents:
diff changeset
2108 if ( v4 >= maxIndex )
Ritor1
parents:
diff changeset
2109 goto LABEL_14;
Ritor1
parents:
diff changeset
2110 v8 = v4;
Ritor1
parents:
diff changeset
2111 while ( 1 )
Ritor1
parents:
diff changeset
2112 {
Ritor1
parents:
diff changeset
2113 result = _strcmpi((const char *)pContainerName, (const char *)&v10->pSubIndices[v8]);
Ritor1
parents:
diff changeset
2114 if ( !result )
Ritor1
parents:
diff changeset
2115 break;
Ritor1
parents:
diff changeset
2116 ++v7;
Ritor1
parents:
diff changeset
2117 ++v8;
Ritor1
parents:
diff changeset
2118 if ( v7 >= maxIndex )
Ritor1
parents:
diff changeset
2119 goto LABEL_14;
Ritor1
parents:
diff changeset
2120 }
Ritor1
parents:
diff changeset
2121 LABEL_21:
Ritor1
parents:
diff changeset
2122 _6A0CA4_lod_binary_search = v7;
Ritor1
parents:
diff changeset
2123 return result;
Ritor1
parents:
diff changeset
2124 }
Ritor1
parents:
diff changeset
2125 // 6A0CA4: using guessed type int _6A0CA4_lod_binary_search;
Ritor1
parents:
diff changeset
2126
Ritor1
parents:
diff changeset
2127
Ritor1
parents:
diff changeset
2128 //----- (0046161C) --------------------------------------------------------
Ritor1
parents:
diff changeset
2129 bool LOD::File::DoesContainerExist(const char *pContainer)
Ritor1
parents:
diff changeset
2130 {
Ritor1
parents:
diff changeset
2131 LOD::File *this_dup; // esi@1
Ritor1
parents:
diff changeset
2132 int i; // ebx@1
Ritor1
parents:
diff changeset
2133 signed int i_dup; // edi@1
Ritor1
parents:
diff changeset
2134 bool result; // eax@4
Ritor1
parents:
diff changeset
2135
Ritor1
parents:
diff changeset
2136 this_dup = this;
Ritor1
parents:
diff changeset
2137 i = 0;
Ritor1
parents:
diff changeset
2138 i_dup = 0;
Ritor1
parents:
diff changeset
2139 if ( (signed int)this->uNumSubIndices <= 0 )
Ritor1
parents:
diff changeset
2140 {
Ritor1
parents:
diff changeset
2141 LABEL_4:
Ritor1
parents:
diff changeset
2142 result = 0;
Ritor1
parents:
diff changeset
2143 }
Ritor1
parents:
diff changeset
2144 else
Ritor1
parents:
diff changeset
2145 {
Ritor1
parents:
diff changeset
2146 while ( _strcmpi((const char *)pContainer, (const char *)&this_dup->pSubIndices[i]) )
Ritor1
parents:
diff changeset
2147 {
Ritor1
parents:
diff changeset
2148 ++i_dup;
Ritor1
parents:
diff changeset
2149 ++i;
Ritor1
parents:
diff changeset
2150 if ( i_dup >= (signed int)this_dup->uNumSubIndices )
Ritor1
parents:
diff changeset
2151 goto LABEL_4;
Ritor1
parents:
diff changeset
2152 }
Ritor1
parents:
diff changeset
2153 result = 1;
Ritor1
parents:
diff changeset
2154 }
Ritor1
parents:
diff changeset
2155 return result;
Ritor1
parents:
diff changeset
2156 }
Ritor1
parents:
diff changeset
2157
Ritor1
parents:
diff changeset
2158
Ritor1
parents:
diff changeset
2159 //----- (00461397) --------------------------------------------------------
Ritor1
parents:
diff changeset
2160 int LODFile_Sprites::_461397()
Ritor1
parents:
diff changeset
2161 {
Ritor1
parents:
diff changeset
2162 int result; // eax@1
737
225d92620998 004A19D8 refactored
Nomad
parents: 733
diff changeset
2163 //int *pfield_ECA0; // edi@1
0
Ritor1
parents:
diff changeset
2164 int v3; // esi@1
Ritor1
parents:
diff changeset
2165 int v4; // ecx@3
Ritor1
parents:
diff changeset
2166
Ritor1
parents:
diff changeset
2167 result = this->uNumLoadedSprites;
737
225d92620998 004A19D8 refactored
Nomad
parents: 733
diff changeset
2168 //pfield_ECA0 = &this->field_ECA0;
0
Ritor1
parents:
diff changeset
2169 v3 = this->field_ECA0;
Ritor1
parents:
diff changeset
2170 this->field_ECA8 = result;
Ritor1
parents:
diff changeset
2171 if ( result < v3 )
Ritor1
parents:
diff changeset
2172 this->field_ECA8 = v3;
Ritor1
parents:
diff changeset
2173 v4 = this->field_ECA4;
Ritor1
parents:
diff changeset
2174 if ( v3 < v4 )
737
225d92620998 004A19D8 refactored
Nomad
parents: 733
diff changeset
2175 field_ECA0 = v4;
0
Ritor1
parents:
diff changeset
2176 return result;
Ritor1
parents:
diff changeset
2177 }
Ritor1
parents:
diff changeset
2178
Ritor1
parents:
diff changeset
2179 //----- (00461580) --------------------------------------------------------
Ritor1
parents:
diff changeset
2180 FILE *LOD::File::FindContainer(const char *pContainerName, bool bLinearSearch)
Ritor1
parents:
diff changeset
2181 {
Ritor1
parents:
diff changeset
2182 unsigned int v4; // eax@4
Ritor1
parents:
diff changeset
2183 if (!isFileOpened)
Ritor1
parents:
diff changeset
2184 return 0;
Ritor1
parents:
diff changeset
2185
Ritor1
parents:
diff changeset
2186
Ritor1
parents:
diff changeset
2187 if (bLinearSearch)
Ritor1
parents:
diff changeset
2188 {
Ritor1
parents:
diff changeset
2189 for (uint i = 0; i < uNumSubIndices; ++i)
Ritor1
parents:
diff changeset
2190 if (!strcmpi(pContainerName, pSubIndices[i].pFilename))
Ritor1
parents:
diff changeset
2191 {
Ritor1
parents:
diff changeset
2192 v4 = pSubIndices[i].uOfsetFromSubindicesStart;
Ritor1
parents:
diff changeset
2193 fseek(pFile, uOffsetToSubIndex + v4, SEEK_SET);
Ritor1
parents:
diff changeset
2194 return pFile;
Ritor1
parents:
diff changeset
2195 }
Ritor1
parents:
diff changeset
2196
Ritor1
parents:
diff changeset
2197 return nullptr;
Ritor1
parents:
diff changeset
2198 }
Ritor1
parents:
diff changeset
2199 else
Ritor1
parents:
diff changeset
2200 {
Ritor1
parents:
diff changeset
2201 CalcIndexFast(0, uNumSubIndices, pContainerName);
Ritor1
parents:
diff changeset
2202 if ( _6A0CA4_lod_binary_search < 0 )
Ritor1
parents:
diff changeset
2203 return 0;
Ritor1
parents:
diff changeset
2204 v4 = pSubIndices[_6A0CA4_lod_binary_search].uOfsetFromSubindicesStart;
Ritor1
parents:
diff changeset
2205 fseek(pFile, uOffsetToSubIndex + v4, SEEK_SET);
Ritor1
parents:
diff changeset
2206 return pFile;
Ritor1
parents:
diff changeset
2207 }
Ritor1
parents:
diff changeset
2208 }
Ritor1
parents:
diff changeset
2209
Ritor1
parents:
diff changeset
2210 //----- (0041097D) --------------------------------------------------------
Ritor1
parents:
diff changeset
2211 void LODFile_IconsBitmaps::SetupPalettes(unsigned int uTargetRBits, unsigned int uTargetGBits, unsigned int uTargetBBits)
Ritor1
parents:
diff changeset
2212 {
Ritor1
parents:
diff changeset
2213 int v4; // edx@1
Ritor1
parents:
diff changeset
2214 LODFile_IconsBitmaps *v5; // esi@1
Ritor1
parents:
diff changeset
2215 int v6; // ecx@1
Ritor1
parents:
diff changeset
2216 unsigned __int8 v7; // zf@4
Ritor1
parents:
diff changeset
2217 unsigned __int8 v8; // sf@4
Ritor1
parents:
diff changeset
2218 unsigned __int16 **v9; // edi@5
Ritor1
parents:
diff changeset
2219 FILE *v10; // eax@7
Ritor1
parents:
diff changeset
2220 FILE *v11; // ebx@7
Ritor1
parents:
diff changeset
2221 signed int v12; // ebx@8
Ritor1
parents:
diff changeset
2222 int v13; // eax@9
Ritor1
parents:
diff changeset
2223 int v14; // edx@9
Ritor1
parents:
diff changeset
2224 int v16; // [sp+4Ch] [bp-8h]@4
Ritor1
parents:
diff changeset
2225 FILE *File; // [sp+50h] [bp-4h]@7
Ritor1
parents:
diff changeset
2226
Ritor1
parents:
diff changeset
2227 v4 = uTargetGBits;
Ritor1
parents:
diff changeset
2228 v5 = this;
Ritor1
parents:
diff changeset
2229 v6 = uTargetBBits;
Ritor1
parents:
diff changeset
2230 if ( v5->uTextureRedBits != uTargetRBits
Ritor1
parents:
diff changeset
2231 || v5->uTextureGreenBits != uTargetGBits
Ritor1
parents:
diff changeset
2232 || v5->uTextureBlueBits != uTargetBBits )
Ritor1
parents:
diff changeset
2233 {
Ritor1
parents:
diff changeset
2234 v16 = 0;
Ritor1
parents:
diff changeset
2235 v7 = v5->uNumLoadedFiles == 0;
Ritor1
parents:
diff changeset
2236 v8 = (v5->uNumLoadedFiles & 0x80000000u) != 0;
Ritor1
parents:
diff changeset
2237 v5->uTextureRedBits = uTargetRBits;
Ritor1
parents:
diff changeset
2238 v5->uTextureGreenBits = v4;
Ritor1
parents:
diff changeset
2239 v5->uTextureBlueBits = v6;
Ritor1
parents:
diff changeset
2240 if ( !(v8 | v7) )
Ritor1
parents:
diff changeset
2241 {
Ritor1
parents:
diff changeset
2242 v9 = &v5->pTextures[0].pPalette16;
Ritor1
parents:
diff changeset
2243 do
Ritor1
parents:
diff changeset
2244 {
Ritor1
parents:
diff changeset
2245 Texture DstBuf; // [sp+4h] [bp-50h]@6
Ritor1
parents:
diff changeset
2246 //Texture::Texture(&DstBuf);
Ritor1
parents:
diff changeset
2247
Ritor1
parents:
diff changeset
2248 if ( *v9 )
Ritor1
parents:
diff changeset
2249 {
Ritor1
parents:
diff changeset
2250 v10 = FindContainer((const char *)v9 - 64, 0);
Ritor1
parents:
diff changeset
2251 v11 = v10;
Ritor1
parents:
diff changeset
2252 File = v10;
Ritor1
parents:
diff changeset
2253 if ( v10 )
Ritor1
parents:
diff changeset
2254 {
Ritor1
parents:
diff changeset
2255 fread(&DstBuf, 1u, 0x30u, v10);
Ritor1
parents:
diff changeset
2256 fseek(v11, DstBuf.uTextureSize, 1);
Ritor1
parents:
diff changeset
2257 v12 = 0;
Ritor1
parents:
diff changeset
2258 do
Ritor1
parents:
diff changeset
2259 {
Ritor1
parents:
diff changeset
2260 fread((char *)&uTargetRBits + 3, 1u, 1u, File);
Ritor1
parents:
diff changeset
2261 fread((char *)&uTargetBBits + 3, 1u, 1u, File);
Ritor1
parents:
diff changeset
2262 v13 = fread((char *)&uTargetGBits + 3, 1u, 1u, File);
Ritor1
parents:
diff changeset
2263 LOWORD(v13) = (unsigned __int8)(BYTE3(uTargetRBits) >> (8 - LOBYTE(v5->uTextureRedBits)));
Ritor1
parents:
diff changeset
2264 (*v9)[v12] = v13 << (LOBYTE(v5->uTextureGreenBits) + LOBYTE(v5->uTextureBlueBits));
Ritor1
parents:
diff changeset
2265 LOWORD(v14) = (unsigned __int8)(BYTE3(uTargetBBits) >> (8 - LOBYTE(v5->uTextureGreenBits)));
Ritor1
parents:
diff changeset
2266 (*v9)[v12] |= v14 << v5->uTextureBlueBits;
Ritor1
parents:
diff changeset
2267 (*v9)[v12] |= BYTE3(uTargetGBits) >> (8 - LOBYTE(v5->uTextureBlueBits));
Ritor1
parents:
diff changeset
2268 ++v12;
Ritor1
parents:
diff changeset
2269 }
Ritor1
parents:
diff changeset
2270 while ( v12 < 256 );
Ritor1
parents:
diff changeset
2271 }
Ritor1
parents:
diff changeset
2272 }
Ritor1
parents:
diff changeset
2273 ++v16;
Ritor1
parents:
diff changeset
2274 v9 += 18;
Ritor1
parents:
diff changeset
2275 }
Ritor1
parents:
diff changeset
2276 while ( v16 < (signed int)v5->uNumLoadedFiles );
Ritor1
parents:
diff changeset
2277 }
Ritor1
parents:
diff changeset
2278 }
Ritor1
parents:
diff changeset
2279 }
Ritor1
parents:
diff changeset
2280
Ritor1
parents:
diff changeset
2281
Ritor1
parents:
diff changeset
2282
Ritor1
parents:
diff changeset
2283 //----- (0041088B) --------------------------------------------------------
Ritor1
parents:
diff changeset
2284 void *LOD::File::LoadRaw(const char *pContainer, int a3)
Ritor1
parents:
diff changeset
2285 {
Ritor1
parents:
diff changeset
2286 LOD::File *v3; // esi@1
Ritor1
parents:
diff changeset
2287 FILE *v4; // eax@1
Ritor1
parents:
diff changeset
2288 FILE *v5; // esi@1
Ritor1
parents:
diff changeset
2289 void *v6; // eax@5
Ritor1
parents:
diff changeset
2290 void *v7; // ebx@7
Ritor1
parents:
diff changeset
2291 void *v8; // edi@7
Ritor1
parents:
diff changeset
2292 void *v9; // eax@9
Ritor1
parents:
diff changeset
2293 Texture DstBuf; // [sp+Ch] [bp-4Ch]@1
Ritor1
parents:
diff changeset
2294 FILE *File; // [sp+54h] [bp-4h]@1
Ritor1
parents:
diff changeset
2295 unsigned int Argsa; // [sp+60h] [bp+8h]@3
Ritor1
parents:
diff changeset
2296
Ritor1
parents:
diff changeset
2297 v3 = this;
Ritor1
parents:
diff changeset
2298 v4 = FindContainer(pContainer, 0);
Ritor1
parents:
diff changeset
2299 v5 = v4;
Ritor1
parents:
diff changeset
2300 File = v4;
Ritor1
parents:
diff changeset
2301 if ( !v4 )
Ritor1
parents:
diff changeset
2302 Abortf("Unable to load %s", pContainer);
Ritor1
parents:
diff changeset
2303 fread(&DstBuf, 1u, 0x30u, v4);
Ritor1
parents:
diff changeset
2304 Argsa = DstBuf.uTextureSize;
Ritor1
parents:
diff changeset
2305 if ( DstBuf.uDecompressedSize )
Ritor1
parents:
diff changeset
2306 {
Ritor1
parents:
diff changeset
2307 if ( a3 )
705
e39702f35283 memory allocation partly reworked
zipi
parents: 700
diff changeset
2308 v6 = malloc(DstBuf.uDecompressedSize+1);
0
Ritor1
parents:
diff changeset
2309 else
705
e39702f35283 memory allocation partly reworked
zipi
parents: 700
diff changeset
2310 v6 = pAllocator->AllocNamedChunk(0, DstBuf.uDecompressedSize+1, DstBuf.pName);
0
Ritor1
parents:
diff changeset
2311 v7 = v6;
705
e39702f35283 memory allocation partly reworked
zipi
parents: 700
diff changeset
2312 v8 = pAllocator->AllocNamedChunk(0, DstBuf.uTextureSize+1, DstBuf.pName);
0
Ritor1
parents:
diff changeset
2313 fread(v8, 1u, Argsa, File);
Ritor1
parents:
diff changeset
2314 zlib::MemUnzip(v7, &DstBuf.uDecompressedSize, v8, DstBuf.uTextureSize);
Ritor1
parents:
diff changeset
2315 DstBuf.uTextureSize = DstBuf.uDecompressedSize;
Ritor1
parents:
diff changeset
2316 pAllocator->FreeChunk(v8);
Ritor1
parents:
diff changeset
2317 }
Ritor1
parents:
diff changeset
2318 else
Ritor1
parents:
diff changeset
2319 {
Ritor1
parents:
diff changeset
2320 if ( a3 )
705
e39702f35283 memory allocation partly reworked
zipi
parents: 700
diff changeset
2321 v9 = malloc(DstBuf.uTextureSize+1);
0
Ritor1
parents:
diff changeset
2322 else
705
e39702f35283 memory allocation partly reworked
zipi
parents: 700
diff changeset
2323 v9 = pAllocator->AllocNamedChunk(0, DstBuf.uTextureSize+1, DstBuf.pName);
0
Ritor1
parents:
diff changeset
2324 v7 = v9;
Ritor1
parents:
diff changeset
2325 fread(v9, 1u, Argsa, v5);
Ritor1
parents:
diff changeset
2326 }
Ritor1
parents:
diff changeset
2327 return v7;
Ritor1
parents:
diff changeset
2328 }
Ritor1
parents:
diff changeset
2329
Ritor1
parents:
diff changeset
2330
Ritor1
parents:
diff changeset
2331
Ritor1
parents:
diff changeset
2332 //----- (00410522) --------------------------------------------------------
Ritor1
parents:
diff changeset
2333 int LODFile_IconsBitmaps::_410522(Texture *pDst, const char *pContainer, unsigned int uTextureType)
Ritor1
parents:
diff changeset
2334 {
Ritor1
parents:
diff changeset
2335 LODFile_IconsBitmaps *v4; // edi@1
Ritor1
parents:
diff changeset
2336 Texture *v5; // esi@5
Ritor1
parents:
diff changeset
2337 unsigned int v6; // eax@5
Ritor1
parents:
diff changeset
2338 void *v7; // eax@6
Ritor1
parents:
diff changeset
2339 unsigned int v8; // ST28_4@6
Ritor1
parents:
diff changeset
2340 void *v9; // ST2C_4@6
Ritor1
parents:
diff changeset
2341 unsigned __int8 *v10; // eax@7
Ritor1
parents:
diff changeset
2342 FILE *v11; // ST28_4@7
Ritor1
parents:
diff changeset
2343 void *v12; // eax@9
Ritor1
parents:
diff changeset
2344 FILE *v13; // ST28_4@9
Ritor1
parents:
diff changeset
2345 signed int v14; // eax@12
Ritor1
parents:
diff changeset
2346 int v15; // ecx@12
Ritor1
parents:
diff changeset
2347 int v16; // ecx@12
Ritor1
parents:
diff changeset
2348 int v17; // eax@12
Ritor1
parents:
diff changeset
2349 signed int v18; // ebx@14
Ritor1
parents:
diff changeset
2350 int v19; // eax@15
Ritor1
parents:
diff changeset
2351 int v20; // edx@15
Ritor1
parents:
diff changeset
2352 signed int v21; // ecx@18
Ritor1
parents:
diff changeset
2353 signed int v22; // ecx@23
Ritor1
parents:
diff changeset
2354 char Args[100]; // [sp+4h] [bp-68h]@3
Ritor1
parents:
diff changeset
2355 FILE *File; // [sp+68h] [bp-4h]@1
Ritor1
parents:
diff changeset
2356
Ritor1
parents:
diff changeset
2357 v4 = this;
Ritor1
parents:
diff changeset
2358 File = FindContainer(pContainer, 0);
Ritor1
parents:
diff changeset
2359 if ( !File )
Ritor1
parents:
diff changeset
2360 {
Ritor1
parents:
diff changeset
2361 File = FindContainer("pending", 0);
Ritor1
parents:
diff changeset
2362 if ( !File )
Ritor1
parents:
diff changeset
2363 {
Ritor1
parents:
diff changeset
2364 sprintf(Args, "Can't find %s!", pContainer);
Ritor1
parents:
diff changeset
2365 Abortf(Args);
Ritor1
parents:
diff changeset
2366 }
Ritor1
parents:
diff changeset
2367 }
Ritor1
parents:
diff changeset
2368 v5 = pDst;
Ritor1
parents:
diff changeset
2369 fread(pDst, 1u, 0x30u, File);
Ritor1
parents:
diff changeset
2370 strcpy(v5->pName, pContainer);
Ritor1
parents:
diff changeset
2371 pDst = (Texture *)v5->uTextureSize;
Ritor1
parents:
diff changeset
2372 v6 = v5->uDecompressedSize;
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2373 v5->pLevelOfDetail0_prolly_alpha_mask = 0;
0
Ritor1
parents:
diff changeset
2374 if ( v6 )
Ritor1
parents:
diff changeset
2375 {
Ritor1
parents:
diff changeset
2376 v7 = operator new(v6);
Ritor1
parents:
diff changeset
2377 v8 = v5->uTextureSize;
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2378 v5->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v7;
0
Ritor1
parents:
diff changeset
2379 pContainer = (const char *)operator new(v8);
Ritor1
parents:
diff changeset
2380 fread((void *)pContainer, 1u, (size_t)pDst, File);
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2381 zlib::MemUnzip(v5->pLevelOfDetail0_prolly_alpha_mask, &v5->uDecompressedSize, pContainer, v5->uTextureSize);
0
Ritor1
parents:
diff changeset
2382 v9 = (void *)pContainer;
Ritor1
parents:
diff changeset
2383 v5->uTextureSize = v5->uDecompressedSize;
Ritor1
parents:
diff changeset
2384 free(v9);
Ritor1
parents:
diff changeset
2385 }
Ritor1
parents:
diff changeset
2386 else
Ritor1
parents:
diff changeset
2387 {
Ritor1
parents:
diff changeset
2388 v10 = (unsigned __int8 *)operator new(0);
Ritor1
parents:
diff changeset
2389 v11 = File;
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2390 v5->pLevelOfDetail0_prolly_alpha_mask = v10;
0
Ritor1
parents:
diff changeset
2391 fread(v10, 1u, (size_t)pDst, v11);
Ritor1
parents:
diff changeset
2392 }
Ritor1
parents:
diff changeset
2393 v5->pPalette24 = 0;
Ritor1
parents:
diff changeset
2394 if ( uTextureType == 1 )
Ritor1
parents:
diff changeset
2395 {
Ritor1
parents:
diff changeset
2396 v12 = operator new(0x300u);
Ritor1
parents:
diff changeset
2397 v13 = File;
Ritor1
parents:
diff changeset
2398 v5->pPalette24 = (unsigned __int8 *)v12;
Ritor1
parents:
diff changeset
2399 fread(v12, 1u, 0x300u, v13);
Ritor1
parents:
diff changeset
2400 LABEL_10:
Ritor1
parents:
diff changeset
2401 v5->pPalette16 = 0;
Ritor1
parents:
diff changeset
2402 goto LABEL_11;
Ritor1
parents:
diff changeset
2403 }
Ritor1
parents:
diff changeset
2404 if ( uTextureType != 2 )
Ritor1
parents:
diff changeset
2405 goto LABEL_10;
Ritor1
parents:
diff changeset
2406 v18 = 0;
Ritor1
parents:
diff changeset
2407 v5->pPalette16 = 0;
Ritor1
parents:
diff changeset
2408 v5->pPalette16 = (unsigned __int16 *)operator new(0x400u);
Ritor1
parents:
diff changeset
2409 do
Ritor1
parents:
diff changeset
2410 {
Ritor1
parents:
diff changeset
2411 fread((char *)&pContainer + 3, 1u, 1u, File);
Ritor1
parents:
diff changeset
2412 fread((char *)&uTextureType + 3, 1u, 1u, File);
Ritor1
parents:
diff changeset
2413 v19 = fread((char *)&pDst + 3, 1u, 1u, File);
Ritor1
parents:
diff changeset
2414 LOWORD(v19) = (unsigned __int8)(BYTE3(pContainer) >> (8 - LOBYTE(v4->uTextureRedBits)));
Ritor1
parents:
diff changeset
2415 v5->pPalette16[v18] = v19 << (LOBYTE(v4->uTextureBlueBits) + LOBYTE(v4->uTextureGreenBits));
Ritor1
parents:
diff changeset
2416 LOWORD(v20) = (unsigned __int8)(BYTE3(uTextureType) >> (8 - LOBYTE(v4->uTextureGreenBits)));
Ritor1
parents:
diff changeset
2417 v5->pPalette16[v18] += v20 << v4->uTextureBlueBits;
Ritor1
parents:
diff changeset
2418 v5->pPalette16[v18] += (unsigned __int8)(BYTE3(pDst) >> (8 - LOBYTE(v4->uTextureBlueBits)));
Ritor1
parents:
diff changeset
2419 ++v18;
Ritor1
parents:
diff changeset
2420 }
Ritor1
parents:
diff changeset
2421 while ( v18 < 256 );
Ritor1
parents:
diff changeset
2422 LABEL_11:
Ritor1
parents:
diff changeset
2423 if ( v5->pBits & 2 )
Ritor1
parents:
diff changeset
2424 {
Ritor1
parents:
diff changeset
2425 v14 = v5->uSizeOfMaxLevelOfDetail;
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2426 v15 = (int)&v5->pLevelOfDetail0_prolly_alpha_mask[v14];
0
Ritor1
parents:
diff changeset
2427 v5->pLevelOfDetail1 = (unsigned __int8 *)v15;
Ritor1
parents:
diff changeset
2428 v16 = (v14 >> 2) + v15;
Ritor1
parents:
diff changeset
2429 v5->pLevelOfDetail2 = (unsigned __int8 *)v16;
Ritor1
parents:
diff changeset
2430 v17 = v16 + (v14 >> 4);
Ritor1
parents:
diff changeset
2431 }
Ritor1
parents:
diff changeset
2432 else
Ritor1
parents:
diff changeset
2433 {
Ritor1
parents:
diff changeset
2434 v17 = 0;
Ritor1
parents:
diff changeset
2435 v5->pLevelOfDetail2 = 0;
Ritor1
parents:
diff changeset
2436 v5->pLevelOfDetail1 = 0;
Ritor1
parents:
diff changeset
2437 }
Ritor1
parents:
diff changeset
2438 v5->pLevelOfDetail3 = (unsigned __int8 *)v17;
Ritor1
parents:
diff changeset
2439 v21 = 1;
Ritor1
parents:
diff changeset
2440 while ( 1 << v21 != v5->uTextureWidth )
Ritor1
parents:
diff changeset
2441 {
Ritor1
parents:
diff changeset
2442 ++v21;
Ritor1
parents:
diff changeset
2443 if ( v21 >= 15 )
Ritor1
parents:
diff changeset
2444 goto LABEL_23;
Ritor1
parents:
diff changeset
2445 }
Ritor1
parents:
diff changeset
2446 v5->uWidthLn2 = v21;
Ritor1
parents:
diff changeset
2447 LABEL_23:
Ritor1
parents:
diff changeset
2448 v22 = 1;
Ritor1
parents:
diff changeset
2449 while ( 1 << v22 != v5->uTextureHeight )
Ritor1
parents:
diff changeset
2450 {
Ritor1
parents:
diff changeset
2451 ++v22;
Ritor1
parents:
diff changeset
2452 if ( v22 >= 15 )
Ritor1
parents:
diff changeset
2453 goto LABEL_28;
Ritor1
parents:
diff changeset
2454 }
Ritor1
parents:
diff changeset
2455 v5->uHeightLn2 = v22;
Ritor1
parents:
diff changeset
2456 LABEL_28:
Ritor1
parents:
diff changeset
2457 switch ( v5->uWidthLn2 )
Ritor1
parents:
diff changeset
2458 {
Ritor1
parents:
diff changeset
2459 case 2:
Ritor1
parents:
diff changeset
2460 v5->uWidthMinus1 = 3;
Ritor1
parents:
diff changeset
2461 break;
Ritor1
parents:
diff changeset
2462 case 3:
Ritor1
parents:
diff changeset
2463 v5->uWidthMinus1 = 7;
Ritor1
parents:
diff changeset
2464 break;
Ritor1
parents:
diff changeset
2465 case 4:
Ritor1
parents:
diff changeset
2466 v5->uWidthMinus1 = 15;
Ritor1
parents:
diff changeset
2467 break;
Ritor1
parents:
diff changeset
2468 case 5:
Ritor1
parents:
diff changeset
2469 v5->uWidthMinus1 = 31;
Ritor1
parents:
diff changeset
2470 break;
Ritor1
parents:
diff changeset
2471 case 6:
Ritor1
parents:
diff changeset
2472 v5->uWidthMinus1 = 63;
Ritor1
parents:
diff changeset
2473 break;
Ritor1
parents:
diff changeset
2474 case 7:
Ritor1
parents:
diff changeset
2475 v5->uWidthMinus1 = 127;
Ritor1
parents:
diff changeset
2476 break;
Ritor1
parents:
diff changeset
2477 case 8:
Ritor1
parents:
diff changeset
2478 v5->uWidthMinus1 = 255;
Ritor1
parents:
diff changeset
2479 break;
Ritor1
parents:
diff changeset
2480 case 9:
Ritor1
parents:
diff changeset
2481 v5->uWidthMinus1 = 511;
Ritor1
parents:
diff changeset
2482 break;
Ritor1
parents:
diff changeset
2483 case 10:
Ritor1
parents:
diff changeset
2484 v5->uWidthMinus1 = 1023;
Ritor1
parents:
diff changeset
2485 break;
Ritor1
parents:
diff changeset
2486 case 11:
Ritor1
parents:
diff changeset
2487 v5->uWidthMinus1 = 2047;
Ritor1
parents:
diff changeset
2488 break;
Ritor1
parents:
diff changeset
2489 case 12:
Ritor1
parents:
diff changeset
2490 v5->uWidthMinus1 = 4095;
Ritor1
parents:
diff changeset
2491 break;
Ritor1
parents:
diff changeset
2492 default:
Ritor1
parents:
diff changeset
2493 break;
Ritor1
parents:
diff changeset
2494 }
Ritor1
parents:
diff changeset
2495 switch ( v5->uHeightLn2 )
Ritor1
parents:
diff changeset
2496 {
Ritor1
parents:
diff changeset
2497 case 2:
Ritor1
parents:
diff changeset
2498 v5->uHeightMinus1 = 3;
Ritor1
parents:
diff changeset
2499 break;
Ritor1
parents:
diff changeset
2500 case 3:
Ritor1
parents:
diff changeset
2501 v5->uHeightMinus1 = 7;
Ritor1
parents:
diff changeset
2502 break;
Ritor1
parents:
diff changeset
2503 case 4:
Ritor1
parents:
diff changeset
2504 v5->uHeightMinus1 = 15;
Ritor1
parents:
diff changeset
2505 break;
Ritor1
parents:
diff changeset
2506 case 5:
Ritor1
parents:
diff changeset
2507 v5->uHeightMinus1 = 31;
Ritor1
parents:
diff changeset
2508 break;
Ritor1
parents:
diff changeset
2509 case 6:
Ritor1
parents:
diff changeset
2510 v5->uHeightMinus1 = 63;
Ritor1
parents:
diff changeset
2511 break;
Ritor1
parents:
diff changeset
2512 case 7:
Ritor1
parents:
diff changeset
2513 v5->uHeightMinus1 = 127;
Ritor1
parents:
diff changeset
2514 break;
Ritor1
parents:
diff changeset
2515 case 8:
Ritor1
parents:
diff changeset
2516 v5->uHeightMinus1 = 255;
Ritor1
parents:
diff changeset
2517 break;
Ritor1
parents:
diff changeset
2518 case 9:
Ritor1
parents:
diff changeset
2519 v5->uHeightMinus1 = 511;
Ritor1
parents:
diff changeset
2520 break;
Ritor1
parents:
diff changeset
2521 case 10:
Ritor1
parents:
diff changeset
2522 v5->uHeightMinus1 = 1023;
Ritor1
parents:
diff changeset
2523 break;
Ritor1
parents:
diff changeset
2524 case 11:
Ritor1
parents:
diff changeset
2525 v5->uHeightMinus1 = 2047;
Ritor1
parents:
diff changeset
2526 break;
Ritor1
parents:
diff changeset
2527 case 12:
Ritor1
parents:
diff changeset
2528 v5->uHeightMinus1 = 4095;
Ritor1
parents:
diff changeset
2529 break;
Ritor1
parents:
diff changeset
2530 default:
Ritor1
parents:
diff changeset
2531 return 1;
Ritor1
parents:
diff changeset
2532 }
Ritor1
parents:
diff changeset
2533 return 1;
Ritor1
parents:
diff changeset
2534 }
Ritor1
parents:
diff changeset
2535
Ritor1
parents:
diff changeset
2536
Ritor1
parents:
diff changeset
2537 //----- (00410423) --------------------------------------------------------
Ritor1
parents:
diff changeset
2538 void LODFile_IconsBitmaps::_410423_move_textures_to_device()
Ritor1
parents:
diff changeset
2539 {
Ritor1
parents:
diff changeset
2540 LODFile_IconsBitmaps *v1; // esi@1
Ritor1
parents:
diff changeset
2541 unsigned int v2; // edi@1
Ritor1
parents:
diff changeset
2542 char *v3; // ebx@2
Ritor1
parents:
diff changeset
2543 size_t v4; // eax@9
Ritor1
parents:
diff changeset
2544 char *v5; // ST1C_4@9
Ritor1
parents:
diff changeset
2545 void *v6; // eax@12
Ritor1
parents:
diff changeset
2546 signed int v7; // esi@13
Ritor1
parents:
diff changeset
2547
Ritor1
parents:
diff changeset
2548 v1 = this;
Ritor1
parents:
diff changeset
2549 v2 = this->uNumLoadedFiles - 1;
Ritor1
parents:
diff changeset
2550 if ( (v2 & 0x80000000u) == 0 )
Ritor1
parents:
diff changeset
2551 {
Ritor1
parents:
diff changeset
2552 v3 = &this->pTextures[v2].pName[2];
Ritor1
parents:
diff changeset
2553 do
Ritor1
parents:
diff changeset
2554 {
Ritor1
parents:
diff changeset
2555 if ( v1->ptr_011BB4[v2] )
Ritor1
parents:
diff changeset
2556 {
Ritor1
parents:
diff changeset
2557 if ( *(v3 - 2) != 'w' || *(v3 - 1) != 't' || *v3 != 'r' || v3[1] != 'd' || v3[2] != 'r' )
Ritor1
parents:
diff changeset
2558 {
Ritor1
parents:
diff changeset
2559 pRenderer->LoadTexture(
Ritor1
parents:
diff changeset
2560 v3 - 2,
Ritor1
parents:
diff changeset
2561 *((short *)v3 + 17),
Ritor1
parents:
diff changeset
2562 (IDirectDrawSurface4 **)&v1->pHardwareSurfaces[v2],
Ritor1
parents:
diff changeset
2563 &v1->pHardwareTextures[v2]);
Ritor1
parents:
diff changeset
2564 }
Ritor1
parents:
diff changeset
2565 else
Ritor1
parents:
diff changeset
2566 {
Ritor1
parents:
diff changeset
2567 v4 = strlen(v3 - 2);
Ritor1
parents:
diff changeset
2568 v5 = (char *)operator new(v4 + 2);
Ritor1
parents:
diff changeset
2569 *v5 = 'h';
Ritor1
parents:
diff changeset
2570 strcpy(v5 + 1, v3 - 2);
Ritor1
parents:
diff changeset
2571 pRenderer->LoadTexture(
Ritor1
parents:
diff changeset
2572 v5,
Ritor1
parents:
diff changeset
2573 *((short *)v3 + 17),
Ritor1
parents:
diff changeset
2574 (IDirectDrawSurface4 **)&v1->pHardwareSurfaces[v2],
Ritor1
parents:
diff changeset
2575 &v1->pHardwareTextures[v2]);
Ritor1
parents:
diff changeset
2576 free(v5);
Ritor1
parents:
diff changeset
2577 }
Ritor1
parents:
diff changeset
2578 }
Ritor1
parents:
diff changeset
2579 --v2;
Ritor1
parents:
diff changeset
2580 v3 -= 72;
Ritor1
parents:
diff changeset
2581 }
Ritor1
parents:
diff changeset
2582 while ( (v2 & 0x80000000u) == 0 );
Ritor1
parents:
diff changeset
2583 }
Ritor1
parents:
diff changeset
2584 v6 = v1->ptr_011BB4;
Ritor1
parents:
diff changeset
2585 if ( v6 )
Ritor1
parents:
diff changeset
2586 {
Ritor1
parents:
diff changeset
2587 v7 = v1->uNumLoadedFiles;
Ritor1
parents:
diff changeset
2588 if ( v7 > 1 )
Ritor1
parents:
diff changeset
2589 memset(v6, 0, v7 - 1);
Ritor1
parents:
diff changeset
2590 }
Ritor1
parents:
diff changeset
2591 }
Ritor1
parents:
diff changeset
2592
Ritor1
parents:
diff changeset
2593
Ritor1
parents:
diff changeset
2594 //----- (004103BB) --------------------------------------------------------
Ritor1
parents:
diff changeset
2595 void LODFile_IconsBitmaps::ReleaseHardwareTextures()
Ritor1
parents:
diff changeset
2596 {
Ritor1
parents:
diff changeset
2597 LODFile_IconsBitmaps *v1; // esi@1
Ritor1
parents:
diff changeset
2598 unsigned int v2; // edi@1
Ritor1
parents:
diff changeset
2599 struct IDirect3DTexture2 **v3; // eax@2
Ritor1
parents:
diff changeset
2600 struct IDirect3DTexture2 *v4; // eax@3
Ritor1
parents:
diff changeset
2601 struct IDirectDrawSurface **v5; // eax@5
Ritor1
parents:
diff changeset
2602 struct IDirectDrawSurface *v6; // eax@6
Ritor1
parents:
diff changeset
2603
Ritor1
parents:
diff changeset
2604 v1 = this;
Ritor1
parents:
diff changeset
2605 v2 = this->uNumLoadedFiles;
Ritor1
parents:
diff changeset
2606 while ( 1 )
Ritor1
parents:
diff changeset
2607 {
Ritor1
parents:
diff changeset
2608 --v2;
Ritor1
parents:
diff changeset
2609 if ( (v2 & 0x80000000u) != 0 )
Ritor1
parents:
diff changeset
2610 break;
Ritor1
parents:
diff changeset
2611 v3 = v1->pHardwareTextures;
Ritor1
parents:
diff changeset
2612 if ( v3 )
Ritor1
parents:
diff changeset
2613 {
Ritor1
parents:
diff changeset
2614 v4 = v3[v2];
Ritor1
parents:
diff changeset
2615 if ( v4 )
Ritor1
parents:
diff changeset
2616 {
Ritor1
parents:
diff changeset
2617 v4->Release();
Ritor1
parents:
diff changeset
2618 v1->pHardwareTextures[v2] = 0;
Ritor1
parents:
diff changeset
2619 v1->ptr_011BB4[v2] = 1;
Ritor1
parents:
diff changeset
2620 }
Ritor1
parents:
diff changeset
2621 }
Ritor1
parents:
diff changeset
2622 v5 = v1->pHardwareSurfaces;
Ritor1
parents:
diff changeset
2623 if ( v5 )
Ritor1
parents:
diff changeset
2624 {
Ritor1
parents:
diff changeset
2625 v6 = v5[v2];
Ritor1
parents:
diff changeset
2626 if ( v6 )
Ritor1
parents:
diff changeset
2627 {
Ritor1
parents:
diff changeset
2628 v6->Release();
Ritor1
parents:
diff changeset
2629 v1->pHardwareSurfaces[v2] = 0;
Ritor1
parents:
diff changeset
2630 v1->ptr_011BB4[v2] = 1;
Ritor1
parents:
diff changeset
2631 }
Ritor1
parents:
diff changeset
2632 }
Ritor1
parents:
diff changeset
2633 }
Ritor1
parents:
diff changeset
2634 }
Ritor1
parents:
diff changeset
2635
Ritor1
parents:
diff changeset
2636
Ritor1
parents:
diff changeset
2637 //----- (0041033D) --------------------------------------------------------
Ritor1
parents:
diff changeset
2638 void LODFile_IconsBitmaps::ReleaseLostHardwareTextures()
Ritor1
parents:
diff changeset
2639 {
Ritor1
parents:
diff changeset
2640 LODFile_IconsBitmaps *v1; // edi@1
Ritor1
parents:
diff changeset
2641 unsigned int i; // ebx@1
Ritor1
parents:
diff changeset
2642 struct IDirectDrawSurface **pHardwareSurfaces; // eax@2
Ritor1
parents:
diff changeset
2643 int v4; // esi@3
Ritor1
parents:
diff changeset
2644 struct IDirectDrawSurface *pSurface; // eax@3
Ritor1
parents:
diff changeset
2645 struct IDirect3DTexture2 **v6; // eax@5
Ritor1
parents:
diff changeset
2646 struct IDirect3DTexture2 *v7; // eax@6
Ritor1
parents:
diff changeset
2647
Ritor1
parents:
diff changeset
2648 v1 = this;
Ritor1
parents:
diff changeset
2649 for ( i = this->uNumLoadedFiles - 1; (i & 0x80000000u) == 0; --i )
Ritor1
parents:
diff changeset
2650 {
Ritor1
parents:
diff changeset
2651 pHardwareSurfaces = v1->pHardwareSurfaces;
Ritor1
parents:
diff changeset
2652 if ( pHardwareSurfaces )
Ritor1
parents:
diff changeset
2653 {
Ritor1
parents:
diff changeset
2654 v4 = i;
Ritor1
parents:
diff changeset
2655 pSurface = pHardwareSurfaces[i];
Ritor1
parents:
diff changeset
2656 if ( pSurface )
Ritor1
parents:
diff changeset
2657 {
Ritor1
parents:
diff changeset
2658 if ( pSurface->IsLost() == DDERR_SURFACELOST )
Ritor1
parents:
diff changeset
2659 {
Ritor1
parents:
diff changeset
2660 v6 = v1->pHardwareTextures;
Ritor1
parents:
diff changeset
2661 if ( v6 )
Ritor1
parents:
diff changeset
2662 {
Ritor1
parents:
diff changeset
2663 v7 = v6[v4];
Ritor1
parents:
diff changeset
2664 if ( v7 )
Ritor1
parents:
diff changeset
2665 {
Ritor1
parents:
diff changeset
2666 v7->Release();
Ritor1
parents:
diff changeset
2667 v1->pHardwareTextures[v4] = 0;
Ritor1
parents:
diff changeset
2668 }
Ritor1
parents:
diff changeset
2669 }
Ritor1
parents:
diff changeset
2670 v1->pHardwareSurfaces[v4]->Release();
Ritor1
parents:
diff changeset
2671 v1->pHardwareSurfaces[v4] = 0;
Ritor1
parents:
diff changeset
2672 v1->ptr_011BB4[i] = 1;
Ritor1
parents:
diff changeset
2673 }
Ritor1
parents:
diff changeset
2674 }
Ritor1
parents:
diff changeset
2675 }
Ritor1
parents:
diff changeset
2676 }
Ritor1
parents:
diff changeset
2677 }
Ritor1
parents:
diff changeset
2678
Ritor1
parents:
diff changeset
2679 //----- (004101B1) --------------------------------------------------------
Ritor1
parents:
diff changeset
2680 int LODFile_IconsBitmaps::ReloadTexture(Texture *pDst, const char *pContainer, int mode)
Ritor1
parents:
diff changeset
2681 {
Ritor1
parents:
diff changeset
2682 LODFile_IconsBitmaps *v4; // edi@1
Ritor1
parents:
diff changeset
2683 FILE *v5; // eax@1
Ritor1
parents:
diff changeset
2684 Texture *v6; // esi@2
Ritor1
parents:
diff changeset
2685 unsigned int v7; // ebx@6
Ritor1
parents:
diff changeset
2686 unsigned int v8; // ecx@6
Ritor1
parents:
diff changeset
2687 signed int result; // eax@7
Ritor1
parents:
diff changeset
2688 size_t *v10; // ebx@8
Ritor1
parents:
diff changeset
2689 signed int v11; // ebx@12
Ritor1
parents:
diff changeset
2690 int v12; // eax@13
Ritor1
parents:
diff changeset
2691 int v13; // edx@13
Ritor1
parents:
diff changeset
2692 FILE *File; // [sp+Ch] [bp-8h]@1
Ritor1
parents:
diff changeset
2693 unsigned __int8 v15; // [sp+11h] [bp-3h]@13
Ritor1
parents:
diff changeset
2694 unsigned __int8 v16; // [sp+12h] [bp-2h]@13
Ritor1
parents:
diff changeset
2695 unsigned __int8 DstBuf; // [sp+13h] [bp-1h]@13
Ritor1
parents:
diff changeset
2696 void *DstBufa; // [sp+1Ch] [bp+8h]@10
Ritor1
parents:
diff changeset
2697 void *Sourcea; // [sp+20h] [bp+Ch]@10
Ritor1
parents:
diff changeset
2698 unsigned int Counta; // [sp+24h] [bp+10h]@6
Ritor1
parents:
diff changeset
2699
Ritor1
parents:
diff changeset
2700 v4 = this;
Ritor1
parents:
diff changeset
2701 v5 = FindContainer(pContainer, 0);
Ritor1
parents:
diff changeset
2702 File = v5;
Ritor1
parents:
diff changeset
2703 if ( v5
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2704 && (v6 = pDst, pDst->pLevelOfDetail0_prolly_alpha_mask)
0
Ritor1
parents:
diff changeset
2705 && mode == 2
Ritor1
parents:
diff changeset
2706 && pDst->pPalette16
Ritor1
parents:
diff changeset
2707 && !pDst->pPalette24
Ritor1
parents:
diff changeset
2708 && (v7 = pDst->uTextureSize,
Ritor1
parents:
diff changeset
2709 fread(pDst, 1u, 0x30u, v5),
Ritor1
parents:
diff changeset
2710 strcpy(pDst->pName, pContainer),
Ritor1
parents:
diff changeset
2711 v8 = pDst->uTextureSize,
Ritor1
parents:
diff changeset
2712 Counta = pDst->uTextureSize,
Ritor1
parents:
diff changeset
2713 (signed int)v8 <= (signed int)v7) )
Ritor1
parents:
diff changeset
2714 {
Ritor1
parents:
diff changeset
2715 v10 = &pDst->uDecompressedSize;
Ritor1
parents:
diff changeset
2716 if ( !pDst->uDecompressedSize || v4->dword_011BA4 )
Ritor1
parents:
diff changeset
2717 {
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2718 fread(pDst->pLevelOfDetail0_prolly_alpha_mask, 1u, v8, File);
0
Ritor1
parents:
diff changeset
2719 }
Ritor1
parents:
diff changeset
2720 else
Ritor1
parents:
diff changeset
2721 {
Ritor1
parents:
diff changeset
2722 Sourcea = malloc(pDst->uDecompressedSize);
Ritor1
parents:
diff changeset
2723 DstBufa = malloc(pDst->uTextureSize);
Ritor1
parents:
diff changeset
2724 fread(DstBufa, 1u, Counta, File);
Ritor1
parents:
diff changeset
2725 zlib::MemUnzip(Sourcea, &v6->uDecompressedSize, DstBufa, v6->uTextureSize);
Ritor1
parents:
diff changeset
2726 v6->uTextureSize = *v10;
Ritor1
parents:
diff changeset
2727 free(DstBufa);
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2728 memcpy(v6->pLevelOfDetail0_prolly_alpha_mask, Sourcea, *v10);
0
Ritor1
parents:
diff changeset
2729 free(Sourcea);
Ritor1
parents:
diff changeset
2730 }
Ritor1
parents:
diff changeset
2731 v11 = 0;
Ritor1
parents:
diff changeset
2732 do
Ritor1
parents:
diff changeset
2733 {
Ritor1
parents:
diff changeset
2734 fread(&DstBuf, 1u, 1u, File);
Ritor1
parents:
diff changeset
2735 fread(&v16, 1u, 1u, File);
Ritor1
parents:
diff changeset
2736 v12 = fread(&v15, 1u, 1u, File);
Ritor1
parents:
diff changeset
2737 LOWORD(v12) = (unsigned __int8)(DstBuf >> (8 - LOBYTE(v4->uTextureRedBits)));
Ritor1
parents:
diff changeset
2738 v6->pPalette16[v11] = v12 << (LOBYTE(v4->uTextureBlueBits) + LOBYTE(v4->uTextureGreenBits));
Ritor1
parents:
diff changeset
2739 LOWORD(v13) = (unsigned __int8)(v16 >> (8 - LOBYTE(v4->uTextureGreenBits)));
Ritor1
parents:
diff changeset
2740 v6->pPalette16[v11] += v13 << v4->uTextureBlueBits;
Ritor1
parents:
diff changeset
2741 v6->pPalette16[v11] += (unsigned __int8)(v15 >> (8 - LOBYTE(v4->uTextureBlueBits)));
Ritor1
parents:
diff changeset
2742 ++v11;
Ritor1
parents:
diff changeset
2743 }
Ritor1
parents:
diff changeset
2744 while ( v11 < 256 );
Ritor1
parents:
diff changeset
2745 result = 1;
Ritor1
parents:
diff changeset
2746 }
Ritor1
parents:
diff changeset
2747 else
Ritor1
parents:
diff changeset
2748 {
Ritor1
parents:
diff changeset
2749 result = -1;
Ritor1
parents:
diff changeset
2750 }
Ritor1
parents:
diff changeset
2751 return result;
Ritor1
parents:
diff changeset
2752 }
Ritor1
parents:
diff changeset
2753
Ritor1
parents:
diff changeset
2754
Ritor1
parents:
diff changeset
2755 //----- (0040FC08) --------------------------------------------------------
Ritor1
parents:
diff changeset
2756 int LODFile_IconsBitmaps::LoadTextureFromLOD(Texture *pOutTex, const char *pContainer, enum TEXTURE_TYPE eTextureType)
Ritor1
parents:
diff changeset
2757 {
Ritor1
parents:
diff changeset
2758 Texture *v8; // esi@3
Ritor1
parents:
diff changeset
2759 size_t v11; // eax@14
Ritor1
parents:
diff changeset
2760 enum TEXTURE_TYPE v12; // eax@14
Ritor1
parents:
diff changeset
2761 signed int v13; // esi@14
Ritor1
parents:
diff changeset
2762 unsigned int v14; // eax@21
Ritor1
parents:
diff changeset
2763 unsigned int v15; // ecx@25
Ritor1
parents:
diff changeset
2764 unsigned int *v16; // ebx@25
Ritor1
parents:
diff changeset
2765 void *v17; // eax@27
Ritor1
parents:
diff changeset
2766 unsigned int v18; // ST28_4@27
Ritor1
parents:
diff changeset
2767 void *v19; // ST3C_4@27
Ritor1
parents:
diff changeset
2768 Allocator *v20; // ebx@29
Ritor1
parents:
diff changeset
2769 void *v21; // eax@29
Ritor1
parents:
diff changeset
2770 size_t v22; // ST2C_4@29
Ritor1
parents:
diff changeset
2771 const void *v23; // ecx@29
Ritor1
parents:
diff changeset
2772 unsigned __int16 v24; // ax@29
Ritor1
parents:
diff changeset
2773 unsigned __int16 v25; // cx@29
Ritor1
parents:
diff changeset
2774 __int16 v26; // dx@29
Ritor1
parents:
diff changeset
2775 unsigned int v27; // ecx@29
Ritor1
parents:
diff changeset
2776 Texture *v28; // eax@29
Ritor1
parents:
diff changeset
2777 unsigned int v29; // ST28_4@30
Ritor1
parents:
diff changeset
2778 void *v30; // eax@30
Ritor1
parents:
diff changeset
2779 unsigned int v31; // ST2C_4@30
Ritor1
parents:
diff changeset
2780 void *v32; // eax@32
Ritor1
parents:
diff changeset
2781 void *v33; // eax@34
Ritor1
parents:
diff changeset
2782 signed int v34; // eax@37
Ritor1
parents:
diff changeset
2783 unsigned __int8 *v35; // ecx@37
Ritor1
parents:
diff changeset
2784 unsigned __int8 *v36; // ecx@37
Ritor1
parents:
diff changeset
2785 unsigned __int8 *v37; // eax@37
Ritor1
parents:
diff changeset
2786 signed int v38; // ebx@39
Ritor1
parents:
diff changeset
2787 int v39; // eax@40
Ritor1
parents:
diff changeset
2788 int v40; // edx@40
Ritor1
parents:
diff changeset
2789 signed int v41; // ecx@43
Ritor1
parents:
diff changeset
2790 signed int v42; // ecx@48
Ritor1
parents:
diff changeset
2791
Ritor1
parents:
diff changeset
2792 //v4 = pContainer;
Ritor1
parents:
diff changeset
2793 //v5 = this;
Ritor1
parents:
diff changeset
2794 //v6 = FindContainer(pContainer, 0);
Ritor1
parents:
diff changeset
2795 //File = v6;
Ritor1
parents:
diff changeset
2796 auto pFile = FindContainer(pContainer, false);
Ritor1
parents:
diff changeset
2797 if (!pFile)
Ritor1
parents:
diff changeset
2798 return -1;
Ritor1
parents:
diff changeset
2799 v8 = pOutTex;
Ritor1
parents:
diff changeset
2800 fread(pOutTex, 1u, 0x30u, pFile);
Ritor1
parents:
diff changeset
2801 strcpy(v8->pName, pContainer);
Ritor1
parents:
diff changeset
2802 if (pRenderer->pRenderD3D && v8->pBits & 2 && dword_011BA8)
Ritor1
parents:
diff changeset
2803 {
Ritor1
parents:
diff changeset
2804 if (!pHardwareSurfaces || !pHardwareTextures)
Ritor1
parents:
diff changeset
2805 {
Ritor1
parents:
diff changeset
2806 pHardwareSurfaces = new IDirectDrawSurface *[1000];
Ritor1
parents:
diff changeset
2807 memset(pHardwareSurfaces, 0, 1000 * sizeof(IDirectDrawSurface4 *));
Ritor1
parents:
diff changeset
2808
Ritor1
parents:
diff changeset
2809 pHardwareTextures = new IDirect3DTexture2 *[1000];
Ritor1
parents:
diff changeset
2810 memset(pHardwareTextures, 0, 1000 * sizeof(IDirect3DTexture2 *));
Ritor1
parents:
diff changeset
2811
Ritor1
parents:
diff changeset
2812 ptr_011BB4 = new char[1000];
Ritor1
parents:
diff changeset
2813 memset(ptr_011BB4, 0, 1000);
Ritor1
parents:
diff changeset
2814 }
265
96bc024a5fed Render overflows
Nomad
parents: 144
diff changeset
2815 if (strnicmp(pContainer, "wtrdr", 5))//*v4 != 'w' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'd' || v4[4] != 'r' )
0
Ritor1
parents:
diff changeset
2816 {
265
96bc024a5fed Render overflows
Nomad
parents: 144
diff changeset
2817 if (strnicmp(pContainer, "WtrTyl", 6))//if ( *v4 != 'W' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'T' || v4[4] != 'y' || v4[5] != 'l' )
0
Ritor1
parents:
diff changeset
2818 {
Ritor1
parents:
diff changeset
2819 v14 = uNumLoadedFiles;
Ritor1
parents:
diff changeset
2820 }
Ritor1
parents:
diff changeset
2821 else
Ritor1
parents:
diff changeset
2822 {
265
96bc024a5fed Render overflows
Nomad
parents: 144
diff changeset
2823 pRenderer->hd_water_tile_id = uNumLoadedFiles;
0
Ritor1
parents:
diff changeset
2824 v14 = uNumLoadedFiles;
Ritor1
parents:
diff changeset
2825 }
Ritor1
parents:
diff changeset
2826 v13 = pRenderer->LoadTexture(
Ritor1
parents:
diff changeset
2827 pContainer,
Ritor1
parents:
diff changeset
2828 v8->palette_id1,
Ritor1
parents:
diff changeset
2829 (IDirectDrawSurface4 **)&pHardwareSurfaces[v14],
Ritor1
parents:
diff changeset
2830 &pHardwareTextures[v14]);
Ritor1
parents:
diff changeset
2831 }
Ritor1
parents:
diff changeset
2832 else
Ritor1
parents:
diff changeset
2833 {
Ritor1
parents:
diff changeset
2834 v11 = strlen(pContainer);
Ritor1
parents:
diff changeset
2835 v12 = (enum TEXTURE_TYPE)(int)operator new(v11 + 2);
Ritor1
parents:
diff changeset
2836 eTextureType = v12;
Ritor1
parents:
diff changeset
2837 *(char *)v12 = 104;
Ritor1
parents:
diff changeset
2838 strcpy((char *)(v12 + 1), pContainer);
Ritor1
parents:
diff changeset
2839 v13 = pRenderer->LoadTexture(
Ritor1
parents:
diff changeset
2840 (const char *)eTextureType,
Ritor1
parents:
diff changeset
2841 v8->palette_id1,
Ritor1
parents:
diff changeset
2842 (IDirectDrawSurface4 **)&pHardwareSurfaces[uNumLoadedFiles],
Ritor1
parents:
diff changeset
2843 &pHardwareTextures[uNumLoadedFiles]);
Ritor1
parents:
diff changeset
2844 free((void *)eTextureType);
Ritor1
parents:
diff changeset
2845 }
Ritor1
parents:
diff changeset
2846 return v13;
Ritor1
parents:
diff changeset
2847 }
Ritor1
parents:
diff changeset
2848 v15 = v8->uTextureSize;
Ritor1
parents:
diff changeset
2849 v16 = &v8->uDecompressedSize;
Ritor1
parents:
diff changeset
2850 pOutTex = (Texture *)v8->uTextureSize;
Ritor1
parents:
diff changeset
2851 if ( !v8->uDecompressedSize || dword_011BA4 )
Ritor1
parents:
diff changeset
2852 {
Ritor1
parents:
diff changeset
2853 v20 = pAllocator;
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2854 v32 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0_prolly_alpha_mask, v15, v8->pName);
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2855 v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v32;
0
Ritor1
parents:
diff changeset
2856 fread(v32, 1u, (size_t)pOutTex, pFile);
Ritor1
parents:
diff changeset
2857 }
Ritor1
parents:
diff changeset
2858 else
Ritor1
parents:
diff changeset
2859 {
Ritor1
parents:
diff changeset
2860 v17 = malloc(v8->uDecompressedSize);
Ritor1
parents:
diff changeset
2861 v18 = v8->uTextureSize;
Ritor1
parents:
diff changeset
2862 pContainer = (const char *)v17;
Ritor1
parents:
diff changeset
2863 v19 = malloc(v18);
Ritor1
parents:
diff changeset
2864 fread(v19, 1u, (size_t)pOutTex, pFile);
Ritor1
parents:
diff changeset
2865 zlib::MemUnzip((void *)pContainer, &v8->uDecompressedSize, v19, v8->uTextureSize);
Ritor1
parents:
diff changeset
2866 v8->uTextureSize = *v16;
Ritor1
parents:
diff changeset
2867 free(v19);
Ritor1
parents:
diff changeset
2868 if ( bUseLoResSprites && v8->pBits & 2 )
Ritor1
parents:
diff changeset
2869 {
Ritor1
parents:
diff changeset
2870 v20 = pAllocator;
Ritor1
parents:
diff changeset
2871 pOutTex = (Texture *)(((signed int)v8->uSizeOfMaxLevelOfDetail >> 2)
Ritor1
parents:
diff changeset
2872 + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 4)
Ritor1
parents:
diff changeset
2873 + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 6));
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2874 v21 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0_prolly_alpha_mask, (unsigned int)pOutTex, v8->pName);
0
Ritor1
parents:
diff changeset
2875 v22 = (size_t)pOutTex;
Ritor1
parents:
diff changeset
2876 v23 = &pContainer[v8->uTextureWidth * v8->uTextureHeight];
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2877 v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v21;
0
Ritor1
parents:
diff changeset
2878 memcpy(v21, v23, v22);
Ritor1
parents:
diff changeset
2879 v8->uTextureWidth = (signed __int16)v8->uTextureWidth >> 1;
Ritor1
parents:
diff changeset
2880 v24 = v8->uTextureWidth;
Ritor1
parents:
diff changeset
2881 v8->uTextureHeight = (signed __int16)v8->uTextureHeight >> 1;
Ritor1
parents:
diff changeset
2882 v25 = v8->uTextureHeight;
Ritor1
parents:
diff changeset
2883 --v8->uWidthLn2;
Ritor1
parents:
diff changeset
2884 --v8->uHeightLn2;
Ritor1
parents:
diff changeset
2885 v8->uWidthMinus1 = v24 - 1;
Ritor1
parents:
diff changeset
2886 v26 = v25 - 1;
Ritor1
parents:
diff changeset
2887 v27 = (signed __int16)v24 * (signed __int16)v25;
Ritor1
parents:
diff changeset
2888 v28 = pOutTex;
Ritor1
parents:
diff changeset
2889 v8->uHeightMinus1 = v26;
Ritor1
parents:
diff changeset
2890 v8->uSizeOfMaxLevelOfDetail = v27;
Ritor1
parents:
diff changeset
2891 v8->uTextureSize = (unsigned int)v28;
Ritor1
parents:
diff changeset
2892 }
Ritor1
parents:
diff changeset
2893 else
Ritor1
parents:
diff changeset
2894 {
Ritor1
parents:
diff changeset
2895 v29 = *v16;
Ritor1
parents:
diff changeset
2896 v20 = pAllocator;
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2897 v30 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0_prolly_alpha_mask, v29, v8->pName);
0
Ritor1
parents:
diff changeset
2898 v31 = v8->uDecompressedSize;
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2899 v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v30;
0
Ritor1
parents:
diff changeset
2900 memcpy(v30, pContainer, v31);
Ritor1
parents:
diff changeset
2901 }
Ritor1
parents:
diff changeset
2902 free((void *)pContainer);
Ritor1
parents:
diff changeset
2903 }
Ritor1
parents:
diff changeset
2904 pAllocator->FreeChunk(v8->pPalette16);
Ritor1
parents:
diff changeset
2905 pAllocator->FreeChunk(v8->pPalette24);
Ritor1
parents:
diff changeset
2906 if ( eTextureType == TEXTURE_24BIT_PALETTE )
Ritor1
parents:
diff changeset
2907 {
Ritor1
parents:
diff changeset
2908 v33 = pAllocator->AllocNamedChunk(v8->pPalette24, 0x300u, v8->pName);
Ritor1
parents:
diff changeset
2909 v8->pPalette24 = (unsigned __int8 *)v33;
Ritor1
parents:
diff changeset
2910 fread(v33, 1u, 0x300u, pFile);
Ritor1
parents:
diff changeset
2911 }
Ritor1
parents:
diff changeset
2912 else
Ritor1
parents:
diff changeset
2913 {
Ritor1
parents:
diff changeset
2914 v8->pPalette24 = 0;
Ritor1
parents:
diff changeset
2915 if ( eTextureType == TEXTURE_16BIT_PALETTE )
Ritor1
parents:
diff changeset
2916 {
Ritor1
parents:
diff changeset
2917 v8->pPalette16 = (unsigned __int16 *)pAllocator->AllocNamedChunk(v8->pPalette16, 0x200u, v8->pName);
Ritor1
parents:
diff changeset
2918 v38 = 0;
Ritor1
parents:
diff changeset
2919 do
Ritor1
parents:
diff changeset
2920 {
Ritor1
parents:
diff changeset
2921 fread((char *)&eTextureType + 3, 1u, 1u, pFile);
Ritor1
parents:
diff changeset
2922 fread((char *)&pContainer + 3, 1u, 1u, pFile);
Ritor1
parents:
diff changeset
2923 v39 = fread((char *)&pOutTex + 3, 1u, 1u, pFile);
Ritor1
parents:
diff changeset
2924 LOWORD(v39) = (unsigned __int8)(BYTE3(eTextureType) >> (8 - LOBYTE(uTextureRedBits)));
Ritor1
parents:
diff changeset
2925 v8->pPalette16[v38] = v39 << (LOBYTE(uTextureBlueBits) + LOBYTE(uTextureGreenBits));
Ritor1
parents:
diff changeset
2926 LOWORD(v40) = (unsigned __int8)(BYTE3(pContainer) >> (8 - LOBYTE(uTextureGreenBits)));
Ritor1
parents:
diff changeset
2927 v8->pPalette16[v38] += v40 << uTextureBlueBits;
Ritor1
parents:
diff changeset
2928 v8->pPalette16[v38] += (unsigned __int8)(BYTE3(pOutTex) >> (8 - LOBYTE(uTextureBlueBits)));
Ritor1
parents:
diff changeset
2929 ++v38;
Ritor1
parents:
diff changeset
2930 }
Ritor1
parents:
diff changeset
2931 while ( v38 < 256 );
Ritor1
parents:
diff changeset
2932 goto LABEL_36;
Ritor1
parents:
diff changeset
2933 }
Ritor1
parents:
diff changeset
2934 }
Ritor1
parents:
diff changeset
2935 v8->pPalette16 = 0;
Ritor1
parents:
diff changeset
2936 LABEL_36:
Ritor1
parents:
diff changeset
2937 if ( v8->pBits & 2 )
Ritor1
parents:
diff changeset
2938 {
Ritor1
parents:
diff changeset
2939 v34 = v8->uSizeOfMaxLevelOfDetail;
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 705
diff changeset
2940 v35 = &v8->pLevelOfDetail0_prolly_alpha_mask[v34];
0
Ritor1
parents:
diff changeset
2941 v8->pLevelOfDetail1 = v35;
Ritor1
parents:
diff changeset
2942 v36 = &v35[v34 >> 2];
Ritor1
parents:
diff changeset
2943 v8->pLevelOfDetail2 = v36;
Ritor1
parents:
diff changeset
2944 v37 = &v36[v34 >> 4];
Ritor1
parents:
diff changeset
2945 }
Ritor1
parents:
diff changeset
2946 else
Ritor1
parents:
diff changeset
2947 {
Ritor1
parents:
diff changeset
2948 v37 = 0;
Ritor1
parents:
diff changeset
2949 v8->pLevelOfDetail2 = 0;
Ritor1
parents:
diff changeset
2950 v8->pLevelOfDetail1 = 0;
Ritor1
parents:
diff changeset
2951 }
Ritor1
parents:
diff changeset
2952 v8->pLevelOfDetail3 = v37;
Ritor1
parents:
diff changeset
2953 v41 = 1;
Ritor1
parents:
diff changeset
2954 while ( 1 << v41 != v8->uTextureWidth )
Ritor1
parents:
diff changeset
2955 {
Ritor1
parents:
diff changeset
2956 ++v41;
Ritor1
parents:
diff changeset
2957 if ( v41 >= 15 )
Ritor1
parents:
diff changeset
2958 goto LABEL_48;
Ritor1
parents:
diff changeset
2959 }
Ritor1
parents:
diff changeset
2960 v8->uWidthLn2 = v41;
Ritor1
parents:
diff changeset
2961 LABEL_48:
Ritor1
parents:
diff changeset
2962 v42 = 1;
Ritor1
parents:
diff changeset
2963 while ( 1 << v42 != v8->uTextureHeight )
Ritor1
parents:
diff changeset
2964 {
Ritor1
parents:
diff changeset
2965 ++v42;
Ritor1
parents:
diff changeset
2966 if ( v42 >= 15 )
Ritor1
parents:
diff changeset
2967 goto LABEL_53;
Ritor1
parents:
diff changeset
2968 }
Ritor1
parents:
diff changeset
2969 v8->uHeightLn2 = v42;
Ritor1
parents:
diff changeset
2970 LABEL_53:
Ritor1
parents:
diff changeset
2971 switch ( v8->uWidthLn2 )
Ritor1
parents:
diff changeset
2972 {
Ritor1
parents:
diff changeset
2973 case 2:
Ritor1
parents:
diff changeset
2974 v8->uWidthMinus1 = 3;
Ritor1
parents:
diff changeset
2975 break;
Ritor1
parents:
diff changeset
2976 case 3:
Ritor1
parents:
diff changeset
2977 v8->uWidthMinus1 = 7;
Ritor1
parents:
diff changeset
2978 break;
Ritor1
parents:
diff changeset
2979 case 4:
Ritor1
parents:
diff changeset
2980 v8->uWidthMinus1 = 15;
Ritor1
parents:
diff changeset
2981 break;
Ritor1
parents:
diff changeset
2982 case 5:
Ritor1
parents:
diff changeset
2983 v8->uWidthMinus1 = 31;
Ritor1
parents:
diff changeset
2984 break;
Ritor1
parents:
diff changeset
2985 case 6:
Ritor1
parents:
diff changeset
2986 v8->uWidthMinus1 = 63;
Ritor1
parents:
diff changeset
2987 break;
Ritor1
parents:
diff changeset
2988 case 7:
Ritor1
parents:
diff changeset
2989 v8->uWidthMinus1 = 127;
Ritor1
parents:
diff changeset
2990 break;
Ritor1
parents:
diff changeset
2991 case 8:
Ritor1
parents:
diff changeset
2992 v8->uWidthMinus1 = 255;
Ritor1
parents:
diff changeset
2993 break;
Ritor1
parents:
diff changeset
2994 case 9:
Ritor1
parents:
diff changeset
2995 v8->uWidthMinus1 = 511;
Ritor1
parents:
diff changeset
2996 break;
Ritor1
parents:
diff changeset
2997 case 10:
Ritor1
parents:
diff changeset
2998 v8->uWidthMinus1 = 1023;
Ritor1
parents:
diff changeset
2999 break;
Ritor1
parents:
diff changeset
3000 case 11:
Ritor1
parents:
diff changeset
3001 v8->uWidthMinus1 = 2047;
Ritor1
parents:
diff changeset
3002 break;
Ritor1
parents:
diff changeset
3003 case 12:
Ritor1
parents:
diff changeset
3004 v8->uWidthMinus1 = 4095;
Ritor1
parents:
diff changeset
3005 break;
Ritor1
parents:
diff changeset
3006 default:
Ritor1
parents:
diff changeset
3007 break;
Ritor1
parents:
diff changeset
3008 }
Ritor1
parents:
diff changeset
3009 switch ( v8->uHeightLn2 )
Ritor1
parents:
diff changeset
3010 {
Ritor1
parents:
diff changeset
3011 case 2:
Ritor1
parents:
diff changeset
3012 v8->uHeightMinus1 = 3;
Ritor1
parents:
diff changeset
3013 break;
Ritor1
parents:
diff changeset
3014 case 3:
Ritor1
parents:
diff changeset
3015 v8->uHeightMinus1 = 7;
Ritor1
parents:
diff changeset
3016 break;
Ritor1
parents:
diff changeset
3017 case 4:
Ritor1
parents:
diff changeset
3018 v8->uHeightMinus1 = 15;
Ritor1
parents:
diff changeset
3019 break;
Ritor1
parents:
diff changeset
3020 case 5:
Ritor1
parents:
diff changeset
3021 v8->uHeightMinus1 = 31;
Ritor1
parents:
diff changeset
3022 break;
Ritor1
parents:
diff changeset
3023 case 6:
Ritor1
parents:
diff changeset
3024 v8->uHeightMinus1 = 63;
Ritor1
parents:
diff changeset
3025 break;
Ritor1
parents:
diff changeset
3026 case 7:
Ritor1
parents:
diff changeset
3027 v8->uHeightMinus1 = 127;
Ritor1
parents:
diff changeset
3028 break;
Ritor1
parents:
diff changeset
3029 case 8:
Ritor1
parents:
diff changeset
3030 v8->uHeightMinus1 = 255;
Ritor1
parents:
diff changeset
3031 break;
Ritor1
parents:
diff changeset
3032 case 9:
Ritor1
parents:
diff changeset
3033 v8->uHeightMinus1 = 511;
Ritor1
parents:
diff changeset
3034 break;
Ritor1
parents:
diff changeset
3035 case 10:
Ritor1
parents:
diff changeset
3036 v8->uHeightMinus1 = 1023;
Ritor1
parents:
diff changeset
3037 break;
Ritor1
parents:
diff changeset
3038 case 11:
Ritor1
parents:
diff changeset
3039 v8->uHeightMinus1 = 2047;
Ritor1
parents:
diff changeset
3040 break;
Ritor1
parents:
diff changeset
3041 case 12:
Ritor1
parents:
diff changeset
3042 v8->uHeightMinus1 = 4095;
Ritor1
parents:
diff changeset
3043 break;
Ritor1
parents:
diff changeset
3044 default:
Ritor1
parents:
diff changeset
3045 return 1;
Ritor1
parents:
diff changeset
3046 }
Ritor1
parents:
diff changeset
3047 return 1;
Ritor1
parents:
diff changeset
3048 }
Ritor1
parents:
diff changeset
3049
Ritor1
parents:
diff changeset
3050
Ritor1
parents:
diff changeset
3051 Texture *LODFile_IconsBitmaps::LoadTexturePtr(const char *pContainer, enum TEXTURE_TYPE uTextureType)
Ritor1
parents:
diff changeset
3052 {
Ritor1
parents:
diff changeset
3053 uint id = LoadTexture(pContainer, uTextureType);
737
225d92620998 004A19D8 refactored
Nomad
parents: 733
diff changeset
3054
225d92620998 004A19D8 refactored
Nomad
parents: 733
diff changeset
3055 assert(id != -1 && L"Texture not found");
225d92620998 004A19D8 refactored
Nomad
parents: 733
diff changeset
3056
0
Ritor1
parents:
diff changeset
3057 return &pTextures[id];
Ritor1
parents:
diff changeset
3058 }
Ritor1
parents:
diff changeset
3059
Ritor1
parents:
diff changeset
3060 //----- (0040FB20) --------------------------------------------------------
Ritor1
parents:
diff changeset
3061 unsigned int LODFile_IconsBitmaps::LoadTexture(const char *pContainer, enum TEXTURE_TYPE uTextureType)
Ritor1
parents:
diff changeset
3062 {
Ritor1
parents:
diff changeset
3063 //LODFile_IconsBitmaps *v3; // esi@1
Ritor1
parents:
diff changeset
3064 //unsigned int v4; // edi@1
Ritor1
parents:
diff changeset
3065 //Texture *v5; // ebx@2
Ritor1
parents:
diff changeset
3066 unsigned int v6; // ebx@8
Ritor1
parents:
diff changeset
3067 const char *Sourcea; // [sp+14h] [bp+8h]@9
Ritor1
parents:
diff changeset
3068
Ritor1
parents:
diff changeset
3069 //v3 = this;
Ritor1
parents:
diff changeset
3070 //v4 = 0;
Ritor1
parents:
diff changeset
3071 areWeLoadingTexture = 1;
Ritor1
parents:
diff changeset
3072
Ritor1
parents:
diff changeset
3073 for (uint i = 0; i < uNumLoadedFiles; ++i)
Ritor1
parents:
diff changeset
3074 if (!strcmpi(pContainer, pTextures[i].pName))
Ritor1
parents:
diff changeset
3075 return i;
Ritor1
parents:
diff changeset
3076
Ritor1
parents:
diff changeset
3077 // if (!uNumLoadedFiles)
Ritor1
parents:
diff changeset
3078 // {
Ritor1
parents:
diff changeset
3079 //LABEL_5:
649
0e368c04acfb Sleeping in a tavern
Nomad
parents: 568
diff changeset
3080 assert(uNumLoadedFiles < 1000);
0e368c04acfb Sleeping in a tavern
Nomad
parents: 568
diff changeset
3081 /*if (uNumLoadedFiles >= 1000)
0
Ritor1
parents:
diff changeset
3082 {
Ritor1
parents:
diff changeset
3083 Log::Warning(L"Maximum texture number exceeded");
Ritor1
parents:
diff changeset
3084 AbortWithError();
649
0e368c04acfb Sleeping in a tavern
Nomad
parents: 568
diff changeset
3085 }*/
0
Ritor1
parents:
diff changeset
3086 if (LoadTextureFromLOD(&pTextures[uNumLoadedFiles], pContainer, uTextureType) == -1)
Ritor1
parents:
diff changeset
3087 {
Ritor1
parents:
diff changeset
3088 v6 = 0;
Ritor1
parents:
diff changeset
3089 if (uNumLoadedFiles > 0)
Ritor1
parents:
diff changeset
3090 {
Ritor1
parents:
diff changeset
3091 Sourcea = (const char *)pTextures;
Ritor1
parents:
diff changeset
3092 while ( _strcmpi(Sourcea, "pending") )
Ritor1
parents:
diff changeset
3093 {
Ritor1
parents:
diff changeset
3094 Sourcea += 72;
Ritor1
parents:
diff changeset
3095 ++v6;
Ritor1
parents:
diff changeset
3096 if (v6 >= uNumLoadedFiles)
Ritor1
parents:
diff changeset
3097 goto LABEL_15;
Ritor1
parents:
diff changeset
3098 }
Ritor1
parents:
diff changeset
3099 return v6;
Ritor1
parents:
diff changeset
3100 }
Ritor1
parents:
diff changeset
3101 LABEL_15:
Ritor1
parents:
diff changeset
3102 LoadTextureFromLOD(&pTextures[uNumLoadedFiles], "pending", uTextureType);
Ritor1
parents:
diff changeset
3103 }
Ritor1
parents:
diff changeset
3104 areWeLoadingTexture = 0;
Ritor1
parents:
diff changeset
3105 ++uNumLoadedFiles;
Ritor1
parents:
diff changeset
3106 return uNumLoadedFiles - 1;
Ritor1
parents:
diff changeset
3107 // }
Ritor1
parents:
diff changeset
3108 // v5 = pTextures;
Ritor1
parents:
diff changeset
3109 // while ( _strcmpi(v5->pName, pContainer) )
Ritor1
parents:
diff changeset
3110 // {
Ritor1
parents:
diff changeset
3111 // ++v4;
Ritor1
parents:
diff changeset
3112 // ++v5;
Ritor1
parents:
diff changeset
3113 // if (v4 >= uNumLoadedFiles )
Ritor1
parents:
diff changeset
3114 // goto LABEL_5;
Ritor1
parents:
diff changeset
3115 // }
Ritor1
parents:
diff changeset
3116 // return v4;
Ritor1
parents:
diff changeset
3117 }