Resolve merge commits, stage 1

This commit is contained in:
Tom
2011-09-04 07:06:36 -07:00
267 changed files with 19393 additions and 5645 deletions

View File

@@ -90,7 +90,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event ObjectAttach OnObjectAttach;
public event ObjectDeselect OnObjectDetach;
public event ObjectDrop OnObjectDrop;
public event GenericCall1 OnCompleteMovementToRegion;
public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
public event AgentRequestSit OnAgentRequestSit;
@@ -232,7 +232,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event ScriptReset OnScriptReset;
public event GetScriptRunning OnGetScriptRunning;
public event SetScriptRunning OnSetScriptRunning;
public event UpdateVector OnAutoPilotGo;
public event Action<Vector3, bool> OnAutoPilotGo;
public event TerrainUnacked OnUnackedTerrain;
public event ActivateGesture OnActivateGesture;
public event DeactivateGesture OnDeactivateGesture;
@@ -534,7 +534,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_udpServer.Flush(m_udpClient);
// Remove ourselves from the scene
m_scene.RemoveClient(AgentId);
m_scene.RemoveClient(AgentId, true);
// We can't reach into other scenes and close the connection
// We need to do this over grid communications
@@ -596,22 +596,42 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return result;
}
/// <summary>
/// Add a handler for the given packet type.
/// </summary>
/// <remarks>The packet is handled on its own thread. If packets must be handled in the order in which thye
/// are received then please us ethe synchronous version of this method.</remarks>
/// <param name="packetType"></param>
/// <param name="handler"></param>
/// <returns>true if the handler was added. This is currently always the case.</returns>
public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
{
return AddLocalPacketHandler(packetType, handler, true);
}
public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool async)
/// <summary>
/// Add a handler for the given packet type.
/// </summary>
/// <param name="packetType"></param>
/// <param name="handler"></param>
/// <param name="doAsync">
/// If true, when the packet is received it is handled on its own thread rather than on the main inward bound
/// packet handler thread. This vastly increases respnosiveness but some packets need to be handled
/// synchronously.
/// </param>
/// <returns>true if the handler was added. This is currently always the case.</returns>
public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
{
bool result = false;
lock (m_packetHandlers)
{
if (!m_packetHandlers.ContainsKey(packetType))
{
m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = async });
m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = doAsync });
result = true;
}
}
return result;
}
@@ -694,7 +714,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public virtual void Start()
{
m_scene.AddNewClient(this);
m_scene.AddNewClient(this, PresenceType.User);
RefreshGroupMembership();
}
@@ -4800,7 +4820,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
SceneObjectPart part = (SceneObjectPart)entity;
attachPoint = part.AttachmentPoint;
attachPoint = part.ParentGroup.AttachmentPoint;
// m_log.DebugFormat(
// "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
// attachPoint, part.Name, part.LocalId, Name);
collisionPlane = Vector4.Zero;
position = part.RelativePosition;
velocity = part.Velocity;
@@ -4957,17 +4982,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//update.JointType = 0;
update.Material = data.Material;
update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
if (data.IsAttachment)
if (data.ParentGroup.IsAttachment)
{
update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.FromItemID);
update.State = (byte)((data.AttachmentPoint % 16) * 16 + (data.AttachmentPoint / 16));
update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
}
else
{
update.NameValue = Utils.EmptyBytes;
update.State = data.Shape.State;
// The root part state is the canonical state for all parts of the object. The other part states in the
// case for attachments may contain conflicting values that can end up crashing the viewer.
update.State = data.ParentGroup.RootPart.Shape.State;
}
// m_log.DebugFormat(
// "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}",
// update.State, data.Name, data.LocalId, Name);
update.ObjectData = objectData;
update.ParentID = data.ParentID;
update.PathBegin = data.Shape.PathBegin;
@@ -5311,6 +5343,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
AddGenericPacketHandler("autopilot", HandleAutopilot);
}
#region Packet Handlers
@@ -5354,7 +5388,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
);
}
else
{
update = true;
}
// These should be ordered from most-likely to
// least likely to change. I've made an initial
@@ -5362,6 +5398,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (update)
{
// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name);
AgentUpdateArgs arg = new AgentUpdateArgs();
arg.AgentID = x.AgentID;
arg.BodyRotation = x.BodyRotation;
@@ -6235,10 +6273,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
{
GenericCall1 handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
if (handlerCompleteMovementToRegion != null)
{
handlerCompleteMovementToRegion(sender);
handlerCompleteMovementToRegion(sender, true);
}
handlerCompleteMovementToRegion = null;
@@ -11316,8 +11354,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
{
MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
if (multipleupdate.AgentData.SessionID != SessionId) return false;
// m_log.Debug("new multi update packet " + multipleupdate.ToString());
if (multipleupdate.AgentData.SessionID != SessionId)
return false;
// m_log.DebugFormat(
// "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
Scene tScene = (Scene)m_scene;
for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
@@ -11338,7 +11381,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
else
{
// UUID partId = part.UUID;
// m_log.DebugFormat(
// "[CLIENT]: Processing block {0} type {1} for {2} {3}",
// i, block.Type, part.Name, part.LocalId);
// // Do this once since fetch parts creates a new array.
// SceneObjectPart[] parts = part.ParentGroup.Parts;
// for (int j = 0; j < parts.Length; j++)
// {
// part.StoreUndoState();
// parts[j].IgnoreUndoUpdate = true;
// }
UpdatePrimGroupRotation handlerUpdatePrimGroupRotation;
switch (block.Type)
@@ -11353,6 +11407,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerUpdatePrimSinglePosition(localId, pos1, this);
}
break;
case 2:
Quaternion rot1 = new Quaternion(block.Data, 0, true);
@@ -11363,6 +11418,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerUpdatePrimSingleRotation(localId, rot1, this);
}
break;
case 3:
Vector3 rotPos = new Vector3(block.Data, 0);
Quaternion rot2 = new Quaternion(block.Data, 12, true);
@@ -11375,6 +11431,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this);
}
break;
case 4:
case 20:
Vector3 scale4 = new Vector3(block.Data, 0);
@@ -11386,8 +11443,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerUpdatePrimScale(localId, scale4, this);
}
break;
case 5:
case 5:
Vector3 scale1 = new Vector3(block.Data, 12);
Vector3 pos11 = new Vector3(block.Data, 0);
@@ -11404,6 +11461,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
}
break;
case 9:
Vector3 pos2 = new Vector3(block.Data, 0);
@@ -11411,10 +11469,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (handlerUpdateVector != null)
{
handlerUpdateVector(localId, pos2, this);
}
break;
case 10:
Quaternion rot3 = new Quaternion(block.Data, 0, true);
@@ -11425,6 +11483,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerUpdatePrimRotation(localId, rot3, this);
}
break;
case 11:
Vector3 pos3 = new Vector3(block.Data, 0);
Quaternion rot4 = new Quaternion(block.Data, 12, true);
@@ -11448,6 +11507,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerUpdatePrimGroupScale(localId, scale7, this);
}
break;
case 13:
Vector3 scale2 = new Vector3(block.Data, 12);
Vector3 pos4 = new Vector3(block.Data, 0);
@@ -11467,6 +11527,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
}
break;
case 29:
Vector3 scale5 = new Vector3(block.Data, 12);
Vector3 pos5 = new Vector3(block.Data, 0);
@@ -11475,6 +11536,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (handlerUpdatePrimGroupScale != null)
{
// m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
part.StoreUndoState(true);
part.IgnoreUndoUpdate = true;
handlerUpdatePrimGroupScale(localId, scale5, this);
handlerUpdateVector = OnUpdatePrimGroupPosition;
@@ -11482,8 +11545,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
handlerUpdateVector(localId, pos5, this);
}
part.IgnoreUndoUpdate = false;
}
break;
case 21:
Vector3 scale6 = new Vector3(block.Data, 12);
Vector3 pos6 = new Vector3(block.Data, 0);
@@ -11491,6 +11558,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerUpdatePrimScale = OnUpdatePrimScale;
if (handlerUpdatePrimScale != null)
{
part.StoreUndoState(false);
part.IgnoreUndoUpdate = true;
// m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
handlerUpdatePrimScale(localId, scale6, this);
handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
@@ -11498,15 +11568,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
handlerUpdatePrimSinglePosition(localId, pos6, this);
}
part.IgnoreUndoUpdate = false;
}
break;
default:
m_log.Debug("[CLIENT] MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
break;
}
// for (int j = 0; j < parts.Length; j++)
// parts[j].IgnoreUndoUpdate = false;
}
}
}
return true;
}
@@ -11666,55 +11743,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return false;
}
/// <summary>
/// Breaks down the genericMessagePacket into specific events
/// </summary>
/// <param name="gmMethod"></param>
/// <param name="gmInvoice"></param>
/// <param name="gmParams"></param>
public void DecipherGenericMessage(string gmMethod, UUID gmInvoice, GenericMessagePacket.ParamListBlock[] gmParams)
protected void HandleAutopilot(Object sender, string method, List<String> args)
{
switch (gmMethod)
{
case "autopilot":
float locx;
float locy;
float locz;
float locx = 0;
float locy = 0;
float locz = 0;
uint regionX = 0;
uint regionY = 0;
try
{
uint regionX;
uint regionY;
Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY);
locx = Convert.ToSingle(Utils.BytesToString(gmParams[0].Parameter)) - regionX;
locy = Convert.ToSingle(Utils.BytesToString(gmParams[1].Parameter)) - regionY;
locz = Convert.ToSingle(Utils.BytesToString(gmParams[2].Parameter));
}
catch (InvalidCastException)
{
m_log.Error("[CLIENT]: Invalid autopilot request");
return;
}
Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
locx = Convert.ToSingle(args[0]) - (float)regionX;
locy = Convert.ToSingle(args[1]) - (float)regionY;
locz = Convert.ToSingle(args[2]);
UpdateVector handlerAutoPilotGo = OnAutoPilotGo;
if (handlerAutoPilotGo != null)
{
handlerAutoPilotGo(0, new Vector3(locx, locy, locz), this);
}
m_log.InfoFormat("[CLIENT]: Client Requests autopilot to position <{0},{1},{2}>", locx, locy, locz);
break;
default:
m_log.Debug("[CLIENT]: Unknown Generic Message, Method: " + gmMethod + ". Invoice: " + gmInvoice + ". Dumping Params:");
for (int hi = 0; hi < gmParams.Length; hi++)
{
Console.WriteLine(gmParams[hi].ToString());
}
//gmpack.MethodData.
break;
}
Action<Vector3, bool> handlerAutoPilotGo = OnAutoPilotGo;
if (handlerAutoPilotGo != null)
handlerAutoPilotGo(new Vector3(locx, locy, locz), false);
}
/// <summary>

View File

@@ -44,7 +44,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static Int32 m_counter = 0;
private Int32 m_identifier;
// private Int32 m_identifier;
/// <summary>
/// Number of ticks (ms) per quantum, drip rate and max burst
@@ -173,7 +173,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// second. If zero, the bucket always remains full</param>
public TokenBucket(TokenBucket parent, Int64 dripRate)
{
m_identifier = m_counter++;
// m_identifier = m_counter++;
m_counter++;
Parent = parent;
RequestedDripRate = dripRate;
@@ -320,7 +321,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public class AdaptiveTokenBucket : TokenBucket
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// The minimum rate for flow control. Minimum drip rate is one