From 49691ef7431caed28d74bb8e2d9ba6dd87b9b8cc Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 27 Apr 2024 12:40:22 +0300 Subject: [PATCH] Unblock interface during turn of another human player --- client/CPlayerInterface.cpp | 1 - client/adventureMap/AdventureMapInterface.cpp | 3 --- client/adventureMap/AdventureMapShortcuts.cpp | 6 ++--- client/mapView/MapViewController.cpp | 24 ++++++++++++++----- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 12ff0c09a..1ff10cfc4 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1215,7 +1215,6 @@ void CPlayerInterface::loadGame( BinaryDeserializer & h ) void CPlayerInterface::moveHero( const CGHeroInstance *h, const CGPath& path ) { - assert(LOCPLINT->makingTurn); assert(h); assert(!showingDialog->get()); assert(dialogs.empty()); diff --git a/client/adventureMap/AdventureMapInterface.cpp b/client/adventureMap/AdventureMapInterface.cpp index 9432cb9c1..c89e71598 100644 --- a/client/adventureMap/AdventureMapInterface.cpp +++ b/client/adventureMap/AdventureMapInterface.cpp @@ -510,9 +510,6 @@ void AdventureMapInterface::onTileLeftClicked(const int3 &targetPosition) if(!shortcuts->optionMapViewActive()) return; - if(!LOCPLINT->makingTurn) - return; - const CGObjectInstance *topBlocking = LOCPLINT->cb->isVisible(targetPosition) ? getActiveObject(targetPosition) : nullptr; if(spellBeingCasted) diff --git a/client/adventureMap/AdventureMapShortcuts.cpp b/client/adventureMap/AdventureMapShortcuts.cpp index 847666223..4431a6c3c 100644 --- a/client/adventureMap/AdventureMapShortcuts.cpp +++ b/client/adventureMap/AdventureMapShortcuts.cpp @@ -475,16 +475,16 @@ bool AdventureMapShortcuts::optionInWorldView() bool AdventureMapShortcuts::optionSidePanelActive() { - return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW; + return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW || state == EAdventureState::OTHER_HUMAN_PLAYER_TURN; } bool AdventureMapShortcuts::optionMapScrollingActive() { - return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW || (state == EAdventureState::OTHER_HUMAN_PLAYER_TURN); + return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW || state == EAdventureState::OTHER_HUMAN_PLAYER_TURN; } bool AdventureMapShortcuts::optionMapViewActive() { return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW || state == EAdventureState::CASTING_SPELL - || (state == EAdventureState::OTHER_HUMAN_PLAYER_TURN); + || state == EAdventureState::OTHER_HUMAN_PLAYER_TURN; } diff --git a/client/mapView/MapViewController.cpp b/client/mapView/MapViewController.cpp index 5a0a4d873..c0daae4b2 100644 --- a/client/mapView/MapViewController.cpp +++ b/client/mapView/MapViewController.cpp @@ -16,6 +16,7 @@ #include "MapViewCache.h" #include "MapViewModel.h" +#include "../CCallback.h" #include "../CPlayerInterface.h" #include "../adventureMap/AdventureMapInterface.h" #include "../gui/CGuiHandler.h" @@ -23,6 +24,7 @@ #include "../eventsSDL/InputHandler.h" #include "../../lib/CConfigHandler.h" +#include "../../lib/StartInfo.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/MiscObjects.h" #include "../../lib/pathfinder/CGPathNode.h" @@ -295,9 +297,14 @@ bool MapViewController::isEventVisible(const CGObjectInstance * obj, const Playe if(!GH.windows().isTopWindow(adventureInt)) return false; - // do not focus on actions of other players during our turn (e.g. simturns) - if (LOCPLINT->makingTurn && initiator != LOCPLINT->playerID) - return false; + // do not focus on actions of other players except for AI with simturns off + if (initiator != LOCPLINT->playerID) + { + if (LOCPLINT->makingTurn) + return false; + if (LOCPLINT->cb->getStartInfo()->playerInfos.at(initiator).isControlledByHuman()) + return false; + } if(obj->isVisitable()) return context->isVisible(obj->visitablePos()); @@ -316,9 +323,14 @@ bool MapViewController::isEventVisible(const CGHeroInstance * obj, const int3 & if(!GH.windows().isTopWindow(adventureInt)) return false; - // do not focus on actions of other players during our turn (e.g. simturns) - if (LOCPLINT->makingTurn && obj->getOwner() != LOCPLINT->playerID) - return false; + // do not focus on actions of other players except for AI with simturns off + if (obj->getOwner() != LOCPLINT->playerID) + { + if (LOCPLINT->makingTurn) + return false; + if (LOCPLINT->cb->getStartInfo()->playerInfos.at(obj->getOwner()).isControlledByHuman()) + return false; + } if(context->isVisible(obj->convertToVisitablePos(from))) return true;