annotate LOD.cpp @ 2490:0a0c6d75aabe

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