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