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