Selaa lähdekoodia

- Removed unecessary includes
- Fixed town types configured from RMG templates

DjWarmonger 11 vuotta sitten
vanhempi
sitoutus
9eeea7299a
3 muutettua tiedostoa jossa 16 lisäystä ja 8 poistoa
  1. 0 2
      AI/VCAI/Fuzzy.cpp
  2. 8 4
      lib/rmg/CRmgTemplateStorage.cpp
  3. 8 2
      lib/rmg/CRmgTemplateZone.cpp

+ 0 - 2
AI/VCAI/Fuzzy.cpp

@@ -1,7 +1,5 @@
 #include "StdInc.h"
 #include "Fuzzy.h"
-#include "src/Engine.cpp"
-#include "src/Operation.cpp"
 #include <limits>
 
 #include "../../lib/mapObjects/MapObjects.h"

+ 8 - 4
lib/rmg/CRmgTemplateStorage.cpp

@@ -70,14 +70,18 @@ void CJsonRmgTemplateLoader::loadTemplates()
 				for (int i = 0; i < 2; ++i)
 				{
 					std::set<TFaction> 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())
 						{

+ 8 - 2
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);