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