annotate Engine/LOD.cpp @ 2567:d569340b05ff

Few constants changed into enum values
author a.parshin
date Thu, 21 May 2015 01:50:59 +0200
parents a902abdfc7f2
children d87bfbd3bb3b
rev   line source
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1 #define _CRTDBG_MAP_ALLOC
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2 #include <stdlib.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
3 #include <crtdbg.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
5 #define _CRT_SECURE_NO_WARNINGS
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2524
diff changeset
6
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2524
diff changeset
7 #include "Engine/Engine.h"
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2524
diff changeset
8
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
9 #include "LOD.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
10 #include "Engine/Graphics/Render.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
11 #include "Engine/Graphics/Viewport.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
12 #include "ZlibWrapper.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
13
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
14 #include "Engine/Graphics/Sprites.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
15
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
16
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
17
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
18
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
19
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
20
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
21 LODFile_IconsBitmaps *pEvents_LOD = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
22
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
23 LODFile_IconsBitmaps *pIcons_LOD = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
24 LODFile_IconsBitmaps *pIcons_LOD_mm6 = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
25 LODFile_IconsBitmaps *pIcons_LOD_mm8 = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
26
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
27 LODFile_IconsBitmaps *pBitmaps_LOD = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
28 LODFile_IconsBitmaps *pBitmaps_LOD_mm6 = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
29 LODFile_IconsBitmaps *pBitmaps_LOD_mm8 = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
30
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
31 LODFile_Sprites *pSprites_LOD = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
32 LODFile_Sprites *pSprites_LOD_mm6 = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
33 LODFile_Sprites *pSprites_LOD_mm8 = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
34
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
35 LODWriteableFile *pNew_LOD = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
36 LODWriteableFile *pGames_LOD = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
37
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
38
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
39
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
40
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
41 int _6A0CA4_lod_binary_search; // weak
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
42 int _6A0CA8_lod_unused; // weak
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
43
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
44
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
45 // inlined
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
46 //----- (mm6c::00408860) --------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
47 void LODFile_IconsBitmaps::_inlined_sub2()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
48 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
49 ++uTexturePacksCount;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
50 if (!uNumPrevLoadedFiles)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
51 uNumPrevLoadedFiles = uNumLoadedFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
52 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
53
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
54 // inlined
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
55 //----- (mm6c::0045BE60) --------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
56 void LODFile_IconsBitmaps::_inlined_sub1()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
57 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
58 dword_11B84 = uNumLoadedFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
59 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
60
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
61 // inlined
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
62 //----- (mm6c::0045C310) --------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
63 void LODFile_Sprites::_inlined_sub1()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
64 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
65 field_ECA0 = uNumLoadedSprites;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
66 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
67
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
68 // inlined
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
69 //----- (mm6c::0045C5B0) --------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
70 void LODFile_IconsBitmaps::_inlined_sub0()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
71 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
72 dword_11B80 = uNumLoadedFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
73 if (dword_11B84 < uNumLoadedFiles)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
74 dword_11B84 = uNumLoadedFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
75 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
76
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
77
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
78 // inlined
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
79 //----- (mm6c::0045C660) --------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
80 void LODFile_Sprites::_inlined_sub0()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
81 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
82 field_ECA4 = uNumLoadedSprites;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
83 if (field_ECA0 < uNumLoadedSprites)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
84 field_ECA0 = uNumLoadedSprites;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
85 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
86
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
87 //----- (004355F7) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
88 void LODFile_IconsBitmaps::RemoveTexturesFromTextureList()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
89 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
90 if ( this->uTexturePacksCount )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
91 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
92 if ( (this->uNumLoadedFiles - 1) >= this->uNumPrevLoadedFiles )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
93 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
94 for ( uint i = this->uNumLoadedFiles - 1; i >= this->uNumPrevLoadedFiles; --i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
95 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
96 this->pTextures[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
97 if ( this->pHardwareTextures )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
98 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
99 if ( this->pHardwareTextures[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
100 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
101 this->pHardwareTextures[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
102 this->pHardwareTextures[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
103 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
104 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
105 if ( this->pHardwareSurfaces )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
106 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
107 if ( this->pHardwareSurfaces[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
108 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
109 this->pHardwareSurfaces[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
110 this->pHardwareSurfaces[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
111 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
112 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
113 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
114 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
115 this->uNumLoadedFiles = this->uNumPrevLoadedFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
116 this->uNumPrevLoadedFiles = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
117 this->uTexturePacksCount = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
118 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
119 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
120
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
121 //----- (004114F2) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
122 void LODFile_IconsBitmaps::RemoveTexturesPackFromTextureList()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
123 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
124 if ( this->uTexturePacksCount )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
125 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
126 this->uTexturePacksCount--;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
127 if ( !this->uTexturePacksCount )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
128 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
129 if ( (this->uNumLoadedFiles - 1) >= this->uNumPrevLoadedFiles )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
130 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
131 for ( uint i = this->uNumLoadedFiles - 1; i >= this->uNumPrevLoadedFiles; --i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
132 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
133 this->pTextures[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
134 if ( this->pHardwareTextures )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
135 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
136 if ( this->pHardwareTextures[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
137 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
138 this->pHardwareTextures[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
139 this->pHardwareTextures[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
140 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
141 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
142 if ( this->pHardwareSurfaces )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
143 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
144 if ( this->pHardwareSurfaces[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
145 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
146 this->pHardwareSurfaces[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
147 this->pHardwareSurfaces[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
148 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
149 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
150 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
151 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
152 this->uNumLoadedFiles = this->uNumPrevLoadedFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
153 this->uNumPrevLoadedFiles = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
154 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
155 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
156 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
157
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
158 //----- (004AC67E) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
159 int LODFile_Sprites::LoadSpriteFromFile(LODSprite *pSpriteHeader, const char *pContainer)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
160 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
161 FILE *File; // [sp+4h] [bp-4h]@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
162 void *DstBufa; // [sp+10h] [bp+8h]@4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
163 int Sizea; // [sp+14h] [bp+Ch]@3
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
164
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
165 File = FindContainer(pContainer, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
166 if ( File )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
167 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
168 fread(pSpriteHeader, 1, 0x20u, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
169 strcpy(pSpriteHeader->pName, pContainer);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
170 Sizea = pSpriteHeader->uSpriteSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
171 pSpriteHeader->pSpriteLines = (LODSprite_stru0 *)malloc(8 * pSpriteHeader->uHeight);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
172 fread(pSpriteHeader->pSpriteLines, 1, 8 * pSpriteHeader->uHeight, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
173
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
174 if ( pSpriteHeader->uDecompressedSize )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
175 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
176 pSpriteHeader->pDecompressedBytes = malloc(pSpriteHeader->uDecompressedSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
177 DstBufa = malloc(Sizea);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
178 fread(DstBufa, 1, Sizea, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
179 zlib::MemUnzip(pSpriteHeader->pDecompressedBytes, (unsigned int *)&pSpriteHeader->uDecompressedSize, DstBufa, pSpriteHeader->uSpriteSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
180 pSpriteHeader->uSpriteSize = pSpriteHeader->uDecompressedSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
181 free(DstBufa);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
182 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
183 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
184 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
185 pSpriteHeader->pDecompressedBytes = malloc(Sizea);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
186 fread(pSpriteHeader->pDecompressedBytes, 1, Sizea, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
187 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
188 for ( uint i = 0; i < pSpriteHeader->uHeight; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
189 pSpriteHeader->pSpriteLines[i].pos += (unsigned int)pSpriteHeader->pDecompressedBytes;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
190 return 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
191 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
192 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
193 return -1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
194 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
195
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
196 //----- (004AC795) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
197 bool LODFile_Sprites::LoadSprites(const char *pFilename)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
198 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
199 if (LoadHeader(pFilename, 1))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
200 return false;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
201 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
202 return LoadSubIndices("sprites08") == 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
203 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
204
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
205 //----- (004AC7C0) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
206 int LODFile_Sprites::LoadSprite(const char *pContainerName, unsigned int uPaletteID)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
207 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
208
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
209 FILE *sprite_file; // eax@12
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
210 LODSprite temp_sprite_hdr; // [sp+Ch] [bp-3Ch]@12
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
211 int i;//, sprite_indx;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
212
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
213 //find if already loaded
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
214 //if ( pRenderer->pRenderD3D )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
215 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
216 for (i=0; i<uNumLoadedSprites;++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
217 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
218 if (!(_stricmp(pHardwareSprites[i].pName, pContainerName)))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
219 return i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
220 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
221 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
222 /*else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
223 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
224 for (i=0; i<uNumLoadedSprites;++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
225 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
226 if (!(_stricmp(pSpriteHeaders[i].pName, pContainerName)))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
227 return i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
228 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
229 }*/
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
230
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
231 if (uNumLoadedSprites >= 1500 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
232 return -1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
233 //if not loaded - load from file
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
234
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
235 //if ( pRenderer->pRenderD3D && can_load_hardware_sprites )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
236 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
237 if ( !pHardwareSprites )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
238 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
239 pHardwareSprites = (Sprite *)malloc(1500*sizeof(Sprite));//0xEA60u
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
240 for (i=0; i<1500;++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
241 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
242 pHardwareSprites[i].pName=nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
243 pHardwareSprites[i].pTextureSurface=nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
244 pHardwareSprites[i].pTexture=nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
245 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
246 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
247 temp_sprite_hdr.uHeight = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
248 temp_sprite_hdr.uPaletteId = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
249 temp_sprite_hdr.word_1A = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
250 temp_sprite_hdr.pSpriteLines = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
251 temp_sprite_hdr.pDecompressedBytes = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
252 sprite_file = FindContainer(pContainerName, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
253 if ( !sprite_file )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
254 return -1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
255 //fread(&temp_sprite_hdr, 1, sizeof(LODSprite), sprite_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
256 fread(&temp_sprite_hdr, 1, 0x20, sprite_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
257 pHardwareSprites[uNumLoadedSprites].uBufferWidth = temp_sprite_hdr.uWidth;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
258 pHardwareSprites[uNumLoadedSprites].uBufferHeight = temp_sprite_hdr.uHeight;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
259 pSpriteHeaders[uNumLoadedSprites].uWidth = temp_sprite_hdr.uWidth;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
260 pSpriteHeaders[uNumLoadedSprites].uHeight = temp_sprite_hdr.uHeight;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
261 LoadSpriteFromFile( &pSpriteHeaders[uNumLoadedSprites], pContainerName); //this line is not present here in the original. necessary for Grayface's mouse picking fix
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
262 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
263 /*else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
264 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
265 sprite_indx = LoadSpriteFromFile( &pSpriteHeaders[uNumLoadedSprites], pContainerName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
266 pSpriteHeaders[uNumLoadedSprites].word_1A = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
267
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
268 if ( sprite_indx != -1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
269 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
270 pSpriteHeaders[uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
271 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
272 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
273 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
274 if ( uNumLoadedSprites<=0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
275 uNumLoadedSprites=0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
276 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
277 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
278 for (i=0; i<uNumLoadedSprites;++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
279 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
280 if (!(_stricmp(pSpriteHeaders[i].pName, "pending")))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
281 return i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
282 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
283 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
284 if ( LoadSpriteFromFile(&pSpriteHeaders[uNumLoadedSprites], "pending") == -1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
285 return -1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
286 pSpriteHeaders[uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
287 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
288 }*/
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
289
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
290 //if ( pRenderer->pRenderD3D )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
291 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
292 pHardwareSprites[uNumLoadedSprites].pName = (const char *)malloc(20);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
293 strcpy((char *)pHardwareSprites[uNumLoadedSprites].pName, pContainerName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
294 pHardwareSprites[uNumLoadedSprites].uPaletteID = uPaletteID;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
295 pRenderer->MoveSpriteToDevice(&pHardwareSprites[uNumLoadedSprites]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
296 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
297 ++uNumLoadedSprites;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
298 return uNumLoadedSprites - 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
299
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
300 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
301
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
302 //----- (004ACADA) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
303 void LODFile_Sprites::ReleaseLostHardwareSprites()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
304 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
305 signed int v2; // ebx@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
306 int v3; // edi@3
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
307 IDirectDrawSurface *v4; // eax@4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
308 IDirect3DTexture2 *v5; // eax@6
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
309 IDirectDrawSurface *v6; // ST00_4@8
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
310
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
311 if ( this->pHardwareSprites )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
312 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
313 v2 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
314 if ( (signed int)this->uNumLoadedSprites > 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
315 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
316 v3 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
317 do
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
318 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
319 v4 = (IDirectDrawSurface *)this->pHardwareSprites[v3].pTextureSurface;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
320 if ( v4 && v4->IsLost() == DDERR_SURFACELOST )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
321 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
322 v5 = this->pHardwareSprites[v3].pTexture;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
323 if ( v5 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
324 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
325 v5->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
326 this->pHardwareSprites[v3].pTexture = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
327 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
328 v6 = (IDirectDrawSurface *)this->pHardwareSprites[v3].pTextureSurface;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
329 v6->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
330 this->pHardwareSprites[v3].pTextureSurface = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
331 pRenderer->MoveSpriteToDevice(&this->pHardwareSprites[v3]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
332 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
333 ++v2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
334 ++v3;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
335 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
336 while ( v2 < (signed int)this->uNumLoadedSprites );
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
337 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
338 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
339 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
340
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
341 //----- (004ACB70) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
342 void LODFile_Sprites::ReleaseAll()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
343 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
344 if ( this->pHardwareSprites )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
345 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
346 for ( int i = 0; i < this->uNumLoadedSprites; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
347 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
348 if ( this->pHardwareSprites )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
349 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
350 if ( this->pHardwareSprites[i].pTexture )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
351 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
352 this->pHardwareSprites[i].pTexture->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
353 this->pHardwareSprites[i].pTexture = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
354 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
355 if ( this->pHardwareSprites )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
356 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
357 if ( this->pHardwareSprites[i].pTextureSurface )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
358 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
359 this->pHardwareSprites[i].pTextureSurface->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
360 this->pHardwareSprites[i].pTextureSurface = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
361 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
362 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
363 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
364 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
365 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
366 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
367
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
368 //----- (004ACBE0) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
369 void LODFile_Sprites::MoveSpritesToVideoMemory()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
370 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
371 if ( this->pHardwareSprites )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
372 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
373 for ( int i = 0; i < this->uNumLoadedSprites; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
374 pRenderer->MoveSpriteToDevice(&this->pHardwareSprites[i]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
375 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
376 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
377
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
378 //----- (004ACC38) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
379 int LODSprite::DrawSprite_sw(RenderBillboardTransform_local0 *a2, char a3)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
380 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
381 RenderBillboardTransform_local0 *v3; // edi@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
382 int result; // eax@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
383 int v5; // esi@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
384 int v6; // ST18_4@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
385 //signed int v7; // eax@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
386 signed int v8; // ebx@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
387 int v9; // ebx@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
388 int *v10; // ecx@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
389 int v11; // esi@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
390 unsigned int v12; // edx@4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
391 int v13; // esi@13
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
392 int v14; // esi@17
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
393 int v15; // ecx@17
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
394 char *v16; // edx@17
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
395 int v17; // esi@17
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
396 int v18; // ecx@18
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
397 int v19; // esi@18
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
398 LODSprite_stru0 *v20; // edx@21
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
399 int v21; // eax@22
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
400 int v22; // esi@22
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
401 int v23; // eax@25
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
402 int v24; // ecx@25
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
403 signed __int64 v25; // qtt@27
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
404 int v26; // eax@27
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
405 unsigned __int16 *v27; // eax@29
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
406 LODSprite_stru0 *v28; // edx@29
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
407 signed int v29; // ecx@30
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
408 int v30; // ecx@37
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
409 int v31; // ecx@38
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
410 signed int v32; // ecx@41
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
411 int v33; // ecx@47
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
412 int v34; // ecx@56
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
413 int v35; // esi@58
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
414 __int16 v36; // ax@58
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
415 int v37; // ecx@59
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
416 int v38; // eax@59
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
417 int v39; // ecx@62
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
418 signed int v40; // ST30_4@64
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
419 signed __int64 v41; // qtt@64
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
420 int v42; // ecx@64
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
421 unsigned __int16 *v43; // eax@66
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
422 LODSprite_stru0 *v44; // ecx@66
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
423 int v45; // edx@69
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
424 int v46; // edx@77
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
425 //unsigned __int16 *pTarget; // [sp+Ch] [bp-50h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
426 signed int v48; // [sp+10h] [bp-4Ch]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
427 signed int v49; // [sp+14h] [bp-48h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
428 int v50; // [sp+14h] [bp-48h]@19
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
429 int v51; // [sp+14h] [bp-48h]@57
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
430 int v52; // [sp+18h] [bp-44h]@13
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
431 int v53; // [sp+1Ch] [bp-40h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
432 int v54; // [sp+1Ch] [bp-40h]@22
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
433 int v55; // [sp+1Ch] [bp-40h]@32
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
434 int v56; // [sp+1Ch] [bp-40h]@69
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
435 int v57; // [sp+20h] [bp-3Ch]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
436 int v58; // [sp+24h] [bp-38h]@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
437 int v59; // [sp+28h] [bp-34h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
438 int v60; // [sp+28h] [bp-34h]@13
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
439 unsigned __int16 *v61; // [sp+2Ch] [bp-30h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
440 int v62; // [sp+30h] [bp-2Ch]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
441 void *v63; // [sp+30h] [bp-2Ch]@29
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
442 void *v64; // [sp+30h] [bp-2Ch]@66
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
443 int v65; // [sp+34h] [bp-28h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
444 int v66; // [sp+34h] [bp-28h]@22
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
445 int v67; // [sp+34h] [bp-28h]@59
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
446 int v68; // [sp+38h] [bp-24h]@13
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
447 unsigned int v69; // [sp+3Ch] [bp-20h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
448 int v70; // [sp+40h] [bp-1Ch]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
449 signed int v71; // [sp+40h] [bp-1Ch]@15
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
450 int v72; // [sp+44h] [bp-18h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
451 unsigned __int16 *v73; // [sp+44h] [bp-18h]@29
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
452 unsigned __int16 *v74; // [sp+44h] [bp-18h]@66
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
453 int v75; // [sp+48h] [bp-14h]@4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
454 int v76; // [sp+48h] [bp-14h]@22
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
455 int v77; // [sp+48h] [bp-14h]@59
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
456 //LODSprite *v78; // [sp+4Ch] [bp-10h]@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
457 int v79; // [sp+50h] [bp-Ch]@4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
458 int v80; // [sp+50h] [bp-Ch]@21
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
459 int v81; // [sp+50h] [bp-Ch]@62
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
460 int v82; // [sp+50h] [bp-Ch]@67
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
461 int v83; // [sp+50h] [bp-Ch]@75
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
462 int *pTargetZ; // [sp+54h] [bp-8h]@4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
463 int v85; // [sp+58h] [bp-4h]@18
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
464 int v86; // [sp+58h] [bp-4h]@56
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
465 signed int v87; // [sp+64h] [bp+8h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
466 int v88; // [sp+68h] [bp+Ch]@18
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
467 int v89; // [sp+68h] [bp+Ch]@56
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
468
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
469 v3 = a2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
470 //v78 = this;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
471 result = a2->_screenspace_x_scaler_packedfloat;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
472 v58 = a2->_screenspace_x_scaler_packedfloat;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
473 if ( result <= 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
474 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
475 v5 = a2->_screenspace_y_scaler_packedfloat;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
476 v6 = a2->_screenspace_x_scaler_packedfloat;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
477 v87 = (signed __int64)0x100000000ui64 / result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
478 v48 = (signed __int64)0x100000000ui64 / result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
479 v62 = (signed __int64)0x100000000ui64 / v5;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
480 //v7 = this->uHeight;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
481 v8 = (signed int)((signed __int64)0x100000000ui64 / v5) >> 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
482 v53 = v8;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
483 v70 = (this->uHeight << 16) - v8;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
484 v49 = this->uHeight;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
485 v69 = v3->uTargetPitch;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
486
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
487 __debugbreak(); // target surface will most likely be 32bit, but this sub awaits 16bits
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
488 auto pTarget = (unsigned __int16 *)v3->pTarget;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
489 v57 = v3->sZValue;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
490 v61 = v3->pPalette;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
491 v9 = (v6 * this->uWidth + 0x8000) >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
492 v72 = v3->uScreenSpaceY;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
493 result = (v5 * this->uHeight + 0x8000) >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
494 v10 = (int *)(v72 - result + 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
495 v11 = v3->uScreenSpaceX - (v9 >> 1) + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
496 v65 = v72 - result + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
497 v59 = v11 + v9 - 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
498 if ( v3->uFlags & 0x800 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
499 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
500 v10 = (int *)((char *)v10 + (v49 >> 1));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
501 v72 += v49 >> 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
502 v65 = (int)v10;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
503 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
504 v12 = v72;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
505 pTargetZ = v10;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
506 v75 = v3->uScreenSpaceX - (v9 >> 1) + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
507 v79 = v11 + v9 - 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
508 if ( !(v3->uFlags & 8) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
509 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
510 if ( v65 < (signed int)v3->uViewportY )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
511 pTargetZ = (int *)v3->uViewportY;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
512 if ( v72 > (signed int)v3->uViewportW )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
513 v12 = v3->uViewportW;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
514 if ( v11 < (signed int)v3->uViewportX )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
515 v75 = v3->uViewportX;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
516 if ( v59 > (signed int)v3->uViewportZ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
517 v79 = v3->uViewportZ;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
518 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
519 v68 = v75 - v11;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
520 v13 = -v62;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
521 v60 = v59 - v79;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
522 v52 = -v62;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
523 if ( v3->uFlags & 1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
524 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
525 v13 = v62;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
526 v70 = v53;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
527 v52 = v62;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
528 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
529 v71 = v13 * (v72 - v12) + v70;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
530 if ( LOBYTE(viewparams->field_20) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
531 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
532 if ( a3 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
533 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
534 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
535 v14 = 5 * v12;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
536 v15 = v69 * v12;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
537 result = v12 - v72 + result - 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
538 v16 = (char *)pTargetZ - v65;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
539 v17 = v14 << 7;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
540 if ( v3->uFlags & 4 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
541 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
542 v34 = v79 + v15;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
543 v89 = v34;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
544 v86 = v79 + v17;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
545 if ( result < (signed int)v16 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
546 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
547 v51 = result - (int)v16 + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
548 while ( 1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
549 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
550 v35 = v71 >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
551 v36 = this->pSpriteLines[v35].a1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
552 if ( v36 == -1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
553 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
554 v34 -= v69;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
555 v89 = v34;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
556 goto LABEL_84;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
557 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
558 v37 = v9 - ((unsigned __int64)(v36 * (signed __int64)v58) >> 16);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
559 v67 = v87 * ((unsigned __int64)(this->pSpriteLines[v35].a2 * (signed __int64)v58) >> 16);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
560 v38 = v9 - v60;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
561 v77 = v9 - v60;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
562 if ( v9 - v60 <= (signed int)(v9 - ((unsigned __int64)(this->pSpriteLines[v35].a2 * (signed __int64)v58) >> 16))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
563 || v68 >= v37 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
564 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
565 v89 -= v69;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
566 v34 = v89;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
567 LABEL_84:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
568 v86 -= window->GetWidth();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
569 goto LABEL_85;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
570 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
571 if ( v38 < v37 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
572 v81 = (v87 >> 1) + v87 * (v37 - v38);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
573 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
574 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
575 v77 = v37;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
576 v81 = v87 >> 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
577 v39 = v37 - v9;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
578 v89 += v39 + v60;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
579 v86 += v60 + v39;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
580 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
581 v40 = ((this->pSpriteLines[v35].a2 + 1) << 16) - v81 - v67;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
582 LODWORD(v41) = v40 << 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
583 HIDWORD(v41) = v40 >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
584 v42 = v77 - (((signed int)((unsigned __int64)(v41 / v48) - 0x8000) >> 16) + 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
585 if ( v68 >= v42 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
586 v42 = v68;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
587 v43 = &pTarget[v89];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
588 v74 = &v43[v42 - v77 + 1];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
589 v44 = &this->pSpriteLines[v35];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
590 v64 = v44->pos;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
591 if ( !v57 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
592 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
593 v83 = v67 + v81;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
594 if ( ((v83 - (v44->a1 << 16)) & 0xFFFF0000) < 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
595 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
596 v83 += v87;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
597 --v43;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
598 --pTargetZ;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
599 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
600 while ( v43 >= v74 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
601 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
602 v46 = (v83 - ((signed int)this->pSpriteLines[v35].a1 << 16)) >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
603 if ( *((char *)v64 + v46) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
604 *v43 = v61[*((char *)v64 + v46)];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
605 v83 += v87;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
606 --v43;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
607 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
608 goto LABEL_81;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
609 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
610 pTargetZ = &v3->pTargetZ[v86];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
611 v82 = v67 + v81;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
612 if ( ((v82 - (v44->a1 << 16)) & 0xFFFF0000) < 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
613 goto LABEL_72;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
614 LABEL_73:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
615 if ( v43 >= v74 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
616 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
617 LABEL_81:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
618 v89 += v9 - v77 - v60 - v69;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
619 v34 = v89;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
620 v86 = v86 + v9 - v77 - v60 - window->GetWidth();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
621 LABEL_85:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
622 result = v52;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
623 v71 += v52;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
624 --v51;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
625 if ( !v51 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
626 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
627 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
628 v45 = (v82 - ((signed int)this->pSpriteLines[v35].a1 << 16)) >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
629 v56 = *((char *)v64 + v45);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
630 if ( *((char *)v64 + v45) && v57 <= (unsigned int)*pTargetZ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
631 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
632 *pTargetZ = v57;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
633 *v43 = v61[v56];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
634 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
635 LABEL_72:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
636 v82 += v87;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
637 --v43;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
638 --pTargetZ;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
639 goto LABEL_73;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
640 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
641 v18 = v75 + v15;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
642 v19 = v75 + v17;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
643 v88 = v18;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
644 v85 = v19;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
645 if ( result >= (signed int)v16 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
646 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
647 v50 = result - (int)v16 + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
648 while ( 1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
649 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
650 v20 = &this->pSpriteLines[v71 >> 16];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
651 v80 = v71 >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
652 if ( v20->a1 != -1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
653 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
654 v18 -= v69;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
655 v85 = v19 - window->GetWidth();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
656 v88 = v18;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
657 LABEL_54:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
658 result = v52;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
659 v71 += v52;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
660 --v50;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
661 if ( !v50 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
662 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
663 v19 = v85;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
664 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
665 v21 = (v58 * v20->a1 + 32768) >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
666 v66 = v21 * v87;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
667 v76 = v68;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
668 v54 = v20->a2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
669 v22 = v9 - v60;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
670 if ( v68 >= (v58 * v54 + 32768) >> 16 || v22 <= v21 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
671 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
672 v88 -= v69;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
673 v85 -= window->GetWidth();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
674 goto LABEL_51;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
675 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
676 if ( v68 > v21 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
677 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
678 v24 = (v87 >> 1) + v87 * (v68 - v21);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
679 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
680 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
681 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
682 v76 = (v58 * v20->a1 + 0x8000) >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
683 v23 = v21 - v68;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
684 v88 += v23;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
685 v24 = v87 >> 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
686 v85 += v23;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
687 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
688 LODWORD(v25) = (((v54 + 1) << 16) - v24 - v66) << 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
689 HIDWORD(v25) = (((v54 + 1) << 16) - v24 - v66) >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
690 v26 = v76 + ((signed int)(v25 / v48) >> 16) + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
691 if ( v22 > v26 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
692 v22 = v26;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
693 v27 = &pTarget[v88];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
694 v73 = &v27[v22 - v76 - 1];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
695 v28 = &this->pSpriteLines[v80];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
696 v63 = v28->pos;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
697 if ( v57 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
698 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
699 pTargetZ = &v3->pTargetZ[v85];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
700 v29 = v66 - (v28->a1 << 16) + v24;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
701 if ( (v29 & 0xFFFF0000) >= 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
702 goto LABEL_36;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
703 while ( 1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
704 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
705 v29 += v87;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
706 ++v27;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
707 ++pTargetZ;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
708 LABEL_36:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
709 if ( v27 >= v73 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
710 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
711 v55 = *((char *)v63 + (v29 >> 16));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
712 if ( *((char *)v63 + (v29 >> 16)) && v57 <= (unsigned int)*pTargetZ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
713 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
714 *pTargetZ = v57;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
715 *v27 = v61[v55];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
716 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
717 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
718 v30 = v29 >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
719 if ( v30 > this->pSpriteLines[v80].a2 - (signed int)this->pSpriteLines[v80].a1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
720 || (v31 = *((char *)v63 + v30)) == 0
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
721 || v57 > (unsigned int)*pTargetZ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
722 goto LABEL_50;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
723 *pTargetZ = v57;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
724 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
725 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
726 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
727 v32 = v66 - (v28->a1 << 16) + v24;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
728 if ( (v32 & 0xFFFF0000) < 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
729 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
730 v32 += v87;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
731 ++v27;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
732 ++pTargetZ;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
733 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
734 while ( v27 < v73 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
735 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
736 if ( *((char *)v63 + (v32 >> 16)) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
737 *v27 = v61[*((char *)v63 + (v32 >> 16))];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
738 v32 += v87;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
739 ++v27;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
740 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
741 v33 = v32 >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
742 if ( v33 > this->pSpriteLines[v80].a2 - (signed int)this->pSpriteLines[v80].a1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
743 || (v31 = *((char *)v63 + v33)) == 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
744 goto LABEL_50;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
745 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
746 *v27 = v61[v31];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
747 LABEL_50:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
748 v88 += v68 - v76 - v69;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
749 v85 = v85 + v68 - v76 - window->GetWidth();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
750 LABEL_51:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
751 v18 = v88;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
752 goto LABEL_54;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
753 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
754 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
755 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
756
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
757 //----- (004AD2D1) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
758 int LODSprite::_4AD2D1(struct RenderBillboardTransform_local0 *a2, int a3)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
759 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
760 int result; // eax@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
761 unsigned int v4; // esi@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
762 int v5; // edi@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
763 LODSprite_stru0 *v6; // edx@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
764 __int16 v7; // bx@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
765 int v8; // ecx@3
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
766 unsigned __int16 *v9; // esi@3
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
767 int v10; // ebx@3
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
768 void *v11; // edx@3
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
769 unsigned __int16 *v12; // ecx@3
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
770 int v13; // ebx@4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
771 //LODSprite *v14; // [sp+8h] [bp-10h]@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
772 unsigned __int16 *v15; // [sp+10h] [bp-8h]@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
773 unsigned __int16 *v16; // [sp+14h] [bp-4h]@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
774 int i; // [sp+20h] [bp+8h]@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
775
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
776 result = (int)a2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
777 v4 = a2->uTargetPitch;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
778
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
779 __debugbreak(); // sub expects 16bit target surface, we may have 32bit
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
780 v16 = (unsigned short *)a2->pTarget;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
781 v15 = a2->pPalette;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
782 v5 = this->uHeight - 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
783 for ( i = v4 * a2->uScreenSpaceY - (this->uWidth >> 1) + a2->uScreenSpaceX + 1; v5 >= 0; --v5 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
784 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
785 v6 = &this->pSpriteLines[v5];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
786 v7 = this->pSpriteLines[v5].a1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
787 if ( this->pSpriteLines[v5].a1 != -1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
788 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
789 v8 = v7;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
790 v9 = &v16[v7 + i];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
791 v10 = v6->a2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
792 v11 = v6->pos;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
793 v12 = &v9[v10 - v8];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
794 while ( v9 <= v12 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
795 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
796 v13 = *(char *)v11;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
797 v11 = (char *)v11 + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
798 if ( v13 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
799 *v9 = v15[v13];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
800 ++v9;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
801 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
802 v4 = *(int *)(result + 48);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
803 //this = v14;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
804 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
805 i -= v4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
806 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
807 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
808 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
809
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
810 //----- (0046454B) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
811 void LODFile_IconsBitmaps::ReleaseAll2()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
812 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
813 for ( uint i = (uint)this->dword_11B84; i < this->uNumLoadedFiles; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
814 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
815 this->pTextures[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
816 if ( this->pHardwareTextures )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
817 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
818 if ( this->pHardwareTextures[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
819 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
820 this->pHardwareTextures[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
821 this->pHardwareTextures[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
822 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
823 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
824 if ( this->pHardwareSurfaces )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
825 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
826 if ( this->pHardwareSurfaces[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
827 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
828 this->pHardwareSurfaces[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
829 this->pHardwareSurfaces[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
830 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
831 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
832 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
833 this->uTexturePacksCount = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
834 this->uNumPrevLoadedFiles = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
835 this->uNumLoadedFiles = this->dword_11B84;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
836 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
837
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
838 //----- (004645DC) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
839 void LODFile_Sprites::DeleteSomeOtherSprites()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
840 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
841 int *v1; // esi@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
842 int *v2; // edi@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
843
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
844 v1 = (int *)&this->uNumLoadedSprites;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
845 v2 = &this->field_ECA0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
846 DeleteSpritesRange(field_ECA0, uNumLoadedSprites);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
847 *v1 = *v2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
848 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
849
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
850 //----- (00461431) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
851 void LOD::File::Close()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
852 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
853 if (isFileOpened )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
854 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
855 this->pContainerName[0] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
856 this->uCurrentIndexDir = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
857 free(pSubIndices);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
858 free(pRoot);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
859 pSubIndices = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
860 pRoot = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
861 fclose(pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
862 isFileOpened = false;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
863 _6A0CA8_lod_unused = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
864 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
865 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
866
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
867 //----- (00461492) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
868 int LODWriteableFile::CreateNewLod(LOD::FileHeader *pHeader, LOD::Directory *pDir, const char *lod_name)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
869 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
870 if (isFileOpened)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
871 return 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
872 if ( !pDir->pFilename[0] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
873 return 2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
874 strcpy(pHeader->pSignature, "LOD");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
875 pHeader->LODSize = 100;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
876 pHeader->uNumIndices = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
877 pDir->field_F = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
878 pDir->uDataSize = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
879 pDir->uOfsetFromSubindicesStart = 288;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
880 strcpy(pLODName, lod_name);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
881
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
882 pFile = fopen(pLODName, "wb+");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
883 if (!pFile)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
884 return 3;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
885 fwrite(pHeader,sizeof(LOD::FileHeader), 1, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
886 fwrite(pDir, sizeof(LOD::Directory), 1, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
887 fclose(pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
888 pFile = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
889 return 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
890 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
891
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
892 //----- (0046153F) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
893 void LOD::File::ResetSubIndices()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
894 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
895 if ( isFileOpened )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
896 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
897 pContainerName[0] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
898 uCurrentIndexDir = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
899 uOffsetToSubIndex = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
900 uNumSubDirs = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
901 uLODDataSize = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
902 free(pSubIndices);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
903 pSubIndices = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
904 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
905 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
906
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
907 //----- (00450C8B) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
908 void LODFile_Sprites::DeleteSomeSprites()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
909 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
910 int *v1; // esi@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
911 int *v2; // edi@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
912
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
913 v1 = (int *)&this->uNumLoadedSprites;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
914 v2 = &this->field_ECA8;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
915 DeleteSpritesRange(this->field_ECA8, this->uNumLoadedSprites);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
916 *v1 = *v2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
917 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
918
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
919 //----- (00450CA9) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
920 void LODFile_Sprites::DeleteSpritesRange(int uStartIndex, int uStopIndex)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
921 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
922 if ( this->pHardwareSprites )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
923 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
924 if ( uStartIndex < uStopIndex )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
925 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
926 for ( int i = uStartIndex; i < uStopIndex; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
927 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
928 this->pSpriteHeaders[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
929 pHardwareSprites[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
930 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
931 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
932 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
933 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
934 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
935 if ( uStartIndex < uStopIndex )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
936 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
937 for ( int i = uStartIndex; i < uStopIndex; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
938 this->pSpriteHeaders[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
939 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
940 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
941 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
942
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
943 //----- (00450D1D) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
944 void LODSprite::Release()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
945 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
946 if ( !(HIBYTE(this->word_1A) & 4) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
947 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
948 free(this->pDecompressedBytes);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
949 free(this->pSpriteLines);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
950 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
951 this->word_1A = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
952 this->pDecompressedBytes = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
953 this->pSpriteLines = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
954 this->pName[0] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
955 this->word_16 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
956 this->uPaletteId = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
957 this->uTexturePitch = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
958 this->uHeight = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
959 this->uWidth = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
960 this->uSpriteSize = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
961 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
962
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
963 //----- (00450D68) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
964 void Sprite::Release()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
965 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
966 free((void *)pName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
967 pName = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
968
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
969 if (pTextureSurface)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
970 pTextureSurface->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
971 pTextureSurface = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
972
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
973 if (pTexture)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
974 pTexture->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
975 pTexture = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
976 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
977
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
978 //----- (0040FAEE) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
979 //----- (0040FA2E) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
980 bool LODFile_IconsBitmaps::Load(const char *pLODFilename, const char *pFolderName)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
981 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
982 ReleaseAll();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
983
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
984 if (LoadHeader(pLODFilename, 1))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
985 return false;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
986
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
987 return LoadSubIndices(pFolderName) == 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
988 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
989
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
990 //----- (0040FA60) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
991 void LODFile_IconsBitmaps::ReleaseAll()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
992 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
993 for( uint i = 0; i < this->uNumLoadedFiles; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
994 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
995 this->pTextures[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
996 if ( this->pHardwareTextures )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
997 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
998 if ( this->pHardwareTextures[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
999 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1000 this->pHardwareTextures[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1001 this->pHardwareTextures[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1002 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1003 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1004 if ( this->pHardwareSurfaces )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1005 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1006 if ( this->pHardwareSurfaces[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1007 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1008 this->pHardwareSurfaces[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1009 this->pHardwareSurfaces[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1010 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1011 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1012 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1013 this->uTexturePacksCount = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1014 this->uNumPrevLoadedFiles = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1015 this->dword_11B84 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1016 this->dword_11B80 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1017 this->uNumLoadedFiles = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1018 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1019
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1020 //----- (0040F9F0) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1021 unsigned int LODFile_IconsBitmaps::FindTextureByName(const char *pName)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1022 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1023 for ( uint i = 0; i < this->uNumLoadedFiles; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1024 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1025 if ( !_stricmp(this->pTextures[i].pName, pName) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1026 return i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1027 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1028 return -1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1029 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1030
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1031 //----- (0040F9C5) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1032 void LODFile_IconsBitmaps::SyncLoadedFilesCount()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1033 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1034 signed int loaded_files; // eax@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1035 Texture *pTex; // edx@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1036
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1037 loaded_files = this->uNumLoadedFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1038 for ( pTex = &this->pTextures[loaded_files]; !pTex->pName[0]; --pTex )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1039 --loaded_files;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1040 if ( loaded_files < (signed int)this->uNumLoadedFiles )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1041 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1042 ++loaded_files;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1043 this->uNumLoadedFiles = loaded_files;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1044 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1045
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1046 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1047
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1048 //----- (0046249B) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1049 LODFile_Sprites::~LODFile_Sprites()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1050 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1051 if ( this->pHardwareSprites )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1052 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1053 for ( int i = 0; i < this->uNumLoadedSprites; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1054 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1055 this->pSpriteHeaders[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1056 this->pHardwareSprites[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1057 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1058 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1059 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1060 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1061 for ( int i = 0; i < this->uNumLoadedSprites; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1062 this->pSpriteHeaders[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1063 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1064 //_eh_vector_destructor_iterator_(v1->pSpriteHeaders, 40, 1500, LODSprite::dtor);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1065 //LOD::File::vdtor((LOD::File *)v1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1066 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1067 // 4CC2B4: using guessed type int __stdcall _eh vector destructor iterator_(int, int, int, int);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1068
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1069 //----- (00462463) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1070 LODSprite::~LODSprite()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1071 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1072 if ( !(HIBYTE(this->word_1A) & 4) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1073 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1074 free(pDecompressedBytes);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1075 free(pSpriteLines);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1076 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1077 pDecompressedBytes = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1078 pSpriteLines = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1079 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1080
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1081 //----- (004623E5) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1082 LODFile_Sprites::LODFile_Sprites():
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1083 LOD::File()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1084 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1085 /*_eh_vector_constructor_iterator_(
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1086 v1->pSpriteHeaders,
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1087 40,
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1088 1500,
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1089 (void ( *)(void *))LODSprite::LODSprite,
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1090 (void ( *)(void *))LODSprite::dtor);*/
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1091 field_ECA4 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1092 field_ECA0 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1093 pHardwareSprites = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1094 //can_load_hardware_sprites = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1095 field_ECB4 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1096 uNumLoadedSprites = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1097 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1098
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1099 //----- (00462303) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1100 LODFile_IconsBitmaps::~LODFile_IconsBitmaps()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1101 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1102
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1103 for ( uint i = 0; i < this->uNumLoadedFiles; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1104 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1105 this->pTextures[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1106 if ( this->pHardwareTextures )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1107 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1108 if ( this->pHardwareTextures[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1109 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1110 this->pHardwareTextures[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1111 this->pHardwareTextures[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1112 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1113 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1114 if ( this->pHardwareSurfaces )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1115 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1116 if ( this->pHardwareSurfaces[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1117 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1118 this->pHardwareSurfaces[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1119 this->pHardwareSurfaces[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1120 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1121 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1122 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1123 free(this->pHardwareSurfaces);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1124 free(this->pHardwareTextures);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1125 free(this->ptr_011BB4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1126 //LOD::File::vdtor((LOD::File *)v1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1127 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1128
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1129 //----- (00462272) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1130 LODFile_IconsBitmaps::LODFile_IconsBitmaps():
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1131 LOD::File()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1132 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1133 /*v2 = v1->pTextures;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1134 v3 = 1000;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1135 do
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1136 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1137 Texture::Texture(v2);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1138 ++v2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1139 --v3;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1140 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1141 while ( v3 );*/
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1142 this->uTexturePacksCount = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1143 this->uNumPrevLoadedFiles = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1144 this->dword_11B84 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1145 this->dword_11B80 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1146 this->uNumLoadedFiles = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1147 this->dword_011BA4 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1148 //this->can_load_hardware_sprites = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1149 this->pHardwareSurfaces = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1150 this->pHardwareTextures = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1151 this->ptr_011BB4 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1152 this->uTextureRedBits = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1153 this->uTextureGreenBits = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1154 this->uTextureBlueBits = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1155 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1156
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1157 //----- (004621A7) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1158 bool LODWriteableFile::_4621A7()//çàêðûòü è çàãðóçèòü çàïèñûâàåìûé ô-ë(ïðè ñîõðàíåíèè)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1159 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1160 CloseWriteFile();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1161 return LoadFile(pLODName, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1162 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1163
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1164 //----- (00461FD4) ---LODFile_sub_461FD4---text:004632EA --------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1165 int LODWriteableFile::FixDirectoryOffsets()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1166 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1167 int total_size; // edi@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1168 int temp_offset; // ecx@5
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1169 FILE *tmp_file; // eax@9
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1170 size_t write_size; // edi@12
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1171 int result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1172 char Filename[256]; // [sp+Ch] [bp-228h]@9
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1173 char NewFilename[256]; // [sp+10Ch] [bp-128h]@15
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1174 int i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1175
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1176 total_size = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1177 for ( i = 0; i < uNumSubDirs; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1178 total_size += pSubIndices[i].uDataSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1179 //fix offsets
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1180 temp_offset = sizeof(LOD::Directory) * uNumSubDirs;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1181 for ( i = 0; i < uNumSubDirs; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1182 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1183 pSubIndices[i].uOfsetFromSubindicesStart=temp_offset;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1184 temp_offset+=pSubIndices[i].uDataSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1185 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1186 strcpy(Filename, "lod.tmp");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1187 tmp_file = fopen(Filename, "wb+");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1188
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1189 if ( tmp_file )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1190 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1191 fwrite((const void *)&header, sizeof(LOD::FileHeader), 1, tmp_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1192
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1193 LOD::Directory Lindx;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1194 strcpy(Lindx.pFilename, "chapter");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1195 Lindx.uOfsetFromSubindicesStart = uOffsetToSubIndex; //10h 16
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1196 Lindx.uDataSize = sizeof(LOD::Directory) * uNumSubDirs + total_size; //14h 20
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1197 Lindx.dword_000018 = 0; //18h 24
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1198 Lindx.uNumSubIndices = uNumSubDirs; //1ch 28
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1199 Lindx.word_00001E = 0; // 1Eh 30
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1200 fwrite(&Lindx, sizeof(LOD::Directory), 1, tmp_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1201 fwrite(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, tmp_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1202 fseek(pOutputFileHandle, 0, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1203 if ( total_size > 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1204 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1205 do
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1206 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1207 write_size = uIOBufferSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1208 if ( total_size <= (signed int)uIOBufferSize )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1209 write_size =total_size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1210 fread(pIOBuffer, 1, write_size, pOutputFileHandle);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1211 fwrite(pIOBuffer, 1, write_size, tmp_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1212 total_size -= write_size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1213 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1214 while ( total_size > 0 );
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1215 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1216 strcpy(NewFilename, (const char *)&pLODName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1217 fclose(tmp_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1218 fclose(pOutputFileHandle);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1219 CloseWriteFile();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1220 remove("lodapp.tmp");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1221 remove(NewFilename);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1222 rename(Filename, NewFilename);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1223 CloseWriteFile();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1224 LoadFile( (const char *)&pLODName, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1225 result = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1226 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1227 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1228 result = 5;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1229 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1230 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1231
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1232 //----- (00461F71) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1233 bool LOD::File::AppendDirectory(LOD::Directory *pDir, const void *pData)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1234 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1235 Assert(uNumSubDirs < 299);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1236
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1237 memcpy(&pSubIndices[uNumSubDirs++], pDir, sizeof(LOD::Directory));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1238 fwrite(pData, 1, pDir->uDataSize, pOutputFileHandle);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1239 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1240 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1241
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1242 //----- (00461F1E) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1243 int LODWriteableFile::CreateTempFile()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1244 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1245 if (!isFileOpened)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1246 return 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1247
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1248 if (pIOBuffer && uIOBufferSize )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1249 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1250 uCurrentIndexDir = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1251 uNumSubDirs = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1252 pOutputFileHandle = fopen("lodapp.tmp", "wb+");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1253 return pOutputFileHandle ? 1 : 7;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1254 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1255 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1256 return 5;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1257 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1258
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1259 //----- (00461EE9) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1260 void LODWriteableFile::CloseWriteFile()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1261 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1262 if (isFileOpened)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1263 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1264 pContainerName[0] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1265 uCurrentIndexDir = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1266 _6A0CA8_lod_unused = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1267
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1268 isFileOpened = false;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1269 fflush(pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1270 fclose(pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1271 pFile = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1272 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1273 //else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1274 //__debugbreak();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1275 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1276 // 6A0CA8: using guessed type int 6A0CA8_lod_unused;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1277
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1278
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1279 //----- (00461B48) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1280 unsigned int LODWriteableFile::Write(const LOD::Directory *pDir, const void *pDirData, int a4)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1281 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1282 char Filename[256];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1283 char NewFilename[256];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1284 FILE *tmp_file;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1285 int comp_res;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1286 bool bRewrite_data;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1287 int offset_to_data;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1288 int total_data_size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1289 int size_correction;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1290 int to_copy_size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1291 int read_size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1292 int curr_position;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1293 int insert_index;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1294
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1295 //insert new data in sorted index lod file
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1296 bRewrite_data = false;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1297 insert_index = -1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1298 if ( !isFileOpened )//sometimes gives crash
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1299 return 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1300 if ( !pSubIndices )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1301 return 2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1302 if ( !pIOBuffer || !uIOBufferSize )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1303 return 3;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1304
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1305 for ( int i = 0; i < uNumSubDirs; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1306 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1307 comp_res = _stricmp(pSubIndices[i].pFilename, pDir->pFilename);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1308 if( comp_res == 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1309 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1310 insert_index = i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1311 if ( a4 == 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1312 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1313 bRewrite_data = true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1314 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1315 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1316 if ( a4 == 1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1317 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1318 if ( pSubIndices[i].uNumSubIndices < pDir->uNumSubIndices )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1319 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1320 if ( pSubIndices[i].word_00001E < pDir->word_00001E )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1321 return 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1322 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1323 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1324 bRewrite_data = true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1325 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1326 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1327 if ( a4 == 2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1328 return 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1329 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1330 else if ( comp_res > 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1331 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1332 if ( insert_index == -1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1333 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1334 insert_index=i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1335 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1336 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1337 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1338 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1339 strcpy(Filename, "lod.tmp");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1340 tmp_file = fopen(Filename, "wb+");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1341 if ( !tmp_file )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1342 return 5;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1343 if (!bRewrite_data)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1344 size_correction = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1345 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1346 size_correction = pSubIndices[insert_index].uDataSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1347
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1348 //create chapter index
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1349 LOD::Directory Lindx;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1350 strcpy(Lindx.pFilename, "chapter");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1351 Lindx.dword_000018 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1352 Lindx.word_00001E = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1353 Lindx.uNumSubIndices = uNumSubDirs;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1354 Lindx.uOfsetFromSubindicesStart = sizeof(LOD::FileHeader) + sizeof(LOD::Directory);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1355 total_data_size = uLODDataSize + pDir->uDataSize-size_correction;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1356 if (!bRewrite_data)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1357 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1358 total_data_size += sizeof(LOD::Directory);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1359 Lindx.uNumSubIndices++;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1360 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1361
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1362 Lindx.uDataSize = total_data_size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1363 uNumSubDirs = Lindx.uNumSubIndices;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1364 //move indexes +1 after insert point
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1365 if ( !bRewrite_data && (insert_index < uNumSubDirs) )//ïåðåçàïèñûâàíèå ôàéëîâ äëÿ îñâîáîæäåíèÿ ìåñòà äëÿ íîâîãî ô-ëà
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1366 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1367 for( int i = uNumSubDirs; i > insert_index; --i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1368 memcpy(&pSubIndices[i], &pSubIndices[i - 1], sizeof(LOD::Directory)); //Uninitialized memory access
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1369 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1370 //insert
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1371 memcpy(&pSubIndices[insert_index], pDir, sizeof(LOD::Directory));//çàïèñàòü òåêóùèé ôàéë
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1372 //correct offsets to data
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1373 if (uNumSubDirs > 0)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1374 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1375 offset_to_data = sizeof(LOD::Directory) * uNumSubDirs;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1376 for ( int i = 0; i < uNumSubDirs; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1377 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1378 pSubIndices[i].uOfsetFromSubindicesStart = offset_to_data;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1379 offset_to_data += pSubIndices[i].uDataSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1380 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1381 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1382
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1383 //construct lod file with added data
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1384 fwrite(&header, sizeof(LOD::FileHeader), 1, tmp_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1385 fwrite(&Lindx, sizeof(LOD::Directory), 1, tmp_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1386 fseek(pFile,Lindx.uOfsetFromSubindicesStart, SEEK_SET);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1387 fwrite(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, tmp_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1388
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1389 offset_to_data = sizeof(LOD::Directory) * uNumSubDirs;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1390 if ( !bRewrite_data )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1391 offset_to_data -= sizeof(LOD::Directory);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1392
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1393 fseek(pFile, offset_to_data, SEEK_CUR);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1394 //copy from open lod to temp lod first half
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1395 to_copy_size = pSubIndices[insert_index].uOfsetFromSubindicesStart - pSubIndices[0].uOfsetFromSubindicesStart;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1396 while(to_copy_size > 0)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1397 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1398 read_size = uIOBufferSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1399 if ( to_copy_size <= uIOBufferSize )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1400 read_size = to_copy_size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1401 fread(pIOBuffer, 1, read_size, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1402 fwrite(pIOBuffer, 1, read_size, tmp_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1403 to_copy_size -= read_size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1404 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1405 // add container data
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1406 fwrite(pDirData, 1, pDir->uDataSize, tmp_file);// Uninitialized memory access(tmp_file)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1407 if ( bRewrite_data )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1408 fseek(pFile,size_correction , SEEK_CUR);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1409
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1410 //add remainng data last half
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1411 curr_position = ftell(pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1412 fseek(pFile, 0, SEEK_END);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1413 to_copy_size = ftell(pFile) - curr_position;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1414 fseek(pFile, curr_position, SEEK_SET);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1415 while ( to_copy_size > 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1416 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1417 read_size = uIOBufferSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1418 if ( to_copy_size <= uIOBufferSize )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1419 read_size = to_copy_size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1420 fread(pIOBuffer, 1, read_size, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1421 fwrite(pIOBuffer, 1, read_size, tmp_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1422 to_copy_size -= read_size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1423 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1424 //replace old file by new with added data
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1425 strcpy(NewFilename, (const char *)&pLODName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1426 fclose(tmp_file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1427 fclose(pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1428 CloseWriteFile();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1429 remove(NewFilename);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1430 rename(Filename, NewFilename);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1431 CloseWriteFile();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1432 //reload new
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1433 LoadFile((const char *)&pLODName, 0);//isFileOpened == true, next file
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1434 return 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1435 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1436
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1437 //----- (00461A43) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1438 bool LODWriteableFile::LoadFile(const char *pFilename, bool bWriting)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1439 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1440 if (bWriting & 1)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1441 pFile = fopen(pFilename, "rb");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1442 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1443 pFile = fopen(pFilename, "rb+");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1444 if (!pFile)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1445 {
2511
fb1c61a82a55 uHouseID - 1
Ritor1
parents: 2499
diff changeset
1446 // __debugbreak();
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1447 return false;// âîçìîæíî ôàéë íå çàêðûò, ïîýòîìó íå îòêðûâàåòñÿ
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1448 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1449
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1450 strcpy(pLODName, pFilename);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1451 fread(&header, sizeof(LOD::FileHeader), 1, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1452
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1453 LOD::Directory lod_indx;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1454 fread( &lod_indx,sizeof(LOD::Directory), 1, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1455
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1456 fseek(pFile, 0, SEEK_SET);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1457 isFileOpened = true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1458 strcpy(pContainerName, "chapter");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1459 uCurrentIndexDir = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1460 uLODDataSize = lod_indx.uDataSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1461 uNumSubDirs = lod_indx.uNumSubIndices;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1462 Assert(uNumSubDirs <= 300);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1463
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1464 uOffsetToSubIndex = lod_indx.uOfsetFromSubindicesStart;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1465 fseek(pFile, uOffsetToSubIndex, SEEK_SET);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1466
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1467 fread(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1468 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1469 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1470
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1471 //----- (00461A11) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1472 void LOD::File::FreeSubIndexAndIO()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1473 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1474 free(pSubIndices);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1475 free(pIOBuffer);// delete [] pIOBuffer;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1476 pIOBuffer = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1477 pSubIndices = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1478 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1479
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1480 //----- (00461954) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1481 void LOD::File::AllocSubIndicesAndIO(unsigned int uNumSubIndices, unsigned int uBufferSize)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1482 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1483 if (pSubIndices)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1484 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1485 MessageBoxA(0, "Attempt to reset a LOD subindex!", "MM6", MB_ICONEXCLAMATION);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1486 free(pSubIndices);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1487 pSubIndices = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1488 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1489 pSubIndices =(LOD::Directory *)malloc(32 * uNumSubIndices);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1490 if (pIOBuffer)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1491 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1492 MessageBoxA(0, "Attempt to reset a LOD IObuffer!", "MM6", MB_ICONEXCLAMATION);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1493 free(pIOBuffer);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1494 pIOBuffer = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1495 uIOBufferSize = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1496 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1497 if ( uBufferSize )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1498 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1499 pIOBuffer = (unsigned __int8 *)malloc(uBufferSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1500 uIOBufferSize = uBufferSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1501 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1502 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1503
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1504 //----- (0046188A) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1505 int LOD::File::LoadSubIndices(const char *pContainer)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1506 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1507 unsigned int uDir; // edi@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1508 LOD::Directory *curr_index; // eax@7
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1509
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1510 ResetSubIndices();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1511 uDir = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1512
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1513 for (uDir=0; uDir <header.uNumIndices;++uDir)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1514 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1515 if (!_stricmp(pContainer, pRoot[uDir].pFilename))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1516 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1517 strcpy(pContainerName, pContainer);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1518 uCurrentIndexDir = uDir;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1519 curr_index = (LOD::Directory *)&pRoot[uDir];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1520 uOffsetToSubIndex = curr_index->uOfsetFromSubindicesStart ;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1521 uNumSubDirs = curr_index->uNumSubIndices;// *(_WORD *)(v8 + 28);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1522 fseek( pFile, uOffsetToSubIndex, SEEK_SET);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1523 pSubIndices = (LOD::Directory *)malloc(sizeof(LOD::Directory)*(uNumSubDirs + 5));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1524
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1525 if ( pSubIndices)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1526 fread( pSubIndices, sizeof(LOD::Directory), uNumSubDirs, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1527 return 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1528 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1529 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1530 return 3;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1531 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1532
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1533 //----- (004617D5) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1534 bool LOD::File::LoadHeader(const char *pFilename, bool bWriting)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1535 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1536 const char *v6; // [sp-4h] [bp-Ch]@4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1537
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1538 if ( this->isFileOpened )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1539 Close();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1540 if ( bWriting & 1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1541 v6 = "rb";
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1542 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1543 v6 = "rb+";
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1544
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1545 pFile = fopen(pFilename, v6);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1546 if ( pFile )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1547 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1548 strcpy(pLODName, pFilename);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1549 fread(&header, sizeof(LOD::FileHeader), 1, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1550 pRoot = (LOD::Directory *)malloc(160);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1551 if ( pRoot )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1552 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1553 fread(pRoot, sizeof(LOD::Directory), header.uNumIndices, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1554 fseek(pFile, 0, SEEK_SET);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1555 isFileOpened = true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1556 return false;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1557 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1558 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1559 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1560 fclose(pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1561 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1562 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1563 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1564 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1565 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1566
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1567 //----- (00461790) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1568 LOD::File::~File()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1569 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1570 if ( this->isFileOpened )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1571 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1572 fclose(this->pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1573 free(this->pSubIndices);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1574 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1575 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1576
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1577 //----- (0046175B) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1578 LOD::File::File():
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1579 pRoot(nullptr),
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1580 isFileOpened(false)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1581 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1582 memset(pLODName, 0, 256);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1583 memset(pContainerName, 0, 16);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1584 this->pFile = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1585 this->pSubIndices = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1586 this->pIOBuffer = nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1587 this->isFileOpened = false;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1588 this->uIOBufferSize = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1589 Close();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1590 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1591
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1592 //----- (0046172B) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1593 LOD::Directory::Directory()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1594 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1595 memset(pFilename, 0, 16);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1596 this->pFilename[0] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1597 this->uOfsetFromSubindicesStart = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1598 this->uDataSize = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1599 this->uNumSubIndices = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1600 this->dword_000018 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1601 this->word_00001E = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1602 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1603
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1604 //----- (0046165E) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1605 int LOD::File::CalcIndexFast(int startIndex, int maxIndex, const char *pContainerName)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1606 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1607 int pCurrent_position; // esi@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1608 int v5; // ebx@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1609 int result; // eax@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1610
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1611 pCurrent_position = startIndex;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1612 while ( 1 ) // binary search in LOD indices
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1613 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1614
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1615 while ( 1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1616 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1617 v5 = maxIndex - pCurrent_position;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1618 result = _stricmp(pContainerName, (const char *)(&this->pSubIndices[(maxIndex - pCurrent_position) / 2] + pCurrent_position));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1619 if ( !_stricmp(pContainerName, (const char *)(&this->pSubIndices[(maxIndex - pCurrent_position) / 2] + pCurrent_position)) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1620 _6A0CA4_lod_binary_search = (maxIndex - pCurrent_position) / 2 + pCurrent_position;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1621 if ( pCurrent_position == maxIndex )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1622 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1623 _6A0CA4_lod_binary_search = -1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1624 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1625 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1626 if ( result < 0 )//ïåðâàÿ ñòðîêà ìåíüøå âòîðîé
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1627 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1628 if ( v5 <= 4 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1629 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1630 for ( int i = pCurrent_position; i < maxIndex; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1631 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1632 result = _stricmp(pContainerName, this->pSubIndices[i].pFilename);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1633 if ( !_stricmp(pContainerName, this->pSubIndices[i].pFilename) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1634 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1635 _6A0CA4_lod_binary_search = i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1636 return 0;//ñòðîêè ðîâíû
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1637 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1638 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1639 _6A0CA4_lod_binary_search = -1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1640 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1641 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1642 pCurrent_position += (maxIndex - pCurrent_position) / 2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1643 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1644
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1645 if ( v5 <= 4 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1646 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1647 maxIndex = (maxIndex - pCurrent_position) / 2 + pCurrent_position;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1648 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1649
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1650 for (int i = pCurrent_position; i < maxIndex; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1651 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1652 result = _stricmp(pContainerName, this->pSubIndices[i].pFilename);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1653 if ( !_stricmp(pContainerName, this->pSubIndices[i].pFilename) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1654 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1655 _6A0CA4_lod_binary_search = i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1656 return 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1657 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1658 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1659 _6A0CA4_lod_binary_search = -1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1660 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1661 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1662 // 6A0CA4: using guessed type int _6A0CA4_lod_binary_search;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1663
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1664 //----- (0046161C) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1665 bool LOD::File::DoesContainerExist(const char *pContainer)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1666 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1667 for ( int i = 0; i < (signed int)this->uNumSubDirs; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1668 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1669 if ( !_stricmp(pContainer, this->pSubIndices[i].pFilename) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1670 return 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1671 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1672 return 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1673 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1674
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1675 //----- (00461397) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1676 int LODFile_Sprites::_461397()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1677 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1678 this->field_ECA8 = this->uNumLoadedSprites;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1679 if ( this->uNumLoadedSprites < this->field_ECA0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1680 this->field_ECA8 = this->field_ECA0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1681 if ( this->field_ECA0 < this->field_ECA4 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1682 field_ECA0 = this->field_ECA4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1683 return this->uNumLoadedSprites;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1684 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1685
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1686 //----- (00461580) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1687 FILE *LOD::File::FindContainer(const char *pContainer_Name, bool bLinearSearch)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1688 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1689 if (!isFileOpened)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1690 return 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1691
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1692 if (bLinearSearch)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1693 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1694 for (uint i = 0; i < uNumSubDirs; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1695 if (!_stricmp(pContainer_Name, pSubIndices[i].pFilename))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1696 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1697 fseek(pFile, uOffsetToSubIndex + pSubIndices[i].uOfsetFromSubindicesStart, SEEK_SET);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1698 return pFile;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1699 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1700 return nullptr;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1701 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1702 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1703 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1704 CalcIndexFast(0, uNumSubDirs, pContainer_Name);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1705 if ( _6A0CA4_lod_binary_search < 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1706 return 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1707 fseek(pFile, uOffsetToSubIndex + pSubIndices[_6A0CA4_lod_binary_search].uOfsetFromSubindicesStart, SEEK_SET);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1708 return pFile;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1709 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1710 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1711
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1712 //----- (0041097D) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1713 void LODFile_IconsBitmaps::SetupPalettes(unsigned int uTargetRBits, unsigned int uTargetGBits, unsigned int uTargetBBits)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1714 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1715 FILE *File; // [sp+50h] [bp-4h]@7
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1716
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1717 if ( this->uTextureRedBits != uTargetRBits
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1718 || this->uTextureGreenBits != uTargetGBits
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1719 || this->uTextureBlueBits != uTargetBBits ) //Uninitialized memory access
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1720 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1721 this->uTextureRedBits = uTargetRBits;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1722 this->uTextureGreenBits = uTargetGBits;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1723 this->uTextureBlueBits = uTargetBBits;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1724 for ( uint i = 0; i < this->uNumLoadedFiles; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1725 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1726 Texture DstBuf; // [sp+4h] [bp-50h]@6
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1727 //Texture::Texture(&DstBuf);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1728 if ( this->pTextures[i].pPalette16 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1729 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1730 File = FindContainer((const char *)this->pTextures[i].pName, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1731 if ( File )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1732 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1733 fread(&DstBuf, 1, 0x30u, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1734 fseek(File, DstBuf.uTextureSize, 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1735 for ( uint j = 0; j < 256; ++j )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1736 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1737 fread((char *)&uTargetRBits + 3, 1, 1, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1738 fread((char *)&uTargetGBits + 3, 1, 1, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1739 fread((char *)&uTargetBBits + 3, 1, 1, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1740 this->pTextures[i].pPalette16[j] = (BYTE3(uTargetRBits) >> (8 - LOBYTE(this->uTextureRedBits)))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1741 << (LOBYTE(this->uTextureGreenBits) + LOBYTE(this->uTextureBlueBits));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1742 this->pTextures[i].pPalette16[j] |= (BYTE3(uTargetGBits) >> (8 - LOBYTE(this->uTextureGreenBits)))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1743 << this->uTextureBlueBits;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1744 this->pTextures[i].pPalette16[j] |= BYTE3(uTargetBBits) >> (8 - LOBYTE(this->uTextureBlueBits));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1745 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1746 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1747 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1748 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1749 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1750 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1751
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1752 //----- (0041088B) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1753 void *LOD::File::LoadRaw(const char *pContainer, int a3)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1754 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1755 FILE *File; // eax@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1756 void *v7; // ebx@7
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1757 void *v8; // edi@7
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1758 Texture DstBuf; // [sp+Ch] [bp-4Ch]@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1759
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1760 File = FindContainer(pContainer, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1761 if ( !File )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1762 Error("Unable to load %s", pContainer);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1763
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1764 fread(&DstBuf, 1, 0x30u, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1765 if ( DstBuf.uDecompressedSize )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1766 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1767 if ( a3 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1768 v7 = malloc(DstBuf.uDecompressedSize+1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1769 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1770 v7 = malloc(DstBuf.uDecompressedSize+1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1771 v8 = malloc(DstBuf.uTextureSize+1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1772 fread(v8, 1, DstBuf.uTextureSize, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1773 zlib::MemUnzip(v7, &DstBuf.uDecompressedSize, v8, DstBuf.uTextureSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1774 DstBuf.uTextureSize = DstBuf.uDecompressedSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1775 free(v8);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1776 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1777 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1778 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1779 if ( a3 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1780 v7 = malloc(DstBuf.uTextureSize+1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1781 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1782 v7 = malloc(DstBuf.uTextureSize+1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1783 fread(v7, 1, DstBuf.uTextureSize, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1784 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1785 return v7;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1786 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1787
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1788 //----- (00410522) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1789 int LODFile_IconsBitmaps::_410522(Texture *pDst, const char *pContainer, unsigned int uTextureType)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1790 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1791 void *v9; // ST2C_4@6
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1792 int v15; // ecx@12
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1793 int v16; // ecx@12
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1794 int v17; // eax@12
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1795 signed int v21; // ecx@18
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1796 signed int v22; // ecx@23
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1797 FILE *File; // [sp+68h] [bp-4h]@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1798 unsigned int uTargetRBits;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1799 unsigned int uTargetGBits;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1800 unsigned int uTargetBBits;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1801
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1802 File = FindContainer(pContainer, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1803 if ( !File )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1804 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1805 File = FindContainer("pending", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1806 if ( !File )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1807 Error("Can't find %s!", pContainer);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1808 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1809
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1810 fread(pDst, 1, 0x30u, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1811 strcpy(pDst->pName, pContainer);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1812 pDst->pLevelOfDetail0_prolly_alpha_mask = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1813 if ( pDst->uDecompressedSize )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1814 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1815 pDst->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(pDst->uDecompressedSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1816 v9 = malloc(pDst->uTextureSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1817 fread((void *)v9, 1, (size_t)pDst->uTextureSize, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1818 zlib::MemUnzip(pDst->pLevelOfDetail0_prolly_alpha_mask, &pDst->uDecompressedSize, v9, pDst->uTextureSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1819 pDst->uTextureSize = pDst->uDecompressedSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1820 free(v9);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1821 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1822 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1823 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1824 pDst->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1825 fread(pDst->pLevelOfDetail0_prolly_alpha_mask, 1, (size_t)pDst->uTextureSize, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1826 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1827 pDst->pPalette16 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1828 pDst->pPalette24 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1829 if ( uTextureType == 1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1830 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1831 pDst->pPalette24 = (unsigned __int8 *)malloc(0x300u);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1832 fread(pDst->pPalette24, 1, 0x300u, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1833 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1834 else if ( uTextureType == 2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1835 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1836 pDst->pPalette16 = (unsigned __int16 *)malloc(0x400u);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1837 for ( uint i = 0; i < 256; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1838 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1839 fread((char *)&uTargetRBits + 3, 1, 1, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1840 fread((char *)&uTargetGBits + 3, 1, 1, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1841 fread((char *)&uTargetBBits + 3, 1, 1, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1842 pDst->pPalette16[i] = (unsigned __int8)(BYTE3(uTargetRBits) >> (8 - LOBYTE(this->uTextureRedBits)))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1843 << (LOBYTE(this->uTextureBlueBits) + LOBYTE(this->uTextureGreenBits));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1844 pDst->pPalette16[i] += (unsigned __int8)(BYTE3(uTargetGBits) >> (8 - LOBYTE(this->uTextureGreenBits)))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1845 << this->uTextureBlueBits;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1846 pDst->pPalette16[i] += (unsigned __int8)(BYTE3(uTargetBBits) >> (8 - LOBYTE(this->uTextureBlueBits)));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1847 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1848 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1849
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1850 if ( pDst->pBits & 2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1851 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1852 v15 = (int)&pDst->pLevelOfDetail0_prolly_alpha_mask[pDst->uSizeOfMaxLevelOfDetail];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1853 pDst->pLevelOfDetail1 = (unsigned __int8 *)v15;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1854 v16 = (pDst->uSizeOfMaxLevelOfDetail >> 2) + v15;
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2511
diff changeset
1855 //pDst->pLevelOfDetail2 = (unsigned __int8 *)v16;
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1856 v17 = v16 + (pDst->uSizeOfMaxLevelOfDetail >> 4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1857 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1858 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1859 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1860 v17 = 0;
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2511
diff changeset
1861 //pDst->pLevelOfDetail2 = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2511
diff changeset
1862 //pDst->pLevelOfDetail1 = 0;
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1863 }
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2511
diff changeset
1864 //pDst->pLevelOfDetail3 = (unsigned __int8 *)v17;
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1865 v21 = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1866 while ( 1 << v21 != pDst->uTextureWidth )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1867 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1868 ++v21;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1869 if ( v21 >= 15 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1870 goto LABEL_23;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1871 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1872 pDst->uWidthLn2 = v21;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1873 LABEL_23:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1874 v22 = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1875 while ( 1 << v22 != pDst->uTextureHeight )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1876 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1877 ++v22;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1878 if ( v22 >= 15 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1879 goto LABEL_28;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1880 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1881 pDst->uHeightLn2 = v22;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1882 LABEL_28:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1883 switch ( pDst->uWidthLn2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1884 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1885 case 2:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1886 pDst->uWidthMinus1 = 3;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1887 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1888 case 3:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1889 pDst->uWidthMinus1 = 7;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1890 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1891 case 4:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1892 pDst->uWidthMinus1 = 15;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1893 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1894 case 5:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1895 pDst->uWidthMinus1 = 31;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1896 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1897 case 6:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1898 pDst->uWidthMinus1 = 63;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1899 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1900 case 7:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1901 pDst->uWidthMinus1 = 127;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1902 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1903 case 8:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1904 pDst->uWidthMinus1 = 255;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1905 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1906 case 9:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1907 pDst->uWidthMinus1 = 511;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1908 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1909 case 10:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1910 pDst->uWidthMinus1 = 1023;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1911 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1912 case 11:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1913 pDst->uWidthMinus1 = 2047;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1914 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1915 case 12:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1916 pDst->uWidthMinus1 = 4095;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1917 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1918 default:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1919 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1920 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1921 switch ( pDst->uHeightLn2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1922 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1923 case 2:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1924 pDst->uHeightMinus1 = 3;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1925 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1926 case 3:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1927 pDst->uHeightMinus1 = 7;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1928 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1929 case 4:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1930 pDst->uHeightMinus1 = 15;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1931 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1932 case 5:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1933 pDst->uHeightMinus1 = 31;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1934 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1935 case 6:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1936 pDst->uHeightMinus1 = 63;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1937 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1938 case 7:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1939 pDst->uHeightMinus1 = 127;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1940 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1941 case 8:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1942 pDst->uHeightMinus1 = 255;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1943 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1944 case 9:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1945 pDst->uHeightMinus1 = 511;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1946 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1947 case 10:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1948 pDst->uHeightMinus1 = 1023;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1949 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1950 case 11:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1951 pDst->uHeightMinus1 = 2047;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1952 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1953 case 12:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1954 pDst->uHeightMinus1 = 4095;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1955 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1956 default:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1957 return 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1958 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1959 return 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1960 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1961
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1962 //----- (00410423) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1963 void LODFile_IconsBitmaps::_410423_move_textures_to_device()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1964 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1965 size_t v4; // eax@9
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1966 char *v5; // ST1C_4@9
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1967
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1968 for ( uint i = 0; i < this->uNumLoadedFiles; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1969 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1970 if ( this->ptr_011BB4[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1971 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1972 if ( this->pTextures[i].pName[0] != 'w' || this->pTextures[i].pName[1] != 't'
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1973 || this->pTextures[i].pName[2] != 'r' || this->pTextures[i].pName[3] != 'd' || this->pTextures[i].pName[4] != 'r' )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1974 pRenderer->LoadTexture(&this->pTextures[i].pName[0], this->pTextures[i].uTextureSize, (IDirectDrawSurface4 **)&this->pHardwareSurfaces[i],
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1975 &this->pHardwareTextures[i]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1976 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1977 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1978 v4 = strlen(&this->pTextures[i].pName[0]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1979 v5 = (char *)malloc(v4 + 2);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1980 *v5 = 'h';
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1981 strcpy(v5 + 1, &this->pTextures[i].pName[0]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1982 pRenderer->LoadTexture(v5, this->pTextures[i].uTextureSize, (IDirectDrawSurface4 **)&this->pHardwareSurfaces[i], &this->pHardwareTextures[i]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1983 free(v5);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1984 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1985 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1986 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1987 if ( this->ptr_011BB4 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1988 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1989 if ( this->uNumLoadedFiles > 1 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1990 memset(this->ptr_011BB4, 0, this->uNumLoadedFiles - 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1991 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1992 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1993
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1994 //----- (004103BB) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1995 void LODFile_IconsBitmaps::ReleaseHardwareTextures()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1996 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1997 for ( uint i = 0; i < this->uNumLoadedFiles; i++ )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1998 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1999 if ( this->pHardwareTextures )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2000 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2001 if ( this->pHardwareTextures[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2002 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2003 this->pHardwareTextures[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2004 this->pHardwareTextures[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2005 this->ptr_011BB4[i] = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2006 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2007 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2008 if ( this->pHardwareSurfaces )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2009 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2010 if ( this->pHardwareSurfaces[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2011 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2012 this->pHardwareSurfaces[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2013 this->pHardwareSurfaces[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2014 this->ptr_011BB4[i] = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2015 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2016 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2017 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2018 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2019
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2020 //----- (0041033D) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2021 void LODFile_IconsBitmaps::ReleaseLostHardwareTextures()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2022 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2023 for ( uint i = 0; i < this->uNumLoadedFiles; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2024 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2025 if ( this->pHardwareSurfaces )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2026 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2027 if ( this->pHardwareSurfaces[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2028 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2029 if ( this->pHardwareSurfaces[i]->IsLost() == DDERR_SURFACELOST )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2030 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2031 if ( this->pHardwareTextures )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2032 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2033 if ( this->pHardwareTextures[i] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2034 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2035 this->pHardwareTextures[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2036 this->pHardwareTextures[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2037 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2038 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2039 this->pHardwareSurfaces[i]->Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2040 this->pHardwareSurfaces[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2041 this->ptr_011BB4[i] = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2042 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2043 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2044 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2045 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2046 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2047
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2048 //----- (004101B1) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2049 int LODFile_IconsBitmaps::ReloadTexture(Texture *pDst, const char *pContainer, int mode)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2050 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2051 Texture *v6; // esi@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2052 unsigned int v7; // ebx@6
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2053 unsigned int v8; // ecx@6
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2054 signed int result; // eax@7
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2055 FILE *File; // [sp+Ch] [bp-8h]@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2056 unsigned __int8 v15; // [sp+11h] [bp-3h]@13
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2057 unsigned __int8 v16; // [sp+12h] [bp-2h]@13
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2058 unsigned __int8 DstBuf; // [sp+13h] [bp-1h]@13
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2059 void *DstBufa; // [sp+1Ch] [bp+8h]@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2060 void *Sourcea; // [sp+20h] [bp+Ch]@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2061
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2062 File = FindContainer(pContainer, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2063 v6 = pDst;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2064 if ( File && pDst->pLevelOfDetail0_prolly_alpha_mask
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2065 && mode == 2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2066 && pDst->pPalette16 && !pDst->pPalette24
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2067 && (v7 = pDst->uTextureSize,
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2068 fread(pDst, 1, 0x30u, File),
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2069 strcpy(pDst->pName, pContainer),
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2070 v8 = pDst->uTextureSize,
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2071 (signed int)v8 <= (signed int)v7) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2072 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2073 if ( !pDst->uDecompressedSize || this->dword_011BA4 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2074 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2075 fread(pDst->pLevelOfDetail0_prolly_alpha_mask, 1, pDst->uTextureSize, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2076 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2077 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2078 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2079 Sourcea = malloc(pDst->uDecompressedSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2080 DstBufa = malloc(pDst->uTextureSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2081 fread(DstBufa, 1, pDst->uTextureSize, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2082 zlib::MemUnzip(Sourcea, &v6->uDecompressedSize, DstBufa, v6->uTextureSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2083 v6->uTextureSize = pDst->uDecompressedSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2084 free(DstBufa);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2085 memcpy(v6->pLevelOfDetail0_prolly_alpha_mask, Sourcea, pDst->uDecompressedSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2086 free(Sourcea);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2087 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2088 for( uint i = 0; i < 256; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2089 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2090 fread(&DstBuf, 1, 1, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2091 fread(&v16, 1, 1, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2092 fread(&v15, 1, 1, File);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2093 v6->pPalette16[i] = (unsigned __int8)(DstBuf >> (8 - LOBYTE(this->uTextureRedBits)))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2094 << (LOBYTE(this->uTextureBlueBits) + LOBYTE(this->uTextureGreenBits));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2095 v6->pPalette16[i] += (unsigned __int8)(v16 >> (8 - LOBYTE(this->uTextureGreenBits)))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2096 << this->uTextureBlueBits;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2097 v6->pPalette16[i] += (unsigned __int8)(v15 >> (8 - LOBYTE(this->uTextureBlueBits)));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2098 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2099 result = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2100 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2101 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2102 result = -1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2103 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2104 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2105
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2106 //----- (0040FC08) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2107 int LODFile_IconsBitmaps::LoadTextureFromLOD(Texture *pOutTex, const char *pContainer, enum TEXTURE_TYPE eTextureType)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2108 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2109 Texture *v8; // esi@3
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2110 enum TEXTURE_TYPE v12; // eax@14
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2111 signed int result; // esi@14
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2112 unsigned int v14; // eax@21
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2113 void *v19; // ST3C_4@27
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2114 size_t v22; // ST2C_4@29
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2115 const void *v23; // ecx@29
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2116 void *v30; // eax@30
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2117 signed int v41; // ecx@43
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2118 signed int v42; // ecx@48
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2119
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2120 FILE* pFile = FindContainer(pContainer, false);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2121 if (!pFile)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2122 return -1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2123 v8 = pOutTex;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2124 fread(pOutTex, 1, 0x30, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2125 strcpy(pOutTex->pName, pContainer);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2126 if (/*pRenderer->pRenderD3D &&*/ (pOutTex->pBits & 2) && strcmp(v8->pName, "sptext01"))//Ritor1: "&& strcmp(v8->pName, "sptext01")" - temporarily for red_aura
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2127 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2128 if (!pHardwareSurfaces || !pHardwareTextures)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2129 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2130 pHardwareSurfaces = new IDirectDrawSurface *[1000];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2131 memset(pHardwareSurfaces, 0, 1000 * sizeof(IDirectDrawSurface4 *));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2132
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2133 pHardwareTextures = new IDirect3DTexture2 *[1000];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2134 memset(pHardwareTextures, 0, 1000 * sizeof(IDirect3DTexture2 *));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2135
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2136 ptr_011BB4 = new char[1000];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2137 memset(ptr_011BB4, 0, 1000);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2138 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2139 if (_strnicmp(pContainer, "wtrdr", 5))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2140 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2141 if (_strnicmp(pContainer, "WtrTyl", 6))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2142 v14 = uNumLoadedFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2143 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2144 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2145 pRenderer->hd_water_tile_id = uNumLoadedFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2146 v14 = uNumLoadedFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2147 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2148 result = pRenderer->LoadTexture(pContainer, pOutTex->palette_id1, (IDirectDrawSurface4 **)&pHardwareSurfaces[v14], &pHardwareTextures[v14]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2149 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2150 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2151 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2152 char *temp_container;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2153 temp_container = (char *)malloc(strlen(pContainer) + 2);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2154 *temp_container = 104;//'h'
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2155 strcpy(temp_container + 1, pContainer);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2156 result = pRenderer->LoadTexture((const char *)temp_container, pOutTex->palette_id1,
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2157 (IDirectDrawSurface4 **)&pHardwareSurfaces[uNumLoadedFiles], &pHardwareTextures[uNumLoadedFiles]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2158 free((void *)temp_container);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2159 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2160 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2161 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2162 if ( !v8->uDecompressedSize || dword_011BA4 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2163 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2164 v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(v8->uTextureSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2165 fread(v8->pLevelOfDetail0_prolly_alpha_mask, 1, (size_t)v8->uTextureSize, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2166 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2167 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2168 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2169 pContainer = (const char *)malloc(v8->uDecompressedSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2170 v19 = malloc(v8->uTextureSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2171 fread(v19, 1, (size_t)v8->uTextureSize, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2172 zlib::MemUnzip((void *)pContainer, &v8->uDecompressedSize, v19, v8->uTextureSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2173 v8->uTextureSize = v8->uDecompressedSize;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2174 free(v19);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2175 if ( /*bUseLoResSprites*/false && v8->pBits & 2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2176 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2177 pOutTex = (Texture *)(((signed int)v8->uSizeOfMaxLevelOfDetail >> 2)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2178 + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 4)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2179 + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 6));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2180 v22 = (size_t)pOutTex;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2181 v23 = &pContainer[v8->uTextureWidth * v8->uTextureHeight];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2182 v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc((unsigned int)pOutTex);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2183 memcpy(v8->pLevelOfDetail0_prolly_alpha_mask, v23, v22);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2184 v8->uTextureWidth = (signed __int16)v8->uTextureWidth / 2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2185 v8->uTextureHeight = (signed __int16)v8->uTextureHeight / 2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2186 --v8->uWidthLn2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2187 --v8->uHeightLn2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2188 v8->uWidthMinus1 = v8->uTextureWidth - 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2189 v8->uHeightMinus1 = v8->uTextureHeight - 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2190 v8->uSizeOfMaxLevelOfDetail = (signed __int16)v8->uTextureWidth * (signed __int16)v8->uTextureHeight;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2191 v8->uTextureSize = (unsigned int)pOutTex;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2192 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2193 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2194 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2195 v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(v8->uDecompressedSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2196 memcpy(v8->pLevelOfDetail0_prolly_alpha_mask, pContainer, v8->uDecompressedSize);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2197 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2198 free((void *)pContainer);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2199 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2200
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2201 free(v8->pPalette16);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2202 v8->pPalette16 = NULL;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2203
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2204 free(v8->pPalette24);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2205 v8->pPalette24 = NULL;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2206
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2207 if ( eTextureType == TEXTURE_24BIT_PALETTE )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2208 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2209 v8->pPalette24 = (unsigned __int8 *)malloc(0x300);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2210 fread(v8->pPalette24, 1, 0x300, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2211 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2212 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2213 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2214 if ( eTextureType == TEXTURE_16BIT_PALETTE )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2215 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2216 v8->pPalette16 = (unsigned __int16 *)malloc(0x200);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2217 for ( uint i = 0; i < 256; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2218 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2219 fread((char *)&eTextureType + 3, 1, 1, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2220 fread((char *)&pContainer + 3, 1, 1, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2221 fread((char *)&pOutTex + 3, 1, 1, pFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2222 v8->pPalette16[i] = (unsigned __int8)(BYTE3(eTextureType) >> (8 - LOBYTE(this->uTextureRedBits))) //Uninitialized memory access
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2223 << (LOBYTE(this->uTextureBlueBits) + LOBYTE(this->uTextureGreenBits));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2224 v8->pPalette16[i] += (unsigned __int8)(BYTE3(pContainer) >> (8 - LOBYTE(this->uTextureGreenBits)))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2225 << this->uTextureBlueBits;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2226 v8->pPalette16[i] += (unsigned __int8)(BYTE3(pOutTex) >> (8 - LOBYTE(this->uTextureBlueBits)));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2227 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2228 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2229 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2230
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2231 if ( v8->pBits & 2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2232 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2233 v8->pLevelOfDetail1 = &v8->pLevelOfDetail0_prolly_alpha_mask[v8->uSizeOfMaxLevelOfDetail];
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2511
diff changeset
2234 //v8->pLevelOfDetail2 = &v8->pLevelOfDetail1[v8->uSizeOfMaxLevelOfDetail >> 2];
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2511
diff changeset
2235 //v8->pLevelOfDetail3 = &v8->pLevelOfDetail2[v8->uSizeOfMaxLevelOfDetail >> 4];
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2236 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2237 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2238 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2239 v8->pLevelOfDetail1 = 0;
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2511
diff changeset
2240 //v8->pLevelOfDetail2 = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2511
diff changeset
2241 //v8->pLevelOfDetail3 = 0;
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2242 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2243 for ( v41 = 1; v41 < 15; ++v41 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2244 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2245 if ( 1 << v41 == v8->uTextureWidth )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2246 v8->uWidthLn2 = v41;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2247 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2248 for ( v42 = 1; v42 < 15; ++v42 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2249 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2250 if ( 1 << v42 == v8->uTextureHeight )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2251 v8->uHeightLn2 = v42;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2252 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2253
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2254 switch ( v8->uWidthLn2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2255 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2256 case 2:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2257 v8->uWidthMinus1 = 3;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2258 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2259 case 3:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2260 v8->uWidthMinus1 = 7;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2261 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2262 case 4:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2263 v8->uWidthMinus1 = 15;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2264 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2265 case 5:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2266 v8->uWidthMinus1 = 31;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2267 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2268 case 6:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2269 v8->uWidthMinus1 = 63;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2270 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2271 case 7:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2272 v8->uWidthMinus1 = 127;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2273 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2274 case 8:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2275 v8->uWidthMinus1 = 255;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2276 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2277 case 9:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2278 v8->uWidthMinus1 = 511;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2279 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2280 case 10:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2281 v8->uWidthMinus1 = 1023;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2282 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2283 case 11:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2284 v8->uWidthMinus1 = 2047;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2285 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2286 case 12:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2287 v8->uWidthMinus1 = 4095;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2288 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2289 default:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2290 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2291 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2292 switch ( v8->uHeightLn2 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2293 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2294 case 2:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2295 v8->uHeightMinus1 = 3;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2296 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2297 case 3:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2298 v8->uHeightMinus1 = 7;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2299 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2300 case 4:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2301 v8->uHeightMinus1 = 15;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2302 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2303 case 5:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2304 v8->uHeightMinus1 = 31;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2305 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2306 case 6:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2307 v8->uHeightMinus1 = 63;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2308 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2309 case 7:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2310 v8->uHeightMinus1 = 127;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2311 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2312 case 8:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2313 v8->uHeightMinus1 = 255;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2314 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2315 case 9:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2316 v8->uHeightMinus1 = 511;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2317 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2318 case 10:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2319 v8->uHeightMinus1 = 1023;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2320 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2321 case 11:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2322 v8->uHeightMinus1 = 2047;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2323 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2324 case 12:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2325 v8->uHeightMinus1 = 4095;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2326 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2327 default:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2328 return 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2329 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2330 return 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2331 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2332
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2333 Texture *LODFile_IconsBitmaps::LoadTexturePtr(const char *pContainer, enum TEXTURE_TYPE uTextureType)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2334 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2335 uint id = LoadTexture(pContainer, uTextureType);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2336
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2337 Assert(id != -1 && L"Texture not found");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2338
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2339 return &pTextures[id];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2340 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2341
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2342 //----- (0040FB20) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2343 unsigned int LODFile_IconsBitmaps::LoadTexture(const char *pContainer, enum TEXTURE_TYPE uTextureType)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2344 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2345 areWeLoadingTexture = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2346
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2347 //check loaded texture?
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2348 for (uint i = 0; i < uNumLoadedFiles; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2349 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2350 if (!_stricmp(pContainer, pTextures[i].pName))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2351 return i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2352 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2353
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2354 // if (!uNumLoadedFiles)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2355 // {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2356 //LABEL_5:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2357 Assert(uNumLoadedFiles < 1000);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2358 /*if (uNumLoadedFiles >= 1000)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2359 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2360 Log::Warning(L"Maximum texture number exceeded");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2361 AbortWithError();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2362 }*/
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2363 if (LoadTextureFromLOD(&pTextures[uNumLoadedFiles], pContainer, uTextureType) == -1)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2364 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2365 for ( uint i = 0; i < uNumLoadedFiles; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2366 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2367 if (!_stricmp(pTextures[i].pName, "pending"))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2368 return i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2369 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2370 LoadTextureFromLOD(&pTextures[uNumLoadedFiles], "pending", uTextureType);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2371 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2372 areWeLoadingTexture = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2373 ++uNumLoadedFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2374 return uNumLoadedFiles - 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2375 // }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2376 // v5 = pTextures;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2377 // while ( _stricmp(v5->pName, pContainer) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2378 // {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2379 // ++v4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2380 // ++v5;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2381 // if (v4 >= uNumLoadedFiles )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2382 // goto LABEL_5;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2383 // }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2384 // return v4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2385 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2386
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2387 Texture * LODFile_IconsBitmaps::GetTexture( int idx )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2388 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2389 Assert(idx < MAX_LOD_TEXTURES, "Texture index out of bounds (%u)", idx);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2390 if (idx == -1)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2391 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2392 //Log::Warning(L"Texture id = %d missing", idx);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2393 return pTextures + LoadDummyTexture();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2394 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2395 return pTextures + idx;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2396 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2397
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2398 //----- (0046082C) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2399 bool Initialize_GamesLOD_NewLOD()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2400 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2401 pGames_LOD = new LODWriteableFile;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2402 pGames_LOD->AllocSubIndicesAndIO(300, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2403 if (pGames_LOD->LoadFile("data\\games.lod", 1))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2404 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2405 pNew_LOD = new LODWriteableFile;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2406 pNew_LOD->AllocSubIndicesAndIO(300, 100000);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2407 return true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2408 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2409 return false;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2410 }