annotate Engine/LOD.cpp @ 2508:491f0babd563

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