mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
Mantis#1207. Thank you, TGlion for a patch that addresses:
Implementation of llModifyLand() and There is a bug on permission-check of land-terraforming: x an y-coordinates are interchanged on function-call ExternalChecksCanTerraformLand. Correct: x is west, and y is north. 2) Missing check of "Other allow to terraform-flag" (Parcel.ParcelFlags.AllowTerraform)
This commit is contained in:
@@ -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
|
||||
@@ -258,6 +259,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
|
||||
throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modify Land
|
||||
/// </summary>
|
||||
/// <param name="pos">Land-position (X,Y,0)</param>
|
||||
/// <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)
|
||||
{
|
||||
client_OnModifyTerrain((float)pos.Z, (float)0.25, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the current heightmap to a specified stream.
|
||||
/// </summary>
|
||||
@@ -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<m_channel.Width && y<m_channel.Height)
|
||||
{
|
||||
if (m_scene.ExternalChecks.ExternalChecksCanTerraformLand(agentId, new Vector3(x,y,0)))
|
||||
{
|
||||
allowMask[x, y] = true;
|
||||
allowed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (allowed)
|
||||
{
|
||||
m_painteffects[(StandardTerrainEffects) action].PaintEffect(
|
||||
m_channel, west, south, size, seconds);
|
||||
m_channel, allowMask, west, south, height, size, seconds);
|
||||
|
||||
CheckForTerrainUpdates(true); //revert changes outside estate limits
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Debug("Unknown terrain brush type " + action);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_floodeffects.ContainsKey((StandardTerrainEffects) action))
|
||||
{
|
||||
bool[,] fillArea = new bool[m_channel.Width,m_channel.Height];
|
||||
fillArea.Initialize();
|
||||
m_log.Debug("Unknown terrain brush type " + action);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_floodeffects.ContainsKey((StandardTerrainEffects) action))
|
||||
{
|
||||
bool[,] fillArea = new bool[m_channel.Width,m_channel.Height];
|
||||
fillArea.Initialize();
|
||||
|
||||
int x;
|
||||
for (x = 0; x < m_channel.Width; x++)
|
||||
int x;
|
||||
for (x = 0; x < m_channel.Width; x++)
|
||||
{
|
||||
int y;
|
||||
for (y = 0; y < m_channel.Height; y++)
|
||||
{
|
||||
int y;
|
||||
for (y = 0; y < m_channel.Height; y++)
|
||||
if (x < east && 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user