Mercurial > mm7
annotate LOD.h @ 2401:f794566045cd
Ticket #79 Game of (stat) incorrectly named
author | Grumpy7 |
---|---|
date | Thu, 10 Jul 2014 21:55:57 +0200 |
parents | e07e297f292d |
children | 5abd8fc8f1c6 |
rev | line source |
---|---|
0 | 1 #pragma once |
2 #include <stdio.h> | |
3 #include <memory.h> | |
2379
e07e297f292d
Implementing Grayface's mouse pick implementation/fix/workaround
Grumpy7
parents:
2337
diff
changeset
|
4 #include <cstdint> |
0 | 5 |
6 #include "Texture.h" | |
7 | |
1103 | 8 class Sprite; |
0 | 9 |
1632 | 10 |
11 #define MAX_LOD_TEXTURES 1000 | |
12 #define MAX_LOD_SPRITES 1500 | |
13 | |
0 | 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 { | |
982 | 27 //----- (004617B6) -------------------------------------------------------- |
0 | 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); | |
982 | 35 |
36 pSignature[0] = 0; | |
37 LodVersion[0] = 0; | |
38 LodDescription[0] = 0; | |
39 LODSize = 0; | |
40 dword_0000A8 = 0; | |
41 uNumIndices = 0; | |
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 | |
982 | 63 char pFilename[15]; |
64 char field_F; | |
0 | 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]; | |
2165 | 93 bool isFileOpened; |
0 | 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; | |
837 | 101 unsigned int uNumSubDirs; |
0 | 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(); | |
837 | 122 int FixDirectoryOffsets(); |
0 | 123 bool _4621A7(); |
837 | 124 int CreateNewLod(LOD::FileHeader *pHeader, LOD::Directory *pDir, const char *Source); |
0 | 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(); | |
1006 | 151 void SyncLoadedFilesCount(); |
0 | 152 unsigned int FindTextureByName(const char *pName); |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
153 bool Load(const char *pFilename, const char *pFolderName); |
0 | 154 void ReleaseAll(); |
155 unsigned int LoadTexture(const char *pContainer, enum TEXTURE_TYPE uTextureType = TEXTURE_DEFAULT); | |
1262 | 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); | |
0 | 159 void ReleaseHardwareTextures(); |
160 void ReleaseLostHardwareTextures(); | |
161 void _410423_move_textures_to_device(); | |
1262 | 162 int _410522(struct Texture *pDst, const char *pContainer, unsigned int uTextureType); |
0 | 163 void SetupPalettes(unsigned int uTargetRBits, unsigned int uTargetGBits, unsigned int uTargetBBits); |
164 void ReleaseAll2(); | |
1405
c0b273d33338
RemoveTexturesPackFromTextureList and RemoveTexturesFromTextureList
Ritor1
parents:
1404
diff
changeset
|
165 void RemoveTexturesPackFromTextureList(); |
c0b273d33338
RemoveTexturesPackFromTextureList and RemoveTexturesFromTextureList
Ritor1
parents:
1404
diff
changeset
|
166 void RemoveTexturesFromTextureList(); |
762 | 167 void _inlined_sub0(); |
168 void _inlined_sub1(); | |
169 void _inlined_sub2(); | |
0 | 170 |
1632 | 171 inline int LoadDummyTexture() |
434 | 172 { |
1632 | 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 | |
2336 | 179 Texture *GetTexture(int idx); |
434 | 180 |
0 | 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;*/ | |
1632 | 196 Texture pTextures[MAX_LOD_TEXTURES]; |
0 | 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; | |
33 | 206 int pFacesLock; |
0 | 207 int dword_011BA4; |
2154 | 208 //int can_load_hardware_sprites; |
0 | 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(); | |
733 | 235 int DrawSprite_sw(struct RenderBillboardTransform_local0 *a2, char a3); |
0 | 236 int _4AD2D1(struct RenderBillboardTransform_local0 *a2, int a3); |
237 | |
670 | 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 | |
0 | 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(); | |
762 | 269 void _inlined_sub0(); |
270 void _inlined_sub1(); | |
0 | 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;*/ | |
1632 | 287 struct LODSprite pSpriteHeaders[MAX_LOD_SPRITES]; |
670 | 288 signed int uNumLoadedSprites; |
0 | 289 int field_ECA0; |
290 int field_ECA4; | |
291 int field_ECA8; | |
2154 | 292 //int can_load_hardware_sprites; |
1103 | 293 Sprite *pHardwareSprites; |
0 | 294 int field_ECB4; |
295 }; | |
296 #pragma pack(pop) | |
297 | |
298 /* 17 */ | |
299 #pragma pack(push, 1) | |
300 struct LODSprite_stru0 | |
301 { | |
2379
e07e297f292d
Implementing Grayface's mouse pick implementation/fix/workaround
Grumpy7
parents:
2337
diff
changeset
|
302 int16_t a1; |
e07e297f292d
Implementing Grayface's mouse pick implementation/fix/workaround
Grumpy7
parents:
2337
diff
changeset
|
303 int16_t a2; |
e07e297f292d
Implementing Grayface's mouse pick implementation/fix/workaround
Grumpy7
parents:
2337
diff
changeset
|
304 char* pos; |
0 | 305 }; |
306 #pragma pack(pop) | |
307 | |
308 | |
309 | |
310 | |
311 extern LODFile_IconsBitmaps *pEvents_LOD; | |
1541 | 312 |
0 | 313 extern LODFile_IconsBitmaps *pIcons_LOD; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
314 extern LODFile_IconsBitmaps *pIcons_LOD_mm6; |
1541 | 315 extern LODFile_IconsBitmaps *pIcons_LOD_mm8; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
316 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
317 extern LODFile_IconsBitmaps *pBitmaps_LOD; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
318 extern LODFile_IconsBitmaps *pBitmaps_LOD_mm6; |
1541 | 319 extern LODFile_IconsBitmaps *pBitmaps_LOD_mm8; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
320 |
0 | 321 extern LODFile_Sprites *pSprites_LOD; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
322 extern LODFile_Sprites *pSprites_LOD_mm6; |
1541 | 323 extern LODFile_Sprites *pSprites_LOD_mm8; |
0 | 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 |