aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs52
1 files changed, 35 insertions, 17 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index 10b4c37..e4452fb 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -186,6 +186,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
186 { 186 {
187 string fromName = c.From; 187 string fromName = c.From;
188 UUID fromID = UUID.Zero; 188 UUID fromID = UUID.Zero;
189 UUID targetID = c.TargetUUID;
189 string message = c.Message; 190 string message = c.Message;
190 IScene scene = c.Scene; 191 IScene scene = c.Scene;
191 Vector3 fromPos = c.Position; 192 Vector3 fromPos = c.Position;
@@ -221,24 +222,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
221 message = message.Substring(0, 1000); 222 message = message.Substring(0, 1000);
222 223
223// m_log.DebugFormat( 224// m_log.DebugFormat(
224// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", 225// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}",
225// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); 226// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID);
226 227
227 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 228 HashSet<UUID> receiverIDs = new HashSet<UUID>();
228 229
229 foreach (Scene s in m_scenes) 230 foreach (Scene s in m_scenes)
230 { 231 {
231 // This should use ForEachClient, but clients don't have a position. 232 if (targetID == UUID.Zero)
232 // If camera is moved into client, then camera position can be used 233 {
233 s.ForEachRootScenePresence( 234 // This should use ForEachClient, but clients don't have a position.
234 delegate(ScenePresence presence) 235 // If camera is moved into client, then camera position can be used
236 s.ForEachRootScenePresence(
237 delegate(ScenePresence presence)
238 {
239 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, false))
240 receiverIDs.Add(presence.UUID);
241 }
242 );
243 }
244 else
245 {
246 // This is a send to a specific client eg from llRegionSayTo
247 // no need to check distance etc, jand send is as say
248 ScenePresence presence = s.GetScenePresence(targetID);
249 if (presence != null && !presence.IsChildAgent)
235 { 250 {
236 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType)) 251 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, ChatTypeEnum.Say, message, sourceType, true))
237 receiverIDs.Add(presence.UUID); 252 receiverIDs.Add(presence.UUID);
238 } 253 }
239 ); 254 }
240 } 255 }
241 256
242 (scene as Scene).EventManager.TriggerOnChatToClients( 257 (scene as Scene).EventManager.TriggerOnChatToClients(
243 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); 258 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
244 } 259 }
@@ -315,7 +330,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
315 /// precondition</returns> 330 /// precondition</returns>
316 protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, 331 protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
317 UUID fromAgentID, string fromName, ChatTypeEnum type, 332 UUID fromAgentID, string fromName, ChatTypeEnum type,
318 string message, ChatSourceType src) 333 string message, ChatSourceType src, bool ignoreDistance)
319 { 334 {
320 // don't send stuff to child agents 335 // don't send stuff to child agents
321 if (presence.IsChildAgent) return false; 336 if (presence.IsChildAgent) return false;
@@ -326,12 +341,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
326 presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); 341 presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
327 342
328 int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); 343 int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);
329 344
330 if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || 345 if (!ignoreDistance)
331 type == ChatTypeEnum.Say && dis > m_saydistance ||
332 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
333 { 346 {
334 return false; 347 if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
348 type == ChatTypeEnum.Say && dis > m_saydistance ||
349 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
350 {
351 return false;
352 }
335 } 353 }
336 354
337 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView 355 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView