aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorCharles Krinke2007-12-17 16:41:28 +0000
committerCharles Krinke2007-12-17 16:41:28 +0000
commita990c64698d465a6ed1694cdaa526254f8063663 (patch)
tree9833c5eb8a95ad44dcea0f84769703323d488a6e /OpenSim/Region
parentThank you, Kiryu for a patch to fix out of sync error in UDP server (diff)
downloadopensim-SC-a990c64698d465a6ed1694cdaa526254f8063663.zip
opensim-SC-a990c64698d465a6ed1694cdaa526254f8063663.tar.gz
opensim-SC-a990c64698d465a6ed1694cdaa526254f8063663.tar.bz2
opensim-SC-a990c64698d465a6ed1694cdaa526254f8063663.tar.xz
Thank you to Kiryu for a patch to fix an out of Sync
error in Scene. Affects 6 files and is Mantis#201
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs66
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs10
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs12
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs34
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneManager.cs10
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs10
6 files changed, 112 insertions, 30 deletions
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 03f3cd0..0ca3405 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -129,7 +129,7 @@ namespace OpenSim.Region.Environment.Scenes
129 129
130 internal void UpdateEntities() 130 internal void UpdateEntities()
131 { 131 {
132 List<EntityBase> updateEntities = new List<EntityBase>(Entities.Values); 132 List<EntityBase> updateEntities = GetEntities();
133 133
134 foreach (EntityBase entity in updateEntities) 134 foreach (EntityBase entity in updateEntities)
135 { 135 {
@@ -147,7 +147,7 @@ namespace OpenSim.Region.Environment.Scenes
147 147
148 internal void UpdateEntityMovement() 148 internal void UpdateEntityMovement()
149 { 149 {
150 List<EntityBase> moveEntities = new List<EntityBase>(Entities.Values); 150 List<EntityBase> moveEntities = GetEntities();
151 151
152 foreach (EntityBase entity in moveEntities) 152 foreach (EntityBase entity in moveEntities)
153 { 153 {
@@ -174,7 +174,10 @@ namespace OpenSim.Region.Environment.Scenes
174 if (!Entities.ContainsKey(sceneObject.UUID)) 174 if (!Entities.ContainsKey(sceneObject.UUID))
175 { 175 {
176 // QuadTree.AddObject(sceneObject); 176 // QuadTree.AddObject(sceneObject);
177 Entities.Add(sceneObject.UUID, sceneObject); 177 lock (Entities)
178 {
179 Entities.Add(sceneObject.UUID, sceneObject);
180 }
178 m_numPrim++; 181 m_numPrim++;
179 } 182 }
180 } 183 }
@@ -188,7 +191,9 @@ namespace OpenSim.Region.Environment.Scenes
188 } 191 }
189 public void RemovePrim(uint localID, LLUUID avatar_deleter) 192 public void RemovePrim(uint localID, LLUUID avatar_deleter)
190 { 193 {
191 foreach (EntityBase obj in Entities.Values) 194 List<EntityBase> EntityList = GetEntities();
195
196 foreach (EntityBase obj in EntityList)
192 { 197 {
193 if (obj is SceneObjectGroup) 198 if (obj is SceneObjectGroup)
194 { 199 {
@@ -310,7 +315,12 @@ namespace OpenSim.Region.Environment.Scenes
310 /// <returns></returns> 315 /// <returns></returns>
311 public List<ScenePresence> GetScenePresences() 316 public List<ScenePresence> GetScenePresences()
312 { 317 {
313 List<ScenePresence> result = new List<ScenePresence>(ScenePresences.Values); 318 List<ScenePresence> result;
319
320 lock (ScenePresences)
321 {
322 result = new List<ScenePresence>(ScenePresences.Values);
323 }
314 324
315 return result; 325 return result;
316 } 326 }
@@ -330,8 +340,9 @@ namespace OpenSim.Region.Environment.Scenes
330 public List<ScenePresence> GetScenePresences(FilterAvatarList filter) 340 public List<ScenePresence> GetScenePresences(FilterAvatarList filter)
331 { 341 {
332 List<ScenePresence> result = new List<ScenePresence>(); 342 List<ScenePresence> result = new List<ScenePresence>();
343 List<ScenePresence> ScenePresencesList = GetScenePresences();
333 344
334 foreach (ScenePresence avatar in ScenePresences.Values) 345 foreach (ScenePresence avatar in ScenePresencesList)
335 { 346 {
336 if (filter(avatar)) 347 if (filter(avatar))
337 { 348 {
@@ -358,7 +369,9 @@ namespace OpenSim.Region.Environment.Scenes
358 369
359 private SceneObjectGroup GetGroupByPrim(uint localID) 370 private SceneObjectGroup GetGroupByPrim(uint localID)
360 { 371 {
361 foreach (EntityBase ent in Entities.Values) 372 List<EntityBase> EntityList = GetEntities();
373
374 foreach (EntityBase ent in EntityList)
362 { 375 {
363 if (ent is SceneObjectGroup) 376 if (ent is SceneObjectGroup)
364 { 377 {
@@ -371,7 +384,9 @@ namespace OpenSim.Region.Environment.Scenes
371 384
372 private SceneObjectGroup GetGroupByPrim(LLUUID fullID) 385 private SceneObjectGroup GetGroupByPrim(LLUUID fullID)
373 { 386 {
374 foreach (EntityBase ent in Entities.Values) 387 List<EntityBase> EntityList = GetEntities();
388
389 foreach (EntityBase ent in EntityList)
375 { 390 {
376 if (ent is SceneObjectGroup) 391 if (ent is SceneObjectGroup)
377 { 392 {
@@ -461,6 +476,18 @@ namespace OpenSim.Region.Environment.Scenes
461 return false; 476 return false;
462 } 477 }
463 478
479 public List<EntityBase> GetEntities()
480 {
481 List<EntityBase> result;
482
483 lock (Entities)
484 {
485 result = new List<EntityBase>(Entities.Values);
486 }
487
488 return result;
489 }
490
464 #endregion 491 #endregion
465 492
466 #region Other Methods 493 #region Other Methods
@@ -484,7 +511,9 @@ namespace OpenSim.Region.Environment.Scenes
484 511
485 public void SendAllSceneObjectsToClient(ScenePresence presence) 512 public void SendAllSceneObjectsToClient(ScenePresence presence)
486 { 513 {
487 foreach (EntityBase ent in Entities.Values) 514 List<EntityBase> EntityList = GetEntities();
515
516 foreach (EntityBase ent in EntityList)
488 { 517 {
489 if (ent is SceneObjectGroup) 518 if (ent is SceneObjectGroup)
490 { 519 {
@@ -770,8 +799,10 @@ namespace OpenSim.Region.Environment.Scenes
770 /// <param name="childPrims"></param> 799 /// <param name="childPrims"></param>
771 public void LinkObjects(uint parentPrim, List<uint> childPrims) 800 public void LinkObjects(uint parentPrim, List<uint> childPrims)
772 { 801 {
802 List<EntityBase> EntityList = GetEntities();
803
773 SceneObjectGroup parenPrim = null; 804 SceneObjectGroup parenPrim = null;
774 foreach (EntityBase ent in Entities.Values) 805 foreach (EntityBase ent in EntityList)
775 { 806 {
776 if (ent is SceneObjectGroup) 807 if (ent is SceneObjectGroup)
777 { 808 {
@@ -788,7 +819,7 @@ namespace OpenSim.Region.Environment.Scenes
788 { 819 {
789 for (int i = 0; i < childPrims.Count; i++) 820 for (int i = 0; i < childPrims.Count; i++)
790 { 821 {
791 foreach (EntityBase ent in Entities.Values) 822 foreach (EntityBase ent in EntityList)
792 { 823 {
793 if (ent is SceneObjectGroup) 824 if (ent is SceneObjectGroup)
794 { 825 {
@@ -819,8 +850,10 @@ namespace OpenSim.Region.Environment.Scenes
819 // XXX I'm anticipating that building this dictionary once is more efficient than 850 // XXX I'm anticipating that building this dictionary once is more efficient than
820 // repeated scanning of the Entity.Values for a large number of primIds. However, it might 851 // repeated scanning of the Entity.Values for a large number of primIds. However, it might
821 // be more efficient yet to keep this dictionary permanently on hand. 852 // be more efficient yet to keep this dictionary permanently on hand.
853
822 Dictionary<uint, SceneObjectGroup> sceneObjects = new Dictionary<uint, SceneObjectGroup>(); 854 Dictionary<uint, SceneObjectGroup> sceneObjects = new Dictionary<uint, SceneObjectGroup>();
823 foreach (EntityBase ent in Entities.Values) 855 List<EntityBase> EntitieList = GetEntities();
856 foreach (EntityBase ent in EntitieList)
824 { 857 {
825 if (ent is SceneObjectGroup) 858 if (ent is SceneObjectGroup)
826 { 859 {
@@ -863,8 +896,10 @@ namespace OpenSim.Region.Environment.Scenes
863 /// <param name="flags"></param> 896 /// <param name="flags"></param>
864 public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags, LLUUID AgentID, LLUUID GroupID) 897 public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags, LLUUID AgentID, LLUUID GroupID)
865 { 898 {
899 List<EntityBase> EntityList = GetEntities();
900
866 SceneObjectGroup originPrim = null; 901 SceneObjectGroup originPrim = null;
867 foreach (EntityBase ent in Entities.Values) 902 foreach (EntityBase ent in EntityList)
868 { 903 {
869 if (ent is SceneObjectGroup) 904 if (ent is SceneObjectGroup)
870 { 905 {
@@ -882,7 +917,10 @@ namespace OpenSim.Region.Environment.Scenes
882 { 917 {
883 SceneObjectGroup copy = originPrim.Copy(AgentID, GroupID); 918 SceneObjectGroup copy = originPrim.Copy(AgentID, GroupID);
884 copy.AbsolutePosition = copy.AbsolutePosition + offset; 919 copy.AbsolutePosition = copy.AbsolutePosition + offset;
885 Entities.Add(copy.UUID, copy); 920 lock (Entities)
921 {
922 Entities.Add(copy.UUID, copy);
923 }
886 m_numPrim++; 924 m_numPrim++;
887 copy.ScheduleGroupForFullUpdate(); 925 copy.ScheduleGroupForFullUpdate();
888 } 926 }
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 7026fea..9821906 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -33,6 +33,7 @@ using OpenSim.Framework;
33using OpenSim.Framework.Communications.Cache; 33using OpenSim.Framework.Communications.Cache;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Region.Physics.Manager; 35using OpenSim.Region.Physics.Manager;
36using System.Collections.Generic;
36 37
37namespace OpenSim.Region.Environment.Scenes 38namespace OpenSim.Region.Environment.Scenes
38{ 39{
@@ -342,7 +343,9 @@ namespace OpenSim.Region.Environment.Scenes
342 343
343 private SceneObjectGroup GetGroupByPrim(uint localID) 344 private SceneObjectGroup GetGroupByPrim(uint localID)
344 { 345 {
345 foreach (EntityBase ent in Entities.Values) 346 List<EntityBase> EntitieList = GetEntities();
347
348 foreach (EntityBase ent in EntitieList)
346 { 349 {
347 if (ent is SceneObjectGroup) 350 if (ent is SceneObjectGroup)
348 { 351 {
@@ -455,7 +458,10 @@ namespace OpenSim.Region.Environment.Scenes
455 { 458 {
456 EntityBase selectedEnt = null; 459 EntityBase selectedEnt = null;
457 //MainLog.Instance.Verbose("CLIENT", "LocalID:" + Data.ObjectLocalID.ToString()); 460 //MainLog.Instance.Verbose("CLIENT", "LocalID:" + Data.ObjectLocalID.ToString());
458 foreach (EntityBase ent in Entities.Values) 461
462 List<EntityBase> EntitieList = GetEntities();
463
464 foreach (EntityBase ent in EntitieList)
459 { 465 {
460 if (ent.LocalId == Data.ObjectLocalID) 466 if (ent.LocalId == Data.ObjectLocalID)
461 { 467 {
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
index aa7c7b4..6a7c266 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -97,7 +97,9 @@ namespace OpenSim.Region.Environment.Scenes
97 /// <param name="remoteClient"></param> 97 /// <param name="remoteClient"></param>
98 public void SelectPrim(uint primLocalID, IClientAPI remoteClient) 98 public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
99 { 99 {
100 foreach (EntityBase ent in Entities.Values) 100 List<EntityBase> EntitieList = GetEntities();
101
102 foreach (EntityBase ent in EntitieList)
101 { 103 {
102 if (ent is SceneObjectGroup) 104 if (ent is SceneObjectGroup)
103 { 105 {
@@ -119,7 +121,9 @@ namespace OpenSim.Region.Environment.Scenes
119 /// <param name="remoteClient"></param> 121 /// <param name="remoteClient"></param>
120 public void DeselectPrim(uint primLocalID, IClientAPI remoteClient) 122 public void DeselectPrim(uint primLocalID, IClientAPI remoteClient)
121 { 123 {
122 foreach (EntityBase ent in Entities.Values) 124 List<EntityBase> EntitieList = GetEntities();
125
126 foreach (EntityBase ent in EntitieList)
123 { 127 {
124 if (ent is SceneObjectGroup) 128 if (ent is SceneObjectGroup)
125 { 129 {
@@ -137,7 +141,9 @@ namespace OpenSim.Region.Environment.Scenes
137 { 141 {
138 EventManager.TriggerObjectGrab(localID, offsetPos, remoteClient); 142 EventManager.TriggerObjectGrab(localID, offsetPos, remoteClient);
139 143
140 foreach (EntityBase ent in Entities.Values) 144 List<EntityBase> EntitieList = GetEntities();
145
146 foreach (EntityBase ent in EntitieList)
141 { 147 {
142 if (ent is SceneObjectGroup) 148 if (ent is SceneObjectGroup)
143 { 149 {
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 8277f39..db2e4b8 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1615,7 +1615,9 @@ namespace OpenSim.Region.Environment.Scenes
1615 /// <param name="message"></param> 1615 /// <param name="message"></param>
1616 public void SendGeneralAlert(string message) 1616 public void SendGeneralAlert(string message)
1617 { 1617 {
1618 foreach (ScenePresence presence in m_scenePresences.Values) 1618 List<ScenePresence> presenceList = GetScenePresences();
1619
1620 foreach (ScenePresence presence in presenceList)
1619 { 1621 {
1620 presence.ControllingClient.SendAlertMessage(message); 1622 presence.ControllingClient.SendAlertMessage(message);
1621 } 1623 }
@@ -1776,7 +1778,9 @@ namespace OpenSim.Region.Environment.Scenes
1776 /// <param name="modal"></param> 1778 /// <param name="modal"></param>
1777 public void SendAlertToUser(string firstName, string lastName, string message, bool modal) 1779 public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
1778 { 1780 {
1779 foreach (ScenePresence presence in m_scenePresences.Values) 1781 List<ScenePresence> presenceList = GetScenePresences();
1782
1783 foreach (ScenePresence presence in presenceList)
1780 { 1784 {
1781 if ((presence.Firstname == firstName) && (presence.Lastname == lastName)) 1785 if ((presence.Firstname == firstName) && (presence.Lastname == lastName))
1782 { 1786 {
@@ -1821,7 +1825,9 @@ namespace OpenSim.Region.Environment.Scenes
1821 /// </summary> 1825 /// </summary>
1822 public void ForceClientUpdate() 1826 public void ForceClientUpdate()
1823 { 1827 {
1824 foreach (EntityBase ent in Entities.Values) 1828 List<EntityBase> EntitieList = GetEntities();
1829
1830 foreach (EntityBase ent in EntitieList)
1825 { 1831 {
1826 if (ent is SceneObjectGroup) 1832 if (ent is SceneObjectGroup)
1827 { 1833 {
@@ -1838,7 +1844,10 @@ namespace OpenSim.Region.Environment.Scenes
1838 public void HandleEditCommand(string[] cmdparams) 1844 public void HandleEditCommand(string[] cmdparams)
1839 { 1845 {
1840 Console.WriteLine("Searching for Primitive: '" + cmdparams[0] + "'"); 1846 Console.WriteLine("Searching for Primitive: '" + cmdparams[0] + "'");
1841 foreach (EntityBase ent in Entities.Values) 1847
1848 List<EntityBase> EntitieList = GetEntities();
1849
1850 foreach (EntityBase ent in EntitieList)
1842 { 1851 {
1843 if (ent is SceneObjectGroup) 1852 if (ent is SceneObjectGroup)
1844 { 1853 {
@@ -2017,7 +2026,8 @@ namespace OpenSim.Region.Environment.Scenes
2017 if (!(m_scenePresences.Equals(null))) 2026 if (!(m_scenePresences.Equals(null)))
2018 { 2027 {
2019 try { 2028 try {
2020 foreach (ScenePresence presence in m_scenePresences.Values) 2029 List<ScenePresence> presenceList = GetScenePresences();
2030 foreach (ScenePresence presence in presenceList)
2021 { 2031 {
2022 action(presence); 2032 action(presence);
2023 } 2033 }
@@ -2033,7 +2043,14 @@ namespace OpenSim.Region.Environment.Scenes
2033 /// <param name="action"></param> 2043 /// <param name="action"></param>
2034 public void ForEachObject(Action<SceneObjectGroup> action) 2044 public void ForEachObject(Action<SceneObjectGroup> action)
2035 { 2045 {
2036 foreach (SceneObjectGroup presence in m_sceneObjects.Values) 2046 List<SceneObjectGroup> presenceList;
2047
2048 lock (m_sceneObjects)
2049 {
2050 presenceList = new List<SceneObjectGroup>(m_sceneObjects.Values);
2051 }
2052
2053 foreach (SceneObjectGroup presence in presenceList)
2037 { 2054 {
2038 action(presence); 2055 action(presence);
2039 } 2056 }
@@ -2074,6 +2091,11 @@ namespace OpenSim.Region.Environment.Scenes
2074 m_innerScene.ForEachClient(action); 2091 m_innerScene.ForEachClient(action);
2075 } 2092 }
2076 2093
2094 public List<EntityBase> GetEntities()
2095 {
2096 return m_innerScene.GetEntities();
2097 }
2098
2077 #endregion 2099 #endregion
2078 } 2100 }
2079} 2101}
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs
index c589e8d..e822874 100644
--- a/OpenSim/Region/Environment/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs
@@ -290,7 +290,9 @@ namespace OpenSim.Region.Environment.Scenes
290 { 290 {
291 ForEachCurrentScene(delegate(Scene scene) 291 ForEachCurrentScene(delegate(Scene scene)
292 { 292 {
293 foreach (EntityBase entity in scene.Entities.Values) 293 List<EntityBase> EntitieList = scene.GetEntities();
294
295 foreach (EntityBase entity in EntitieList)
294 { 296 {
295 if (entity is ScenePresence) 297 if (entity is ScenePresence)
296 { 298 {
@@ -315,7 +317,9 @@ namespace OpenSim.Region.Environment.Scenes
315 317
316 ForEachCurrentScene(delegate(Scene scene) 318 ForEachCurrentScene(delegate(Scene scene)
317 { 319 {
318 foreach (EntityBase entity in scene.Entities.Values) 320 List<EntityBase> EntitieList = scene.GetEntities();
321
322 foreach (EntityBase entity in EntitieList)
319 { 323 {
320 if (entity is ScenePresence) 324 if (entity is ScenePresence)
321 { 325 {
@@ -419,4 +423,4 @@ namespace OpenSim.Region.Environment.Scenes
419 m_localScenes.ForEach(action); 423 m_localScenes.ForEach(action);
420 } 424 }
421 } 425 }
422} \ No newline at end of file 426}
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
index c4411e3..aeb9c61 100644
--- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
@@ -108,7 +108,10 @@ namespace OpenSim.Region.Environment.Scenes
108 StreamWriter stream = new StreamWriter(file); 108 StreamWriter stream = new StreamWriter(file);
109 int primCount = 0; 109 int primCount = 0;
110 stream.WriteLine("<scene>\n"); 110 stream.WriteLine("<scene>\n");
111 foreach (EntityBase ent in m_innerScene.Entities.Values) 111
112 List<EntityBase> EntityList = m_innerScene.GetEntities();
113
114 foreach (EntityBase ent in EntityList)
112 { 115 {
113 if (ent is SceneObjectGroup) 116 if (ent is SceneObjectGroup)
114 { 117 {
@@ -170,7 +173,10 @@ namespace OpenSim.Region.Environment.Scenes
170 StreamWriter stream = new StreamWriter(file); 173 StreamWriter stream = new StreamWriter(file);
171 int primCount = 0; 174 int primCount = 0;
172 stream.WriteLine("<scene>\n"); 175 stream.WriteLine("<scene>\n");
173 foreach (EntityBase ent in m_innerScene.Entities.Values) 176
177 List<EntityBase> EntityList = m_innerScene.GetEntities();
178
179 foreach (EntityBase ent in EntityList)
174 { 180 {
175 if (ent is SceneObjectGroup) 181 if (ent is SceneObjectGroup)
176 { 182 {