Mercurial > might-and-magic-trilogy
view SaveLoad.cpp @ 125:b90504bbb93b
Merge
author | Nomad |
---|---|
date | Fri, 16 Nov 2012 13:58:59 +0200 |
parents | a64b244da76c |
children | 062e8a8e09bc |
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 "LayingItem.h" #include "Viewport.h" #include "stru123.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 = 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 (byte_4ED498) for (uint i = 0; i < 4; ++i) { for (uint j = 0; j < pSoundList->uNumSounds; ++j) if (pSoundList->pSounds[j].uSoundID == 2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4998) { pSoundList->_4A9DCD(j, 1); break; } for (uint j = 0; j < pSoundList->uNumSounds; ++j) if (pSoundList->pSounds[j].uSoundID == 2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4999) { pSoundList->_4A9DCD(j, 1); break; } } sprintf(pTmpBuf, "saves\\%s", pSavegameList->pSavesNames[uSlot]); 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(); v31 = *((int *)&pSpellDatas[66].field_8 + uItemID); stru_A750F8[i]._494836(v31, i + 9); } } } } pGUIWindow_CurrentMenu->Release(); pCurrentScreen = 0; viewparams->bRedrawGameUI = true; SetUserInterface(pParty->uAlignment, 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.0); pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0); if (uTurnSpeed) pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed; MM7Initialization(); bFlashQuestBook = false; viewparams->bRedrawGameUI = true; } //----- (0045F469) -------------------------------------------------------- int __fastcall SaveGame(int a1, __int16 *a2) { int result; // eax@1 void *pScreenshot; // edi@5 int v4; // eax@6 int v5; // eax@6 int v6; // eax@6 const char *v7; // edi@8 FILE *v8; // edi@24 int v9; // 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 char *v20; // edx@39 void *v21; // 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 const char *v38; // [sp-8h] [bp-278h]@8 CHAR Buffer; // [sp+Ch] [bp-264h]@59 char Dir; // [sp+8Ch] [bp-1E4h]@51 char Drive; // [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; // [sp+130h] [bp-140h]@51 char Ext; // [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 int 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 pDir; // [sp+22Ch] [bp-44h]@2 size_t Size; // [sp+250h] [bp-20h]@26 __int16 *v66; // [sp+254h] [bp-1Ch]@1 void *DstBuf; // [sp+258h] [bp-18h]@2 __int16 *v68; // [sp+25Ch] [bp-14h]@32 unsigned int v69; // [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")) return false; DstBuf = malloc(0xF4240); pDir.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->uLastVisitDay = pParty->uTimePlayed; pScreenshot = MakeScreenshot(150, 112); strcpy(pDir.pFilename, "image.pcx"); pRenderer->_49F5A2((int)pScreenshot, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize); free(pScreenshot); if (pCurrentScreen == 11) //SaveScreen { pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); pRenderer->DrawTextureIndexed(0x12, 0x8D, (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0)); v4 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[190]); pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение v5 = pFontSmallnum->AlignText_Center(0xBA, (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot); pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot), 185, 0); v6 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[165]); pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите pRenderer->Present(); } if (pNew_LOD->Write(&pDir, DstBuf, 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); strcpy(header.pLocationName, pCurrentMapName); header.uWordTime = pParty->uTimePlayed; strcpy(pDir.pFilename, "header.bin"); pDir.uDataSize = sizeof(SavegameHeader); if (pNew_LOD->Write(&pDir, &header, 0)) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); } strcpy(pDir.pFilename, "party.bin"); pDir.uDataSize = 90680; if ( pNew_LOD->Write(&pDir, pParty, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); } strcpy(pDir.pFilename, "clock.bin"); pDir.uDataSize = 40; if ( pNew_LOD->Write(&pDir, pEventTimer, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); } strcpy(pDir.pFilename, "overlay.bin"); pDir.uDataSize = 1008; if ( pNew_LOD->Write(&pDir, pOtherOverlayList, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); } strcpy(pDir.pFilename, "npcdata.bin"); pDir.uDataSize = 38076; if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); } strcpy(pDir.pFilename, "npcgroup.bin"); pDir.uDataSize = 102; if ( pNew_LOD->Write(&pDir, 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); pDir.uDataSize = ftell(v8); rewind(v8); fread(DstBuf, pDir.uDataSize, 1, v8); strcpy((char *)&pDir, Str); fclose(v8); remove(Str); if ( pNew_LOD->Write(&pDir, DstBuf, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); Size = 5080748; } } } } if ( !a2 ) { __debugbreak(); sub_42FA22_mess_with_laying_item_list(); v9 = (int)malloc(0xF4240); v71 = (std::string *)v9; Src = 91969; v56 = 109; v57 = 118; v58 = 105; v59 = 105; v60 = 0; v61 = 0; memcpy((void *)v9, &Src, 0x10); if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) { __debugbreak(); pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces; pIndoor->dlv.uNumBModels = 0; pIndoor->dlv.uNumDecorations = uNumLevelDecorations; memcpy(DstBuf, &pIndoor->dlv, 0x28); v10 = (char *)DstBuf + 40; memcpy(v10, pIndoor->_visible_outlines, 0x36B); v11 = (char *)v10 + 875; if ( (signed int)pIndoor->uNumFaces > 0 ) { v68 = 0; for (int i = 0; i <= (signed int)pIndoor->uNumFaces; ++i) { v38 = (char *)v68 + (unsigned int)pIndoor->pFaces + 44; memcpy(v11, v38, 4); v68 += 48; v11 = (char *)v11 + 4; } } if ( (signed int)uNumLevelDecorations > 0 ) { v68 = &pLevelDecorations[0].field_2; for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i) { memcpy(v11, v68, 2); v68 += 16; v11 = (char *)v11 + 2; } } memcpy(v11, &uNumActors, 4); v12 = (char *)v11 + 4; memcpy(v12, pActors, 836 * uNumActors); v13 = (char *)v12 + 836 * uNumActors; memcpy(v13, &uNumLayingItems, 4); v13 = (char *)v13 + 4; memcpy(v13, pLayingItems, 112 * uNumLayingItems); v14 = (char *)v13 + 112 * uNumLayingItems; memcpy(v14, &uNumChests, 4); v14 = (char *)v14 + 4; memcpy(v14, pChests, 5324 * uNumChests); v15 = (char *)v14 + 5324 * uNumChests; memcpy(v15, pIndoor->pDoors, 0x3E80); v15 = (char *)v15 + 16000; memcpy(v15, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size); v16 = (char *)v15 + pIndoor->blv.uDoors_ddata_Size; memcpy(v16, &stru_5E4C90, 0xC8); v17 = (int)((char *)v16 + 200); memcpy((void *)v17, &pIndoor->stru1, 0x38); } else { v18 = 0; pOutdoor->ddm.uNumFacesInBModels = 0; if ( (signed int)pOutdoor->uNumBModels > 0 ) { v19 = pOutdoor->uNumBModels; v20 = (char *)&pOutdoor->pBModels->uNumFaces; do { v18 += *(int *)v20; v20 += 188; --v19; pOutdoor->ddm.uNumFacesInBModels = v18; } while ( v19 ); } v21 = DstBuf; pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels; pOutdoor->ddm.uNumDecorations = uNumLevelDecorations; memcpy(DstBuf, &pOutdoor->ddm, 0x28); v21 = (char *)v21 + 40; memcpy(v21, pOutdoor->array_528, 0x3C8); v21 = (char *)v21 + 968; memcpy(v21, pOutdoor->array_8F0, 0x3C8); v22 = (char *)v21 + 968; if ( (signed int)pOutdoor->uNumBModels > 0 ) { v23 = pOutdoor->pBModels; v24 = 76; for (int i = 0; i <= (signed int)pOutdoor->uNumBModels ; ++i) { v25 = *(int *)&v23->pModelName[v24] == 0; v26 = *(int *)&v23->pModelName[v24] < 0; if ( !(v26 | v25) ) { v68 = 0; for (int j = 0; j <= *(int *)&pOutdoor->pBModels->pModelName[v24]; ++j) { v38 = (char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28; memcpy(v22, v38, 4); v23 = pOutdoor->pBModels; v68 += 154; v22 = (char *)v22 + 4; } } v24 += 188; } } if ( (signed int)uNumLevelDecorations > 0 ) { v66 = &pLevelDecorations[0].field_2; for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i) { memcpy(v22, v66, 2); v66 += 16; v22 = (char *)v22 + 2; } } memcpy(v22, &uNumActors, 4); v28 = (char *)v22 + 4; memcpy(v28, pActors, 836 * uNumActors); v29 = (char *)v28 + 836 * uNumActors; memcpy(v29, &uNumLayingItems, 4); v29 = (char *)v29 + 4; memcpy(v29, pLayingItems, 112 * uNumLayingItems); v30 = (char *)v29 + 112 * uNumLayingItems; memcpy(v30, &uNumChests, 4); v30 = (char *)v30 + 4; memcpy(v30, pChests, 5324 * uNumChests); v31 = (char *)v30 + 5324 * uNumChests; memcpy(v31, &stru_5E4C90, 0xC8); v17 = (int)((char *)v31 + 200); memcpy((void *)v17, &pOutdoor->uLastVisitDay, 0x38); v9 = (int)v71; } v32 = v17 + 56; strcpy(Source, pCurrentMapName); _splitpath(Source, &Drive, &Dir, &Filename, &Ext); v48 = 100; Size = v32 - (int)DstBuf; v69 = 999984; LOBYTE(v33) = zlib::MemZip((char *)v9 + 16, (unsigned int *)&v69, DstBuf, v32 - (int)DstBuf); if ( v33 || (signed int)v69 > (signed int)Size ) { memcpy((void *)(v9 + 16), DstBuf, Size); v69 = Size; } v69 += 16; memcpy((void *)(v9 + 8), &v69, 4); memcpy((void *)(v9 + 12), &Size, 4); sprintf(Source, "%s%s", &Filename, &Ext); strcpy((char *)&pDir, Source); pDir.uDataSize = v69; if ( pNew_LOD->Write(&pDir, (const void *)v9, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 208); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); } free((void *)v9); } free(DstBuf); if ( a1 ) { 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; result = v54; pParty->sRotationX = v54; return result; } //----- (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->pLocationName[v2], pCurrentMapName); *(int *)((char *)&pSavegameHeader->uWordTime + v2) = LODWORD(pParty->uTimePlayed); *(int *)((char *)&pSavegameHeader->uWordTime + v2 + 4) = HIDWORD(pParty->uTimePlayed); strcpy((char *)&pDir, "header.bin"); pDir.uDataSize = 100; pNew_LOD->Write(&pDir, (char *)&pSavegameHeader + v2, 0); sprintf(pTmpBuf, "saves\\save%03d.mm7", v6); pNew_LOD->CloseWriteFile(); CopyFileA("data\\new.lod", pTmpBuf, 0); } GUI_UpdateWindows(); pGUIWindow_CurrentMenu->Release(); pCurrentScreen = 0; v3 = pSavegameThumbnails; viewparams->bRedrawGameUI = 1; do { v3->Release(); ++v3; } 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 = 1; } // 4E28F8: using guessed type int pCurrentScreen; //----- (0045E297) -------------------------------------------------------- void SavegameList::Initialize(unsigned int bHideEmptySlots) { uNumSavegameFiles = 0; _chdir("saves"); { if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) strcpy(pSavesNames[uNumSavegameFiles++], 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(pSavesNames[idx], pTmpBuf); ++uNumSavegameFiles; } } _chdir(".."); }