check land permitions on sit target for unscripted sits

UbitUmarov [2013-01-03 14:27:21]
check land permitions on sit target for unscripted sits
Filename
OpenSim/Framework/ILandObject.cs
OpenSim/Region/CoreModules/World/Land/LandObject.cs
OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs
index 4f98d7b..7a24d1e 100644
--- a/OpenSim/Framework/ILandObject.cs
+++ b/OpenSim/Framework/ILandObject.cs
@@ -70,6 +70,7 @@ namespace OpenSim.Framework
         void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client);
         bool IsEitherBannedOrRestricted(UUID avatar);
         bool IsBannedFromLand(UUID avatar);
+        bool CanBeOnThisLand(UUID avatar, float posHeight);
         bool IsRestrictedFromLand(UUID avatar);
         bool IsInLandAccessList(UUID avatar);
         void SendLandUpdateToClient(IClientAPI remote_client);
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index d5b2adb..fdac418 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -442,6 +442,19 @@ namespace OpenSim.Region.CoreModules.World.Land
             return false;
         }

+        public bool CanBeOnThisLand(UUID avatar, float posHeight)
+        {
+            if (posHeight < LandChannel.BAN_LINE_SAFETY_HIEGHT && IsBannedFromLand(avatar))
+            {
+                return false;
+            }
+            else if (IsRestrictedFromLand(avatar))
+            {
+                return false;
+            }
+            return true;
+        }
+
         public bool HasGroupAccess(UUID avatar)
         {
             if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index c16c544..5087882 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2247,6 +2247,17 @@ namespace OpenSim.Region.Framework.Scenes
             return false;
         }

+
+        private bool CanEnterLandPosition(Vector3 testPos)
+        {
+            ILandObject land = m_scene.LandChannel.GetLandObject(testPos.X, testPos.Y);
+
+            if (land == null || land.LandData.Name == "NO_LAND")
+                return true;
+
+            return land.CanBeOnThisLand(UUID,testPos.Z);
+        }
+
         // status
         //          < 0 ignore
         //          0   bad sit spot
@@ -2265,6 +2276,12 @@ namespace OpenSim.Region.Framework.Scenes
             if (part == null)
                 return;

+            Vector3 targetPos = part.GetWorldPosition() + offset * part.GetWorldRotation();
+            if(!CanEnterLandPosition(targetPos))
+            {
+                ControllingClient.SendAlertMessage(" Sit position on restricted land, try another spot");
+                return;
+            }
 //            m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString());

             RemoveFromPhysicalScene();
ViewGit