Browse Source

Merge pull request #6404 from IvanSavenko/rmg_fix

Fixed issues with object customization in RMG
Ivan Savenko 2 weeks ago
parent
commit
70bbea6f71
3 changed files with 22 additions and 11 deletions
  1. 5 0
      lib/json/JsonNode.cpp
  2. 1 0
      lib/json/JsonNode.h
  3. 16 11
      lib/rmg/ObjectConfig.cpp

+ 5 - 0
lib/json/JsonNode.cpp

@@ -242,6 +242,11 @@ bool JsonNode::isNull() const
 	return getType() == JsonType::DATA_NULL;
 	return getType() == JsonType::DATA_NULL;
 }
 }
 
 
+bool JsonNode::isBool() const
+{
+	return getType() == JsonType::DATA_BOOL;
+}
+
 bool JsonNode::isNumber() const
 bool JsonNode::isNumber() const
 {
 {
 	return getType() == JsonType::DATA_INTEGER || getType() == JsonType::DATA_FLOAT;
 	return getType() == JsonType::DATA_INTEGER || getType() == JsonType::DATA_FLOAT;

+ 1 - 0
lib/json/JsonNode.h

@@ -98,6 +98,7 @@ public:
 	JsonType getType() const;
 	JsonType getType() const;
 
 
 	bool isNull() const;
 	bool isNull() const;
+	bool isBool() const;
 	bool isNumber() const;
 	bool isNumber() const;
 	bool isString() const;
 	bool isString() const;
 	bool isVector() const;
 	bool isVector() const;

+ 16 - 11
lib/rmg/ObjectConfig.cpp

@@ -93,17 +93,22 @@ void ObjectConfig::serializeJson(JsonSerializeFormat & handler)
 		{
 		{
 			LIBRARY->identifiers()->requestIdentifierIfFound(node.second.getModScope(), "object", node.first, [this, node](int primaryID)
 			LIBRARY->identifiers()->requestIdentifierIfFound(node.second.getModScope(), "object", node.first, [this, node](int primaryID)
 			{
 			{
-				if (node.second.Bool())
-					addBannedObject(CompoundMapObjectID(primaryID, -1));
-
-				for (const auto & subNode : node.second.Struct())
+				if (node.second.isBool())
 				{
 				{
-					const std::string jsonKey = LIBRARY->objtypeh->getJsonKey(primaryID);
-
-					LIBRARY->identifiers()->requestIdentifierIfFound(node.second.getModScope(), jsonKey, subNode.first, [this, primaryID](int secondaryID)
+					if (node.second.Bool())
+						addBannedObject(CompoundMapObjectID(primaryID, -1));
+				}
+				else
+				{
+					for (const auto & subNode : node.second.Struct())
 					{
 					{
-						addBannedObject(CompoundMapObjectID(primaryID, secondaryID));
-					});
+						const std::string jsonKey = LIBRARY->objtypeh->getJsonKey(primaryID);
+
+						LIBRARY->identifiers()->requestIdentifierIfFound(node.second.getModScope(), jsonKey, subNode.first, [this, primaryID](int secondaryID)
+						{
+							addBannedObject(CompoundMapObjectID(primaryID, secondaryID));
+						});
+					}
 				}
 				}
 			});
 			});
 		}
 		}
@@ -133,7 +138,7 @@ void ObjectConfig::serializeJson(JsonSerializeFormat & handler)
 					auto objectWithID = object;
 					auto objectWithID = object;
 					objectWithID.primaryID = primaryID;
 					objectWithID.primaryID = primaryID;
 					objectWithID.secondaryID = 0;
 					objectWithID.secondaryID = 0;
-					addCustomObject(object);
+					addCustomObject(objectWithID);
 				}
 				}
 				else
 				else
 				{
 				{
@@ -144,7 +149,7 @@ void ObjectConfig::serializeJson(JsonSerializeFormat & handler)
 						auto objectWithID = object;
 						auto objectWithID = object;
 						objectWithID.primaryID = primaryID;
 						objectWithID.primaryID = primaryID;
 						objectWithID.secondaryID = secondaryID;
 						objectWithID.secondaryID = secondaryID;
-						addCustomObject(object);
+						addCustomObject(objectWithID);
 					});
 					});
 				}
 				}
 			});
 			});