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