1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-19 21:10:12 +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:
Arseniy Shestakov 2016-01-06 12:53:40 +03:00
parent ffeb7f253b
commit c93f8fea48
3 changed files with 7 additions and 4 deletions

View File

@ -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;
}

View File

@ -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();

View File

@ -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; };