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