TurnInfo.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * TurnInfo.h, 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. #pragma once
  11. #include "../bonuses/Bonus.h"
  12. #include "../bonuses/BonusSelector.h"
  13. #include "../bonuses/BonusCache.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. class CGHeroInstance;
  16. class TurnInfoBonusList
  17. {
  18. TConstBonusListPtr bonusList;
  19. std::mutex bonusListMutex;
  20. std::atomic<int64_t> bonusListVersion = 0;
  21. public:
  22. TConstBonusListPtr getBonusList(const CGHeroInstance * target, const CSelector & bonusSelector);
  23. };
  24. struct TurnInfoCache
  25. {
  26. TurnInfoBonusList waterWalking;
  27. TurnInfoBonusList flyingMovement;
  28. TurnInfoBonusList noTerrainPenalty;
  29. TurnInfoBonusList freeShipBoarding;
  30. TurnInfoBonusList roughTerrainDiscount;
  31. TurnInfoBonusList movementPointsLimitLand;
  32. TurnInfoBonusList movementPointsLimitWater;
  33. const CGHeroInstance * target;
  34. mutable std::atomic<int64_t> heroLowestSpeedVersion = 0;
  35. mutable std::atomic<int64_t> heroLowestSpeedValue = 0;
  36. explicit TurnInfoCache(const CGHeroInstance * target):
  37. target(target)
  38. {}
  39. };
  40. class DLL_LINKAGE TurnInfo
  41. {
  42. private:
  43. const CGHeroInstance * target;
  44. // stores cached values per each terrain
  45. std::vector<bool> noterrainPenalty;
  46. int flyingMovementValue;
  47. int waterWalkingValue;
  48. int roughTerrainDiscountValue;
  49. int movePointsLimitLand;
  50. int movePointsLimitWater;
  51. bool waterWalkingTest;
  52. bool flyingMovementTest;
  53. bool freeShipBoardingTest;
  54. public:
  55. int hasWaterWalking() const;
  56. int hasFlyingMovement() const;
  57. int hasNoTerrainPenalty(const TerrainId & terrain) const;
  58. int hasFreeShipBoarding() const;
  59. int getFlyingMovementValue() const;
  60. int getWaterWalkingValue() const;
  61. int getRoughTerrainDiscountValue() const;
  62. int getMovePointsLimitLand() const;
  63. int getMovePointsLimitWater() const;
  64. TurnInfo(TurnInfoCache * sharedCache, const CGHeroInstance * target, int Turn);
  65. bool isLayerAvailable(const EPathfindingLayer & layer) const;
  66. int getMaxMovePoints(const EPathfindingLayer & layer) const;
  67. };
  68. VCMI_LIB_NAMESPACE_END