mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	moatHexes: implement reading moat hexes from configuration files
This also fix Fortess moat that previously used wrong hexes
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| #include "StdInc.h" | ||||
| #include "CObstacleInstance.h" | ||||
| #include "CHeroHandler.h" | ||||
| #include "CTownHandler.h" | ||||
| #include "VCMI_Lib.h" | ||||
| #include "spells/CSpellHandler.h" | ||||
|  | ||||
| @@ -145,7 +146,5 @@ void SpellCreatedObstacle::battleTurnPassed() | ||||
|  | ||||
| std::vector<BattleHex> MoatObstacle::getAffectedTiles() const | ||||
| { | ||||
| 	//rrr... need initializer lists | ||||
| 	static const BattleHex moatHexes[] = {11, 28, 44, 61, 77, 111, 129, 146, 164, 181}; | ||||
| 	return std::vector<BattleHex>(moatHexes, moatHexes + ARRAY_COUNT(moatHexes)); | ||||
| 	return VLC->townh->factions[ID]->town->moatHexes; | ||||
| } | ||||
|   | ||||
| @@ -13,6 +13,7 @@ | ||||
| #include "filesystem/Filesystem.h" | ||||
| #include "mapObjects/CObjectClassesHandler.h" | ||||
| #include "mapObjects/CObjectHandler.h" | ||||
| #include "BattleHex.h" | ||||
|  | ||||
| /* | ||||
|  * CTownHandler.cpp, part of VCMI engine | ||||
| @@ -542,6 +543,7 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source) | ||||
|  | ||||
| 	town.moatDamage = source["moatDamage"].Float(); | ||||
|  | ||||
| 	town.moatHexes = source["moatHexes"].convertTo<std::vector<BattleHex> >(); | ||||
| 	 | ||||
|  | ||||
| 	town.mageLevel = source["mageGuild"].Float(); | ||||
|   | ||||
| @@ -21,6 +21,7 @@ class CLegacyConfigParser; | ||||
| class JsonNode; | ||||
| class CTown; | ||||
| class CFaction; | ||||
| struct BattleHex; | ||||
|  | ||||
| /// a typical building encountered in every castle ;] | ||||
| /// this is structure available to both client and server | ||||
| @@ -156,6 +157,7 @@ public: | ||||
| 	ui16 primaryRes; | ||||
| 	ArtifactID warMachine; | ||||
| 	si32 moatDamage; | ||||
| 	std::vector<BattleHex> moatHexes; | ||||
| 	// default chance for hero of specific class to appear in tavern, if field "tavern" was not set | ||||
| 	// resulting chance = sqrt(town.chance * heroClass.chance) | ||||
| 	ui32 defaultTavernChance; | ||||
| @@ -205,7 +207,7 @@ public: | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| 	{ | ||||
| 		h & names & faction & creatures & dwellings & dwellingNames & buildings & hordeLvl & mageLevel | ||||
| 			& primaryRes & warMachine & clientInfo & moatDamage & defaultTavernChance; | ||||
| 			& primaryRes & warMachine & clientInfo & moatDamage & moatHexes & defaultTavernChance; | ||||
|  | ||||
| 		auto findNull = [](const std::pair<BuildingID, ConstTransitivePtr<CBuilding>> &building) | ||||
| 		{ return building.second == nullptr; }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user