diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 330 |
1 files changed, 181 insertions, 149 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 565438d..d76f029 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Timers; | 32 | using System.Timers; |
@@ -33,12 +34,12 @@ using OpenMetaverse; | |||
33 | using log4net; | 34 | using log4net; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Client; | 36 | using OpenSim.Framework.Client; |
36 | using OpenSim.Framework.Communications.Cache; | ||
37 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes.Animation; | 38 | using OpenSim.Region.Framework.Scenes.Animation; |
39 | using OpenSim.Region.Framework.Scenes.Types; | 39 | using OpenSim.Region.Framework.Scenes.Types; |
40 | using OpenSim.Region.Physics.Manager; | 40 | using OpenSim.Region.Physics.Manager; |
41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
42 | using OpenSim.Services.Interfaces; | ||
42 | 43 | ||
43 | namespace OpenSim.Region.Framework.Scenes | 44 | namespace OpenSim.Region.Framework.Scenes |
44 | { | 45 | { |
@@ -150,7 +151,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
150 | 151 | ||
151 | private float m_sitAvatarHeight = 2.0f; | 152 | private float m_sitAvatarHeight = 2.0f; |
152 | 153 | ||
153 | private float m_godlevel; | 154 | private int m_godLevel; |
155 | private int m_userLevel; | ||
154 | 156 | ||
155 | private bool m_invulnerable = true; | 157 | private bool m_invulnerable = true; |
156 | 158 | ||
@@ -225,7 +227,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
225 | private int m_lastColCount = -1; //KF: Look for Collision chnages | 227 | private int m_lastColCount = -1; //KF: Look for Collision chnages |
226 | private int m_updateCount = 0; //KF: Update Anims for a while | 228 | private int m_updateCount = 0; //KF: Update Anims for a while |
227 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 229 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
228 | |||
229 | private const int NumMovementsBetweenRayCast = 5; | 230 | private const int NumMovementsBetweenRayCast = 5; |
230 | 231 | ||
231 | private bool CameraConstraintActive; | 232 | private bool CameraConstraintActive; |
@@ -266,6 +267,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
266 | 267 | ||
267 | // For teleports and crossings callbacks | 268 | // For teleports and crossings callbacks |
268 | string m_callbackURI; | 269 | string m_callbackURI; |
270 | UUID m_originRegionID; | ||
271 | |||
269 | ulong m_rootRegionHandle; | 272 | ulong m_rootRegionHandle; |
270 | 273 | ||
271 | /// <value> | 274 | /// <value> |
@@ -302,9 +305,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
302 | get { return m_invulnerable; } | 305 | get { return m_invulnerable; } |
303 | } | 306 | } |
304 | 307 | ||
305 | public float GodLevel | 308 | public int UserLevel |
306 | { | 309 | { |
307 | get { return m_godlevel; } | 310 | get { return m_userLevel; } |
311 | } | ||
312 | |||
313 | public int GodLevel | ||
314 | { | ||
315 | get { return m_godLevel; } | ||
308 | } | 316 | } |
309 | 317 | ||
310 | public ulong RegionHandle | 318 | public ulong RegionHandle |
@@ -457,7 +465,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
457 | PhysicsActor actor = m_physicsActor; | 465 | PhysicsActor actor = m_physicsActor; |
458 | // if (actor != null) | 466 | // if (actor != null) |
459 | if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! | 467 | if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! |
460 | m_pos = actor.Position; | 468 | m_pos = actor.Position; |
461 | 469 | ||
462 | return m_parentPosition + m_pos; | 470 | return m_parentPosition + m_pos; |
463 | } | 471 | } |
@@ -655,6 +663,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
655 | set { m_flyDisabled = value; } | 663 | set { m_flyDisabled = value; } |
656 | } | 664 | } |
657 | 665 | ||
666 | public string Viewer | ||
667 | { | ||
668 | get { return m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode).Viewer; } | ||
669 | } | ||
670 | |||
658 | #endregion | 671 | #endregion |
659 | 672 | ||
660 | #region Constructor(s) | 673 | #region Constructor(s) |
@@ -678,6 +691,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
678 | m_regionInfo = reginfo; | 691 | m_regionInfo = reginfo; |
679 | m_localId = m_scene.AllocateLocalId(); | 692 | m_localId = m_scene.AllocateLocalId(); |
680 | 693 | ||
694 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); | ||
695 | |||
696 | if (account != null) | ||
697 | m_userLevel = account.UserLevel; | ||
698 | |||
681 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 699 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
682 | if (gm != null) | 700 | if (gm != null) |
683 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 701 | m_grouptitle = gm.GetGroupTitle(m_uuid); |
@@ -868,47 +886,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
868 | if (land != null) | 886 | if (land != null) |
869 | { | 887 | { |
870 | //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. | 888 | //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. |
871 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_godlevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) | 889 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_userLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) |
872 | { | 890 | { |
873 | pos = land.LandData.UserLocation; | 891 | pos = land.LandData.UserLocation; |
874 | } | 892 | } |
875 | } | 893 | } |
876 | } | 894 | } |
877 | 895 | ||
878 | if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) | 896 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
879 | { | 897 | { |
880 | Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); | ||
881 | |||
882 | if (pos.X < 0) | ||
883 | { | ||
884 | emergencyPos.X = (int)Constants.RegionSize + pos.X; | ||
885 | if (!(pos.Y < 0)) | ||
886 | emergencyPos.Y = pos.Y; | ||
887 | if (!(pos.Z < 0)) | ||
888 | emergencyPos.X = pos.X; | ||
889 | } | ||
890 | if (pos.Y < 0) | ||
891 | { | ||
892 | emergencyPos.Y = (int)Constants.RegionSize + pos.Y; | ||
893 | if (!(pos.X < 0)) | ||
894 | emergencyPos.X = pos.X; | ||
895 | if (!(pos.Z < 0)) | ||
896 | emergencyPos.Z = pos.Z; | ||
897 | } | ||
898 | if (pos.Z < 0) | ||
899 | { | ||
900 | if (!(pos.X < 0)) | ||
901 | emergencyPos.X = pos.X; | ||
902 | if (!(pos.Y < 0)) | ||
903 | emergencyPos.Y = pos.Y; | ||
904 | //Leave as 128 | ||
905 | } | ||
906 | |||
907 | m_log.WarnFormat( | 898 | m_log.WarnFormat( |
908 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", | 899 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
909 | pos, Name, UUID, emergencyPos); | 900 | pos, Name, UUID); |
910 | 901 | ||
911 | pos = emergencyPos; | 902 | if (pos.X < 0f) pos.X = 0f; |
903 | if (pos.Y < 0f) pos.Y = 0f; | ||
904 | if (pos.Z < 0f) pos.Z = 0f; | ||
912 | } | 905 | } |
913 | 906 | ||
914 | float localAVHeight = 1.56f; | 907 | float localAVHeight = 1.56f; |
@@ -919,7 +912,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
919 | 912 | ||
920 | float posZLimit = 0; | 913 | float posZLimit = 0; |
921 | 914 | ||
922 | if (pos.X <Constants.RegionSize && pos.Y < Constants.RegionSize) | 915 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
923 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 916 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
924 | 917 | ||
925 | float newPosZ = posZLimit + localAVHeight / 2; | 918 | float newPosZ = posZLimit + localAVHeight / 2; |
@@ -971,14 +964,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
971 | 964 | ||
972 | m_isChildAgent = false; | 965 | m_isChildAgent = false; |
973 | 966 | ||
974 | ScenePresence[] animAgents = m_scene.GetScenePresences(); | 967 | // send the animations of the other presences to me |
975 | for (int i = 0; i < animAgents.Length; i++) | 968 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) |
976 | { | 969 | { |
977 | ScenePresence presence = animAgents[i]; | ||
978 | |||
979 | if (presence != this) | 970 | if (presence != this) |
980 | presence.Animator.SendAnimPackToClient(ControllingClient); | 971 | presence.Animator.SendAnimPackToClient(ControllingClient); |
981 | } | 972 | }); |
982 | 973 | ||
983 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 974 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
984 | } | 975 | } |
@@ -1162,8 +1153,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1162 | /// This is called upon a very important packet sent from the client, | 1153 | /// This is called upon a very important packet sent from the client, |
1163 | /// so it's client-controlled. Never call this method directly. | 1154 | /// so it's client-controlled. Never call this method directly. |
1164 | /// </summary> | 1155 | /// </summary> |
1165 | public void CompleteMovement() | 1156 | public void CompleteMovement(IClientAPI client) |
1166 | { | 1157 | { |
1158 | //m_log.Debug("[SCENE PRESENCE]: CompleteMovement"); | ||
1159 | |||
1167 | Vector3 look = Velocity; | 1160 | Vector3 look = Velocity; |
1168 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1161 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1169 | { | 1162 | { |
@@ -1188,7 +1181,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1188 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) | 1181 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) |
1189 | { | 1182 | { |
1190 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); | 1183 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); |
1191 | Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); | 1184 | Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); |
1192 | m_callbackURI = null; | 1185 | m_callbackURI = null; |
1193 | } | 1186 | } |
1194 | 1187 | ||
@@ -1196,6 +1189,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1196 | 1189 | ||
1197 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); | 1190 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); |
1198 | SendInitialData(); | 1191 | SendInitialData(); |
1192 | |||
1193 | // Create child agents in neighbouring regions | ||
1194 | if (!m_isChildAgent) | ||
1195 | { | ||
1196 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | ||
1197 | if (m_agentTransfer != null) | ||
1198 | m_agentTransfer.EnableChildAgents(this); | ||
1199 | else | ||
1200 | m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); | ||
1201 | |||
1202 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | ||
1203 | if (friendsModule != null) | ||
1204 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | ||
1205 | } | ||
1206 | |||
1199 | } | 1207 | } |
1200 | 1208 | ||
1201 | /// <summary> | 1209 | /// <summary> |
@@ -1264,6 +1272,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1264 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); | 1272 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); |
1265 | 1273 | ||
1266 | m_pos = m_LastFinitePos; | 1274 | m_pos = m_LastFinitePos; |
1275 | |||
1267 | if (!m_pos.IsFinite()) | 1276 | if (!m_pos.IsFinite()) |
1268 | { | 1277 | { |
1269 | m_pos.X = 127f; | 1278 | m_pos.X = 127f; |
@@ -1900,6 +1909,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1900 | { | 1909 | { |
1901 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center | 1910 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center |
1902 | autopilotTarget = part.AbsolutePosition; | 1911 | autopilotTarget = part.AbsolutePosition; |
1912 | //Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); | ||
1903 | } | 1913 | } |
1904 | else return; // occupied small | 1914 | else return; // occupied small |
1905 | } // end large/small | 1915 | } // end large/small |
@@ -2276,7 +2286,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2276 | m_pos += SIT_TARGET_ADJUSTMENT; | 2286 | m_pos += SIT_TARGET_ADJUSTMENT; |
2277 | m_bodyRot = sitTargetOrient; | 2287 | m_bodyRot = sitTargetOrient; |
2278 | m_parentPosition = part.AbsolutePosition; | 2288 | m_parentPosition = part.AbsolutePosition; |
2279 | part.IsOccupied = true; | 2289 | part.IsOccupied = true; |
2290 | Console.WriteLine("Scripted Sit ofset {0}", m_pos); | ||
2280 | } | 2291 | } |
2281 | else | 2292 | else |
2282 | { | 2293 | { |
@@ -2398,6 +2409,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2398 | { | 2409 | { |
2399 | if (m_isChildAgent) | 2410 | if (m_isChildAgent) |
2400 | { | 2411 | { |
2412 | // WHAT??? | ||
2401 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); | 2413 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); |
2402 | 2414 | ||
2403 | // we have to reset the user's child agent connections. | 2415 | // we have to reset the user's child agent connections. |
@@ -2421,7 +2433,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2421 | 2433 | ||
2422 | if (m_scene.SceneGridService != null) | 2434 | if (m_scene.SceneGridService != null) |
2423 | { | 2435 | { |
2424 | m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); | 2436 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
2437 | if (m_agentTransfer != null) | ||
2438 | m_agentTransfer.EnableChildAgents(this); | ||
2425 | } | 2439 | } |
2426 | 2440 | ||
2427 | return; | 2441 | return; |
@@ -2597,35 +2611,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
2597 | 2611 | ||
2598 | List<Vector3> CoarseLocations = new List<Vector3>(); | 2612 | List<Vector3> CoarseLocations = new List<Vector3>(); |
2599 | List<UUID> AvatarUUIDs = new List<UUID>(); | 2613 | List<UUID> AvatarUUIDs = new List<UUID>(); |
2600 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 2614 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) |
2601 | for (int i = 0; i < avatars.Count; i++) | ||
2602 | { | 2615 | { |
2603 | // Requested by LibOMV. Send Course Location on self. | 2616 | if (sp.IsChildAgent) |
2604 | //if (avatars[i] != this) | 2617 | return; |
2605 | //{ | 2618 | |
2606 | if (avatars[i].ParentID != 0) | 2619 | if (sp.ParentID != 0) |
2620 | { | ||
2621 | // sitting avatar | ||
2622 | SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID); | ||
2623 | if (sop != null) | ||
2607 | { | 2624 | { |
2608 | // sitting avatar | 2625 | CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos); |
2609 | SceneObjectPart sop = m_scene.GetSceneObjectPart(avatars[i].ParentID); | 2626 | AvatarUUIDs.Add(sp.UUID); |
2610 | if (sop != null) | ||
2611 | { | ||
2612 | CoarseLocations.Add(sop.AbsolutePosition + avatars[i].m_pos); | ||
2613 | AvatarUUIDs.Add(avatars[i].UUID); | ||
2614 | } | ||
2615 | else | ||
2616 | { | ||
2617 | // we can't find the parent.. ! arg! | ||
2618 | CoarseLocations.Add(avatars[i].m_pos); | ||
2619 | AvatarUUIDs.Add(avatars[i].UUID); | ||
2620 | } | ||
2621 | } | 2627 | } |
2622 | else | 2628 | else |
2623 | { | 2629 | { |
2624 | CoarseLocations.Add(avatars[i].m_pos); | 2630 | // we can't find the parent.. ! arg! |
2625 | AvatarUUIDs.Add(avatars[i].UUID); | 2631 | CoarseLocations.Add(sp.m_pos); |
2632 | AvatarUUIDs.Add(sp.UUID); | ||
2626 | } | 2633 | } |
2627 | //} | 2634 | } |
2628 | } | 2635 | else |
2636 | { | ||
2637 | CoarseLocations.Add(sp.m_pos); | ||
2638 | AvatarUUIDs.Add(sp.UUID); | ||
2639 | } | ||
2640 | }); | ||
2629 | 2641 | ||
2630 | m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); | 2642 | m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); |
2631 | 2643 | ||
@@ -2667,13 +2679,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2667 | public void SendInitialFullUpdateToAllClients() | 2679 | public void SendInitialFullUpdateToAllClients() |
2668 | { | 2680 | { |
2669 | m_perfMonMS = Util.EnvironmentTickCount(); | 2681 | m_perfMonMS = Util.EnvironmentTickCount(); |
2670 | 2682 | int avUpdates = 0; | |
2671 | ScenePresence[] avatars = m_scene.GetScenePresences(); | 2683 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) |
2672 | |||
2673 | for (int i = 0; i < avatars.Length; i++) | ||
2674 | { | 2684 | { |
2675 | ScenePresence avatar = avatars[i]; | 2685 | ++avUpdates; |
2676 | |||
2677 | // only send if this is the root (children are only "listening posts" in a foreign region) | 2686 | // only send if this is the root (children are only "listening posts" in a foreign region) |
2678 | if (!IsChildAgent) | 2687 | if (!IsChildAgent) |
2679 | { | 2688 | { |
@@ -2689,9 +2698,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2689 | avatar.Animator.SendAnimPackToClient(ControllingClient); | 2698 | avatar.Animator.SendAnimPackToClient(ControllingClient); |
2690 | } | 2699 | } |
2691 | } | 2700 | } |
2692 | } | 2701 | }); |
2693 | 2702 | ||
2694 | m_scene.StatsReporter.AddAgentUpdates(avatars.Length); | 2703 | m_scene.StatsReporter.AddAgentUpdates(avUpdates); |
2695 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2704 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2696 | 2705 | ||
2697 | //Animator.SendAnimPack(); | 2706 | //Animator.SendAnimPack(); |
@@ -2702,13 +2711,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2702 | m_perfMonMS = Util.EnvironmentTickCount(); | 2711 | m_perfMonMS = Util.EnvironmentTickCount(); |
2703 | 2712 | ||
2704 | // only send update from root agents to other clients; children are only "listening posts" | 2713 | // only send update from root agents to other clients; children are only "listening posts" |
2705 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 2714 | int count = 0; |
2706 | foreach (ScenePresence avatar in avatars) | 2715 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) |
2707 | { | 2716 | { |
2708 | SendFullUpdateToOtherClient(avatar); | 2717 | if (sp.IsChildAgent) |
2709 | 2718 | return; | |
2710 | } | 2719 | SendFullUpdateToOtherClient(sp); |
2711 | m_scene.StatsReporter.AddAgentUpdates(avatars.Count); | 2720 | ++count; |
2721 | }); | ||
2722 | m_scene.StatsReporter.AddAgentUpdates(count); | ||
2712 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2723 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2713 | 2724 | ||
2714 | Animator.SendAnimPack(); | 2725 | Animator.SendAnimPack(); |
@@ -2729,14 +2740,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2729 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, | 2740 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, |
2730 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); | 2741 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); |
2731 | 2742 | ||
2732 | if (!m_isChildAgent) | ||
2733 | { | ||
2734 | m_scene.InformClientOfNeighbours(this); | ||
2735 | } | ||
2736 | |||
2737 | SendInitialFullUpdateToAllClients(); | 2743 | SendInitialFullUpdateToAllClients(); |
2738 | SendAppearanceToAllOtherAgents(); | 2744 | SendAppearanceToAllOtherAgents(); |
2739 | } | 2745 | } |
2740 | 2746 | ||
2741 | /// <summary> | 2747 | /// <summary> |
2742 | /// Tell the client for this scene presence what items it should be wearing now | 2748 | /// Tell the client for this scene presence what items it should be wearing now |
@@ -2818,14 +2824,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2818 | } | 2824 | } |
2819 | } | 2825 | } |
2820 | } | 2826 | } |
2827 | |||
2821 | } | 2828 | } |
2822 | 2829 | ||
2830 | |||
2823 | #endregion Bake Cache Check | 2831 | #endregion Bake Cache Check |
2824 | 2832 | ||
2825 | m_appearance.SetAppearance(textureEntry, visualParams); | 2833 | m_appearance.SetAppearance(textureEntry, visualParams); |
2826 | if (m_appearance.AvatarHeight > 0) | 2834 | if (m_appearance.AvatarHeight > 0) |
2827 | SetHeight(m_appearance.AvatarHeight); | 2835 | SetHeight(m_appearance.AvatarHeight); |
2828 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); | 2836 | |
2837 | // This is not needed, because only the transient data changed | ||
2838 | //AvatarData adata = new AvatarData(m_appearance); | ||
2839 | //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); | ||
2829 | 2840 | ||
2830 | SendAppearanceToAllOtherAgents(); | 2841 | SendAppearanceToAllOtherAgents(); |
2831 | if (!m_startAnimationSet) | 2842 | if (!m_startAnimationSet) |
@@ -2845,7 +2856,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2845 | public void SetWearable(int wearableId, AvatarWearable wearable) | 2856 | public void SetWearable(int wearableId, AvatarWearable wearable) |
2846 | { | 2857 | { |
2847 | m_appearance.SetWearable(wearableId, wearable); | 2858 | m_appearance.SetWearable(wearableId, wearable); |
2848 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); | 2859 | AvatarData adata = new AvatarData(m_appearance); |
2860 | m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); | ||
2849 | m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); | 2861 | m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); |
2850 | } | 2862 | } |
2851 | 2863 | ||
@@ -2867,7 +2879,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2867 | /// </summary> | 2879 | /// </summary> |
2868 | protected void CheckForSignificantMovement() | 2880 | protected void CheckForSignificantMovement() |
2869 | { | 2881 | { |
2870 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.5) | 2882 | // Movement updates for agents in neighboring regions are sent directly to clients. |
2883 | // This value only affects how often agent positions are sent to neighbor regions | ||
2884 | // for things such as distance-based update prioritization | ||
2885 | const float SIGNIFICANT_MOVEMENT = 2.0f; | ||
2886 | |||
2887 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) | ||
2871 | { | 2888 | { |
2872 | posLastSignificantMove = AbsolutePosition; | 2889 | posLastSignificantMove = AbsolutePosition; |
2873 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); | 2890 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); |
@@ -2878,18 +2895,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2878 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || | 2895 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || |
2879 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) | 2896 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) |
2880 | { | 2897 | { |
2898 | m_lastChildAgentUpdatePosition = AbsolutePosition; | ||
2899 | m_lastChildAgentUpdateCamPosition = CameraPosition; | ||
2900 | |||
2881 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | 2901 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); |
2882 | cadu.ActiveGroupID = UUID.Zero.Guid; | 2902 | cadu.ActiveGroupID = UUID.Zero.Guid; |
2883 | cadu.AgentID = UUID.Guid; | 2903 | cadu.AgentID = UUID.Guid; |
2884 | cadu.alwaysrun = m_setAlwaysRun; | 2904 | cadu.alwaysrun = m_setAlwaysRun; |
2885 | cadu.AVHeight = m_avHeight; | 2905 | cadu.AVHeight = m_avHeight; |
2886 | sLLVector3 tempCameraCenter = new sLLVector3(new Vector3(m_CameraCenter.X, m_CameraCenter.Y, m_CameraCenter.Z)); | 2906 | Vector3 tempCameraCenter = m_CameraCenter; |
2887 | cadu.cameraPosition = tempCameraCenter; | 2907 | cadu.cameraPosition = tempCameraCenter; |
2888 | cadu.drawdistance = m_DrawDistance; | 2908 | cadu.drawdistance = m_DrawDistance; |
2889 | if (m_scene.Permissions.IsGod(new UUID(cadu.AgentID))) | ||
2890 | cadu.godlevel = m_godlevel; | ||
2891 | cadu.GroupAccess = 0; | 2909 | cadu.GroupAccess = 0; |
2892 | cadu.Position = new sLLVector3(AbsolutePosition); | 2910 | cadu.Position = AbsolutePosition; |
2893 | cadu.regionHandle = m_rootRegionHandle; | 2911 | cadu.regionHandle = m_rootRegionHandle; |
2894 | float multiplier = 1; | 2912 | float multiplier = 1; |
2895 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); | 2913 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); |
@@ -2904,15 +2922,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2904 | 2922 | ||
2905 | //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); | 2923 | //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); |
2906 | cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); | 2924 | cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); |
2907 | cadu.Velocity = new sLLVector3(Velocity); | 2925 | cadu.Velocity = Velocity; |
2908 | 2926 | ||
2909 | AgentPosition agentpos = new AgentPosition(); | 2927 | AgentPosition agentpos = new AgentPosition(); |
2910 | agentpos.CopyFrom(cadu); | 2928 | agentpos.CopyFrom(cadu); |
2911 | 2929 | ||
2912 | m_scene.SendOutChildAgentUpdates(agentpos, this); | 2930 | m_scene.SendOutChildAgentUpdates(agentpos, this); |
2913 | |||
2914 | m_lastChildAgentUpdatePosition = AbsolutePosition; | ||
2915 | m_lastChildAgentUpdateCamPosition = CameraPosition; | ||
2916 | } | 2931 | } |
2917 | } | 2932 | } |
2918 | 2933 | ||
@@ -3168,18 +3183,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3168 | // For now, assign god level 200 to anyone | 3183 | // For now, assign god level 200 to anyone |
3169 | // who is granted god powers, but has no god level set. | 3184 | // who is granted god powers, but has no god level set. |
3170 | // | 3185 | // |
3171 | CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); | 3186 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID); |
3172 | if (profile.UserProfile.GodLevel > 0) | 3187 | if (account != null) |
3173 | m_godlevel = profile.UserProfile.GodLevel; | 3188 | { |
3174 | else | 3189 | if (account.UserLevel > 0) |
3175 | m_godlevel = 200; | 3190 | m_godLevel = account.UserLevel; |
3191 | else | ||
3192 | m_godLevel = 200; | ||
3193 | } | ||
3176 | } | 3194 | } |
3177 | else | 3195 | else |
3178 | { | 3196 | { |
3179 | m_godlevel = 0; | 3197 | m_godLevel = 0; |
3180 | } | 3198 | } |
3181 | 3199 | ||
3182 | ControllingClient.SendAdminResponse(token, (uint)m_godlevel); | 3200 | ControllingClient.SendAdminResponse(token, (uint)m_godLevel); |
3183 | } | 3201 | } |
3184 | 3202 | ||
3185 | #region Child Agent Updates | 3203 | #region Child Agent Updates |
@@ -3238,7 +3256,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3238 | public void CopyTo(AgentData cAgent) | 3256 | public void CopyTo(AgentData cAgent) |
3239 | { | 3257 | { |
3240 | cAgent.AgentID = UUID; | 3258 | cAgent.AgentID = UUID; |
3241 | cAgent.RegionHandle = m_rootRegionHandle; | 3259 | cAgent.RegionID = Scene.RegionInfo.RegionID; |
3242 | 3260 | ||
3243 | cAgent.Position = AbsolutePosition; | 3261 | cAgent.Position = AbsolutePosition; |
3244 | cAgent.Velocity = m_velocity; | 3262 | cAgent.Velocity = m_velocity; |
@@ -3270,7 +3288,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3270 | cAgent.ControlFlags = (uint)m_AgentControlFlags; | 3288 | cAgent.ControlFlags = (uint)m_AgentControlFlags; |
3271 | 3289 | ||
3272 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3290 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3273 | cAgent.GodLevel = (byte)m_godlevel; | 3291 | cAgent.GodLevel = (byte)m_godLevel; |
3274 | else | 3292 | else |
3275 | cAgent.GodLevel = (byte) 0; | 3293 | cAgent.GodLevel = (byte) 0; |
3276 | 3294 | ||
@@ -3337,11 +3355,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3337 | 3355 | ||
3338 | public void CopyFrom(AgentData cAgent) | 3356 | public void CopyFrom(AgentData cAgent) |
3339 | { | 3357 | { |
3340 | m_rootRegionHandle = cAgent.RegionHandle; | 3358 | m_originRegionID = cAgent.RegionID; |
3341 | 3359 | ||
3342 | m_callbackURI = cAgent.CallbackURI; | 3360 | m_callbackURI = cAgent.CallbackURI; |
3343 | 3361 | ||
3344 | m_pos = cAgent.Position; | 3362 | m_pos = cAgent.Position; |
3363 | |||
3345 | m_velocity = cAgent.Velocity; | 3364 | m_velocity = cAgent.Velocity; |
3346 | m_CameraCenter = cAgent.Center; | 3365 | m_CameraCenter = cAgent.Center; |
3347 | //m_avHeight = cAgent.Size.Z; | 3366 | //m_avHeight = cAgent.Size.Z; |
@@ -3359,7 +3378,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3359 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; | 3378 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; |
3360 | 3379 | ||
3361 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3380 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3362 | m_godlevel = cAgent.GodLevel; | 3381 | m_godLevel = cAgent.GodLevel; |
3363 | m_setAlwaysRun = cAgent.AlwaysRun; | 3382 | m_setAlwaysRun = cAgent.AlwaysRun; |
3364 | 3383 | ||
3365 | uint i = 0; | 3384 | uint i = 0; |
@@ -3717,36 +3736,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3717 | } | 3736 | } |
3718 | } | 3737 | } |
3719 | 3738 | ||
3720 | public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent) | ||
3721 | { | ||
3722 | lock (m_attachments) | ||
3723 | { | ||
3724 | // Validate | ||
3725 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3726 | { | ||
3727 | if (gobj == null || gobj.IsDeleted) | ||
3728 | return false; | ||
3729 | } | ||
3730 | |||
3731 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3732 | { | ||
3733 | // If the prim group is null then something must have happened to it! | ||
3734 | if (gobj != null && gobj.RootPart != null) | ||
3735 | { | ||
3736 | // Set the parent localID to 0 so it transfers over properly. | ||
3737 | gobj.RootPart.SetParentLocalId(0); | ||
3738 | gobj.AbsolutePosition = gobj.RootPart.AttachedPos; | ||
3739 | gobj.RootPart.IsAttachment = false; | ||
3740 | //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); | ||
3741 | m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle); | ||
3742 | m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent); | ||
3743 | } | ||
3744 | } | ||
3745 | m_attachments.Clear(); | ||
3746 | |||
3747 | return true; | ||
3748 | } | ||
3749 | } | ||
3750 | 3739 | ||
3751 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) | 3740 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) |
3752 | { | 3741 | { |
@@ -3982,10 +3971,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
3982 | { | 3971 | { |
3983 | if (null == m_appearance) | 3972 | if (null == m_appearance) |
3984 | { | 3973 | { |
3985 | m_log.WarnFormat("[ATTACHMENT] Appearance has not been initialized for agent {0}", UUID); | 3974 | m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID); |
3986 | return; | 3975 | return; |
3987 | } | 3976 | } |
3988 | 3977 | ||
3978 | XmlDocument doc = new XmlDocument(); | ||
3979 | string stateData = String.Empty; | ||
3980 | |||
3981 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | ||
3982 | if (attServ != null) | ||
3983 | { | ||
3984 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | ||
3985 | stateData = attServ.Get(ControllingClient.AgentId.ToString()); | ||
3986 | doc.LoadXml(stateData); | ||
3987 | } | ||
3988 | |||
3989 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | ||
3990 | |||
3991 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | ||
3992 | if (nodes.Count > 0) | ||
3993 | { | ||
3994 | foreach (XmlNode n in nodes) | ||
3995 | { | ||
3996 | XmlElement elem = (XmlElement)n; | ||
3997 | string itemID = elem.GetAttribute("ItemID"); | ||
3998 | string xml = elem.InnerXml; | ||
3999 | |||
4000 | itemData[new UUID(itemID)] = xml; | ||
4001 | } | ||
4002 | } | ||
4003 | |||
3989 | List<int> attPoints = m_appearance.GetAttachedPoints(); | 4004 | List<int> attPoints = m_appearance.GetAttachedPoints(); |
3990 | foreach (int p in attPoints) | 4005 | foreach (int p in attPoints) |
3991 | { | 4006 | { |
@@ -4005,13 +4020,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
4005 | 4020 | ||
4006 | try | 4021 | try |
4007 | { | 4022 | { |
4008 | // Rez from inventory | 4023 | string xmlData; |
4009 | UUID asset = m_scene.RezSingleAttachment(ControllingClient, | 4024 | XmlDocument d = new XmlDocument(); |
4010 | itemID, (uint)p); | 4025 | UUID asset; |
4026 | if (itemData.TryGetValue(itemID, out xmlData)) | ||
4027 | { | ||
4028 | d.LoadXml(xmlData); | ||
4029 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); | ||
4030 | |||
4031 | // Rez from inventory | ||
4032 | asset | ||
4033 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); | ||
4011 | 4034 | ||
4012 | m_log.InfoFormat("[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", | 4035 | } |
4013 | p, itemID, assetID, asset); | 4036 | else |
4037 | { | ||
4038 | // Rez from inventory (with a null doc to let | ||
4039 | // CHANGED_OWNER happen) | ||
4040 | asset | ||
4041 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); | ||
4042 | } | ||
4014 | 4043 | ||
4044 | m_log.InfoFormat( | ||
4045 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", | ||
4046 | p, itemID, assetID, asset); | ||
4015 | } | 4047 | } |
4016 | catch (Exception e) | 4048 | catch (Exception e) |
4017 | { | 4049 | { |