From f8ddf7429eaeae3a3aae88d4560473c3516d20fd Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 14 Sep 2007 13:46:05 +0000 Subject: * Wired up chat so that channel goes into OnChatFromViewer. However: * There's no libsl reply packet field for it, I guess other channels than 0 makes no sense sending back to clients. * We do not currently support objects listening, so there's really no way of actually using this feature. So; somebody please wire chat all the way to the scripts. --- OpenSim/Framework/General/Interfaces/IClientAPI.cs | 2 +- OpenSim/Framework/General/NullClientAPI.cs | 2 +- OpenSim/Region/ClientStack/ClientView.API.cs | 9 +- .../ClientStack/ClientView.ProcessPackets.cs | 5 +- OpenSim/Region/Environment/Interfaces/ISimChat.cs | 2 +- OpenSim/Region/Environment/Modules/ChatModule.cs | 106 ++++++++++++--------- .../Environment/Scenes/Scene.PacketHandlers.cs | 4 +- .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 2 +- .../Compiler/Server_API/LSL_BuiltIn_Commands.cs | 6 +- .../ScriptEngine/DotNetEngine/EventQueueManager.cs | 2 +- .../ScriptEngine/DotNetEngine/ScriptManager.cs | 2 +- 11 files changed, 76 insertions(+), 66 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index 8155373..747ad5c 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs @@ -34,7 +34,7 @@ using OpenSim.Framework.Data; namespace OpenSim.Framework.Interfaces { - public delegate void ChatFromViewer(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID); + public delegate void ChatFromViewer(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID); public delegate void ImprovedInstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, uint timestamp, string fromAgentName, string message, byte dialog); // Cut down from full list public delegate void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos); public delegate void ModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, IClientAPI remoteClient); diff --git a/OpenSim/Framework/General/NullClientAPI.cs b/OpenSim/Framework/General/NullClientAPI.cs index 56faae2..cf7e448 100644 --- a/OpenSim/Framework/General/NullClientAPI.cs +++ b/OpenSim/Framework/General/NullClientAPI.cs @@ -119,7 +119,7 @@ namespace OpenSim.Framework public virtual void SendKillObject(ulong regionHandle, uint localID){} public virtual void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId){} public virtual void SendRegionHandshake(RegionInfo regionInfo){} - public virtual void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID){} + public virtual void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { } public virtual void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID){} public virtual void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, LLUUID imSessionID, string fromName, byte dialog, uint timeStamp){} public virtual void SendLayerData(float[] map){} diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index 031e50a..c97ba37 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -243,14 +243,7 @@ namespace OpenSim.Region.ClientStack SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID); } - /// - /// - /// - /// - /// - /// - /// - /// + public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { Encoding enc = Encoding.ASCII; diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index fab5433..fe3e82c 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -107,9 +107,12 @@ namespace OpenSim.Region.ClientStack byte type = inchatpack.ChatData.Type; LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos; LLUUID fromAgentID = AgentID; + + int channel = inchatpack.ChatData.Channel; + if (OnChatFromViewer != null) { - this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID); + this.OnChatFromViewer(message, type, channel, fromPos, fromName, fromAgentID); } break; case PacketType.ImprovedInstantMessage: diff --git a/OpenSim/Region/Environment/Interfaces/ISimChat.cs b/OpenSim/Region/Environment/Interfaces/ISimChat.cs index 0b83b34..73ef476 100644 --- a/OpenSim/Region/Environment/Interfaces/ISimChat.cs +++ b/OpenSim/Region/Environment/Interfaces/ISimChat.cs @@ -7,6 +7,6 @@ namespace OpenSim.Region.Environment.Interfaces { public interface ISimChat { - void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID); + void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID); } } diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index b38665d..a46343b 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -136,7 +136,7 @@ namespace OpenSim.Region.Environment.Modules } } - public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) + public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { ScenePresence avatar = null; avatar = m_scene.RequestAvatar(fromAgentID); @@ -149,54 +149,68 @@ namespace OpenSim.Region.Environment.Modules if (connected) { - m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + Util.FieldToString(message)); + m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + + Util.FieldToString(message)); m_ircWriter.Flush(); } - m_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 = m_scene.RequestAvatar(presence.ControllingClient.AgentId); - if (avatar != null) - { - dis = (int)avatar.AbsolutePosition.GetDistanceTo(fromPos); - } - - switch (type) - { - case 0: // 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 1: // Say - if ((dis < 30) && (dis > -30)) - { - //Console.WriteLine("sending chat"); - presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, - fromAgentID); - } - break; - case 2: // Shout - if ((dis < 100) && (dis > -100)) - { - presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, - fromAgentID); - } - break; - - case 0xff: // Broadcast - presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, - fromAgentID); - break; - } - }); + if (channel == 0) + { + m_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 = m_scene.RequestAvatar(presence.ControllingClient.AgentId); + if (avatar != null) + { + dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); + } + + switch (type) + { + case 0: // 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 1: // Say + if ((dis < 30) && (dis > -30)) + { + //Console.WriteLine("sending chat"); + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + case 2: // Shout + if ((dis < 100) && (dis > -100)) + { + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + + case 0xff: // Broadcast + presence.ControllingClient.SendChatMessage(message, type, + fromPos, + fromName, + fromAgentID); + break; + } + }); + } } - } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index ab65e36..881b4a1 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -102,11 +102,11 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) + public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { if (m_simChatModule != null) { - m_simChatModule.SimChat(message, type, fromPos, fromName, fromAgentID); + m_simChatModule.SimChat(message, type, channel, fromPos, fromName, fromAgentID); } } diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index 7e6101c..b009192 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -211,7 +211,7 @@ namespace SimpleApp { if (OnChatFromViewer != null) { - this.OnChatFromViewer(enc.GetBytes("Kind of quiet around here, isn't it! \0"), 2, new LLVector3(128, 128, 26), this.FirstName + " " + this.LastName, this.AgentId); + this.OnChatFromViewer(enc.GetBytes("Kind of quiet around here, isn't it! \0"), 2, 0, new LLVector3(128, 128, 26), this.FirstName + " " + this.LastName, this.AgentId); } count = -1; diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index 028544e..fe20e99 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs @@ -168,7 +168,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler { //type for whisper is 0 World.SimChat(Helpers.StringToField(text), - 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + 0, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); } public void llSay(int channelID, string text) @@ -176,14 +176,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler //type for say is 1 World.SimChat(Helpers.StringToField(text), - 1, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + 1, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); } public void llShout(int channelID, string text) { //type for shout is 2 World.SimChat(Helpers.StringToField(text), - 2, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + 2, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); } public int llListen(int channelID, string name, string ID, string msg) { return 0; } diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs index 955e978..aa36ea2 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs @@ -197,7 +197,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine IScriptHost m_host = m_ScriptEngine.World.GetSceneObjectPart(QIS.localID); //if (m_host != null) //{ - m_ScriptEngine.World.SimChat(Helpers.StringToField(text), 1, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + m_ScriptEngine.World.SimChat(Helpers.StringToField(text), 1, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); } catch { //} //else diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index f731cb4..c521d47 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -310,7 +310,7 @@ 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), 1, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + World.SimChat(Helpers.StringToField(text), 1, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); } catch (Exception e2) { -- cgit v1.1