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