CTownHandler.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include "int3.h"
  3. /*
  4. * CTownHandler.h, part of VCMI engine
  5. *
  6. * Authors: listed in file AUTHORS in main folder
  7. *
  8. * License: GNU General Public License v2.0 or later
  9. * Full text of license available in license.txt file, in main folder
  10. *
  11. */
  12. class CBuilding;
  13. class CSpell;
  14. class CHero;
  15. class CGTownInstance;
  16. class DLL_LINKAGE CTown
  17. {
  18. std::string name; //name of type
  19. public:
  20. std::vector<std::string> names; //names of the town instances
  21. std::vector<std::vector<int> > creatures; //level (from 0) -> list of creatures on this tier
  22. std::map<int,int> hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present)
  23. ui32 mageLevel; //max available mage guild level
  24. int bonus; //pic number
  25. ui16 primaryRes, warMachine;
  26. ui8 typeID;
  27. const std::vector<std::string> & Names() const;
  28. const std::string & Name() const;
  29. void Name(const std::string & val) { name = val; }
  30. template <typename Handler> void serialize(Handler &h, const int version)
  31. {
  32. h & names & creatures & hordeLvl & mageLevel & bonus
  33. & primaryRes & warMachine & typeID;
  34. }
  35. };
  36. struct DLL_LINKAGE Structure
  37. {
  38. int ID;
  39. int3 pos;
  40. std::string defName, borderName, areaName, name;
  41. int townID, group;
  42. bool operator<(const Structure & p2) const
  43. {
  44. if(pos.z != p2.pos.z)
  45. return (pos.z) < (p2.pos.z);
  46. else
  47. return (ID) < (p2.ID);
  48. }
  49. };
  50. class DLL_LINKAGE CTownHandler
  51. {
  52. public:
  53. std::vector<CTown> towns;
  54. std::vector<std::map<int, Structure*> > structures; // <town ID, <structure ID, structure>>
  55. CTownHandler(); //c-tor
  56. ~CTownHandler(); //d-tor
  57. void loadStructures();
  58. template <typename Handler> void serialize(Handler &h, const int version)
  59. {
  60. h & towns;
  61. if(!h.saving)
  62. loadStructures();
  63. }
  64. };