CBuildingHandler.h 1.8 KB

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