aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/InnerScene.cs
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/Environment/Scenes/InnerScene.cs
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
1 files changed, 52 insertions, 14 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 }