0
|
1 #include <io.h>
|
|
2 #include <direct.h>
|
|
3 #include <assert.h>
|
|
4
|
|
5 #include "SaveLoad.h"
|
|
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"
|
|
21
|
|
22 #include "mm7_data.h"
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
|
28 struct SavegameList *pSavegameList = new SavegameList;
|
|
29 unsigned int uNumSavegameFiles;
|
|
30 unsigned int pSavegameUsedSlots[45];
|
|
31 struct RGBTexture pSavegameThumbnails[45];
|
|
32 SavegameHeader pSavegameHeader[45];
|
|
33
|
|
34
|
|
35
|
|
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
|
|
50 SavegameHeader header; // [sp+Ch] [bp-E4h]@23
|
|
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 }
|
|
101 assert(sizeof(SavegameHeader) == 100);
|
|
102 fread(&header, sizeof(SavegameHeader), 1, f);
|
|
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();
|
|
194 pCurrentScreen = 0;
|
|
195
|
|
196 viewparams->bRedrawGameUI = true;
|
|
197
|
|
198 SetUserInterface(pParty->uAlignment, true);
|
|
199
|
|
200 pEventTimer->Resume();
|
|
201 pEventTimer->StopGameTime();
|
|
202
|
|
203 v25 = pGames_LOD->DoesContainerExist(header.pLocationName);
|
|
204 sprintf(pTmpBuf, "levels\\%s", header.pLocationName);
|
|
205 v26 = _access(pTmpBuf, 4) != -1;
|
|
206 if ( !v25 && !v26 )
|
|
207 {
|
|
208 sprintf(pTmpBuf, "Unable to find: %s!", header.pLocationName);
|
|
209 Abortf(pTmpBuf);
|
|
210 }
|
|
211
|
|
212 strcpy(pCurrentMapName, header.pLocationName);
|
|
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();
|
|
224 bFlashQuestBook = false;
|
|
225 viewparams->bRedrawGameUI = true;
|
|
226 }
|
|
227
|
|
228
|
|
229 //----- (0045F469) --------------------------------------------------------
|
|
230 int __fastcall SaveGame(int a1, __int16 *a2)
|
|
231 {
|
|
232 int result; // eax@1
|
|
233 void *pScreenshot; // edi@5
|
|
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
|
79
|
250 BSPModel *v20; // edx@39
|
0
|
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
|
|
265 //std::string v35; // [sp-18h] [bp-288h]@8
|
|
266 const char *v36; // [sp-10h] [bp-280h]@6
|
|
267 const char *v37; // [sp-Ch] [bp-27Ch]@6
|
79
|
268 unsigned int *v38; // [sp-8h] [bp-278h]@8
|
0
|
269 CHAR Buffer; // [sp+Ch] [bp-264h]@59
|
79
|
270 char Dir[255]; // [sp+8Ch] [bp-1E4h]@51
|
|
271 char Drive[255]; // [sp+ACh] [bp-1C4h]@51
|
0
|
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
|
79
|
276 char Filename[255]; // [sp+130h] [bp-140h]@51
|
|
277 char Ext[255]; // [sp+150h] [bp-120h]@51
|
0
|
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
|
|
282 int pPositionX; // [sp+20Ch] [bp-64h]@2
|
|
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
|
|
302
|
|
303 v66 = a2;
|
|
304 strcpy(byte_6BE3B0, pCurrentMapName);
|
|
305 if (!_strcmpi(pCurrentMapName, "d05.blv"))
|
|
306 return false;
|
|
307 DstBuf = malloc(0xF4240);
|
|
308 pDir.Reset();
|
|
309 pPositionX = pParty->vPosition.x;
|
|
310 v51 = pParty->vPosition.y;
|
|
311 v62 = pParty->vPosition.z;
|
|
312 v53 = pParty->sRotationY;
|
|
313 v54 = pParty->sRotationX;
|
|
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 pScreenshot = MakeScreenshot(150, 112);
|
|
325 strcpy(pDir.pFilename, "image.pcx");
|
|
326 pRenderer->_49F5A2((int)pScreenshot, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
|
|
327 free(pScreenshot);
|
|
328 if (pCurrentScreen == 11) //SaveScreen
|
|
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 }
|
|
340 if (pNew_LOD->Write(&pDir, DstBuf, 0))
|
|
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 }
|
|
345
|
|
346 assert(sizeof(SavegameHeader) == 100);
|
|
347 memset(header.pName, 0, 20);
|
|
348 memset(header.pLocationName, 0, 20);
|
|
349 memset(header.field_30, 0, 52);
|
|
350 strcpy(header.pLocationName, pCurrentMapName);
|
|
351 header.uWordTime = pParty->uTimePlayed;
|
|
352 strcpy(pDir.pFilename, "header.bin");
|
|
353 pDir.uDataSize = sizeof(SavegameHeader);
|
|
354 if (pNew_LOD->Write(&pDir, &header, 0))
|
|
355 {
|
|
356 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201);
|
|
357 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
|
|
358 }
|
|
359 strcpy(pDir.pFilename, "party.bin");
|
|
360 pDir.uDataSize = 90680;
|
|
361 if ( pNew_LOD->Write(&pDir, pParty, 0) )
|
|
362 {
|
|
363 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202);
|
|
364 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
|
|
365 }
|
|
366 strcpy(pDir.pFilename, "clock.bin");
|
|
367 pDir.uDataSize = 40;
|
|
368 if ( pNew_LOD->Write(&pDir, pEventTimer, 0) )
|
|
369 {
|
|
370 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203);
|
|
371 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
|
|
372 }
|
|
373 strcpy(pDir.pFilename, "overlay.bin");
|
|
374 pDir.uDataSize = 1008;
|
|
375 if ( pNew_LOD->Write(&pDir, pOtherOverlayList, 0) )
|
|
376 {
|
|
377 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204);
|
|
378 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
|
|
379 }
|
|
380 strcpy(pDir.pFilename, "npcdata.bin");
|
|
381 pDir.uDataSize = 38076;
|
|
382 if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) )
|
|
383 {
|
|
384 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205);
|
|
385 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
|
|
386 }
|
|
387 strcpy(pDir.pFilename, "npcgroup.bin");
|
|
388 pDir.uDataSize = 102;
|
|
389 if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) )
|
|
390 {
|
|
391 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206);
|
|
392 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
|
|
393 }
|
|
394 for (int i = 1; i <= 4; ++i) // 4 - players
|
|
395 {
|
|
396 for (int j = 1; j <= 5; ++j) // 5 - images
|
|
397 {
|
|
398 sprintf(Str, "data\\lloyd%d%d.pcx", i, j);
|
|
399 v8 = fopen(Str, "rb");
|
|
400 if ( v8 )
|
|
401 {
|
|
402 __debugbreak();
|
|
403 sprintf(Str, "lloyd%d%d.pcx", i, j);
|
|
404 fseek(v8, 0, 2);
|
|
405 pDir.uDataSize = ftell(v8);
|
|
406 rewind(v8);
|
|
407 fread(DstBuf, pDir.uDataSize, 1, v8);
|
|
408 strcpy((char *)&pDir, Str);
|
|
409 fclose(v8);
|
|
410 remove(Str);
|
|
411 if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
|
|
412 {
|
|
413 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207);
|
|
414 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
|
|
415 Size = 5080748;
|
|
416 }
|
|
417 }
|
|
418 }
|
|
419 }
|
|
420 if ( !a2 )
|
|
421 {
|
79
|
422 //__debugbreak();
|
0
|
423 sub_42FA22_mess_with_laying_item_list();
|
|
424 v9 = (int)malloc(0xF4240);
|
|
425 v71 = (std::string *)v9;
|
|
426 Src = 91969;
|
|
427 v56 = 109;
|
|
428 v57 = 118;
|
|
429 v58 = 105;
|
|
430 v59 = 105;
|
|
431 v60 = 0;
|
|
432 v61 = 0;
|
|
433 memcpy((void *)v9, &Src, 0x10);
|
|
434 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
435 {
|
|
436 __debugbreak();
|
|
437 pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces;
|
|
438 pIndoor->dlv.uNumBModels = 0;
|
|
439 pIndoor->dlv.uNumDecorations = uNumLevelDecorations;
|
|
440 memcpy(DstBuf, &pIndoor->dlv, 0x28);
|
|
441 v10 = (char *)DstBuf + 40;
|
|
442 memcpy(v10, pIndoor->_visible_outlines, 0x36B);
|
|
443 v11 = (char *)v10 + 875;
|
|
444 if ( (signed int)pIndoor->uNumFaces > 0 )
|
|
445 {
|
|
446 v68 = 0;
|
|
447 for (int i = 0; i <= (signed int)pIndoor->uNumFaces; ++i)
|
|
448 {
|
79
|
449 v38 = &pIndoor->pFaces[i].uAttributes;//(char *)v68 + (unsigned int)pIndoor->pFaces + 44;
|
0
|
450 memcpy(v11, v38, 4);
|
|
451 v68 += 48;
|
|
452 v11 = (char *)v11 + 4;
|
|
453 }
|
|
454 }
|
|
455 if ( (signed int)uNumLevelDecorations > 0 )
|
|
456 {
|
|
457 v68 = &pLevelDecorations[0].field_2;
|
|
458 for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i)
|
|
459 {
|
|
460 memcpy(v11, v68, 2);
|
|
461 v68 += 16;
|
|
462 v11 = (char *)v11 + 2;
|
|
463 }
|
|
464 }
|
|
465 memcpy(v11, &uNumActors, 4);
|
|
466 v12 = (char *)v11 + 4;
|
|
467 memcpy(v12, pActors, 836 * uNumActors);
|
|
468 v13 = (char *)v12 + 836 * uNumActors;
|
|
469 memcpy(v13, &uNumLayingItems, 4);
|
|
470 v13 = (char *)v13 + 4;
|
|
471 memcpy(v13, pLayingItems, 112 * uNumLayingItems);
|
|
472 v14 = (char *)v13 + 112 * uNumLayingItems;
|
|
473 memcpy(v14, &uNumChests, 4);
|
|
474 v14 = (char *)v14 + 4;
|
|
475 memcpy(v14, pChests, 5324 * uNumChests);
|
|
476 v15 = (char *)v14 + 5324 * uNumChests;
|
|
477 memcpy(v15, pIndoor->pDoors, 0x3E80);
|
|
478 v15 = (char *)v15 + 16000;
|
|
479 memcpy(v15, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size);
|
|
480 v16 = (char *)v15 + pIndoor->blv.uDoors_ddata_Size;
|
|
481 memcpy(v16, &stru_5E4C90, 0xC8);
|
|
482 v17 = (int)((char *)v16 + 200);
|
|
483 memcpy((void *)v17, &pIndoor->stru1, 0x38);
|
|
484 }
|
|
485 else
|
|
486 {
|
|
487 v18 = 0;
|
|
488 pOutdoor->ddm.uNumFacesInBModels = 0;
|
|
489 if ( (signed int)pOutdoor->uNumBModels > 0 )
|
|
490 {
|
|
491 v19 = pOutdoor->uNumBModels;
|
79
|
492 v20 = &pOutdoor->pBModels[0];
|
0
|
493 do
|
|
494 {
|
79
|
495 v18 += v20->uNumFaces;
|
|
496 ++v20;
|
0
|
497 --v19;
|
|
498 pOutdoor->ddm.uNumFacesInBModels = v18;
|
|
499 }
|
|
500 while ( v19 );
|
|
501 }
|
|
502 v21 = DstBuf;
|
|
503 pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels;
|
|
504 pOutdoor->ddm.uNumDecorations = uNumLevelDecorations;
|
|
505 memcpy(DstBuf, &pOutdoor->ddm, 0x28);
|
|
506 v21 = (char *)v21 + 40;
|
|
507 memcpy(v21, pOutdoor->array_528, 0x3C8);
|
|
508 v21 = (char *)v21 + 968;
|
|
509 memcpy(v21, pOutdoor->array_8F0, 0x3C8);
|
|
510 v22 = (char *)v21 + 968;
|
|
511 if ( (signed int)pOutdoor->uNumBModels > 0 )
|
|
512 {
|
|
513 v23 = pOutdoor->pBModels;
|
|
514 v24 = 76;
|
79
|
515 for (int i = 0; i < (signed int)pOutdoor->uNumBModels ; ++i)
|
0
|
516 {
|
79
|
517 v25 = v23[i].uNumFaces == 0;//*(int *)&v23->pModelName[v24] == 0;
|
|
518 v26 = v23[i].uNumFaces < 0;//*(int *)&v23->pModelName[v24] < 0;
|
0
|
519 if ( !(v26 | v25) )
|
|
520 {
|
|
521 v68 = 0;
|
79
|
522 for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j)
|
0
|
523 {
|
79
|
524 v38 = &(v23[i].pFaces[j].uAttributes); //(char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28;
|
0
|
525 memcpy(v22, v38, 4);
|
|
526 v23 = pOutdoor->pBModels;
|
|
527 v68 += 154;
|
|
528 v22 = (char *)v22 + 4;
|
|
529 }
|
|
530 }
|
|
531 v24 += 188;
|
|
532 }
|
|
533 }
|
|
534 if ( (signed int)uNumLevelDecorations > 0 )
|
|
535 {
|
|
536 v66 = &pLevelDecorations[0].field_2;
|
|
537 for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i)
|
|
538 {
|
|
539 memcpy(v22, v66, 2);
|
|
540 v66 += 16;
|
|
541 v22 = (char *)v22 + 2;
|
|
542 }
|
|
543 }
|
|
544 memcpy(v22, &uNumActors, 4);
|
|
545 v28 = (char *)v22 + 4;
|
|
546 memcpy(v28, pActors, 836 * uNumActors);
|
|
547 v29 = (char *)v28 + 836 * uNumActors;
|
|
548 memcpy(v29, &uNumLayingItems, 4);
|
|
549 v29 = (char *)v29 + 4;
|
|
550 memcpy(v29, pLayingItems, 112 * uNumLayingItems);
|
|
551 v30 = (char *)v29 + 112 * uNumLayingItems;
|
|
552 memcpy(v30, &uNumChests, 4);
|
|
553 v30 = (char *)v30 + 4;
|
|
554 memcpy(v30, pChests, 5324 * uNumChests);
|
|
555 v31 = (char *)v30 + 5324 * uNumChests;
|
|
556 memcpy(v31, &stru_5E4C90, 0xC8);
|
|
557 v17 = (int)((char *)v31 + 200);
|
|
558 memcpy((void *)v17, &pOutdoor->uLastVisitDay, 0x38);
|
|
559 v9 = (int)v71;
|
|
560 }
|
|
561 v32 = v17 + 56;
|
|
562 strcpy(Source, pCurrentMapName);
|
79
|
563 _splitpath(Source, Drive, Dir, Filename, Ext);
|
0
|
564 v48 = 100;
|
|
565 Size = v32 - (int)DstBuf;
|
|
566 v69 = 999984;
|
|
567 LOBYTE(v33) = zlib::MemZip((char *)v9 + 16, (unsigned int *)&v69, DstBuf, v32 - (int)DstBuf);
|
|
568 if ( v33 || (signed int)v69 > (signed int)Size )
|
|
569 {
|
|
570 memcpy((void *)(v9 + 16), DstBuf, Size);
|
|
571 v69 = Size;
|
|
572 }
|
|
573 v69 += 16;
|
|
574 memcpy((void *)(v9 + 8), &v69, 4);
|
|
575 memcpy((void *)(v9 + 12), &Size, 4);
|
|
576 sprintf(Source, "%s%s", &Filename, &Ext);
|
|
577 strcpy((char *)&pDir, Source);
|
|
578 pDir.uDataSize = v69;
|
|
579 if ( pNew_LOD->Write(&pDir, (const void *)v9, 0) )
|
|
580 {
|
|
581 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 208);
|
|
582 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
|
|
583 }
|
|
584 free((void *)v9);
|
|
585 }
|
|
586 free(DstBuf);
|
|
587 if ( a1 )
|
|
588 {
|
|
589 if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) )
|
|
590 {
|
|
591 v34 = GetLastError();
|
|
592 FormatMessageA(0x1000, 0, v34, 0x400, &Buffer, 0x80, 0);
|
|
593 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 300);
|
|
594 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
|
|
595 }
|
|
596 }
|
|
597 pParty->vPosition.x = pPositionX;
|
|
598 pParty->vPosition.y = v51;
|
|
599 pParty->vPosition.z = v62;
|
|
600 pParty->uFallStartY = v62;
|
|
601 pParty->sRotationY = v53;
|
|
602 result = v54;
|
|
603 pParty->sRotationX = v54;
|
|
604 return result;
|
|
605 }
|
|
606
|
|
607
|
|
608 //----- (00460078) --------------------------------------------------------
|
|
609 void __fastcall DoSavegame(unsigned int uSlot)
|
|
610 {
|
|
611 unsigned int v1; // esi@1
|
|
612 int v2; // esi@2
|
|
613 RGBTexture *v3; // ebx@3
|
|
614 int bNotArena; // [sp+2Ch] [bp-8h]@1
|
|
615 unsigned int v6; // [sp+30h] [bp-4h]@1
|
|
616
|
|
617 __debugbreak();
|
|
618
|
|
619 v1 = uSlot;
|
|
620 v6 = uSlot;
|
|
621 bNotArena = _strcmpi(pCurrentMapName, "d05.blv");
|
|
622 if ( bNotArena )
|
|
623 {
|
|
624 LOD::Directory pDir; // [sp+Ch] [bp-28h]@2
|
|
625 SaveGame(0, 0);
|
|
626 v2 = 100 * v1;
|
|
627 strcpy(&pSavegameHeader->pLocationName[v2], pCurrentMapName);
|
|
628 *(int *)((char *)&pSavegameHeader->uWordTime + v2) = LODWORD(pParty->uTimePlayed);
|
|
629 *(int *)((char *)&pSavegameHeader->uWordTime + v2 + 4) = HIDWORD(pParty->uTimePlayed);
|
|
630 strcpy((char *)&pDir, "header.bin");
|
|
631 pDir.uDataSize = 100;
|
|
632 pNew_LOD->Write(&pDir, (char *)&pSavegameHeader + v2, 0);
|
|
633 sprintf(pTmpBuf, "saves\\save%03d.mm7", v6);
|
|
634 pNew_LOD->CloseWriteFile();
|
|
635 CopyFileA("data\\new.lod", pTmpBuf, 0);
|
|
636 }
|
|
637 GUI_UpdateWindows();
|
|
638 pGUIWindow_CurrentMenu->Release();
|
|
639 pCurrentScreen = 0;
|
|
640 v3 = pSavegameThumbnails;
|
|
641 viewparams->bRedrawGameUI = 1;
|
|
642 do
|
|
643 {
|
|
644 v3->Release();
|
|
645 ++v3;
|
|
646 }
|
|
647 while ( (signed int)v3 < (signed int)&unk_6A0758 );
|
|
648 if ( bNotArena )
|
|
649 pNew_LOD->_4621A7();
|
|
650 else
|
|
651 ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena"
|
|
652 pIcons_LOD->_4355F7();
|
|
653 pEventTimer->Resume();
|
|
654 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!"
|
|
655 viewparams->bRedrawGameUI = 1;
|
|
656 }
|
|
657 // 4E28F8: using guessed type int pCurrentScreen;
|
|
658
|
|
659
|
|
660
|
|
661
|
|
662
|
|
663
|
|
664
|
|
665
|
|
666
|
|
667
|
|
668
|
|
669 //----- (0045E297) --------------------------------------------------------
|
|
670 void SavegameList::Initialize(unsigned int bHideEmptySlots)
|
|
671 {
|
|
672 memset(pSavegameList, 0, 0x3138);
|
4
|
673 uNumSavegameFiles = 0;
|
0
|
674
|
|
675 _chdir("saves");
|
|
676 {
|
4
|
677 if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7
|
0
|
678 strcpy(pSavesNames[uNumSavegameFiles++], pGlobalTXT_LocalizationStrings[613]);
|
|
679
|
|
680 for (uint i = 0; i < 40; ++i)
|
|
681 {
|
|
682 sprintf(pTmpBuf, "save%03d.mm7", i);
|
|
683 if (_access(pTmpBuf, 0) == -1)
|
|
684 continue;
|
|
685
|
|
686 uint idx = i;
|
|
687 if (!bHideEmptySlots)
|
|
688 idx = uNumSavegameFiles;
|
|
689 strcpy(pSavesNames[idx], pTmpBuf);
|
|
690
|
|
691 ++uNumSavegameFiles;
|
|
692 }
|
|
693 }
|
|
694 _chdir("..");
|
|
695 } |