CMapInfo.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * CMapInfo.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. // Forward class declarations aren't enough here. The compiler
  12. // generated CMapInfo d-tor, generates the std::unique_ptr d-tor as well here
  13. // as a inline method. The std::unique_ptr d-tor requires a complete type. Defining
  14. // the CMapInfo d-tor to let the compiler add the d-tor stuff in the .cpp file
  15. // would work with one exception. It prevents the generation of the move
  16. // constructor which is needed. (Writing such a c-tor is nasty.) With the
  17. // new c++11 keyword "default" for constructors this problem could be solved. But it isn't
  18. // available for Visual Studio for now. (Empty d-tor in .cpp would be required anyway)
  19. #include "CMap.h"
  20. #include "CCampaignHandler.h"
  21. struct StartInfo;
  22. /**
  23. * A class which stores the count of human players and all players, the filename,
  24. * scenario options, the map header information,...
  25. */
  26. class DLL_LINKAGE CMapInfo
  27. {
  28. public:
  29. std::unique_ptr<CMapHeader> mapHeader; //may be nullptr if campaign
  30. std::unique_ptr<CCampaignHeader> campaignHeader; //may be nullptr if scenario
  31. StartInfo * scenarioOpts; //options with which scenario has been started (used only with saved games)
  32. std::string fileURI;
  33. std::string date;
  34. int playerAmnt; //players in map
  35. int humanPlayers; //players ALLOWED to be controlled by human
  36. int actualHumanPlayers; // >1 if multiplayer game
  37. bool isRandomMap; // true if the map will be created randomly, false if not
  38. CMapInfo();
  39. CMapInfo(CMapInfo && tmp);
  40. virtual ~CMapInfo();
  41. CMapInfo &operator=(CMapInfo &&other);
  42. void mapInit(const std::string & fname);
  43. void campaignInit();
  44. void countPlayers();
  45. template <typename Handler> void serialize(Handler &h, const int Version)
  46. {
  47. h & mapHeader;
  48. h & campaignHeader;
  49. h & scenarioOpts;
  50. h & fileURI;
  51. h & date;
  52. h & playerAmnt;
  53. h & humanPlayers;
  54. h & actualHumanPlayers;
  55. h & isRandomMap;
  56. }
  57. };