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