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.cs315
1 files changed, 167 insertions, 148 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 2603fe1..ceb4395 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Xml;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Reflection; 31using System.Reflection;
31using System.Timers; 32using System.Timers;
@@ -33,12 +34,12 @@ using OpenMetaverse;
33using log4net; 34using log4net;
34using OpenSim.Framework; 35using OpenSim.Framework;
35using OpenSim.Framework.Client; 36using OpenSim.Framework.Client;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes.Animation; 38using OpenSim.Region.Framework.Scenes.Animation;
39using OpenSim.Region.Framework.Scenes.Types; 39using OpenSim.Region.Framework.Scenes.Types;
40using OpenSim.Region.Physics.Manager; 40using OpenSim.Region.Physics.Manager;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
42using OpenSim.Services.Interfaces;
42 43
43namespace OpenSim.Region.Framework.Scenes 44namespace 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
@@ -266,6 +268,8 @@ namespace OpenSim.Region.Framework.Scenes
266 268
267 // For teleports and crossings callbacks 269 // For teleports and crossings callbacks
268 string m_callbackURI; 270 string m_callbackURI;
271 UUID m_originRegionID;
272
269 ulong m_rootRegionHandle; 273 ulong m_rootRegionHandle;
270 274
271 /// <value> 275 /// <value>
@@ -302,9 +306,14 @@ namespace OpenSim.Region.Framework.Scenes
302 get { return m_invulnerable; } 306 get { return m_invulnerable; }
303 } 307 }
304 308
305 public float GodLevel 309 public int UserLevel
310 {
311 get { return m_userLevel; }
312 }
313
314 public int GodLevel
306 { 315 {
307 get { return m_godlevel; } 316 get { return m_godLevel; }
308 } 317 }
309 318
310 public ulong RegionHandle 319 public ulong RegionHandle
@@ -457,7 +466,7 @@ namespace OpenSim.Region.Framework.Scenes
457 PhysicsActor actor = m_physicsActor; 466 PhysicsActor actor = m_physicsActor;
458// if (actor != null) 467// if (actor != null)
459 if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! 468 if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting!
460 m_pos = actor.Position; 469 m_pos = actor.Position;
461 470
462 return m_parentPosition + m_pos; 471 return m_parentPosition + m_pos;
463 } 472 }
@@ -678,6 +687,11 @@ namespace OpenSim.Region.Framework.Scenes
678 m_regionInfo = reginfo; 687 m_regionInfo = reginfo;
679 m_localId = m_scene.AllocateLocalId(); 688 m_localId = m_scene.AllocateLocalId();
680 689
690 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid);
691
692 if (account != null)
693 m_userLevel = account.UserLevel;
694
681 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 695 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
682 if (gm != null) 696 if (gm != null)
683 m_grouptitle = gm.GetGroupTitle(m_uuid); 697 m_grouptitle = gm.GetGroupTitle(m_uuid);
@@ -868,47 +882,22 @@ namespace OpenSim.Region.Framework.Scenes
868 if (land != null) 882 if (land != null)
869 { 883 {
870 //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. 884 //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) 885 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 { 886 {
873 pos = land.LandData.UserLocation; 887 pos = land.LandData.UserLocation;
874 } 888 }
875 } 889 }
876 } 890 }
877 891
878 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) 892 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
879 { 893 {
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( 894 m_log.WarnFormat(
908 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", 895 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping",
909 pos, Name, UUID, emergencyPos); 896 pos, Name, UUID);
910 897
911 pos = emergencyPos; 898 if (pos.X < 0f) pos.X = 0f;
899 if (pos.Y < 0f) pos.Y = 0f;
900 if (pos.Z < 0f) pos.Z = 0f;
912 } 901 }
913 902
914 float localAVHeight = 1.56f; 903 float localAVHeight = 1.56f;
@@ -919,7 +908,7 @@ namespace OpenSim.Region.Framework.Scenes
919 908
920 float posZLimit = 0; 909 float posZLimit = 0;
921 910
922 if (pos.X <Constants.RegionSize && pos.Y < Constants.RegionSize) 911 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
923 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 912 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
924 913
925 float newPosZ = posZLimit + localAVHeight / 2; 914 float newPosZ = posZLimit + localAVHeight / 2;
@@ -971,14 +960,12 @@ namespace OpenSim.Region.Framework.Scenes
971 960
972 m_isChildAgent = false; 961 m_isChildAgent = false;
973 962
974 ScenePresence[] animAgents = m_scene.GetScenePresences(); 963 // send the animations of the other presences to me
975 for (int i = 0; i < animAgents.Length; i++) 964 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
976 { 965 {
977 ScenePresence presence = animAgents[i];
978
979 if (presence != this) 966 if (presence != this)
980 presence.Animator.SendAnimPackToClient(ControllingClient); 967 presence.Animator.SendAnimPackToClient(ControllingClient);
981 } 968 });
982 969
983 m_scene.EventManager.TriggerOnMakeRootAgent(this); 970 m_scene.EventManager.TriggerOnMakeRootAgent(this);
984 } 971 }
@@ -1162,8 +1149,10 @@ namespace OpenSim.Region.Framework.Scenes
1162 /// This is called upon a very important packet sent from the client, 1149 /// This is called upon a very important packet sent from the client,
1163 /// so it's client-controlled. Never call this method directly. 1150 /// so it's client-controlled. Never call this method directly.
1164 /// </summary> 1151 /// </summary>
1165 public void CompleteMovement() 1152 public void CompleteMovement(IClientAPI client)
1166 { 1153 {
1154 //m_log.Debug("[SCENE PRESENCE]: CompleteMovement");
1155
1167 Vector3 look = Velocity; 1156 Vector3 look = Velocity;
1168 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1157 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1169 { 1158 {
@@ -1188,7 +1177,7 @@ namespace OpenSim.Region.Framework.Scenes
1188 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1177 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1189 { 1178 {
1190 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1179 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
1191 Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); 1180 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1192 m_callbackURI = null; 1181 m_callbackURI = null;
1193 } 1182 }
1194 1183
@@ -1196,6 +1185,21 @@ namespace OpenSim.Region.Framework.Scenes
1196 1185
1197 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 1186 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
1198 SendInitialData(); 1187 SendInitialData();
1188
1189 // Create child agents in neighbouring regions
1190 if (!m_isChildAgent)
1191 {
1192 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1193 if (m_agentTransfer != null)
1194 m_agentTransfer.EnableChildAgents(this);
1195 else
1196 m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active");
1197
1198 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1199 if (friendsModule != null)
1200 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1201 }
1202
1199 } 1203 }
1200 1204
1201 /// <summary> 1205 /// <summary>
@@ -1264,6 +1268,7 @@ namespace OpenSim.Region.Framework.Scenes
1264 m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); 1268 m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902");
1265 1269
1266 m_pos = m_LastFinitePos; 1270 m_pos = m_LastFinitePos;
1271
1267 if (!m_pos.IsFinite()) 1272 if (!m_pos.IsFinite())
1268 { 1273 {
1269 m_pos.X = 127f; 1274 m_pos.X = 127f;
@@ -1901,6 +1906,7 @@ namespace OpenSim.Region.Framework.Scenes
1901 { 1906 {
1902 m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center 1907 m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center
1903 autopilotTarget = part.AbsolutePosition; 1908 autopilotTarget = part.AbsolutePosition;
1909//Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget);
1904 } 1910 }
1905 else return; // occupied small 1911 else return; // occupied small
1906 } // end large/small 1912 } // end large/small
@@ -2277,7 +2283,8 @@ namespace OpenSim.Region.Framework.Scenes
2277 m_pos += SIT_TARGET_ADJUSTMENT; 2283 m_pos += SIT_TARGET_ADJUSTMENT;
2278 m_bodyRot = sitTargetOrient; 2284 m_bodyRot = sitTargetOrient;
2279 m_parentPosition = part.AbsolutePosition; 2285 m_parentPosition = part.AbsolutePosition;
2280 part.IsOccupied = true; 2286 part.IsOccupied = true;
2287Console.WriteLine("Scripted Sit ofset {0}", m_pos);
2281 } 2288 }
2282 else 2289 else
2283 { 2290 {
@@ -2399,6 +2406,7 @@ namespace OpenSim.Region.Framework.Scenes
2399 { 2406 {
2400 if (m_isChildAgent) 2407 if (m_isChildAgent)
2401 { 2408 {
2409 // WHAT???
2402 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); 2410 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!");
2403 2411
2404 // we have to reset the user's child agent connections. 2412 // we have to reset the user's child agent connections.
@@ -2422,7 +2430,9 @@ namespace OpenSim.Region.Framework.Scenes
2422 2430
2423 if (m_scene.SceneGridService != null) 2431 if (m_scene.SceneGridService != null)
2424 { 2432 {
2425 m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); 2433 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
2434 if (m_agentTransfer != null)
2435 m_agentTransfer.EnableChildAgents(this);
2426 } 2436 }
2427 2437
2428 return; 2438 return;
@@ -2590,35 +2600,33 @@ namespace OpenSim.Region.Framework.Scenes
2590 2600
2591 List<Vector3> CoarseLocations = new List<Vector3>(); 2601 List<Vector3> CoarseLocations = new List<Vector3>();
2592 List<UUID> AvatarUUIDs = new List<UUID>(); 2602 List<UUID> AvatarUUIDs = new List<UUID>();
2593 List<ScenePresence> avatars = m_scene.GetAvatars(); 2603 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2594 for (int i = 0; i < avatars.Count; i++)
2595 { 2604 {
2596 // Requested by LibOMV. Send Course Location on self. 2605 if (sp.IsChildAgent)
2597 //if (avatars[i] != this) 2606 return;
2598 //{ 2607
2599 if (avatars[i].ParentID != 0) 2608 if (sp.ParentID != 0)
2609 {
2610 // sitting avatar
2611 SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID);
2612 if (sop != null)
2600 { 2613 {
2601 // sitting avatar 2614 CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos);
2602 SceneObjectPart sop = m_scene.GetSceneObjectPart(avatars[i].ParentID); 2615 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 } 2616 }
2615 else 2617 else
2616 { 2618 {
2617 CoarseLocations.Add(avatars[i].m_pos); 2619 // we can't find the parent.. ! arg!
2618 AvatarUUIDs.Add(avatars[i].UUID); 2620 CoarseLocations.Add(sp.m_pos);
2621 AvatarUUIDs.Add(sp.UUID);
2619 } 2622 }
2620 //} 2623 }
2621 } 2624 else
2625 {
2626 CoarseLocations.Add(sp.m_pos);
2627 AvatarUUIDs.Add(sp.UUID);
2628 }
2629 });
2622 2630
2623 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); 2631 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations);
2624 2632
@@ -2660,13 +2668,10 @@ namespace OpenSim.Region.Framework.Scenes
2660 public void SendInitialFullUpdateToAllClients() 2668 public void SendInitialFullUpdateToAllClients()
2661 { 2669 {
2662 m_perfMonMS = Util.EnvironmentTickCount(); 2670 m_perfMonMS = Util.EnvironmentTickCount();
2663 2671 int avUpdates = 0;
2664 ScenePresence[] avatars = m_scene.GetScenePresences(); 2672 m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
2665
2666 for (int i = 0; i < avatars.Length; i++)
2667 { 2673 {
2668 ScenePresence avatar = avatars[i]; 2674 ++avUpdates;
2669
2670 // only send if this is the root (children are only "listening posts" in a foreign region) 2675 // only send if this is the root (children are only "listening posts" in a foreign region)
2671 if (!IsChildAgent) 2676 if (!IsChildAgent)
2672 { 2677 {
@@ -2682,9 +2687,9 @@ namespace OpenSim.Region.Framework.Scenes
2682 avatar.Animator.SendAnimPackToClient(ControllingClient); 2687 avatar.Animator.SendAnimPackToClient(ControllingClient);
2683 } 2688 }
2684 } 2689 }
2685 } 2690 });
2686 2691
2687 m_scene.StatsReporter.AddAgentUpdates(avatars.Length); 2692 m_scene.StatsReporter.AddAgentUpdates(avUpdates);
2688 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2693 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2689 2694
2690 //Animator.SendAnimPack(); 2695 //Animator.SendAnimPack();
@@ -2695,13 +2700,15 @@ namespace OpenSim.Region.Framework.Scenes
2695 m_perfMonMS = Util.EnvironmentTickCount(); 2700 m_perfMonMS = Util.EnvironmentTickCount();
2696 2701
2697 // only send update from root agents to other clients; children are only "listening posts" 2702 // only send update from root agents to other clients; children are only "listening posts"
2698 List<ScenePresence> avatars = m_scene.GetAvatars(); 2703 int count = 0;
2699 foreach (ScenePresence avatar in avatars) 2704 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2700 { 2705 {
2701 SendFullUpdateToOtherClient(avatar); 2706 if (sp.IsChildAgent)
2702 2707 return;
2703 } 2708 SendFullUpdateToOtherClient(sp);
2704 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2709 ++count;
2710 });
2711 m_scene.StatsReporter.AddAgentUpdates(count);
2705 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2712 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2706 2713
2707 Animator.SendAnimPack(); 2714 Animator.SendAnimPack();
@@ -2722,14 +2729,9 @@ namespace OpenSim.Region.Framework.Scenes
2722 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2729 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)); 2730 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot));
2724 2731
2725 if (!m_isChildAgent)
2726 {
2727 m_scene.InformClientOfNeighbours(this);
2728 }
2729
2730 SendInitialFullUpdateToAllClients(); 2732 SendInitialFullUpdateToAllClients();
2731 SendAppearanceToAllOtherAgents(); 2733 SendAppearanceToAllOtherAgents();
2732 } 2734 }
2733 2735
2734 /// <summary> 2736 /// <summary>
2735 /// Tell the client for this scene presence what items it should be wearing now 2737 /// Tell the client for this scene presence what items it should be wearing now
@@ -2811,14 +2813,19 @@ namespace OpenSim.Region.Framework.Scenes
2811 } 2813 }
2812 } 2814 }
2813 } 2815 }
2816
2814 } 2817 }
2815 2818
2819
2816 #endregion Bake Cache Check 2820 #endregion Bake Cache Check
2817 2821
2818 m_appearance.SetAppearance(textureEntry, visualParams); 2822 m_appearance.SetAppearance(textureEntry, visualParams);
2819 if (m_appearance.AvatarHeight > 0) 2823 if (m_appearance.AvatarHeight > 0)
2820 SetHeight(m_appearance.AvatarHeight); 2824 SetHeight(m_appearance.AvatarHeight);
2821 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2825
2826 // This is not needed, because only the transient data changed
2827 //AvatarData adata = new AvatarData(m_appearance);
2828 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2822 2829
2823 SendAppearanceToAllOtherAgents(); 2830 SendAppearanceToAllOtherAgents();
2824 if (!m_startAnimationSet) 2831 if (!m_startAnimationSet)
@@ -2838,7 +2845,8 @@ namespace OpenSim.Region.Framework.Scenes
2838 public void SetWearable(int wearableId, AvatarWearable wearable) 2845 public void SetWearable(int wearableId, AvatarWearable wearable)
2839 { 2846 {
2840 m_appearance.SetWearable(wearableId, wearable); 2847 m_appearance.SetWearable(wearableId, wearable);
2841 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2848 AvatarData adata = new AvatarData(m_appearance);
2849 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2842 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); 2850 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2843 } 2851 }
2844 2852
@@ -2860,7 +2868,12 @@ namespace OpenSim.Region.Framework.Scenes
2860 /// </summary> 2868 /// </summary>
2861 protected void CheckForSignificantMovement() 2869 protected void CheckForSignificantMovement()
2862 { 2870 {
2863 if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.5) 2871 // Movement updates for agents in neighboring regions are sent directly to clients.
2872 // This value only affects how often agent positions are sent to neighbor regions
2873 // for things such as distance-based update prioritization
2874 const float SIGNIFICANT_MOVEMENT = 2.0f;
2875
2876 if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT)
2864 { 2877 {
2865 posLastSignificantMove = AbsolutePosition; 2878 posLastSignificantMove = AbsolutePosition;
2866 m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); 2879 m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient);
@@ -2871,18 +2884,19 @@ namespace OpenSim.Region.Framework.Scenes
2871 if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || 2884 if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance ||
2872 Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) 2885 Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance)
2873 { 2886 {
2887 m_lastChildAgentUpdatePosition = AbsolutePosition;
2888 m_lastChildAgentUpdateCamPosition = CameraPosition;
2889
2874 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); 2890 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
2875 cadu.ActiveGroupID = UUID.Zero.Guid; 2891 cadu.ActiveGroupID = UUID.Zero.Guid;
2876 cadu.AgentID = UUID.Guid; 2892 cadu.AgentID = UUID.Guid;
2877 cadu.alwaysrun = m_setAlwaysRun; 2893 cadu.alwaysrun = m_setAlwaysRun;
2878 cadu.AVHeight = m_avHeight; 2894 cadu.AVHeight = m_avHeight;
2879 sLLVector3 tempCameraCenter = new sLLVector3(new Vector3(m_CameraCenter.X, m_CameraCenter.Y, m_CameraCenter.Z)); 2895 Vector3 tempCameraCenter = m_CameraCenter;
2880 cadu.cameraPosition = tempCameraCenter; 2896 cadu.cameraPosition = tempCameraCenter;
2881 cadu.drawdistance = m_DrawDistance; 2897 cadu.drawdistance = m_DrawDistance;
2882 if (m_scene.Permissions.IsGod(new UUID(cadu.AgentID)))
2883 cadu.godlevel = m_godlevel;
2884 cadu.GroupAccess = 0; 2898 cadu.GroupAccess = 0;
2885 cadu.Position = new sLLVector3(AbsolutePosition); 2899 cadu.Position = AbsolutePosition;
2886 cadu.regionHandle = m_rootRegionHandle; 2900 cadu.regionHandle = m_rootRegionHandle;
2887 float multiplier = 1; 2901 float multiplier = 1;
2888 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); 2902 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount();
@@ -2897,15 +2911,12 @@ namespace OpenSim.Region.Framework.Scenes
2897 2911
2898 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); 2912 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString());
2899 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); 2913 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier);
2900 cadu.Velocity = new sLLVector3(Velocity); 2914 cadu.Velocity = Velocity;
2901 2915
2902 AgentPosition agentpos = new AgentPosition(); 2916 AgentPosition agentpos = new AgentPosition();
2903 agentpos.CopyFrom(cadu); 2917 agentpos.CopyFrom(cadu);
2904 2918
2905 m_scene.SendOutChildAgentUpdates(agentpos, this); 2919 m_scene.SendOutChildAgentUpdates(agentpos, this);
2906
2907 m_lastChildAgentUpdatePosition = AbsolutePosition;
2908 m_lastChildAgentUpdateCamPosition = CameraPosition;
2909 } 2920 }
2910 } 2921 }
2911 2922
@@ -3161,18 +3172,21 @@ namespace OpenSim.Region.Framework.Scenes
3161 // For now, assign god level 200 to anyone 3172 // For now, assign god level 200 to anyone
3162 // who is granted god powers, but has no god level set. 3173 // who is granted god powers, but has no god level set.
3163 // 3174 //
3164 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); 3175 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID);
3165 if (profile.UserProfile.GodLevel > 0) 3176 if (account != null)
3166 m_godlevel = profile.UserProfile.GodLevel; 3177 {
3167 else 3178 if (account.UserLevel > 0)
3168 m_godlevel = 200; 3179 m_godLevel = account.UserLevel;
3180 else
3181 m_godLevel = 200;
3182 }
3169 } 3183 }
3170 else 3184 else
3171 { 3185 {
3172 m_godlevel = 0; 3186 m_godLevel = 0;
3173 } 3187 }
3174 3188
3175 ControllingClient.SendAdminResponse(token, (uint)m_godlevel); 3189 ControllingClient.SendAdminResponse(token, (uint)m_godLevel);
3176 } 3190 }
3177 3191
3178 #region Child Agent Updates 3192 #region Child Agent Updates
@@ -3231,7 +3245,7 @@ namespace OpenSim.Region.Framework.Scenes
3231 public void CopyTo(AgentData cAgent) 3245 public void CopyTo(AgentData cAgent)
3232 { 3246 {
3233 cAgent.AgentID = UUID; 3247 cAgent.AgentID = UUID;
3234 cAgent.RegionHandle = m_rootRegionHandle; 3248 cAgent.RegionID = Scene.RegionInfo.RegionID;
3235 3249
3236 cAgent.Position = AbsolutePosition; 3250 cAgent.Position = AbsolutePosition;
3237 cAgent.Velocity = m_velocity; 3251 cAgent.Velocity = m_velocity;
@@ -3263,7 +3277,7 @@ namespace OpenSim.Region.Framework.Scenes
3263 cAgent.ControlFlags = (uint)m_AgentControlFlags; 3277 cAgent.ControlFlags = (uint)m_AgentControlFlags;
3264 3278
3265 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) 3279 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID)))
3266 cAgent.GodLevel = (byte)m_godlevel; 3280 cAgent.GodLevel = (byte)m_godLevel;
3267 else 3281 else
3268 cAgent.GodLevel = (byte) 0; 3282 cAgent.GodLevel = (byte) 0;
3269 3283
@@ -3330,11 +3344,12 @@ namespace OpenSim.Region.Framework.Scenes
3330 3344
3331 public void CopyFrom(AgentData cAgent) 3345 public void CopyFrom(AgentData cAgent)
3332 { 3346 {
3333 m_rootRegionHandle = cAgent.RegionHandle; 3347 m_originRegionID = cAgent.RegionID;
3334 3348
3335 m_callbackURI = cAgent.CallbackURI; 3349 m_callbackURI = cAgent.CallbackURI;
3336 3350
3337 m_pos = cAgent.Position; 3351 m_pos = cAgent.Position;
3352
3338 m_velocity = cAgent.Velocity; 3353 m_velocity = cAgent.Velocity;
3339 m_CameraCenter = cAgent.Center; 3354 m_CameraCenter = cAgent.Center;
3340 //m_avHeight = cAgent.Size.Z; 3355 //m_avHeight = cAgent.Size.Z;
@@ -3352,7 +3367,7 @@ namespace OpenSim.Region.Framework.Scenes
3352 m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; 3367 m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags;
3353 3368
3354 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) 3369 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID)))
3355 m_godlevel = cAgent.GodLevel; 3370 m_godLevel = cAgent.GodLevel;
3356 m_setAlwaysRun = cAgent.AlwaysRun; 3371 m_setAlwaysRun = cAgent.AlwaysRun;
3357 3372
3358 uint i = 0; 3373 uint i = 0;
@@ -3710,36 +3725,6 @@ namespace OpenSim.Region.Framework.Scenes
3710 } 3725 }
3711 } 3726 }
3712 3727
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 3728
3744 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) 3729 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
3745 { 3730 {
@@ -3975,10 +3960,36 @@ namespace OpenSim.Region.Framework.Scenes
3975 { 3960 {
3976 if (null == m_appearance) 3961 if (null == m_appearance)
3977 { 3962 {
3978 m_log.WarnFormat("[ATTACHMENT] Appearance has not been initialized for agent {0}", UUID); 3963 m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID);
3979 return; 3964 return;
3980 } 3965 }
3981 3966
3967 XmlDocument doc = new XmlDocument();
3968 string stateData = String.Empty;
3969
3970 IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>();
3971 if (attServ != null)
3972 {
3973 m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service");
3974 stateData = attServ.Get(ControllingClient.AgentId.ToString());
3975 doc.LoadXml(stateData);
3976 }
3977
3978 Dictionary<UUID, string> itemData = new Dictionary<UUID, string>();
3979
3980 XmlNodeList nodes = doc.GetElementsByTagName("Attachment");
3981 if (nodes.Count > 0)
3982 {
3983 foreach (XmlNode n in nodes)
3984 {
3985 XmlElement elem = (XmlElement)n;
3986 string itemID = elem.GetAttribute("ItemID");
3987 string xml = elem.InnerXml;
3988
3989 itemData[new UUID(itemID)] = xml;
3990 }
3991 }
3992
3982 List<int> attPoints = m_appearance.GetAttachedPoints(); 3993 List<int> attPoints = m_appearance.GetAttachedPoints();
3983 foreach (int p in attPoints) 3994 foreach (int p in attPoints)
3984 { 3995 {
@@ -3998,13 +4009,21 @@ namespace OpenSim.Region.Framework.Scenes
3998 4009
3999 try 4010 try
4000 { 4011 {
4001 // Rez from inventory 4012 string xmlData;
4002 UUID asset = m_scene.RezSingleAttachment(ControllingClient, 4013 XmlDocument d = new XmlDocument();
4003 itemID, (uint)p); 4014 if (itemData.TryGetValue(itemID, out xmlData))
4015 {
4016 d.LoadXml(xmlData);
4017 m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID);
4018 }
4004 4019
4005 m_log.InfoFormat("[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", 4020 // Rez from inventory
4006 p, itemID, assetID, asset); 4021 UUID asset
4022 = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d);
4007 4023
4024 m_log.InfoFormat(
4025 "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",
4026 p, itemID, assetID, asset);
4008 } 4027 }
4009 catch (Exception e) 4028 catch (Exception e)
4010 { 4029 {