From 35fa06008b99e3134d8287b550ada7209777201a Mon Sep 17 00:00:00 2001 From: nordsoft Date: Fri, 14 Apr 2023 00:20:51 +0400 Subject: [PATCH] Revert "Auxiliary commit to revert individual files from fb4db41891e157f4f7d72ee759141754d2df680c" This reverts commit 129b15a49c911315789721b7e62b93757819519a. --- client/Client.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/client/Client.cpp b/client/Client.cpp index b75e7d617..47b29cb0f 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -586,29 +586,27 @@ void CClient::battleStarted(const BattleInfo * info) if(vstd::contains(playerint, rightSide.color) && playerint[rightSide.color]->human) def = std::dynamic_pointer_cast(playerint[rightSide.color]); - auto spectratorInterface = std::dynamic_pointer_cast(playerint[PlayerColor::SPECTATOR]); - //Remove player interfaces for auto battle (quickCombat option) if(att && att->isAutoFightOn) { att.reset(); def.reset(); - spectratorInterface.reset(); } - else if(!settings["session"]["headless"].Bool()) + + if(!settings["session"]["headless"].Bool()) { if(!!att || !!def) { boost::unique_lock un(*CPlayerInterface::pim); CPlayerInterface::battleInt = std::make_shared(leftSide.armyObject, rightSide.armyObject, leftSide.hero, rightSide.hero, att, def); } - else if(false && settings["session"]["spectate"].Bool() && !settings["session"]["spectate-skip-battle"].Bool()) + else if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-skip-battle"].Bool()) { - //spectator for AI-only battles //TODO: This certainly need improvement - spectratorInterface->cb->setBattle(info); + auto spectratorInt = std::dynamic_pointer_cast(playerint[PlayerColor::SPECTATOR]); + spectratorInt->cb->setBattle(info); boost::unique_lock un(*CPlayerInterface::pim); - CPlayerInterface::battleInt = std::make_shared(leftSide.armyObject, rightSide.armyObject, leftSide.hero, rightSide.hero, att, def, spectratorInterface); + CPlayerInterface::battleInt = std::make_shared(leftSide.armyObject, rightSide.armyObject, leftSide.hero, rightSide.hero, att, def, spectratorInt); } } @@ -644,7 +642,7 @@ void CClient::battleFinished() if(battleCallbacks.count(side.color)) battleCallbacks[side.color]->setBattle(nullptr); - if(battleCallbacks[PlayerColor::SPECTATOR]) + if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-skip-battle"].Bool()) battleCallbacks[PlayerColor::SPECTATOR]->setBattle(nullptr); setBattle(nullptr);