CMapInfo.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include "StdInc.h"
  3. // Forward class declarations aren't enough here. The compiler
  4. // generated CMapInfo d-tor, generates the unique_ptr d-tor as well here
  5. // as a inline method. The unique_ptr d-tor requires a complete type. Defining
  6. // the CMapInfo d-tor to let the compiler add the d-tor stuff in the .cpp file
  7. // would work with one exception. It prevents the generation of the move
  8. // constructor which is needed. (Writing such a c-tor is nasty.) With the
  9. // new c++11 keyword "default" for constructors this problem could be solved. But it isn't
  10. // available for Visual Studio for now. (Empty d-tor in .cpp would be required anyway)
  11. #include "CMap.h"
  12. #include "CCampaignHandler.h"
  13. struct StartInfo;
  14. /**
  15. * A class which stores the count of human players and all players, the filename,
  16. * scenario options, the map header information,...
  17. */
  18. class DLL_LINKAGE CMapInfo
  19. {
  20. public:
  21. //FIXME: unique_ptr won't work here with gcc-4.5. (can't move into vector at CPregame.cpp, SelectionTab::parseMaps() method)
  22. //Needs some workaround or wait till there is no need to support 4.5
  23. shared_ptr<CMapHeader> mapHeader; //may be nullptr if campaign
  24. shared_ptr<CCampaignHeader> campaignHeader; //may be nullptr if scenario
  25. StartInfo * scenarioOpts; //options with which scenario has been started (used only with saved games)
  26. std::string fileURI;
  27. std::string date;
  28. int playerAmnt; //players in map
  29. int humanPlayers; //players ALLOWED to be controlled by human
  30. int actualHumanPlayers; // >1 if multiplayer game
  31. bool isRandomMap; // true if the map will be created randomly, false if not
  32. CMapInfo();
  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;
  40. }
  41. };