annotate SaveLoad.cpp @ 38:c261e0eea3c9

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