Mercurial > mm7
annotate SaveLoad.cpp @ 814:35122475edd7
struct correction
author | Gloval |
---|---|
date | Tue, 26 Mar 2013 08:19:58 +0400 |
parents | f5156b8c61ad |
children | 448e6d979c7a |
rev | line source |
---|---|
0 | 1 #include <io.h> |
2 #include <direct.h> | |
3 #include <assert.h> | |
4 | |
5 #include "SaveLoad.h" | |
6 #include "NPC.h" | |
7 #include "Party.h" | |
8 #include "LOD.h" | |
9 #include "Outdoor.h" | |
10 #include "AudioPlayer.h" | |
11 #include "Actor.h" | |
12 #include "Chest.h" | |
13 #include "Time.h" | |
14 #include "GUIWindow.h" | |
15 #include "GUIFont.h" | |
16 #include "Overlays.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
17 #include "SpriteObject.h" |
0 | 18 #include "Viewport.h" |
19 #include "stru123.h" | |
189 | 20 #include "texts.h" |
0 | 21 #include "Log.h" |
22 | |
23 #include "mm7_data.h" | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 struct SavegameList *pSavegameList = new SavegameList; | |
30 unsigned int uNumSavegameFiles; | |
31 unsigned int pSavegameUsedSlots[45]; | |
32 struct RGBTexture pSavegameThumbnails[45]; | |
33 SavegameHeader pSavegameHeader[45]; | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 //----- (0045EE8A) -------------------------------------------------------- | |
45 void __fastcall LoadGame(unsigned int uSlot) | |
46 { | |
47 bool v25; // esi@62 | |
48 bool v26; // eax@62 | |
49 int v30; // [sp-Ch] [bp-FCh]@65 | |
50 int v31; // [sp-8h] [bp-F8h]@4 | |
51 SavegameHeader header; // [sp+Ch] [bp-E4h]@23 | |
52 char Str[123]; // [sp+70h] [bp-80h]@25 | |
53 | |
336 | 54 dword_5B65C8_timers_count = 0; |
0 | 55 if (!pSavegameUsedSlots[uSlot]) |
56 { | |
57 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); | |
58 Log::Warning(L"LoadGame: slot %u is empty", uSlot); | |
59 return; | |
60 } | |
61 | |
62 for (uint i = 1; i < 5; ++i) | |
63 for (uint j = 1; j < 6; ++j) | |
64 { | |
65 sprintf(pTmpBuf, "data\\lloyd%d%d.pcx", i, j); | |
66 remove(pTmpBuf); | |
67 } | |
68 | |
69 | |
203 | 70 if (SoundSetAction[24][0]) |
0 | 71 for (uint i = 0; i < 4; ++i) |
72 { | |
764 | 73 for (uint j = 0; j < pSoundList->sNumSounds; ++j) |
203 | 74 if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998) |
0 | 75 { |
764 | 76 pSoundList->UnloadSound(j, 1); |
0 | 77 break; |
78 } | |
79 | |
764 | 80 for (uint j = 0; j < pSoundList->sNumSounds; ++j) |
203 | 81 if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999) |
0 | 82 { |
764 | 83 pSoundList->UnloadSound(j, 1); |
0 | 84 break; |
85 } | |
86 } | |
87 | |
382 | 88 sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[uSlot].pSaveFileName); |
0 | 89 |
90 pNew_LOD->CloseWriteFile(); | |
91 if (!CopyFileA(pTmpBuf, "data\\new.lod", 0)) | |
92 int e = GetLastError(); | |
93 | |
94 pNew_LOD->LoadFile("data\\new.lod", 0); | |
95 auto *f = pNew_LOD->FindContainer("header.bin", 1); | |
96 if (!f) | |
97 { | |
98 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100); | |
99 Log::Warning(L"%S", Str); | |
100 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0); | |
101 } | |
102 assert(sizeof(SavegameHeader) == 100); | |
103 fread(&header, sizeof(SavegameHeader), 1, f); | |
104 | |
105 f = pNew_LOD->FindContainer("party.bin", 1); | |
106 if (!f) | |
107 { | |
108 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101); | |
109 Log::Warning(L"%S", Str); | |
110 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0); | |
111 } | |
112 if (sizeof(Party) != 0x16238) | |
113 Log::Warning(L"class Party: deserialization warning"); | |
114 fread(pParty, 0x16238u, 1, f); | |
115 | |
116 | |
117 f = pNew_LOD->FindContainer("clock.bin", 1); | |
118 if (!f) | |
119 { | |
120 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 102); | |
121 Log::Warning(L"%S", Str); | |
122 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0); | |
123 } | |
124 if (sizeof(Timer) != 0x28) | |
125 Log::Warning(L"class Timer: deserialization warning"); | |
126 fread(pEventTimer, 0x28u, 1u, f); | |
127 | |
128 f = pNew_LOD->FindContainer("overlay.bin", 1); | |
129 if (!f) | |
130 { | |
131 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 103); | |
132 Log::Warning(L"%S", Str); | |
133 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0); | |
134 } | |
135 if (sizeof(OtherOverlayList) != 0x3F0) | |
136 Log::Warning(L"class OtherOverlayList: deserialization warning"); | |
137 fread(pOtherOverlayList, 0x3F0, 1, f); | |
138 | |
139 f = pNew_LOD->FindContainer("npcdata.bin", 0); | |
140 if (!f) | |
141 { | |
142 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 104); | |
143 Log::Warning(L"%S", Str); | |
144 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0); | |
145 } | |
146 if (sizeof(pNPCStats->pNewNPCData) != 0x94BC) | |
147 Log::Warning(L"NPCStats: deserialization warning"); | |
148 fread(pNPCStats->pNewNPCData, 0x94BC, 1, f); | |
149 pNPCStats->_476C60(); | |
150 | |
151 f = pNew_LOD->FindContainer("npcgroup.bin", 0); | |
152 if (!f) | |
153 { | |
154 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 105); | |
155 Log::Warning(L"%S", Str); | |
156 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0); | |
157 } | |
158 if (sizeof(pNPCStats->pGroups_copy) != 0x66) | |
159 Log::Warning(L"NPCStats: deserialization warning"); | |
160 fread(pNPCStats->pGroups_copy, 0x66, 1, f); | |
161 | |
162 | |
163 uActiveCharacter = 0; | |
164 for (uint i = 0; i < 4; ++i) | |
165 if (pParty->pPlayers[i].CanAct()) | |
166 { | |
167 uActiveCharacter = i + 1; | |
168 break; | |
169 } | |
170 | |
171 for (uint i = 0; i < 4; ++i) | |
172 { | |
173 auto uQuickspell = pParty->pPlayers[i].uQuickSpell; | |
174 if (uQuickspell) | |
175 stru_AA1058[i]._494836(uQuickspell, i + 9 - 8); | |
176 | |
177 for (uint j = 0; j < 2; ++j) | |
178 { | |
179 uint uEquipIdx = pParty->pPlayers[i].pEquipment.pIndices[j]; | |
180 if (uEquipIdx) | |
181 { | |
182 auto uItemID = pParty->pPlayers[i].pInventoryItems[uEquipIdx - 1].uItemID; | |
183 if (pItemsTable->pItems[uItemID].uEquipType == 12) | |
184 { | |
185 __debugbreak(); | |
488 | 186 v31 = *((int *)&pSpellDatas[66].uNormalLevelRecovery + uItemID); |
0 | 187 stru_A750F8[i]._494836(v31, i + 9); |
188 } | |
189 } | |
190 } | |
191 } | |
192 | |
193 | |
194 pGUIWindow_CurrentMenu->Release(); | |
151 | 195 pCurrentScreen = SCREEN_GAME; |
0 | 196 |
197 viewparams->bRedrawGameUI = true; | |
198 | |
373 | 199 SetUserInterface(pParty->alignment, true); |
0 | 200 |
201 pEventTimer->Resume(); | |
202 pEventTimer->StopGameTime(); | |
203 | |
204 v25 = pGames_LOD->DoesContainerExist(header.pLocationName); | |
205 sprintf(pTmpBuf, "levels\\%s", header.pLocationName); | |
206 v26 = _access(pTmpBuf, 4) != -1; | |
207 if ( !v25 && !v26 ) | |
208 { | |
209 sprintf(pTmpBuf, "Unable to find: %s!", header.pLocationName); | |
210 Abortf(pTmpBuf); | |
211 } | |
212 | |
213 strcpy(pCurrentMapName, header.pLocationName); | |
214 dword_6BE364_game_settings_1 |= 0x2001; | |
215 | |
216 for (uint i = 0; i < uNumSavegameFiles; ++i) | |
217 pSavegameThumbnails[i].Release(); | |
218 | |
219 pIcons_LOD->_4114F2(); | |
328 | 220 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); |
221 pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); | |
0 | 222 if (uTurnSpeed) |
223 pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed; | |
224 MM7Initialization(); | |
225 bFlashQuestBook = false; | |
226 viewparams->bRedrawGameUI = true; | |
227 } | |
228 | |
229 | |
230 //----- (0045F469) -------------------------------------------------------- | |
810 | 231 void SaveGame( bool IsAutoSAve, bool NotSaveWorld ) |
232 { | |
0 | 233 int result; // eax@1 |
810 | 234 unsigned short *pScreenshot; // edi@5 |
235 int text_pos; // eax@6 | |
0 | 236 int v5; // eax@6 |
237 int v6; // eax@6 | |
238 const char *v7; // edi@8 | |
239 FILE *v8; // edi@24 | |
810 | 240 char* compressed_buf; // edi@30 |
0 | 241 void *v10; // esi@31 |
242 void *v11; // esi@31 | |
243 void *v12; // esi@37 | |
244 void *v13; // esi@37 | |
245 void *v14; // esi@37 | |
246 void *v15; // esi@37 | |
247 void *v16; // esi@37 | |
248 int v17; // esi@37 | |
249 unsigned int v18; // ecx@38 | |
250 unsigned int v19; // esi@39 | |
79 | 251 BSPModel *v20; // edx@39 |
810 | 252 char *data_write_pos; // esi@41 |
0 | 253 void *v22; // esi@41 |
254 BSPModel *v23; // eax@42 | |
255 signed int v24; // edi@42 | |
256 unsigned __int8 v25; // zf@43 | |
257 unsigned __int8 v26; // sf@43 | |
258 signed int v27; // edi@47 | |
259 void *v28; // esi@50 | |
260 void *v29; // esi@50 | |
261 void *v30; // esi@50 | |
262 void *v31; // esi@50 | |
263 int v32; // esi@51 | |
264 int v33; // eax@51 | |
265 DWORD v34; // eax@59 | |
266 //std::string v35; // [sp-18h] [bp-288h]@8 | |
267 const char *v36; // [sp-10h] [bp-280h]@6 | |
268 const char *v37; // [sp-Ch] [bp-27Ch]@6 | |
79 | 269 unsigned int *v38; // [sp-8h] [bp-278h]@8 |
0 | 270 CHAR Buffer; // [sp+Ch] [bp-264h]@59 |
79 | 271 char Dir[255]; // [sp+8Ch] [bp-1E4h]@51 |
272 char Drive[255]; // [sp+ACh] [bp-1C4h]@51 | |
0 | 273 SavegameHeader header; // [sp+CCh] [bp-1A4h]@10 |
274 //int v43; // [sp+CCh] [bp-1A4h]@10 | |
275 //char Dest[20]; // [sp+E0h] [bp-190h]@10 | |
276 //unsigned __int64 pTimePlayed; // [sp+F4h] [bp-17Ch]@10 | |
79 | 277 char Filename[255]; // [sp+130h] [bp-140h]@51 |
278 char Ext[255]; // [sp+150h] [bp-120h]@51 | |
0 | 279 char v48; // [sp+151h] [bp-11Fh]@51 |
280 char Source[32]; // [sp+170h] [bp-100h]@51 | |
281 char Str[120]; // [sp+190h] [bp-E0h]@8 | |
282 int v51; // [sp+208h] [bp-68h]@2 | |
283 int pPositionX; // [sp+20Ch] [bp-64h]@2 | |
284 int v53; // [sp+210h] [bp-60h]@2 | |
285 int v54; // [sp+214h] [bp-5Ch]@2 | |
814 | 286 ODMHeader Src; // [sp+218h] [bp-58h]@30 |
0 | 287 char v56; // [sp+21Ch] [bp-54h]@30 |
288 char v57; // [sp+21Dh] [bp-53h]@30 | |
289 char v58; // [sp+21Eh] [bp-52h]@30 | |
290 char v59; // [sp+21Fh] [bp-51h]@30 | |
291 int v60; // [sp+220h] [bp-50h]@30 | |
292 int v61; // [sp+224h] [bp-4Ch]@30 | |
293 int v62; // [sp+228h] [bp-48h]@2 | |
810 | 294 LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2 |
0 | 295 size_t Size; // [sp+250h] [bp-20h]@26 |
296 __int16 *v66; // [sp+254h] [bp-1Ch]@1 | |
810 | 297 char *uncompressed_buff; // [sp+258h] [bp-18h]@2 |
0 | 298 __int16 *v68; // [sp+25Ch] [bp-14h]@32 |
810 | 299 unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23 |
0 | 300 int v70; // [sp+264h] [bp-Ch]@22 |
301 std::string *v71; // [sp+268h] [bp-8h]@8 | |
302 int a3; // [sp+26Fh] [bp-1h]@8 | |
303 | |
568 | 304 //v66 = a2; |
0 | 305 strcpy(byte_6BE3B0, pCurrentMapName); |
568 | 306 if (!_strcmpi(pCurrentMapName, "d05.blv")) // arena |
810 | 307 return; |
568 | 308 |
810 | 309 uncompressed_buff = (char*)malloc(1000000); |
310 pLodDirectory.Reset(); | |
0 | 311 pPositionX = pParty->vPosition.x; |
312 v51 = pParty->vPosition.y; | |
313 v62 = pParty->vPosition.z; | |
314 v53 = pParty->sRotationY; | |
315 v54 = pParty->sRotationX; | |
316 pParty->vPosition.x = pParty->vPrevPosition.x; | |
317 pParty->vPosition.y = pParty->vPrevPosition.z; | |
318 pParty->vPosition.z = pParty->vPrevPosition.y; | |
319 pParty->uFallStartY = pParty->vPrevPosition.y; | |
320 pParty->sRotationY = pParty->sPrevRotationY; | |
321 pParty->sRotationX = pParty->sPrevRotationX; | |
322 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
323 pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed; | |
324 else | |
810 | 325 pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed; |
0 | 326 pScreenshot = MakeScreenshot(150, 112); |
810 | 327 strcpy(pLodDirectory.pFilename, "image.pcx"); |
328 pRenderer->PackPCXpicture(pScreenshot, 150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize); | |
0 | 329 free(pScreenshot); |
151 | 330 if (pCurrentScreen == SCREEN_SAVEGAME) |
0 | 331 { |
568 | 332 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); |
333 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up)); | |
810 | 334 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[190]); |
335 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Ñîõðàíåíèå | |
336 text_pos = pFontSmallnum->AlignText_Center(186, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); | |
337 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, text_pos + 25, 259, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0); | |
338 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[165]); | |
339 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Ïîæàëóéñòà, ïîäîæäèòå | |
0 | 340 pRenderer->Present(); |
568 | 341 } |
342 | |
810 | 343 if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0)) |
0 | 344 { |
345 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d | |
346 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); | |
347 } | |
348 | |
349 assert(sizeof(SavegameHeader) == 100); | |
350 memset(header.pName, 0, 20); | |
351 memset(header.pLocationName, 0, 20); | |
352 memset(header.field_30, 0, 52); | |
353 strcpy(header.pLocationName, pCurrentMapName); | |
354 header.uWordTime = pParty->uTimePlayed; | |
810 | 355 strcpy(pLodDirectory.pFilename, "header.bin"); |
356 pLodDirectory.uDataSize = sizeof(SavegameHeader); | |
357 if (pNew_LOD->Write(&pLodDirectory, &header, 0)) | |
0 | 358 { |
359 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201); | |
360 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); | |
361 } | |
810 | 362 strcpy(pLodDirectory.pFilename, "party.bin"); |
363 pLodDirectory.uDataSize = sizeof(Party); //90680; | |
364 if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) ) | |
0 | 365 { |
366 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202); | |
367 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); | |
368 } | |
810 | 369 strcpy(pLodDirectory.pFilename, "clock.bin"); |
370 pLodDirectory.uDataSize =sizeof(Timer);// 40; | |
371 if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) ) | |
0 | 372 { |
373 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203); | |
374 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); | |
375 } | |
810 | 376 strcpy(pLodDirectory.pFilename, "overlay.bin"); |
377 pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008; | |
378 if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) ) | |
0 | 379 { |
380 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204); | |
381 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); | |
382 } | |
810 | 383 strcpy(pLodDirectory.pFilename, "npcdata.bin"); |
384 pLodDirectory.uDataSize = 501 * sizeof(NPCData); | |
385 assert(pLodDirectory.uDataSize == 38076); | |
386 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) ) | |
0 | 387 { |
388 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205); | |
389 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); | |
390 } | |
810 | 391 strcpy(pLodDirectory.pFilename, "npcgroup.bin"); |
392 pLodDirectory.uDataSize = 102; | |
393 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) ) | |
0 | 394 { |
395 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206); | |
396 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0); | |
397 } | |
398 for (int i = 1; i <= 4; ++i) // 4 - players | |
399 { | |
400 for (int j = 1; j <= 5; ++j) // 5 - images | |
401 { | |
402 sprintf(Str, "data\\lloyd%d%d.pcx", i, j); | |
403 v8 = fopen(Str, "rb"); | |
404 if ( v8 ) | |
405 { | |
406 __debugbreak(); | |
407 sprintf(Str, "lloyd%d%d.pcx", i, j); | |
408 fseek(v8, 0, 2); | |
810 | 409 pLodDirectory.uDataSize = ftell(v8); |
0 | 410 rewind(v8); |
810 | 411 fread(uncompressed_buff, pLodDirectory.uDataSize, 1, v8); |
412 strcpy((char *)&pLodDirectory, Str); | |
0 | 413 fclose(v8); |
414 remove(Str); | |
810 | 415 if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) ) |
0 | 416 { |
417 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207); | |
418 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); | |
419 Size = 5080748; | |
420 } | |
421 } | |
422 } | |
423 } | |
810 | 424 if ( !NotSaveWorld ) |
0 | 425 { |
79 | 426 //__debugbreak(); |
810 | 427 CompactLayingItemsList(); |
428 compressed_buf = (char*)malloc(1000000); | |
429 // v71 = (std::string *)compressed_buf; | |
814 | 430 Src.uVersion = 91969; |
431 Src.pMagic[0] = 'm'; | |
432 Src.pMagic[1] = 'v'; | |
433 Src.pMagic[2] = 'i'; | |
434 Src.pMagic[3] = 'i'; | |
435 Src.uCompressedSize = 0; | |
436 Src.uDecompressedSize = 0; | |
810 | 437 data_write_pos = uncompressed_buff; |
438 memcpy((void *)compressed_buf, &Src, 0x10); | |
0 | 439 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) |
440 { | |
441 pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces; | |
442 pIndoor->dlv.uNumBModels = 0; | |
443 pIndoor->dlv.uNumDecorations = uNumLevelDecorations; | |
810 | 444 memcpy(data_write_pos, &pIndoor->dlv, 0x28); |
445 data_write_pos += 40; | |
446 memcpy(data_write_pos, pIndoor->_visible_outlines, 0x36B); | |
447 data_write_pos += 875; | |
448 | |
449 for (int i = 0; i <(signed int)pIndoor->uNumFaces; ++i) | |
0 | 450 { |
810 | 451 memcpy(data_write_pos, &pIndoor->pFaces[i].uAttributes, 4); |
452 data_write_pos += 4; | |
0 | 453 } |
810 | 454 |
455 for (int i = 0; i <(signed int)uNumLevelDecorations; ++i) | |
0 | 456 { |
810 | 457 memcpy(data_write_pos, &pLevelDecorations[i].field_2, 2); |
458 | |
459 data_write_pos+= 2; | |
0 | 460 } |
810 | 461 memcpy(data_write_pos, &uNumActors, 4); |
462 data_write_pos += 4; | |
463 memcpy(data_write_pos, pActors, 836 * uNumActors); | |
464 data_write_pos += 836 * uNumActors; | |
465 memcpy(data_write_pos, &uNumSpriteObjects, 4); | |
466 data_write_pos += 4; | |
467 memcpy(data_write_pos, pSpriteObjects, 112 * uNumSpriteObjects); | |
468 data_write_pos += 112 * uNumSpriteObjects; | |
469 memcpy(data_write_pos, &uNumChests, 4); | |
470 data_write_pos += 4; | |
471 memcpy(data_write_pos, pChests, 5324 * uNumChests); | |
472 data_write_pos += 5324 * uNumChests; | |
473 memcpy(data_write_pos, pIndoor->pDoors, 0x3E80); | |
474 data_write_pos += 16000; | |
475 memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size); | |
476 data_write_pos += pIndoor->blv.uDoors_ddata_Size; | |
477 memcpy(data_write_pos, &stru_5E4C90, 0xC8); | |
478 data_write_pos += 200; | |
479 memcpy(data_write_pos, &pIndoor->stru1, 0x38); | |
480 data_write_pos += 56; | |
481 | |
0 | 482 } |
483 else | |
484 { | |
485 v18 = 0; | |
486 pOutdoor->ddm.uNumFacesInBModels = 0; | |
810 | 487 for (int i=0; i<pOutdoor->uNumBModels;++i) |
488 { | |
489 v18 +=pOutdoor->pBModels[i].uNumFaces; | |
490 } | |
491 pOutdoor->ddm.uNumFacesInBModels = v18; | |
0 | 492 pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels; |
493 pOutdoor->ddm.uNumDecorations = uNumLevelDecorations; | |
810 | 494 memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28 |
495 data_write_pos += sizeof(DDM_DLV_Header); | |
496 memcpy(data_write_pos, pOutdoor->uUndiscoveredArea, 0x3C8); | |
497 data_write_pos += 968; | |
498 memcpy(data_write_pos, pOutdoor->uDicovered_area, 0x3C8); | |
499 data_write_pos += 968; | |
0 | 500 if ( (signed int)pOutdoor->uNumBModels > 0 ) |
501 { | |
502 v23 = pOutdoor->pBModels; | |
503 v24 = 76; | |
79 | 504 for (int i = 0; i < (signed int)pOutdoor->uNumBModels ; ++i) |
0 | 505 { |
810 | 506 //v25 = v23[i].uNumFaces == 0;//*(int *)&v23->pModelName[v24] == 0; |
507 // v26 = v23[i].uNumFaces < 0;//*(int *)&v23->pModelName[v24] < 0; | |
508 if ( pOutdoor->pBModels[i].uNumFaces>0) | |
0 | 509 { |
510 v68 = 0; | |
79 | 511 for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j) |
0 | 512 { |
79 | 513 v38 = &(v23[i].pFaces[j].uAttributes); //(char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28; |
810 | 514 memcpy(data_write_pos, v38, 4); |
0 | 515 v23 = pOutdoor->pBModels; |
516 v68 += 154; | |
810 | 517 data_write_pos += 4; |
0 | 518 } |
519 } | |
520 v24 += 188; | |
521 } | |
522 } | |
523 if ( (signed int)uNumLevelDecorations > 0 ) | |
524 { | |
525 v66 = &pLevelDecorations[0].field_2; | |
568 | 526 for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i) |
0 | 527 { |
810 | 528 memcpy(data_write_pos, v66, 2); |
0 | 529 v66 += 16; |
810 | 530 data_write_pos += 2; |
0 | 531 } |
532 } | |
810 | 533 memcpy(data_write_pos, &uNumActors, 4); |
534 data_write_pos += 4; | |
535 memcpy(data_write_pos, pActors, 836 * uNumActors); | |
536 data_write_pos += 836 * uNumActors; | |
537 memcpy(data_write_pos, &uNumSpriteObjects, 4); | |
538 data_write_pos += 4; | |
539 memcpy(data_write_pos, pSpriteObjects, 112 * uNumSpriteObjects); | |
540 data_write_pos += 112 * uNumSpriteObjects; | |
541 memcpy(data_write_pos, &uNumChests, 4); | |
542 data_write_pos += 4; | |
543 memcpy(data_write_pos, pChests, 5324 * uNumChests); | |
544 data_write_pos += 5324 * uNumChests; | |
545 memcpy(data_write_pos, &stru_5E4C90, 0xC8); | |
546 data_write_pos += 200; | |
547 memcpy(data_write_pos, &pOutdoor->loc_time, 0x38); | |
548 data_write_pos += 56; | |
549 | |
550 //compressed_buf = (int)v71; | |
0 | 551 } |
552 strcpy(Source, pCurrentMapName); | |
79 | 553 _splitpath(Source, Drive, Dir, Filename, Ext); |
0 | 554 v48 = 100; |
810 | 555 Size = (int)data_write_pos - (int)uncompressed_buff; |
556 compressed_block_size = 999984; | |
557 LOBYTE(v33) = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size); | |
558 if ( v33 || (signed int)compressed_block_size > (signed int)Size ) | |
0 | 559 { |
810 | 560 memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size); |
561 compressed_block_size = Size; | |
0 | 562 } |
810 | 563 compressed_block_size += 16; |
814 | 564 memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4); |
565 memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4); | |
0 | 566 sprintf(Source, "%s%s", &Filename, &Ext); |
810 | 567 strcpy((char *)&pLodDirectory, Source); |
568 pLodDirectory.uDataSize = compressed_block_size; | |
569 if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) ) | |
0 | 570 { |
571 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 208); | |
572 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); | |
573 } | |
810 | 574 free((void *)compressed_buf); |
0 | 575 } |
810 | 576 free(uncompressed_buff); |
577 if ( IsAutoSAve ) | |
0 | 578 { |
579 if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) ) | |
580 { | |
581 v34 = GetLastError(); | |
582 FormatMessageA(0x1000, 0, v34, 0x400, &Buffer, 0x80, 0); | |
583 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 300); | |
584 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0); | |
585 } | |
586 } | |
587 pParty->vPosition.x = pPositionX; | |
588 pParty->vPosition.y = v51; | |
589 pParty->vPosition.z = v62; | |
590 pParty->uFallStartY = v62; | |
591 pParty->sRotationY = v53; | |
592 pParty->sRotationX = v54; | |
593 } | |
594 | |
595 | |
596 //----- (00460078) -------------------------------------------------------- | |
597 void __fastcall DoSavegame(unsigned int uSlot) | |
598 { | |
568 | 599 //unsigned int v1; // esi@1 |
600 //int v2; // esi@2 | |
557 | 601 //RGBTexture *v3; // ebx@3 |
0 | 602 int bNotArena; // [sp+2Ch] [bp-8h]@1 |
568 | 603 //unsigned int v6; // [sp+30h] [bp-4h]@1 |
0 | 604 |
165 | 605 //__debugbreak(); |
0 | 606 |
568 | 607 //v1 = uSlot; |
608 //v6 = uSlot; | |
0 | 609 bNotArena = _strcmpi(pCurrentMapName, "d05.blv"); |
610 if ( bNotArena ) | |
611 { | |
612 LOD::Directory pDir; // [sp+Ch] [bp-28h]@2 | |
613 SaveGame(0, 0); | |
568 | 614 //v2 = 100 * v1; |
615 strcpy(pSavegameHeader[uSlot].pLocationName, pCurrentMapName); | |
616 pSavegameHeader[uSlot].uWordTime = pParty->uTimePlayed; | |
617 strcpy(pDir.pFilename, "header.bin"); | |
0 | 618 pDir.uDataSize = 100; |
568 | 619 pNew_LOD->Write(&pDir, &pSavegameHeader[uSlot], 0); |
620 sprintf(pTmpBuf, "saves\\save%03d.mm7", uSlot); | |
0 | 621 pNew_LOD->CloseWriteFile(); |
622 CopyFileA("data\\new.lod", pTmpBuf, 0); | |
623 } | |
624 GUI_UpdateWindows(); | |
625 pGUIWindow_CurrentMenu->Release(); | |
151 | 626 pCurrentScreen = SCREEN_GAME; |
557 | 627 //v3 = pSavegameThumbnails; |
0 | 628 viewparams->bRedrawGameUI = 1; |
568 | 629 for (uint i = 0; i < 45; i++) |
557 | 630 pSavegameThumbnails[i].Release(); |
631 //while ( (signed int)v3 < (signed int)&unk_6A0758 ); | |
0 | 632 if ( bNotArena ) |
633 pNew_LOD->_4621A7(); | |
634 else | |
635 ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena" | |
636 pIcons_LOD->_4355F7(); | |
637 pEventTimer->Resume(); | |
638 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!" | |
568 | 639 viewparams->bRedrawGameUI = true; |
0 | 640 } |
641 // 4E28F8: using guessed type int pCurrentScreen; | |
642 | |
643 | |
644 | |
645 | |
646 | |
647 | |
648 | |
649 | |
650 | |
651 | |
652 | |
653 //----- (0045E297) -------------------------------------------------------- | |
654 void SavegameList::Initialize(unsigned int bHideEmptySlots) | |
655 { | |
382 | 656 memset(pSavegameList, 0, 0x3138); |
657 // Reset(); | |
4 | 658 uNumSavegameFiles = 0; |
0 | 659 |
660 _chdir("saves"); | |
661 { | |
4 | 662 if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7 |
382 | 663 strcpy(pSavegameList->pFileList[uNumSavegameFiles++].pSaveFileName, pGlobalTXT_LocalizationStrings[613]); |
0 | 664 |
665 for (uint i = 0; i < 40; ++i) | |
666 { | |
667 sprintf(pTmpBuf, "save%03d.mm7", i); | |
668 if (_access(pTmpBuf, 0) == -1) | |
669 continue; | |
670 | |
671 uint idx = i; | |
672 if (!bHideEmptySlots) | |
673 idx = uNumSavegameFiles; | |
382 | 674 strcpy(pSavegameList->pFileList[idx].pSaveFileName, pTmpBuf); |
0 | 675 |
676 ++uNumSavegameFiles; | |
677 } | |
678 } | |
679 _chdir(".."); | |
680 } |