diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 0823b0d3bc..7fb8091e6d 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -85,6 +85,7 @@ namespace OpenSim.Framework protected IScene m_scene; protected IClientAPI m_sender; + protected object m_senderObject; protected ChatTypeEnum m_type; protected LLUUID m_fromID; @@ -140,6 +141,9 @@ namespace OpenSim.Framework #region IEventArgs Members + /// TODO: Sender and SenderObject should just be Sender and of + /// type IChatSender + /// /// The client responsible for sending the message, or null. /// @@ -149,6 +153,15 @@ namespace OpenSim.Framework set { m_sender = value; } } + /// + /// The object responsible for sending the message, or null. + /// + public object SenderObject + { + get { return m_senderObject; } + set { m_senderObject = value; } + } + public LLUUID SenderUUID { get { return m_fromID; } diff --git a/OpenSim/Grid/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Grid/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index 3411465aa9..422af46d5f 100644 --- a/OpenSim/Grid/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Grid/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs @@ -57,7 +57,6 @@ namespace OpenSim.Grid.ScriptEngine.Common LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r); LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 start, LSL_Types.Vector3 end); void llWhisper(int channelID, string text); - //void llSay(int channelID, string text); void llSay(int channelID, string text); void llShout(int channelID, string text); int llListen(int channelID, string name, string ID, string msg); diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs index 60f4d42741..1db14469dc 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs @@ -243,6 +243,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL m_LSL_Functions.llShout(channelID, text); } + public void llOwnerSay(string msg) + { + m_LSL_Functions.llOwnerSay(msg); + } + public int llListen(int channelID, string name, string ID, string msg) { return m_LSL_Functions.llListen(channelID, name, ID, msg); @@ -1617,11 +1622,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL return m_LSL_Functions.llGetInventoryCreator(item); } - public void llOwnerSay(string msg) - { - m_LSL_Functions.llOwnerSay(msg); - } - public void llRequestSimulatorData(string simulator, int data) { m_LSL_Functions.llRequestSimulatorData(simulator, data); diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index 64d34938eb..b06a457796 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs @@ -272,19 +272,30 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler public void llWhisper(int channelID, string text) { World.SimChat(Helpers.StringToField(text), - ChatTypeEnum.Whisper, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + ChatTypeEnum.Whisper, channelID, m_host.AbsolutePosition, + m_host.Name, m_host.UUID, false); } public void llSay(int channelID, string text) { World.SimChat(Helpers.StringToField(text), - ChatTypeEnum.Say, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + ChatTypeEnum.Say, channelID, m_host.AbsolutePosition, + m_host.Name, m_host.UUID, false); } public void llShout(int channelID, string text) { World.SimChat(Helpers.StringToField(text), - ChatTypeEnum.Shout, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + ChatTypeEnum.Shout, channelID, m_host.AbsolutePosition, + m_host.Name, m_host.UUID, false); + } + + public void llOwnerSay(string msg) + { + m_log.DebugFormat("llOwnerSay(\"{0}\")", msg); + World.SimChatBroadcast(Helpers.StringToField(text), + ChatTypeEnum.Owner, 0, m_host.AbsolutePosition, + m_host.Name, m_host.UUID, false); } public int llListen(int channelID, string name, string ID, string msg) @@ -2032,11 +2043,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler return ""; } - public void llOwnerSay(string msg) - { - NotImplemented("llOwnerSay"); - } - public void llRequestSimulatorData(string simulator, int data) { NotImplemented("llRequestSimulatorData"); diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs index e12588cc24..c3fc26e400 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs @@ -107,7 +107,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat #region ISimChat Members public void SimBroadcast(Object sender, ChatFromViewerArgs c) { - // We only want to relay stuff on channel 0 + // We only want to relay stuff on channel 0 and on the debug channel if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return; if (c.Channel == DEBUG_CHANNEL) @@ -118,13 +118,25 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat LLVector3 pos = new LLVector3(128, 128, 30); ((Scene)c.Scene).ForEachScenePresence(delegate(ScenePresence presence) { - if (!presence.IsChildAgent) return; + if (presence.IsChildAgent) return; + + IClientAPI client = presence.ControllingClient; + + if ((c.Type == ChatTypeEnum.Owner) && + (null != c.SenderObject) && + (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) + return; - presence.ControllingClient.SendChatMessage(c.Message, - 1, //255, - pos, c.From, LLUUID.Zero, - c.Channel == DEBUG_CHANNEL? (byte)ChatSourceType.Object : (byte)ChatSourceType.Agent, - (byte)ChatAudibleLevel.Fully); + if (null == c.SenderObject) + client.SendChatMessage(c.Message, (byte)c.Type, + pos, c.From, LLUUID.Zero, + (byte)ChatSourceType.Agent, + (byte)ChatAudibleLevel.Fully); + else + client.SendChatMessage(c.Message, (byte)c.Type, + pos, c.From, LLUUID.Zero, + (byte)ChatSourceType.Object, + (byte)ChatAudibleLevel.Fully); }); } @@ -147,7 +159,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat string fromName = e.From; string message = e.Message; - LLUUID fromAgentID = e.SenderUUID; + LLUUID fromID = e.SenderUUID; if (e.Sender != null) { @@ -160,7 +172,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat regionPos = new LLVector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); fromName = avatar.Firstname + " " + avatar.Lastname; - fromAgentID = e.Sender.AgentId; + fromID = e.Sender.AgentId; } if (e.Channel == DEBUG_CHANNEL) @@ -175,13 +187,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat if (e.Channel == DEBUG_CHANNEL) { TrySendChatMessage(presence, fromPos, regionPos, - fromAgentID, fromName, e.Type, + fromID, fromName, e.Type, message, ChatSourceType.Object); } else { TrySendChatMessage(presence, fromPos, regionPos, - fromAgentID, fromName, e.Type, + fromID, fromName, e.Type, message, ChatSourceType.Agent); } }); diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs index 18106bebcc..452ea7b55a 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs @@ -88,6 +88,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat { m_irc = new IRCChatModule(config); } + if (m_irc_connector == null) { m_irc_connector = new Thread(IRCConnectRun); @@ -183,6 +184,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat m_irc_connector.Name = "IRCConnectorThread"; m_irc_connector.IsBackground = true; } + if (!m_irc_connector.IsAlive) { m_irc_connector.Start(); @@ -196,20 +198,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat if (e.Message.StartsWith("/me ") && (null != avatar)) e.Message = String.Format("{0} {1}", fromName, e.Message.Substring(4)); - if (e.Channel == 0 || e.Channel == DEBUG_CHANNEL) - { - if (e.Channel == DEBUG_CHANNEL) - e.Type = ChatTypeEnum.DebugChannel; - - // IRC stuff - if (e.Message.Length > 0 && e.Channel == 0) - { - if (m_irc.Connected && (avatar != null)) // this is to keep objects from talking to IRC - { + + // this is to keep objects from talking to IRC + if (m_irc.Connected && (avatar != null)) m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, e.Message); - } - } - } } #endregion @@ -528,14 +520,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat // Get some direct matches $1 $4 is a if ((matches.Count == 0) || (matches.Count != 1) || (matches[0].Groups.Count != 5)) - { - result = new Dictionary(); - result.Add("nick", matches[0].Groups[1].Value); - result.Add("user", matches[0].Groups[2].Value); - result.Add("channel", matches[0].Groups[3].Value); - result.Add("msg", matches[0].Groups[4].Value); - } - else { m_log.Info("[IRC]: Number of matches: " + matches.Count); if (matches.Count > 0) @@ -641,7 +625,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat public void BroadcastSim(string sender, string format, params string[] args) { - LLVector3 pos = new LLVector3(128, 128, 20); try { ChatFromViewerArgs c = new ChatFromViewerArgs(); @@ -781,8 +764,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat public void eventIrcMode(string[] commArgs) { - string IrcChannel = commArgs[2]; - string IrcUser = commArgs[0].Split('!')[0]; string UserMode = ""; for (int i = 3; i < commArgs.Length; i++) { diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 788e80a824..8419399622 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -34,6 +34,39 @@ namespace OpenSim.Region.Environment.Scenes { public partial class Scene { + protected void SimChat(byte[] message, ChatTypeEnum type, int channel, LLVector3 fromPos, string fromName, + LLUUID fromID, bool fromAgent, bool broadcast) + { + ChatFromViewerArgs args = new ChatFromViewerArgs(); + + args.Message = Helpers.FieldToUTF8String(message); + args.Channel = channel; + args.Type = type; + args.Position = fromPos; + args.SenderUUID = fromID; + args.Scene = this; + + if (fromAgent) + { + ScenePresence user = GetScenePresence(fromID); + if (user != null) + args.Sender = user.ControllingClient; + } + else + { + SceneObjectPart obj = GetSceneObjectPart(fromID); + args.SenderObject = obj; + } + + args.From = fromName; + //args. + + if (broadcast) + EventManager.TriggerOnChatBroadcast(this, args); + else + EventManager.TriggerOnChatFromWorld(this, args); + + } /// /// /// @@ -43,27 +76,23 @@ namespace OpenSim.Region.Environment.Scenes /// /// public void SimChat(byte[] message, ChatTypeEnum type, int channel, LLVector3 fromPos, string fromName, - LLUUID fromAgentID) + LLUUID fromID, bool fromAgent) { - ChatFromViewerArgs args = new ChatFromViewerArgs(); + SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, false); + } - args.Message = Helpers.FieldToUTF8String(message); - args.Channel = channel; - args.Type = type; - args.Position = fromPos; - args.SenderUUID = fromAgentID; - args.Scene = this; - - ScenePresence user = GetScenePresence(fromAgentID); - if (user != null) - args.Sender = user.ControllingClient; - else - args.Sender = null; - - args.From = fromName; - //args. - - EventManager.TriggerOnChatFromWorld(this, args); + /// + /// + /// + /// + /// + /// + /// + /// + public void SimChatBroadcast(byte[] message, ChatTypeEnum type, int channel, LLVector3 fromPos, string fromName, + LLUUID fromID, bool fromAgent) + { + SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); } /// diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index f4ec1a3ce9..4d380f9858 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -113,7 +113,6 @@ namespace OpenSim.Region.Environment.Scenes public IXfer XferManager; protected IHttpRequests m_httpRequestModule; - protected ISimChat m_simChatModule; protected IXMLRPC m_xmlrpcModule; protected IWorldComm m_worldCommModule; protected IAvatarFactory m_AvatarFactory; @@ -637,7 +636,6 @@ namespace OpenSim.Region.Environment.Scenes /// public void SetModuleInterfaces() { - m_simChatModule = RequestModuleInterface(); m_httpRequestModule = RequestModuleInterface(); m_xmlrpcModule = RequestModuleInterface(); m_worldCommModule = RequestModuleInterface(); diff --git a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs index 2c33b57aab..07db853e0c 100644 --- a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs @@ -285,6 +285,11 @@ namespace OpenSim.Region.ScriptEngine.Common m_LSL_Functions.llShout(channelID, text); } + public void llOwnerSay(string msg) + { + m_LSL_Functions.llOwnerSay(msg); + } + public void llRegionSay(int channelID, string text) { m_LSL_Functions.llRegionSay(channelID, text); @@ -1673,11 +1678,6 @@ namespace OpenSim.Region.ScriptEngine.Common return m_LSL_Functions.llGetInventoryCreator(item); } - public void llOwnerSay(string msg) - { - m_LSL_Functions.llOwnerSay(msg); - } - public void llRequestSimulatorData(string simulator, int data) { m_LSL_Functions.llRequestSimulatorData(simulator, data); diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 9446844b85..efdf2499e9 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -50,7 +50,7 @@ namespace OpenSim.Region.ScriptEngine.Common /// public class LSL_BuiltIn_Commands : MarshalByRefObject, LSL_BuiltIn_Commands_Interface { - // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); internal ScriptEngineBase.ScriptEngine m_ScriptEngine; internal SceneObjectPart m_host; @@ -409,7 +409,7 @@ namespace OpenSim.Region.ScriptEngine.Common { m_host.AddScriptLPS(1); World.SimChat(Helpers.StringToField(text), - ChatTypeEnum.Whisper, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + ChatTypeEnum.Whisper, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); @@ -419,7 +419,7 @@ namespace OpenSim.Region.ScriptEngine.Common { m_host.AddScriptLPS(1); World.SimChat(Helpers.StringToField(text), - ChatTypeEnum.Say, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + ChatTypeEnum.Say, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); wComm.DeliverMessage(ChatTypeEnum.Say, channelID, m_host.Name, m_host.UUID, text); @@ -429,7 +429,7 @@ namespace OpenSim.Region.ScriptEngine.Common { m_host.AddScriptLPS(1); World.SimChat(Helpers.StringToField(text), - ChatTypeEnum.Shout, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + ChatTypeEnum.Shout, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); wComm.DeliverMessage(ChatTypeEnum.Shout, channelID, m_host.Name, m_host.UUID, text); @@ -5478,15 +5478,13 @@ namespace OpenSim.Region.ScriptEngine.Common public void llOwnerSay(string msg) { - //m_host.AddScriptLPS(1); // since we reuse llInstantMessage - //temp fix so that lsl wiki examples aren't annoying to use to test other functions - //should be similar to : llInstantMessage(llGetOwner(),msg) - // llGetOwner ==> m_host.ObjectOwner.ToString() - llInstantMessage(m_host.ObjectOwner.ToString(),msg); + m_host.AddScriptLPS(1); + World.SimChatBroadcast(Helpers.StringToField(msg), + ChatTypeEnum.Owner, 0, m_host.AbsolutePosition, + m_host.Name, m_host.UUID, false); - //World.SimChat(Helpers.StringToField(msg), ChatTypeEnum.Owner, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); - //IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); - //wComm.DeliverMessage(ChatTypeEnum.Owner, 0, m_host.Name, m_host.UUID, msg); + IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); + wComm.DeliverMessage(ChatTypeEnum.Owner, 0, m_host.Name, m_host.UUID, msg); } public void llRequestSimulatorData(string simulator, int data) diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs index 6f266c3d78..64d6a75885 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs @@ -333,7 +333,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase m_ScriptEngine.World.SimChat(Helpers.StringToField(text), ChatTypeEnum.DebugChannel, 2147483647, m_host.AbsolutePosition, - m_host.Name, m_host.UUID); + m_host.Name, m_host.UUID, false); } catch (Exception) { diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index bfa9951d41..087f6885e4 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -140,8 +140,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine string text = "Error compiling script:\r\n" + e.Message.ToString(); if (text.Length > 1500) text = text.Substring(0, 1500); - World.SimChat(Helpers.StringToField(text), ChatTypeEnum.DebugChannel, 2147483647, m_host.AbsolutePosition, - m_host.Name, m_host.UUID); + World.SimChat(Helpers.StringToField(text), ChatTypeEnum.DebugChannel, 2147483647, + m_host.AbsolutePosition, m_host.Name, m_host.UUID, false); } catch (Exception e2) // LEGIT: User Scripting {