diff options
author | Adam Frisby | 2008-11-24 14:45:05 +0000 |
---|---|---|
committer | Adam Frisby | 2008-11-24 14:45:05 +0000 |
commit | 47829849d99e1ec6e11ac26e1f892cbaf94d5503 (patch) | |
tree | 8f6d4371874f1716312bf0752e9251f20dc920c2 /OpenSim/Region/Environment/Scenes | |
parent | * Makes EntityManager IEnumerable - meaning we should be good to go to enable... (diff) | |
download | opensim-SC-47829849d99e1ec6e11ac26e1f892cbaf94d5503.zip opensim-SC-47829849d99e1ec6e11ac26e1f892cbaf94d5503.tar.gz opensim-SC-47829849d99e1ec6e11ac26e1f892cbaf94d5503.tar.bz2 opensim-SC-47829849d99e1ec6e11ac26e1f892cbaf94d5503.tar.xz |
* Swaps Scene.Entities Dictionary for EntityManager.
* Important Changes: Scene.Entities is now IEnumerable directly. You do not need to use Entities.Values, you can Enumerate on .Entities directly. (So 'foreach Scene.Entities' vs 'foreach Scene.Entities.Values').
* Locks: Entities maintains it's own internal locking states. This means you do not need to lock entities anymore. I'll be going through and removing locks on it systematically.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/EntityManager.cs | 32 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 12 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneGraph.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/ScenePresence.cs | 2 |
5 files changed, 40 insertions, 16 deletions
diff --git a/OpenSim/Region/Environment/Scenes/EntityManager.cs b/OpenSim/Region/Environment/Scenes/EntityManager.cs index 43bf090..be39878 100644 --- a/OpenSim/Region/Environment/Scenes/EntityManager.cs +++ b/OpenSim/Region/Environment/Scenes/EntityManager.cs | |||
@@ -71,21 +71,25 @@ namespace OpenSim.Region.Environment.Scenes | |||
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | public void Remove(uint localID) | 74 | public bool Remove(uint localID) |
75 | { | 75 | { |
76 | lock(m_lock) | 76 | lock(m_lock) |
77 | { | 77 | { |
78 | m_eb_uuid.Remove(m_eb_localID[localID].UUID); | 78 | bool a = m_eb_uuid.Remove(m_eb_localID[localID].UUID); |
79 | m_eb_localID.Remove(localID); | 79 | bool b = m_eb_localID.Remove(localID); |
80 | |||
81 | return a && b; | ||
80 | } | 82 | } |
81 | } | 83 | } |
82 | 84 | ||
83 | public void Remove(UUID id) | 85 | public bool Remove(UUID id) |
84 | { | 86 | { |
85 | lock(m_lock) | 87 | lock(m_lock) |
86 | { | 88 | { |
87 | m_eb_localID.Remove(m_eb_uuid[id].LocalId); | 89 | bool a = m_eb_localID.Remove(m_eb_uuid[id].LocalId); |
88 | m_eb_uuid.Remove(id); | 90 | bool b = m_eb_uuid.Remove(id); |
91 | |||
92 | return a && b; | ||
89 | } | 93 | } |
90 | } | 94 | } |
91 | 95 | ||
@@ -145,6 +149,22 @@ namespace OpenSim.Region.Environment.Scenes | |||
145 | } | 149 | } |
146 | } | 150 | } |
147 | 151 | ||
152 | public bool TryGetValue(UUID key, out EntityBase obj) | ||
153 | { | ||
154 | lock(m_lock) | ||
155 | { | ||
156 | return m_eb_uuid.TryGetValue(key, out obj); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | public bool TryGetValue(uint key, out EntityBase obj) | ||
161 | { | ||
162 | lock (m_lock) | ||
163 | { | ||
164 | return m_eb_localID.TryGetValue(key, out obj); | ||
165 | } | ||
166 | } | ||
167 | |||
148 | /// <summary> | 168 | /// <summary> |
149 | /// This could be optimised to work on the list 'live' rather than making a safe copy and iterating that. | 169 | /// This could be optimised to work on the list 'live' rather than making a safe copy and iterating that. |
150 | /// </summary> | 170 | /// </summary> |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 9b30d87..9f91f37 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -57,7 +57,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
57 | { | 57 | { |
58 | m_log.Info("[PRIM INVENTORY]: Starting scripts in scene"); | 58 | m_log.Info("[PRIM INVENTORY]: Starting scripts in scene"); |
59 | 59 | ||
60 | foreach (EntityBase group in Entities.Values) | 60 | foreach (EntityBase group in Entities) |
61 | { | 61 | { |
62 | if (group is SceneObjectGroup) | 62 | if (group is SceneObjectGroup) |
63 | { | 63 | { |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index d2e797a..55e8634 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -244,6 +244,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
244 | // set { m_sceneGraph.SceneObjects = value; } | 244 | // set { m_sceneGraph.SceneObjects = value; } |
245 | // } | 245 | // } |
246 | 246 | ||
247 | /** | ||
247 | /// <summary> | 248 | /// <summary> |
248 | /// The dictionary of all entities in this scene. The contents of this dictionary may be changed at any time. | 249 | /// The dictionary of all entities in this scene. The contents of this dictionary may be changed at any time. |
249 | /// If you wish to add or remove entities, please use the appropriate method for that entity rather than | 250 | /// If you wish to add or remove entities, please use the appropriate method for that entity rather than |
@@ -257,6 +258,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
257 | get { return m_sceneGraph.Entities; } | 258 | get { return m_sceneGraph.Entities; } |
258 | set { m_sceneGraph.Entities = value; } | 259 | set { m_sceneGraph.Entities = value; } |
259 | } | 260 | } |
261 | */ | ||
262 | public EntityManager Entities | ||
263 | { | ||
264 | get { return m_sceneGraph.Entities; } | ||
265 | } | ||
260 | 266 | ||
261 | public Dictionary<UUID, ScenePresence> m_restorePresences | 267 | public Dictionary<UUID, ScenePresence> m_restorePresences |
262 | { | 268 | { |
@@ -605,7 +611,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
605 | m_log.Info("Stopping all Scripts in Scene"); | 611 | m_log.Info("Stopping all Scripts in Scene"); |
606 | lock (Entities) | 612 | lock (Entities) |
607 | { | 613 | { |
608 | foreach (EntityBase ent in Entities.Values) | 614 | foreach (EntityBase ent in Entities) |
609 | { | 615 | { |
610 | if (ent is SceneObjectGroup) | 616 | if (ent is SceneObjectGroup) |
611 | { | 617 | { |
@@ -619,7 +625,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
619 | m_log.Info("Starting all Scripts in Scene"); | 625 | m_log.Info("Starting all Scripts in Scene"); |
620 | lock (Entities) | 626 | lock (Entities) |
621 | { | 627 | { |
622 | foreach (EntityBase ent in Entities.Values) | 628 | foreach (EntityBase ent in Entities) |
623 | { | 629 | { |
624 | if (ent is SceneObjectGroup) | 630 | if (ent is SceneObjectGroup) |
625 | { | 631 | { |
@@ -1857,7 +1863,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1857 | { | 1863 | { |
1858 | lock (Entities) | 1864 | lock (Entities) |
1859 | { | 1865 | { |
1860 | ICollection<EntityBase> entities = new List<EntityBase>(Entities.Values); | 1866 | ICollection<EntityBase> entities = new List<EntityBase>(Entities); |
1861 | 1867 | ||
1862 | foreach (EntityBase e in entities) | 1868 | foreach (EntityBase e in entities) |
1863 | { | 1869 | { |
diff --git a/OpenSim/Region/Environment/Scenes/SceneGraph.cs b/OpenSim/Region/Environment/Scenes/SceneGraph.cs index 05ad996..2c75867 100644 --- a/OpenSim/Region/Environment/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Environment/Scenes/SceneGraph.cs | |||
@@ -59,7 +59,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
59 | protected internal Dictionary<UUID, ScenePresence> ScenePresences = new Dictionary<UUID, ScenePresence>(); | 59 | protected internal Dictionary<UUID, ScenePresence> ScenePresences = new Dictionary<UUID, ScenePresence>(); |
60 | // SceneObjects is not currently populated or used. | 60 | // SceneObjects is not currently populated or used. |
61 | //public Dictionary<UUID, SceneObjectGroup> SceneObjects; | 61 | //public Dictionary<UUID, SceneObjectGroup> SceneObjects; |
62 | protected internal Dictionary<UUID, EntityBase> Entities = new Dictionary<UUID, EntityBase>(); | 62 | protected internal EntityManager Entities = new EntityManager(); |
63 | // protected internal Dictionary<UUID, EntityBase> Entities = new Dictionary<UUID, EntityBase>(); | ||
63 | protected internal Dictionary<UUID, ScenePresence> RestorePresences = new Dictionary<UUID, ScenePresence>(); | 64 | protected internal Dictionary<UUID, ScenePresence> RestorePresences = new Dictionary<UUID, ScenePresence>(); |
64 | 65 | ||
65 | protected internal BasicQuadTreeNode QuadTree; | 66 | protected internal BasicQuadTreeNode QuadTree; |
@@ -972,10 +973,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
972 | /// <returns></returns> | 973 | /// <returns></returns> |
973 | protected internal List<EntityBase> GetEntities() | 974 | protected internal List<EntityBase> GetEntities() |
974 | { | 975 | { |
975 | lock (Entities) | 976 | return Entities.GetEntities(); |
976 | { | ||
977 | return new List<EntityBase>(Entities.Values); | ||
978 | } | ||
979 | } | 977 | } |
980 | 978 | ||
981 | protected internal Dictionary<uint, float> GetTopScripts() | 979 | protected internal Dictionary<uint, float> GetTopScripts() |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 042a4fb..807fd8c 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -600,7 +600,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
600 | { | 600 | { |
601 | m_pendingObjects = new Queue<SceneObjectGroup>(); | 601 | m_pendingObjects = new Queue<SceneObjectGroup>(); |
602 | 602 | ||
603 | List<EntityBase> ents = new List<EntityBase>(m_scene.Entities.Values); | 603 | List<EntityBase> ents = new List<EntityBase>(m_scene.Entities); |
604 | if (!m_isChildAgent) // Proximity sort makes no sense for | 604 | if (!m_isChildAgent) // Proximity sort makes no sense for |
605 | { // Child agents | 605 | { // Child agents |
606 | ents.Sort(delegate(EntityBase a, EntityBase b) | 606 | ents.Sort(delegate(EntityBase a, EntityBase b) |