From 76a71226a2209ee7d8ca64a84ff3d4832883f079 Mon Sep 17 00:00:00 2001 From: Adriankhl Date: Fri, 24 Mar 2023 22:43:41 +0100 Subject: [PATCH] Deactivate activeStack during spellCast --- client/battle/BattleInterface.cpp | 9 +++++++++ client/battle/BattleStacksController.cpp | 9 +++++++++ client/battle/BattleStacksController.h | 4 +++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/client/battle/BattleInterface.cpp b/client/battle/BattleInterface.cpp index c4769d545..8ef4f4b73 100644 --- a/client/battle/BattleInterface.cpp +++ b/client/battle/BattleInterface.cpp @@ -310,6 +310,12 @@ void BattleInterface::spellCast(const BattleSpellCast * sc) { windowObject->blockUI(true); + // Disable current active stack duing the cast + // Store the current activeStack to stackToActivate + stacksController->deactivateStack(); + + CCS->curh->set(Cursor::Combat::BLOCKED); + const SpellID spellID = sc->spellID; const CSpell * spell = spellID.toSpell(); auto targetedTile = sc->tile; @@ -551,6 +557,9 @@ void BattleInterface::endAction(const BattleAction* action) { const CStack *stack = curInt->cb->battleGetStackByID(action->stackNumber); + // Activate stack from stackToActivate because this might have been temporary disabled, e.g., during spell cast + activateStack(); + stacksController->endAction(action); windowObject->updateQueue(); diff --git a/client/battle/BattleStacksController.cpp b/client/battle/BattleStacksController.cpp index 561c1874c..6cf219854 100644 --- a/client/battle/BattleStacksController.cpp +++ b/client/battle/BattleStacksController.cpp @@ -683,6 +683,15 @@ void BattleStacksController::stackActivated(const CStack *stack) owner.activateStack(); } +void BattleStacksController::deactivateStack() +{ + if (!activeStack) { + return; + } + stackToActivate = activeStack; + setActiveStack(nullptr); +} + void BattleStacksController::activateStack() { if ( !currentAnimations.empty()) diff --git a/client/battle/BattleStacksController.h b/client/battle/BattleStacksController.h index 3cce90334..8fe4f6ab0 100644 --- a/client/battle/BattleStacksController.h +++ b/client/battle/BattleStacksController.h @@ -118,7 +118,9 @@ public: void startAction(const BattleAction* action); void endAction(const BattleAction* action); - void activateStack(); //sets activeStack to stackToActivate etc. //FIXME: No, it's not clear at all + void deactivateStack(); //copy activeStack to stackToActivate, then set activeStack to nullptr to temporary disable current stack + + void activateStack(); //copy stackToActivate to activeStack to enable controls of the stack void setActiveStack(const CStack *stack); void setSelectedStack(const CStack *stack);