mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Fix obstacles escaping for twohex creatures
This commit is contained in:
@@ -1179,17 +1179,8 @@ ReachabilityInfo CBattleInfoCallback::makeBFS(const AccessibilityInfo &accessibi
|
|||||||
hexq.pop();
|
hexq.pop();
|
||||||
|
|
||||||
//walking stack can't step past the obstacles
|
//walking stack can't step past the obstacles
|
||||||
//TODO what if second hex of two-hex creature enters obstacles
|
if(curHex != params.startPosition && isInObstacle(curHex, obstacles, params))
|
||||||
if(curHex != params.startPosition && vstd::contains(obstacles, curHex))
|
|
||||||
{
|
|
||||||
if(curHex == ESiegeHex::GATE_BRIDGE)
|
|
||||||
{
|
|
||||||
if(battleGetGateState() != EGateState::DESTROYED && params.side == BattleSide::ATTACKER)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int costToNeighbour = ret.distances[curHex.hex] + 1;
|
const int costToNeighbour = ret.distances[curHex.hex] + 1;
|
||||||
for(BattleHex neighbour : BattleHex::neighbouringTilesCache[curHex.hex])
|
for(BattleHex neighbour : BattleHex::neighbouringTilesCache[curHex.hex])
|
||||||
@@ -1211,6 +1202,31 @@ ReachabilityInfo CBattleInfoCallback::makeBFS(const AccessibilityInfo &accessibi
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CBattleInfoCallback::isInObstacle(
|
||||||
|
BattleHex hex,
|
||||||
|
const std::set<BattleHex> & obstacles,
|
||||||
|
const ReachabilityInfo::Parameters & params) const
|
||||||
|
{
|
||||||
|
auto occupiedHexes = battle::Unit::getHexes(hex, params.doubleWide, params.side);
|
||||||
|
|
||||||
|
for(auto occupiedHex : occupiedHexes)
|
||||||
|
{
|
||||||
|
if(vstd::contains(obstacles, occupiedHex))
|
||||||
|
{
|
||||||
|
if(occupiedHex == ESiegeHex::GATE_BRIDGE)
|
||||||
|
{
|
||||||
|
if(battleGetGateState() != EGateState::DESTROYED && params.side == BattleSide::ATTACKER)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::set<BattleHex> CBattleInfoCallback::getStoppers(BattlePerspective::BattlePerspective whichSidePerspective) const
|
std::set<BattleHex> CBattleInfoCallback::getStoppers(BattlePerspective::BattlePerspective whichSidePerspective) const
|
||||||
{
|
{
|
||||||
std::set<BattleHex> ret;
|
std::set<BattleHex> ret;
|
||||||
|
@@ -142,5 +142,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
ReachabilityInfo getFlyingReachability(const ReachabilityInfo::Parameters & params) const;
|
ReachabilityInfo getFlyingReachability(const ReachabilityInfo::Parameters & params) const;
|
||||||
ReachabilityInfo makeBFS(const AccessibilityInfo & accessibility, const ReachabilityInfo::Parameters & params) const;
|
ReachabilityInfo makeBFS(const AccessibilityInfo & accessibility, const ReachabilityInfo::Parameters & params) const;
|
||||||
|
bool isInObstacle(BattleHex hex, const std::set<BattleHex> & obstacles, const ReachabilityInfo::Parameters & params) const;
|
||||||
std::set<BattleHex> getStoppers(BattlePerspective::BattlePerspective whichSidePerspective) const; //get hexes with stopping obstacles (quicksands)
|
std::set<BattleHex> getStoppers(BattlePerspective::BattlePerspective whichSidePerspective) const; //get hexes with stopping obstacles (quicksands)
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user