Attempt to fix mantis #741, could not replicate it myself. But the error was suggesting that the SceneObjectPart was null, so added a null check, to make sure the sceneobject to be attached is found before attempting the attachment.

0.6.0-stable
MW 2008-03-14 15:23:33 +00:00
parent 923cc9f62f
commit 7ab08f2ac4
1 changed files with 121 additions and 114 deletions

View File

@ -290,140 +290,147 @@ namespace OpenSim.Region.Environment.Scenes
{
System.Console.WriteLine("Attaching object " + objectLocalID + " to " + AttachmentPt);
SceneObjectPart p = GetSceneObjectPart(objectLocalID);
ScenePresence av = null;
if (TryGetAvatar(remoteClient.AgentId, out av))
if (p != null)
{
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
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] = 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].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].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 = 47;
objupdate.ObjectData[0].TextureEntry = ScenePresence.DefaultTexture;
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 = 47;
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);
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];
// 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;
objupdate.ObjectData[1].ObjectData = new byte[60];
objupdate.ObjectData[1].ObjectData[46] = 128;
objupdate.ObjectData[1].ObjectData[47] = 63;
// SetPrimPacketShapeData
PrimitiveBaseShape primData = p.Shape;
// 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].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);
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);
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);
byte[] brot = rot.GetBytes();
Array.Copy(brot, 0, objupdate.ObjectData[1].ObjectData, 36, brot.Length);
remoteClient.OutPacket(objupdate, ThrottleOutPacketType.Task);
remoteClient.OutPacket(objupdate, ThrottleOutPacketType.Task);
}
else
{
m_log.Info("[SCENE]: Avatar " + remoteClient.AgentId + " not found");
}
}
else
{
m_log.Info("[SCENE]: Avatar " + remoteClient.AgentId + " not found");
m_log.Info("[SCENE]: Attempting to attach object; Object " + objectLocalID + "(localID) not found");
}
}