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];
|
94
|
30 struct RGBTexture pSavegameThumbnails[45];
|
|
31 SavegameHeader pSavegameHeader[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
|
110
|
301
|
26
|
302 v66 = a2;
|
76
|
303 //v64 = (std::string *)a1;
|
26
|
304 strcpy(byte_6BE3B0, pCurrentMapName);
|
76
|
305 if (!_strcmpi(pCurrentMapName, "d05.blv"))
|
|
306 return false;
|
|
307 DstBuf = malloc(0xF4240u);
|
|
308 pDir.Reset();
|
26
|
309 v52 = pParty->vPosition.x;
|
58
|
310 v51 = pParty->vPosition.y;
|
|
311 v62 = pParty->vPosition.z;
|
26
|
312 v53 = pParty->sRotationY;
|
|
313 v54 = pParty->sRotationX;
|
76
|
314 pParty->vPosition.x = pParty->vPrevPosition.x;
|
|
315 pParty->vPosition.y = pParty->vPrevPosition.z;
|
|
316 pParty->vPosition.z = pParty->vPrevPosition.y;
|
|
317 pParty->uFallStartY = pParty->vPrevPosition.y;
|
|
318 pParty->sRotationY = pParty->sPrevRotationY;
|
|
319 pParty->sRotationX = pParty->sPrevRotationX;
|
|
320 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
321 pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed;
|
|
322 else
|
|
323 pOutdoor->uLastVisitDay = pParty->uTimePlayed;
|
|
324 v3 = MakeScreenshot(150, 112);
|
110
|
325 strcpy(pDir.pFilename, "image.pcx");
|
|
326 pRenderer->_49F5A2((int)v3, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
|
76
|
327 free(v3);
|
110
|
328 if ( pCurrentScreen == 11 )//Save
|
26
|
329 {
|
110
|
330 pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
|
|
331 pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0));
|
26
|
332 v4 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[190]);
|
110
|
333 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //
|
|
334 v5 = pFontSmallnum->AlignText_Center(0xBAu, (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
|
|
335 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot), 185, 0);
|
26
|
336 v6 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[165]);
|
110
|
337 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //,
|
26
|
338 pRenderer->Present();
|
|
339 }
|
|
340 if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
|
|
341 {
|
110
|
342 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); // ! Code=%d
|
|
343 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
|
26
|
344 }
|
110
|
345 else
|
26
|
346 {
|
|
347 v7 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp";
|
|
348 }
|
|
349 strcpy(Dest, pCurrentMapName);
|
|
350 v45 = pParty->uTimePlayed;
|
|
351 strcpy((char *)&pDir, "header.bin");
|
|
352 pDir.uDataSize = 100;
|
|
353 if ( pNew_LOD->Write(&pDir, &v43, 0) )
|
|
354 {
|
|
355 v39 = 201;
|
107
|
356 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201);
|
26
|
357 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
|
|
358 }
|
|
359 strcpy((char *)&pDir, "party.bin");
|
|
360 pDir.uDataSize = 90680;
|
|
361 if ( pNew_LOD->Write(&pDir, &pParty, 0) )
|
|
362 {
|
|
363 v39 = 202;
|
107
|
364 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202);
|
26
|
365 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
|
|
366 }
|
110
|
367 strcpy((char *)&pDir, "clock.bin");
|
26
|
368 pDir.uDataSize = 40;
|
|
369 if ( pNew_LOD->Write(&pDir, &pEventTimer, 0) )
|
|
370 {
|
|
371 v39 = 203;
|
107
|
372 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203);
|
26
|
373 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
|
|
374 }
|
|
375 strcpy((char *)&pDir, "overlay.bin");
|
|
376 pDir.uDataSize = 1008;
|
|
377 if ( pNew_LOD->Write(&pDir, &pOtherOverlayList, 0) )
|
|
378 {
|
|
379 v39 = 204;
|
107
|
380 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204);
|
26
|
381 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
|
|
382 }
|
|
383 strcpy((char *)&pDir, "npcdata.bin");
|
|
384 pDir.uDataSize = 38076;
|
|
385 if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) )
|
|
386 {
|
|
387 v39 = 205;
|
107
|
388 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205);
|
26
|
389 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
|
|
390 }
|
|
391 strcpy((char *)&pDir, "npcgroup.bin");
|
|
392 pDir.uDataSize = 102;
|
|
393 if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) )
|
|
394 {
|
|
395 v39 = 206;
|
107
|
396 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206);
|
26
|
397 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
|
|
398 }
|
|
399 v70 = 1;
|
|
400 do
|
|
401 {
|
|
402 v69 = 1;
|
|
403 do
|
|
404 {
|
|
405 v39 = v69;
|
|
406 v38 = (const char *)v70;
|
80
|
407 sprintf(Str, "data\\lloyd%d%d.pcx", v70, v69);
|
26
|
408 v8 = fopen(Str, "rb");
|
|
409 if ( v8 )
|
|
410 {
|
|
411 v39 = v69;
|
|
412 v38 = (const char *)v70;
|
80
|
413 sprintf(Str, "lloyd%d%d.pcx", v70, v69);
|
26
|
414 fseek(v8, 0, 2);
|
|
415 pDir.uDataSize = ftell(v8);
|
|
416 rewind(v8);
|
|
417 fread(DstBuf, pDir.uDataSize, 1u, v8);
|
|
418 strcpy((char *)&pDir, Str);
|
|
419 fclose(v8);
|
|
420 remove(Str);
|
|
421 if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
|
|
422 {
|
|
423 v39 = 207;
|
80
|
424 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207);
|
26
|
425 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
|
|
426 Size = 5080748;
|
|
427 }
|
|
428 }
|
|
429 ++v69;
|
|
430 }
|
|
431 while ( (signed int)v69 <= 5 );
|
|
432 ++v70;
|
|
433 }
|
|
434 while ( v70 <= 4 );
|
76
|
435 if ( !a2 )
|
26
|
436 {
|
|
437 sub_42FA22_mess_with_laying_item_list();
|
|
438 v9 = (int)malloc(0xF4240u);
|
|
439 v71 = (std::string *)v9;
|
|
440 Src = 91969;
|
|
441 v56 = 109;
|
|
442 v57 = 118;
|
|
443 v58 = 105;
|
|
444 v59 = 105;
|
|
445 v60 = 0;
|
|
446 v61 = 0;
|
|
447 memcpy((void *)v9, &Src, 0x10u);
|
|
448 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
449 {
|
|
450 v10 = DstBuf;
|
|
451 pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces;
|
|
452 pIndoor->dlv.uNumBModels = 0;
|
|
453 pIndoor->dlv.uNumDecorations = uNumLevelDecorations;
|
|
454 memcpy(DstBuf, &pIndoor->dlv, 0x28u);
|
|
455 v10 = (char *)v10 + 40;
|
|
456 memcpy(v10, pIndoor->_visible_outlines, 0x36Bu);
|
|
457 v11 = (char *)v10 + 875;
|
|
458 v70 = 0;
|
|
459 if ( (signed int)pIndoor->uNumFaces > 0 )
|
|
460 {
|
|
461 v68 = 0;
|
|
462 do
|
|
463 {
|
|
464 v38 = (char *)v68 + (unsigned int)pIndoor->pFaces + 44;
|
|
465 memcpy(v11, v38, 4u);
|
|
466 v68 += 48;
|
|
467 v11 = (char *)v11 + 4;
|
|
468 ++v70;
|
|
469 }
|
|
470 while ( v70 < (signed int)pIndoor->uNumFaces );
|
|
471 }
|
|
472 v70 = 0;
|
|
473 if ( (signed int)uNumLevelDecorations > 0 )
|
|
474 {
|
|
475 v68 = &pLevelDecorations[0].field_2;
|
|
476 do
|
|
477 {
|
|
478 memcpy(v11, v68, 2u);
|
|
479 v68 += 16;
|
|
480 v11 = (char *)v11 + 2;
|
|
481 ++v70;
|
|
482 }
|
|
483 while ( v70 < (signed int)uNumLevelDecorations );
|
|
484 }
|
|
485 memcpy(v11, &uNumActors, 4u);
|
|
486 v12 = (char *)v11 + 4;
|
|
487 memcpy(v12, pActors, 836 * uNumActors);
|
|
488 v13 = (char *)v12 + 836 * uNumActors;
|
|
489 memcpy(v13, &uNumLayingItems, 4u);
|
|
490 v13 = (char *)v13 + 4;
|
|
491 memcpy(v13, pLayingItems, 112 * uNumLayingItems);
|
|
492 v14 = (char *)v13 + 112 * uNumLayingItems;
|
|
493 memcpy(v14, &uNumChests, 4u);
|
|
494 v14 = (char *)v14 + 4;
|
|
495 memcpy(v14, pChests, 5324 * uNumChests);
|
|
496 v15 = (char *)v14 + 5324 * uNumChests;
|
|
497 memcpy(v15, pIndoor->pDoors, 0x3E80u);
|
|
498 v15 = (char *)v15 + 16000;
|
|
499 memcpy(v15, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size);
|
|
500 v16 = (char *)v15 + pIndoor->blv.uDoors_ddata_Size;
|
|
501 memcpy(v16, &stru_5E4C90, 0xC8u);
|
|
502 v17 = (int)((char *)v16 + 200);
|
28
|
503 memcpy((void *)v17, &pIndoor->stru1, 0x38u);
|
26
|
504 }
|
|
505 else
|
|
506 {
|
|
507 v18 = 0;
|
|
508 pOutdoor->ddm.uNumFacesInBModels = 0;
|
|
509 if ( (signed int)pOutdoor->uNumBModels > 0 )
|
|
510 {
|
|
511 v19 = pOutdoor->uNumBModels;
|
|
512 v20 = (char *)&pOutdoor->pBModels->uNumFaces;
|
|
513 do
|
|
514 {
|
|
515 v18 += *(int *)v20;
|
|
516 v20 += 188;
|
|
517 --v19;
|
|
518 pOutdoor->ddm.uNumFacesInBModels = v18;
|
|
519 }
|
|
520 while ( v19 );
|
|
521 }
|
|
522 v21 = DstBuf;
|
|
523 pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels;
|
|
524 pOutdoor->ddm.uNumDecorations = uNumLevelDecorations;
|
|
525 memcpy(DstBuf, &pOutdoor->ddm, 0x28u);
|
|
526 v21 = (char *)v21 + 40;
|
|
527 memcpy(v21, pOutdoor->array_528, 0x3C8u);
|
|
528 v21 = (char *)v21 + 968;
|
|
529 memcpy(v21, pOutdoor->array_8F0, 0x3C8u);
|
|
530 v22 = (char *)v21 + 968;
|
|
531 v70 = 0;
|
|
532 if ( (signed int)pOutdoor->uNumBModels > 0 )
|
|
533 {
|
|
534 v23 = pOutdoor->pBModels;
|
|
535 v24 = 76;
|
|
536 do
|
|
537 {
|
|
538 v25 = *(int *)&v23->pModelName[v24] == 0;
|
|
539 v26 = *(int *)&v23->pModelName[v24] < 0;
|
|
540 v66 = 0;
|
|
541 if ( !(v26 | v25) )
|
|
542 {
|
|
543 v68 = 0;
|
|
544 do
|
|
545 {
|
|
546 v38 = (char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28;
|
|
547 memcpy(v22, v38, 4u);
|
|
548 v23 = pOutdoor->pBModels;
|
|
549 v68 += 154;
|
|
550 v22 = (char *)v22 + 4;
|
|
551 v66 = (__int16 *)((char *)v66 + 1);
|
|
552 }
|
|
553 while ( (signed int)v66 < *(int *)&pOutdoor->pBModels->pModelName[v24] );
|
|
554 }
|
|
555 ++v70;
|
|
556 v24 += 188;
|
|
557 }
|
|
558 while ( v70 < (signed int)pOutdoor->uNumBModels );
|
|
559 }
|
|
560 v27 = 0;
|
|
561 if ( (signed int)uNumLevelDecorations > 0 )
|
|
562 {
|
|
563 v66 = &pLevelDecorations[0].field_2;
|
|
564 do
|
|
565 {
|
|
566 memcpy(v22, v66, 2u);
|
|
567 v66 += 16;
|
|
568 v22 = (char *)v22 + 2;
|
|
569 ++v27;
|
|
570 }
|
|
571 while ( v27 < (signed int)uNumLevelDecorations );
|
|
572 }
|
|
573 memcpy(v22, &uNumActors, 4u);
|
|
574 v28 = (char *)v22 + 4;
|
|
575 memcpy(v28, pActors, 836 * uNumActors);
|
|
576 v29 = (char *)v28 + 836 * uNumActors;
|
|
577 memcpy(v29, &uNumLayingItems, 4u);
|
|
578 v29 = (char *)v29 + 4;
|
|
579 memcpy(v29, pLayingItems, 112 * uNumLayingItems);
|
|
580 v30 = (char *)v29 + 112 * uNumLayingItems;
|
|
581 memcpy(v30, &uNumChests, 4u);
|
|
582 v30 = (char *)v30 + 4;
|
|
583 memcpy(v30, pChests, 5324 * uNumChests);
|
|
584 v31 = (char *)v30 + 5324 * uNumChests;
|
|
585 memcpy(v31, &stru_5E4C90, 0xC8u);
|
|
586 v17 = (int)((char *)v31 + 200);
|
|
587 memcpy((void *)v17, &pOutdoor->uLastVisitDay, 0x38u);
|
|
588 v9 = (int)v71;
|
|
589 }
|
|
590 v32 = v17 + 56;
|
|
591 strcpy(Source, pCurrentMapName);
|
|
592 _splitpath(Source, &Drive, &Dir, &Filename, &Ext);
|
|
593 v48 = 100;
|
|
594 Size = v32 - (int)DstBuf;
|
|
595 v69 = 999984;
|
|
596 LOBYTE(v33) = zlib::MemZip((char *)v9 + 16, (unsigned int *)&v69, DstBuf, v32 - (int)DstBuf);
|
|
597 if ( v33 || (signed int)v69 > (signed int)Size )
|
|
598 {
|
|
599 memcpy((void *)(v9 + 16), DstBuf, Size);
|
|
600 v69 = Size;
|
|
601 }
|
|
602 v69 += 16;
|
|
603 memcpy((void *)(v9 + 8), &v69, 4u);
|
|
604 memcpy((void *)(v9 + 12), &Size, 4u);
|
107
|
605 sprintf(Source, "%s%s", &Filename, &Ext);
|
26
|
606 strcpy((char *)&pDir, Source);
|
|
607 pDir.uDataSize = v69;
|
|
608 if ( pNew_LOD->Write(&pDir, (const void *)v9, 0) )
|
|
609 {
|
|
610 v39 = 208;
|
107
|
611 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 208);
|
26
|
612 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
|
|
613 }
|
|
614 free((void *)v9);
|
|
615 }
|
|
616 free(DstBuf);
|
76
|
617 if ( a1 )
|
26
|
618 {
|
|
619 if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) )
|
|
620 {
|
|
621 v34 = GetLastError();
|
|
622 FormatMessageA(0x1000u, 0, v34, 0x400u, &Buffer, 0x80u, 0);
|
|
623 v39 = 300;
|
107
|
624 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 300);
|
26
|
625 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
|
|
626 }
|
|
627 }
|
|
628 pParty->vPosition.x = v52;
|
58
|
629 pParty->vPosition.y = v51;
|
|
630 pParty->vPosition.z = v62;
|
26
|
631 pParty->uFallStartY = v62;
|
|
632 pParty->sRotationY = v53;
|
|
633 result = v54;
|
|
634 pParty->sRotationX = v54;
|
|
635 return result;
|
|
636 }
|
|
637
|
|
638
|
|
639 //----- (00460078) --------------------------------------------------------
|
|
640 void __fastcall DoSavegame(unsigned int uSlot)
|
|
641 {
|
|
642 unsigned int v1; // esi@1
|
|
643 int v2; // esi@2
|
|
644 RGBTexture *v3; // ebx@3
|
|
645 int bNotArena; // [sp+2Ch] [bp-8h]@1
|
|
646 unsigned int v6; // [sp+30h] [bp-4h]@1
|
|
647
|
|
648 v1 = uSlot;
|
|
649 v6 = uSlot;
|
|
650 bNotArena = _strcmpi(pCurrentMapName, "d05.blv");
|
|
651 if ( bNotArena )
|
|
652 {
|
|
653 LOD::Directory pDir; // [sp+Ch] [bp-28h]@2
|
|
654 SaveGame(0, 0);
|
|
655 v2 = 100 * v1;
|
|
656 strcpy(&pSavegameHeader->pLocationName[v2], pCurrentMapName);
|
|
657 *(int *)((char *)&pSavegameHeader->uWordTime + v2) = LODWORD(pParty->uTimePlayed);
|
|
658 *(int *)((char *)&pSavegameHeader->uWordTime + v2 + 4) = HIDWORD(pParty->uTimePlayed);
|
|
659 strcpy((char *)&pDir, "header.bin");
|
|
660 pDir.uDataSize = 100;
|
|
661 pNew_LOD->Write(&pDir, (char *)&pSavegameHeader + v2, 0);
|
107
|
662 sprintf(pTmpBuf, "saves\\save%03d.mm7", v6);
|
26
|
663 pNew_LOD->CloseWriteFile();
|
|
664 CopyFileA("data\\new.lod", pTmpBuf, 0);
|
|
665 }
|
|
666 GUI_UpdateWindows();
|
|
667 pGUIWindow_CurrentMenu->Release();
|
44
|
668 pCurrentScreen = 0;
|
26
|
669 v3 = pSavegameThumbnails;
|
|
670 viewparams->bRedrawGameUI = 1;
|
|
671 do
|
|
672 {
|
|
673 v3->Release();
|
|
674 ++v3;
|
|
675 }
|
|
676 while ( (signed int)v3 < (signed int)&unk_6A0758 );
|
|
677 if ( bNotArena )
|
|
678 pNew_LOD->_4621A7();
|
|
679 else
|
|
680 ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena"
|
|
681 pIcons_LOD->_4355F7();
|
|
682 pEventTimer->Resume();
|
|
683 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!"
|
|
684 viewparams->bRedrawGameUI = 1;
|
|
685 }
|
44
|
686 // 4E28F8: using guessed type int pCurrentScreen;
|
26
|
687
|
|
688
|
|
689
|
|
690
|
|
691
|
|
692
|
|
693
|
|
694
|
|
695
|
|
696
|
|
697
|
0
|
698 //----- (0045E297) --------------------------------------------------------
|
3
|
699 void SavegameList::Initialize(unsigned int bHideEmptySlots)
|
0
|
700 {
|
|
701 uNumSavegameFiles = 0;
|
3
|
702
|
|
703 _chdir("saves");
|
0
|
704 {
|
3
|
705 if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 )
|
|
706 strcpy(pSavesNames[uNumSavegameFiles++], pGlobalTXT_LocalizationStrings[613]);
|
|
707
|
|
708 for (uint i = 0; i < 40; ++i)
|
0
|
709 {
|
3
|
710 sprintf(pTmpBuf, "save%03d.mm7", i);
|
|
711 if (_access(pTmpBuf, 0) == -1)
|
|
712 continue;
|
|
713
|
|
714 uint idx = i;
|
|
715 if (!bHideEmptySlots)
|
|
716 idx = uNumSavegameFiles;
|
|
717 strcpy(pSavesNames[idx], pTmpBuf);
|
|
718
|
0
|
719 ++uNumSavegameFiles;
|
|
720 }
|
|
721 }
|
|
722 _chdir("..");
|
|
723 } |