annotate SaveLoad.cpp @ 1206:ab6560001f5b

arrays to std::arrays phase 2 - some more arrays converted
author Grumpy7
date Sun, 09 Jun 2013 01:10:49 +0200
parents 8c02e6f74b29
children 96a81634669e
rev   line source
1165
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1104
diff changeset
1 #ifdef _MSC_VER
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1104
diff changeset
2 #define _CRT_SECURE_NO_WARNINGS
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1104
diff changeset
3 #endif
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1104
diff changeset
4
0
Ritor1
parents:
diff changeset
5 #include <io.h>
Ritor1
parents:
diff changeset
6 #include <direct.h>
Ritor1
parents:
diff changeset
7 #include <assert.h>
Ritor1
parents:
diff changeset
8
Ritor1
parents:
diff changeset
9 #include "SaveLoad.h"
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 982
diff changeset
10 #include "BSPModel.h"
0
Ritor1
parents:
diff changeset
11 #include "Party.h"
Ritor1
parents:
diff changeset
12 #include "LOD.h"
Ritor1
parents:
diff changeset
13 #include "Outdoor.h"
Ritor1
parents:
diff changeset
14 #include "AudioPlayer.h"
Ritor1
parents:
diff changeset
15 #include "Actor.h"
Ritor1
parents:
diff changeset
16 #include "Chest.h"
Ritor1
parents:
diff changeset
17 #include "Time.h"
Ritor1
parents:
diff changeset
18 #include "GUIWindow.h"
Ritor1
parents:
diff changeset
19 #include "GUIFont.h"
Ritor1
parents:
diff changeset
20 #include "Overlays.h"
515
cb0ad52d6a26 LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents: 488
diff changeset
21 #include "SpriteObject.h"
0
Ritor1
parents:
diff changeset
22 #include "Viewport.h"
Ritor1
parents:
diff changeset
23 #include "stru123.h"
189
038a4d09406f new texts file, fix text rendender error
Gloval
parents: 165
diff changeset
24 #include "texts.h"
0
Ritor1
parents:
diff changeset
25 #include "Log.h"
Ritor1
parents:
diff changeset
26
Ritor1
parents:
diff changeset
27 #include "mm7_data.h"
Ritor1
parents:
diff changeset
28
Ritor1
parents:
diff changeset
29
Ritor1
parents:
diff changeset
30
Ritor1
parents:
diff changeset
31
Ritor1
parents:
diff changeset
32
Ritor1
parents:
diff changeset
33 struct SavegameList *pSavegameList = new SavegameList;
Ritor1
parents:
diff changeset
34 unsigned int uNumSavegameFiles;
1206
ab6560001f5b arrays to std::arrays phase 2 - some more arrays converted
Grumpy7
parents: 1205
diff changeset
35 std::array<unsigned int, 45> pSavegameUsedSlots;
ab6560001f5b arrays to std::arrays phase 2 - some more arrays converted
Grumpy7
parents: 1205
diff changeset
36 std::array<struct RGBTexture, 45> pSavegameThumbnails;
ab6560001f5b arrays to std::arrays phase 2 - some more arrays converted
Grumpy7
parents: 1205
diff changeset
37 std::array<SavegameHeader, 45> pSavegameHeader;
0
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
Ritor1
parents:
diff changeset
44
Ritor1
parents:
diff changeset
45
Ritor1
parents:
diff changeset
46
Ritor1
parents:
diff changeset
47
Ritor1
parents:
diff changeset
48 //----- (0045EE8A) --------------------------------------------------------
Ritor1
parents:
diff changeset
49 void __fastcall LoadGame(unsigned int uSlot)
Ritor1
parents:
diff changeset
50 {
Ritor1
parents:
diff changeset
51 bool v25; // esi@62
Ritor1
parents:
diff changeset
52 bool v26; // eax@62
Ritor1
parents:
diff changeset
53 int v30; // [sp-Ch] [bp-FCh]@65
Ritor1
parents:
diff changeset
54 int v31; // [sp-8h] [bp-F8h]@4
Ritor1
parents:
diff changeset
55 SavegameHeader header; // [sp+Ch] [bp-E4h]@23
Ritor1
parents:
diff changeset
56 char Str[123]; // [sp+70h] [bp-80h]@25
Ritor1
parents:
diff changeset
57
336
ea55d6414029 Event_proceccor preliminary
Gloval
parents: 328
diff changeset
58 dword_5B65C8_timers_count = 0;
0
Ritor1
parents:
diff changeset
59 if (!pSavegameUsedSlots[uSlot])
Ritor1
parents:
diff changeset
60 {
Ritor1
parents:
diff changeset
61 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
Ritor1
parents:
diff changeset
62 Log::Warning(L"LoadGame: slot %u is empty", uSlot);
Ritor1
parents:
diff changeset
63 return;
Ritor1
parents:
diff changeset
64 }
Ritor1
parents:
diff changeset
65
Ritor1
parents:
diff changeset
66 for (uint i = 1; i < 5; ++i)
Ritor1
parents:
diff changeset
67 for (uint j = 1; j < 6; ++j)
Ritor1
parents:
diff changeset
68 {
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
69 sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j);
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
70 remove(pTmpBuf.data());
0
Ritor1
parents:
diff changeset
71 }
Ritor1
parents:
diff changeset
72
Ritor1
parents:
diff changeset
73
203
0c64754c7fd4 Voices work (at least in party creation screen)
Nomad
parents: 189
diff changeset
74 if (SoundSetAction[24][0])
0
Ritor1
parents:
diff changeset
75 for (uint i = 0; i < 4; ++i)
Ritor1
parents:
diff changeset
76 {
764
90bcfb56c8f9 sound cleaning
Gloval
parents: 752
diff changeset
77 for (uint j = 0; j < pSoundList->sNumSounds; ++j)
203
0c64754c7fd4 Voices work (at least in party creation screen)
Nomad
parents: 189
diff changeset
78 if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998)
0
Ritor1
parents:
diff changeset
79 {
764
90bcfb56c8f9 sound cleaning
Gloval
parents: 752
diff changeset
80 pSoundList->UnloadSound(j, 1);
0
Ritor1
parents:
diff changeset
81 break;
Ritor1
parents:
diff changeset
82 }
Ritor1
parents:
diff changeset
83
764
90bcfb56c8f9 sound cleaning
Gloval
parents: 752
diff changeset
84 for (uint j = 0; j < pSoundList->sNumSounds; ++j)
203
0c64754c7fd4 Voices work (at least in party creation screen)
Nomad
parents: 189
diff changeset
85 if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999)
0
Ritor1
parents:
diff changeset
86 {
764
90bcfb56c8f9 sound cleaning
Gloval
parents: 752
diff changeset
87 pSoundList->UnloadSound(j, 1);
0
Ritor1
parents:
diff changeset
88 break;
Ritor1
parents:
diff changeset
89 }
Ritor1
parents:
diff changeset
90 }
Ritor1
parents:
diff changeset
91
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
92 sprintf(pTmpBuf.data(), "saves\\%s", pSavegameList->pFileList[uSlot].pSaveFileName);
0
Ritor1
parents:
diff changeset
93
Ritor1
parents:
diff changeset
94 pNew_LOD->CloseWriteFile();
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
95 if (!CopyFileA(pTmpBuf.data(), "data\\new.lod", 0))
0
Ritor1
parents:
diff changeset
96 int e = GetLastError();
Ritor1
parents:
diff changeset
97
Ritor1
parents:
diff changeset
98 pNew_LOD->LoadFile("data\\new.lod", 0);
Ritor1
parents:
diff changeset
99 auto *f = pNew_LOD->FindContainer("header.bin", 1);
Ritor1
parents:
diff changeset
100 if (!f)
Ritor1
parents:
diff changeset
101 {
Ritor1
parents:
diff changeset
102 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100);
Ritor1
parents:
diff changeset
103 Log::Warning(L"%S", Str);
Ritor1
parents:
diff changeset
104 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0);
Ritor1
parents:
diff changeset
105 }
Ritor1
parents:
diff changeset
106 assert(sizeof(SavegameHeader) == 100);
Ritor1
parents:
diff changeset
107 fread(&header, sizeof(SavegameHeader), 1, f);
Ritor1
parents:
diff changeset
108
Ritor1
parents:
diff changeset
109 f = pNew_LOD->FindContainer("party.bin", 1);
Ritor1
parents:
diff changeset
110 if (!f)
Ritor1
parents:
diff changeset
111 {
Ritor1
parents:
diff changeset
112 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101);
Ritor1
parents:
diff changeset
113 Log::Warning(L"%S", Str);
Ritor1
parents:
diff changeset
114 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0);
Ritor1
parents:
diff changeset
115 }
Ritor1
parents:
diff changeset
116 if (sizeof(Party) != 0x16238)
Ritor1
parents:
diff changeset
117 Log::Warning(L"class Party: deserialization warning");
Ritor1
parents:
diff changeset
118 fread(pParty, 0x16238u, 1, f);
Ritor1
parents:
diff changeset
119
Ritor1
parents:
diff changeset
120
Ritor1
parents:
diff changeset
121 f = pNew_LOD->FindContainer("clock.bin", 1);
Ritor1
parents:
diff changeset
122 if (!f)
Ritor1
parents:
diff changeset
123 {
Ritor1
parents:
diff changeset
124 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 102);
Ritor1
parents:
diff changeset
125 Log::Warning(L"%S", Str);
Ritor1
parents:
diff changeset
126 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0);
Ritor1
parents:
diff changeset
127 }
Ritor1
parents:
diff changeset
128 if (sizeof(Timer) != 0x28)
Ritor1
parents:
diff changeset
129 Log::Warning(L"class Timer: deserialization warning");
Ritor1
parents:
diff changeset
130 fread(pEventTimer, 0x28u, 1u, f);
Ritor1
parents:
diff changeset
131
Ritor1
parents:
diff changeset
132 f = pNew_LOD->FindContainer("overlay.bin", 1);
Ritor1
parents:
diff changeset
133 if (!f)
Ritor1
parents:
diff changeset
134 {
Ritor1
parents:
diff changeset
135 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 103);
Ritor1
parents:
diff changeset
136 Log::Warning(L"%S", Str);
Ritor1
parents:
diff changeset
137 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0);
Ritor1
parents:
diff changeset
138 }
Ritor1
parents:
diff changeset
139 if (sizeof(OtherOverlayList) != 0x3F0)
Ritor1
parents:
diff changeset
140 Log::Warning(L"class OtherOverlayList: deserialization warning");
Ritor1
parents:
diff changeset
141 fread(pOtherOverlayList, 0x3F0, 1, f);
Ritor1
parents:
diff changeset
142
Ritor1
parents:
diff changeset
143 f = pNew_LOD->FindContainer("npcdata.bin", 0);
Ritor1
parents:
diff changeset
144 if (!f)
Ritor1
parents:
diff changeset
145 {
Ritor1
parents:
diff changeset
146 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 104);
Ritor1
parents:
diff changeset
147 Log::Warning(L"%S", Str);
Ritor1
parents:
diff changeset
148 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0);
Ritor1
parents:
diff changeset
149 }
Ritor1
parents:
diff changeset
150 if (sizeof(pNPCStats->pNewNPCData) != 0x94BC)
Ritor1
parents:
diff changeset
151 Log::Warning(L"NPCStats: deserialization warning");
Ritor1
parents:
diff changeset
152 fread(pNPCStats->pNewNPCData, 0x94BC, 1, f);
Ritor1
parents:
diff changeset
153 pNPCStats->_476C60();
Ritor1
parents:
diff changeset
154
Ritor1
parents:
diff changeset
155 f = pNew_LOD->FindContainer("npcgroup.bin", 0);
Ritor1
parents:
diff changeset
156 if (!f)
Ritor1
parents:
diff changeset
157 {
Ritor1
parents:
diff changeset
158 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 105);
Ritor1
parents:
diff changeset
159 Log::Warning(L"%S", Str);
Ritor1
parents:
diff changeset
160 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0);
Ritor1
parents:
diff changeset
161 }
Ritor1
parents:
diff changeset
162 if (sizeof(pNPCStats->pGroups_copy) != 0x66)
Ritor1
parents:
diff changeset
163 Log::Warning(L"NPCStats: deserialization warning");
Ritor1
parents:
diff changeset
164 fread(pNPCStats->pGroups_copy, 0x66, 1, f);
Ritor1
parents:
diff changeset
165
Ritor1
parents:
diff changeset
166
Ritor1
parents:
diff changeset
167 uActiveCharacter = 0;
Ritor1
parents:
diff changeset
168 for (uint i = 0; i < 4; ++i)
Ritor1
parents:
diff changeset
169 if (pParty->pPlayers[i].CanAct())
Ritor1
parents:
diff changeset
170 {
Ritor1
parents:
diff changeset
171 uActiveCharacter = i + 1;
Ritor1
parents:
diff changeset
172 break;
Ritor1
parents:
diff changeset
173 }
Ritor1
parents:
diff changeset
174
Ritor1
parents:
diff changeset
175 for (uint i = 0; i < 4; ++i)
Ritor1
parents:
diff changeset
176 {
Ritor1
parents:
diff changeset
177 auto uQuickspell = pParty->pPlayers[i].uQuickSpell;
Ritor1
parents:
diff changeset
178 if (uQuickspell)
Ritor1
parents:
diff changeset
179 stru_AA1058[i]._494836(uQuickspell, i + 9 - 8);
Ritor1
parents:
diff changeset
180
Ritor1
parents:
diff changeset
181 for (uint j = 0; j < 2; ++j)
Ritor1
parents:
diff changeset
182 {
Ritor1
parents:
diff changeset
183 uint uEquipIdx = pParty->pPlayers[i].pEquipment.pIndices[j];
Ritor1
parents:
diff changeset
184 if (uEquipIdx)
Ritor1
parents:
diff changeset
185 {
Ritor1
parents:
diff changeset
186 auto uItemID = pParty->pPlayers[i].pInventoryItems[uEquipIdx - 1].uItemID;
Ritor1
parents:
diff changeset
187 if (pItemsTable->pItems[uItemID].uEquipType == 12)
Ritor1
parents:
diff changeset
188 {
816
cfc65feef029 * Player Recovery Times
Nomad
parents: 810
diff changeset
189 __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5
488
Nomad
parents: 382
diff changeset
190 v31 = *((int *)&pSpellDatas[66].uNormalLevelRecovery + uItemID);
0
Ritor1
parents:
diff changeset
191 stru_A750F8[i]._494836(v31, i + 9);
Ritor1
parents:
diff changeset
192 }
Ritor1
parents:
diff changeset
193 }
Ritor1
parents:
diff changeset
194 }
Ritor1
parents:
diff changeset
195 }
Ritor1
parents:
diff changeset
196
Ritor1
parents:
diff changeset
197
Ritor1
parents:
diff changeset
198 pGUIWindow_CurrentMenu->Release();
151
9abdd40a107b pCurrentScreen
Ritor1
parents: 79
diff changeset
199 pCurrentScreen = SCREEN_GAME;
0
Ritor1
parents:
diff changeset
200
Ritor1
parents:
diff changeset
201 viewparams->bRedrawGameUI = true;
Ritor1
parents:
diff changeset
202
373
edd2d8b7e3c4 Interface reloading fix & party alignment enum
Nomad
parents: 336
diff changeset
203 SetUserInterface(pParty->alignment, true);
0
Ritor1
parents:
diff changeset
204
Ritor1
parents:
diff changeset
205 pEventTimer->Resume();
Ritor1
parents:
diff changeset
206 pEventTimer->StopGameTime();
Ritor1
parents:
diff changeset
207
Ritor1
parents:
diff changeset
208 v25 = pGames_LOD->DoesContainerExist(header.pLocationName);
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
209 sprintf(pTmpBuf.data(), "levels\\%s", header.pLocationName);
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
210 v26 = _access(pTmpBuf.data(), 4) != -1;
0
Ritor1
parents:
diff changeset
211 if ( !v25 && !v26 )
Ritor1
parents:
diff changeset
212 {
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
213 sprintf(pTmpBuf.data(), "Unable to find: %s!", header.pLocationName);
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
214 Abortf(pTmpBuf.data());
0
Ritor1
parents:
diff changeset
215 }
Ritor1
parents:
diff changeset
216
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
217 strcpy(pCurrentMapName.data(), header.pLocationName);
0
Ritor1
parents:
diff changeset
218 dword_6BE364_game_settings_1 |= 0x2001;
Ritor1
parents:
diff changeset
219
Ritor1
parents:
diff changeset
220 for (uint i = 0; i < uNumSavegameFiles; ++i)
Ritor1
parents:
diff changeset
221 pSavegameThumbnails[i].Release();
Ritor1
parents:
diff changeset
222
Ritor1
parents:
diff changeset
223 pIcons_LOD->_4114F2();
328
8e23edf57e27 little fix
Ritor1
parents: 203
diff changeset
224 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
8e23edf57e27 little fix
Ritor1
parents: 203
diff changeset
225 pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
0
Ritor1
parents:
diff changeset
226 if (uTurnSpeed)
Ritor1
parents:
diff changeset
227 pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed;
Ritor1
parents:
diff changeset
228 MM7Initialization();
Ritor1
parents:
diff changeset
229 bFlashQuestBook = false;
Ritor1
parents:
diff changeset
230 viewparams->bRedrawGameUI = true;
Ritor1
parents:
diff changeset
231 }
Ritor1
parents:
diff changeset
232
Ritor1
parents:
diff changeset
233
Ritor1
parents:
diff changeset
234 //----- (0045F469) --------------------------------------------------------
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
235 void SaveGame( bool IsAutoSAve, bool NotSaveWorld )
982
08fd1436ef35 enums & lod
Nomad
parents: 847
diff changeset
236 {
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
237 unsigned short *pScreenshot; // edi@5
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
238 int text_pos; // eax@6
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
239 FILE *pLLoidFile; // edi@24
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
240 char* compressed_buf; // edi@30
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
241 char *data_write_pos; // esi@41
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
242 CHAR Buffer[128]; // [sp+Ch] [bp-264h]@59
79
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
243 char Dir[255]; // [sp+8Ch] [bp-1E4h]@51
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
244 char Drive[255]; // [sp+ACh] [bp-1C4h]@51
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
245 SavegameHeader save_header; // [sp+CCh] [bp-1A4h]@10
79
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
246 char Filename[255]; // [sp+130h] [bp-140h]@51
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
247 char Ext[255]; // [sp+150h] [bp-120h]@51
0
Ritor1
parents:
diff changeset
248 char Source[32]; // [sp+170h] [bp-100h]@51
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
249 char work_string[120]; // [sp+190h] [bp-E0h]@8
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
250 int pPositionY; // [sp+208h] [bp-68h]@2
0
Ritor1
parents:
diff changeset
251 int pPositionX; // [sp+20Ch] [bp-64h]@2
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
252 int sPRotationY; // [sp+210h] [bp-60h]@2
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
253 int sPRotationX; // [sp+214h] [bp-5Ch]@2
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
254 ODMHeader odm_data; // [sp+218h] [bp-58h]@30
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
255 int res; // [sp+224h] [bp-4Ch]@30
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
256 int pPositionZ; // [sp+228h] [bp-48h]@2
0
Ritor1
parents:
diff changeset
257 size_t Size; // [sp+250h] [bp-20h]@26
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
258 char *uncompressed_buff; // [sp+258h] [bp-18h]@2
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
259 unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
260
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
261 //v66 = a2;
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
262 strcpy(byte_6BE3B0.data(), pCurrentMapName.data());
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
263 if (!_stricmp(pCurrentMapName.data(), "d05.blv")) // arena
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
264 return;
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
265
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
266 uncompressed_buff = (char*)malloc(1000000);
982
08fd1436ef35 enums & lod
Nomad
parents: 847
diff changeset
267
08fd1436ef35 enums & lod
Nomad
parents: 847
diff changeset
268 LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2
0
Ritor1
parents:
diff changeset
269 pPositionX = pParty->vPosition.x;
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
270 pPositionY = pParty->vPosition.y;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
271 pPositionZ = pParty->vPosition.z;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
272 sPRotationY = pParty->sRotationY;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
273 sPRotationX = pParty->sRotationX;
0
Ritor1
parents:
diff changeset
274 pParty->vPosition.x = pParty->vPrevPosition.x;
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
275 pParty->vPosition.z = pParty->vPrevPosition.z;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
276 pParty->vPosition.y = pParty->vPrevPosition.y;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
277
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
278 pParty->uFallStartY = pParty->vPrevPosition.z;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
279
0
Ritor1
parents:
diff changeset
280 pParty->sRotationY = pParty->sPrevRotationY;
Ritor1
parents:
diff changeset
281 pParty->sRotationX = pParty->sPrevRotationX;
Ritor1
parents:
diff changeset
282 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
Ritor1
parents:
diff changeset
283 pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed;
Ritor1
parents:
diff changeset
284 else
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
285 pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed;
0
Ritor1
parents:
diff changeset
286 pScreenshot = MakeScreenshot(150, 112);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
287 strcpy(pLodDirectory.pFilename, "image.pcx");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
288 pRenderer->PackPCXpicture(pScreenshot, 150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize);
0
Ritor1
parents:
diff changeset
289 free(pScreenshot);
151
9abdd40a107b pCurrentScreen
Ritor1
parents: 79
diff changeset
290 if (pCurrentScreen == SCREEN_SAVEGAME)
0
Ritor1
parents:
diff changeset
291 {
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
292 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
293 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up));
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
294 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[190]);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
295 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Ñîõðàíåíèå
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
296 text_pos = pFontSmallnum->AlignText_Center(186, pSavegameHeader[uLoadGameUI_SelectedSlot].pName);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
297 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, text_pos + 25, 259, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
298 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[165]);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
299 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Ïîæàëóéñòà, ïîäîæäèòå
0
Ritor1
parents:
diff changeset
300 pRenderer->Present();
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
301 }
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
302
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
303 if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0))
0
Ritor1
parents:
diff changeset
304 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
305 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 200); //Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
306 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
0
Ritor1
parents:
diff changeset
307 }
Ritor1
parents:
diff changeset
308
Ritor1
parents:
diff changeset
309 assert(sizeof(SavegameHeader) == 100);
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
310 memset(save_header.pName, 0, 20);
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
311 memset(save_header.pLocationName, 0, 20);
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
312 memset(save_header.field_30, 0, 52);
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
313 strcpy(save_header.pLocationName, pCurrentMapName.data());
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
314 save_header.uWordTime = pParty->uTimePlayed;
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
315 strcpy(pLodDirectory.pFilename, "header.bin");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
316 pLodDirectory.uDataSize = sizeof(SavegameHeader);
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
317 if (pNew_LOD->Write(&pLodDirectory, &save_header, 0))
0
Ritor1
parents:
diff changeset
318 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
319 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 201);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
320 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
0
Ritor1
parents:
diff changeset
321 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
322 strcpy(pLodDirectory.pFilename, "party.bin");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
323 pLodDirectory.uDataSize = sizeof(Party); //90680;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
324 if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) )
0
Ritor1
parents:
diff changeset
325 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
326 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
327 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
0
Ritor1
parents:
diff changeset
328 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
329 strcpy(pLodDirectory.pFilename, "clock.bin");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
330 pLodDirectory.uDataSize =sizeof(Timer);// 40;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
331 if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) )
0
Ritor1
parents:
diff changeset
332 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
333 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 203);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
334 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
0
Ritor1
parents:
diff changeset
335 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
336 strcpy(pLodDirectory.pFilename, "overlay.bin");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
337 pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
338 if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) )
0
Ritor1
parents:
diff changeset
339 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
340 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 204);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
341 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
0
Ritor1
parents:
diff changeset
342 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
343 strcpy(pLodDirectory.pFilename, "npcdata.bin");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
344 pLodDirectory.uDataSize = 501 * sizeof(NPCData);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
345 assert(pLodDirectory.uDataSize == 38076);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
346 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) )
0
Ritor1
parents:
diff changeset
347 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
348 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 205);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
349 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
0
Ritor1
parents:
diff changeset
350 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
351 strcpy(pLodDirectory.pFilename, "npcgroup.bin");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
352 pLodDirectory.uDataSize = 102;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
353 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) )
0
Ritor1
parents:
diff changeset
354 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
355 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 206);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
356 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
0
Ritor1
parents:
diff changeset
357 }
Ritor1
parents:
diff changeset
358 for (int i = 1; i <= 4; ++i) // 4 - players
Ritor1
parents:
diff changeset
359 {
Ritor1
parents:
diff changeset
360 for (int j = 1; j <= 5; ++j) // 5 - images
Ritor1
parents:
diff changeset
361 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
362 sprintf(work_string, "data\\lloyd%d%d.pcx", i, j);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
363 pLLoidFile = fopen(work_string, "rb");
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
364 if ( pLLoidFile )
0
Ritor1
parents:
diff changeset
365 {
Ritor1
parents:
diff changeset
366 __debugbreak();
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
367 sprintf(work_string, "lloyd%d%d.pcx", i, j);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
368 fseek(pLLoidFile, 0, SEEK_END);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
369 pLodDirectory.uDataSize = ftell(pLLoidFile);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
370 rewind(pLLoidFile);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
371 fread(uncompressed_buff, pLodDirectory.uDataSize, 1, pLLoidFile);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
372 strcpy(pLodDirectory.pFilename, work_string);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
373 fclose(pLLoidFile);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
374 remove(work_string);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
375 if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) )
0
Ritor1
parents:
diff changeset
376 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
377 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 207);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
378 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
0
Ritor1
parents:
diff changeset
379 Size = 5080748;
Ritor1
parents:
diff changeset
380 }
Ritor1
parents:
diff changeset
381 }
Ritor1
parents:
diff changeset
382 }
Ritor1
parents:
diff changeset
383 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
384 if ( !NotSaveWorld )
0
Ritor1
parents:
diff changeset
385 {
79
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
386 //__debugbreak();
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
387 CompactLayingItemsList();
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
388 compressed_buf = (char*)malloc(1000000);
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
389 odm_data.uVersion = 91969;
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
390 odm_data.pMagic[0] = 'm';
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
391 odm_data.pMagic[1] = 'v';
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
392 odm_data.pMagic[2] = 'i';
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
393 odm_data.pMagic[3] = 'i';
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
394 odm_data.uCompressedSize = 0;
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
395 odm_data.uDecompressedSize = 0;
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
396 data_write_pos = uncompressed_buff;
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
397 memcpy((void *)compressed_buf, &odm_data, 0x10);
0
Ritor1
parents:
diff changeset
398 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
Ritor1
parents:
diff changeset
399 {
Ritor1
parents:
diff changeset
400 pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces;
Ritor1
parents:
diff changeset
401 pIndoor->dlv.uNumBModels = 0;
Ritor1
parents:
diff changeset
402 pIndoor->dlv.uNumDecorations = uNumLevelDecorations;
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
403 memcpy(data_write_pos, &pIndoor->dlv,sizeof(DDM_DLV_Header) );//0x28
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
404 data_write_pos += sizeof(DDM_DLV_Header);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
405 memcpy(data_write_pos, pIndoor->_visible_outlines, 0x36B);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
406 data_write_pos += 875;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
407
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
408 for (int i = 0; i <(signed int)pIndoor->uNumFaces; ++i)
0
Ritor1
parents:
diff changeset
409 {
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
410 memcpy(data_write_pos, &pIndoor->pFaces[i].uAttributes, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
411 data_write_pos += 4;
0
Ritor1
parents:
diff changeset
412 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
413
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
414 for (int i = 0; i <(signed int)uNumLevelDecorations; ++i)
0
Ritor1
parents:
diff changeset
415 {
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
416 memcpy(data_write_pos, &pLevelDecorations[i].field_2, 2);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
417
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
418 data_write_pos+= 2;
0
Ritor1
parents:
diff changeset
419 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
420 memcpy(data_write_pos, &uNumActors, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
421 data_write_pos += 4;
1202
0dbf6c4dd029 arrays to std::arrays phase 1
Grumpy7
parents: 1165
diff changeset
422 memcpy(data_write_pos, pActors.data(), 836 * uNumActors);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
423 data_write_pos += 836 * uNumActors;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
424 memcpy(data_write_pos, &uNumSpriteObjects, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
425 data_write_pos += 4;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
426 memcpy(data_write_pos, pSpriteObjects, 112 * uNumSpriteObjects);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
427 data_write_pos += 112 * uNumSpriteObjects;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
428 memcpy(data_write_pos, &uNumChests, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
429 data_write_pos += 4;
1202
0dbf6c4dd029 arrays to std::arrays phase 1
Grumpy7
parents: 1165
diff changeset
430 memcpy(data_write_pos, pChests.data(), sizeof(Chest)*uNumChests);//5324 *
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
431 data_write_pos += sizeof(Chest)* uNumChests;
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
432 memcpy(data_write_pos, pIndoor->pDoors, 0x3E80);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
433 data_write_pos += 16000;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
434 memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
435 data_write_pos += pIndoor->blv.uDoors_ddata_Size;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
436 memcpy(data_write_pos, &stru_5E4C90, 0xC8);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
437 data_write_pos += 200;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
438 memcpy(data_write_pos, &pIndoor->stru1, 0x38);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
439 data_write_pos += 56;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
440
0
Ritor1
parents:
diff changeset
441 }
Ritor1
parents:
diff changeset
442 else
Ritor1
parents:
diff changeset
443 {
Ritor1
parents:
diff changeset
444 pOutdoor->ddm.uNumFacesInBModels = 0;
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
445 for (int i=0; i<pOutdoor->uNumBModels;++i)
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
446 {
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
447 pOutdoor->ddm.uNumFacesInBModels +=pOutdoor->pBModels[i].uNumFaces;
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
448 }
0
Ritor1
parents:
diff changeset
449 pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels;
Ritor1
parents:
diff changeset
450 pOutdoor->ddm.uNumDecorations = uNumLevelDecorations;
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
451 memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
452 data_write_pos += sizeof(DDM_DLV_Header);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
453 memcpy(data_write_pos, pOutdoor->uUndiscoveredArea, 0x3C8);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
454 data_write_pos += 968;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
455 memcpy(data_write_pos, pOutdoor->uDicovered_area, 0x3C8);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
456 data_write_pos += 968;
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
457 for (int i = 0; i < pOutdoor->uNumBModels ; ++i)
79
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
458 for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j)
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
459 {
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
460 memcpy(data_write_pos, &(pOutdoor->pBModels[i].pFaces[j].uAttributes), 4);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
461 data_write_pos += 4;
0
Ritor1
parents:
diff changeset
462 }
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
463
1084
5a59b5b2699f SaveGame "for" cycle fix - orignal disassembly code has "i < uNumLevelDecorations"
Grumpy7
parents: 1016
diff changeset
464 for (int i = 0; i < (signed int)uNumLevelDecorations; ++i)
0
Ritor1
parents:
diff changeset
465 {
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
466 memcpy(data_write_pos, &pLevelDecorations[i].field_2, 2);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
467 data_write_pos += 2;
0
Ritor1
parents:
diff changeset
468 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
469 memcpy(data_write_pos, &uNumActors, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
470 data_write_pos += 4;
1202
0dbf6c4dd029 arrays to std::arrays phase 1
Grumpy7
parents: 1165
diff changeset
471 memcpy(data_write_pos, pActors.data(), 836 * uNumActors);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
472 data_write_pos += 836 * uNumActors;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
473 memcpy(data_write_pos, &uNumSpriteObjects, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
474 data_write_pos += 4;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
475 memcpy(data_write_pos, pSpriteObjects, 112 * uNumSpriteObjects);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
476 data_write_pos += 112 * uNumSpriteObjects;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
477 memcpy(data_write_pos, &uNumChests, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
478 data_write_pos += 4;
1202
0dbf6c4dd029 arrays to std::arrays phase 1
Grumpy7
parents: 1165
diff changeset
479 memcpy(data_write_pos, pChests.data(), sizeof(Chest)* uNumChests);
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
480 data_write_pos += sizeof(Chest)* uNumChests;
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
481 memcpy(data_write_pos, &stru_5E4C90, 0xC8);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
482 data_write_pos += 200;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
483 memcpy(data_write_pos, &pOutdoor->loc_time, 0x38);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
484 data_write_pos += 56;
0
Ritor1
parents:
diff changeset
485 }
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
486 strcpy(Source, pCurrentMapName.data());
79
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
487 _splitpath(Source, Drive, Dir, Filename, Ext);
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
488
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
489 Size = (int)data_write_pos - (int)uncompressed_buff;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
490 compressed_block_size = 999984;
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
491 res = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
492 if (res || (signed int)compressed_block_size > (signed int)Size )
0
Ritor1
parents:
diff changeset
493 {
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
494 memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
495 compressed_block_size = Size;
0
Ritor1
parents:
diff changeset
496 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
497 compressed_block_size += 16;
814
35122475edd7 struct correction
Gloval
parents: 810
diff changeset
498 memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4);
35122475edd7 struct correction
Gloval
parents: 810
diff changeset
499 memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4);
0
Ritor1
parents:
diff changeset
500 sprintf(Source, "%s%s", &Filename, &Ext);
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
501 strcpy(pLodDirectory.pFilename, Source);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
502 pLodDirectory.uDataSize = compressed_block_size;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
503 if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) )
0
Ritor1
parents:
diff changeset
504 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
505 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 208);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
506 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
0
Ritor1
parents:
diff changeset
507 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
508 free((void *)compressed_buf);
0
Ritor1
parents:
diff changeset
509 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
510 free(uncompressed_buff);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
511 if ( IsAutoSAve )
0
Ritor1
parents:
diff changeset
512 {
Ritor1
parents:
diff changeset
513 if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) )
Ritor1
parents:
diff changeset
514 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
515 FormatMessageA(0x1000, 0, GetLastError(), 0x400, Buffer, 0x80, 0);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
516 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 300);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
517 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
0
Ritor1
parents:
diff changeset
518 }
Ritor1
parents:
diff changeset
519 }
Ritor1
parents:
diff changeset
520 pParty->vPosition.x = pPositionX;
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
521 pParty->vPosition.y = pPositionY;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
522 pParty->vPosition.z = pPositionZ;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
523 pParty->uFallStartY = pPositionZ;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
524 pParty->sRotationY = sPRotationY;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
525 pParty->sRotationX = sPRotationX;
0
Ritor1
parents:
diff changeset
526 }
Ritor1
parents:
diff changeset
527
Ritor1
parents:
diff changeset
528
Ritor1
parents:
diff changeset
529 //----- (00460078) --------------------------------------------------------
Ritor1
parents:
diff changeset
530 void __fastcall DoSavegame(unsigned int uSlot)
Ritor1
parents:
diff changeset
531 {
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
532 //unsigned int v1; // esi@1
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
533 //int v2; // esi@2
557
604d70894002 Saving works partly
zipi
parents: 515
diff changeset
534 //RGBTexture *v3; // ebx@3
0
Ritor1
parents:
diff changeset
535 int bNotArena; // [sp+2Ch] [bp-8h]@1
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
536 //unsigned int v6; // [sp+30h] [bp-4h]@1
0
Ritor1
parents:
diff changeset
537
165
Ritor1
parents: 151
diff changeset
538 //__debugbreak();
0
Ritor1
parents:
diff changeset
539
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
540 //v1 = uSlot;
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
541 //v6 = uSlot;
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
542 bNotArena = _stricmp(pCurrentMapName.data(), "d05.blv");
0
Ritor1
parents:
diff changeset
543 if ( bNotArena )
Ritor1
parents:
diff changeset
544 {
Ritor1
parents:
diff changeset
545 LOD::Directory pDir; // [sp+Ch] [bp-28h]@2
Ritor1
parents:
diff changeset
546 SaveGame(0, 0);
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
547 //v2 = 100 * v1;
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
548 strcpy(pSavegameHeader[uSlot].pLocationName, pCurrentMapName.data());
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
549 pSavegameHeader[uSlot].uWordTime = pParty->uTimePlayed;
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
550 strcpy(pDir.pFilename, "header.bin");
0
Ritor1
parents:
diff changeset
551 pDir.uDataSize = 100;
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
552 pNew_LOD->Write(&pDir, &pSavegameHeader[uSlot], 0);
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
553 sprintf(pTmpBuf.data(), "saves\\save%03d.mm7", uSlot);
0
Ritor1
parents:
diff changeset
554 pNew_LOD->CloseWriteFile();
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
555 CopyFileA("data\\new.lod", pTmpBuf.data(), 0);
0
Ritor1
parents:
diff changeset
556 }
Ritor1
parents:
diff changeset
557 GUI_UpdateWindows();
Ritor1
parents:
diff changeset
558 pGUIWindow_CurrentMenu->Release();
151
9abdd40a107b pCurrentScreen
Ritor1
parents: 79
diff changeset
559 pCurrentScreen = SCREEN_GAME;
557
604d70894002 Saving works partly
zipi
parents: 515
diff changeset
560 //v3 = pSavegameThumbnails;
0
Ritor1
parents:
diff changeset
561 viewparams->bRedrawGameUI = 1;
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
562 for (uint i = 0; i < 45; i++)
557
604d70894002 Saving works partly
zipi
parents: 515
diff changeset
563 pSavegameThumbnails[i].Release();
604d70894002 Saving works partly
zipi
parents: 515
diff changeset
564 //while ( (signed int)v3 < (signed int)&unk_6A0758 );
0
Ritor1
parents:
diff changeset
565 if ( bNotArena )
Ritor1
parents:
diff changeset
566 pNew_LOD->_4621A7();
Ritor1
parents:
diff changeset
567 else
Ritor1
parents:
diff changeset
568 ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena"
Ritor1
parents:
diff changeset
569 pIcons_LOD->_4355F7();
Ritor1
parents:
diff changeset
570 pEventTimer->Resume();
Ritor1
parents:
diff changeset
571 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!"
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
572 viewparams->bRedrawGameUI = true;
0
Ritor1
parents:
diff changeset
573 }
Ritor1
parents:
diff changeset
574 // 4E28F8: using guessed type int pCurrentScreen;
Ritor1
parents:
diff changeset
575
Ritor1
parents:
diff changeset
576
Ritor1
parents:
diff changeset
577
Ritor1
parents:
diff changeset
578
Ritor1
parents:
diff changeset
579
Ritor1
parents:
diff changeset
580
Ritor1
parents:
diff changeset
581
Ritor1
parents:
diff changeset
582
Ritor1
parents:
diff changeset
583
Ritor1
parents:
diff changeset
584
Ritor1
parents:
diff changeset
585
Ritor1
parents:
diff changeset
586 //----- (0045E297) --------------------------------------------------------
Ritor1
parents:
diff changeset
587 void SavegameList::Initialize(unsigned int bHideEmptySlots)
Ritor1
parents:
diff changeset
588 {
382
a4a5996fea5b Fixed savelist problem
Gloval
parents: 373
diff changeset
589 memset(pSavegameList, 0, 0x3138);
a4a5996fea5b Fixed savelist problem
Gloval
parents: 373
diff changeset
590 // Reset();
4
8e33efd39355 15.01.13(work)
Ritor1
parents: 0
diff changeset
591 uNumSavegameFiles = 0;
0
Ritor1
parents:
diff changeset
592
Ritor1
parents:
diff changeset
593 _chdir("saves");
Ritor1
parents:
diff changeset
594 {
4
8e33efd39355 15.01.13(work)
Ritor1
parents: 0
diff changeset
595 if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7
382
a4a5996fea5b Fixed savelist problem
Gloval
parents: 373
diff changeset
596 strcpy(pSavegameList->pFileList[uNumSavegameFiles++].pSaveFileName, pGlobalTXT_LocalizationStrings[613]);
0
Ritor1
parents:
diff changeset
597
Ritor1
parents:
diff changeset
598 for (uint i = 0; i < 40; ++i)
Ritor1
parents:
diff changeset
599 {
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
600 sprintf(pTmpBuf.data(), "save%03d.mm7", i);
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
601 if (_access(pTmpBuf.data(), 0) == -1)
0
Ritor1
parents:
diff changeset
602 continue;
Ritor1
parents:
diff changeset
603
Ritor1
parents:
diff changeset
604 uint idx = i;
Ritor1
parents:
diff changeset
605 if (!bHideEmptySlots)
Ritor1
parents:
diff changeset
606 idx = uNumSavegameFiles;
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
607 strcpy(pSavegameList->pFileList[idx].pSaveFileName, pTmpBuf.data());
0
Ritor1
parents:
diff changeset
608
Ritor1
parents:
diff changeset
609 ++uNumSavegameFiles;
Ritor1
parents:
diff changeset
610 }
Ritor1
parents:
diff changeset
611 }
Ritor1
parents:
diff changeset
612 _chdir("..");
Ritor1
parents:
diff changeset
613 }