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