annotate LOD.cpp @ 2254:2e02c384c62b

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