The very beginnings of attachments (no detachments! :)

ThreadPoolClientBranch
Dalien Talbot 2008-02-10 22:23:11 +00:00
parent 78363c3bab
commit c935b308e6
7 changed files with 194 additions and 15 deletions

View File

@ -234,6 +234,11 @@ namespace OpenSim.Framework
uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags, uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags,
bool RezSelected, bool RemoveItem, LLUUID fromTaskID ); bool RezSelected, bool RemoveItem, LLUUID fromTaskID );
public delegate void RezSingleAttachmentFromInv(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt,
uint ItemFlags, uint NextOwnerMask);
public delegate void ObjectAttach(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot);
public delegate void ModifyTerrain( public delegate void ModifyTerrain(
float height, float seconds, byte size, byte action, float north, float west, float south, float east, float height, float seconds, byte size, byte action, float north, float west, float south, float east,
IClientAPI remoteClient); IClientAPI remoteClient);
@ -417,6 +422,8 @@ namespace OpenSim.Framework
event ModifyTerrain OnModifyTerrain; event ModifyTerrain OnModifyTerrain;
event SetAppearance OnSetAppearance; event SetAppearance OnSetAppearance;
event AvatarNowWearing OnAvatarNowWearing; event AvatarNowWearing OnAvatarNowWearing;
event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
event ObjectAttach OnObjectAttach;
event StartAnim OnStartAnim; event StartAnim OnStartAnim;
event StopAnim OnStopAnim; event StopAnim OnStopAnim;
event LinkObjects OnLinkObjects; event LinkObjects OnLinkObjects;

View File

@ -515,6 +515,8 @@ namespace OpenSim.Region.ClientStack
public event GenericCall2 OnRequestWearables; public event GenericCall2 OnRequestWearables;
public event SetAppearance OnSetAppearance; public event SetAppearance OnSetAppearance;
public event AvatarNowWearing OnAvatarNowWearing; public event AvatarNowWearing OnAvatarNowWearing;
public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
public event ObjectAttach OnObjectAttach;
public event GenericCall2 OnCompleteMovementToRegion; public event GenericCall2 OnCompleteMovementToRegion;
public event UpdateAgent OnAgentUpdate; public event UpdateAgent OnAgentUpdate;
public event AgentRequestSit OnAgentRequestSit; public event AgentRequestSit OnAgentRequestSit;
@ -1645,6 +1647,7 @@ namespace OpenSim.Region.ClientStack
public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint)
{ {
ObjectAttachPacket attach = (ObjectAttachPacket)PacketPool.Instance.GetPacket(PacketType.ObjectAttach); ObjectAttachPacket attach = (ObjectAttachPacket)PacketPool.Instance.GetPacket(PacketType.ObjectAttach);
System.Console.WriteLine("Attach object!");
// TODO: don't create new blocks if recycling an old packet // TODO: don't create new blocks if recycling an old packet
attach.AgentData.AgentID = AgentId; attach.AgentData.AgentID = AgentId;
attach.AgentData.SessionID = m_sessionId; attach.AgentData.SessionID = m_sessionId;
@ -2009,7 +2012,7 @@ namespace OpenSim.Region.ClientStack
/// ///
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry) public ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry)
{ {
ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock();
// new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
@ -2858,6 +2861,21 @@ namespace OpenSim.Region.ClientStack
OnAvatarNowWearing(this, wearingArgs); OnAvatarNowWearing(this, wearingArgs);
} }
break; break;
case PacketType.RezSingleAttachmentFromInv:
if (OnRezSingleAttachmentFromInv != null)
{
RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket) Pack;
OnRezSingleAttachmentFromInv(this, rez.ObjectData.ItemID,
rez.ObjectData.AttachmentPt, rez.ObjectData.ItemFlags, rez.ObjectData.NextOwnerMask);
}
break;
case PacketType.ObjectAttach:
if (OnObjectAttach != null)
{
ObjectAttachPacket att = (ObjectAttachPacket) Pack;
OnObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, att.ObjectData[0].Rotation);
}
break;
case PacketType.SetAlwaysRun: case PacketType.SetAlwaysRun:
SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;

View File

