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-07-01 20:05:10 +02:00
|
|
|
#include "StdInc.h"
|
2017-06-24 15:51:07 +02:00
|
|
|
#include "ReachabilityInfo.h"
|
2017-07-20 06:08:49 +02:00
|
|
|
#include "Unit.h"
|
2017-06-24 15:51:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
ReachabilityInfo::Parameters::Parameters()
|
|
|
|
{
|
|
|
|
perspective = BattlePerspective::ALL_KNOWING;
|
2017-07-01 10:34:00 +02:00
|
|
|
side = 0;
|
|
|
|
doubleWide = flying = false;
|
2017-06-24 15:51:07 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
ReachabilityInfo::Parameters::Parameters(const battle::Unit * Stack, BattleHex StartPosition)
|
2017-06-24 15:51:07 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
perspective = (BattlePerspective::BattlePerspective)(Stack->unitSide());
|
|
|
|
startPosition = StartPosition;
|
|
|
|
doubleWide = Stack->doubleWide();
|
|
|
|
side = Stack->unitSide();
|
|
|
|
flying = Stack->hasBonusOfType(Bonus::FLYING);
|
|
|
|
knownAccessible = battle::Unit::getHexes(startPosition, doubleWide, side);
|
2017-06-24 15:51:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ReachabilityInfo::ReachabilityInfo()
|
|
|
|
{
|
|
|
|
distances.fill(INFINITE_DIST);
|
|
|
|
predecessors.fill(BattleHex::INVALID);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ReachabilityInfo::isReachable(BattleHex hex) const
|
|
|
|
{
|
|
|
|
return distances[hex] < INFINITE_DIST;
|
|
|
|
}
|