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