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.cs155
1 files changed, 152 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 42cd4be..5c56150 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -40,6 +40,7 @@ using 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; 42using OpenSim.Services.Interfaces;
43using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags;
43 44
44namespace OpenSim.Region.Framework.Scenes 45namespace OpenSim.Region.Framework.Scenes
45{ 46{
@@ -892,6 +893,8 @@ namespace OpenSim.Region.Framework.Scenes
892 pos.Y = crossedBorder.BorderLine.Z - 1; 893 pos.Y = crossedBorder.BorderLine.Z - 1;
893 } 894 }
894 895
896 CheckAndAdjustLandingPoint(ref pos);
897
895 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 898 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
896 { 899 {
897 m_log.WarnFormat( 900 m_log.WarnFormat(
@@ -1056,6 +1059,7 @@ namespace OpenSim.Region.Framework.Scenes
1056 bool isFlying = Flying; 1059 bool isFlying = Flying;
1057 RemoveFromPhysicalScene(); 1060 RemoveFromPhysicalScene();
1058 Velocity = Vector3.Zero; 1061 Velocity = Vector3.Zero;
1062 CheckLandingPoint(ref pos);
1059 AbsolutePosition = pos; 1063 AbsolutePosition = pos;
1060 AddToPhysicalScene(isFlying); 1064 AddToPhysicalScene(isFlying);
1061 1065
@@ -1066,6 +1070,7 @@ namespace OpenSim.Region.Framework.Scenes
1066 { 1070 {
1067 bool isFlying = Flying; 1071 bool isFlying = Flying;
1068 RemoveFromPhysicalScene(); 1072 RemoveFromPhysicalScene();
1073 CheckLandingPoint(ref pos);
1069 AbsolutePosition = pos; 1074 AbsolutePosition = pos;
1070 AddToPhysicalScene(isFlying); 1075 AddToPhysicalScene(isFlying);
1071 1076
@@ -1180,6 +1185,7 @@ namespace OpenSim.Region.Framework.Scenes
1180 client.Name, Scene.RegionInfo.RegionName, AbsolutePosition); 1185 client.Name, Scene.RegionInfo.RegionName, AbsolutePosition);
1181 1186
1182 Vector3 look = Velocity; 1187 Vector3 look = Velocity;
1188
1183 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1189 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1184 { 1190 {
1185 look = new Vector3(0.99f, 0.042f, 0); 1191 look = new Vector3(0.99f, 0.042f, 0);
@@ -1206,7 +1212,7 @@ namespace OpenSim.Region.Framework.Scenes
1206 m_callbackURI = null; 1212 m_callbackURI = null;
1207 } 1213 }
1208 1214
1209 //m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); 1215// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1210 1216
1211 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); 1217 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1212 ValidateAndSendAppearanceAndAgentData(); 1218 ValidateAndSendAppearanceAndAgentData();
@@ -1274,8 +1280,8 @@ namespace OpenSim.Region.Framework.Scenes
1274 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 1280 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
1275 { 1281 {
1276// m_log.DebugFormat( 1282// m_log.DebugFormat(
1277// "[SCENE PRESENCE]: In {0} received agent update from {1}", 1283// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
1278// Scene.RegionInfo.RegionName, remoteClient.Name); 1284// Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags);
1279 1285
1280 if (IsChildAgent) 1286 if (IsChildAgent)
1281 { 1287 {
@@ -2312,6 +2318,8 @@ namespace OpenSim.Region.Framework.Scenes
2312 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> 2318 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param>
2313 public void AddNewMovement(Vector3 vec) 2319 public void AddNewMovement(Vector3 vec)
2314 { 2320 {
2321// m_log.DebugFormat("[SCENE PRESENCE]: Adding new movement {0} for {1}", vec, Name);
2322
2315 Vector3 direc = vec * Rotation; 2323 Vector3 direc = vec * Rotation;
2316 direc.Normalize(); 2324 direc.Normalize();
2317 2325
@@ -3801,5 +3809,146 @@ namespace OpenSim.Region.Framework.Scenes
3801 m_reprioritization_called = false; 3809 m_reprioritization_called = false;
3802 } 3810 }
3803 } 3811 }
3812
3813 private void CheckLandingPoint(ref Vector3 pos)
3814 {
3815 // Never constrain lures
3816 if ((TeleportFlags & TeleportFlags.ViaLure) != 0)
3817 return;
3818
3819 if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
3820 return;
3821
3822 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3823
3824 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3825 land.LandData.UserLocation != Vector3.Zero &&
3826 land.LandData.OwnerID != m_uuid &&
3827 (!m_scene.Permissions.IsGod(m_uuid)) &&
3828 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)))
3829 {
3830 float curr = Vector3.Distance(AbsolutePosition, pos);
3831 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
3832 pos = land.LandData.UserLocation;
3833 else
3834 ControllingClient.SendAlertMessage("Can't teleport closer to destination");
3835 }
3836 }
3837
3838 private void CheckAndAdjustTelehub(SceneObjectGroup telehub, ref Vector3 pos)
3839 {
3840 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) ==
3841 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
3842 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
3843 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
3844 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
3845 {
3846 if (GodLevel < 200 &&
3847 ((!m_scene.Permissions.IsGod(m_uuid) &&
3848 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) ||
3849 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
3850 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
3851 {
3852 SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray();
3853 if (spawnPoints.Length == 0)
3854 return;
3855
3856 float distance = 9999;
3857 int closest = -1;
3858
3859 for (int i = 0 ; i < spawnPoints.Length ; i++)
3860 {
3861 Vector3 spawnPosition = spawnPoints[i].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
3862 Vector3 offset = spawnPosition - pos;
3863 float d = Vector3.Mag(offset);
3864 if (d >= distance)
3865 continue;
3866 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
3867 if (land == null)
3868 continue;
3869 if (land.IsEitherBannedOrRestricted(UUID))
3870 continue;
3871 distance = d;
3872 closest = i;
3873 }
3874 if (closest == -1)
3875 return;
3876
3877 pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
3878 }
3879 }
3880 }
3881
3882 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3883 {
3884 SceneObjectGroup telehub = null;
3885 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null)
3886 {
3887 if (!m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
3888 {
3889 CheckAndAdjustTelehub(telehub, ref pos);
3890 return;
3891 }
3892 }
3893
3894 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3895 if (land != null)
3896 {
3897 if (Scene.DEBUG)
3898 TeleportFlagsDebug();
3899
3900 // If we come in via login, landmark or map, we want to
3901 // honor landing points. If we come in via Lure, we want
3902 // to ignore them.
3903 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) ==
3904 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
3905 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
3906 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
3907 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
3908 {
3909 // Don't restrict gods, estate managers, or land owners to
3910 // the TP point. This behaviour mimics agni.
3911 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3912 land.LandData.UserLocation != Vector3.Zero &&
3913 GodLevel < 200 &&
3914 ((land.LandData.OwnerID != m_uuid &&
3915 !m_scene.Permissions.IsGod(m_uuid) &&
3916 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) ||
3917 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
3918 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
3919 {
3920 pos = land.LandData.UserLocation;
3921 }
3922 }
3923
3924 land.SendLandUpdateToClient(ControllingClient);
3925 }
3926 }
3927
3928 private void TeleportFlagsDebug() {
3929
3930 // Some temporary debugging help to show all the TeleportFlags we have...
3931 bool HG = false;
3932 if((m_teleportFlags & TeleportFlags.ViaHGLogin) == TeleportFlags.ViaHGLogin)
3933 HG = true;
3934
3935 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
3936
3937 uint i = 0u;
3938 for (int x = 0; x <= 30 ; x++, i = 1u << x)
3939 {
3940 i = 1u << x;
3941
3942 if((m_teleportFlags & (TeleportFlags)i) == (TeleportFlags)i)
3943 if (HG == false)
3944 m_log.InfoFormat("[SCENE PRESENCE]: Teleport Flags include {0}", ((TeleportFlags) i).ToString());
3945 else
3946 m_log.InfoFormat("[SCENE PRESENCE]: HG Teleport Flags include {0}", ((TeleportFlags)i).ToString());
3947 }
3948
3949 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
3950
3951 }
3952
3804 } 3953 }
3805} 3954}