diff options
author | Sean Dague | 2008-12-12 18:33:16 +0000 |
---|---|---|
committer | Sean Dague | 2008-12-12 18:33:16 +0000 |
commit | 7a4f11b94da2ba2fbe24393ce2804214e199bce7 (patch) | |
tree | 106c9d1e745156a100da8bfc352a0997a04062fe /OpenSim/Region/Environment/Scenes/EntityManager.cs | |
parent | Made the casting of stings to floats more robust and work more like SL. (diff) | |
download | opensim-SC_OLD-7a4f11b94da2ba2fbe24393ce2804214e199bce7.zip opensim-SC_OLD-7a4f11b94da2ba2fbe24393ce2804214e199bce7.tar.gz opensim-SC_OLD-7a4f11b94da2ba2fbe24393ce2804214e199bce7.tar.bz2 opensim-SC_OLD-7a4f11b94da2ba2fbe24393ce2804214e199bce7.tar.xz |
* Deleted old EntiyList tests, added new EntityManager tests
* Edited EntityManager to treat Exceptions
From: Arthur Rodrigo S Valadares <arthursv@linux.vnet.ibm.com>
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/EntityManager.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/EntityManager.cs | 108 |
1 files changed, 89 insertions, 19 deletions
diff --git a/OpenSim/Region/Environment/Scenes/EntityManager.cs b/OpenSim/Region/Environment/Scenes/EntityManager.cs index 25f73b4..e7592fe 100644 --- a/OpenSim/Region/Environment/Scenes/EntityManager.cs +++ b/OpenSim/Region/Environment/Scenes/EntityManager.cs | |||
@@ -28,14 +28,19 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | ||
32 | using log4net; | ||
31 | using OpenMetaverse; | 33 | using OpenMetaverse; |
32 | 34 | ||
35 | |||
33 | namespace OpenSim.Region.Environment.Scenes | 36 | namespace OpenSim.Region.Environment.Scenes |
34 | { | 37 | { |
35 | public class EntityManager : IEnumerable<EntityBase> | 38 | public class EntityManager : IEnumerable<EntityBase> |
36 | { | 39 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
37 | private readonly Dictionary<UUID,EntityBase> m_eb_uuid = new Dictionary<UUID, EntityBase>(); | 41 | private readonly Dictionary<UUID,EntityBase> m_eb_uuid = new Dictionary<UUID, EntityBase>(); |
38 | private readonly Dictionary<uint, EntityBase> m_eb_localID = new Dictionary<uint, EntityBase>(); | 42 | private readonly Dictionary<uint, EntityBase> m_eb_localID = new Dictionary<uint, EntityBase>(); |
43 | private readonly Dictionary<UUID, ScenePresence> m_pres_uuid = new Dictionary<UUID, ScenePresence>(); | ||
39 | private readonly Object m_lock = new Object(); | 44 | private readonly Object m_lock = new Object(); |
40 | 45 | ||
41 | [Obsolete("Use Add() instead.")] | 46 | [Obsolete("Use Add() instead.")] |
@@ -48,8 +53,15 @@ namespace OpenSim.Region.Environment.Scenes | |||
48 | { | 53 | { |
49 | lock (m_lock) | 54 | lock (m_lock) |
50 | { | 55 | { |
51 | m_eb_uuid.Add(entity.UUID, entity); | 56 | try |
52 | m_eb_localID.Add(entity.LocalId, entity); | 57 | { |
58 | m_eb_uuid.Add(entity.UUID, entity); | ||
59 | m_eb_localID.Add(entity.LocalId, entity); | ||
60 | } | ||
61 | catch(Exception e) | ||
62 | { | ||
63 | m_log.ErrorFormat("Add Entity failed: ", e); | ||
64 | } | ||
53 | } | 65 | } |
54 | } | 66 | } |
55 | 67 | ||
@@ -57,8 +69,15 @@ namespace OpenSim.Region.Environment.Scenes | |||
57 | { | 69 | { |
58 | lock (m_lock) | 70 | lock (m_lock) |
59 | { | 71 | { |
60 | m_eb_uuid[entity.UUID] = entity; | 72 | try |
61 | m_eb_localID[entity.LocalId] = entity; | 73 | { |
74 | m_eb_uuid[entity.UUID] = entity; | ||
75 | m_eb_localID[entity.LocalId] = entity; | ||
76 | } | ||
77 | catch(Exception e) | ||
78 | { | ||
79 | m_log.ErrorFormat("Insert or Replace Entity failed: ", e); | ||
80 | } | ||
62 | } | 81 | } |
63 | } | 82 | } |
64 | 83 | ||
@@ -86,7 +105,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
86 | { | 105 | { |
87 | lock (m_lock) | 106 | lock (m_lock) |
88 | { | 107 | { |
89 | return m_eb_uuid.ContainsKey(id); | 108 | try |
109 | { | ||
110 | return m_eb_uuid.ContainsKey(id); | ||
111 | } | ||
112 | catch | ||
113 | { | ||
114 | return false; | ||
115 | } | ||
90 | } | 116 | } |
91 | } | 117 | } |
92 | 118 | ||
@@ -94,7 +120,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
94 | { | 120 | { |
95 | lock (m_lock) | 121 | lock (m_lock) |
96 | { | 122 | { |
97 | return m_eb_localID.ContainsKey(localID); | 123 | try |
124 | { | ||
125 | return m_eb_localID.ContainsKey(localID); | ||
126 | } | ||
127 | catch | ||
128 | { | ||
129 | return false; | ||
130 | } | ||
98 | } | 131 | } |
99 | } | 132 | } |
100 | 133 | ||
@@ -102,10 +135,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
102 | { | 135 | { |
103 | lock (m_lock) | 136 | lock (m_lock) |
104 | { | 137 | { |
105 | bool a = m_eb_uuid.Remove(m_eb_localID[localID].UUID); | 138 | try |
106 | bool b = m_eb_localID.Remove(localID); | 139 | { |
107 | 140 | bool a = m_eb_uuid.Remove(m_eb_localID[localID].UUID); | |
108 | return a && b; | 141 | bool b = m_eb_localID.Remove(localID); |
142 | return a && b; | ||
143 | } | ||
144 | catch (Exception e) | ||
145 | { | ||
146 | m_log.ErrorFormat("Remove Entity failed for {0}", localID, e); | ||
147 | return false; | ||
148 | } | ||
109 | } | 149 | } |
110 | } | 150 | } |
111 | 151 | ||
@@ -113,10 +153,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
113 | { | 153 | { |
114 | lock (m_lock) | 154 | lock (m_lock) |
115 | { | 155 | { |
116 | bool a = m_eb_localID.Remove(m_eb_uuid[id].LocalId); | 156 | try |
117 | bool b = m_eb_uuid.Remove(id); | 157 | { |
118 | 158 | bool a = m_eb_localID.Remove(m_eb_uuid[id].LocalId); | |
119 | return a && b; | 159 | bool b = m_eb_uuid.Remove(id); |
160 | return a && b; | ||
161 | } | ||
162 | catch (Exception e) | ||
163 | { | ||
164 | m_log.ErrorFormat("Remove Entity failed for {0}", id, e); | ||
165 | return false; | ||
166 | } | ||
120 | } | 167 | } |
121 | } | 168 | } |
122 | 169 | ||
@@ -126,13 +173,21 @@ namespace OpenSim.Region.Environment.Scenes | |||
126 | 173 | ||
127 | lock (m_lock) | 174 | lock (m_lock) |
128 | { | 175 | { |
129 | foreach (KeyValuePair<UUID, EntityBase> pair in m_eb_uuid) | 176 | try |
130 | { | 177 | { |
131 | if (pair.Value is T) | 178 | foreach (KeyValuePair<UUID, EntityBase> pair in m_eb_uuid) |
132 | { | 179 | { |
133 | tmp.Add(pair.Value); | 180 | if (pair.Value is T) |
181 | { | ||
182 | tmp.Add(pair.Value); | ||
183 | } | ||
134 | } | 184 | } |
135 | } | 185 | } |
186 | catch (Exception e) | ||
187 | { | ||
188 | m_log.ErrorFormat("GetAllByType failed for {0}", e); | ||
189 | tmp = null; | ||
190 | } | ||
136 | } | 191 | } |
137 | 192 | ||
138 | return tmp; | 193 | return tmp; |
@@ -152,7 +207,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
152 | { | 207 | { |
153 | lock (m_lock) | 208 | lock (m_lock) |
154 | { | 209 | { |
155 | return m_eb_uuid[id]; | 210 | try |
211 | { | ||
212 | return m_eb_uuid[id]; | ||
213 | } | ||
214 | catch | ||
215 | { | ||
216 | return null; | ||
217 | } | ||
156 | } | 218 | } |
157 | } | 219 | } |
158 | set | 220 | set |
@@ -167,7 +229,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
167 | { | 229 | { |
168 | lock (m_lock) | 230 | lock (m_lock) |
169 | { | 231 | { |
170 | return m_eb_localID[localID]; | 232 | try |
233 | { | ||
234 | return m_eb_localID[localID]; | ||
235 | } | ||
236 | catch | ||
237 | { | ||
238 | return null; | ||
239 | } | ||
171 | } | 240 | } |
172 | } | 241 | } |
173 | set | 242 | set |
@@ -205,5 +274,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
205 | { | 274 | { |
206 | return GetEnumerator(); | 275 | return GetEnumerator(); |
207 | } | 276 | } |
277 | |||
208 | } | 278 | } |
209 | } | 279 | } |