From e278d07220f976dec730890e4853ead58f83502a Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 10 Dec 2007 02:29:42 +0000 Subject: refactored ChatModule a bit. misc cleanup and code convention fixes. --- OpenSim/Region/ClientStack/ClientView.cs | 1 - OpenSim/Region/Environment/Modules/ChatModule.cs | 134 +++++++-------------- .../Environment/Modules/InstantMessageModule.cs | 9 +- .../Environment/Scenes/Scene.PacketHandlers.cs | 4 +- .../Region/Environment/Scenes/SceneObjectPart.cs | 3 +- .../Compiler/Server_API/LSL_BuiltIn_Commands.cs | 7 +- 6 files changed, 55 insertions(+), 103 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 540536e..5d5629b 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -587,7 +587,6 @@ namespace OpenSim.Region.ClientStack /// /// /// - /// TODO /// /// public void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index ef46224..081e7ac 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -110,6 +110,43 @@ namespace OpenSim.Region.Environment.Modules client.OnChatFromViewer += SimChat; } + private void TrySendChatMessage(ScenePresence presence, LLVector3 fromPos, LLVector3 regionPos, + LLUUID fromAgentID, string fromName, ChatTypeEnum type, string message) + { + if (!presence.IsChildAgent) + { + LLVector3 fromRegionPos = fromPos + regionPos; + LLVector3 toRegionPos = presence.AbsolutePosition + regionPos; + int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos)); + + switch (type) + { + case ChatTypeEnum.Whisper: + if (dis < m_whisperdistance) + { + // TODO: should change so the message is sent through the avatar rather than direct to the ClientView + presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID); + } + break; + case ChatTypeEnum.Say: + if (dis < m_saydistance) + { + presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID); + } + break; + case ChatTypeEnum.Shout: + if (dis < m_shoutdistance) + { + presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID); + } + break; + case ChatTypeEnum.Broadcast: + presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID); + break; + } + } + } + public void SimChat(Object sender, ChatFromViewerArgs e) { ScenePresence avatar = null; @@ -123,12 +160,10 @@ namespace OpenSim.Region.Environment.Modules // Filled in since it's easier than rewriting right now. LLVector3 fromPos = e.Position; - LLVector3 fromRegionPos = e.Position + - new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, - 0); + LLVector3 regionPos = new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0); + string fromName = e.From; string message = e.Message; - byte type = (byte) e.Type; LLUUID fromAgentID = LLUUID.Zero; if (e.Sender != null) @@ -139,32 +174,11 @@ namespace OpenSim.Region.Environment.Modules if (avatar != null) { fromPos = avatar.AbsolutePosition; - fromRegionPos = fromPos + - new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0); + regionPos = new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0); fromName = avatar.Firstname + " " + avatar.Lastname; fromAgentID = e.Sender.AgentId; } - string typeName; - switch (e.Type) - { - case ChatTypeEnum.Broadcast: - typeName = "broadcasts"; - break; - case ChatTypeEnum.Say: - typeName = "says"; - break; - case ChatTypeEnum.Shout: - typeName = "shouts"; - break; - case ChatTypeEnum.Whisper: - typeName = "whispers"; - break; - default: - typeName = "unknown"; - break; - } - if (e.Message.Length > 0) { if (m_irc.Connected) @@ -174,69 +188,13 @@ namespace OpenSim.Region.Environment.Modules if (e.Channel == 0) { - foreach (Scene m_scene in m_scenes) + foreach (Scene s in m_scenes) { - m_scene.ForEachScenePresence(delegate(ScenePresence presence) - { - if (!presence.IsChildAgent) - { - int dis = -100000; - - LLVector3 avatarRegionPos = presence.AbsolutePosition + - new LLVector3( - scene.RegionInfo.RegionLocX * 256, - scene.RegionInfo.RegionLocY * 256, - 0); - dis = - Math.Abs((int) Util.GetDistanceTo(avatarRegionPos, fromRegionPos)); - - switch (e.Type) - { - case ChatTypeEnum.Whisper: - if (dis < m_whisperdistance) - { - //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 < m_saydistance) - { - //Console.WriteLine("sending chat"); - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case ChatTypeEnum.Shout: - if (dis < m_shoutdistance) - { - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - - case ChatTypeEnum.Broadcast: - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - break; - default: - break; - } - } - }); + s.ForEachScenePresence(delegate(ScenePresence presence) + { + TrySendChatMessage(presence, fromPos, regionPos, + fromAgentID, fromName, e.Type, message); + }); } } } diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs index 23dd0d9..cf6a94d 100644 --- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs +++ b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs @@ -65,12 +65,12 @@ namespace OpenSim.Region.Environment.Modules LLUUID imSessionID, uint timestamp, string fromAgentName, string message, byte dialog) { - foreach (Scene m_scene in m_scenes) + foreach (Scene scene in m_scenes) { - if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) + if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence) { - // Local Message - ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID]; + // Local message + ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; if (!user.IsChildAgent) { user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, @@ -83,6 +83,7 @@ namespace OpenSim.Region.Environment.Modules } // Still here, try send via Grid + // TODO } public void PostInitialise() diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 745345d..0c9f38c 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -156,10 +156,10 @@ namespace OpenSim.Region.Environment.Scenes } } } + public void ProcessAvatarPickerRequest(IClientAPI client, LLUUID avatarID, LLUUID RequestID, string query) { //EventManager.TriggerAvatarPickerRequest(); - List AvatarResponses = new List(); AvatarResponses = CommsManager.GenerateAgentPickerRequestResponse(RequestID, query); @@ -167,7 +167,7 @@ namespace OpenSim.Region.Environment.Scenes AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket(); AvatarPickerReplyPacket.DataBlock[] searchData = new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); - + agentData.AgentID = avatarID; agentData.QueryID = RequestID; replyPacket.AgentData = agentData; diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 05a59a2..8eef40b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -68,7 +68,7 @@ namespace OpenSim.Region.Environment.Scenes public Int32 CreationDate; public uint ParentID = 0; - // Main grid has default permissions as follows + // Main grid has default permissions as follows // public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER; public uint NextOwnerMask = OBJNEXT_OWNER; @@ -85,7 +85,6 @@ namespace OpenSim.Region.Environment.Scenes [XmlIgnore] public uint TimeStampLastActivity = 0; // Will be used for AutoReturn - /// /// Only used internally to schedule client updates /// 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 1b660b8..353382d 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 @@ -59,7 +59,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler private LLUUID m_itemID; private bool throwErrorOnNotImplemented = true; - public LSL_BuiltIn_Commands(ScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID) { m_ScriptEngine = ScriptEngine; @@ -67,11 +66,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler m_localID = localID; m_itemID = itemID; - //MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]"); } - private string m_state = "default"; public string State() @@ -95,7 +92,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return lease; } - public Scene World { get { return m_ScriptEngine.World; } @@ -1022,7 +1018,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler m_host.SetText(text, av3, alpha); } - public double llWater(LSL_Types.Vector3 offset) { NotImplemented("llWater"); @@ -2300,4 +2295,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler throw new NotImplementedException("Command not implemented: " + Command); } } -} \ No newline at end of file +} -- cgit v1.1