From f364a084f1ae72c9c52393267052d061df5328e3 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 19 Oct 2007 23:27:54 +0000 Subject: * Cross-border region chat should now work as long as both regions are part of the same simulator. --- OpenSim/Region/Environment/Modules/ChatModule.cs | 118 +++++++++++------------ 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 3b08db3..b6bbdb7 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -196,7 +196,8 @@ namespace OpenSim.Region.Environment.Modules scene = m_scenes[0]; // Filled in since it's easier than rewriting right now. - LLVector3 fromPos = e.Position; + LLVector3 fromPos = e.Position; + LLVector3 fromRegionPos = e.Position + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0); string fromName = e.From; string message = e.Message; byte type = (byte)e.Type; @@ -240,64 +241,63 @@ namespace OpenSim.Region.Environment.Modules m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + " in " + scene.RegionInfo.RegionName + ">: " + e.Message); m_ircWriter.Flush(); - } - - if (e.Channel == 0) - { - scene.ForEachScenePresence(delegate(ScenePresence presence) - { - int dis = -1000; - - //err ??? the following code seems to be request a scenePresence when it already has a ref to it - avatar = scene.GetScenePresence(presence.ControllingClient.AgentId); - if (avatar != null) - { - dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); - } - - switch (e.Type) - { - case ChatTypeEnum.Whisper: - if ((dis < 10) && (dis > -10)) - { - //should change so the message is sent through the avatar rather than direct to the ClientView - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case ChatTypeEnum.Say: - if ((dis < 30) && (dis > -30)) - { - //Console.WriteLine("sending chat"); - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case ChatTypeEnum.Shout: - if ((dis < 100) && (dis > -100)) - { - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - - case ChatTypeEnum.Broadcast: - presence.ControllingClient.SendChatMessage(message, type, - fromPos, - fromName, - fromAgentID); - break; - } - }); + } + + if (e.Channel == 0) + { + foreach (Scene m_scene in m_scenes) + { + m_scene.ForEachScenePresence(delegate(ScenePresence presence) + { + int dis = -100000; + + LLVector3 avatarRegionPos = presence.AbsolutePosition + new LLVector3(scene.RegionInfo.RegionLocX * 256, scene.RegionInfo.RegionLocY * 256, 0); + dis = (int)avatarRegionPos.GetDistanceTo(fromRegionPos); + + switch (e.Type) + { + case ChatTypeEnum.Whisper: + if ((dis < 10) && (dis > -10)) + { + //should change so the message is sent through the avatar rather than direct to the ClientView + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + case ChatTypeEnum.Say: + if ((dis < 30) && (dis > -30)) + { + //Console.WriteLine("sending chat"); + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + case ChatTypeEnum.Shout: + if ((dis < 100) && (dis > -100)) + { + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + + case ChatTypeEnum.Broadcast: + presence.ControllingClient.SendChatMessage(message, type, + fromPos, + fromName, + fromAgentID); + break; + } + }); + } } } } -- cgit v1.1