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