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