mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
vcmi: really correct BFS
AFAIK, all is working as H3.
This commit is contained in:
parent
26db14b7b4
commit
88a7b3141d
@ -932,6 +932,8 @@ ReachabilityInfo CBattleInfoCallback::makeBFS(const AccessibilityInfo &accessibi
|
||||
return ret;
|
||||
|
||||
const std::set<BattleHex> obstacles = getStoppers(params.perspective);
|
||||
auto checkParams = params;
|
||||
checkParams.ignoreKnownAccessible = true; //Ignore starting hexes obstacles
|
||||
|
||||
std::queue<BattleHex> hexq; //bfs queue
|
||||
|
||||
@ -949,7 +951,7 @@ ReachabilityInfo CBattleInfoCallback::makeBFS(const AccessibilityInfo &accessibi
|
||||
hexq.pop();
|
||||
|
||||
//walking stack can't step past the obstacles
|
||||
if(curHex != params.startPosition && isInObstacle(curHex, obstacles, params))
|
||||
if(isInObstacle(curHex, obstacles, checkParams))
|
||||
continue;
|
||||
|
||||
const int costToNeighbour = ret.distances[curHex.hex] + 1;
|
||||
@ -982,6 +984,9 @@ bool CBattleInfoCallback::isInObstacle(
|
||||
|
||||
for(auto occupiedHex : occupiedHexes)
|
||||
{
|
||||
if(params.ignoreKnownAccessible && vstd::contains(params.knownAccessible, occupiedHex))
|
||||
continue;
|
||||
|
||||
if(vstd::contains(obstacles, occupiedHex))
|
||||
{
|
||||
if(occupiedHex == ESiegeHex::GATE_BRIDGE)
|
||||
|
@ -28,6 +28,7 @@ struct DLL_LINKAGE ReachabilityInfo
|
||||
ui8 side = 0;
|
||||
bool doubleWide = false;
|
||||
bool flying = false;
|
||||
bool ignoreKnownAccessible = false; //Ignore obstacles if it is in accessible hexes
|
||||
std::vector<BattleHex> knownAccessible; //hexes that will be treated as accessible, even if they're occupied by stack (by default - tiles occupied by stack we do reachability for, so it doesn't block itself)
|
||||
|
||||
BattleHex startPosition; //assumed position of stack
|
||||
|
Loading…
x
Reference in New Issue
Block a user