diff --git a/AI/BattleAI/BattleAI.cpp b/AI/BattleAI/BattleAI.cpp index 3db147573..f9824c70c 100644 --- a/AI/BattleAI/BattleAI.cpp +++ b/AI/BattleAI/BattleAI.cpp @@ -282,7 +282,7 @@ BattleAction CBattleAI::activeStack( const CStack * stack ) BattleAction CBattleAI::goTowardsNearest(const CStack * stack, std::vector hexes) const { auto reachability = cb->getReachability(stack); - auto avHexes = cb->battleGetAvailableHexes(reachability, stack, true); + auto avHexes = cb->battleGetAvailableHexes(reachability, stack, false); if(!avHexes.size() || !hexes.size()) //we are blocked or dest is blocked { diff --git a/AI/BattleAI/PotentialTargets.cpp b/AI/BattleAI/PotentialTargets.cpp index a817e8c30..8fbbec07c 100644 --- a/AI/BattleAI/PotentialTargets.cpp +++ b/AI/BattleAI/PotentialTargets.cpp @@ -15,7 +15,7 @@ PotentialTargets::PotentialTargets(const battle::Unit * attacker, const Hypothet { auto attackerInfo = state.battleGetUnitByID(attacker->unitId()); auto reachability = state.getReachability(attackerInfo); - auto avHexes = state.battleGetAvailableHexes(reachability, attackerInfo, true); + auto avHexes = state.battleGetAvailableHexes(reachability, attackerInfo, false); //FIXME: this should part of battleGetAvailableHexes bool forceTarget = false; diff --git a/AI/StupidAI/StupidAI.cpp b/AI/StupidAI/StupidAI.cpp index ba2e36463..0a66edefc 100644 --- a/AI/StupidAI/StupidAI.cpp +++ b/AI/StupidAI/StupidAI.cpp @@ -120,7 +120,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack ) } else { - std::vector avHexes = cb->battleGetAvailableHexes(stack, true); + std::vector avHexes = cb->battleGetAvailableHexes(stack, false); for (BattleHex hex : avHexes) { diff --git a/client/battle/BattleActionsController.cpp b/client/battle/BattleActionsController.cpp index 425cc59a6..256b897fd 100644 --- a/client/battle/BattleActionsController.cpp +++ b/client/battle/BattleActionsController.cpp @@ -620,7 +620,7 @@ void BattleActionsController::actionRealize(PossiblePlayerBattleAction action, B { if(owner.stacksController->getActiveStack()->doubleWide()) { - std::vector acc = owner.curInt->cb->battleGetAvailableHexes(owner.stacksController->getActiveStack(), true); + std::vector acc = owner.curInt->cb->battleGetAvailableHexes(owner.stacksController->getActiveStack(), false); BattleHex shiftedDest = targetHex.cloneInDirection(owner.stacksController->getActiveStack()->destShiftDir(), false); if(vstd::contains(acc, targetHex)) owner.giveCommand(EActionType::WALK, targetHex); diff --git a/client/battle/BattleFieldController.cpp b/client/battle/BattleFieldController.cpp index be67b14ea..4ebc2d93d 100644 --- a/client/battle/BattleFieldController.cpp +++ b/client/battle/BattleFieldController.cpp @@ -174,7 +174,7 @@ void BattleFieldController::redrawBackgroundWithHexes() const CStack *activeStack = owner.stacksController->getActiveStack(); std::vector attackableHexes; if(activeStack) - occupiableHexes = owner.curInt->cb->battleGetAvailableHexes(activeStack, true, true, &attackableHexes); + occupiableHexes = owner.curInt->cb->battleGetAvailableHexes(activeStack, false, true, &attackableHexes); // prepare background graphic with hexes and shaded hexes backgroundWithHexes->draw(background, Point(0,0)); @@ -252,7 +252,7 @@ std::set BattleFieldController::getMovementRangeForHoveredStack() const CStack * const hoveredStack = owner.curInt->cb->battleGetStackByPos(hoveredHex, true); if(hoveredStack) { - std::vector v = owner.curInt->cb->battleGetAvailableHexes(hoveredStack, false, true, nullptr); + std::vector v = owner.curInt->cb->battleGetAvailableHexes(hoveredStack, true, true, nullptr); for(BattleHex hex : v) result.insert(hex); } @@ -289,7 +289,7 @@ std::set BattleFieldController::getHighlightedHexesForSpellRange() return result; } -std::set BattleFieldController::getHighlightedHexesMovementTarget() +std::set BattleFieldController::getHighlightedHexesForMovementTarget() { const CStack * stack = owner.stacksController->getActiveStack(); auto hoveredHex = getHoveredHex(); @@ -297,7 +297,7 @@ std::set BattleFieldController::getHighlightedHexesMovementTarget() if(!stack) return {}; - std::vector availableHexes = owner.curInt->cb->battleGetAvailableHexes(stack, true, false, nullptr); + std::vector availableHexes = owner.curInt->cb->battleGetAvailableHexes(stack, false, false, nullptr); auto hoveredStack = owner.curInt->cb->battleGetStackByPos(hoveredHex, true); if(owner.curInt->cb->battleCanAttack(stack, hoveredStack, hoveredHex)) @@ -337,7 +337,7 @@ void BattleFieldController::showHighlightedHexes(Canvas & canvas) { std::set hoveredStackMovementRangeHexes = getMovementRangeForHoveredStack(); std::set hoveredSpellHexes = getHighlightedHexesForSpellRange(); - std::set hoveredMoveHexes = getHighlightedHexesMovementTarget(); + std::set hoveredMoveHexes = getHighlightedHexesForMovementTarget(); if(getHoveredHex() == BattleHex::INVALID) return; diff --git a/client/battle/BattleFieldController.h b/client/battle/BattleFieldController.h index 1697e75e5..ec2e8b830 100644 --- a/client/battle/BattleFieldController.h +++ b/client/battle/BattleFieldController.h @@ -53,7 +53,7 @@ class BattleFieldController : public CIntObject std::set getHighlightedHexesForActiveStack(); std::set getMovementRangeForHoveredStack(); std::set getHighlightedHexesForSpellRange(); - std::set getHighlightedHexesMovementTarget(); + std::set getHighlightedHexesForMovementTarget(); void showBackground(Canvas & canvas); void showBackgroundImage(Canvas & canvas); diff --git a/lib/battle/CBattleInfoCallback.cpp b/lib/battle/CBattleInfoCallback.cpp index 8b3fd21a4..cb63ee88a 100644 --- a/lib/battle/CBattleInfoCallback.cpp +++ b/lib/battle/CBattleInfoCallback.cpp @@ -546,7 +546,7 @@ void CBattleInfoCallback::battleGetTurnOrder(std::vector & turns, battleGetTurnOrder(turns, maxUnits, maxTurns, actualTurn + 1, sideThatLastMoved); } -std::vector CBattleInfoCallback::battleGetAvailableHexes(const battle::Unit * unit, bool isActiveStack) const +std::vector CBattleInfoCallback::battleGetAvailableHexes(const battle::Unit * unit, bool getMovementRange) const { RETURN_IF_NOT_BATTLE(std::vector()); @@ -555,10 +555,10 @@ std::vector CBattleInfoCallback::battleGetAvailableHexes(const battle auto reachability = getReachability(unit); - return battleGetAvailableHexes(reachability, unit, isActiveStack); + return battleGetAvailableHexes(reachability, unit, getMovementRange); } -std::vector CBattleInfoCallback::battleGetAvailableHexes(const ReachabilityInfo & cache, const battle::Unit * unit, bool isActiveStack) const +std::vector CBattleInfoCallback::battleGetAvailableHexes(const ReachabilityInfo & cache, const battle::Unit * unit, bool getMovementRange) const { std::vector ret; @@ -568,7 +568,7 @@ std::vector CBattleInfoCallback::battleGetAvailableHexes(const Reacha auto unitSpeed = unit->Speed(0, true); - const bool showTacticsRange = battleTacticDist() && battleGetTacticsSide() == unit->unitSide() && isActiveStack; + const bool tacticsPhase = battleTacticDist() && battleGetTacticsSide() == unit->unitSide(); for(int i = 0; i < GameConstants::BFIELD_SIZE; ++i) { @@ -576,7 +576,7 @@ std::vector CBattleInfoCallback::battleGetAvailableHexes(const Reacha if(!cache.isReachable(i)) continue; - if(showTacticsRange) + if(tacticsPhase && !getMovementRange) // if getMovementRange requested do not return tactics range { // Stack has to perform tactic-phase movement -> can enter any reachable tile within given range if(!isInTacticRange(i)) @@ -595,9 +595,9 @@ std::vector CBattleInfoCallback::battleGetAvailableHexes(const Reacha return ret; } -std::vector CBattleInfoCallback::battleGetAvailableHexes(const battle::Unit * unit, bool isActiveStack, bool addOccupiable, std::vector * attackable) const +std::vector CBattleInfoCallback::battleGetAvailableHexes(const battle::Unit * unit, bool getMovementRange, bool addOccupiable, std::vector * attackable) const { - std::vector ret = battleGetAvailableHexes(unit, isActiveStack); + std::vector ret = battleGetAvailableHexes(unit, getMovementRange); if(ret.empty()) return ret; diff --git a/lib/battle/CBattleInfoCallback.h b/lib/battle/CBattleInfoCallback.h index f25afb785..c40440b10 100644 --- a/lib/battle/CBattleInfoCallback.h +++ b/lib/battle/CBattleInfoCallback.h @@ -77,12 +77,12 @@ public: void battleGetTurnOrder(std::vector & out, const size_t maxUnits, const int maxTurns, const int turn = 0, int8_t lastMoved = -1) const; ///returns reachable hexes (valid movement destinations), DOES contain stack current position - std::vector battleGetAvailableHexes(const battle::Unit * unit, bool isActiveStack, bool addOccupiable, std::vector * attackable) const; + std::vector battleGetAvailableHexes(const battle::Unit * unit, bool getMovementRange, bool addOccupiable, std::vector * attackable) const; ///returns reachable hexes (valid movement destinations), DOES contain stack current position (lite version) - std::vector battleGetAvailableHexes(const battle::Unit * unit, bool isActiveStack) const; + std::vector battleGetAvailableHexes(const battle::Unit * unit, bool getMovementRange) const; - std::vector battleGetAvailableHexes(const ReachabilityInfo & cache, const battle::Unit * unit, bool isActiveStack) const; + std::vector battleGetAvailableHexes(const ReachabilityInfo & cache, const battle::Unit * unit, bool getMovementRange) const; int battleGetSurrenderCost(const PlayerColor & Player) const; //returns cost of surrendering battle, -1 if surrendering is not possible ReachabilityInfo::TDistances battleGetDistances(const battle::Unit * unit, BattleHex assumedPosition) const;