Mercurial > mm7
annotate Engine/SaveLoad.cpp @ 2567:d569340b05ff
Few constants changed into enum values
author | a.parshin |
---|---|
date | Thu, 21 May 2015 01:50:59 +0200 |
parents | 117c219bf913 |
children | d87bfbd3bb3b |
rev | line source |
---|---|
2499 | 1 #define _CRTDBG_MAP_ALLOC |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
2499 | 3 #include <stdlib.h> |
4 #include <crtdbg.h> | |
5 #include <io.h> | |
6 #include <direct.h> | |
7 | |
2541 | 8 #include "Engine/Engine.h" |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
9 #include "Engine/texts.h" |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
10 #include "Engine/ZlibWrapper.h" |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
11 #include "Engine/SaveLoad.h" |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
12 #include "Engine/Party.h" |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
13 #include "Engine/LOD.h" |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
14 #include "Engine/Timer.h" |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
15 #include "Engine/stru123.h" |
2499 | 16 #include "Engine/Graphics/Outdoor.h" |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
17 #include "Engine/Graphics/Overlays.h" |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
18 #include "Engine/Graphics/Viewport.h" |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
19 #include "Engine/Graphics/Level/Decoration.h" |
2499 | 20 #include "Engine/Objects/Actor.h" |
21 #include "Engine/Objects/Chest.h" | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
22 #include "Engine/Objects/SpriteObject.h" |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
23 #include "Engine/Serialization/LegacyImages.h" |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
24 |
2502 | 25 #include "GUI/GUIWindow.h" |
26 #include "GUI/GUIFont.h" | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
27 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
28 #include "Media/Audio/AudioPlayer.h" |
2499 | 29 |
2508 | 30 #include "MMT.h" |
2499 | 31 |
32 | |
33 | |
34 struct SavegameList *pSavegameList = new SavegameList; | |
35 unsigned int uNumSavegameFiles; | |
36 std::array<unsigned int, 45> pSavegameUsedSlots; | |
37 std::array<struct RGBTexture, 45> pSavegameThumbnails; | |
38 std::array<SavegameHeader, 45> pSavegameHeader; | |
39 | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
40 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
41 |
2499 | 42 //----- (0045EE8A) -------------------------------------------------------- |
43 void __fastcall LoadGame(unsigned int uSlot) | |
44 { | |
45 bool v25; // esi@62 | |
46 bool v26; // eax@62 | |
47 SavegameHeader header; // [sp+Ch] [bp-E4h]@23 | |
48 char Str[123]; // [sp+70h] [bp-80h]@25 | |
49 | |
50 MapsLongTimers_count = 0; | |
51 if (!pSavegameUsedSlots[uSlot]) | |
52 { | |
53 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); | |
54 Log::Warning(L"LoadGame: slot %u is empty", uSlot); | |
55 return; | |
56 } | |
57 | |
58 for (uint i = 1; i < 5; ++i) | |
59 for (uint j = 1; j < 6; ++j) | |
60 { | |
61 sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j); | |
62 remove(pTmpBuf.data()); | |
63 } | |
64 | |
65 if (SoundSetAction[24][0]) | |
66 for (uint i = 0; i < 4; ++i) | |
67 { | |
68 for (uint j = 0; j < pSoundList->sNumSounds; ++j) | |
69 if (pSoundList->pSL_Sounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998) | |
70 { | |
71 pSoundList->UnloadSound(j, 1); | |
72 break; | |
73 } | |
74 | |
75 for (uint j = 0; j < pSoundList->sNumSounds; ++j) | |
76 if (pSoundList->pSL_Sounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999) | |
77 { | |
78 pSoundList->UnloadSound(j, 1); | |
79 break; | |
80 } | |
81 } | |
82 | |
83 sprintf(pTmpBuf.data(), "saves\\%s", pSavegameList->pFileList[uSlot].pSaveFileName); | |
84 | |
85 pNew_LOD->CloseWriteFile(); | |
86 if (!CopyFileA(pTmpBuf.data(), "data\\new.lod", 0)) | |
87 int e = GetLastError(); | |
88 | |
89 pNew_LOD->LoadFile("data\\new.lod", 0); | |
90 FILE *file = pNew_LOD->FindContainer("header.bin", 1); | |
91 if (!file) | |
92 { | |
93 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100);//Сохраненная игра повреждена! Code=%d | |
94 Log::Warning(L"%S", Str); | |
95 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0); | |
96 } | |
97 Assert(sizeof(SavegameHeader) == 100); | |
98 fread(&header, sizeof(SavegameHeader), 1, file); | |
99 | |
100 { | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
101 file = pNew_LOD->FindContainer("party.bin", 1); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
102 if (!file) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
103 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
104 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101);//Сохраненная игра повреждена! Code=%d |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
105 Log::Warning(L"%S", Str); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
106 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
107 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
108 else |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
109 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
110 Party_Image_MM7 serialization; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
111 fread(&serialization, sizeof(serialization), 1, file); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
112 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
113 serialization.Deserialize(pParty); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
114 } |
2499 | 115 } |
116 | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
117 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
118 file = pNew_LOD->FindContainer("clock.bin", 1); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
119 if (!file) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
120 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
121 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 102);//Сохраненная игра повреждена! Code=%d |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
122 Log::Warning(L"%S", Str); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
123 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
124 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
125 else |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
126 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
127 Timer_Image_MM7 serialization; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
128 fread(&serialization, sizeof(serialization), 1, file); |
2499 | 129 |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
130 serialization.Deserialize(pEventTimer); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
131 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
132 } |
2499 | 133 |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
134 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
135 file = pNew_LOD->FindContainer("overlay.bin", 1); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
136 if (!file) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
137 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
138 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 103);//Сохраненная игра повреждена! Code=%d |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
139 Log::Warning(L"%S", Str); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
140 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
141 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
142 else |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
143 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
144 OtherOverlayList_Image_MM7 serialization; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
145 fread(&serialization, sizeof(serialization), 1, file); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
146 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
147 serialization.Deserialize(pOtherOverlayList); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
148 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
149 } |
2499 | 150 |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
151 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
152 file = pNew_LOD->FindContainer("npcdata.bin", 0); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
153 if (!file) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
154 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
155 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 104);//Сохраненная игра повреждена! Code=%d |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
156 Log::Warning(L"%S", Str); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
157 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
158 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
159 else |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
160 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
161 NPCData_Image_MM7 serialization[501]; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
162 fread(serialization, sizeof(serialization), 1, file); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
163 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
164 for (unsigned int i = 0; i < 501; ++i) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
165 serialization[i].Deserialize(pNPCStats->pNewNPCData + i); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
166 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
167 pNPCStats->_476C60_on_load_game(); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
168 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
169 } |
2499 | 170 |
171 file = pNew_LOD->FindContainer("npcgroup.bin", 0); | |
172 if (!file) | |
173 { | |
174 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 105);//Сохраненная игра повреждена! Code=%d | |
175 Log::Warning(L"%S", Str); | |
176 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0); | |
177 } | |
178 if (sizeof(pNPCStats->pGroups_copy) != 0x66) | |
179 Log::Warning(L"NPCStats: deserialization warning"); | |
180 fread(pNPCStats->pGroups_copy, sizeof(pNPCStats->pGroups_copy), 1, file); | |
181 | |
182 uActiveCharacter = 0; | |
183 for (uint i = 0; i < 4; ++i) | |
184 if (pParty->pPlayers[i].CanAct()) | |
185 { | |
186 uActiveCharacter = i + 1; | |
187 break; | |
188 } | |
189 | |
190 for (uint i = 0; i < 4; ++i) | |
191 { | |
192 if ( pParty->pPlayers[i].uQuickSpell ) | |
193 AA1058_PartyQuickSpellSound[i].AddPartySpellSound(pParty->pPlayers[i].uQuickSpell, i + 1); | |
194 | |
195 for (uint j = 0; j < 2; ++j) | |
196 { | |
197 uint uEquipIdx = pParty->pPlayers[i].pEquipment.pIndices[j]; | |
198 if (uEquipIdx) | |
199 { | |
200 int pItemID = pParty->pPlayers[i].pInventoryItemList[uEquipIdx - 1].uItemID; | |
201 if (pItemsTable->pItems[pItemID].uEquipType == EQUIP_WAND && pItemID )//жезл | |
202 { | |
203 __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 | |
204 stru_A750F8[i].AddPartySpellSound(wand_spell_ids[pItemID - ITEM_WAND_FIRE], i + 9); | |
205 } | |
206 } | |
207 } | |
208 } | |
209 | |
2563
65c97624c047
Saving & loading works from both main menu and game
a.parshin
parents:
2552
diff
changeset
|
210 /*if (pGUIWindow_CurrentMenu) |
2552
ac16f4a3a91e
Load from MainMenu logic separated from MainMenu window
a.parshin
parents:
2541
diff
changeset
|
211 { |
ac16f4a3a91e
Load from MainMenu logic separated from MainMenu window
a.parshin
parents:
2541
diff
changeset
|
212 pGUIWindow_CurrentMenu->Release(); |
ac16f4a3a91e
Load from MainMenu logic separated from MainMenu window
a.parshin
parents:
2541
diff
changeset
|
213 pGUIWindow_CurrentMenu = nullptr; |
2563
65c97624c047
Saving & loading works from both main menu and game
a.parshin
parents:
2552
diff
changeset
|
214 }*/ |
2541 | 215 current_screen_type = SCREEN_GAME; |
2499 | 216 |
217 viewparams->bRedrawGameUI = true; | |
218 | |
219 SetUserInterface(pParty->alignment, true); | |
220 | |
221 pEventTimer->Resume(); | |
222 pEventTimer->StopGameTime(); | |
223 | |
224 v25 = pGames_LOD->DoesContainerExist(header.pLocationName); | |
225 sprintf(pTmpBuf.data(), "levels\\%s", header.pLocationName); | |
226 v26 = _access(pTmpBuf.data(), 4) != -1; | |
227 if ( !v25 && !v26 ) | |
228 Error("Unable to find: %s!", header.pLocationName); | |
229 | |
230 strcpy(pCurrentMapName, header.pLocationName); | |
231 dword_6BE364_game_settings_1 |= GAME_SETTINGS_2000 | GAME_SETTINGS_0001; | |
232 | |
233 for (uint i = 0; i < uNumSavegameFiles; ++i) | |
234 pSavegameThumbnails[i].Release(); | |
235 | |
236 pIcons_LOD->RemoveTexturesPackFromTextureList(); | |
2508 | 237 if ( use_music_folder ) |
238 alSourcef (mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]); | |
239 else | |
240 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); | |
2499 | 241 pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); |
242 if (uTurnSpeed) | |
243 pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed; | |
244 MM7Initialization(); | |
245 bFlashQuestBook = false; | |
246 viewparams->bRedrawGameUI = true; | |
247 } | |
248 | |
249 //----- (0045F469) -------------------------------------------------------- | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
250 void SaveGame(bool IsAutoSAve, bool NotSaveWorld) |
2499 | 251 { |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
252 int text_pos; // eax@6 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
253 FILE *pLLoidFile; // edi@24 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
254 char* compressed_buf; // edi@30 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
255 char *data_write_pos; // esi@41 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
256 CHAR Buffer[128]; // [sp+Ch] [bp-264h]@59 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
257 char Dir[255]; // [sp+8Ch] [bp-1E4h]@51 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
258 char Drive[255]; // [sp+ACh] [bp-1C4h]@51 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
259 SavegameHeader save_header; // [sp+CCh] [bp-1A4h]@10 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
260 char Filename[255]; // [sp+130h] [bp-140h]@51 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
261 char Ext[255]; // [sp+150h] [bp-120h]@51 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
262 char Source[32]; // [sp+170h] [bp-100h]@51 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
263 char work_string[120]; // [sp+190h] [bp-E0h]@8 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
264 int pPositionY; // [sp+208h] [bp-68h]@2 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
265 int pPositionX; // [sp+20Ch] [bp-64h]@2 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
266 int sPRotationY; // [sp+210h] [bp-60h]@2 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
267 int sPRotationX; // [sp+214h] [bp-5Ch]@2 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
268 ODMHeader odm_data; // [sp+218h] [bp-58h]@30 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
269 int res; // [sp+224h] [bp-4Ch]@30 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
270 int pPositionZ; // [sp+228h] [bp-48h]@2 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
271 size_t Size; // [sp+250h] [bp-20h]@26 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
272 char *uncompressed_buff; // [sp+258h] [bp-18h]@2 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
273 unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
274 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
275 //v66 = a2; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
276 strcpy(byte_6BE3B0.data(), pCurrentMapName);//byte_6BE3B0 - save_map_name |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
277 if (!_stricmp(pCurrentMapName, "d05.blv")) // arena |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
278 return; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
279 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
280 uncompressed_buff = (char*)malloc(1000000); |
2499 | 281 |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
282 LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
283 pPositionX = pParty->vPosition.x; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
284 pPositionY = pParty->vPosition.y; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
285 pPositionZ = pParty->vPosition.z; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
286 sPRotationY = pParty->sRotationY; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
287 sPRotationX = pParty->sRotationX; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
288 pParty->vPosition.x = pParty->vPrevPosition.x; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
289 pParty->vPosition.z = pParty->vPrevPosition.z; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
290 pParty->vPosition.y = pParty->vPrevPosition.y; |
2499 | 291 |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
292 pParty->uFallStartY = pParty->vPrevPosition.z; |
2499 | 293 |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
294 pParty->sRotationY = pParty->sPrevRotationY; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
295 pParty->sRotationX = pParty->sPrevRotationX; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
296 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
297 pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
298 else |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
299 pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
300 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
301 pRenderer->PackScreenshot(150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize);//создание скриншота |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
302 strcpy(pLodDirectory.pFilename, "image.pcx"); |
2499 | 303 |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
304 if (current_screen_type == SCREEN_SAVEGAME) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
305 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
306 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
307 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up)); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
308 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[190]); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
309 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
310 text_pos = pFontSmallnum->AlignText_Center(186, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
311 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, text_pos + 25, 259, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
312 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[165]); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
313 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
314 pRenderer->Present(); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
315 } |
2499 | 316 |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
317 if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0)) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
318 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
319 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
320 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
321 } |
2499 | 322 |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
323 Assert(sizeof(SavegameHeader) == 100); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
324 memset(save_header.pName, 0, 20); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
325 memset(save_header.pLocationName, 0, 20); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
326 memset(save_header.field_30, 0, 52); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
327 strcpy(save_header.pLocationName, pCurrentMapName); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
328 save_header.uWordTime = pParty->uTimePlayed; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
329 strcpy(pLodDirectory.pFilename, "header.bin"); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
330 pLodDirectory.uDataSize = sizeof(SavegameHeader); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
331 if (pNew_LOD->Write(&pLodDirectory, &save_header, 0)) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
332 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
333 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 201); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
334 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
335 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
336 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
337 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
338 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
339 Party_Image_MM7 serialization; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
340 serialization.Serialize(pParty); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
341 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
342 pLodDirectory.uDataSize = sizeof(serialization); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
343 strcpy(pLodDirectory.pFilename, "party.bin"); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
344 if (pNew_LOD->Write(&pLodDirectory, &serialization, 0)) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
345 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
346 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202);//Save game corrupted! Code=%d |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
347 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
348 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
349 } |
2499 | 350 |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
351 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
352 Timer_Image_MM7 serialization; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
353 serialization.Serialize(pEventTimer); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
354 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
355 pLodDirectory.uDataSize = sizeof(serialization); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
356 strcpy(pLodDirectory.pFilename, "clock.bin"); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
357 if (pNew_LOD->Write(&pLodDirectory, &serialization, 0)) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
358 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
359 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 203); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
360 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
361 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
362 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
363 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
364 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
365 OtherOverlayList_Image_MM7 serialization; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
366 serialization.Serialize(pOtherOverlayList); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
367 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
368 pLodDirectory.uDataSize = sizeof(serialization); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
369 strcpy(pLodDirectory.pFilename, "overlay.bin"); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
370 if (pNew_LOD->Write(&pLodDirectory, &serialization, 0)) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
371 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
372 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 204); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
373 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
374 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
375 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
376 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
377 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
378 NPCData_Image_MM7 serialization[501]; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
379 for (unsigned int i = 0; i < 501; ++i) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
380 serialization[i].Serialize(pNPCStats->pNewNPCData + i); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
381 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
382 pLodDirectory.uDataSize = sizeof(serialization); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
383 strcpy(pLodDirectory.pFilename, "npcdata.bin"); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
384 if (pNew_LOD->Write(&pLodDirectory, serialization, 0)) |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
385 { |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
386 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 205); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
387 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
388 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
389 } |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
390 |
2499 | 391 strcpy(pLodDirectory.pFilename, "npcgroup.bin"); |
392 pLodDirectory.uDataSize = 102; | |
393 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) ) | |
394 { | |
395 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 206); | |
396 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0); | |
397 } | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
398 |
2499 | 399 for (int i = 1; i <= 4; ++i) // 4 - players |
400 { | |
401 for (int j = 1; j <= 5; ++j) // 5 - images | |
402 { | |
403 sprintf(work_string, "data\\lloyd%d%d.pcx", i, j); | |
404 pLLoidFile = fopen(work_string, "rb"); | |
405 if ( pLLoidFile ) | |
406 { | |
407 __debugbreak(); | |
408 sprintf(work_string, "lloyd%d%d.pcx", i, j); | |
409 fseek(pLLoidFile, 0, SEEK_END); | |
410 pLodDirectory.uDataSize = ftell(pLLoidFile); | |
411 rewind(pLLoidFile); | |
412 fread(uncompressed_buff, pLodDirectory.uDataSize, 1, pLLoidFile); | |
413 strcpy(pLodDirectory.pFilename, work_string); | |
414 fclose(pLLoidFile); | |
415 remove(work_string); | |
416 if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) ) | |
417 { | |
418 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 207); | |
419 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); | |
420 Size = 5080748; | |
421 } | |
422 } | |
423 } | |
424 } | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2563
diff
changeset
|
425 |
2499 | 426 if ( !NotSaveWorld )//autosave for change location |
427 { | |
428 //__debugbreak(); | |
429 CompactLayingItemsList(); | |
430 compressed_buf = (char*)malloc(1000000); | |
431 odm_data.uVersion = 91969; | |
432 odm_data.pMagic[0] = 'm'; | |
433 odm_data.pMagic[1] = 'v'; | |
434 odm_data.pMagic[2] = 'i'; | |
435 odm_data.pMagic[3] = 'i'; | |
436 odm_data.uCompressedSize = 0; | |
437 odm_data.uDecompressedSize = 0; | |
438 data_write_pos = uncompressed_buff; | |
439 memcpy((void *)compressed_buf, &odm_data, 0x10); | |
440 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
441 { | |
442 pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces; | |
443 pIndoor->dlv.uNumBModels = 0; | |
444 pIndoor->dlv.uNumDecorations = uNumLevelDecorations; | |
445 memcpy(data_write_pos, &pIndoor->dlv,sizeof(DDM_DLV_Header) );//0x28 | |
446 data_write_pos += sizeof(DDM_DLV_Header); | |
447 memcpy(data_write_pos, pIndoor->_visible_outlines, 0x36B); | |
448 data_write_pos += 875; | |
449 for (int i = 0; i <(signed int)pIndoor->uNumFaces; ++i) | |
450 { | |
451 memcpy(data_write_pos, &pIndoor->pFaces[i].uAttributes, 4); | |
452 data_write_pos += 4; | |
453 } | |
454 | |
455 for (int i = 0; i <(signed int)uNumLevelDecorations; ++i) | |
456 { | |
457 memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2); | |
458 data_write_pos += 2; | |
459 } | |
460 memcpy(data_write_pos, &uNumActors, 4); | |
461 data_write_pos += 4; | |
462 memcpy(data_write_pos, &pActors, uNumActors * sizeof(Actor)); | |
463 data_write_pos += uNumActors * sizeof(Actor); | |
464 memcpy(data_write_pos, &uNumSpriteObjects, 4); | |
465 data_write_pos += 4; | |
466 memcpy(data_write_pos, pSpriteObjects.data(), 112 * uNumSpriteObjects); | |
467 data_write_pos += 112 * uNumSpriteObjects; | |
468 memcpy(data_write_pos, &uNumChests, 4); | |
469 data_write_pos += 4; | |
470 memcpy(data_write_pos, pChests.data(), sizeof(Chest)*uNumChests);//5324 * | |
471 data_write_pos += sizeof(Chest)* uNumChests; | |
472 memcpy(data_write_pos, pIndoor->pDoors, 0x3E80); | |
473 data_write_pos += 16000; | |
474 memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size); | |
475 data_write_pos += pIndoor->blv.uDoors_ddata_Size; | |
476 memcpy(data_write_pos, &stru_5E4C90_MapPersistVars, 0xC8); | |
477 data_write_pos += 200; | |
478 memcpy(data_write_pos, &pIndoor->stru1, 0x38); | |
479 data_write_pos += 56; | |
480 | |
481 } | |
482 else//for Outdoor | |
483 { | |
484 pOutdoor->ddm.uNumFacesInBModels = 0; | |
485 for ( int i = 0; i < pOutdoor->uNumBModels; ++i ) | |
486 pOutdoor->ddm.uNumFacesInBModels += pOutdoor->pBModels[i].uNumFaces; | |
487 pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels; | |
488 pOutdoor->ddm.uNumDecorations = uNumLevelDecorations; | |
489 memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28 | |
490 data_write_pos += sizeof(DDM_DLV_Header); | |
491 memcpy(data_write_pos, pOutdoor->uFullyRevealedCellOnMap, 0x3C8); | |
492 data_write_pos += 968; | |
493 memcpy(data_write_pos, pOutdoor->uPartiallyRevealedCellOnMap, 0x3C8); | |
494 data_write_pos += 968; | |
495 for (int i = 0; i < pOutdoor->uNumBModels ; ++i) | |
496 for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j) | |
497 { | |
498 memcpy(data_write_pos, &(pOutdoor->pBModels[i].pFaces[j].uAttributes), 4); | |
499 data_write_pos += 4; | |
500 } | |
501 | |
502 for (int i = 0; i < (signed int)uNumLevelDecorations; ++i) | |
503 { | |
504 memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2); | |
505 data_write_pos += 2; | |
506 } | |
507 memcpy(data_write_pos, &uNumActors, 4); | |
508 data_write_pos += 4; | |
509 memcpy(data_write_pos, &pActors, uNumActors * sizeof(Actor)); | |
510 data_write_pos += uNumActors * sizeof(Actor); | |
511 memcpy(data_write_pos, &uNumSpriteObjects, 4); | |
512 data_write_pos += 4; | |
513 memcpy(data_write_pos, &pSpriteObjects, uNumSpriteObjects * sizeof(SpriteObject)); | |
514 data_write_pos += uNumSpriteObjects * sizeof(SpriteObject); | |
515 memcpy(data_write_pos, &uNumChests, 4); | |
516 data_write_pos += 4; | |
517 memcpy(data_write_pos, pChests.data(), sizeof(Chest)* uNumChests); | |
518 data_write_pos += sizeof(Chest) * uNumChests; | |
519 memcpy(data_write_pos, &stru_5E4C90_MapPersistVars, 0xC8); | |
520 data_write_pos += 200; | |
521 memcpy(data_write_pos, &pOutdoor->loc_time, 0x38); | |
522 data_write_pos += 56; | |
523 } | |
524 strcpy(Source, pCurrentMapName); | |
525 _splitpath(Source, Drive, Dir, Filename, Ext); | |
526 Ext[1] = 'd'; | |
527 | |
528 Size = (int)data_write_pos - (int)uncompressed_buff; | |
529 compressed_block_size = 999984; | |
530 res = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size); | |
531 if (res || (signed int)compressed_block_size > (signed int)Size ) | |
532 { | |
533 memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size); | |
534 compressed_block_size = Size; | |
535 } | |
536 compressed_block_size += 16; | |
537 memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4); | |
538 memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4); | |
539 sprintf(Source, "%s%s", Filename, Ext); | |
540 strcpy(pLodDirectory.pFilename, Source); | |
541 pLodDirectory.uDataSize = compressed_block_size; | |
542 if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) ) | |
543 { | |
544 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 208); | |
545 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); | |
546 } | |
547 free((void *)compressed_buf); | |
548 } | |
549 free(uncompressed_buff); | |
550 if ( IsAutoSAve ) | |
551 { | |
552 if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) ) | |
553 { | |
554 FormatMessageA(0x1000, 0, GetLastError(), 0x400, Buffer, 0x80, 0); | |
555 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 300); | |
556 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0); | |
557 } | |
558 } | |
559 pParty->vPosition.x = pPositionX; | |
560 pParty->vPosition.y = pPositionY; | |
561 pParty->vPosition.z = pPositionZ; | |
562 pParty->uFallStartY = pPositionZ; | |
563 pParty->sRotationY = sPRotationY; | |
564 pParty->sRotationX = sPRotationX; | |
565 } | |
566 | |
567 //----- (00460078) -------------------------------------------------------- | |
568 void __fastcall DoSavegame(unsigned int uSlot) | |
569 { | |
570 if ( _stricmp(pCurrentMapName, "d05.blv") )//Not Arena(не Арена) | |
571 { | |
572 LOD::Directory pDir; // [sp+Ch] [bp-28h]@2 | |
573 SaveGame(0, 0); | |
574 strcpy(pSavegameHeader[uSlot].pLocationName, pCurrentMapName);//дать название карты | |
575 pSavegameHeader[uSlot].uWordTime = pParty->uTimePlayed;//текущее время | |
576 strcpy(pDir.pFilename, "header.bin"); | |
577 pDir.uDataSize = 100; | |
578 pNew_LOD->Write(&pDir, &pSavegameHeader[uSlot], 0); | |
579 sprintf(pTmpBuf.data(), "saves\\save%03d.mm7", uSlot); | |
580 pNew_LOD->CloseWriteFile();//закрыть | |
581 CopyFileA("data\\new.lod", pTmpBuf.data(), 0);//сохранение файла в директорию saves | |
582 } | |
583 GUI_UpdateWindows(); | |
584 pGUIWindow_CurrentMenu->Release(); | |
2541 | 585 current_screen_type = SCREEN_GAME; |
2499 | 586 //v3 = pSavegameThumbnails; |
587 viewparams->bRedrawGameUI = true; | |
588 for (uint i = 0; i < 45; i++) | |
589 pSavegameThumbnails[i].Release(); | |
590 | |
591 if ( _stricmp(pCurrentMapName, "d05.blv") ) | |
592 pNew_LOD->_4621A7(); | |
593 else | |
594 ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2);// "No saving in the Arena" | |
595 pIcons_LOD->RemoveTexturesFromTextureList(); | |
596 pEventTimer->Resume(); | |
597 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2);// "Game Saved!" | |
598 viewparams->bRedrawGameUI = true; | |
599 } | |
2541 | 600 // 4E28F8: using guessed type int current_screen_type; |
2499 | 601 |
602 //----- (0045E297) -------------------------------------------------------- | |
603 void SavegameList::Initialize(unsigned int bHideEmptySlots) | |
604 { | |
605 //memset(pSavegameList, 0, sizeof(pSavegameList));//Ritor1: вызывает затирание | |
606 pSavegameList->Reset(); | |
607 uNumSavegameFiles = 0; | |
608 | |
609 _chdir("saves"); | |
610 { | |
611 if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7 | |
612 strcpy(pSavegameList->pFileList[uNumSavegameFiles++].pSaveFileName, pGlobalTXT_LocalizationStrings[613]); | |
613 | |
614 for (uint i = 0; i < 40; ++i) | |
615 { | |
616 sprintf(pTmpBuf.data(), "save%03d.mm7", i); | |
617 if (_access(pTmpBuf.data(), 0) == -1) | |
618 continue; | |
619 | |
620 uint idx = i; | |
621 if (!bHideEmptySlots) | |
622 idx = uNumSavegameFiles; | |
623 strcpy(pSavegameList->pFileList[idx].pSaveFileName, pTmpBuf.data()); | |
624 | |
625 ++uNumSavegameFiles; | |
626 } | |
627 } | |
628 _chdir(".."); | |
629 } | |
630 //----- (0046086A) -------------------------------------------------------- | |
631 void SaveNewGame() | |
632 { | |
633 FILE *file; // eax@7 | |
634 void *pSave; // [sp+170h] [bp-8h]@3 | |
635 | |
636 if ( pMovie_Track ) | |
637 pMediaPlayer->Unload(); | |
638 pSave = malloc(1000000); | |
639 pNew_LOD->CloseWriteFile(); | |
640 remove("data\\new.lod");//удалить new.lod | |
641 | |
642 LOD::FileHeader header; // [sp+Ch] [bp-16Ch]@3 заголовок | |
643 strcpy(header.LodVersion, "MMVII"); | |
644 strcpy(header.LodDescription, "newmaps for MMVII"); | |
645 header.LODSize = 100; | |
646 header.dword_0000A8 = 0; | |
647 | |
648 LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3 | |
649 a3.dword_000018 = 0; | |
650 a3.word_00001E = 0; | |
651 strcpy(a3.pFilename, "current"); | |
652 pNew_LOD->CreateNewLod(&header, &a3, "data\\new.lod");//создаётся new.lod в дирректории | |
653 if (pNew_LOD->LoadFile("data\\new.lod", false))//загрузить файл new.lod(isFileOpened = true) | |
654 { | |
655 pNew_LOD->CreateTempFile();//создаётся временный файл OutputFileHandle | |
656 pNew_LOD->uNumSubDirs = 0; | |
657 | |
658 LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4 | |
659 for (int i = pGames_LOD->uNumSubDirs / 2; i < pGames_LOD->uNumSubDirs; ++i)//копирование файлов с 76 по 151 | |
660 { | |
661 memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir));//копирование текущего файла в pDir | |
662 file = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1); | |
663 fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, file); | |
664 pNew_LOD->AppendDirectory(&pDir, pSave); | |
665 } | |
666 | |
667 LOD::Directory save_game_dir; // [sp+12Ch] [bp-4Ch]@9 | |
668 strcpy(pSavegameHeader[0].pLocationName, "out01.odm"); | |
669 strcpy(save_game_dir.pFilename, "header.bin"); | |
670 save_game_dir.uDataSize = sizeof(SavegameHeader); | |
671 pNew_LOD->AppendDirectory(&save_game_dir, &pSavegameHeader[0]); | |
672 | |
673 pNew_LOD->FixDirectoryOffsets(); | |
674 | |
675 pParty->vPrevPosition.x = 12552; | |
676 pParty->vPrevPosition.y = 1816; | |
677 pParty->vPrevPosition.z = 0; | |
678 | |
679 pParty->vPosition.x = 12552; | |
680 pParty->vPosition.y = 1816; | |
681 pParty->vPosition.z = 0; | |
682 | |
683 pParty->uFallStartY = 0; | |
684 | |
685 pParty->sPrevRotationX = 0; | |
686 pParty->sPrevRotationY = 512; | |
687 | |
688 pParty->sRotationX = 0; | |
689 pParty->sRotationY = 512; | |
690 | |
691 SaveGame(1, 1); | |
692 } | |
693 free(pSave); | |
694 } | |
695 |