mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
No longer save/load common game state to/from client file
This commit is contained in:
@@ -202,8 +202,20 @@ void CClient::loadGame(CGameState * initializedGameState)
|
||||
{
|
||||
logNetwork->info("Loading procedure started!");
|
||||
|
||||
std::unique_ptr<CLoadFile> loader;
|
||||
// try to assign loader, which is needed to deserialize data such as sleepingHeroes
|
||||
logNetwork->info("Game state was transferred over network, loading.");
|
||||
gs = initializedGameState;
|
||||
|
||||
gs->preInit(VLC);
|
||||
gs->updateOnLoad(CSH->si.get());
|
||||
logNetwork->info("Game loaded, initialize interfaces.");
|
||||
|
||||
initMapHandler();
|
||||
|
||||
reinitScripting();
|
||||
|
||||
initPlayerEnvironments();
|
||||
|
||||
// try to deserialize client data including sleepingHeroes
|
||||
try
|
||||
{
|
||||
boost::filesystem::path clientSaveName = *CResourceHandler::get("local")->getResourceName(ResourceID(CSH->si->mapname, EResType::CLIENT_SAVEGAME));
|
||||
@@ -225,40 +237,16 @@ void CClient::loadGame(CGameState * initializedGameState)
|
||||
throw std::runtime_error("Cannot open server part of " + CSH->si->mapname);
|
||||
|
||||
CLoadIntegrityValidator checkingLoader(clientSaveName, controlServerSaveName, MINIMAL_SERIALIZATION_VERSION);
|
||||
loadCommonState(checkingLoader);
|
||||
loader = checkingLoader.decay();
|
||||
std::unique_ptr<CLoadFile> loader = checkingLoader.decay();
|
||||
serialize(loader->serializer, loader->serializer.fileVersion);
|
||||
|
||||
logNetwork->trace("Loaded common part of save %d ms", CSH->th->getDiff());
|
||||
logNetwork->info("Client data loaded.");
|
||||
}
|
||||
catch(std::exception & e)
|
||||
{
|
||||
if(initializedGameState)
|
||||
{
|
||||
logNetwork->info("Game state was transferred over network, loading.");
|
||||
// if loader can't be assigned, use the game state transferred from network if exist
|
||||
gs = initializedGameState;
|
||||
}
|
||||
else
|
||||
{
|
||||
logGlobal->error("Cannot load game %s. Error: %s", CSH->si->mapname, e.what());
|
||||
throw; //obviously we cannot continue here
|
||||
}
|
||||
logGlobal->info("Cannot load client data for game %s. Error: %s", CSH->si->mapname, e.what());
|
||||
}
|
||||
|
||||
gs->preInit(VLC);
|
||||
gs->updateOnLoad(CSH->si.get());
|
||||
logNetwork->info("Game loaded, initialize interfaces.");
|
||||
|
||||
initMapHandler();
|
||||
|
||||
reinitScripting();
|
||||
|
||||
initPlayerEnvironments();
|
||||
|
||||
// deserialize data including sleepingHeroes
|
||||
if(loader)
|
||||
serialize(loader->serializer, loader->serializer.fileVersion);
|
||||
|
||||
initPlayerInterfaces();
|
||||
}
|
||||
|
||||
|
@@ -833,7 +833,6 @@ void ApplyClientNetPackVisitor::visitSaveGameClient(SaveGameClient & pack)
|
||||
try
|
||||
{
|
||||
CSaveFile save(*CResourceHandler::get()->getResourceName(ResourceID(stem.to_string(), EResType::CLIENT_SAVEGAME)));
|
||||
cl.saveCommonState(save);
|
||||
save << cl;
|
||||
}
|
||||
catch(std::exception &e)
|
||||
|
@@ -224,11 +224,11 @@ void SelectionTab::toggleMode()
|
||||
|
||||
case ESelectionScreen::loadGame:
|
||||
inputName->disable();
|
||||
parseSaves(getFiles("Saves/", EResType::CLIENT_SAVEGAME));
|
||||
parseSaves(getFiles("Saves/", EResType::SERVER_SAVEGAME));
|
||||
break;
|
||||
|
||||
case ESelectionScreen::saveGame:
|
||||
parseSaves(getFiles("Saves/", EResType::CLIENT_SAVEGAME));
|
||||
parseSaves(getFiles("Saves/", EResType::SERVER_SAVEGAME));
|
||||
inputName->enable();
|
||||
restoreLastSelection();
|
||||
break;
|
||||
|
Reference in New Issue
Block a user