@ -232,6 +232,153 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot)
{
System.Console.WriteLine("Attaching object " + objectLocalID + " to " + AttachmentPt);
SceneObjectPart p = GetSceneObjectPart(objectLocalID);
ScenePresence av = null;
if (TryGetAvatar(remoteClient.AgentId, out av)) {
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle = m_regInfo.RegionHandle;
objupdate.RegionData.TimeDilation = 64096;
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 = 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);
// 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");
}
}
public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarAppearance appearance) public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarAppearance appearance)
{ {
ScenePresence newAvatar = null; ScenePresence newAvatar = null;

View File

@ -33,6 +33,10 @@ using libsecondlife.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using System.IO;
using System.Text;
using System.Xml;
namespace OpenSim.Region.Environment.Scenes namespace OpenSim.Region.Environment.Scenes
{ {
@ -766,6 +770,12 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
} }
public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt,
uint ItemFlags, uint NextOwnerMask)
{
System.Console.WriteLine("RezSingleAttachment: unimplemented yet");
}
private void AddRezObject(string xmlData, LLVector3 pos) private void AddRezObject(string xmlData, LLVector3 pos)
{ {

View File

@ -1299,6 +1299,8 @@ namespace OpenSim.Region.Environment.Scenes
client.OnGrabUpdate += m_innerScene.MoveObject; client.OnGrabUpdate += m_innerScene.MoveObject;
client.OnDeRezObject += DeRezObject; client.OnDeRezObject += DeRezObject;
client.OnRezObject += RezObject; client.OnRezObject += RezObject;
client.OnRezSingleAttachmentFromInv += RezSingleAttachment;
client.OnObjectAttach += m_innerScene.AttachObject;
client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest;
client.OnObjectDescription += m_innerScene.PrimDescription; client.OnObjectDescription += m_innerScene.PrimDescription;
client.OnObjectName += m_innerScene.PrimName; client.OnObjectName += m_innerScene.PrimName;

View File

@ -58,6 +58,8 @@ namespace SimpleApp
public event ModifyTerrain OnModifyTerrain; public event ModifyTerrain OnModifyTerrain;
public event SetAppearance OnSetAppearance; public event SetAppearance OnSetAppearance;
public event AvatarNowWearing OnAvatarNowWearing; public event AvatarNowWearing OnAvatarNowWearing;
public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
public event ObjectAttach OnObjectAttach;
public event StartAnim OnStartAnim; public event StartAnim OnStartAnim;
public event StopAnim OnStopAnim; public event StopAnim OnStopAnim;
public event LinkObjects OnLinkObjects; public event LinkObjects OnLinkObjects;

View File

@ -176,9 +176,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
{ {
// 0 => 1: Get last // 0 => 1: Get last
Match m = Match m =
//Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{", Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{",
Regex.Match(cache, @"(?![a-zA-Z_]+)\s*(state\s+)?(?<statename>[a-zA-Z_]+)[^a-zA-Z_\(\)]*{",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
in_state = false; in_state = false;
@ -186,14 +184,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
{ {
// Go back to level 0, this is not a state // Go back to level 0, this is not a state
in_state = true; in_state = true;
current_statename = m.Groups["statename"].Captures[0].Value; current_statename = m.Groups[1].Captures[0].Value;
//Console.WriteLine("Current statename: " + current_statename); //Console.WriteLine("Current statename: " + current_statename);
cache = cache =
//@"(?<s1>(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?<s2>[^a-zA-Z_\(\)]*){",
Regex.Replace(cache, Regex.Replace(cache,
@"(?<s1>(?![a-zA-Z_]+)\s*)" + @"(state\s+)?([a-zA-Z_]+)(?<s2>[^a-zA-Z_\(\)]*){", @"(?<s1>(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?<s2>[^a-zA-Z_\(\)]*){",
"${s1}${s2}", "${s1}${s2}",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
} }
ret += cache; ret += cache;
cache = String.Empty; cache = String.Empty;
@ -214,7 +211,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
Regex.Replace(cache, Regex.Replace(cache,
@"^(\s*)((?!(if|switch|for|while)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", @"^(\s*)((?!(if|switch|for|while)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)",
@"$1public " + current_statename + "_event_$2", @"$1public " + current_statename + "_event_$2",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
} }
ret += cache; ret += cache;
@ -260,10 +257,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
// Replace <x,y,z> and <x,y,z,r> // Replace <x,y,z> and <x,y,z,r>
Script = Script =
Regex.Replace(Script, @"<([^,>;]*,[^,>;]*,[^,>;]*,[^,>;]*)>", @"new LSL_Types.Quaternion($1)", Regex.Replace(Script, @"<([^,>;]*,[^,>;\)]*,[^,>;\)]*,[^,>;\)]*)>", @"new LSL_Types.Quaternion($1)",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
Script = Script =
Regex.Replace(Script, @"<([^,>;)]*,[^,>;]*,[^,>;]*)>", @"new LSL_Types.Vector3($1)", Regex.Replace(Script, @"<([^,>;]*,[^,>;\)]*,[^,>;\)]*)>", @"new LSL_Types.Vector3($1)",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
// Replace List []'s // Replace List []'s
@ -280,10 +277,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
Regex.Replace(Script, @"\((float|int)\)\s*([a-zA-Z0-9_.]+(\s*\([^\)]*\))?)", @"$1.Parse($2)", Regex.Replace(Script, @"\((float|int)\)\s*([a-zA-Z0-9_.]+(\s*\([^\)]*\))?)", @"$1.Parse($2)",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
// Replace "state STATENAME" with "state("statename")"
Script =
Regex.Replace(Script, @"(state)\s+([^;\n\r]+)([\r\n\s];)", "$1(\"$2\")$3",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
// REPLACE BACK QUOTES // REPLACE BACK QUOTES
foreach (string key in quotes.Keys) foreach (string key in quotes.Keys)