CBuildingHandler.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef __CBUILDINGHANDLER_H__
  2. #define __CBUILDINGHANDLER_H__
  3. #include "../global.h"
  4. #include <map>
  5. #include <vector>
  6. #include <set>
  7. /*
  8. * CBuildingHandler.h, part of VCMI engine
  9. *
  10. * Authors: listed in file AUTHORS in main folder
  11. *
  12. * License: GNU General Public License v2.0 or later
  13. * Full text of license available in license.txt file, in main folder
  14. *
  15. */
  16. //enum EbuildingType {NEUTRAL=-1, CASTLE, RAMPART, TOWER, INFERNO, NECROPOLIS, DUNGEON, STRONGHOLD, FORTRESS, CONFLUX};
  17. class DLL_EXPORT CBuilding //a typical building encountered in every castle ;]
  18. {
  19. public:
  20. si32 tid, bid; //town ID and structure ID
  21. std::vector<si32> resources;
  22. std::string name;
  23. std::string description;
  24. const std::string &Name() const;
  25. const std::string &Description() const;
  26. template <typename Handler> void serialize(Handler &h, const int version)
  27. {
  28. h & tid & bid & resources & name & description;
  29. }
  30. CBuilding(int TID = -1, int BID = -1);
  31. };
  32. class DLL_EXPORT CBuildingHandler
  33. {
  34. public:
  35. std::map<int, std::map<int, CBuilding*> > buildings; ///< first int is the castle ID, second the building ID (in ERM-U format)
  36. std::map<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
  37. std::map<int, std::string> ERMUtoPicture[F_NUMBER]; //maps building ID to it's picture's name for each town type
  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 & ERMUtoPicture;
  44. }
  45. };
  46. #endif // __CBUILDINGHANDLER_H__