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