From 302d65569f721e19ee4400e3a73aa0530dd8e7e7 Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Tue, 11 Nov 2008 01:47:40 +0000
Subject: Allow gods to terraform without limits. Respect the Allow Others To
 Terraform flag in land.

---
 OpenSim/Framework/IClientAPI.cs                             |  2 +-
 OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs        |  2 +-
 .../Environment/Modules/World/Terrain/ITerrainModule.cs     |  3 ++-
 .../Environment/Modules/World/Terrain/TerrainModule.cs      | 13 +++++++------
 .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs       |  2 +-
 5 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 2be647f..508fefb 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Framework
     public delegate void ObjectAttach(
         IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent);
 
-    public delegate void ModifyTerrain(
+    public delegate void ModifyTerrain(UUID user, 
         float height, float seconds, byte size, byte action, float north, float west, float south, float east,
         UUID agentId);
 
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index a835e43..f9d73d5 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -4156,7 +4156,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
                                 if (handlerModifyTerrain != null)
                                 {
                                     modify.ModifyBlock.Height = -1; // Hack, i don't know why the value is wrong
-                                    handlerModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
+                                    handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
                                                          modify.ModifyBlock.BrushSize,
                                                          modify.ModifyBlock.Action, modify.ParcelData[i].North,
                                                          modify.ParcelData[i].West, modify.ParcelData[i].South,
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs
index bc5dc72..91bc31f 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs
@@ -28,6 +28,7 @@
 
 using System.IO;
 using OpenMetaverse;
+using OpenSim.Framework;
 
 namespace OpenSim.Region.Environment.Modules.World.Terrain
 {
@@ -35,7 +36,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
     {
         void LoadFromFile(string filename);
         void SaveToFile(string filename);
-        void ModifyTerrain(Vector3 pos, byte size, byte action, UUID agentId);
+        void ModifyTerrain(UUID user, Vector3 pos, byte size, byte action, UUID agentId);
         
         /// <summary>
         /// Load a terrain from a stream.
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
index c49b0b9..3170724 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
@@ -279,9 +279,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
         /// <param name="size">The size of the brush (0=small, 1=medium, 2=large)</param>
         /// <param name="action">0=LAND_LEVEL, 1=LAND_RAISE, 2=LAND_LOWER, 3=LAND_SMOOTH, 4=LAND_NOISE, 5=LAND_REVERT</param>
         /// <param name="agentId">UUID of script-owner</param>
-        public void ModifyTerrain(Vector3 pos, byte size, byte action, UUID agentId)
+        public void ModifyTerrain(UUID user, Vector3 pos, byte size, byte action, UUID agentId)
         {
-            client_OnModifyTerrain((float)pos.Z, (float)0.25, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId);
+            client_OnModifyTerrain(user, (float)pos.Z, (float)0.25, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId);
         }        
 
         /// <summary>
@@ -613,9 +613,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
             );
         }
 
-        private void client_OnModifyTerrain(float height, float seconds, byte size, byte action,
+        private void client_OnModifyTerrain(UUID user, float height, float seconds, byte size, byte action,
                                             float north, float west, float south, float east, UUID agentId)
         {
+            bool god = m_scene.ExternalChecks.ExternalChecksCanBeGodLike(user);
             bool allowed = false;
             if (north == south && east == west)
             {
@@ -653,7 +654,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
                         m_painteffects[(StandardTerrainEffects) action].PaintEffect(
                             m_channel, allowMask, west, south, height, size, seconds);
 
-                        CheckForTerrainUpdates(true); //revert changes outside estate limits
+                        CheckForTerrainUpdates(!god); //revert changes outside estate limits
                     }
                 }
                 else
@@ -693,7 +694,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
                         m_floodeffects[(StandardTerrainEffects) action].FloodEffect(
                             m_channel, fillArea, size);
 
-                        CheckForTerrainUpdates(true); //revert changes outside estate limits
+                        CheckForTerrainUpdates(!god); //revert changes outside estate limits
                     }
                 }
                 else
@@ -708,7 +709,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
             // Not a good permissions check (see client_OnModifyTerrain above), need to check the entire area.
             // for now check a point in the centre of the region
 
-            if (m_scene.ExternalChecks.ExternalChecksCanTerraformLand(remoteClient.AgentId, new Vector3(127, 127, 0)))
+            if (m_scene.ExternalChecks.ExternalChecksCanIssueEstateCommand(remoteClient.AgentId, true))
             {
                 InterfaceBakeTerrain(null); //bake terrain does not use the passed in parameter
             }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index d141ffe..09d3d79 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3470,7 +3470,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             ITerrainModule tm = m_ScriptEngine.World.RequestModuleInterface<ITerrainModule>();
             if (tm != null)
             {
-                tm.ModifyTerrain(m_host.AbsolutePosition, (byte) brush, (byte) action, m_host.OwnerID);
+                tm.ModifyTerrain(m_host.OwnerID, m_host.AbsolutePosition, (byte) brush, (byte) action, m_host.OwnerID);
             }
         }
 
-- 
cgit v1.1