annotate LOD.cpp @ 2464:104fdbea0386

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