Mercurial > mm7
annotate SaveLoad.cpp @ 1587:b42e6f35e03d
m
author | Ritor1 |
---|---|
date | Mon, 09 Sep 2013 09:13:23 +0600 |
parents | a27cdb3d753e |
children | c4ab816fcc5e |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
4 |
0 | 5 #include <io.h> |
6 #include <direct.h> | |
7 #include <assert.h> | |
8 | |
9 #include "SaveLoad.h" | |
1016 | 10 #include "BSPModel.h" |
0 | 11 #include "Party.h" |
12 #include "LOD.h" | |
13 #include "Outdoor.h" | |
14 #include "AudioPlayer.h" | |
15 #include "Actor.h" | |
16 #include "Chest.h" | |
17 #include "Time.h" | |
18 #include "GUIWindow.h" | |
19 #include "GUIFont.h" | |
20 #include "Overlays.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
21 #include "SpriteObject.h" |
0 | 22 #include "Viewport.h" |
23 #include "stru123.h" | |
189 | 24 #include "texts.h" |
0 | 25 #include "Log.h" |
1297 | 26 #include "Allocator.h" |
27 #include "VideoPlayer.h" | |
0 | 28 |
29 #include "mm7_data.h" | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 struct SavegameList *pSavegameList = new SavegameList; | |
36 unsigned int uNumSavegameFiles; | |
1206
ab6560001f5b
arrays to std::arrays phase 2 - some more arrays converted
Grumpy7
parents:
1205
diff
changeset
|
37 std::array<unsigned int, 45> pSavegameUsedSlots; |
ab6560001f5b
arrays to std::arrays phase 2 - some more arrays converted
Grumpy7
parents:
1205
diff
changeset
|
38 std::array<struct RGBTexture, 45> pSavegameThumbnails; |
ab6560001f5b
arrays to std::arrays phase 2 - some more arrays converted
Grumpy7
parents:
1205
diff
changeset
|
39 std::array<SavegameHeader, 45> pSavegameHeader; |
0 | 40 |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 //----- (0045EE8A) -------------------------------------------------------- | |
51 void __fastcall LoadGame(unsigned int uSlot) | |
52 { | |
53 bool v25; // esi@62 | |
54 bool v26; // eax@62 | |
55 int v30; // [sp-Ch] [bp-FCh]@65 | |
56 int v31; // [sp-8h] [bp-F8h]@4 | |
57 SavegameHeader header; // [sp+Ch] [bp-E4h]@23 | |
58 char Str[123]; // [sp+70h] [bp-80h]@25 | |
59 | |
336 | 60 dword_5B65C8_timers_count = 0; |
0 | 61 if (!pSavegameUsedSlots[uSlot]) |
62 { | |
63 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); | |
64 Log::Warning(L"LoadGame: slot %u is empty", uSlot); | |
65 return; | |
66 } | |
67 | |
68 for (uint i = 1; i < 5; ++i) | |
69 for (uint j = 1; j < 6; ++j) | |
70 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
71 sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
72 remove(pTmpBuf.data()); |
0 | 73 } |
74 | |
75 | |
203 | 76 if (SoundSetAction[24][0]) |
0 | 77 for (uint i = 0; i < 4; ++i) |
78 { | |
764 | 79 for (uint j = 0; j < pSoundList->sNumSounds; ++j) |
203 | 80 if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998) |
0 | 81 { |
764 | 82 pSoundList->UnloadSound(j, 1); |
0 | 83 break; |
84 } | |
85 | |
764 | 86 for (uint j = 0; j < pSoundList->sNumSounds; ++j) |
203 | 87 if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999) |
0 | 88 { |
764 | 89 pSoundList->UnloadSound(j, 1); |
0 | 90 break; |
91 } | |
92 } | |
93 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
94 sprintf(pTmpBuf.data(), "saves\\%s", pSavegameList->pFileList[uSlot].pSaveFileName); |
0 | 95 |
96 pNew_LOD->CloseWriteFile(); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
97 if (!CopyFileA(pTmpBuf.data(), "data\\new.lod", 0)) |
0 | 98 int e = GetLastError(); |
99 | |
100 pNew_LOD->LoadFile("data\\new.lod", 0); | |
101 auto *f = pNew_LOD->FindContainer("header.bin", 1); | |
102 if (!f) | |
103 { | |
104 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100); | |
105 Log::Warning(L"%S", Str); | |
106 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0); | |
107 } | |
108 assert(sizeof(SavegameHeader) == 100); | |
109 fread(&header, sizeof(SavegameHeader), 1, f); | |
110 | |
111 f = pNew_LOD->FindContainer("party.bin", 1); | |
112 if (!f) | |
113 { | |
114 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101); | |
115 Log::Warning(L"%S", Str); | |
116 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0); | |
117 } | |
118 if (sizeof(Party) != 0x16238) | |
119 Log::Warning(L"class Party: deserialization warning"); | |
120 fread(pParty, 0x16238u, 1, f); | |
121 | |
122 | |
123 f = pNew_LOD->FindContainer("clock.bin", 1); | |
124 if (!f) | |
125 { | |
126 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 102); | |
127 Log::Warning(L"%S", Str); | |
128 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0); | |
129 } | |
130 if (sizeof(Timer) != 0x28) | |
131 Log::Warning(L"class Timer: deserialization warning"); | |
132 fread(pEventTimer, 0x28u, 1u, f); | |
133 | |
134 f = pNew_LOD->FindContainer("overlay.bin", 1); | |
135 if (!f) | |
136 { | |
137 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 103); | |
138 Log::Warning(L"%S", Str); | |
139 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0); | |
140 } | |
141 if (sizeof(OtherOverlayList) != 0x3F0) | |
142 Log::Warning(L"class OtherOverlayList: deserialization warning"); | |
143 fread(pOtherOverlayList, 0x3F0, 1, f); | |
144 | |
145 f = pNew_LOD->FindContainer("npcdata.bin", 0); | |
146 if (!f) | |
147 { | |
148 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 104); | |
149 Log::Warning(L"%S", Str); | |
150 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0); | |
151 } | |
152 if (sizeof(pNPCStats->pNewNPCData) != 0x94BC) | |
153 Log::Warning(L"NPCStats: deserialization warning"); | |
154 fread(pNPCStats->pNewNPCData, 0x94BC, 1, f); | |
155 pNPCStats->_476C60(); | |
156 | |
157 f = pNew_LOD->FindContainer("npcgroup.bin", 0); | |
158 if (!f) | |
159 { | |
160 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 105); | |
161 Log::Warning(L"%S", Str); | |
162 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0); | |
163 } | |
164 if (sizeof(pNPCStats->pGroups_copy) != 0x66) | |
165 Log::Warning(L"NPCStats: deserialization warning"); | |
166 fread(pNPCStats->pGroups_copy, 0x66, 1, f); | |
167 | |
168 | |
169 uActiveCharacter = 0; | |
170 for (uint i = 0; i < 4; ++i) | |
171 if (pParty->pPlayers[i].CanAct()) | |
172 { | |
173 uActiveCharacter = i + 1; | |
174 break; | |
175 } | |
176 | |
177 for (uint i = 0; i < 4; ++i) | |
178 { | |
179 auto uQuickspell = pParty->pPlayers[i].uQuickSpell; | |
180 if (uQuickspell) | |
181 stru_AA1058[i]._494836(uQuickspell, i + 9 - 8); | |
182 | |
183 for (uint j = 0; j < 2; ++j) | |
184 { | |
185 uint uEquipIdx = pParty->pPlayers[i].pEquipment.pIndices[j]; | |
186 if (uEquipIdx) | |
187 { | |
1384
b51332ab228f
changed a few member variables in Player to slightly less confusing names
Grumpy7
parents:
1306
diff
changeset
|
188 auto uItemID = pParty->pPlayers[i].pInventoryItemList[uEquipIdx - 1].uItemID; |
0 | 189 if (pItemsTable->pItems[uItemID].uEquipType == 12) |
190 { | |
816 | 191 __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 |
488 | 192 v31 = *((int *)&pSpellDatas[66].uNormalLevelRecovery + uItemID); |
0 | 193 stru_A750F8[i]._494836(v31, i + 9); |
194 } | |
195 } | |
196 } | |
197 } | |
198 | |
199 | |
200 pGUIWindow_CurrentMenu->Release(); | |
151 | 201 pCurrentScreen = SCREEN_GAME; |
0 | 202 |
203 viewparams->bRedrawGameUI = true; | |
204 | |
373 | 205 SetUserInterface(pParty->alignment, true); |
0 | 206 |
207 pEventTimer->Resume(); | |
208 pEventTimer->StopGameTime(); | |
209 | |
210 v25 = pGames_LOD->DoesContainerExist(header.pLocationName); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
211 sprintf(pTmpBuf.data(), "levels\\%s", header.pLocationName); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
212 v26 = _access(pTmpBuf.data(), 4) != -1; |
0 | 213 if ( !v25 && !v26 ) |
214 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
215 sprintf(pTmpBuf.data(), "Unable to find: %s!", header.pLocationName); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
216 Abortf(pTmpBuf.data()); |
0 | 217 } |
218 | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1458
diff
changeset
|
219 strcpy(pCurrentMapName, header.pLocationName); |
0 | 220 dword_6BE364_game_settings_1 |= 0x2001; |
221 | |
222 for (uint i = 0; i < uNumSavegameFiles; ++i) | |
223 pSavegameThumbnails[i].Release(); | |
224 | |
1405
c0b273d33338
RemoveTexturesPackFromTextureList and RemoveTexturesFromTextureList
Ritor1
parents:
1404
diff
changeset
|
225 pIcons_LOD->RemoveTexturesPackFromTextureList(); |
328 | 226 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); |
227 pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); | |
0 | 228 if (uTurnSpeed) |
229 pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed; | |
230 MM7Initialization(); | |
231 bFlashQuestBook = false; | |
232 viewparams->bRedrawGameUI = true; | |
233 } | |
234 | |
235 | |
236 //----- (0045F469) -------------------------------------------------------- | |
810 | 237 void SaveGame( bool IsAutoSAve, bool NotSaveWorld ) |
982 | 238 { |
810 | 239 unsigned short *pScreenshot; // edi@5 |
240 int text_pos; // eax@6 | |
847 | 241 FILE *pLLoidFile; // edi@24 |
810 | 242 char* compressed_buf; // edi@30 |
243 char *data_write_pos; // esi@41 | |
847 | 244 CHAR Buffer[128]; // [sp+Ch] [bp-264h]@59 |
79 | 245 char Dir[255]; // [sp+8Ch] [bp-1E4h]@51 |
246 char Drive[255]; // [sp+ACh] [bp-1C4h]@51 | |
837 | 247 SavegameHeader save_header; // [sp+CCh] [bp-1A4h]@10 |
79 | 248 char Filename[255]; // [sp+130h] [bp-140h]@51 |
249 char Ext[255]; // [sp+150h] [bp-120h]@51 | |
0 | 250 char Source[32]; // [sp+170h] [bp-100h]@51 |
847 | 251 char work_string[120]; // [sp+190h] [bp-E0h]@8 |
252 int pPositionY; // [sp+208h] [bp-68h]@2 | |
0 | 253 int pPositionX; // [sp+20Ch] [bp-64h]@2 |
847 | 254 int sPRotationY; // [sp+210h] [bp-60h]@2 |
255 int sPRotationX; // [sp+214h] [bp-5Ch]@2 | |
837 | 256 ODMHeader odm_data; // [sp+218h] [bp-58h]@30 |
847 | 257 int res; // [sp+224h] [bp-4Ch]@30 |
258 int pPositionZ; // [sp+228h] [bp-48h]@2 | |
0 | 259 size_t Size; // [sp+250h] [bp-20h]@26 |
810 | 260 char *uncompressed_buff; // [sp+258h] [bp-18h]@2 |
261 unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23 | |
847 | 262 |
568 | 263 //v66 = a2; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1458
diff
changeset
|
264 strcpy(byte_6BE3B0.data(), pCurrentMapName); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1458
diff
changeset
|
265 if (!_stricmp(pCurrentMapName, "d05.blv")) // arena |
810 | 266 return; |
568 | 267 |
810 | 268 uncompressed_buff = (char*)malloc(1000000); |
982 | 269 |
270 LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2 | |
0 | 271 pPositionX = pParty->vPosition.x; |
847 | 272 pPositionY = pParty->vPosition.y; |
273 pPositionZ = pParty->vPosition.z; | |
274 sPRotationY = pParty->sRotationY; | |
275 sPRotationX = pParty->sRotationX; | |
0 | 276 pParty->vPosition.x = pParty->vPrevPosition.x; |
847 | 277 pParty->vPosition.z = pParty->vPrevPosition.z; |
278 pParty->vPosition.y = pParty->vPrevPosition.y; | |
279 | |
280 pParty->uFallStartY = pParty->vPrevPosition.z; | |
281 | |
0 | 282 pParty->sRotationY = pParty->sPrevRotationY; |
283 pParty->sRotationX = pParty->sPrevRotationX; | |
284 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
285 pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed; | |
286 else | |
810 | 287 pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed; |
0 | 288 pScreenshot = MakeScreenshot(150, 112); |
810 | 289 strcpy(pLodDirectory.pFilename, "image.pcx"); |
290 pRenderer->PackPCXpicture(pScreenshot, 150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize); | |
0 | 291 free(pScreenshot); |
151 | 292 if (pCurrentScreen == SCREEN_SAVEGAME) |
0 | 293 { |
568 | 294 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); |
295 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up)); | |
810 | 296 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[190]); |
297 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Ñîõðàíåíèå | |
298 text_pos = pFontSmallnum->AlignText_Center(186, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); | |
299 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, text_pos + 25, 259, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0); | |
300 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[165]); | |
301 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Ïîæàëóéñòà, ïîäîæäèòå | |
0 | 302 pRenderer->Present(); |
568 | 303 } |
304 | |
810 | 305 if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0)) |
0 | 306 { |
847 | 307 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 200); //Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d |
308 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); | |
0 | 309 } |
310 | |
311 assert(sizeof(SavegameHeader) == 100); | |
837 | 312 memset(save_header.pName, 0, 20); |
313 memset(save_header.pLocationName, 0, 20); | |
314 memset(save_header.field_30, 0, 52); | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1458
diff
changeset
|
315 strcpy(save_header.pLocationName, pCurrentMapName); |
837 | 316 save_header.uWordTime = pParty->uTimePlayed; |
810 | 317 strcpy(pLodDirectory.pFilename, "header.bin"); |
318 pLodDirectory.uDataSize = sizeof(SavegameHeader); | |
837 | 319 if (pNew_LOD->Write(&pLodDirectory, &save_header, 0)) |
0 | 320 { |
847 | 321 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 201); |
322 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); | |
0 | 323 } |
810 | 324 strcpy(pLodDirectory.pFilename, "party.bin"); |
325 pLodDirectory.uDataSize = sizeof(Party); //90680; | |
326 if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) ) | |
0 | 327 { |
847 | 328 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202); |
329 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); | |
0 | 330 } |
810 | 331 strcpy(pLodDirectory.pFilename, "clock.bin"); |
332 pLodDirectory.uDataSize =sizeof(Timer);// 40; | |
333 if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) ) | |
0 | 334 { |
847 | 335 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 203); |
336 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); | |
0 | 337 } |
810 | 338 strcpy(pLodDirectory.pFilename, "overlay.bin"); |
339 pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008; | |
340 if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) ) | |
0 | 341 { |
847 | 342 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 204); |
343 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); | |
0 | 344 } |
810 | 345 strcpy(pLodDirectory.pFilename, "npcdata.bin"); |
346 pLodDirectory.uDataSize = 501 * sizeof(NPCData); | |
347 assert(pLodDirectory.uDataSize == 38076); | |
348 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) ) | |
0 | 349 { |
847 | 350 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 205); |
351 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); | |
0 | 352 } |
810 | 353 strcpy(pLodDirectory.pFilename, "npcgroup.bin"); |
354 pLodDirectory.uDataSize = 102; | |
355 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) ) | |
0 | 356 { |
847 | 357 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 206); |
358 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0); | |
0 | 359 } |
360 for (int i = 1; i <= 4; ++i) // 4 - players | |
361 { | |
362 for (int j = 1; j <= 5; ++j) // 5 - images | |
363 { | |
847 | 364 sprintf(work_string, "data\\lloyd%d%d.pcx", i, j); |
365 pLLoidFile = fopen(work_string, "rb"); | |
366 if ( pLLoidFile ) | |
0 | 367 { |
368 __debugbreak(); | |
847 | 369 sprintf(work_string, "lloyd%d%d.pcx", i, j); |
370 fseek(pLLoidFile, 0, SEEK_END); | |
371 pLodDirectory.uDataSize = ftell(pLLoidFile); | |
372 rewind(pLLoidFile); | |
373 fread(uncompressed_buff, pLodDirectory.uDataSize, 1, pLLoidFile); | |
374 strcpy(pLodDirectory.pFilename, work_string); | |
375 fclose(pLLoidFile); | |
376 remove(work_string); | |
810 | 377 if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) ) |
0 | 378 { |
847 | 379 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 207); |
380 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); | |
0 | 381 Size = 5080748; |
382 } | |
383 } | |
384 } | |
385 } | |
810 | 386 if ( !NotSaveWorld ) |
0 | 387 { |
79 | 388 //__debugbreak(); |
810 | 389 CompactLayingItemsList(); |
390 compressed_buf = (char*)malloc(1000000); | |
837 | 391 odm_data.uVersion = 91969; |
392 odm_data.pMagic[0] = 'm'; | |
393 odm_data.pMagic[1] = 'v'; | |
394 odm_data.pMagic[2] = 'i'; | |
395 odm_data.pMagic[3] = 'i'; | |
396 odm_data.uCompressedSize = 0; | |
397 odm_data.uDecompressedSize = 0; | |
810 | 398 data_write_pos = uncompressed_buff; |
837 | 399 memcpy((void *)compressed_buf, &odm_data, 0x10); |
0 | 400 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) |
401 { | |
402 pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces; | |
403 pIndoor->dlv.uNumBModels = 0; | |
404 pIndoor->dlv.uNumDecorations = uNumLevelDecorations; | |
837 | 405 memcpy(data_write_pos, &pIndoor->dlv,sizeof(DDM_DLV_Header) );//0x28 |
406 data_write_pos += sizeof(DDM_DLV_Header); | |
810 | 407 memcpy(data_write_pos, pIndoor->_visible_outlines, 0x36B); |
408 data_write_pos += 875; | |
409 | |
410 for (int i = 0; i <(signed int)pIndoor->uNumFaces; ++i) | |
0 | 411 { |
810 | 412 memcpy(data_write_pos, &pIndoor->pFaces[i].uAttributes, 4); |
413 data_write_pos += 4; | |
0 | 414 } |
810 | 415 |
416 for (int i = 0; i <(signed int)uNumLevelDecorations; ++i) | |
0 | 417 { |
1489 | 418 memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2); |
810 | 419 |
420 data_write_pos+= 2; | |
0 | 421 } |
810 | 422 memcpy(data_write_pos, &uNumActors, 4); |
423 data_write_pos += 4; | |
1202 | 424 memcpy(data_write_pos, pActors.data(), 836 * uNumActors); |
810 | 425 data_write_pos += 836 * uNumActors; |
426 memcpy(data_write_pos, &uNumSpriteObjects, 4); | |
427 data_write_pos += 4; | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
428 memcpy(data_write_pos, pSpriteObjects.data(), 112 * uNumSpriteObjects); |
810 | 429 data_write_pos += 112 * uNumSpriteObjects; |
430 memcpy(data_write_pos, &uNumChests, 4); | |
431 data_write_pos += 4; | |
1202 | 432 memcpy(data_write_pos, pChests.data(), sizeof(Chest)*uNumChests);//5324 * |
847 | 433 data_write_pos += sizeof(Chest)* uNumChests; |
810 | 434 memcpy(data_write_pos, pIndoor->pDoors, 0x3E80); |
435 data_write_pos += 16000; | |
436 memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size); | |
437 data_write_pos += pIndoor->blv.uDoors_ddata_Size; | |
438 memcpy(data_write_pos, &stru_5E4C90, 0xC8); | |
439 data_write_pos += 200; | |
440 memcpy(data_write_pos, &pIndoor->stru1, 0x38); | |
441 data_write_pos += 56; | |
442 | |
0 | 443 } |
444 else | |
445 { | |
446 pOutdoor->ddm.uNumFacesInBModels = 0; | |
810 | 447 for (int i=0; i<pOutdoor->uNumBModels;++i) |
448 { | |
837 | 449 pOutdoor->ddm.uNumFacesInBModels +=pOutdoor->pBModels[i].uNumFaces; |
810 | 450 } |
0 | 451 pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels; |
452 pOutdoor->ddm.uNumDecorations = uNumLevelDecorations; | |
810 | 453 memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28 |
454 data_write_pos += sizeof(DDM_DLV_Header); | |
455 memcpy(data_write_pos, pOutdoor->uUndiscoveredArea, 0x3C8); | |
456 data_write_pos += 968; | |
457 memcpy(data_write_pos, pOutdoor->uDicovered_area, 0x3C8); | |
458 data_write_pos += 968; | |
837 | 459 for (int i = 0; i < pOutdoor->uNumBModels ; ++i) |
79 | 460 for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j) |
837 | 461 { |
462 memcpy(data_write_pos, &(pOutdoor->pBModels[i].pFaces[j].uAttributes), 4); | |
810 | 463 data_write_pos += 4; |
0 | 464 } |
837 | 465 |
1084
5a59b5b2699f
SaveGame "for" cycle fix - orignal disassembly code has "i < uNumLevelDecorations"
Grumpy7
parents:
1016
diff
changeset
|
466 for (int i = 0; i < (signed int)uNumLevelDecorations; ++i) |
0 | 467 { |
1489 | 468 memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2); |
810 | 469 data_write_pos += 2; |
0 | 470 } |
810 | 471 memcpy(data_write_pos, &uNumActors, 4); |
472 data_write_pos += 4; | |
1202 | 473 memcpy(data_write_pos, pActors.data(), 836 * uNumActors); |
810 | 474 data_write_pos += 836 * uNumActors; |
475 memcpy(data_write_pos, &uNumSpriteObjects, 4); | |
476 data_write_pos += 4; | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
477 memcpy(data_write_pos, pSpriteObjects.data(), 112 * uNumSpriteObjects); |
810 | 478 data_write_pos += 112 * uNumSpriteObjects; |
479 memcpy(data_write_pos, &uNumChests, 4); | |
480 data_write_pos += 4; | |
1202 | 481 memcpy(data_write_pos, pChests.data(), sizeof(Chest)* uNumChests); |
847 | 482 data_write_pos += sizeof(Chest)* uNumChests; |
810 | 483 memcpy(data_write_pos, &stru_5E4C90, 0xC8); |
484 data_write_pos += 200; | |
485 memcpy(data_write_pos, &pOutdoor->loc_time, 0x38); | |
486 data_write_pos += 56; | |
0 | 487 } |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1458
diff
changeset
|
488 strcpy(Source, pCurrentMapName); |
79 | 489 _splitpath(Source, Drive, Dir, Filename, Ext); |
847 | 490 |
810 | 491 Size = (int)data_write_pos - (int)uncompressed_buff; |
492 compressed_block_size = 999984; | |
847 | 493 res = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size); |
494 if (res || (signed int)compressed_block_size > (signed int)Size ) | |
0 | 495 { |
810 | 496 memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size); |
497 compressed_block_size = Size; | |
0 | 498 } |
810 | 499 compressed_block_size += 16; |
814 | 500 memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4); |
501 memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4); | |
0 | 502 sprintf(Source, "%s%s", &Filename, &Ext); |
847 | 503 strcpy(pLodDirectory.pFilename, Source); |
810 | 504 pLodDirectory.uDataSize = compressed_block_size; |
505 if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) ) | |
0 | 506 { |
847 | 507 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 208); |
508 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); | |
0 | 509 } |
810 | 510 free((void *)compressed_buf); |
0 | 511 } |
810 | 512 free(uncompressed_buff); |
513 if ( IsAutoSAve ) | |
0 | 514 { |
515 if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) ) | |
516 { | |
847 | 517 FormatMessageA(0x1000, 0, GetLastError(), 0x400, Buffer, 0x80, 0); |
518 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 300); | |
519 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0); | |
0 | 520 } |
521 } | |
522 pParty->vPosition.x = pPositionX; | |
847 | 523 pParty->vPosition.y = pPositionY; |
524 pParty->vPosition.z = pPositionZ; | |
525 pParty->uFallStartY = pPositionZ; | |
526 pParty->sRotationY = sPRotationY; | |
527 pParty->sRotationX = sPRotationX; | |
0 | 528 } |
529 | |
530 | |
531 //----- (00460078) -------------------------------------------------------- | |
532 void __fastcall DoSavegame(unsigned int uSlot) | |
533 { | |
568 | 534 //unsigned int v1; // esi@1 |
535 //int v2; // esi@2 | |
557 | 536 //RGBTexture *v3; // ebx@3 |
0 | 537 int bNotArena; // [sp+2Ch] [bp-8h]@1 |
568 | 538 //unsigned int v6; // [sp+30h] [bp-4h]@1 |
0 | 539 |
165 | 540 //__debugbreak(); |
0 | 541 |
568 | 542 //v1 = uSlot; |
543 //v6 = uSlot; | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1458
diff
changeset
|
544 bNotArena = _stricmp(pCurrentMapName, "d05.blv"); |
0 | 545 if ( bNotArena ) |
546 { | |
547 LOD::Directory pDir; // [sp+Ch] [bp-28h]@2 | |
548 SaveGame(0, 0); | |
568 | 549 //v2 = 100 * v1; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1458
diff
changeset
|
550 strcpy(pSavegameHeader[uSlot].pLocationName, pCurrentMapName); |
568 | 551 pSavegameHeader[uSlot].uWordTime = pParty->uTimePlayed; |
552 strcpy(pDir.pFilename, "header.bin"); | |
0 | 553 pDir.uDataSize = 100; |
568 | 554 pNew_LOD->Write(&pDir, &pSavegameHeader[uSlot], 0); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
555 sprintf(pTmpBuf.data(), "saves\\save%03d.mm7", uSlot); |
0 | 556 pNew_LOD->CloseWriteFile(); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
557 CopyFileA("data\\new.lod", pTmpBuf.data(), 0); |
0 | 558 } |
559 GUI_UpdateWindows(); | |
560 pGUIWindow_CurrentMenu->Release(); | |
151 | 561 pCurrentScreen = SCREEN_GAME; |
557 | 562 //v3 = pSavegameThumbnails; |
0 | 563 viewparams->bRedrawGameUI = 1; |
568 | 564 for (uint i = 0; i < 45; i++) |
557 | 565 pSavegameThumbnails[i].Release(); |
566 //while ( (signed int)v3 < (signed int)&unk_6A0758 ); | |
0 | 567 if ( bNotArena ) |
568 pNew_LOD->_4621A7(); | |
569 else | |
570 ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena" | |
1405
c0b273d33338
RemoveTexturesPackFromTextureList and RemoveTexturesFromTextureList
Ritor1
parents:
1404
diff
changeset
|
571 pIcons_LOD->RemoveTexturesFromTextureList(); |
0 | 572 pEventTimer->Resume(); |
573 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!" | |
568 | 574 viewparams->bRedrawGameUI = true; |
0 | 575 } |
576 // 4E28F8: using guessed type int pCurrentScreen; | |
577 | |
578 | |
579 | |
580 | |
581 | |
582 | |
583 | |
584 | |
585 | |
586 | |
587 | |
588 //----- (0045E297) -------------------------------------------------------- | |
589 void SavegameList::Initialize(unsigned int bHideEmptySlots) | |
590 { | |
382 | 591 memset(pSavegameList, 0, 0x3138); |
592 // Reset(); | |
4 | 593 uNumSavegameFiles = 0; |
0 | 594 |
595 _chdir("saves"); | |
596 { | |
4 | 597 if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7 |
382 | 598 strcpy(pSavegameList->pFileList[uNumSavegameFiles++].pSaveFileName, pGlobalTXT_LocalizationStrings[613]); |
0 | 599 |
600 for (uint i = 0; i < 40; ++i) | |
601 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
602 sprintf(pTmpBuf.data(), "save%03d.mm7", i); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
603 if (_access(pTmpBuf.data(), 0) == -1) |
0 | 604 continue; |
605 | |
606 uint idx = i; | |
607 if (!bHideEmptySlots) | |
608 idx = uNumSavegameFiles; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
609 strcpy(pSavegameList->pFileList[idx].pSaveFileName, pTmpBuf.data()); |
0 | 610 |
611 ++uNumSavegameFiles; | |
612 } | |
613 } | |
614 _chdir(".."); | |
1297 | 615 } |
616 //----- (0046086A) -------------------------------------------------------- | |
617 void SaveNewGame() | |
618 { | |
619 FILE *v3; // eax@7 | |
620 void *pSave; // [sp+170h] [bp-8h]@3 | |
621 | |
622 if ( pVideoPlayer->AnyMovieLoaded() ) | |
623 pVideoPlayer->Unload(); | |
624 pSave = pAllocator->AllocNamedChunk(0, 1000000, 0); | |
625 pNew_LOD->CloseWriteFile(); | |
626 remove("data\\new.lod"); | |
627 | |
628 LOD::FileHeader this_; // [sp+Ch] [bp-16Ch]@3 | |
629 strcpy(this_.LodVersion, "MMVII"); | |
630 strcpy(this_.LodDescription, "newmaps for MMVII"); | |
631 this_.LODSize = 100; | |
632 this_.dword_0000A8 = 0; | |
633 | |
634 LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3 | |
635 a3.dword_000018 = 0; | |
636 a3.word_00001E = 0; | |
637 strcpy(a3.pFilename, "current"); | |
638 pNew_LOD->CreateNewLod(&this_, &a3, "data\\new.lod"); | |
639 if (pNew_LOD->LoadFile("data\\new.lod", false)) | |
640 { | |
641 pNew_LOD->CreateTempFile(); | |
642 pNew_LOD->uNumSubDirs = 0; | |
643 | |
644 LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4 | |
645 for (int i = pGames_LOD->uNumSubDirs / 2; i < pGames_LOD->uNumSubDirs; ++i) | |
646 { | |
647 memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir)); | |
648 v3 = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1); | |
649 fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, v3); | |
650 pNew_LOD->AppendDirectory(&pDir, pSave); | |
651 } | |
652 | |
653 LOD::Directory save_game_dir; // [sp+12Ch] [bp-4Ch]@9 | |
654 strcpy(pSavegameHeader[0].pLocationName, "out01.odm"); | |
655 strcpy(save_game_dir.pFilename, "header.bin"); | |
656 save_game_dir.uDataSize = sizeof(SavegameHeader); | |
657 pNew_LOD->AppendDirectory(&save_game_dir, &pSavegameHeader[0]); | |
658 | |
659 pNew_LOD->FixDirectoryOffsets(); | |
660 pParty->vPrevPosition.y = 0; | |
661 pParty->vPrevPosition.x = 12552; | |
662 pParty->vPosition.x = 12552; | |
663 pParty->vPosition.z = 0; | |
664 pParty->uFallStartY = 0; | |
665 pParty->sPrevRotationX = 0; | |
666 pParty->sRotationX = 0; | |
667 pParty->vPrevPosition.z = 1816; | |
668 pParty->vPosition.y = 1816; | |
669 pParty->sPrevRotationY = 512; | |
670 pParty->sRotationY = 512; | |
671 SaveGame(1, 1); | |
672 } | |
673 pAllocator->FreeChunk(pSave); | |
674 } | |
675 //----- (0045E03A) -------------------------------------------------------- | |
676 unsigned short * MakeScreenshot( signed int width, signed int height ) | |
677 { | |
678 //signed int v2; // edi@1 | |
679 unsigned __int16 *v3; // ebx@1 | |
680 int v4; // edx@7 | |
681 unsigned __int8 v5; // cf@9 | |
682 unsigned int v6; // ecx@9 | |
683 unsigned __int16 *v7; // edi@9 | |
684 int j; // ecx@9 | |
685 //unsigned __int16 *v9; // edi@15 | |
686 //int v10; // ecx@15 | |
687 //LONG v11; // esi@15 | |
688 //signed __int64 v12; // qax@18 | |
689 //unsigned int v13; // ST10_4@21 | |
690 HRESULT v14; // eax@21 | |
691 int v15; // edi@29 | |
692 signed __int64 v16; // qax@30 | |
693 signed int v17; // edx@34 | |
694 unsigned __int16 *v18; // edi@36 | |
695 int k; // ecx@36 | |
696 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 | |
697 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 | |
698 float v23; // [sp+84h] [bp-20h]@1 | |
699 unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21 | |
700 float v25; // [sp+8Ch] [bp-18h]@1 | |
701 unsigned int v26; // [sp+90h] [bp-14h]@17 | |
702 //int v27; // [sp+94h] [bp-10h]@1 | |
703 int v28; // [sp+98h] [bp-Ch]@16 | |
704 int v29; // [sp+9Ch] [bp-8h]@15 | |
705 //int v30; // [sp+A0h] [bp-4h]@1 | |
706 | |
707 //v30 = width; | |
708 //v2 = height; | |
709 //v27 = height; | |
710 v23 = game_viewport_width / (double)width; | |
711 v25 = game_viewport_height / (double)height; | |
712 | |
713 pPixels = (unsigned __int16 *)malloc(2 * height * width); | |
714 memset(pPixels, 0 , 2 * height * width); | |
715 | |
716 v3 = pPixels; | |
717 if ( pRenderer->pRenderD3D ) | |
718 { | |
719 pRenderer->BeginSceneD3D(); | |
720 | |
721 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
722 pIndoor->Draw(); | |
723 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
724 pOutdoor->Draw(); | |
725 | |
726 pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
727 memset(&Dst, 0, 0x7Cu); | |
728 Dst.dwSize = sizeof(Dst); | |
729 | |
730 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
731 { | |
732 auto src = (unsigned __int16 *)Dst.lpSurface; | |
733 auto src_width = (Dst.lPitch / sizeof(short)); | |
734 auto src_height = Dst.dwHeight; | |
735 auto dst = pPixels; | |
736 for (uint y = 0; y < height; ++y) | |
737 { | |
738 //uint src_y = (game_viewport_y + y * v25) * (Dst.lPitch / sizeof(short)); | |
739 uint src_y = game_viewport_y + y * v25; | |
740 assert(game_viewport_y + y * v25 < src_height); | |
741 assert(y < height); | |
742 | |
743 for (uint x = 0; x < width; ++x) | |
744 { | |
745 //uint src_x = game_viewport_x + x * v23; | |
746 uint src_x = game_viewport_x + x * v23; | |
747 assert(src_x < src_width); | |
748 assert(x < width); | |
749 | |
750 dst[y * width + x] = (((63*y)/117) << 5) | 31*x/155;//31*y/117;//src[src_y * src_width + src_x]; | |
751 } | |
752 } | |
753 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
754 } | |
755 else | |
756 { | |
757 __debugbreak(); // unrefactored | |
758 v4 = height; | |
759 if ( height > 0 ) | |
760 { | |
761 do | |
762 { | |
763 if ( width > 0 ) | |
764 { | |
765 v5 = width & 1; | |
766 v6 = (unsigned int)width >> 1; | |
767 memset(v3, 0, 4 * ((unsigned int)width >> 1)); | |
768 v7 = &v3[2 * v6]; | |
769 for ( j = v5; j; --j ) | |
770 { | |
771 *v7 = 0; | |
772 ++v7; | |
773 } | |
774 v3 += width; | |
775 } | |
776 --v4; | |
777 } | |
778 while ( v4 ); | |
779 } | |
780 } | |
781 } | |
782 else | |
783 { | |
784 pRenderer->BeginScene(); | |
785 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
786 { | |
787 pIndoor->Draw(); | |
788 } | |
789 else | |
790 { | |
791 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
792 pOutdoor->Draw(); | |
793 } | |
794 _this = pRenderer->pTargetSurface; | |
795 v26 = pRenderer->uTargetSurfacePitch; | |
796 if ( pRenderer->pTargetSurface ) | |
797 { | |
798 if ( height > 0 ) | |
799 { | |
1430 | 800 for ( v29 = 0; v29 < height; ++v29 ) |
1297 | 801 { |
802 if ( width > 0 ) | |
803 { | |
804 v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0); | |
1430 | 805 for ( v28 = 0; v28 < width; v28++ ) |
1297 | 806 { |
1430 | 807 *v3 = _this[v15 + (int)(signed __int64)((double)v28 * v23 + 8.0)]; |
1297 | 808 ++v3; |
809 } | |
810 } | |
811 } | |
812 } | |
813 } | |
814 else | |
815 { | |
816 if ( height > 0 ) | |
817 { | |
1430 | 818 for ( v17 = height; v17; --v17 ) |
1297 | 819 { |
820 if ( width > 0 ) | |
821 { | |
822 memset(v3, 0, 4 * ((unsigned int)width >> 1)); | |
823 v18 = &v3[2 * ((unsigned int)width >> 1)]; | |
824 for ( k = width & 1; k; --k ) | |
825 { | |
826 *v18 = 0; | |
827 ++v18; | |
828 } | |
829 v3 += width; | |
830 } | |
831 } | |
832 } | |
833 } | |
834 pRenderer->EndScene(); | |
835 } | |
836 return pPixels; | |
837 } | |
838 //----- (0045E26C) -------------------------------------------------------- | |
1458 | 839 void SaveScreenshot(const char *pFilename) |
1297 | 840 { |
841 unsigned __int16 *v2; // esi@1 | |
842 | |
843 v2 = MakeScreenshot(92, 68); | |
1430 | 844 pRenderer->SavePCXImage(pFilename, (char *)v2, 92, 68); |
1297 | 845 free(v2); |
0 | 846 } |