CMapInfo.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. VCMI_LIB_NAMESPACE_BEGIN
  22. struct StartInfo;
  23. /**
  24. * A class which stores the count of human players and all players, the filename,
  25. * scenario options, the map header information,...
  26. */
  27. class DLL_LINKAGE CMapInfo
  28. {
  29. public:
  30. std::unique_ptr<CMapHeader> mapHeader; //may be nullptr if campaign
  31. std::unique_ptr<CCampaignHeader> campaignHeader; //may be nullptr if scenario
  32. StartInfo * scenarioOptionsOfSave; // Options with which scenario has been started (used only with saved games)
  33. std::string fileURI;
  34. std::string date;
  35. int amountOfPlayersOnMap;
  36. int amountOfHumanControllablePlayers;
  37. int amountOfHumanPlayersInSave;
  38. bool isRandomMap;
  39. CMapInfo();
  40. virtual ~CMapInfo();
  41. CMapInfo &operator=(CMapInfo &&other);
  42. void mapInit(const std::string & fname);
  43. void saveInit(ResourceID file);
  44. void campaignInit();
  45. void countPlayers();
  46. // TODO: Those must be on client-side
  47. std::string getName() const;
  48. std::string getNameForList() const;
  49. std::string getDescription() const;
  50. int getMapSizeIconId() const;
  51. std::pair<int, int> getMapSizeFormatIconId() const;
  52. std::string getMapSizeName() const;
  53. template <typename Handler> void serialize(Handler &h, const int Version)
  54. {
  55. h & mapHeader;
  56. h & campaignHeader;
  57. h & scenarioOptionsOfSave;
  58. h & fileURI;
  59. h & date;
  60. h & amountOfPlayersOnMap;
  61. h & amountOfHumanControllablePlayers;
  62. h & amountOfHumanPlayersInSave;
  63. h & isRandomMap;
  64. }
  65. };
  66. VCMI_LIB_NAMESPACE_END