aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs24
1 files changed, 16 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs b/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs
index 37131b9..f874495 100644
--- a/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs
@@ -85,19 +85,27 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
85 { 85 {
86 OSDMap attrs = null; 86 OSDMap attrs = null;
87 SceneObjectPart sop = m_scene.GetSceneObjectPart(groupId); 87 SceneObjectPart sop = m_scene.GetSceneObjectPart(groupId);
88
89 if (sop == null)
90 return true;
91
88 if (!sop.DynAttrs.TryGetValue(Name, out attrs)) 92 if (!sop.DynAttrs.TryGetValue(Name, out attrs))
89 attrs = new OSDMap(); 93 attrs = new OSDMap();
90 94
91 OSDInteger newValue; 95 OSDInteger newValue;
92
93 if (!attrs.ContainsKey("moves"))
94 newValue = new OSDInteger(1);
95 else
96 newValue = new OSDInteger(((OSDInteger)attrs["moves"]).AsInteger() + 1);
97
98 attrs["moves"] = newValue;
99 96
100 sop.DynAttrs[Name] = attrs; 97 // We have to lock on the entire dynamic attributes map to avoid race conditions with serialization code.
98 lock (sop.DynAttrs)
99 {
100 if (!attrs.ContainsKey("moves"))
101 newValue = new OSDInteger(1);
102 else
103 newValue = new OSDInteger(attrs["moves"].AsInteger() + 1);
104
105 attrs["moves"] = newValue;
106
107 sop.DynAttrs[Name] = attrs;
108 }
101 109
102 m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue)); 110 m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue));
103 111