浏览代码

Load unknown objects as "Nothing" object

Ivan Savenko 9 月之前
父节点
当前提交
baa9b1e312
共有 2 个文件被更改,包括 18 次插入0 次删除
  1. 2 0
      lib/constants/EntityIdentifiers.h
  2. 16 0
      lib/mapping/MapIdentifiersH3M.cpp

+ 2 - 0
lib/constants/EntityIdentifiers.h

@@ -405,6 +405,8 @@ public:
 	enum Type
 	{
 		NO_OBJ = -1,
+
+		NOTHING = 0,
 		ALTAR_OF_SACRIFICE [[deprecated]] = 2,
 		ANCHOR_POINT = 3,
 		ARENA = 4,

+ 16 - 0
lib/mapping/MapIdentifiersH3M.cpp

@@ -116,6 +116,22 @@ void MapIdentifiersH3M::remapTemplate(ObjectTemplate & objectTemplate)
 		objectTemplate.subid = mappedType.subID;
 	}
 
+	if (VLC->objtypeh->knownObjects().count(objectTemplate.id) == 0)
+	{
+		logGlobal->warn("Unknown object found: %d | %d", objectTemplate.id, objectTemplate.subid);
+
+		objectTemplate.id = Obj::NOTHING;
+		objectTemplate.subid = {};
+	}
+	else
+	{
+		if (VLC->objtypeh->knownSubObjects(objectTemplate.id).count(objectTemplate.subid) == 0)
+		{
+			logGlobal->warn("Unknown subobject found: %d | %d", objectTemplate.id, objectTemplate.subid);
+			objectTemplate.subid = {};
+		}
+	}
+
 	if (objectTemplate.id == Obj::TOWN || objectTemplate.id == Obj::RANDOM_DWELLING_FACTION)
 		objectTemplate.subid = remap(FactionID(objectTemplate.subid));