ReachabilityInfo.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * ReachabilityInfo.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "ReachabilityInfo.h"
  12. #include "CStack.h"
  13. ReachabilityInfo::Parameters::Parameters()
  14. {
  15. stack = nullptr;
  16. perspective = BattlePerspective::ALL_KNOWING;
  17. attackerOwned = doubleWide = flying = false;
  18. }
  19. ReachabilityInfo::Parameters::Parameters(const CStack * Stack)
  20. {
  21. stack = Stack;
  22. perspective = (BattlePerspective::BattlePerspective)(!Stack->attackerOwned);
  23. startPosition = Stack->position;
  24. doubleWide = stack->doubleWide();
  25. attackerOwned = stack->attackerOwned;
  26. flying = stack->hasBonusOfType(Bonus::FLYING);
  27. knownAccessible = stack->getHexes();
  28. }
  29. ReachabilityInfo::ReachabilityInfo()
  30. {
  31. distances.fill(INFINITE_DIST);
  32. predecessors.fill(BattleHex::INVALID);
  33. }
  34. bool ReachabilityInfo::isReachable(BattleHex hex) const
  35. {
  36. return distances[hex] < INFINITE_DIST;
  37. }