瀏覽代碼

Add workaround & logging for mods that use incorrect building ID's

Ivan Savenko 3 月之前
父節點
當前提交
81d09aee14
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      lib/entities/faction/CTownHandler.cpp

+ 7 - 0
lib/entities/faction/CTownHandler.cpp

@@ -889,6 +889,13 @@ void CTownHandler::beforeValidate(JsonNode & object)
 			return;
 
 		JsonNode baseCopy(buildingsLibrary[name]);
+
+		if (target.Struct().count("id") && baseCopy.Struct().count("id"))
+		{
+			logMod->warn("Mod '%s': Town building '%s' has specified 'id' field for a predefined building! Ignoring this field.", target["id"].getModScope(), name);
+			target.Struct().erase("id");
+		}
+
 		baseCopy.setModScope(target.getModScope());
 		JsonUtils::inherit(target, baseCopy);
 	};