CBuildingHandler.h 1.8 KB

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