From a39e61373c11a6a6311b42a9cd86e62d2ef97adf Mon Sep 17 00:00:00 2001 From: Arseniy Shestakov Date: Sun, 10 Jan 2016 18:00:24 +0300 Subject: [PATCH] Deactivate CAdvMapInt while quick combat is going. Fix issue 2354 If quick combat calculation take a while it's possible to give hero movement command before battle is finished. This will lead to client freeze or crash. To avoid this we must lock adventure interface until battle calculation is finished. --- client/CPlayerInterface.cpp | 3 +++ client/windows/CAdvmapInterface.cpp | 12 ++++++++++++ client/windows/CAdvmapInterface.h | 2 ++ 3 files changed, 17 insertions(+) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index ffcf90eca..33040aef8 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -647,6 +647,8 @@ void CPlayerInterface::battleStart(const CCreatureSet *army1, const CCreatureSet autofightingAI->battleStart(army1, army2, int3(0,0,0), hero1, hero2, side); isAutoFightOn = true; cb->registerBattleInterface(autofightingAI); + // Player shouldn't be able to move on adventure map if quick combat is going + adventureInt->quickCombatLock(); } //Don't wait for dialogs when we are non-active hot-seat player @@ -843,6 +845,7 @@ void CPlayerInterface::battleEnd(const BattleResult *br) isAutoFightOn = false; cb->unregisterBattleInterface(autofightingAI); autofightingAI.reset(); + adventureInt->quickCombatUnlock(); if(!battleInt) { diff --git a/client/windows/CAdvmapInterface.cpp b/client/windows/CAdvmapInterface.cpp index 06558f5ad..34f547e1b 100644 --- a/client/windows/CAdvmapInterface.cpp +++ b/client/windows/CAdvmapInterface.cpp @@ -1707,6 +1707,18 @@ void CAdvMapInt::adjustActiveness(bool aiTurnStart) activate(); } +void CAdvMapInt::quickCombatLock() +{ + if(!duringAITurn) + deactivate(); +} + +void CAdvMapInt::quickCombatUnlock() +{ + if(!duringAITurn) + activate(); +} + void CAdvMapInt::changeMode(EAdvMapMode newMode, float newScale /* = 0.4f */) { if (mode != newMode) diff --git a/client/windows/CAdvmapInterface.h b/client/windows/CAdvmapInterface.h index 956bd5d69..9e2bf7be8 100644 --- a/client/windows/CAdvmapInterface.h +++ b/client/windows/CAdvmapInterface.h @@ -224,6 +224,8 @@ public: void aiTurnStarted(); void adjustActiveness(bool aiTurnStart); //should be called every time at AI/human turn transition; blocks GUI during AI turn + void quickCombatLock(); //should be called when quick battle started + void quickCombatUnlock(); void tileLClicked(const int3 &mapPos); void tileHovered(const int3 &mapPos); void tileRClicked(const int3 &mapPos);