aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs279
1 files changed, 131 insertions, 148 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 2603fe1..5c54616 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -33,12 +33,12 @@ using OpenMetaverse;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Client; 35using OpenSim.Framework.Client;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes.Animation; 37using OpenSim.Region.Framework.Scenes.Animation;
39using OpenSim.Region.Framework.Scenes.Types; 38using OpenSim.Region.Framework.Scenes.Types;
40using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.Physics.Manager;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenSim.Services.Interfaces;
42 42
43namespace OpenSim.Region.Framework.Scenes 43namespace OpenSim.Region.Framework.Scenes
44{ 44{
@@ -150,7 +150,8 @@ namespace OpenSim.Region.Framework.Scenes
150 150
151 private float m_sitAvatarHeight = 2.0f; 151 private float m_sitAvatarHeight = 2.0f;
152 152
153 private float m_godlevel; 153 private int m_godLevel;
154 private int m_userLevel;
154 155
155 private bool m_invulnerable = true; 156 private bool m_invulnerable = true;
156 157
@@ -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
309 {
310 get { return m_userLevel; }
311 }
312
313 public int GodLevel
306 { 314 {
307 get { return m_godlevel; } 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 }
@@ -678,6 +686,11 @@ namespace OpenSim.Region.Framework.Scenes
678 m_regionInfo = reginfo; 686 m_regionInfo = reginfo;
679 m_localId = m_scene.AllocateLocalId(); 687 m_localId = m_scene.AllocateLocalId();
680 688
689 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid);
690
691 if (account != null)
692 m_userLevel = account.UserLevel;
693
681 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 694 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
682 if (gm != null) 695 if (gm != null)
683 m_grouptitle = gm.GetGroupTitle(m_uuid); 696 m_grouptitle = gm.GetGroupTitle(m_uuid);
@@ -868,47 +881,22 @@ namespace OpenSim.Region.Framework.Scenes
868 if (land != null) 881 if (land != null)
869 { 882 {
870 //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. 883 //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) 884 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 { 885 {
873 pos = land.LandData.UserLocation; 886 pos = land.LandData.UserLocation;
874 } 887 }
875 } 888 }
876 } 889 }
877 890
878 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) 891 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
879 { 892 {
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( 893 m_log.WarnFormat(
908 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", 894 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping",
909 pos, Name, UUID, emergencyPos); 895 pos, Name, UUID);
910 896
911 pos = emergencyPos; 897 if (pos.X < 0f) pos.X = 0f;
898 if (pos.Y < 0f) pos.Y = 0f;
899 if (pos.Z < 0f) pos.Z = 0f;
912 } 900 }
913 901
914 float localAVHeight = 1.56f; 902 float localAVHeight = 1.56f;
@@ -919,7 +907,7 @@ namespace OpenSim.Region.Framework.Scenes
919 907
920 float posZLimit = 0; 908 float posZLimit = 0;
921 909
922 if (pos.X <Constants.RegionSize && pos.Y < Constants.RegionSize) 910 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
923 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 911 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
924 912
925 float newPosZ = posZLimit + localAVHeight / 2; 913 float newPosZ = posZLimit + localAVHeight / 2;
@@ -971,14 +959,11 @@ namespace OpenSim.Region.Framework.Scenes
971 959
972 m_isChildAgent = false; 960 m_isChildAgent = false;
973 961
974 ScenePresence[] animAgents = m_scene.GetScenePresences(); 962 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
975 for (int i = 0; i < animAgents.Length; i++)
976 { 963 {
977 ScenePresence presence = animAgents[i];
978
979 if (presence != this) 964 if (presence != this)
980 presence.Animator.SendAnimPackToClient(ControllingClient); 965 presence.Animator.SendAnimPackToClient(ControllingClient);
981 } 966 });
982 967
983 m_scene.EventManager.TriggerOnMakeRootAgent(this); 968 m_scene.EventManager.TriggerOnMakeRootAgent(this);
984 } 969 }
@@ -1162,8 +1147,10 @@ namespace OpenSim.Region.Framework.Scenes
1162 /// This is called upon a very important packet sent from the client, 1147 /// This is called upon a very important packet sent from the client,
1163 /// so it's client-controlled. Never call this method directly. 1148 /// so it's client-controlled. Never call this method directly.
1164 /// </summary> 1149 /// </summary>
1165 public void CompleteMovement() 1150 public void CompleteMovement(IClientAPI client)
1166 { 1151 {
1152 //m_log.Debug("[SCENE PRESENCE]: CompleteMovement");
1153
1167 Vector3 look = Velocity; 1154 Vector3 look = Velocity;
1168 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1155 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1169 { 1156 {
@@ -1188,7 +1175,7 @@ namespace OpenSim.Region.Framework.Scenes
1188 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1175 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1189 { 1176 {
1190 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1177 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
1191 Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); 1178 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1192 m_callbackURI = null; 1179 m_callbackURI = null;
1193 } 1180 }
1194 1181
@@ -1196,6 +1183,21 @@ namespace OpenSim.Region.Framework.Scenes
1196 1183
1197 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 1184 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
1198 SendInitialData(); 1185 SendInitialData();
1186
1187 // Create child agents in neighbouring regions
1188 if (!m_isChildAgent)
1189 {
1190 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1191 if (m_agentTransfer != null)
1192 m_agentTransfer.EnableChildAgents(this);
1193 else
1194 m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active");
1195
1196 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1197 if (friendsModule != null)
1198 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1199 }
1200
1199 } 1201 }
1200 1202
1201 /// <summary> 1203 /// <summary>
@@ -1264,6 +1266,7 @@ namespace OpenSim.Region.Framework.Scenes
1264 m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); 1266 m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902");
1265 1267
1266 m_pos = m_LastFinitePos; 1268 m_pos = m_LastFinitePos;
1269
1267 if (!m_pos.IsFinite()) 1270 if (!m_pos.IsFinite())
1268 { 1271 {
1269 m_pos.X = 127f; 1272 m_pos.X = 127f;
@@ -1901,6 +1904,7 @@ namespace OpenSim.Region.Framework.Scenes
1901 { 1904 {
1902 m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center 1905 m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center
1903 autopilotTarget = part.AbsolutePosition; 1906 autopilotTarget = part.AbsolutePosition;
1907//Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget);
1904 } 1908 }
1905 else return; // occupied small 1909 else return; // occupied small
1906 } // end large/small 1910 } // end large/small
@@ -2277,7 +2281,8 @@ namespace OpenSim.Region.Framework.Scenes
2277 m_pos += SIT_TARGET_ADJUSTMENT; 2281 m_pos += SIT_TARGET_ADJUSTMENT;
2278 m_bodyRot = sitTargetOrient; 2282 m_bodyRot = sitTargetOrient;
2279 m_parentPosition = part.AbsolutePosition; 2283 m_parentPosition = part.AbsolutePosition;
2280 part.IsOccupied = true; 2284 part.IsOccupied = true;
2285Console.WriteLine("Scripted Sit ofset {0}", m_pos);
2281 } 2286 }
2282 else 2287 else
2283 { 2288 {
@@ -2399,6 +2404,7 @@ namespace OpenSim.Region.Framework.Scenes
2399 { 2404 {
2400 if (m_isChildAgent) 2405 if (m_isChildAgent)
2401 { 2406 {
2407 // WHAT???
2402 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); 2408 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!");
2403 2409
2404 // we have to reset the user's child agent connections. 2410 // we have to reset the user's child agent connections.
@@ -2422,7 +2428,9 @@ namespace OpenSim.Region.Framework.Scenes
2422 2428
2423 if (m_scene.SceneGridService != null) 2429 if (m_scene.SceneGridService != null)
2424 { 2430 {
2425 m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); 2431 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
2432 if (m_agentTransfer != null)
2433 m_agentTransfer.EnableChildAgents(this);
2426 } 2434 }
2427 2435
2428 return; 2436 return;
@@ -2590,35 +2598,33 @@ namespace OpenSim.Region.Framework.Scenes
2590 2598
2591 List<Vector3> CoarseLocations = new List<Vector3>(); 2599 List<Vector3> CoarseLocations = new List<Vector3>();
2592 List<UUID> AvatarUUIDs = new List<UUID>(); 2600 List<UUID> AvatarUUIDs = new List<UUID>();
2593 List<ScenePresence> avatars = m_scene.GetAvatars(); 2601 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2594 for (int i = 0; i < avatars.Count; i++)
2595 { 2602 {
2596 // Requested by LibOMV. Send Course Location on self. 2603 if (sp.IsChildAgent)
2597 //if (avatars[i] != this) 2604 return;
2598 //{ 2605
2599 if (avatars[i].ParentID != 0) 2606 if (sp.ParentID != 0)
2607 {
2608 // sitting avatar
2609 SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID);
2610 if (sop != null)
2600 { 2611 {
2601 // sitting avatar 2612 CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos);
2602 SceneObjectPart sop = m_scene.GetSceneObjectPart(avatars[i].ParentID); 2613 AvatarUUIDs.Add(sp.UUID);
2603 if (sop != null)
2604 {
2605 CoarseLocations.Add(sop.AbsolutePosition + avatars[i].m_pos);
2606 AvatarUUIDs.Add(avatars[i].UUID);
2607 }
2608 else
2609 {
2610 // we can't find the parent.. ! arg!
2611 CoarseLocations.Add(avatars[i].m_pos);
2612 AvatarUUIDs.Add(avatars[i].UUID);
2613 }
2614 } 2614 }
2615 else 2615 else
2616 { 2616 {
2617 CoarseLocations.Add(avatars[i].m_pos); 2617 // we can't find the parent.. ! arg!
2618 AvatarUUIDs.Add(avatars[i].UUID); 2618 CoarseLocations.Add(sp.m_pos);
2619 AvatarUUIDs.Add(sp.UUID);
2619 } 2620 }
2620 //} 2621 }
2621 } 2622 else
2623 {
2624 CoarseLocations.Add(sp.m_pos);
2625 AvatarUUIDs.Add(sp.UUID);
2626 }
2627 });
2622 2628
2623 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); 2629 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations);
2624 2630
@@ -2660,13 +2666,10 @@ namespace OpenSim.Region.Framework.Scenes
2660 public void SendInitialFullUpdateToAllClients() 2666 public void SendInitialFullUpdateToAllClients()
2661 { 2667 {
2662 m_perfMonMS = Util.EnvironmentTickCount(); 2668 m_perfMonMS = Util.EnvironmentTickCount();
2663 2669 int avUpdates = 0;
2664 ScenePresence[] avatars = m_scene.GetScenePresences(); 2670 m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
2665
2666 for (int i = 0; i < avatars.Length; i++)
2667 { 2671 {
2668 ScenePresence avatar = avatars[i]; 2672 ++avUpdates;
2669
2670 // only send if this is the root (children are only "listening posts" in a foreign region) 2673 // only send if this is the root (children are only "listening posts" in a foreign region)
2671 if (!IsChildAgent) 2674 if (!IsChildAgent)
2672 { 2675 {
@@ -2682,9 +2685,9 @@ namespace OpenSim.Region.Framework.Scenes
2682 avatar.Animator.SendAnimPackToClient(ControllingClient); 2685 avatar.Animator.SendAnimPackToClient(ControllingClient);
2683 } 2686 }
2684 } 2687 }
2685 } 2688 });
2686 2689
2687 m_scene.StatsReporter.AddAgentUpdates(avatars.Length); 2690 m_scene.StatsReporter.AddAgentUpdates(avUpdates);
2688 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2691 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2689 2692
2690 //Animator.SendAnimPack(); 2693 //Animator.SendAnimPack();
@@ -2695,13 +2698,15 @@ namespace OpenSim.Region.Framework.Scenes
2695 m_perfMonMS = Util.EnvironmentTickCount(); 2698 m_perfMonMS = Util.EnvironmentTickCount();
2696 2699
2697 // only send update from root agents to other clients; children are only "listening posts" 2700 // only send update from root agents to other clients; children are only "listening posts"
2698 List<ScenePresence> avatars = m_scene.GetAvatars(); 2701 int count = 0;
2699 foreach (ScenePresence avatar in avatars) 2702 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2700 { 2703 {
2701 SendFullUpdateToOtherClient(avatar); 2704 if (sp.IsChildAgent)
2702 2705 return;
2703 } 2706 SendFullUpdateToOtherClient(sp);
2704 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2707 ++count;
2708 });
2709 m_scene.StatsReporter.AddAgentUpdates(count);
2705 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2710 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2706 2711
2707 Animator.SendAnimPack(); 2712 Animator.SendAnimPack();
@@ -2722,14 +2727,9 @@ namespace OpenSim.Region.Framework.Scenes
2722 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2727 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
2723 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); 2728 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot));
2724 2729
2725 if (!m_isChildAgent)
2726 {
2727 m_scene.InformClientOfNeighbours(this);
2728 }
2729
2730 SendInitialFullUpdateToAllClients(); 2730 SendInitialFullUpdateToAllClients();
2731 SendAppearanceToAllOtherAgents(); 2731 SendAppearanceToAllOtherAgents();
2732 } 2732 }
2733 2733
2734 /// <summary> 2734 /// <summary>
2735 /// Tell the client for this scene presence what items it should be wearing now 2735 /// Tell the client for this scene presence what items it should be wearing now
@@ -2811,14 +2811,19 @@ namespace OpenSim.Region.Framework.Scenes
2811 } 2811 }
2812 } 2812 }
2813 } 2813 }
2814
2814 } 2815 }
2815 2816
2817
2816 #endregion Bake Cache Check 2818 #endregion Bake Cache Check
2817 2819
2818 m_appearance.SetAppearance(textureEntry, visualParams); 2820 m_appearance.SetAppearance(textureEntry, visualParams);
2819 if (m_appearance.AvatarHeight > 0) 2821 if (m_appearance.AvatarHeight > 0)
2820 SetHeight(m_appearance.AvatarHeight); 2822 SetHeight(m_appearance.AvatarHeight);
2821 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2823
2824 // This is not needed, because only the transient data changed
2825 //AvatarData adata = new AvatarData(m_appearance);
2826 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2822 2827
2823 SendAppearanceToAllOtherAgents(); 2828 SendAppearanceToAllOtherAgents();
2824 if (!m_startAnimationSet) 2829 if (!m_startAnimationSet)
@@ -2838,7 +2843,8 @@ namespace OpenSim.Region.Framework.Scenes
2838 public void SetWearable(int wearableId, AvatarWearable wearable) 2843 public void SetWearable(int wearableId, AvatarWearable wearable)
2839 { 2844 {
2840 m_appearance.SetWearable(wearableId, wearable); 2845 m_appearance.SetWearable(wearableId, wearable);
2841 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2846 AvatarData adata = new AvatarData(m_appearance);
2847 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2842 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); 2848 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2843 } 2849 }
2844 2850
@@ -2860,7 +2866,12 @@ namespace OpenSim.Region.Framework.Scenes
2860 /// </summary> 2866 /// </summary>
2861 protected void CheckForSignificantMovement() 2867 protected void CheckForSignificantMovement()
2862 { 2868 {
2863 if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.5) 2869 // Movement updates for agents in neighboring regions are sent directly to clients.
2870 // This value only affects how often agent positions are sent to neighbor regions
2871 // for things such as distance-based update prioritization
2872 const float SIGNIFICANT_MOVEMENT = 2.0f;
2873
2874 if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT)
2864 { 2875 {
2865 posLastSignificantMove = AbsolutePosition; 2876 posLastSignificantMove = AbsolutePosition;
2866 m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); 2877 m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient);
@@ -2871,18 +2882,19 @@ namespace OpenSim.Region.Framework.Scenes
2871 if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || 2882 if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance ||
2872 Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) 2883 Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance)
2873 { 2884 {
2885 m_lastChildAgentUpdatePosition = AbsolutePosition;
2886 m_lastChildAgentUpdateCamPosition = CameraPosition;
2887
2874 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); 2888 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
2875 cadu.ActiveGroupID = UUID.Zero.Guid; 2889 cadu.ActiveGroupID = UUID.Zero.Guid;
2876 cadu.AgentID = UUID.Guid; 2890 cadu.AgentID = UUID.Guid;
2877 cadu.alwaysrun = m_setAlwaysRun; 2891 cadu.alwaysrun = m_setAlwaysRun;
2878 cadu.AVHeight = m_avHeight; 2892 cadu.AVHeight = m_avHeight;
2879 sLLVector3 tempCameraCenter = new sLLVector3(new Vector3(m_CameraCenter.X, m_CameraCenter.Y, m_CameraCenter.Z)); 2893 Vector3 tempCameraCenter = m_CameraCenter;
2880 cadu.cameraPosition = tempCameraCenter; 2894 cadu.cameraPosition = tempCameraCenter;
2881 cadu.drawdistance = m_DrawDistance; 2895 cadu.drawdistance = m_DrawDistance;
2882 if (m_scene.Permissions.IsGod(new UUID(cadu.AgentID)))
2883 cadu.godlevel = m_godlevel;
2884 cadu.GroupAccess = 0; 2896 cadu.GroupAccess = 0;
2885 cadu.Position = new sLLVector3(AbsolutePosition); 2897 cadu.Position = AbsolutePosition;
2886 cadu.regionHandle = m_rootRegionHandle; 2898 cadu.regionHandle = m_rootRegionHandle;
2887 float multiplier = 1; 2899 float multiplier = 1;
2888 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); 2900 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount();
@@ -2897,15 +2909,12 @@ namespace OpenSim.Region.Framework.Scenes
2897 2909
2898 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); 2910 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString());
2899 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); 2911 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier);
2900 cadu.Velocity = new sLLVector3(Velocity); 2912 cadu.Velocity = Velocity;
2901 2913
2902 AgentPosition agentpos = new AgentPosition(); 2914 AgentPosition agentpos = new AgentPosition();
2903 agentpos.CopyFrom(cadu); 2915 agentpos.CopyFrom(cadu);
2904 2916
2905 m_scene.SendOutChildAgentUpdates(agentpos, this); 2917 m_scene.SendOutChildAgentUpdates(agentpos, this);
2906
2907 m_lastChildAgentUpdatePosition = AbsolutePosition;
2908 m_lastChildAgentUpdateCamPosition = CameraPosition;
2909 } 2918 }
2910 } 2919 }
2911 2920
@@ -3161,18 +3170,21 @@ namespace OpenSim.Region.Framework.Scenes
3161 // For now, assign god level 200 to anyone 3170 // For now, assign god level 200 to anyone
3162 // who is granted god powers, but has no god level set. 3171 // who is granted god powers, but has no god level set.
3163 // 3172 //
3164 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); 3173 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID);
3165 if (profile.UserProfile.GodLevel > 0) 3174 if (account != null)
3166 m_godlevel = profile.UserProfile.GodLevel; 3175 {
3167 else 3176 if (account.UserLevel > 0)
3168 m_godlevel = 200; 3177 m_godLevel = account.UserLevel;
3178 else
3179 m_godLevel = 200;
3180 }
3169 } 3181 }
3170 else 3182 else
3171 { 3183 {
3172 m_godlevel = 0; 3184 m_godLevel = 0;
3173 } 3185 }
3174 3186
3175 ControllingClient.SendAdminResponse(token, (uint)m_godlevel); 3187 ControllingClient.SendAdminResponse(token, (uint)m_godLevel);
3176 } 3188 }
3177 3189
3178 #region Child Agent Updates 3190 #region Child Agent Updates
@@ -3231,7 +3243,7 @@ namespace OpenSim.Region.Framework.Scenes
3231 public void CopyTo(AgentData cAgent) 3243 public void CopyTo(AgentData cAgent)
3232 { 3244 {
3233 cAgent.AgentID = UUID; 3245 cAgent.AgentID = UUID;
3234 cAgent.RegionHandle = m_rootRegionHandle; 3246 cAgent.RegionID = Scene.RegionInfo.RegionID;
3235 3247
3236 cAgent.Position = AbsolutePosition; 3248 cAgent.Position = AbsolutePosition;
3237 cAgent.Velocity = m_velocity; 3249 cAgent.Velocity = m_velocity;
@@ -3263,7 +3275,7 @@ namespace OpenSim.Region.Framework.Scenes
3263 cAgent.ControlFlags = (uint)m_AgentControlFlags; 3275 cAgent.ControlFlags = (uint)m_AgentControlFlags;
3264 3276
3265 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) 3277 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID)))
3266 cAgent.GodLevel = (byte)m_godlevel; 3278 cAgent.GodLevel = (byte)m_godLevel;
3267 else 3279 else
3268 cAgent.GodLevel = (byte) 0; 3280 cAgent.GodLevel = (byte) 0;
3269 3281
@@ -3330,11 +3342,12 @@ namespace OpenSim.Region.Framework.Scenes
3330 3342
3331 public void CopyFrom(AgentData cAgent) 3343 public void CopyFrom(AgentData cAgent)
3332 { 3344 {
3333 m_rootRegionHandle = cAgent.RegionHandle; 3345 m_originRegionID = cAgent.RegionID;
3334 3346
3335 m_callbackURI = cAgent.CallbackURI; 3347 m_callbackURI = cAgent.CallbackURI;
3336 3348
3337 m_pos = cAgent.Position; 3349 m_pos = cAgent.Position;
3350
3338 m_velocity = cAgent.Velocity; 3351 m_velocity = cAgent.Velocity;
3339 m_CameraCenter = cAgent.Center; 3352 m_CameraCenter = cAgent.Center;
3340 //m_avHeight = cAgent.Size.Z; 3353 //m_avHeight = cAgent.Size.Z;
@@ -3352,7 +3365,7 @@ namespace OpenSim.Region.Framework.Scenes
3352 m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; 3365 m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags;
3353 3366
3354 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) 3367 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID)))
3355 m_godlevel = cAgent.GodLevel; 3368 m_godLevel = cAgent.GodLevel;
3356 m_setAlwaysRun = cAgent.AlwaysRun; 3369 m_setAlwaysRun = cAgent.AlwaysRun;
3357 3370
3358 uint i = 0; 3371 uint i = 0;
@@ -3710,36 +3723,6 @@ namespace OpenSim.Region.Framework.Scenes
3710 } 3723 }
3711 } 3724 }
3712 3725
3713 public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent)
3714 {
3715 lock (m_attachments)
3716 {
3717 // Validate
3718 foreach (SceneObjectGroup gobj in m_attachments)
3719 {
3720 if (gobj == null || gobj.IsDeleted)
3721 return false;
3722 }
3723
3724 foreach (SceneObjectGroup gobj in m_attachments)
3725 {
3726 // If the prim group is null then something must have happened to it!
3727 if (gobj != null && gobj.RootPart != null)
3728 {
3729 // Set the parent localID to 0 so it transfers over properly.
3730 gobj.RootPart.SetParentLocalId(0);
3731 gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
3732 gobj.RootPart.IsAttachment = false;
3733 //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
3734 m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle);
3735 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent);
3736 }
3737 }
3738 m_attachments.Clear();
3739
3740 return true;
3741 }
3742 }
3743 3726
3744 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) 3727 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
3745 { 3728 {
@@ -3975,7 +3958,7 @@ namespace OpenSim.Region.Framework.Scenes
3975 { 3958 {
3976 if (null == m_appearance) 3959 if (null == m_appearance)
3977 { 3960 {
3978 m_log.WarnFormat("[ATTACHMENT] Appearance has not been initialized for agent {0}", UUID); 3961 m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID);
3979 return; 3962 return;
3980 } 3963 }
3981 3964
@@ -3999,12 +3982,12 @@ namespace OpenSim.Region.Framework.Scenes
3999 try 3982 try
4000 { 3983 {
4001 // Rez from inventory 3984 // Rez from inventory
4002 UUID asset = m_scene.RezSingleAttachment(ControllingClient, 3985 UUID asset
4003 itemID, (uint)p); 3986 = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p);
4004
4005 m_log.InfoFormat("[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",
4006 p, itemID, assetID, asset);
4007 3987
3988 m_log.InfoFormat(
3989 "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",
3990 p, itemID, assetID, asset);
4008 } 3991 }
4009 catch (Exception e) 3992 catch (Exception e)
4010 { 3993 {