diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index 43c9288aee..f4ca464252 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -171,9 +171,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation // "[ANIMATION SET]: Setting default animation {0}, sequence number {1}, object id {2}", // anim, sequenceNum, objectID); - if (DefaultAvatarAnimations.AnimsUUID.ContainsKey(anim)) + if (DefaultAvatarAnimations.AnimsUUIDbyName.TryGetValue(anim, out UUID id)) { - return SetDefaultAnimation(DefaultAvatarAnimations.AnimsUUID[anim], sequenceNum, objectID); + return SetDefaultAnimation(id, sequenceNum, objectID); } return false; } diff --git a/OpenSim/Region/Framework/Scenes/Animation/DefaultAvatarAnimations.cs b/OpenSim/Region/Framework/Scenes/Animation/DefaultAvatarAnimations.cs index b8db3a966f..411c96d68e 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/DefaultAvatarAnimations.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/DefaultAvatarAnimations.cs @@ -39,8 +39,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation public static readonly string DefaultAnimationsPath = "data/avataranimations.xml"; - public static Dictionary AnimsUUID = new Dictionary(); - public static Dictionary AnimsNames = new Dictionary(); + public static Dictionary AnimsUUIDbyName = new Dictionary(); + public static Dictionary AnimsNamesbyUUID = new Dictionary(); public static Dictionary AnimStateNames = new Dictionary(); static DefaultAvatarAnimations() @@ -70,8 +70,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation UUID id = (UUID)nod.InnerText; string animState = (string)nod.Attributes["state"].Value; - AnimsUUID.Add(name, id); - AnimsNames.Add(id, name); + AnimsUUIDbyName.Add(name, id); + AnimsNamesbyUUID.Add(id, name); if (animState != "") AnimStateNames.Add(id, animState); @@ -93,13 +93,18 @@ namespace OpenSim.Region.Framework.Scenes.Animation { // m_log.DebugFormat( // "[AVATAR ANIMATIONS]: Looking for default avatar animation with name {0}", name); - - if (AnimsUUID.ContainsKey(name)) + UUID id; + if (AnimsUUIDbyName.TryGetValue(name, out id)) { // m_log.DebugFormat( // "[AVATAR ANIMATIONS]: Found {0} {1} in GetDefaultAvatarAnimation()", AnimsUUID[name], name); - return AnimsUUID[name]; + return id; + } + if(UUID.TryParse(name, out id)) + { + if(AnimsNamesbyUUID.ContainsKey(id)) + return id; } return UUID.Zero; @@ -111,24 +116,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public static string GetDefaultAnimationName(UUID uuid) { - string ret = "unknown"; - if (AnimsUUID.ContainsValue(uuid)) - { - foreach (KeyValuePair kvp in AnimsUUID) - { - if (kvp.Value == uuid) - { - ret = kvp.Key; - break; - } - } - } + if(AnimsNamesbyUUID.TryGetValue(uuid, out string ret)) + return ret; else - { - ret = uuid.ToString(); - } - - return ret; + return uuid.ToString(); } } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index f564b2a768..233d06f0d8 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -216,7 +216,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation { if (anim == "SITGROUND") { - UUID defsit = DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]; + UUID defsit = DefaultAvatarAnimations.AnimsUUIDbyName["SIT_GROUND_CONSTRAINED"]; if (defsit == UUID.Zero) return false; m_animations.SetDefaultAnimation(defsit, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID); @@ -863,7 +863,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation { string animName; - if (!DefaultAvatarAnimations.AnimsNames.TryGetValue(animId, out animName)) + if (!DefaultAvatarAnimations.AnimsNamesbyUUID.TryGetValue(animId, out animName)) { AssetMetadata amd = m_scenePresence.Scene.AssetService.GetMetadata(animId.ToString()); if (amd != null) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b37c5c2f9b..f45a8b1607 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6662,7 +6662,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } if (agent.Animator.Animations.ImplicitDefaultAnimation.AnimID - == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) + == DefaultAvatarAnimations.AnimsUUIDbyName["SIT_GROUND_CONSTRAINED"]) { flags |= ScriptBaseClass.AGENT_SITTING; } @@ -11212,7 +11212,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 box = presence.Appearance.AvatarBoxSize * 0.5f; if (presence.Animator.Animations.ImplicitDefaultAnimation.AnimID - == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) + == DefaultAvatarAnimations.AnimsUUIDbyName["SIT_GROUND_CONSTRAINED"]) /* { // This is for ground sitting avatars @@ -11310,7 +11310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api upper = new Vector3(m_lABB2SitX0, m_lABB2SitY0, m_lABB2SitZ0 + m_lABB2SitZ1 * height); } // When avatar is groundsitting - else if (sp.Animator.Animations.ImplicitDefaultAnimation.AnimID == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) + else if (sp.Animator.Animations.ImplicitDefaultAnimation.AnimID == DefaultAvatarAnimations.AnimsUUIDbyName["SIT_GROUND_CONSTRAINED"]) { lower = new Vector3(m_lABB1GrsX0, m_lABB1GrsY0, m_lABB1GrsZ0 + m_lABB1GrsZ1 * height); upper = new Vector3(m_lABB2GrsX0, m_lABB2GrsY0, m_lABB2GrsZ0 + m_lABB2GrsZ1 * height); @@ -17365,7 +17365,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (animID == UUID.Zero) { String animupper = ((string)anim).ToUpperInvariant(); - DefaultAvatarAnimations.AnimsUUID.TryGetValue(animupper, out animID); + DefaultAvatarAnimations.AnimsUUIDbyName.TryGetValue(animupper, out animID); } if (animID == UUID.Zero) @@ -17458,7 +17458,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (animID == UUID.Zero) return animState; - foreach (KeyValuePair kvp in DefaultAvatarAnimations.AnimsUUID) + foreach (KeyValuePair kvp in DefaultAvatarAnimations.AnimsUUIDbyName) { if (kvp.Value == animID) return kvp.Key.ToLower();