2017-06-24 15:51:07 +02:00
|
|
|
/*
|
|
|
|
* ReachabilityInfo.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-06-29 01:02:05 +02:00
|
|
|
#include "../StdInc.h"
|
2017-06-24 15:51:07 +02:00
|
|
|
#include "ReachabilityInfo.h"
|
2017-06-29 01:02:05 +02:00
|
|
|
#include "../CStack.h"
|
2017-06-24 15:51:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
ReachabilityInfo::Parameters::Parameters()
|
|
|
|
{
|
|
|
|
stack = nullptr;
|
|
|
|
perspective = BattlePerspective::ALL_KNOWING;
|
|
|
|
attackerOwned = doubleWide = flying = false;
|
|
|
|
}
|
|
|
|
|
2017-06-26 18:50:35 +02:00
|
|
|
ReachabilityInfo::Parameters::Parameters(const CStack * Stack)
|
2017-06-24 15:51:07 +02:00
|
|
|
{
|
|
|
|
stack = Stack;
|
|
|
|
perspective = (BattlePerspective::BattlePerspective)(!Stack->attackerOwned);
|
|
|
|
startPosition = Stack->position;
|
|
|
|
doubleWide = stack->doubleWide();
|
|
|
|
attackerOwned = stack->attackerOwned;
|
|
|
|
flying = stack->hasBonusOfType(Bonus::FLYING);
|
|
|
|
knownAccessible = stack->getHexes();
|
|
|
|
}
|
|
|
|
|
|
|
|
ReachabilityInfo::ReachabilityInfo()
|
|
|
|
{
|
|
|
|
distances.fill(INFINITE_DIST);
|
|
|
|
predecessors.fill(BattleHex::INVALID);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ReachabilityInfo::isReachable(BattleHex hex) const
|
|
|
|
{
|
|
|
|
return distances[hex] < INFINITE_DIST;
|
|
|
|
}
|