0
|
1 #pragma once
|
|
2 #include <stdio.h>
|
|
3 #include <memory.h>
|
434
|
4 #include <assert.h>
|
0
|
5
|
|
6 #include "Texture.h"
|
|
7
|
|
8
|
|
9 /* 354 */
|
|
10 enum TEXTURE_TYPE
|
|
11 {
|
|
12 TEXTURE_DEFAULT = 0,
|
|
13 TEXTURE_24BIT_PALETTE = 0x1,
|
|
14 TEXTURE_16BIT_PALETTE = 0x2,
|
|
15 };
|
|
16
|
|
17 namespace LOD
|
|
18 {
|
|
19 #pragma pack(push, 1)
|
|
20 struct FileHeader
|
|
21 {
|
982
|
22 //----- (004617B6) --------------------------------------------------------
|
0
|
23 inline FileHeader()
|
|
24 {
|
|
25 memset(pSignature, 0, 4);
|
|
26 memset(LodVersion, 0, 80);
|
|
27 memset(LodDescription, 0, 80);
|
|
28 memset(array_0000B0, 0, 28);
|
|
29 memset(array_0000CC, 0, 52);
|
982
|
30
|
|
31 pSignature[0] = 0;
|
|
32 LodVersion[0] = 0;
|
|
33 LodDescription[0] = 0;
|
|
34 LODSize = 0;
|
|
35 dword_0000A8 = 0;
|
|
36 uNumIndices = 0;
|
0
|
37 }
|
|
38
|
|
39 char pSignature[4];
|
|
40 char LodVersion[80];
|
|
41 //char field_C[32];
|
|
42 //char field_2C[40];
|
|
43 char LodDescription[80];
|
|
44 int LODSize;
|
|
45 int dword_0000A8;
|
|
46 unsigned int uNumIndices;
|
|
47 char array_0000B0[28];
|
|
48 char array_0000CC[52];
|
|
49 };
|
|
50 #pragma pack(pop)
|
|
51
|
|
52
|
|
53 #pragma pack(push, 1)
|
|
54 struct Directory
|
|
55 {
|
|
56 Directory();
|
|
57
|
982
|
58 char pFilename[15];
|
|
59 char field_F;
|
0
|
60 unsigned int uOfsetFromSubindicesStart;
|
|
61 unsigned int uDataSize;
|
|
62 int dword_000018;
|
|
63 unsigned __int16 uNumSubIndices;
|
|
64 __int16 word_00001E;
|
|
65 };
|
|
66 #pragma pack(pop)
|
|
67
|
|
68
|
|
69 #pragma pack(push, 1)
|
|
70 struct File
|
|
71 {
|
|
72 File();
|
|
73 virtual ~File();
|
|
74 void *LoadRaw(const char *pContainer, int a3);
|
|
75 FILE *FindContainer(const char *pContainerName, bool bLinearSearch);
|
|
76 bool DoesContainerExist(const char *pContainer);
|
|
77 int CalcIndexFast(int startIndex, int maxIndex, const char *pContainerName);
|
|
78 bool LoadHeader(const char *pFilename, bool bWriting);
|
|
79 int LoadSubIndices(const char *pContainer);
|
|
80 void AllocSubIndicesAndIO(unsigned int uNumSubIndices, unsigned int uBufferSize);
|
|
81 void FreeSubIndexAndIO();
|
|
82 bool AppendDirectory(LOD::Directory *pDir, const void *pData);
|
|
83 void ResetSubIndices();
|
|
84 void Close();
|
|
85
|
|
86 FILE *pFile;
|
|
87 char pLODName[256];
|
|
88 unsigned int isFileOpened;
|
|
89 unsigned __int8 *pIOBuffer;
|
|
90 unsigned int uIOBufferSize;
|
|
91 struct FileHeader header;
|
|
92 struct Directory *pRoot;
|
|
93 char pContainerName[16];
|
|
94 unsigned int uCurrentIndexDir;
|
|
95 unsigned int uLODDataSize;
|
837
|
96 unsigned int uNumSubDirs;
|
0
|
97 struct Directory *pSubIndices;
|
|
98 unsigned int uOffsetToSubIndex;
|
|
99 FILE *pOutputFileHandle;
|
|
100 };
|
|
101 #pragma pack(pop)
|
|
102 };
|
|
103
|
|
104
|
|
105
|
|
106
|
|
107
|
|
108
|
|
109 /* 6 */
|
|
110 #pragma pack(push, 1)
|
|
111 struct LODWriteableFile: public LOD::File
|
|
112 {
|
|
113 bool LoadFile(const char *pFilename, bool bWriting);
|
|
114 unsigned int Write(const LOD::Directory *pDir, const void *pDirData, int a4);
|
|
115 void CloseWriteFile();
|
|
116 int CreateTempFile();
|
837
|
117 int FixDirectoryOffsets();
|
0
|
118 bool _4621A7();
|
837
|
119 int CreateNewLod(LOD::FileHeader *pHeader, LOD::Directory *pDir, const char *Source);
|
0
|
120
|
|
121 /*FILE *pFile;
|
|
122 char pLODName[256];
|
|
123 unsigned int isFileOpened;
|
|
124 unsigned __int8 *pIOBuffer;
|
|
125 unsigned int uIOBufferSize;
|
|
126 struct LOD::FileHeader header;
|
|
127 struct LOD::Directory *pRoot;
|
|
128 unsigned __int8 pContainerName[16];
|
|
129 unsigned int uCurrentIndexDir;
|
|
130 unsigned int uLODDataSize;
|
|
131 unsigned int uNumSubIndices;
|
|
132 struct LOD::Directory *pSubIndices;
|
|
133 unsigned int uOffsetToSubIndex;
|
|
134 FILE *pOutputFileHandle;*/
|
|
135 };
|
|
136 #pragma pack(pop)
|
|
137
|
|
138
|
|
139
|
|
140
|
|
141 #pragma pack(push, 1)
|
|
142 struct LODFile_IconsBitmaps: public LOD::File
|
|
143 {
|
|
144 LODFile_IconsBitmaps();
|
|
145 virtual ~LODFile_IconsBitmaps();
|
|
146 int _40F9C5();
|
|
147 unsigned int FindTextureByName(const char *pName);
|
|
148 bool LoadBitmaps(const char *pFilename);
|
|
149 bool LoadIconsOrEvents(const char *pLODFilename);
|
|
150 void ReleaseAll();
|
|
151 unsigned int LoadTexture(const char *pContainer, enum TEXTURE_TYPE uTextureType = TEXTURE_DEFAULT);
|
|
152 Texture *LoadTexturePtr(const char *pContainer, enum TEXTURE_TYPE uTextureType = TEXTURE_DEFAULT);
|
|
153 int LoadTextureFromLOD(Texture *pOutTex, const char *pContainer, enum TEXTURE_TYPE eTextureType);
|
|
154 int ReloadTexture(Texture *pDst, const char *pContainer, int mode);
|
|
155 void ReleaseHardwareTextures();
|
|
156 void ReleaseLostHardwareTextures();
|
|
157 void _410423_move_textures_to_device();
|
|
158 int _410522(Texture *pDst, const char *pContainer, unsigned int uTextureType);
|
|
159 void SetupPalettes(unsigned int uTargetRBits, unsigned int uTargetGBits, unsigned int uTargetBBits);
|
|
160 void ReleaseAll2();
|
|
161 void _4114F2();
|
|
162 void _4355F7();
|
762
|
163 void _inlined_sub0();
|
|
164 void _inlined_sub1();
|
|
165 void _inlined_sub2();
|
0
|
166
|
434
|
167 inline Texture *GetTexture(int idx)
|
|
168 {
|
|
169 assert(idx < 1000);
|
945
|
170 if (idx == -1) return nullptr; // we need to return dummy texture here
|
434
|
171 return pTextures + idx;
|
|
172 }
|
|
173
|
0
|
174
|
|
175 /*FILE *pFile;
|
|
176 unsigned __int8 pLODName[256];
|
|
177 unsigned int isFileOpened;
|
|
178 unsigned __int8 *pIOBuffer;
|
|
179 unsigned int uIOBufferSize;
|
|
180 struct LOD::FileHeader header;
|
|
181 struct LOD::Directory *pRoot;
|
|
182 unsigned __int8 pContainerName[16];
|
|
183 unsigned int uCurrentIndexDir;
|
|
184 unsigned int uLODDataSize;
|
|
185 unsigned int uNumSubIndices;
|
|
186 struct LOD::Directory *pSubIndices;
|
|
187 unsigned int uOffsetToSubIndex;
|
|
188 FILE *pOutputFileHandle;*/
|
|
189 struct Texture pTextures[1000];
|
|
190 unsigned int uNumLoadedFiles;
|
|
191 int dword_11B80;
|
|
192 int dword_11B84;
|
|
193 int dword_11B88;
|
|
194 int uTextureRedBits;
|
|
195 int uTextureGreenBits;
|
|
196 int uTextureBlueBits;
|
|
197 int uNumPrevLoadedFiles;
|
|
198 int uTexturePacksCount;
|
33
|
199 int pFacesLock;
|
0
|
200 int dword_011BA4;
|
|
201 int dword_011BA8;
|
|
202 struct IDirectDrawSurface **pHardwareSurfaces;
|
|
203 struct IDirect3DTexture2 **pHardwareTextures;
|
|
204 char *ptr_011BB4;
|
|
205 };
|
|
206 #pragma pack(pop)
|
|
207
|
|
208
|
|
209
|
|
210
|
|
211
|
|
212
|
|
213 #pragma pack(push, 1)
|
|
214 struct LODSprite
|
|
215 {
|
|
216 //----- (0046244C) --------------------------------------------------------
|
|
217 inline LODSprite()
|
|
218 {
|
|
219 uHeight = 0;
|
|
220 uPaletteId = 0;
|
|
221 word_1A = 0;
|
|
222 pSpriteLines = nullptr;
|
|
223 pDecompressedBytes = nullptr;
|
|
224 }
|
|
225 ~LODSprite();
|
|
226
|
|
227 void Release();
|
733
|
228 int DrawSprite_sw(struct RenderBillboardTransform_local0 *a2, char a3);
|
0
|
229 int _4AD2D1(struct RenderBillboardTransform_local0 *a2, int a3);
|
|
230
|
670
|
231 char pName[12]; //0
|
|
232 int uSpriteSize; //C
|
|
233 __int16 uWidth; //10
|
|
234 __int16 uHeight; //12
|
|
235 __int16 uPaletteId; //14
|
|
236 __int16 word_16; //16
|
|
237 __int16 uTexturePitch; //18
|
|
238 __int16 word_1A; //1a
|
|
239 int uDecompressedSize; //1c
|
|
240 struct LODSprite_stru0 *pSpriteLines; //20
|
|
241 void *pDecompressedBytes; //24
|
0
|
242 };
|
|
243 #pragma pack(pop)
|
|
244
|
|
245 /* 15 */
|
|
246 #pragma pack(push, 1)
|
|
247 struct LODFile_Sprites: public LOD::File
|
|
248 {
|
|
249 LODFile_Sprites();
|
|
250 virtual ~LODFile_Sprites();
|
|
251
|
|
252 void DeleteSomeSprites();
|
|
253 void DeleteSpritesRange(int uStartIndex, int uStopIndex);
|
|
254 int _461397();
|
|
255 void DeleteSomeOtherSprites();
|
|
256 int LoadSpriteFromFile(LODSprite *pSpriteHeader, const char *pContainer);
|
|
257 bool LoadSprites(const char *pFilename);
|
|
258 int LoadSprite(const char *pContainerName, unsigned int uPaletteID);
|
|
259 void ReleaseLostHardwareSprites();
|
|
260 void ReleaseAll();
|
|
261 void MoveSpritesToVideoMemory();
|
762
|
262 void _inlined_sub0();
|
|
263 void _inlined_sub1();
|
0
|
264
|
|
265
|
|
266 /*FILE *pFile;
|
|
267 unsigned __int8 pLODName[256];
|
|
268 unsigned int isFileOpened;
|
|
269 unsigned __int8 *pIOBuffer;
|
|
270 unsigned int uIOBufferSize;
|
|
271 struct LOD::FileHeader header;
|
|
272 struct LOD::Directory *pRoot;
|
|
273 unsigned __int8 pContainerName[16];
|
|
274 unsigned int uCurrentIndexDir;
|
|
275 unsigned int uLODDataSize;
|
|
276 unsigned int uNumSubIndices;
|
|
277 struct LOD::Directory *pSubIndices;
|
|
278 unsigned int uOffsetToSubIndex;
|
|
279 FILE *pOutputFileHandle;*/
|
|
280 struct LODSprite pSpriteHeaders[1500];
|
670
|
281 signed int uNumLoadedSprites;
|
0
|
282 int field_ECA0;
|
|
283 int field_ECA4;
|
|
284 int field_ECA8;
|
|
285 int field_ECAC;
|
|
286 struct Sprite *pHardwareSprites;
|
|
287 int field_ECB4;
|
|
288 };
|
|
289 #pragma pack(pop)
|
|
290
|
|
291 /* 17 */
|
|
292 #pragma pack(push, 1)
|
|
293 struct LODSprite_stru0
|
|
294 {
|
|
295 int dword_0;
|
|
296 void *ptr_4;
|
|
297 };
|
|
298 #pragma pack(pop)
|
|
299
|
|
300
|
|
301
|
|
302
|
|
303 extern LODFile_IconsBitmaps *pEvents_LOD;
|
|
304 extern LODFile_IconsBitmaps *pIcons_LOD;
|
|
305 extern LODFile_Sprites *pSprites_LOD;
|
|
306 extern LODFile_IconsBitmaps *pBitmaps_LOD;
|
|
307
|
|
308 extern LODWriteableFile *pNew_LOD;
|
|
309 extern LODWriteableFile *pGames_LOD;
|
|
310
|
|
311
|
|
312
|
|
313
|
|
314 extern int _6A0CA4_lod_binary_search; // weak
|
|
315 extern int _6A0CA8_lod_unused; // weak |