mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
moatHexes: add saves and mods compatability
This commit is contained in:
parent
48aedaef47
commit
8c39ecf538
@ -233,7 +233,6 @@
|
||||
"moatHexes": {
|
||||
"type" : "array",
|
||||
"description" : "Numbers of battlefield hexes affected by moat during siege",
|
||||
"minItems" : 1,
|
||||
"items" : { "type" : "number" }
|
||||
},
|
||||
"musicTheme": {
|
||||
|
@ -86,6 +86,12 @@ CTown::~CTown()
|
||||
str.dellNull();
|
||||
}
|
||||
|
||||
std::vector<BattleHex> CTown::defaultMoatHexes()
|
||||
{
|
||||
static const BattleHex moatHexes[] = {11, 28, 44, 61, 77, 111, 129, 146, 164, 181};
|
||||
return std::vector<BattleHex>(moatHexes, moatHexes + ARRAY_COUNT(moatHexes));
|
||||
}
|
||||
|
||||
CTownHandler::CTownHandler()
|
||||
{
|
||||
VLC->townh = this;
|
||||
@ -543,9 +549,14 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source)
|
||||
|
||||
town.moatDamage = source["moatDamage"].Float();
|
||||
|
||||
// Mods Compatability for pre 0.99
|
||||
if(source["moatHexes"].isNull())
|
||||
{
|
||||
town.moatHexes = CTown::defaultMoatHexes();
|
||||
}
|
||||
else
|
||||
town.moatHexes = source["moatHexes"].convertTo<std::vector<BattleHex> >();
|
||||
|
||||
|
||||
town.mageLevel = source["mageGuild"].Float();
|
||||
town.names = source["names"].convertTo<std::vector<std::string> >();
|
||||
|
||||
|
@ -137,6 +137,8 @@ class DLL_LINKAGE CTown
|
||||
public:
|
||||
CTown();
|
||||
~CTown();
|
||||
// TODO: remove once save and mod compatability not needed
|
||||
static std::vector<BattleHex> defaultMoatHexes();
|
||||
|
||||
CFaction * faction;
|
||||
|
||||
@ -207,7 +209,16 @@ public:
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & names & faction & creatures & dwellings & dwellingNames & buildings & hordeLvl & mageLevel
|
||||
& primaryRes & warMachine & clientInfo & moatDamage & moatHexes & defaultTavernChance;
|
||||
& primaryRes & warMachine & clientInfo & moatDamage;
|
||||
if(version >= 758)
|
||||
{
|
||||
h & moatHexes;
|
||||
}
|
||||
else if(!h.saving)
|
||||
{
|
||||
moatHexes = defaultMoatHexes();
|
||||
}
|
||||
h & defaultTavernChance;
|
||||
|
||||
auto findNull = [](const std::pair<BuildingID, ConstTransitivePtr<CBuilding>> &building)
|
||||
{ return building.second == nullptr; };
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "mapping/CCampaignHandler.h" //for CCampaignState
|
||||
#include "rmg/CMapGenerator.h" // for CMapGenOptions
|
||||
|
||||
const ui32 version = 757;
|
||||
const ui32 version = 758;
|
||||
const ui32 minSupportedVersion = 753;
|
||||
|
||||
class CISer;
|
||||
|
Loading…
Reference in New Issue
Block a user