* This wraps the autopilot request to the client's sit response. An interesting, but successful way to do it.

* This also takes care of a few error situations that were previously never seen.
0.6.0-stable
Teravus Ovares 2008-06-06 12:51:20 +00:00
parent 3cbc01ee88
commit c892ddcd20
8 changed files with 186 additions and 32 deletions

View File

@ -838,6 +838,7 @@ namespace OpenSim.Framework
event RequestObjectPropertiesFamily OnObjectGroupRequest;
event ScriptReset OnScriptReset;
event UpdateVector OnAutoPilotGo;
[Obsolete("IClientAPI.OutPacket SHOULD NOT EXIST outside of LLClientView please refactor appropriately.")]
void OutPacket(Packet newPack, ThrottleOutPacketType packType);

View File

@ -269,6 +269,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private RequestObjectPropertiesFamily handlerObjectGroupRequest = null;
private ScriptReset handlerScriptReset = null;
private UpdateVector handlerAutoPilotGo = null;
/* Properties */
@ -900,6 +901,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
public event ScriptReset OnScriptReset;
public event UpdateVector OnAutoPilotGo;
#region Scene/Avatar to Client
@ -1125,7 +1127,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
patches[0] = patchx + 0 + patchy * 16;
Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
LayerDataPacket layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
layerpack.Header.Zerocoded = true;
OutPacket(layerpack, ThrottleOutPacketType.Land);
}
@ -3966,7 +3968,50 @@ namespace OpenSim.Region.ClientStack.LindenUDP
get { return m_packetProcessingEnabled; }
set { m_packetProcessingEnabled = value; }
}
public void DecipherGenericMessage(string gmMethod, LLUUID gmInvoice, GenericMessagePacket.ParamListBlock[] gmParams)
{
switch (gmMethod)
{
case "autopilot":
float locx = 0f;
float locy = 0f;
float locz = 0f;
uint regionX = 0;
uint regionY = 0;
try
{
Helpers.LongToUInts(Scene.RegionInfo.RegionHandle,out regionX, out regionY);
locx = Convert.ToSingle(Helpers.FieldToUTF8String(gmParams[0].Parameter)) - (float)regionX;
locy = Convert.ToSingle(Helpers.FieldToUTF8String(gmParams[1].Parameter)) - (float)regionY;
locz = Convert.ToSingle(Helpers.FieldToUTF8String(gmParams[2].Parameter));
}
catch (InvalidCastException)
{
m_log.Error("[CLIENT]: Invalid autopilot request");
return;
}
handlerAutoPilotGo = OnAutoPilotGo;
if (handlerAutoPilotGo != null)
{
handlerAutoPilotGo(0, new LLVector3(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.ToString() + ". Dumping Params:");
for (int hi = 0; hi < gmParams.Length; hi++)
{
System.Console.WriteLine(gmParams[hi].ToString());
}
//gmpack.MethodData.
break;
}
}
protected void ProcessInPacket(Packet Pack)
{
ack_pack(Pack);
@ -3998,6 +4043,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
#region Scene/Avatar
case PacketType.GenericMessage:
GenericMessagePacket gmpack = (GenericMessagePacket)Pack;
DecipherGenericMessage(Helpers.FieldToUTF8String(gmpack.MethodData.Method),gmpack.MethodData.Invoice,gmpack.ParamList);
break;
case PacketType.AvatarPropertiesRequest:
AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
@ -5933,10 +5984,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// TODO: handle this packet
m_log.Warn("[CLIENT]: unhandled CreateGroupRequest packet");
break;
case PacketType.GenericMessage:
//case PacketType.GenericMessage:
// TODO: handle this packet
m_log.Warn("[CLIENT]: unhandled GenericMessage packet");
break;
//m_log.Warn("[CLIENT]: unhandled GenericMessage packet");
//break;
case PacketType.MapItemRequest:
// TODO: handle this packet
m_log.Warn("[CLIENT]: unhandled MapItemRequest packet");

View File

@ -289,6 +289,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
public event ScriptReset OnScriptReset;
public event UpdateVector OnAutoPilotGo;
#pragma warning restore 67
#endregion

View File

@ -1736,6 +1736,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnObjectGroupRequest += m_innerScene.HandleObjectGroupUpdate;
client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel;
client.OnScriptReset += ProcessScriptReset;
// EventManager.TriggerOnNewClient(client);
}

View File

@ -62,6 +62,9 @@ namespace OpenSim.Region.Environment.Scenes
public uint ExternalChecksGenerateClientFlags(LLUUID userID, LLUUID objectID)
{
SceneObjectPart part=m_scene.GetSceneObjectPart(objectID);
if (part == null)
return 0;
uint perms=part.GetEffectiveObjectFlags() |
(uint)LLObject.ObjectFlags.ObjectModify |

View File

@ -472,6 +472,7 @@ namespace OpenSim.Region.Environment.Scenes
UpdateParentIDs();
}
/// <summary>
///
/// </summary>
@ -488,12 +489,12 @@ namespace OpenSim.Region.Environment.Scenes
newPart.LinkNum = m_parts.Count;
m_parts.Add(newPart.UUID, newPart);
SetPartAsRoot(newPart);
AttachToBackup();
// one of these is a proxy.
if (shape.PCode != (byte)PCode.None && shape.PCode != (byte)PCode.ParticleSystem)
AttachToBackup();
//ApplyPhysics(scene.m_physicalPrim);
}
/// <summary>
///
/// </summary>

View File

@ -80,6 +80,8 @@ namespace OpenSim.Region.Environment.Scenes
private Dictionary<LLUUID, ScriptControllers> scriptedcontrols = new Dictionary<LLUUID, ScriptControllers>();
private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO;
private SceneObjectGroup proxyObjectGroup = null;
private SceneObjectPart proxyObjectPart = null;
public Vector3 lastKnownAllowedPosition = new Vector3();
public bool sentMessageAboutRestrictedParcelFlyingDown = false;
@ -89,6 +91,8 @@ namespace OpenSim.Region.Environment.Scenes
private readonly List<NewForce> m_forcesList = new List<NewForce>();
private short m_updateCount = 0;
private uint m_requestedSitTargetID = 0;
private LLUUID m_requestedSitTargetUUID = LLUUID.Zero;
private LLVector3 m_requestedSitOffset = new LLVector3();
private LLVector3 m_LastFinitePos = new LLVector3();
@ -144,6 +148,10 @@ namespace OpenSim.Region.Environment.Scenes
//Reuse the LLVector3 instead of creating a new one on the UpdateMovement method
private LLVector3 movementvector = new LLVector3();
private bool m_autopilotMoving = false;
private LLVector3 m_autoPilotTarget = LLVector3.Zero;
private bool m_sitAtAutoTarget = false;
private List<LLUUID> m_knownPrimUUID = new List<LLUUID>();
// Agent's Draw distance.
@ -439,6 +447,7 @@ namespace OpenSim.Region.Environment.Scenes
m_controllingClient.OnStartAnim += HandleStartAnim;
m_controllingClient.OnStopAnim += HandleStopAnim;
m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls;
m_controllingClient.OnAutoPilotGo += DoAutoPilot;
// ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
// ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
@ -472,6 +481,8 @@ namespace OpenSim.Region.Environment.Scenes
// }
}
public uint GenerateClientFlags(LLUUID ObjectID)
{
return m_scene.ExternalChecks.ExternalChecksGenerateClientFlags(m_uuid, ObjectID);
@ -835,6 +846,9 @@ namespace OpenSim.Region.Environment.Scenes
return;
}
if (m_autopilotMoving)
CheckAtSitTarget();
if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
{
// TODO: This doesn't enable the "stand up" button on the viewer yet (probably a parent ID problem)
@ -856,14 +870,16 @@ namespace OpenSim.Region.Environment.Scenes
bool DCFlagKeyPressed = false;
Vector3 agent_control_v3 = new Vector3(0, 0, 0);
Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z);
bool oldflying = PhysicsActor.Flying;
PhysicsActor.Flying = ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
if (PhysicsActor.Flying != oldflying)
if (PhysicsActor != null)
{
update_movementflag = true;
}
bool oldflying = PhysicsActor.Flying;
PhysicsActor.Flying = ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
if (PhysicsActor.Flying != oldflying)
{
update_movementflag = true;
}
}
if (q != m_bodyRot)
{
m_bodyRot = q;
@ -930,11 +946,78 @@ namespace OpenSim.Region.Environment.Scenes
}
}
m_scene.EventManager.TriggerOnClientMovement(this);
m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS);
}
public void DoAutoPilot(uint not_used, LLVector3 Pos, IClientAPI remote_client)
{
m_autopilotMoving = true;
m_autoPilotTarget = Pos;
m_sitAtAutoTarget = false;
PrimitiveBaseShape proxy = PrimitiveBaseShape.Default;
//proxy.PCode = (byte)PCode.ParticleSystem;
uint nextUUID = m_scene.NextLocalId;
proxyObjectGroup = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, UUID, nextUUID, Pos, new LLQuaternion(Rotation.x, Rotation.y, Rotation.z, Rotation.w), proxy);
if (proxyObjectGroup != null)
{
proxyObjectGroup.SendGroupFullUpdate();
remote_client.SendSitResponse(proxyObjectGroup.UUID, LLVector3.Zero, LLQuaternion.Identity, true, LLVector3.Zero, LLVector3.Zero, false);
m_scene.DeleteSceneObject(proxyObjectGroup);
}
else
{
m_autopilotMoving = false;
m_autoPilotTarget = LLVector3.Zero;
ControllingClient.SendAlertMessage("Autopilot cancelled");
}
}
private void CheckAtSitTarget()
{
//m_log.Debug("[AUTOPILOT]: " + Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget).ToString());
if (Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget) <= 1.5)
{
if (m_sitAtAutoTarget)
{
SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetUUID);
if (part != null)
{
AbsolutePosition = part.AbsolutePosition;
Velocity = new LLVector3(0, 0, 0);
SendFullUpdateToAllClients();
//HandleAgentSit(ControllingClient, m_requestedSitTargetUUID);
}
//ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, LLQuaternion.Identity, false, LLVector3.Zero, LLVector3.Zero, false);
m_requestedSitTargetUUID = LLUUID.Zero;
}
else
{
//ControllingClient.SendAlertMessage("Autopilot cancelled");
//SendTerseUpdateToAllClients();
//PrimitiveBaseShape proxy = PrimitiveBaseShape.Default;
//proxy.PCode = (byte)PCode.ParticleSystem;
////uint nextUUID = m_scene.NextLocalId;
//proxyObjectGroup = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, UUID, nextUUID, m_autoPilotTarget, LLQuaternion.Identity, proxy);
//if (proxyObjectGroup != null)
//{
//proxyObjectGroup.SendGroupFullUpdate();
//ControllingClient.SendSitResponse(LLUUID.Zero, m_autoPilotTarget, LLQuaternion.Identity, true, LLVector3.Zero, LLVector3.Zero, false);
//m_scene.DeleteSceneObject(proxyObjectGroup);
//}
}
m_autoPilotTarget = LLVector3.Zero;
m_autopilotMoving = false;
}
}
/// <summary>
/// Perform the logic necessary to stand the client up. This method also executes
/// the stand animation.
@ -963,7 +1046,7 @@ namespace OpenSim.Region.Environment.Scenes
m_parentID = 0;
SendFullUpdateToAllClients();
m_requestedSitTargetID = 0;
if (m_physicsActor != null)
{
SetHeight(m_avHeight);
@ -1005,7 +1088,11 @@ namespace OpenSim.Region.Environment.Scenes
}
pos = part.AbsolutePosition + offset;
//if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1)
//{
// offset = pos;
//autopilot = false;
//}
if (m_physicsActor != null)
{
// If we're not using the client autopilot, we're immediately warping the avatar to the location
@ -1030,11 +1117,14 @@ namespace OpenSim.Region.Environment.Scenes
}
ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, LLVector3.Zero, LLVector3.Zero, false);
m_requestedSitTargetUUID = targetID;
// This calls HandleAgentSit twice, once from here, and the client calls
// HandleAgentSit itself after it gets to the location
// It doesn't get to the location until we've moved them there though
// which happens in HandleAgentSit :P
m_autopilotMoving = autopilot;
m_autoPilotTarget = pos;
m_sitAtAutoTarget = autopilot;
if (!autopilot)
HandleAgentSit(remoteClient, UUID);
}
@ -1064,32 +1154,38 @@ namespace OpenSim.Region.Environment.Scenes
{
SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID);
if (part != null)
if (m_sitAtAutoTarget || !m_autopilotMoving)
{
if (part.GetAvatarOnSitTarget() == UUID)
if (part != null)
{
Vector3 sitTargetPos = part.GetSitTargetPosition();
Quaternion sitTargetOrient = part.GetSitTargetOrientation();
if (part.GetAvatarOnSitTarget() == UUID)
{
Vector3 sitTargetPos = part.GetSitTargetPosition();
Quaternion sitTargetOrient = part.GetSitTargetOrientation();
//Quaternion vq = new Quaternion(sitTargetPos.x, sitTargetPos.y+0.2f, sitTargetPos.z+0.2f, 0);
//Quaternion nq = new Quaternion(sitTargetOrient.w, -sitTargetOrient.x, -sitTargetOrient.y, -sitTargetOrient.z);
//Quaternion vq = new Quaternion(sitTargetPos.x, sitTargetPos.y+0.2f, sitTargetPos.z+0.2f, 0);
//Quaternion nq = new Quaternion(sitTargetOrient.w, -sitTargetOrient.x, -sitTargetOrient.y, -sitTargetOrient.z);
//Quaternion result = (sitTargetOrient * vq) * nq;
//Quaternion result = (sitTargetOrient * vq) * nq;
m_pos = new LLVector3(sitTargetPos.x, sitTargetPos.y, sitTargetPos.z);
m_bodyRot = sitTargetOrient;
//Rotation = sitTargetOrient;
m_parentPosition = part.AbsolutePosition;
m_pos = new LLVector3(sitTargetPos.x, sitTargetPos.y, sitTargetPos.z);
m_bodyRot = sitTargetOrient;
//Rotation = sitTargetOrient;
m_parentPosition = part.AbsolutePosition;
//SendTerseUpdateToAllClients();
//SendTerseUpdateToAllClients();
}
else
{
m_pos -= part.AbsolutePosition;
m_parentPosition = part.AbsolutePosition;
}
}
else
{
m_pos -= part.AbsolutePosition;
m_parentPosition = part.AbsolutePosition;
return;
}
}
m_parentID = m_requestedSitTargetID;
Velocity = new LLVector3(0, 0, 0);

View File

@ -194,7 +194,7 @@ namespace OpenSim.Region.Examples.SimpleModule
public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
public event ScriptReset OnScriptReset;
public event UpdateVector OnAutoPilotGo;
#pragma warning restore 67