From 921692a15f7b793da55cd4ddc4d85eae4393964e Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Thu, 27 Nov 2008 05:16:47 +0000 Subject: Thank you kindly, Nlin for a patch that: Adds a new method to IClientAPI to allow adding message handlers for GenericMessages (of which "autopilot" is one). Part 2 adds a specific autopilot handler in ScenePresence.cs. 2) Removing unused variables and functions. 3) Simplifying the navigation logic in ScenePresence.cs. The original patch was somewhat complex because it included orientation logic for a future enhancement of orienting the avatar to point towards the direction being walked. Currently this isn't working, though, so I removed the orientation code, which leaves just the smaller and hopefully simpler-to-understand movement code. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 54 ++++++++++++++++------ 1 file changed, 39 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/ClientStack') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 7c66599..e3b91a5 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -93,6 +93,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP new Dictionary(); //Global/static handlers for all clients protected Dictionary m_packetHandlers = new Dictionary(); + protected Dictionary m_genericPacketHandlers = new Dictionary(); //PauPaw:Local Generic Message handlers protected IScene m_scene; @@ -608,6 +609,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP return result; } + public bool AddGenericPacketHandler(string MethodName, GenericMessage handler) + { + bool result = false; + lock (m_genericPacketHandlers) + { + if (!m_genericPacketHandlers.ContainsKey(MethodName)) + { + m_genericPacketHandlers.Add(MethodName, handler); + result = true; + } + } + return result; + } + /// /// Try to process a packet using registered packet handlers /// @@ -3457,21 +3472,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP public bool HandleGenericMessage(IClientAPI sender, Packet pack) { GenericMessagePacket gmpack = (GenericMessagePacket) pack; - handlerGenericMessage = OnGenericMessage; - - List msg = new List(); - - if (handlerGenericMessage != null) + if (m_genericPacketHandlers.Count == 0) return false; + handlerGenericMessage = null; + string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim(); + if(m_genericPacketHandlers.TryGetValue(method, out handlerGenericMessage)) { - string method = Util.FieldToString(gmpack.MethodData.Method); - foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList) + List msg = new List(); + + if (handlerGenericMessage != null) { - msg.Add(Util.FieldToString(block.Parameter)); + foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList) + { + msg.Add(Util.FieldToString(block.Parameter)); + } + try + { + handlerGenericMessage(sender, method, msg); + return true; + } + catch (Exception ex) + { + } } - - handlerGenericMessage(this, method, msg); } - return true; + return false; } public bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack) @@ -3965,12 +3989,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP { #region Scene/Avatar - case PacketType.GenericMessage: - GenericMessagePacket gmpack = (GenericMessagePacket)Pack; + // case PacketType.GenericMessage: + // GenericMessagePacket gmpack = (GenericMessagePacket)Pack; - DecipherGenericMessage(Utils.BytesToString(gmpack.MethodData.Method), gmpack.MethodData.Invoice, gmpack.ParamList); + // DecipherGenericMessage(Utils.BytesToString(gmpack.MethodData.Method), gmpack.MethodData.Invoice, gmpack.ParamList); - break; + // break; case PacketType.AvatarPropertiesRequest: AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack; -- cgit v1.1