ReachabilityInfo.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. side = 0;
  18. doubleWide = flying = false;
  19. }
  20. ReachabilityInfo::Parameters::Parameters(const CStack * Stack)
  21. {
  22. stack = Stack;
  23. perspective = (BattlePerspective::BattlePerspective)(Stack->side);
  24. startPosition = Stack->position;
  25. doubleWide = stack->doubleWide();
  26. side = stack->side;
  27. flying = stack->hasBonusOfType(Bonus::FLYING);
  28. knownAccessible = stack->getHexes();
  29. }
  30. ReachabilityInfo::ReachabilityInfo()
  31. {
  32. distances.fill(INFINITE_DIST);
  33. predecessors.fill(BattleHex::INVALID);
  34. }
  35. bool ReachabilityInfo::isReachable(BattleHex hex) const
  36. {
  37. return distances[hex] < INFINITE_DIST;
  38. }