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