Browse Source

When deserializing a VariantMap from XML, also accept entries without "hash" attribute but a "name" attribute. Closes #1342.

Lasse Öörni 9 năm trước cách đây
mục cha
commit
21bf5d4bea
1 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 6 2
      Source/Urho3D/Resource/XMLElement.cpp

+ 6 - 2
Source/Urho3D/Resource/XMLElement.cpp

@@ -867,8 +867,12 @@ VariantMap XMLElement::GetVariantMap() const
     XMLElement variantElem = GetChild("variant");
     while (variantElem)
     {
-        StringHash key(variantElem.GetUInt("hash"));
-        ret[key] = variantElem.GetVariant();
+        // If this is a manually edited map, user can not be expected to calculate hashes manually. Also accept "name" attribute
+        if (variantElem.HasAttribute("name"))
+            ret[StringHash(variantElem.GetAttribute("name"))] = variantElem.GetVariant();
+        else if (variantElem.HasAttribute("hash"))
+            ret[StringHash(variantElem.GetUInt("hash"))] = variantElem.GetVariant();
+
         variantElem = variantElem.GetNext("variant");
     }