From 9eeea7299a111139081b88dad857f1c2f194fc83 Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Fri, 31 Oct 2014 17:09:34 +0100 Subject: [PATCH] - Removed unecessary includes - Fixed town types configured from RMG templates --- AI/VCAI/Fuzzy.cpp | 2 -- lib/rmg/CRmgTemplateStorage.cpp | 12 ++++++++---- lib/rmg/CRmgTemplateZone.cpp | 10 ++++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/AI/VCAI/Fuzzy.cpp b/AI/VCAI/Fuzzy.cpp index 812006d12..676c1ed7f 100644 --- a/AI/VCAI/Fuzzy.cpp +++ b/AI/VCAI/Fuzzy.cpp @@ -1,7 +1,5 @@ #include "StdInc.h" #include "Fuzzy.h" -#include "src/Engine.cpp" -#include "src/Operation.cpp" #include #include "../../lib/mapObjects/MapObjects.h" diff --git a/lib/rmg/CRmgTemplateStorage.cpp b/lib/rmg/CRmgTemplateStorage.cpp index e896ed32b..dd72b8341 100644 --- a/lib/rmg/CRmgTemplateStorage.cpp +++ b/lib/rmg/CRmgTemplateStorage.cpp @@ -70,14 +70,18 @@ void CJsonRmgTemplateLoader::loadTemplates() for (int i = 0; i < 2; ++i) { std::set allowedTownTypes; - if (zoneNode[i ? "allowedTowns" : "allowedMonsters"].isNull()) + if (i) { - if (i) + if (zoneNode["allowedTowns"].isNull()) allowedTownTypes = zone->getDefaultTownTypes(); - else - allowedTownTypes = VLC->townh->getAllowedFactions(false); } else + { + if (zoneNode["allowedMonsters"].isNull()) + allowedTownTypes = VLC->townh->getAllowedFactions(false); + } + + if (allowedTownTypes.empty()) { for (const JsonNode & allowedTown : zoneNode[i ? "allowedTowns" : "allowedMonsters"].Vector()) { diff --git a/lib/rmg/CRmgTemplateZone.cpp b/lib/rmg/CRmgTemplateZone.cpp index 06f699da7..673f3ac2b 100644 --- a/lib/rmg/CRmgTemplateZone.cpp +++ b/lib/rmg/CRmgTemplateZone.cpp @@ -1049,13 +1049,19 @@ void CRmgTemplateZone::initTownType (CMapGenerator* gen) else { type = ETemplateZoneType::TREASURE; - townType = *RandomGeneratorUtil::nextItem(VLC->townh->getAllowedFactions(), gen->rand); + if (townTypes.size()) + townType = *RandomGeneratorUtil::nextItem(townTypes, gen->rand); + else + townType = *RandomGeneratorUtil::nextItem(getDefaultTownTypes(), gen->rand); //it is possible to have zone with no towns allowed logGlobal->infoStream() << "Skipping this zone cause no player"; } } else //no player { - townType = *RandomGeneratorUtil::nextItem(VLC->townh->getAllowedFactions(), gen->rand); + if (townTypes.size()) + townType = *RandomGeneratorUtil::nextItem(townTypes, gen->rand); + else + townType = *RandomGeneratorUtil::nextItem(getDefaultTownTypes(), gen->rand); //it is possible to have zone with no towns allowed } addNewTowns (neutralTowns.getCastleCount(), true, PlayerColor::NEUTRAL);