diff options
author | UbitUmarov | 2015-11-24 17:28:05 +0000 |
---|---|---|
committer | UbitUmarov | 2015-11-24 17:28:05 +0000 |
commit | 6d5b405168b4fb9f137e63dae8669cfcf940d7b7 (patch) | |
tree | 122ca2b285d3955453161c307e23fc3b16d64701 /OpenSim/Region/CoreModules | |
parent | again chat echos, check repeats uncondicionally (diff) | |
download | opensim-SC_OLD-6d5b405168b4fb9f137e63dae8669cfcf940d7b7.zip opensim-SC_OLD-6d5b405168b4fb9f137e63dae8669cfcf940d7b7.tar.gz opensim-SC_OLD-6d5b405168b4fb9f137e63dae8669cfcf940d7b7.tar.bz2 opensim-SC_OLD-6d5b405168b4fb9f137e63dae8669cfcf940d7b7.tar.xz |
simplify DeliverChatToAvatars(..) ( hopefully not breaking it )
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 135 |
1 files changed, 62 insertions, 73 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 3b56ca6..ee0a4f8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
206 | UUID fromID = UUID.Zero; | 206 | UUID fromID = UUID.Zero; |
207 | UUID ownerID = UUID.Zero; | 207 | UUID ownerID = UUID.Zero; |
208 | string message = c.Message; | 208 | string message = c.Message; |
209 | IScene scene = c.Scene; | 209 | Scene scene = c.Scene as Scene; |
210 | UUID destination = c.Destination; | 210 | UUID destination = c.Destination; |
211 | Vector3 fromPos = c.Position; | 211 | Vector3 fromPos = c.Position; |
212 | Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0); | 212 | Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0); |
@@ -217,47 +217,48 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
217 | 217 | ||
218 | if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel; | 218 | if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel; |
219 | 219 | ||
220 | if(!m_scenes.Contains(scene)) | ||
221 | { | ||
222 | m_log.WarnFormat("[CHAT]: message from unkown scene {0} ignored", | ||
223 | scene.RegionInfo.RegionName); | ||
224 | return; | ||
225 | } | ||
226 | |||
220 | switch (sourceType) | 227 | switch (sourceType) |
221 | { | 228 | { |
222 | case ChatSourceType.Agent: | 229 | case ChatSourceType.Agent: |
223 | if (!(scene is Scene)) | 230 | ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId); |
224 | { | 231 | fromPos = avatar.AbsolutePosition; |
225 | m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}", | 232 | fromName = avatar.Name; |
226 | scene.RegionInfo.RegionName, c.Sender.AgentId); | 233 | fromID = c.Sender.AgentId; |
227 | return; | 234 | if (avatar.GodLevel >= 200) |
228 | } | 235 | { // let gods speak to outside or things may get confusing |
229 | ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId); | 236 | fromNamePrefix = m_adminPrefix; |
230 | fromPos = avatar.AbsolutePosition; | 237 | checkParcelHide = false; |
231 | fromName = avatar.Name; | 238 | } |
232 | fromID = c.Sender.AgentId; | 239 | else |
233 | if (avatar.GodLevel >= 200) | 240 | { |
234 | { // let gods speak to outside or things may get confusing | 241 | checkParcelHide = true; |
235 | fromNamePrefix = m_adminPrefix; | 242 | } |
236 | checkParcelHide = false; | 243 | destination = UUID.Zero; // Avatars cant "SayTo" |
237 | } | 244 | ownerID = c.Sender.AgentId; |
238 | else | ||
239 | { | ||
240 | checkParcelHide = true; | ||
241 | } | ||
242 | destination = UUID.Zero; // Avatars cant "SayTo" | ||
243 | ownerID = c.Sender.AgentId; | ||
244 | 245 | ||
245 | hidePos = fromPos; | 246 | hidePos = fromPos; |
246 | break; | 247 | break; |
247 | 248 | ||
248 | case ChatSourceType.Object: | 249 | case ChatSourceType.Object: |
249 | fromID = c.SenderUUID; | 250 | fromID = c.SenderUUID; |
250 | 251 | ||
251 | if (c.SenderObject != null && c.SenderObject is SceneObjectPart) | 252 | if (c.SenderObject != null && c.SenderObject is SceneObjectPart) |
252 | { | ||
253 | ownerID = ((SceneObjectPart)c.SenderObject).OwnerID; | ||
254 | if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment) | ||
255 | { | 253 | { |
256 | checkParcelHide = true; | 254 | ownerID = ((SceneObjectPart)c.SenderObject).OwnerID; |
257 | hidePos = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition; | 255 | if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment) |
256 | { | ||
257 | checkParcelHide = true; | ||
258 | hidePos = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition; | ||
259 | } | ||
258 | } | 260 | } |
259 | } | 261 | break; |
260 | break; | ||
261 | } | 262 | } |
262 | 263 | ||
263 | // TODO: iterate over message | 264 | // TODO: iterate over message |
@@ -275,7 +276,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
275 | checkParcelHide = false; | 276 | checkParcelHide = false; |
276 | if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero) | 277 | if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero) |
277 | { | 278 | { |
278 | ILandObject srcland = (scene as Scene).LandChannel.GetLandObject(hidePos.X, hidePos.Y); | 279 | ILandObject srcland = scene.LandChannel.GetLandObject(hidePos.X, hidePos.Y); |
279 | if (srcland != null && !srcland.LandData.SeeAVs) | 280 | if (srcland != null && !srcland.LandData.SeeAVs) |
280 | { | 281 | { |
281 | sourceParcelID = srcland.LandData.GlobalID; | 282 | sourceParcelID = srcland.LandData.GlobalID; |
@@ -284,54 +285,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
284 | } | 285 | } |
285 | } | 286 | } |
286 | 287 | ||
287 | foreach (Scene s in m_scenes) | 288 | scene.ForEachScenePresence( |
288 | { | 289 | delegate(ScenePresence presence) |
289 | // This should use ForEachClient, but clients don't have a position. | 290 | { |
290 | // If camera is moved into client, then camera position can be used | 291 | if (destination != UUID.Zero && presence.UUID != destination) |
291 | // MT: No, it can't, as chat is heard from the avatar position, not | 292 | return; |
292 | // the camera position. | ||
293 | |||
294 | s.ForEachScenePresence( | ||
295 | delegate(ScenePresence presence) | ||
296 | { | ||
297 | if (receiverIDs.Contains(presence.UUID)) | ||
298 | return; // already sent to this presence | ||
299 | 293 | ||
300 | if (destination != UUID.Zero && presence.UUID != destination) | 294 | if(presence.IsChildAgent) |
295 | { | ||
296 | if(checkParcelHide) | ||
297 | return; | ||
298 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, | ||
299 | ownerID, fromNamePrefix + fromName, c.Type, | ||
300 | message, sourceType, (destination != UUID.Zero))) | ||
301 | receiverIDs.Add(presence.UUID); | ||
301 | return; | 302 | return; |
303 | } | ||
302 | 304 | ||
303 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); | 305 | ILandObject Presencecheck = scene.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); |
304 | if (Presencecheck != null) | 306 | if (Presencecheck != null) |
307 | { | ||
308 | if (checkParcelHide) | ||
305 | { | 309 | { |
306 | // This will pass all chat from objects. Not | 310 | if (sourceParcelID != Presencecheck.LandData.GlobalID && presence.GodLevel < 200) |
307 | // perfect, but it will do. For now. Better | 311 | return; |
308 | // than the prior behavior of muting all | ||
309 | // objects on a parcel with access restrictions | ||
310 | if (checkParcelHide) | ||
311 | { | ||
312 | if (sourceParcelID != Presencecheck.LandData.GlobalID && presence.GodLevel < 200) | ||
313 | return; | ||
314 | } | ||
315 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) | ||
316 | { | ||
317 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, | ||
318 | ownerID, fromNamePrefix + fromName, c.Type, | ||
319 | message, sourceType, (destination != UUID.Zero))) | ||
320 | receiverIDs.Add(presence.UUID); | ||
321 | } | ||
322 | } | 312 | } |
323 | else if(!checkParcelHide && (presence.IsChildAgent)) | 313 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) |
324 | { | 314 | { |
325 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, | 315 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, |
326 | ownerID, fromNamePrefix + fromName, c.Type, | 316 | ownerID, fromNamePrefix + fromName, c.Type, |
327 | message, sourceType, (destination != UUID.Zero))) | 317 | message, sourceType, (destination != UUID.Zero))) |
328 | receiverIDs.Add(presence.UUID); | 318 | receiverIDs.Add(presence.UUID); |
329 | } | 319 | } |
330 | } | 320 | } |
331 | ); | 321 | }); |
332 | } | ||
333 | 322 | ||
334 | (scene as Scene).EventManager.TriggerOnChatToClients( | 323 | scene.EventManager.TriggerOnChatToClients( |
335 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); | 324 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); |
336 | } | 325 | } |
337 | 326 | ||