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