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