CCallbackBase.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * CCallbackBase.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 "../GameConstants.h"
  12. #define RETURN_IF_NOT_BATTLE(...) if(!duringBattle()) {logGlobal->error("%s called when no battle!", __FUNCTION__); return __VA_ARGS__; }
  13. #define ASSERT_IF_CALLED_WITH_PLAYER if(!getPlayerID()) {logGlobal->error(BOOST_CURRENT_FUNCTION); assert(0);}
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. class IBattleInfo;
  16. class BattleInfo;
  17. class CBattleInfoEssentials;
  18. //Basic class for various callbacks (interfaces called by players to get info about game and so forth)
  19. class DLL_LINKAGE CCallbackBase
  20. {
  21. protected:
  22. std::optional<PlayerColor> player; // not set gives access to all information, otherwise callback provides only information "visible" for player
  23. CCallbackBase(std::optional<PlayerColor> Player);
  24. CCallbackBase() = default;
  25. public:
  26. std::optional<PlayerColor> getPlayerID() const;
  27. };
  28. VCMI_LIB_NAMESPACE_END