From 48d86fb23f7ae0e7919274d67fc25f590e6845b1 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Tue, 7 Oct 2008 14:49:12 +0000
Subject: * Apply http://opensimulator.org/mantis/view.php?id=1207 *
Implmements llModifyLand() and a check for the "Allow others to terraform
flag" * Thanks tglion!
---
.../Modules/World/Terrain/TerrainModule.cs | 97 ++++++++++++++++------
1 file changed, 72 insertions(+), 25 deletions(-)
(limited to 'OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs')
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
index ed4075c..3b8debb 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
@@ -40,6 +40,7 @@ using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes;
using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes;
using OpenSim.Region.Environment.Scenes;
+
namespace OpenSim.Region.Environment.Modules.World.Terrain
{
public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule
@@ -259,6 +260,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
}
///
+ /// Modify Land
+ ///
+ /// Land-position (X,Y,0)
+ /// The size of the brush (0=small, 1=medium, 2=large)
+ /// 0=LAND_LEVEL, 1=LAND_RAISE, 2=LAND_LOWER, 3=LAND_SMOOTH, 4=LAND_NOISE, 5=LAND_REVERT
+ /// UUID of script-owner
+ public void ModifyTerrain(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);
+ }
+
+ ///
/// Saves the current heightmap to a specified stream.
///
/// The destination filename. Used here only to identify the image type
@@ -587,58 +600,92 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
);
}
- private void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west,
- float south, float east, IClientAPI remoteClient)
+ private void client_OnModifyTerrain(float height, float seconds, byte size, byte action,
+ float north, float west, float south, float east, UUID agentId)
{
- // Not a good permissions check, if in area mode, need to check the entire area.
- if (m_scene.ExternalChecks.ExternalChecksCanTerraformLand(remoteClient.AgentId, new Vector3(north, west, 0)))
+ bool allowed = false;
+ if (north == south && east == west)
{
- if (north == south && east == west)
+ if (m_painteffects.ContainsKey((StandardTerrainEffects) action))
{
- if (m_painteffects.ContainsKey((StandardTerrainEffects) action))
+ bool[,] allowMask = new bool[m_channel.Width,m_channel.Height];
+ allowMask.Initialize();
+ int n = size + 1;
+ if (n > 2)
+ n = 4;
+
+ int zx = (int) (west + 0.5);
+ int zy = (int) (north + 0.5);
+
+ int dx;
+ for (dx=-n; dx<=n; dx++)
+ {
+ int dy;
+ for (dy=-n; dy<=n; dy++)
+ {
+ int x = zx + dx;
+ int y = zy + dy;
+ if (x>=0 && y>=0 && x west)
{
- if (x < east && x > west)
+ if (y < north && y > south)
{
- if (y < north && y > south)
+ if (m_scene.ExternalChecks.ExternalChecksCanTerraformLand(agentId, new Vector3(x,y,0)))
{
fillArea[x, y] = true;
+ allowed = true;
}
}
}
}
+ }
+ if (allowed)
+ {
m_floodeffects[(StandardTerrainEffects) action].FloodEffect(
m_channel, fillArea, size);
CheckForTerrainUpdates(true); //revert changes outside estate limits
}
- else
- {
- m_log.Debug("Unknown terrain flood type " + action);
- }
+ }
+ else
+ {
+ m_log.Debug("Unknown terrain flood type " + action);
}
}
}
--
cgit v1.1