diff options
author | Dan Lake | 2011-10-27 02:26:37 -0700 |
---|---|---|
committer | Dan Lake | 2011-10-27 02:26:37 -0700 |
commit | 272bf712796ad8e98e79aee50311a84deaf23d79 (patch) | |
tree | edda33f1e7478678a457f187768e1b73a118240b /OpenSim/Region | |
parent | Continuation of previous checkin. Found more places where ForEachScenePresenc... (diff) | |
download | opensim-SC_OLD-272bf712796ad8e98e79aee50311a84deaf23d79.zip opensim-SC_OLD-272bf712796ad8e98e79aee50311a84deaf23d79.tar.gz opensim-SC_OLD-272bf712796ad8e98e79aee50311a84deaf23d79.tar.bz2 opensim-SC_OLD-272bf712796ad8e98e79aee50311a84deaf23d79.tar.xz |
Removed use of 'is' operator and casting to find the root ScenePresence in MessageTransfer modules and Groups module.
Diffstat (limited to 'OpenSim/Region')
4 files changed, 53 insertions, 82 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs index 72b448b..321a705 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs | |||
@@ -143,24 +143,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
143 | // Try root avatar only first | 143 | // Try root avatar only first |
144 | foreach (Scene scene in m_Scenes) | 144 | foreach (Scene scene in m_Scenes) |
145 | { | 145 | { |
146 | if (scene.Entities.ContainsKey(toAgentID) && | 146 | // m_log.DebugFormat( |
147 | scene.Entities[toAgentID] is ScenePresence) | 147 | // "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", |
148 | { | 148 | // toAgentID.ToString(), scene.RegionInfo.RegionName); |
149 | // m_log.DebugFormat( | 149 | ScenePresence sp = scene.GetScenePresence(toAgentID); |
150 | // "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", | 150 | if (sp != null && !sp.IsChildAgent) |
151 | // toAgentID.ToString(), scene.RegionInfo.RegionName); | 151 | { |
152 | 152 | // Local message | |
153 | ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; | 153 | // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); |
154 | if (!user.IsChildAgent) | 154 | sp.ControllingClient.SendInstantMessage(im); |
155 | { | ||
156 | // Local message | ||
157 | // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); | ||
158 | user.ControllingClient.SendInstantMessage(im); | ||
159 | 155 | ||
160 | // Message sent | 156 | // Message sent |
161 | result(true); | 157 | result(true); |
162 | return; | 158 | return; |
163 | } | ||
164 | } | 159 | } |
165 | } | 160 | } |
166 | 161 | ||
@@ -168,16 +163,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
168 | foreach (Scene scene in m_Scenes) | 163 | foreach (Scene scene in m_Scenes) |
169 | { | 164 | { |
170 | // m_log.DebugFormat( | 165 | // m_log.DebugFormat( |
171 | // "[HG INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); | 166 | // "[HG INSTANT MESSAGE]: Looking for child of {0} in {1}", |
172 | 167 | // toAgentID, scene.RegionInfo.RegionName); | |
173 | if (scene.Entities.ContainsKey(toAgentID) && | 168 | ScenePresence sp = scene.GetScenePresence(toAgentID); |
174 | scene.Entities[toAgentID] is ScenePresence) | 169 | if (sp != null) |
175 | { | 170 | { |
176 | // Local message | 171 | // Local message |
177 | ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; | ||
178 | |||
179 | // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); | 172 | // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); |
180 | user.ControllingClient.SendInstantMessage(im); | 173 | sp.ControllingClient.SendInstantMessage(im); |
181 | 174 | ||
182 | // Message sent | 175 | // Message sent |
183 | result(true); | 176 | result(true); |
@@ -231,17 +224,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
231 | bool successful = false; | 224 | bool successful = false; |
232 | foreach (Scene scene in m_Scenes) | 225 | foreach (Scene scene in m_Scenes) |
233 | { | 226 | { |
234 | if (scene.Entities.ContainsKey(toAgentID) && | 227 | ScenePresence sp = scene.GetScenePresence(toAgentID); |
235 | scene.Entities[toAgentID] is ScenePresence) | 228 | if(!sp.IsChildAgent) |
236 | { | 229 | { |
237 | ScenePresence user = | 230 | scene.EventManager.TriggerIncomingInstantMessage(gim); |
238 | (ScenePresence)scene.Entities[toAgentID]; | 231 | successful = true; |
239 | |||
240 | if (!user.IsChildAgent) | ||
241 | { | ||
242 | scene.EventManager.TriggerIncomingInstantMessage(gim); | ||
243 | successful = true; | ||
244 | } | ||
245 | } | 232 | } |
246 | } | 233 | } |
247 | if (!successful) | 234 | if (!successful) |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 45b84f4..0dad3c4 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -136,24 +136,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
136 | // Try root avatar only first | 136 | // Try root avatar only first |
137 | foreach (Scene scene in m_Scenes) | 137 | foreach (Scene scene in m_Scenes) |
138 | { | 138 | { |
139 | if (scene.Entities.ContainsKey(toAgentID) && | 139 | // m_log.DebugFormat( |
140 | scene.Entities[toAgentID] is ScenePresence) | 140 | // "[INSTANT MESSAGE]: Looking for root agent {0} in {1}", |
141 | // toAgentID.ToString(), scene.RegionInfo.RegionName); | ||
142 | ScenePresence sp = scene.GetScenePresence(toAgentID); | ||
143 | if (sp != null && !sp.IsChildAgent) | ||
141 | { | 144 | { |
142 | // m_log.DebugFormat( | 145 | // Local message |
143 | // "[INSTANT MESSAGE]: Looking for root agent {0} in {1}", | 146 | // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); |
144 | // toAgentID.ToString(), scene.RegionInfo.RegionName); | 147 | sp.ControllingClient.SendInstantMessage(im); |
145 | 148 | ||
146 | ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; | 149 | // Message sent |
147 | if (!user.IsChildAgent) | 150 | result(true); |
148 | { | 151 | return; |
149 | // Local message | ||
150 | // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); | ||
151 | user.ControllingClient.SendInstantMessage(im); | ||
152 | |||
153 | // Message sent | ||
154 | result(true); | ||
155 | return; | ||
156 | } | ||
157 | } | 152 | } |
158 | } | 153 | } |
159 | 154 | ||
@@ -162,15 +157,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
162 | { | 157 | { |
163 | // m_log.DebugFormat( | 158 | // m_log.DebugFormat( |
164 | // "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); | 159 | // "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); |
165 | 160 | ScenePresence sp = scene.GetScenePresence(toAgentID); | |
166 | if (scene.Entities.ContainsKey(toAgentID) && | 161 | if (sp != null) |
167 | scene.Entities[toAgentID] is ScenePresence) | ||
168 | { | 162 | { |
169 | // Local message | 163 | // Local message |
170 | ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; | ||
171 | |||
172 | // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); | 164 | // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); |
173 | user.ControllingClient.SendInstantMessage(im); | 165 | sp.ControllingClient.SendInstantMessage(im); |
174 | 166 | ||
175 | // Message sent | 167 | // Message sent |
176 | result(true); | 168 | result(true); |
@@ -389,17 +381,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
389 | // Trigger the Instant message in the scene. | 381 | // Trigger the Instant message in the scene. |
390 | foreach (Scene scene in m_Scenes) | 382 | foreach (Scene scene in m_Scenes) |
391 | { | 383 | { |
392 | if (scene.Entities.ContainsKey(toAgentID) && | 384 | ScenePresence sp = scene.GetScenePresence(toAgentID); |
393 | scene.Entities[toAgentID] is ScenePresence) | 385 | if (sp != null && !sp.IsChildAgent) |
394 | { | 386 | { |
395 | ScenePresence user = | 387 | scene.EventManager.TriggerIncomingInstantMessage(gim); |
396 | (ScenePresence)scene.Entities[toAgentID]; | 388 | successful = true; |
397 | |||
398 | if (!user.IsChildAgent) | ||
399 | { | ||
400 | scene.EventManager.TriggerIncomingInstantMessage(gim); | ||
401 | successful = true; | ||
402 | } | ||
403 | } | 389 | } |
404 | } | 390 | } |
405 | if (!successful) | 391 | if (!successful) |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index a12e6ea..10b83e6 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | |||
@@ -504,19 +504,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
504 | // Try root avatar first | 504 | // Try root avatar first |
505 | foreach (Scene scene in m_sceneList) | 505 | foreach (Scene scene in m_sceneList) |
506 | { | 506 | { |
507 | if (scene.Entities.ContainsKey(agentID) && | 507 | ScenePresence sp = scene.GetScenePresence(agentID); |
508 | scene.Entities[agentID] is ScenePresence) | 508 | if (sp != null) |
509 | { | 509 | { |
510 | ScenePresence user = (ScenePresence)scene.Entities[agentID]; | 510 | if (!sp.IsChildAgent) |
511 | if (!user.IsChildAgent) | ||
512 | { | 511 | { |
513 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name); | 512 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name); |
514 | return user.ControllingClient; | 513 | return sp.ControllingClient; |
515 | } | 514 | } |
516 | else | 515 | else |
517 | { | 516 | { |
518 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name); | 517 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name); |
519 | child = user.ControllingClient; | 518 | child = sp.ControllingClient; |
520 | } | 519 | } |
521 | } | 520 | } |
522 | } | 521 | } |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index 630fcab..b2c0f48 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | |||
@@ -1076,17 +1076,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1076 | // Try root avatar first | 1076 | // Try root avatar first |
1077 | foreach (Scene scene in m_sceneList) | 1077 | foreach (Scene scene in m_sceneList) |
1078 | { | 1078 | { |
1079 | if (scene.Entities.ContainsKey(agentID) && | 1079 | ScenePresence sp = scene.GetScenePresence(agentID); |
1080 | scene.Entities[agentID] is ScenePresence) | 1080 | if (sp != null) |
1081 | { | 1081 | { |
1082 | ScenePresence user = (ScenePresence)scene.Entities[agentID]; | 1082 | if (!sp.IsChildAgent) |
1083 | if (!user.IsChildAgent) | ||
1084 | { | 1083 | { |
1085 | return user.ControllingClient; | 1084 | return sp.ControllingClient; |
1086 | } | 1085 | } |
1087 | else | 1086 | else |
1088 | { | 1087 | { |
1089 | child = user.ControllingClient; | 1088 | child = sp.ControllingClient; |
1090 | } | 1089 | } |
1091 | } | 1090 | } |
1092 | } | 1091 | } |