1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +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

@@ -1544,12 +1544,10 @@ void CGameHandler::save(const std::string & filename)
try
{
{
CSaveFile save(*CResourceHandler::get("local")->getResourceName(savePath));
saveCommonState(save);
logGlobal->info("Saving server state");
save << *this;
}
CSaveFile save(*CResourceHandler::get("local")->getResourceName(savePath));
gameState()->saveGame(save);
logGlobal->info("Saving server state");
save.save(*this);
logGlobal->info("Game has been successfully saved!");
}
catch(std::exception &e)
@@ -1567,13 +1565,11 @@ bool CGameHandler::load(const std::string & filename)
try
{
{
CLoadFile lf(*CResourceHandler::get()->getResourceName(ResourcePath(stem.to_string(), EResType::SAVEGAME)), ESerializationVersion::MINIMAL);
lf.serializer.cb = this;
loadCommonState(lf);
logGlobal->info("Loading server state");
lf >> *this;
}
CLoadFile lf(*CResourceHandler::get()->getResourceName(ResourcePath(stem.to_string(), EResType::SAVEGAME)), this);
gs = std::make_shared<CGameState>(this);
gs->loadGame(lf);
logGlobal->info("Loading server state");
lf.load(*this);
logGlobal->info("Game has been successfully loaded!");
}
catch(const ModIncompatibility & e)