aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-02 23:41:12 +0100
committerJustin Clark-Casey (justincc)2011-08-02 23:41:12 +0100
commitc122489e0947300753281e88771b7a74d49869c7 (patch)
treec8b0f67e85f883cd1e9a1ff3ff411c7eca08e64f /OpenSim/Region
parentIf GetRegionByName can't match something in the local db, then search the hyp... (diff)
downloadopensim-SC-c122489e0947300753281e88771b7a74d49869c7.zip
opensim-SC-c122489e0947300753281e88771b7a74d49869c7.tar.gz
opensim-SC-c122489e0947300753281e88771b7a74d49869c7.tar.bz2
opensim-SC-c122489e0947300753281e88771b7a74d49869c7.tar.xz
Partially fix autopilot/go here
This now works again except that it requires a click or avatar mvmt to get going This is because the ScenePresence.HandleAgentUpdate() method doesn't trigger until the client does something significant, at which point autopilot takes over. Even clicking is enough to trigger. This will be improved presently.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs79
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs112
-rw-r--r--OpenSim/Region/Framework/Scenes/UndoState.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs1
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs11
6 files changed, 98 insertions, 118 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 60f0075..bb491a1 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -5266,6 +5266,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5266 AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest); 5266 AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
5267 AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes); 5267 AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
5268 AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard); 5268 AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
5269
5270 AddGenericPacketHandler("autopilot", HandleAutopilot);
5269 } 5271 }
5270 5272
5271 #region Packet Handlers 5273 #region Packet Handlers
@@ -5308,7 +5310,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5308 ); 5310 );
5309 } 5311 }
5310 else 5312 else
5313 {
5311 update = true; 5314 update = true;
5315 }
5312 5316
5313 // These should be ordered from most-likely to 5317 // These should be ordered from most-likely to
5314 // least likely to change. I've made an initial 5318 // least likely to change. I've made an initial
@@ -5316,6 +5320,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5316 5320
5317 if (update) 5321 if (update)
5318 { 5322 {
5323// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name);
5324
5319 AgentUpdateArgs arg = new AgentUpdateArgs(); 5325 AgentUpdateArgs arg = new AgentUpdateArgs();
5320 arg.AgentID = x.AgentID; 5326 arg.AgentID = x.AgentID;
5321 arg.BodyRotation = x.BodyRotation; 5327 arg.BodyRotation = x.BodyRotation;
@@ -11609,54 +11615,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11609 return false; 11615 return false;
11610 } 11616 }
11611 11617
11612 /// <summary> 11618 protected void HandleAutopilot(Object sender, string method, List<String> args)
11613 /// Breaks down the genericMessagePacket into specific events
11614 /// </summary>
11615 /// <param name="gmMethod"></param>
11616 /// <param name="gmInvoice"></param>
11617 /// <param name="gmParams"></param>
11618 public void DecipherGenericMessage(string gmMethod, UUID gmInvoice, GenericMessagePacket.ParamListBlock[] gmParams)
11619 { 11619 {
11620 switch (gmMethod) 11620 try
11621 { 11621 {
11622 case "autopilot": 11622 float locx = 0f;
11623 float locx; 11623 float locy = 0f;
11624 float locy; 11624 float locz = 0f;
11625 float locz; 11625 uint regionX = 0;
11626 11626 uint regionY = 0;
11627 try 11627 try
11628 { 11628 {
11629 uint regionX; 11629 Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
11630 uint regionY; 11630 locx = Convert.ToSingle(args[0]) - (float)regionX;
11631 Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY); 11631 locy = Convert.ToSingle(args[1]) - (float)regionY;
11632 locx = Convert.ToSingle(Utils.BytesToString(gmParams[0].Parameter)) - regionX; 11632 locz = Convert.ToSingle(args[2]);
11633 locy = Convert.ToSingle(Utils.BytesToString(gmParams[1].Parameter)) - regionY; 11633 }
11634 locz = Convert.ToSingle(Utils.BytesToString(gmParams[2].Parameter)); 11634 catch (InvalidCastException)
11635 } 11635 {
11636 catch (InvalidCastException) 11636 m_log.Error("[CLIENT]: Invalid autopilot request");
11637 { 11637 return;
11638 m_log.Error("[CLIENT]: Invalid autopilot request"); 11638 }
11639 return;
11640 }
11641
11642 UpdateVector handlerAutoPilotGo = OnAutoPilotGo;
11643 if (handlerAutoPilotGo != null)
11644 {
11645 handlerAutoPilotGo(0, new Vector3(locx, locy, locz), this);
11646 }
11647 m_log.InfoFormat("[CLIENT]: Client Requests autopilot to position <{0},{1},{2}>", locx, locy, locz);
11648
11649
11650 break;
11651 default:
11652 m_log.Debug("[CLIENT]: Unknown Generic Message, Method: " + gmMethod + ". Invoice: " + gmInvoice + ". Dumping Params:");
11653 for (int hi = 0; hi < gmParams.Length; hi++)
11654 {
11655 Console.WriteLine(gmParams[hi].ToString());
11656 }
11657 //gmpack.MethodData.
11658 break;
11659 11639
11640 UpdateVector handlerAutoPilotGo = OnAutoPilotGo;
11641 if (handlerAutoPilotGo != null)
11642 {
11643 handlerAutoPilotGo(0, new Vector3(locx, locy, locz), this);
11644 }
11645 }
11646 catch (Exception e)
11647 {
11648 m_log.ErrorFormat("[LLCLIENTVIEW]: HandleAutopilot exception {0} {1}", e.Message, e.StackTrace);
11660 } 11649 }
11661 } 11650 }
11662 11651
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index b6fb5a4..1417efb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1650,16 +1650,7 @@ namespace OpenSim.Region.Framework.Scenes
1650 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); 1650 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
1651 if (avatar != null) 1651 if (avatar != null)
1652 { 1652 {
1653 List<string> coords = new List<string>(); 1653 avatar.DoMoveToPosition(0, target, null);
1654 uint regionX = 0;
1655 uint regionY = 0;
1656 Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY);
1657 target.X += regionX;
1658 target.Y += regionY;
1659 coords.Add(target.X.ToString());
1660 coords.Add(target.Y.ToString());
1661 coords.Add(target.Z.ToString());
1662 avatar.DoMoveToPosition(avatar, "", coords);
1663 } 1654 }
1664 } 1655 }
1665 else 1656 else
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4739f5b..a508813 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -116,7 +116,7 @@ namespace OpenSim.Region.Framework.Scenes
116 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; 116 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
117 private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; 117 private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO;
118 private bool MouseDown = false; 118 private bool MouseDown = false;
119 private SceneObjectGroup proxyObjectGroup; 119// private SceneObjectGroup proxyObjectGroup;
120 //private SceneObjectPart proxyObjectPart = null; 120 //private SceneObjectPart proxyObjectPart = null;
121 public Vector3 lastKnownAllowedPosition; 121 public Vector3 lastKnownAllowedPosition;
122 public bool sentMessageAboutRestrictedParcelFlyingDown; 122 public bool sentMessageAboutRestrictedParcelFlyingDown;
@@ -779,8 +779,7 @@ namespace OpenSim.Region.Framework.Scenes
779 m_controllingClient.OnStartAnim += HandleStartAnim; 779 m_controllingClient.OnStartAnim += HandleStartAnim;
780 m_controllingClient.OnStopAnim += HandleStopAnim; 780 m_controllingClient.OnStopAnim += HandleStopAnim;
781 m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls; 781 m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls;
782 m_controllingClient.OnAutoPilotGo += DoAutoPilot; 782 m_controllingClient.OnAutoPilotGo += DoMoveToPosition;
783 m_controllingClient.AddGenericPacketHandler("autopilot", DoMoveToPosition);
784 783
785 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 784 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
786 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 785 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
@@ -1480,6 +1479,7 @@ namespace OpenSim.Region.Framework.Scenes
1480 bAllowUpdateMoveToPosition = true; 1479 bAllowUpdateMoveToPosition = true;
1481 } 1480 }
1482 } 1481 }
1482
1483 i++; 1483 i++;
1484 } 1484 }
1485 1485
@@ -1492,12 +1492,21 @@ namespace OpenSim.Region.Framework.Scenes
1492 bAllowUpdateMoveToPosition = false; 1492 bAllowUpdateMoveToPosition = false;
1493 } 1493 }
1494 1494
1495 m_log.DebugFormat(
1496 "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}",
1497 bAllowUpdateMoveToPosition, m_moveToPositionInProgress, m_autopilotMoving);
1498
1495 if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) 1499 if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving))
1496 { 1500 {
1497 //Check the error term of the current position in relation to the target position 1501 double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget);
1498 if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) 1502// m_log.DebugFormat(
1503// "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}",
1504// Name, AbsolutePosition, m_moveToPositionTarget, distanceToTarget);
1505
1506 // Check the error term of the current position in relation to the target position
1507 if (distanceToTarget <= 1)
1499 { 1508 {
1500 // we are close enough to the target 1509 // We are close enough to the target
1501 m_moveToPositionTarget = Vector3.Zero; 1510 m_moveToPositionTarget = Vector3.Zero;
1502 m_moveToPositionInProgress = false; 1511 m_moveToPositionInProgress = false;
1503 update_movementflag = true; 1512 update_movementflag = true;
@@ -1608,8 +1617,6 @@ namespace OpenSim.Region.Framework.Scenes
1608 // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); 1617 // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3);
1609 1618
1610 AddNewMovement(agent_control_v3, q); 1619 AddNewMovement(agent_control_v3, q);
1611
1612
1613 } 1620 }
1614 } 1621 }
1615 1622
@@ -1621,61 +1628,44 @@ namespace OpenSim.Region.Framework.Scenes
1621 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 1628 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
1622 } 1629 }
1623 1630
1624 public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) 1631// public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client)
1625 { 1632// {
1626 m_autopilotMoving = true; 1633// m_autopilotMoving = true;
1627 m_autoPilotTarget = Pos; 1634// m_autoPilotTarget = Pos;
1628 m_sitAtAutoTarget = false; 1635// m_sitAtAutoTarget = false;
1629 PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; 1636// PrimitiveBaseShape proxy = PrimitiveBaseShape.Default;
1630 //proxy.PCode = (byte)PCode.ParticleSystem; 1637// //proxy.PCode = (byte)PCode.ParticleSystem;
1638//
1639// proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy);
1640// proxyObjectGroup.AttachToScene(m_scene);
1641//
1642// // Commented out this code since it could never have executed, but might still be informative.
1643//// if (proxyObjectGroup != null)
1644//// {
1645// proxyObjectGroup.SendGroupFullUpdate();
1646// remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false);
1647// m_scene.DeleteSceneObject(proxyObjectGroup, false);
1648//// }
1649//// else
1650//// {
1651//// m_autopilotMoving = false;
1652//// m_autoPilotTarget = Vector3.Zero;
1653//// ControllingClient.SendAlertMessage("Autopilot cancelled");
1654//// }
1655// }
1631 1656
1632 proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); 1657 /// <summary>
1633 proxyObjectGroup.AttachToScene(m_scene); 1658 /// Move this presence to the given position over time.
1634 1659 /// </summary>
1635 // Commented out this code since it could never have executed, but might still be informative. 1660 /// <param name="pos"></param>
1636// if (proxyObjectGroup != null) 1661 public void DoMoveToPosition(uint not_used, Vector3 pos, IClientAPI remote_client)
1637// {
1638 proxyObjectGroup.SendGroupFullUpdate();
1639 remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false);
1640 m_scene.DeleteSceneObject(proxyObjectGroup, false);
1641// }
1642// else
1643// {
1644// m_autopilotMoving = false;
1645// m_autoPilotTarget = Vector3.Zero;
1646// ControllingClient.SendAlertMessage("Autopilot cancelled");
1647// }
1648 }
1649
1650 public void DoMoveToPosition(Object sender, string method, List<String> args)
1651 { 1662 {
1652 try 1663 m_log.DebugFormat(
1653 { 1664 "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}",
1654 float locx = 0f; 1665 Name, pos, m_scene.RegionInfo.RegionName);
1655 float locy = 0f; 1666
1656 float locz = 0f; 1667 m_moveToPositionInProgress = true;
1657 uint regionX = 0; 1668 m_moveToPositionTarget = pos;
1658 uint regionY = 0;
1659 try
1660 {
1661 Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY);
1662 locx = Convert.ToSingle(args[0]) - (float)regionX;
1663 locy = Convert.ToSingle(args[1]) - (float)regionY;
1664 locz = Convert.ToSingle(args[2]);
1665 }
1666 catch (InvalidCastException)
1667 {
1668 m_log.Error("[CLIENT]: Invalid autopilot request");
1669 return;
1670 }
1671 m_moveToPositionInProgress = true;
1672 m_moveToPositionTarget = new Vector3(locx, locy, locz);
1673 }
1674 catch (Exception ex)
1675 {
1676 //Why did I get this error?
1677 m_log.Error("[SCENEPRESENCE]: DoMoveToPosition" + ex);
1678 }
1679 } 1669 }
1680 1670
1681 private void CheckAtSitTarget() 1671 private void CheckAtSitTarget()
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 393f42d..d34d8e5 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -35,7 +35,7 @@ namespace OpenSim.Region.Framework.Scenes
35{ 35{
36 public class UndoState 36 public class UndoState
37 { 37 {
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 38// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39 39
40 public Vector3 Position = Vector3.Zero; 40 public Vector3 Position = Vector3.Zero;
41 public Vector3 Scale = Vector3.Zero; 41 public Vector3 Scale = Vector3.Zero;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 3afcc8d..e87993a 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -99,6 +99,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
99 { 99 {
100 100
101 } 101 }
102
102 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, 103 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
103 Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) 104 Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
104 { 105 {
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 6286dc8..8cb8318 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -140,7 +140,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC
140 { 140 {
141 ScenePresence sp; 141 ScenePresence sp;
142 scene.TryGetScenePresence(agentID, out sp); 142 scene.TryGetScenePresence(agentID, out sp);
143 sp.DoAutoPilot(0, pos, m_avatars[agentID]); 143
144// m_log.DebugFormat(
145// "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName);
146//
147// List<string> targetArgs = new List<string>();
148// targetArgs.Add(pos.X);
149// targetArgs.Add(pos.Y);
150// targetArgs.Add(pos.Z);
151// sp.DoMoveToPosition(null, "NPC", targetArgs);
152// sp.DoMoveToPosition(0, pos, m_avatars[agentID]);
144 } 153 }
145 } 154 }
146 } 155 }