CMapInfo.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 * scenarioOptionsOfSave; // Options with which scenario has been started (used only with saved games)
  32. std::string fileURI;
  33. std::string date;
  34. int amountOfPlayersOnMap;
  35. int amountOfHumanControllablePlayers;
  36. int amountOfHumanPlayersInSave;
  37. bool isRandomMap;
  38. CMapInfo();
  39. virtual ~CMapInfo();
  40. CMapInfo &operator=(CMapInfo &&other);
  41. void mapInit(const std::string & fname);
  42. void saveInit(ResourceID file);
  43. void campaignInit();
  44. void countPlayers();
  45. // TODO: Those must be on client-side
  46. std::string getName() const;
  47. std::string getNameForList() const;
  48. std::string getDescription() const;
  49. int getMapSizeIconId() const;
  50. std::pair<int, int> getMapSizeFormatIconId() const;
  51. std::string getMapSizeName() const;
  52. template <typename Handler> void serialize(Handler &h, const int Version)
  53. {
  54. h & mapHeader;
  55. h & campaignHeader;
  56. h & scenarioOptionsOfSave;
  57. h & fileURI;
  58. h & date;
  59. h & amountOfPlayersOnMap;
  60. h & amountOfHumanControllablePlayers;
  61. h & amountOfHumanPlayersInSave;
  62. h & isRandomMap;
  63. }
  64. };