annotate LOD.cpp @ 942:530e3d5ab48d

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