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