From a95f13a646e6c0ff07c765437011a29c3372f1b9 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 7 May 2008 20:31:48 +0000 Subject: * Removes references to libsecondlife.Packets from IClientAPI. BAD PROGRAMMERS. NAUGHTY. * Thanks to Andrew (DeepThink) for working on this one. --- OpenSim/Framework/ClientManager.cs | 19 +++-- OpenSim/Framework/IClientAPI.cs | 84 ++++++++++++++++++++-- .../Region/ClientStack/LindenUDP/LLClientView.cs | 82 +++++++++++++++++++-- .../Region/Environment/Scenes/AvatarAppearance.cs | 8 +-- OpenSim/Region/Environment/Scenes/InnerScene.cs | 25 ++++++- .../Environment/Scenes/Scene.PacketHandlers.cs | 16 ++++- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 34 ++++----- .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 9 +-- 8 files changed, 232 insertions(+), 45 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs index 35c9319..4f21ab6 100644 --- a/OpenSim/Framework/ClientManager.cs +++ b/OpenSim/Framework/ClientManager.cs @@ -171,11 +171,22 @@ namespace OpenSim.Framework return circuits; } - public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock) + public void ViewerEffectHandler(IClientAPI sender, List args) { - ViewerEffectPacket packet = (ViewerEffectPacket) PacketPool.Instance.GetPacket(PacketType.ViewerEffect); + ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect); // TODO: don't create new blocks if recycling an old packet - packet.Effect = effectBlock; + List effectBlock = new List(); + for (int i = 0; i < args.Count; i++) + { + ViewerEffectPacket.EffectBlock effect = new ViewerEffectPacket.EffectBlock(); + effect.AgentID = args[i].AgentID; + effect.Color = args[i].Color; + effect.Duration = args[i].Duration; + effect.ID = args[i].ID; + effect.Type = args[i].Type; + effectBlock.Add(effect); + } + packet.Effect = effectBlock.ToArray(); // Wasteful, I know IClientAPI[] LocalClients = new IClientAPI[0]; @@ -205,4 +216,4 @@ namespace OpenSim.Framework } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 8344196..2ade592 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -41,7 +41,8 @@ namespace OpenSim.Framework IClientAPI Sender { get; set; } } - public delegate void ViewerEffectEventHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock); + + public delegate void ViewerEffectEventHandler(IClientAPI sender, List args); public delegate void ChatFromViewer(Object sender, ChatFromViewerArgs e); @@ -235,6 +236,15 @@ namespace OpenSim.Framework #endregion } + public class ViewerEffectEventHandlerArg : EventArgs + { + public LLUUID AgentID; + public byte[] Color; + public float Duration; + public LLUUID ID; + public byte Type; + } + public class LandUpdateArgs : EventArgs { public LLUUID AuthBuyerID; @@ -301,6 +311,66 @@ namespace OpenSim.Framework public float waterHeight; public string simName; } + + public class UpdateShapeArgs : EventArgs + { + public uint ObjectLocalID; + public ushort PathBegin; + public byte PathCurve; + public ushort PathEnd; + public sbyte PathRadiusOffset; + public byte PathRevolutions; + public byte PathScaleX; + public byte PathScaleY; + public byte PathShearX; + public byte PathShearY; + public sbyte PathSkew; + public sbyte PathTaperX; + public sbyte PathTaperY; + public sbyte PathTwist; + public sbyte PathTwistBegin; + public ushort ProfileBegin; + public byte ProfileCurve; + public ushort ProfileEnd; + public ushort ProfileHollow; + } + + public class RequestAssetArgs : EventArgs + { + public int ChannelType; + public float Priority; + public int SourceType; + public LLUUID TransferID; + } + public class AgentUpdateArgs : EventArgs + { + public LLUUID AgentID; + public LLQuaternion BodyRotation; + public LLVector3 CameraAtAxis; + public LLVector3 CameraCenter; + public LLVector3 CameraLeftAxis; + public LLVector3 CameraUpAxis; + public uint ControlFlags; + public float Far; + public byte Flags; + public LLQuaternion HeadRotation; + public LLUUID SessionID; + public byte State; + } + + public class AvatarPickerReplyAgentDataArgs : EventArgs + { + public LLUUID AgentID; + public LLUUID QueryID; + } + + public class AvatarPickerReplyDataArgs : EventArgs + { + public LLUUID AvatarID; + public byte[] FirstName; + public byte[] LastName; + } + public delegate void TextureRequest(Object sender, TextureRequestArgs e); public delegate void AvatarNowWearing(Object sender, AvatarWearingArgs e); @@ -325,7 +395,7 @@ namespace OpenSim.Framework float height, float seconds, byte size, byte action, float north, float west, float south, float east, IClientAPI remoteClient); - public delegate void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam); + public delegate void SetAppearance(byte[] texture, List visualParamList); public delegate void StartAnim(IClientAPI remoteClient, LLUUID animID); @@ -362,7 +432,7 @@ namespace OpenSim.Framework public delegate void GenericCall7(IClientAPI remoteClient, uint localID, string message); - public delegate void UpdateShape(LLUUID agentID, uint localID, ObjectShapePacket.ObjectDataBlock shapeBlock); + public delegate void UpdateShape(LLUUID agentID, uint localID, UpdateShapeArgs shapeBlock); public delegate void ObjectExtraParams(LLUUID agentID, uint localID, ushort type, bool inUse, byte[] data); @@ -396,7 +466,7 @@ namespace OpenSim.Framework public delegate void NewAvatar(IClientAPI remoteClient, LLUUID agentID, bool status); - public delegate void UpdateAgent(IClientAPI remoteClient, AgentUpdatePacket agentData); + public delegate void UpdateAgent(IClientAPI remoteClient, AgentUpdateArgs agentData); public delegate void AgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset); @@ -427,7 +497,7 @@ namespace OpenSim.Framework public delegate void ParcelObjectOwnerRequest(int local_id, IClientAPI remote_client); - public delegate void EstateOwnerMessageRequest(EstateOwnerMessagePacket packet, IClientAPI remote_client); + public delegate void EstateOwnerMessageRequest(LLUUID AgentID, LLUUID SessionID, LLUUID TransactionID, LLUUID Invoice, byte[] Method, byte[][] Parameters, IClientAPI remote_client); public delegate void RegionInfoRequest(IClientAPI remote_client); @@ -487,7 +557,7 @@ namespace OpenSim.Framework public delegate void RemoveInventoryFolder( IClientAPI remoteClient, LLUUID folderID); - public delegate void RequestAsset(IClientAPI remoteClient, TransferRequestPacket transferRequest); + public delegate void RequestAsset(IClientAPI remoteClient, RequestAssetArgs transferRequest); public delegate void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID); @@ -822,7 +892,7 @@ namespace OpenSim.Framework int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay, int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent); - void SendAvatarPickerReply(AvatarPickerReplyPacket Pack); + void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List Data); void SendAgentDataUpdate(LLUUID agentid, LLUUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 7587f44..0ea7e0a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1651,8 +1651,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP } - public void SendAvatarPickerReply(AvatarPickerReplyPacket replyPacket) + public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List Data) { + //construct the AvatarPickerReply packet. + AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket(); + replyPacket.AgentData.AgentID = AgentData.AgentID; + replyPacket.AgentData.QueryID = AgentData.QueryID; + int i = 0; + List data_block = new List(); + foreach (AvatarPickerReplyDataArgs arg in Data) + { + AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock(); + db.AvatarID = arg.AvatarID; + db.FirstName = arg.FirstName; + db.LastName = arg.LastName; + data_block.Add(db); + } + replyPacket.Data = data_block.ToArray(); OutPacket(replyPacket, ThrottleOutPacketType.Task); } @@ -2904,11 +2919,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerViewerEffect = OnViewerEffect; if (handlerViewerEffect != null) { - handlerViewerEffect(sender, viewer.Effect); + int length = viewer.Effect.Length; + List args = new List(length); + for (int i = 0; i < length; i++) + { + //copy the effects block arguments into the event handler arg. + ViewerEffectEventHandlerArg argument = new ViewerEffectEventHandlerArg(); + argument.AgentID = viewer.Effect[i].AgentID; + argument.Color = viewer.Effect[i].Color; + argument.Duration = viewer.Effect[i].Duration; + argument.ID = viewer.Effect[i].ID; + argument.Type = viewer.Effect[i].Type; + args.Add(argument); + } + + handlerViewerEffect(sender, args); } return true; } + public void SendScriptQuestion(LLUUID taskID, string taskName, string ownerName, LLUUID itemID, int question) { @@ -3778,7 +3808,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP // for the client session anyway, in order to protect ourselves against bad code in plugins try { - handlerSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam); + List visualparams = new List(); + foreach (AgentSetAppearancePacket.VisualParamBlock x in appear.VisualParam) + { + visualparams.Add(x.ParamValue); + } + + handlerSetAppearance(appear.ObjectData.TextureEntry, visualparams); } catch (Exception e) { @@ -3885,9 +3921,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP { AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack; + AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData; + AgentUpdateArgs arg = new AgentUpdateArgs(); + arg.AgentID = x.AgentID; + arg.BodyRotation = x.BodyRotation; + arg.CameraAtAxis = x.CameraAtAxis; + arg.CameraCenter = x.CameraCenter; + arg.CameraLeftAxis = x.CameraLeftAxis; + arg.CameraUpAxis = x.CameraUpAxis; + arg.ControlFlags = x.ControlFlags; + arg.Far = x.Far; + arg.Flags = x.Flags; + arg.HeadRotation = x.HeadRotation; + arg.SessionID = x.SessionID; + arg.State = x.State; + handlerAgentUpdate = OnAgentUpdate; if (handlerAgentUpdate != null) - OnAgentUpdate(this, agenUpdate); + OnAgentUpdate(this, arg); handlerAgentUpdate = null; //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa); @@ -4085,8 +4136,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerUpdatePrimShape = OnUpdatePrimShape; if (handlerUpdatePrimShape != null) { + UpdateShapeArgs shapeData = new UpdateShapeArgs(); + shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID; + shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin; + shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve; + shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd; + shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset; + shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions; + shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX; + shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY; + shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX; + shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY; + shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew; + shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX; + shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY; + shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist; + shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin; + shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin; + shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve; + shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd; + shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow; + handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID, - shapePacket.ObjectData[i]); + shapeData); } } break; diff --git a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs index 8f29507..c482d94 100644 --- a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs +++ b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.Runtime.Serialization; using System.Security.Permissions; using libsecondlife; @@ -102,15 +103,12 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) + public void SetAppearance(byte[] texture, List visualParam) { LLObject.TextureEntry textureEnt = new LLObject.TextureEntry(texture, 0, texture.Length); m_textureEntry = textureEnt; - for (int i = 0; i < visualParam.Length; i++) - { - m_visualParams[i] = visualParam[i].ParamValue; - } + m_visualParams = visualParam.ToArray(); // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters. // (float)m_visualParams[25] = Height diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index f29e1f3..80e71c8 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -1275,14 +1275,35 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void UpdatePrimShape(LLUUID agentID, uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) + public void UpdatePrimShape(LLUUID agentID, uint primLocalID, UpdateShapeArgs shapeBlock) { SceneObjectGroup group = GetGroupByPrim(primLocalID); if (group != null) { if (m_parentScene.Permissions.CanEditObjectPosition(agentID, group.GetPartsFullID(primLocalID))) { - group.UpdateShape(shapeBlock, primLocalID); + ObjectShapePacket.ObjectDataBlock shapeData = new ObjectShapePacket.ObjectDataBlock(); + shapeData.ObjectLocalID = shapeBlock.ObjectLocalID; + shapeData.PathBegin = shapeBlock.PathBegin; + shapeData.PathCurve = shapeBlock.PathCurve; + shapeData.PathEnd = shapeBlock.PathEnd; + shapeData.PathRadiusOffset = shapeBlock.PathRadiusOffset; + shapeData.PathRevolutions = shapeBlock.PathRevolutions; + shapeData.PathScaleX = shapeBlock.PathScaleX; + shapeData.PathScaleY = shapeBlock.PathScaleY; + shapeData.PathShearX = shapeBlock.PathShearX; + shapeData.PathShearY = shapeBlock.PathShearY; + shapeData.PathSkew = shapeBlock.PathSkew; + shapeData.PathTaperX = shapeBlock.PathTaperX; + shapeData.PathTaperY = shapeBlock.PathTaperY; + shapeData.PathTwist = shapeBlock.PathTwist; + shapeData.PathTwistBegin = shapeBlock.PathTwistBegin; + shapeData.ProfileBegin = shapeBlock.ProfileBegin; + shapeData.ProfileCurve = shapeBlock.ProfileCurve; + shapeData.ProfileEnd = shapeBlock.ProfileEnd; + shapeData.ProfileHollow = shapeBlock.ProfileHollow; + + group.UpdateShape(shapeData, primLocalID); } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 0a4906a..623368a 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -245,7 +245,21 @@ namespace OpenSim.Region.Environment.Scenes searchData = new AvatarPickerReplyPacket.DataBlock[0]; } replyPacket.Data = searchData; - client.SendAvatarPickerReply(replyPacket); + + AvatarPickerReplyAgentDataArgs agent_data = new AvatarPickerReplyAgentDataArgs(); + agent_data.AgentID = replyPacket.AgentData.AgentID; + agent_data.QueryID = replyPacket.AgentData.QueryID; + + List data_args = new List(); + for (i = 0; i < replyPacket.Data.Length; i++) + { + AvatarPickerReplyDataArgs data_arg = new AvatarPickerReplyDataArgs(); + data_arg.AvatarID = replyPacket.Data[i].AvatarID; + data_arg.FirstName = replyPacket.Data[i].FirstName; + data_arg.LastName = replyPacket.Data[i].LastName; + data_args.Add(data_arg); + } + client.SendAvatarPickerReply(agent_data, data_args); } } } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 9343ad3..9732d05 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -754,7 +754,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// This is the event handler for client movement. If a client is moving, this event is triggering. /// - public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdatePacket agentData) + public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) { //if (m_isChildAgent) //{ @@ -767,31 +767,31 @@ namespace OpenSim.Region.Environment.Scenes m_perfMonMS = System.Environment.TickCount; - uint flags = agentData.AgentData.ControlFlags; - LLQuaternion bodyRotation = agentData.AgentData.BodyRotation; + uint flags = agentData.ControlFlags; + LLQuaternion bodyRotation = agentData.BodyRotation; // Camera location in world. We'll need to raytrace // from this location from time to time. - m_CameraCenter.x = agentData.AgentData.CameraCenter.X; - m_CameraCenter.y = agentData.AgentData.CameraCenter.Y; - m_CameraCenter.z = agentData.AgentData.CameraCenter.Z; + m_CameraCenter.x = agentData.CameraCenter.X; + m_CameraCenter.y = agentData.CameraCenter.Y; + m_CameraCenter.z = agentData.CameraCenter.Z; // Use these three vectors to figure out what the agent is looking at // Convert it to a Matrix and/or Quaternion - m_CameraAtAxis.x = agentData.AgentData.CameraAtAxis.X; - m_CameraAtAxis.y = agentData.AgentData.CameraAtAxis.Y; - m_CameraAtAxis.z = agentData.AgentData.CameraAtAxis.Z; + m_CameraAtAxis.x = agentData.CameraAtAxis.X; + m_CameraAtAxis.y = agentData.CameraAtAxis.Y; + m_CameraAtAxis.z = agentData.CameraAtAxis.Z; - m_CameraLeftAxis.x = agentData.AgentData.CameraLeftAxis.X; - m_CameraLeftAxis.y = agentData.AgentData.CameraLeftAxis.Y; - m_CameraLeftAxis.z = agentData.AgentData.CameraLeftAxis.Z; + m_CameraLeftAxis.x = agentData.CameraLeftAxis.X; + m_CameraLeftAxis.y = agentData.CameraLeftAxis.Y; + m_CameraLeftAxis.z = agentData.CameraLeftAxis.Z; - m_CameraUpAxis.x = agentData.AgentData.CameraUpAxis.X; - m_CameraUpAxis.y = agentData.AgentData.CameraUpAxis.Y; - m_CameraUpAxis.z = agentData.AgentData.CameraUpAxis.Z; + m_CameraUpAxis.x = agentData.CameraUpAxis.X; + m_CameraUpAxis.y = agentData.CameraUpAxis.Y; + m_CameraUpAxis.z = agentData.CameraUpAxis.Z; // The Agent's Draw distance setting - m_DrawDistance = agentData.AgentData.Far; + m_DrawDistance = agentData.Far; if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) { @@ -1569,7 +1569,7 @@ namespace OpenSim.Region.Environment.Scenes m_appearance.SendAppearanceToOtherAgent(avatar); } - public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) + public void SetAppearance(byte[] texture, List visualParam) { m_appearance.SetAppearance(texture, visualParam); SetHeight(m_appearance.AvatarHeight); diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 51bc0d8..e5e6469 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -271,7 +271,7 @@ namespace OpenSim.Region.Examples.SimpleModule { } - public virtual void SendAvatarPickerReply(AvatarPickerReplyPacket response) + public virtual void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List Data) { } @@ -528,9 +528,10 @@ namespace OpenSim.Region.Examples.SimpleModule frame = 0; if (OnAgentUpdate != null) { - AgentUpdatePacket pack = new AgentUpdatePacket(); - pack.AgentData.ControlFlags = movementFlag; - pack.AgentData.BodyRotation = bodyDirection; + AgentUpdateArgs pack = new AgentUpdateArgs(); + pack.ControlFlags = movementFlag; + pack.BodyRotation = bodyDirection; + OnAgentUpdate(this, pack); } if (flyState == 0) -- cgit v1.1