Mercurial > mm7
view SaveLoad.cpp @ 823:c1da83d8223f
More spell renames
author | Nomad |
---|---|
date | Tue, 26 Mar 2013 20:05:57 +0200 |
parents | 448e6d979c7a |
children | bebc19f3d2af |
line wrap: on
line source
#include <io.h> #include <direct.h> #include <assert.h> #include "SaveLoad.h" #include "NPC.h" #include "Party.h" #include "LOD.h" #include "Outdoor.h" #include "AudioPlayer.h" #include "Actor.h" #include "Chest.h" #include "Time.h" #include "GUIWindow.h" #include "GUIFont.h" #include "Overlays.h" #include "SpriteObject.h" #include "Viewport.h" #include "stru123.h" #include "texts.h" #include "Log.h" #include "mm7_data.h" struct SavegameList *pSavegameList = new SavegameList; unsigned int uNumSavegameFiles; unsigned int pSavegameUsedSlots[45]; struct RGBTexture pSavegameThumbnails[45]; SavegameHeader pSavegameHeader[45]; //----- (0045EE8A) -------------------------------------------------------- void __fastcall LoadGame(unsigned int uSlot) { bool v25; // esi@62 bool v26; // eax@62 int v30; // [sp-Ch] [bp-FCh]@65 int v31; // [sp-8h] [bp-F8h]@4 SavegameHeader header; // [sp+Ch] [bp-E4h]@23 char Str[123]; // [sp+70h] [bp-80h]@25 dword_5B65C8_timers_count = 0; if (!pSavegameUsedSlots[uSlot]) { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); Log::Warning(L"LoadGame: slot %u is empty", uSlot); return; } for (uint i = 1; i < 5; ++i) for (uint j = 1; j < 6; ++j) { sprintf(pTmpBuf, "data\\lloyd%d%d.pcx", i, j); remove(pTmpBuf); } if (SoundSetAction[24][0]) for (uint i = 0; i < 4; ++i) { for (uint j = 0; j < pSoundList->sNumSounds; ++j) if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998) { pSoundList->UnloadSound(j, 1); break; } for (uint j = 0; j < pSoundList->sNumSounds; ++j) if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999) { pSoundList->UnloadSound(j, 1); break; } } sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[uSlot].pSaveFileName); pNew_LOD->CloseWriteFile(); if (!CopyFileA(pTmpBuf, "data\\new.lod", 0)) int e = GetLastError(); pNew_LOD->LoadFile("data\\new.lod", 0); auto *f = pNew_LOD->FindContainer("header.bin", 1); if (!f) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100); Log::Warning(L"%S", Str); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0); } assert(sizeof(SavegameHeader) == 100); fread(&header, sizeof(SavegameHeader), 1, f); f = pNew_LOD->FindContainer("party.bin", 1); if (!f) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101); Log::Warning(L"%S", Str); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0); } if (sizeof(Party) != 0x16238) Log::Warning(L"class Party: deserialization warning"); fread(pParty, 0x16238u, 1, f); f = pNew_LOD->FindContainer("clock.bin", 1); if (!f) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 102); Log::Warning(L"%S", Str); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0); } if (sizeof(Timer) != 0x28) Log::Warning(L"class Timer: deserialization warning"); fread(pEventTimer, 0x28u, 1u, f); f = pNew_LOD->FindContainer("overlay.bin", 1); if (!f) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 103); Log::Warning(L"%S", Str); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0); } if (sizeof(OtherOverlayList) != 0x3F0) Log::Warning(L"class OtherOverlayList: deserialization warning"); fread(pOtherOverlayList, 0x3F0, 1, f); f = pNew_LOD->FindContainer("npcdata.bin", 0); if (!f) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 104); Log::Warning(L"%S", Str); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0); } if (sizeof(pNPCStats->pNewNPCData) != 0x94BC) Log::Warning(L"NPCStats: deserialization warning"); fread(pNPCStats->pNewNPCData, 0x94BC, 1, f); pNPCStats->_476C60(); f = pNew_LOD->FindContainer("npcgroup.bin", 0); if (!f) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 105); Log::Warning(L"%S", Str); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0); } if (sizeof(pNPCStats->pGroups_copy) != 0x66) Log::Warning(L"NPCStats: deserialization warning"); fread(pNPCStats->pGroups_copy, 0x66, 1, f); uActiveCharacter = 0; for (uint i = 0; i < 4; ++i) if (pParty->pPlayers[i].CanAct()) { uActiveCharacter = i + 1; break; } for (uint i = 0; i < 4; ++i) { auto uQuickspell = pParty->pPlayers[i].uQuickSpell; if (uQuickspell) stru_AA1058[i]._494836(uQuickspell, i + 9 - 8); for (uint j = 0; j < 2; ++j) { uint uEquipIdx = pParty->pPlayers[i].pEquipment.pIndices[j]; if (uEquipIdx) { auto uItemID = pParty->pPlayers[i].pInventoryItems[uEquipIdx - 1].uItemID; if (pItemsTable->pItems[uItemID].uEquipType == 12) { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 v31 = *((int *)&pSpellDatas[66].uNormalLevelRecovery + uItemID); stru_A750F8[i]._494836(v31, i + 9); } } } } pGUIWindow_CurrentMenu->Release(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = true; SetUserInterface(pParty->alignment, true); pEventTimer->Resume(); pEventTimer->StopGameTime(); v25 = pGames_LOD->DoesContainerExist(header.pLocationName); sprintf(pTmpBuf, "levels\\%s", header.pLocationName); v26 = _access(pTmpBuf, 4) != -1; if ( !v25 && !v26 ) { sprintf(pTmpBuf, "Unable to find: %s!", header.pLocationName); Abortf(pTmpBuf); } strcpy(pCurrentMapName, header.pLocationName); dword_6BE364_game_settings_1 |= 0x2001; for (uint i = 0; i < uNumSavegameFiles; ++i) pSavegameThumbnails[i].Release(); pIcons_LOD->_4114F2(); pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); if (uTurnSpeed) pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed; MM7Initialization(); bFlashQuestBook = false; viewparams->bRedrawGameUI = true; } //----- (0045F469) -------------------------------------------------------- void SaveGame( bool IsAutoSAve, bool NotSaveWorld ) { int result; // eax@1 unsigned short *pScreenshot; // edi@5 int text_pos; // eax@6 int v5; // eax@6 int v6; // eax@6 const char *v7; // edi@8 FILE *v8; // edi@24 char* compressed_buf; // edi@30 void *v10; // esi@31 void *v11; // esi@31 void *v12; // esi@37 void *v13; // esi@37 void *v14; // esi@37 void *v15; // esi@37 void *v16; // esi@37 int v17; // esi@37 unsigned int v18; // ecx@38 unsigned int v19; // esi@39 BSPModel *v20; // edx@39 char *data_write_pos; // esi@41 void *v22; // esi@41 BSPModel *v23; // eax@42 signed int v24; // edi@42 unsigned __int8 v25; // zf@43 unsigned __int8 v26; // sf@43 signed int v27; // edi@47 void *v28; // esi@50 void *v29; // esi@50 void *v30; // esi@50 void *v31; // esi@50 int v32; // esi@51 int v33; // eax@51 DWORD v34; // eax@59 //std::string v35; // [sp-18h] [bp-288h]@8 const char *v36; // [sp-10h] [bp-280h]@6 const char *v37; // [sp-Ch] [bp-27Ch]@6 unsigned int *v38; // [sp-8h] [bp-278h]@8 CHAR Buffer; // [sp+Ch] [bp-264h]@59 char Dir[255]; // [sp+8Ch] [bp-1E4h]@51 char Drive[255]; // [sp+ACh] [bp-1C4h]@51 SavegameHeader header; // [sp+CCh] [bp-1A4h]@10 //int v43; // [sp+CCh] [bp-1A4h]@10 //char Dest[20]; // [sp+E0h] [bp-190h]@10 //unsigned __int64 pTimePlayed; // [sp+F4h] [bp-17Ch]@10 char Filename[255]; // [sp+130h] [bp-140h]@51 char Ext[255]; // [sp+150h] [bp-120h]@51 char v48; // [sp+151h] [bp-11Fh]@51 char Source[32]; // [sp+170h] [bp-100h]@51 char Str[120]; // [sp+190h] [bp-E0h]@8 int v51; // [sp+208h] [bp-68h]@2 int pPositionX; // [sp+20Ch] [bp-64h]@2 int v53; // [sp+210h] [bp-60h]@2 int v54; // [sp+214h] [bp-5Ch]@2 ODMHeader Src; // [sp+218h] [bp-58h]@30 char v56; // [sp+21Ch] [bp-54h]@30 char v57; // [sp+21Dh] [bp-53h]@30 char v58; // [sp+21Eh] [bp-52h]@30 char v59; // [sp+21Fh] [bp-51h]@30 int v60; // [sp+220h] [bp-50h]@30 int v61; // [sp+224h] [bp-4Ch]@30 int v62; // [sp+228h] [bp-48h]@2 LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2 size_t Size; // [sp+250h] [bp-20h]@26 __int16 *v66; // [sp+254h] [bp-1Ch]@1 char *uncompressed_buff; // [sp+258h] [bp-18h]@2 __int16 *v68; // [sp+25Ch] [bp-14h]@32 unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23 int v70; // [sp+264h] [bp-Ch]@22 std::string *v71; // [sp+268h] [bp-8h]@8 int a3; // [sp+26Fh] [bp-1h]@8 //v66 = a2; strcpy(byte_6BE3B0, pCurrentMapName); if (!_strcmpi(pCurrentMapName, "d05.blv")) // arena return; uncompressed_buff = (char*)malloc(1000000); pLodDirectory.Reset(); pPositionX = pParty->vPosition.x; v51 = pParty->vPosition.y; v62 = pParty->vPosition.z; v53 = pParty->sRotationY; v54 = pParty->sRotationX; pParty->vPosition.x = pParty->vPrevPosition.x; pParty->vPosition.y = pParty->vPrevPosition.z; pParty->vPosition.z = pParty->vPrevPosition.y; pParty->uFallStartY = pParty->vPrevPosition.y; pParty->sRotationY = pParty->sPrevRotationY; pParty->sRotationX = pParty->sPrevRotationX; if (uCurrentlyLoadedLevelType == LEVEL_Indoor) pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed; else pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed; pScreenshot = MakeScreenshot(150, 112); strcpy(pLodDirectory.pFilename, "image.pcx"); pRenderer->PackPCXpicture(pScreenshot, 150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize); free(pScreenshot); if (pCurrentScreen == SCREEN_SAVEGAME) { pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up)); text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[190]); pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение text_pos = pFontSmallnum->AlignText_Center(186, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, text_pos + 25, 259, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0); text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[165]); pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите pRenderer->Present(); } if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0)) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); } assert(sizeof(SavegameHeader) == 100); memset(header.pName, 0, 20); memset(header.pLocationName, 0, 20); memset(header.field_30, 0, 52); strcpy(header.pLocationName, pCurrentMapName); header.uWordTime = pParty->uTimePlayed; strcpy(pLodDirectory.pFilename, "header.bin"); pLodDirectory.uDataSize = sizeof(SavegameHeader); if (pNew_LOD->Write(&pLodDirectory, &header, 0)) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); } strcpy(pLodDirectory.pFilename, "party.bin"); pLodDirectory.uDataSize = sizeof(Party); //90680; if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); } strcpy(pLodDirectory.pFilename, "clock.bin"); pLodDirectory.uDataSize =sizeof(Timer);// 40; if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); } strcpy(pLodDirectory.pFilename, "overlay.bin"); pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008; if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); } strcpy(pLodDirectory.pFilename, "npcdata.bin"); pLodDirectory.uDataSize = 501 * sizeof(NPCData); assert(pLodDirectory.uDataSize == 38076); if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); } strcpy(pLodDirectory.pFilename, "npcgroup.bin"); pLodDirectory.uDataSize = 102; if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0); } for (int i = 1; i <= 4; ++i) // 4 - players { for (int j = 1; j <= 5; ++j) // 5 - images { sprintf(Str, "data\\lloyd%d%d.pcx", i, j); v8 = fopen(Str, "rb"); if ( v8 ) { __debugbreak(); sprintf(Str, "lloyd%d%d.pcx", i, j); fseek(v8, 0, 2); pLodDirectory.uDataSize = ftell(v8); rewind(v8); fread(uncompressed_buff, pLodDirectory.uDataSize, 1, v8); strcpy((char *)&pLodDirectory, Str); fclose(v8); remove(Str); if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); Size = 5080748; } } } } if ( !NotSaveWorld ) { //__debugbreak(); CompactLayingItemsList(); compressed_buf = (char*)malloc(1000000); // v71 = (std::string *)compressed_buf; Src.uVersion = 91969; Src.pMagic[0] = 'm'; Src.pMagic[1] = 'v'; Src.pMagic[2] = 'i'; Src.pMagic[3] = 'i'; Src.uCompressedSize = 0; Src.uDecompressedSize = 0; data_write_pos = uncompressed_buff; memcpy((void *)compressed_buf, &Src, 0x10); if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) { pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces; pIndoor->dlv.uNumBModels = 0; pIndoor->dlv.uNumDecorations = uNumLevelDecorations; memcpy(data_write_pos, &pIndoor->dlv, 0x28); data_write_pos += 40; memcpy(data_write_pos, pIndoor->_visible_outlines, 0x36B); data_write_pos += 875; for (int i = 0; i <(signed int)pIndoor->uNumFaces; ++i) { memcpy(data_write_pos, &pIndoor->pFaces[i].uAttributes, 4); data_write_pos += 4; } for (int i = 0; i <(signed int)uNumLevelDecorations; ++i) { memcpy(data_write_pos, &pLevelDecorations[i].field_2, 2); data_write_pos+= 2; } memcpy(data_write_pos, &uNumActors, 4); data_write_pos += 4; memcpy(data_write_pos, pActors, 836 * uNumActors); data_write_pos += 836 * uNumActors; memcpy(data_write_pos, &uNumSpriteObjects, 4); data_write_pos += 4; memcpy(data_write_pos, pSpriteObjects, 112 * uNumSpriteObjects); data_write_pos += 112 * uNumSpriteObjects; memcpy(data_write_pos, &uNumChests, 4); data_write_pos += 4; memcpy(data_write_pos, pChests, 5324 * uNumChests); data_write_pos += 5324 * uNumChests; memcpy(data_write_pos, pIndoor->pDoors, 0x3E80); data_write_pos += 16000; memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size); data_write_pos += pIndoor->blv.uDoors_ddata_Size; memcpy(data_write_pos, &stru_5E4C90, 0xC8); data_write_pos += 200; memcpy(data_write_pos, &pIndoor->stru1, 0x38); data_write_pos += 56; } else { v18 = 0; pOutdoor->ddm.uNumFacesInBModels = 0; for (int i=0; i<pOutdoor->uNumBModels;++i) { v18 +=pOutdoor->pBModels[i].uNumFaces; } pOutdoor->ddm.uNumFacesInBModels = v18; pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels; pOutdoor->ddm.uNumDecorations = uNumLevelDecorations; memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28 data_write_pos += sizeof(DDM_DLV_Header); memcpy(data_write_pos, pOutdoor->uUndiscoveredArea, 0x3C8); data_write_pos += 968; memcpy(data_write_pos, pOutdoor->uDicovered_area, 0x3C8); data_write_pos += 968; if ( (signed int)pOutdoor->uNumBModels > 0 ) { v23 = pOutdoor->pBModels; v24 = 76; for (int i = 0; i < (signed int)pOutdoor->uNumBModels ; ++i) { //v25 = v23[i].uNumFaces == 0;//*(int *)&v23->pModelName[v24] == 0; // v26 = v23[i].uNumFaces < 0;//*(int *)&v23->pModelName[v24] < 0; if ( pOutdoor->pBModels[i].uNumFaces>0) { v68 = 0; for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j) { v38 = &(v23[i].pFaces[j].uAttributes); //(char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28; memcpy(data_write_pos, v38, 4); v23 = pOutdoor->pBModels; v68 += 154; data_write_pos += 4; } } v24 += 188; } } if ( (signed int)uNumLevelDecorations > 0 ) { v66 = &pLevelDecorations[0].field_2; for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i) { memcpy(data_write_pos, v66, 2); v66 += 16; data_write_pos += 2; } } memcpy(data_write_pos, &uNumActors, 4); data_write_pos += 4; memcpy(data_write_pos, pActors, 836 * uNumActors); data_write_pos += 836 * uNumActors; memcpy(data_write_pos, &uNumSpriteObjects, 4); data_write_pos += 4; memcpy(data_write_pos, pSpriteObjects, 112 * uNumSpriteObjects); data_write_pos += 112 * uNumSpriteObjects; memcpy(data_write_pos, &uNumChests, 4); data_write_pos += 4; memcpy(data_write_pos, pChests, 5324 * uNumChests); data_write_pos += 5324 * uNumChests; memcpy(data_write_pos, &stru_5E4C90, 0xC8); data_write_pos += 200; memcpy(data_write_pos, &pOutdoor->loc_time, 0x38); data_write_pos += 56; //compressed_buf = (int)v71; } strcpy(Source, pCurrentMapName); _splitpath(Source, Drive, Dir, Filename, Ext); v48 = 100; Size = (int)data_write_pos - (int)uncompressed_buff; compressed_block_size = 999984; LOBYTE(v33) = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size); if ( v33 || (signed int)compressed_block_size > (signed int)Size ) { memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size); compressed_block_size = Size; } compressed_block_size += 16; memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4); memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4); sprintf(Source, "%s%s", &Filename, &Ext); strcpy((char *)&pLodDirectory, Source); pLodDirectory.uDataSize = compressed_block_size; if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 208); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); } free((void *)compressed_buf); } free(uncompressed_buff); if ( IsAutoSAve ) { if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) ) { v34 = GetLastError(); FormatMessageA(0x1000, 0, v34, 0x400, &Buffer, 0x80, 0); sprintf(Str, pGlobalTXT_LocalizationStrings[612], 300); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0); } } pParty->vPosition.x = pPositionX; pParty->vPosition.y = v51; pParty->vPosition.z = v62; pParty->uFallStartY = v62; pParty->sRotationY = v53; pParty->sRotationX = v54; } //----- (00460078) -------------------------------------------------------- void __fastcall DoSavegame(unsigned int uSlot) { //unsigned int v1; // esi@1 //int v2; // esi@2 //RGBTexture *v3; // ebx@3 int bNotArena; // [sp+2Ch] [bp-8h]@1 //unsigned int v6; // [sp+30h] [bp-4h]@1 //__debugbreak(); //v1 = uSlot; //v6 = uSlot; bNotArena = _strcmpi(pCurrentMapName, "d05.blv"); if ( bNotArena ) { LOD::Directory pDir; // [sp+Ch] [bp-28h]@2 SaveGame(0, 0); //v2 = 100 * v1; strcpy(pSavegameHeader[uSlot].pLocationName, pCurrentMapName); pSavegameHeader[uSlot].uWordTime = pParty->uTimePlayed; strcpy(pDir.pFilename, "header.bin"); pDir.uDataSize = 100; pNew_LOD->Write(&pDir, &pSavegameHeader[uSlot], 0); sprintf(pTmpBuf, "saves\\save%03d.mm7", uSlot); pNew_LOD->CloseWriteFile(); CopyFileA("data\\new.lod", pTmpBuf, 0); } GUI_UpdateWindows(); pGUIWindow_CurrentMenu->Release(); pCurrentScreen = SCREEN_GAME; //v3 = pSavegameThumbnails; viewparams->bRedrawGameUI = 1; for (uint i = 0; i < 45; i++) pSavegameThumbnails[i].Release(); //while ( (signed int)v3 < (signed int)&unk_6A0758 ); if ( bNotArena ) pNew_LOD->_4621A7(); else ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena" pIcons_LOD->_4355F7(); pEventTimer->Resume(); ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!" viewparams->bRedrawGameUI = true; } // 4E28F8: using guessed type int pCurrentScreen; //----- (0045E297) -------------------------------------------------------- void SavegameList::Initialize(unsigned int bHideEmptySlots) { memset(pSavegameList, 0, 0x3138); // Reset(); uNumSavegameFiles = 0; _chdir("saves"); { if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7 strcpy(pSavegameList->pFileList[uNumSavegameFiles++].pSaveFileName, pGlobalTXT_LocalizationStrings[613]); for (uint i = 0; i < 40; ++i) { sprintf(pTmpBuf, "save%03d.mm7", i); if (_access(pTmpBuf, 0) == -1) continue; uint idx = i; if (!bHideEmptySlots) idx = uNumSavegameFiles; strcpy(pSavegameList->pFileList[idx].pSaveFileName, pTmpBuf); ++uNumSavegameFiles; } } _chdir(".."); }