CMapInfo.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. // Forward class declarations aren't enough here. The compiler
  3. // generated CMapInfo d-tor, generates the unique_ptr d-tor as well here
  4. // as a inline method. The 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. //FIXME: unique_ptr won't work here with gcc-4.5. (can't move into vector at CPregame.cpp, SelectionTab::parseMaps() method)
  21. //Needs some workaround or wait till there is no need to support 4.5
  22. shared_ptr<CMapHeader> mapHeader; //may be nullptr if campaign
  23. shared_ptr<CCampaignHeader> campaignHeader; //may be nullptr if scenario
  24. StartInfo * scenarioOpts; //options with which scenario has been started (used only with saved games)
  25. std::string fileURI;
  26. std::string date;
  27. int playerAmnt; //players in map
  28. int humanPlayers; //players ALLOWED to be controlled by human
  29. int actualHumanPlayers; // >1 if multiplayer game
  30. CMapInfo();
  31. void mapInit(const std::string & fname);
  32. void campaignInit();
  33. void countPlayers();
  34. template <typename Handler> void serialize(Handler &h, const int Version)
  35. {
  36. h & mapHeader & campaignHeader & scenarioOpts & fileURI & date & playerAmnt & humanPlayers;
  37. h & actualHumanPlayers;
  38. }
  39. };