| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 | 
							- #ifndef __CTOWNHANDLER_H__
 
- #define __CTOWNHANDLER_H__
 
- #include "../global.h"
 
- #include <set>
 
- class CBuilding;
 
- class CSpell;
 
- class CHero;
 
- class CGTownInstance;
 
- class DLL_EXPORT CTown
 
- {
 
- 	std::string name; //name of type
 
- public:
 
- 	std::vector<std::string> names; //names of the town instances
 
- 	std::vector<int> basicCreatures; //level (from 0) -> ID
 
- 	std::vector<int> upgradedCreatures; //level (from 0) -> ID
 
- 	std::map<int,int> hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present)
 
- 	ui32 mageLevel; //max available mage guild level
 
- 	int bonus; //pic number
 
- 	ui16 primaryRes, warMachine;
 
- 	ui8 typeID;
 
- 	const std::vector<std::string> & Names() const;
 
- 	const std::string & Name() const;
 
- 	void Name(const std::string & val) { name = val; }
 
- 	template <typename Handler> void serialize(Handler &h, const int version)
 
- 	{
 
- 		h & names & basicCreatures & upgradedCreatures & hordeLvl & mageLevel & bonus 
 
- 			& primaryRes & warMachine & typeID;
 
- 	}
 
- };
 
- struct DLL_EXPORT Structure
 
- {
 
- 	int ID;
 
- 	int3 pos;
 
- 	std::string defName, borderName, areaName, name;
 
- 	int townID, group;
 
- 	bool operator<(const Structure & p2) const
 
- 	{
 
- 		if(pos.z != p2.pos.z)
 
- 			return (pos.z) < (p2.pos.z);
 
- 		else
 
- 			return (ID) < (p2.ID);
 
- 	}
 
- };
 
- class DLL_EXPORT CTownHandler
 
- {
 
- public:
 
- 	std::vector<CTown> towns;
 
- 	std::map<int,std::map<int, Structure*> > structures; // <town ID, <structure ID, structure>>
 
- 	std::map<int, std::map<int,std::set<int> > > requirements; //requirements[town_id][structure_id] -> set of required buildings
 
- 	CTownHandler();
 
- 	~CTownHandler();
 
- 	void loadNames();
 
- 	void loadStructures();
 
- 	template <typename Handler> void serialize(Handler &h, const int version)
 
- 	{
 
- 		h & towns & requirements;
 
- 		if(!h.saving)
 
- 			loadStructures();
 
- 	}
 
- };
 
- #endif // __CTOWNHANDLER_H__
 
 
  |