1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-05 00:49:09 +02:00

Fix and simplify game saving / loading

This commit is contained in:
Ivan Savenko
2025-04-12 21:25:23 +03:00
parent f5f8ed192b
commit 966468f3fa
16 changed files with 128 additions and 213 deletions

View File

@ -160,16 +160,15 @@ CMapOverviewWidget::CMapOverviewWidget(CMapOverview& parent):
std::unique_ptr<CMap> campaignMap = nullptr;
if(p.tabType != ESelectionScreen::newGame && config["variables"]["mapPreviewForSaves"].Bool())
{
CLoadFile lf(*CResourceHandler::get()->getResourceName(ResourcePath(p.resource.getName(), EResType::SAVEGAME)), ESerializationVersion::MINIMAL);
lf.checkMagicBytes(SAVEGAME_MAGIC);
CLoadFile lf(*CResourceHandler::get()->getResourceName(ResourcePath(p.resource.getName(), EResType::SAVEGAME)), nullptr);
CMapHeader mapHeader;
StartInfo startInfo;
lf.load(mapHeader);
lf.load(startInfo);
auto mapHeader = std::make_unique<CMapHeader>();
std::unique_ptr<StartInfo> startInfo;
lf >> *(mapHeader) >> startInfo;
if(startInfo->campState)
campaignMap = startInfo->campState->getMap(*startInfo->campState->currentScenario(), nullptr);
res = ResourcePath(startInfo->fileURI, EResType::MAP);
if(startInfo.campState)
campaignMap = startInfo.campState->getMap(*startInfo.campState->currentScenario(), nullptr);
res = ResourcePath(startInfo.fileURI, EResType::MAP);
}
if(!campaignMap)
minimaps = createMinimaps(res);