CBuildingHandler.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include "../lib/ConstTransitivePtr.h"
  3. #include "ResourceSet.h"
  4. /*
  5. * CBuildingHandler.h, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. //enum EbuildingType {NEUTRAL=-1, CASTLE, RAMPART, TOWER, INFERNO, NECROPOLIS, DUNGEON, STRONGHOLD, FORTRESS, CONFLUX};
  14. class DLL_LINKAGE CBuilding //a typical building encountered in every castle ;]
  15. {
  16. public:
  17. si32 tid, bid; //town ID and structure ID
  18. TResources resources;
  19. std::string name;
  20. std::string description;
  21. std::set<int> requirements; //set of required buildings
  22. const std::string &Name() const;
  23. const std::string &Description() const;
  24. template <typename Handler> void serialize(Handler &h, const int version)
  25. {
  26. h & tid & bid & resources & name & description & requirements;
  27. }
  28. CBuilding(int TID = -1, int BID = -1);
  29. };
  30. class DLL_LINKAGE CBuildingHandler
  31. {
  32. public:
  33. typedef bmap<int, ConstTransitivePtr<CBuilding> > TBuildingsMap;
  34. std::vector< TBuildingsMap > buildings; ///< vector by castle ID, second the building ID (in ERM-U format)
  35. bmap<int, std::pair<std::string,std::vector< std::vector< std::vector<int> > > > > hall; //map<castle ID, pair<hall bg name, std::vector< std::vector<building id> >[5]> - external vector is the vector of buildings in the row, internal is the list of buildings for the specific slot
  36. void loadBuildings(); //main loader
  37. ~CBuildingHandler(); //d-tor
  38. static int campToERMU(int camp, int townType, std::set<si32> builtBuildings);
  39. template <typename Handler> void serialize(Handler &h, const int version)
  40. {
  41. h & buildings & hall;
  42. }
  43. };