Pārlūkot izejas kodu

Ability to make faction not pickable on typical maps

Dydzio 1 gadu atpakaļ
vecāks
revīzija
00ebbad622
3 mainītis faili ar 8 papildinājumiem un 1 dzēšanām
  1. 4 0
      config/schemas/faction.json
  2. 3 1
      lib/CTownHandler.cpp
  3. 1 0
      lib/CTownHandler.h

+ 4 - 0
config/schemas/faction.json

@@ -58,6 +58,10 @@
 			"type" : "boolean",
 			"description" : "Random map generator places player/cpu-owned towns underground if true is specified and on the ground otherwise. Parameter is unused for maps without underground."
 		},
+		"special" : {
+			"type" : "boolean",
+			"description" : "If true, faction is disabled from starting pick and in random map generation"
+		},
 		"creatureBackground" : {
 			"type" : "object",
 			"additionalProperties" : false,

+ 3 - 1
lib/CTownHandler.cpp

@@ -1068,6 +1068,8 @@ CFaction * CTownHandler::loadFromJson(const std::string & scope, const JsonNode
 	
 	auto preferUndergound = source["preferUndergroundPlacement"];
 	faction->preferUndergroundPlacement = preferUndergound.isNull() ? false : preferUndergound.Bool();
+	auto isSpecial = source["special"];
+	faction->special = isSpecial.isNull() ? false : isSpecial.Bool();
 
 	// NOTE: semi-workaround - normally, towns are supposed to have native terrains.
 	// Towns without one are exceptions. So, vcmi requires nativeTerrain to be defined
@@ -1259,7 +1261,7 @@ std::set<FactionID> CTownHandler::getDefaultAllowed() const
 	std::set<FactionID> allowedFactions;
 
 	for(auto town : objects)
-		if (town->town != nullptr)
+		if (town->town != nullptr && !town->special)
 			allowedFactions.insert(town->getId());
 
 	return allowedFactions;

+ 1 - 0
lib/CTownHandler.h

@@ -168,6 +168,7 @@ public:
 	TerrainId nativeTerrain;
 	EAlignment alignment = EAlignment::NEUTRAL;
 	bool preferUndergroundPlacement = false;
+	bool special = false;
 
 	/// Boat that will be used by town shipyard (if any)
 	/// and for placing heroes directly on boat (in map editor, water prisons & taverns)