From 1ba51dd2fdd658947cc94af2d788f0cc4da03a3f Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 10 May 2008 13:11:09 +0000 Subject: * More OutPacket refactors. * Added back a sleep to the kick routine so users get a 'you have been logged off message' when they get kicked from the simulator for various reasons (like 'the simulator is going down') --- OpenSim/Framework/IClientAPI.cs | 3 + .../Region/ClientStack/LindenUDP/LLClientView.cs | 13 ++ OpenSim/Region/Environment/Scenes/InnerScene.cs | 152 +-------------------- OpenSim/Region/Environment/Scenes/Scene.cs | 10 +- .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 8 ++ 5 files changed, 29 insertions(+), 157 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 3ae90f3..09c6329 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -939,6 +939,9 @@ namespace OpenSim.Framework void SendImagePart(ushort numParts, LLUUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec); + void SendShutdownConnectionNotice(); + void SendSimStats(Packet pack); + byte[] GetThrottlesPacked(float multiplier); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 8721356..aff43d5 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -436,6 +436,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP kupack.TargetBlock.TargetPort = (ushort)0; kupack.UserInfo.Reason = Helpers.StringToField(message); OutPacket(kupack, ThrottleOutPacketType.Task); + // You must sleep here or users get no message! + Thread.Sleep(500); } } @@ -2244,6 +2246,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP im.Header.Zerocoded = true; OutPacket(im, ThrottleOutPacketType.Texture); } + public void SendShutdownConnectionNotice() + { + OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown); + } + + public void SendSimStats(Packet pack) + { + pack.Header.Reliable = false; + OutPacket(pack, ThrottleOutPacketType.Task); + } + #endregion #region Estate Data Sending Methods diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 2c8c323..9dba398 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -447,157 +447,7 @@ namespace OpenSim.Region.Environment.Scenes } } - // Use the above method. - public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, - bool deadMethod) - { - Console.WriteLine("Attaching object " + objectLocalID + " to " + AttachmentPt); - SceneObjectPart p = GetSceneObjectPart(objectLocalID); - if (p != null) - { - ScenePresence av = null; - if (TryGetAvatar(remoteClient.AgentId, out av)) - { - ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle = m_regInfo.RegionHandle; - objupdate.RegionData.TimeDilation = ushort.MaxValue; - objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[2]; - // avatar stuff - horrible group copypaste - - objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock(); - objupdate.ObjectData[0].PSBlock = new byte[0]; - objupdate.ObjectData[0].ExtraParams = new byte[1]; - objupdate.ObjectData[0].MediaURL = new byte[0]; - objupdate.ObjectData[0].NameValue = new byte[0]; - objupdate.ObjectData[0].Text = new byte[0]; - objupdate.ObjectData[0].TextColor = new byte[4]; - objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0); - objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0); - objupdate.ObjectData[0].Material = 4; - objupdate.ObjectData[0].TextureAnim = new byte[0]; - objupdate.ObjectData[0].Sound = LLUUID.Zero; - - objupdate.ObjectData[0].State = 0; - objupdate.ObjectData[0].Data = new byte[0]; - - objupdate.ObjectData[0].ObjectData = new byte[76]; - objupdate.ObjectData[0].ObjectData[15] = 128; - objupdate.ObjectData[0].ObjectData[16] = 63; - objupdate.ObjectData[0].ObjectData[56] = 128; - objupdate.ObjectData[0].ObjectData[61] = 102; - objupdate.ObjectData[0].ObjectData[62] = 40; - objupdate.ObjectData[0].ObjectData[63] = 61; - objupdate.ObjectData[0].ObjectData[64] = 189; - - - objupdate.ObjectData[0].UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24); - objupdate.ObjectData[0].PathCurve = 16; - objupdate.ObjectData[0].ProfileCurve = 1; - objupdate.ObjectData[0].PathScaleX = 100; - objupdate.ObjectData[0].PathScaleY = 100; - objupdate.ObjectData[0].ParentID = 0; - objupdate.ObjectData[0].OwnerID = LLUUID.Zero; - objupdate.ObjectData[0].Scale = new LLVector3(1, 1, 1); - objupdate.ObjectData[0].PCode = (byte)PCode.Avatar; - objupdate.ObjectData[0].TextureEntry = ScenePresence.DefaultTexture; - - objupdate.ObjectData[0].ID = av.LocalId; - objupdate.ObjectData[0].FullID = remoteClient.AgentId; - objupdate.ObjectData[0].ParentID = 0; - objupdate.ObjectData[0].NameValue = - Helpers.StringToField("FirstName STRING RW SV " + av.Firstname + "\nLastName STRING RW SV " + av.Lastname); - LLVector3 pos2 = av.AbsolutePosition; - // new LLVector3((float) Pos.X, (float) Pos.Y, (float) Pos.Z); - byte[] pb = pos2.GetBytes(); - Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); - - - // primitive part - objupdate.ObjectData[1] = new ObjectUpdatePacket.ObjectDataBlock(); - // SetDefaultPrimPacketValues - objupdate.ObjectData[1].PSBlock = new byte[0]; - objupdate.ObjectData[1].ExtraParams = new byte[1]; - objupdate.ObjectData[1].MediaURL = new byte[0]; - objupdate.ObjectData[1].NameValue = new byte[0]; - objupdate.ObjectData[1].Text = new byte[0]; - objupdate.ObjectData[1].TextColor = new byte[4]; - objupdate.ObjectData[1].JointAxisOrAnchor = new LLVector3(0, 0, 0); - objupdate.ObjectData[1].JointPivot = new LLVector3(0, 0, 0); - objupdate.ObjectData[1].Material = 3; - objupdate.ObjectData[1].TextureAnim = new byte[0]; - objupdate.ObjectData[1].Sound = LLUUID.Zero; - objupdate.ObjectData[1].State = 0; - objupdate.ObjectData[1].Data = new byte[0]; - - objupdate.ObjectData[1].ObjectData = new byte[60]; - objupdate.ObjectData[1].ObjectData[46] = 128; - objupdate.ObjectData[1].ObjectData[47] = 63; - - // SetPrimPacketShapeData - PrimitiveBaseShape primData = p.Shape; - - objupdate.ObjectData[1].TextureEntry = primData.TextureEntry; - objupdate.ObjectData[1].PCode = primData.PCode; - objupdate.ObjectData[1].State = (byte)(((byte)AttachmentPt) << 4); - objupdate.ObjectData[1].PathBegin = primData.PathBegin; - objupdate.ObjectData[1].PathEnd = primData.PathEnd; - objupdate.ObjectData[1].PathScaleX = primData.PathScaleX; - objupdate.ObjectData[1].PathScaleY = primData.PathScaleY; - objupdate.ObjectData[1].PathShearX = primData.PathShearX; - objupdate.ObjectData[1].PathShearY = primData.PathShearY; - objupdate.ObjectData[1].PathSkew = primData.PathSkew; - objupdate.ObjectData[1].ProfileBegin = primData.ProfileBegin; - objupdate.ObjectData[1].ProfileEnd = primData.ProfileEnd; - objupdate.ObjectData[1].Scale = primData.Scale; - objupdate.ObjectData[1].PathCurve = primData.PathCurve; - objupdate.ObjectData[1].ProfileCurve = primData.ProfileCurve; - objupdate.ObjectData[1].ProfileHollow = primData.ProfileHollow; - objupdate.ObjectData[1].PathRadiusOffset = primData.PathRadiusOffset; - objupdate.ObjectData[1].PathRevolutions = primData.PathRevolutions; - objupdate.ObjectData[1].PathTaperX = primData.PathTaperX; - objupdate.ObjectData[1].PathTaperY = primData.PathTaperY; - objupdate.ObjectData[1].PathTwist = primData.PathTwist; - objupdate.ObjectData[1].PathTwistBegin = primData.PathTwistBegin; - objupdate.ObjectData[1].ExtraParams = primData.ExtraParams; - - - objupdate.ObjectData[1].UpdateFlags = 276957500; // flags; // ?? - objupdate.ObjectData[1].ID = p.LocalId; - objupdate.ObjectData[1].FullID = p.UUID; - objupdate.ObjectData[1].OwnerID = p.OwnerID; - objupdate.ObjectData[1].Text = Helpers.StringToField(p.Text); - objupdate.ObjectData[1].TextColor[0] = 255; - objupdate.ObjectData[1].TextColor[1] = 255; - objupdate.ObjectData[1].TextColor[2] = 255; - objupdate.ObjectData[1].TextColor[3] = 128; - objupdate.ObjectData[1].ParentID = objupdate.ObjectData[0].ID; - //objupdate.ObjectData[1].PSBlock = particleSystem; - //objupdate.ObjectData[1].ClickAction = clickAction; - objupdate.ObjectData[1].Radius = 20; - objupdate.ObjectData[1].NameValue = - Helpers.StringToField("AttachItemID STRING RW SV " + p.UUID); - LLVector3 pos = new LLVector3((float)0.0, (float)0.0, (float)0.0); - - pb = pos.GetBytes(); - Array.Copy(pb, 0, objupdate.ObjectData[1].ObjectData, 0, pb.Length); - - byte[] brot = rot.GetBytes(); - Array.Copy(brot, 0, objupdate.ObjectData[1].ObjectData, 36, brot.Length); - - remoteClient.OutPacket(objupdate, ThrottleOutPacketType.Task); - } - else - { - m_log.Info("[SCENE]: Avatar " + remoteClient.AgentId + " not found"); - } - } - else - { - m_log.Info("[SCENE]: Attempting to attach object; Object " + objectLocalID + "(localID) not found"); - } - } - - + public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarAppearance appearance) { ScenePresence newAvatar = null; diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 1f66744..2e1116b 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -570,8 +570,7 @@ namespace OpenSim.Region.Environment.Scenes if (!avatar.IsChildAgent) avatar.ControllingClient.Kick("The simulator is going down."); - avatar.ControllingClient.OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), - ThrottleOutPacketType.Task); + avatar.ControllingClient.SendShutdownConnectionNotice(); }); // Wait here, or the kick messages won't actually get to the agents before the scene terminates. @@ -790,8 +789,7 @@ namespace OpenSim.Region.Environment.Scenes { if (!agent.IsChildAgent) { - pack.Header.Reliable = false; - agent.ControllingClient.OutPacket(pack, ThrottleOutPacketType.Task); + agent.ControllingClient.SendSimStats(pack); } } } @@ -2140,8 +2138,8 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.removeUserCount(true); } // Tell a single agent to disconnect from the region. - DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator); - presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Unknown); + presence.ControllingClient.SendShutdownConnectionNotice(); + presence.ControllingClient.Close(true); } } diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index d14089b..05f963a 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -535,6 +535,14 @@ namespace OpenSim.Region.Examples.SimpleModule { } + public void SendShutdownConnectionNotice() + { + } + + public void SendSimStats(Packet pack) + { + } + private void Update() { frame++; -- cgit v1.1