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