diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5e80f5a..18d84a2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -109,6 +109,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | /// <summary> | ||
113 | /// This exists to prevent race conditions between two CompleteMovement threads if the simulator is slow and | ||
114 | /// the viewer fires these in quick succession. | ||
115 | /// </summary> | ||
116 | /// <remarks> | ||
117 | /// TODO: The child -> agent transition should be folded into LifecycleState and the CompleteMovement | ||
118 | /// regulation done there. | ||
119 | /// </remarks> | ||
120 | private object m_completeMovementLock = new object(); | ||
121 | |||
112 | // private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); | 122 | // private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); |
113 | private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); | 123 | private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); |
114 | private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); | 124 | private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); |
@@ -982,6 +992,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
982 | /// <summary> | 992 | /// <summary> |
983 | /// Turns a child agent into a root agent. | 993 | /// Turns a child agent into a root agent. |
984 | /// </summary> | 994 | /// </summary> |
995 | /// <remarks> | ||
985 | /// Child agents are logged into neighbouring sims largely to observe changes. Root agents exist when the | 996 | /// Child agents are logged into neighbouring sims largely to observe changes. Root agents exist when the |
986 | /// avatar is actual in the sim. They can perform all actions. | 997 | /// avatar is actual in the sim. They can perform all actions. |
987 | /// This change is made whenever an avatar enters a region, whether by crossing over from a neighbouring sim, | 998 | /// This change is made whenever an avatar enters a region, whether by crossing over from a neighbouring sim, |
@@ -989,8 +1000,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
989 | /// | 1000 | /// |
990 | /// This method is on the critical path for transferring an avatar from one region to another. Delay here | 1001 | /// This method is on the critical path for transferring an avatar from one region to another. Delay here |
991 | /// delays that crossing. | 1002 | /// delays that crossing. |
992 | /// </summary> | 1003 | /// </remarks> |
993 | private void MakeRootAgent(Vector3 pos, bool isFlying) | 1004 | private bool MakeRootAgent(Vector3 pos, bool isFlying) |
994 | { | 1005 | { |
995 | // m_log.InfoFormat( | 1006 | // m_log.InfoFormat( |
996 | // "[SCENE]: Upgrading child to root agent for {0} in {1}", | 1007 | // "[SCENE]: Upgrading child to root agent for {0} in {1}", |
@@ -1030,7 +1041,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1030 | 1041 | ||
1031 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | 1042 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); |
1032 | 1043 | ||
1033 | IsChildAgent = false; | 1044 | lock (m_completeMovementLock) |
1045 | { | ||
1046 | if (!IsChildAgent) | ||
1047 | return false; | ||
1048 | |||
1049 | IsChildAgent = false; | ||
1050 | } | ||
1034 | 1051 | ||
1035 | // Must reset this here so that a teleport to a region next to an existing region does not keep the flag | 1052 | // Must reset this here so that a teleport to a region next to an existing region does not keep the flag |
1036 | // set and prevent the close of the connection on a subsequent re-teleport. | 1053 | // set and prevent the close of the connection on a subsequent re-teleport. |
@@ -1213,6 +1230,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1213 | 1230 | ||
1214 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1231 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1215 | 1232 | ||
1233 | return true; | ||
1216 | } | 1234 | } |
1217 | 1235 | ||
1218 | public int GetStateSource() | 1236 | public int GetStateSource() |
@@ -1636,7 +1654,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1636 | } | 1654 | } |
1637 | 1655 | ||
1638 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1656 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1639 | MakeRootAgent(AbsolutePosition, flying); | 1657 | if (!MakeRootAgent(AbsolutePosition, flying)) |
1658 | { | ||
1659 | m_log.DebugFormat( | ||
1660 | "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root", | ||
1661 | Name, Scene.Name); | ||
1662 | |||
1663 | return; | ||
1664 | } | ||
1640 | 1665 | ||
1641 | // Tell the client that we're totally ready | 1666 | // Tell the client that we're totally ready |
1642 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); | 1667 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); |