CMapInfo.h 1.8 KB

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