diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs
similarity index 71%
rename from OpenSim/Region/Environment/EstateManager.cs
rename to OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs
index b3ffd10144..daabd9b0a8 100644
--- a/OpenSim/Region/Environment/EstateManager.cs
+++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs
@@ -1,699 +1,744 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSim Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using libsecondlife;
-using libsecondlife.Packets;
-using log4net;
-using OpenSim.Framework;
-using OpenSim.Region.Environment.Scenes;
-
-namespace OpenSim.Region.Environment
-{
- ///
- /// Processes requests regarding estates. Refer to EstateSettings.cs in OpenSim.Framework. Types for all of the core settings
- ///
- public class EstateManager
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- private Scene m_scene;
- private RegionInfo m_regInfo;
-
- public enum EstateAccessCodex : uint
- {
- AccessOptions = 17,
- AllowedGroups = 18,
- EstateBans = 20,
- EstateManagers = 24
- }
-
-
- public EstateManager(Scene scene, RegionInfo reginfo)
- {
- m_scene = scene;
- m_regInfo = reginfo;
- }
-
- private bool convertParamStringToBool(byte[] field)
- {
- string s = Helpers.FieldToUTF8String(field);
- if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
- {
- return true;
- }
- return false;
- }
-
- ///
- /// Sets terrain texture heights for each of the four corners of the region - textures are distributed as a linear range between the two heights.
- ///
- /// Which corner
- /// Minimum height that texture range should cover
- /// Maximum height that texture range should cover
- public void setEstateTextureRange(Int16 corner, float lowValue, float highValue)
- {
- switch (corner)
- {
- case 0:
- m_regInfo.EstateSettings.terrainStartHeight0 = lowValue;
- m_regInfo.EstateSettings.terrainHeightRange0 = highValue;
- break;
- case 1:
- m_regInfo.EstateSettings.terrainStartHeight1 = lowValue;
- m_regInfo.EstateSettings.terrainHeightRange1 = highValue;
- break;
- case 2:
- m_regInfo.EstateSettings.terrainStartHeight2 = lowValue;
- m_regInfo.EstateSettings.terrainHeightRange2 = highValue;
- break;
- case 3:
- m_regInfo.EstateSettings.terrainStartHeight3 = lowValue;
- m_regInfo.EstateSettings.terrainHeightRange3 = highValue;
- break;
- }
- }
-
- ///
- /// Sets the 'detail' terrain texture on each of the bands.
- ///
- /// Which texture band
- /// The UUID of the texture
- public void setTerrainTexture(Int16 band, LLUUID textureUUID)
- {
- switch (band)
- {
- case 0:
- m_regInfo.EstateSettings.terrainDetail0 = textureUUID;
- break;
- case 1:
- m_regInfo.EstateSettings.terrainDetail1 = textureUUID;
- break;
- case 2:
- m_regInfo.EstateSettings.terrainDetail2 = textureUUID;
- break;
- case 3:
- m_regInfo.EstateSettings.terrainDetail3 = textureUUID;
- break;
- }
- }
-
- ///
- /// Sets common region settings
- ///
- /// Water height of the waterplane (may not nessecarily be one value)
- /// Maximum amount terrain can be raised from previous baking
- /// Minimum amount terrain can be lowered from previous baking
- /// Use a fixed time of day on the sun?
- /// The offset hour of the day
- public void setRegionSettings(float WaterHeight, float TerrainRaiseLimit, float TerrainLowerLimit,
- bool UseFixedSun, float SunHour)
- {
- // Water Height
- m_regInfo.EstateSettings.waterHeight = WaterHeight;
-
- // Terraforming limits
- m_regInfo.EstateSettings.terrainRaiseLimit = TerrainRaiseLimit;
- m_regInfo.EstateSettings.terrainLowerLimit = TerrainLowerLimit;
-
- // Time of day / fixed sun
- m_regInfo.EstateSettings.useFixedSun = UseFixedSun;
- m_regInfo.EstateSettings.sunHour = SunHour;
- }
-
- #region Packet Handlers
-
- public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client)
- {
- switch (Helpers.FieldToUTF8String(packet.MethodData.Method))
- {
- case "getinfo":
-
- //System.Console.WriteLine("[ESTATE]: CLIENT--->" + packet.ToString());
- //sendRegionInfoPacketToAll();
- if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
- {
- sendDetailedEstateData(remote_client, packet);
- }
- break;
- case "setregioninfo":
- if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
- estateSetRegionInfoHandler(packet);
- break;
- case "texturebase":
- if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
- estateTextureBaseHandler(packet);
- break;
- case "texturedetail":
- if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
- estateTextureDetailHandler(packet);
- break;
- case "textureheights":
- if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
- estateTextureHeightsHandler(packet);
- break;
- case "texturecommit":
- sendRegionHandshakeToAll();
- break;
- case "setregionterrain":
- if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
- estateSetRegionTerrainHandler(packet);
- break;
- case "restart":
- if (m_scene.PermissionsMngr.CanRestartSim(remote_client.AgentId))
- {
- estateRestartSim(packet);
- }
- break;
- case "estatechangecovenantid":
- if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
- {
- EstateChangeCovenant(packet);
- }
- break;
- case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
- if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
- {
- estateAccessDelta(remote_client, packet);
- }
- break;
- case "simulatormessage":
- if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
- {
- SendSimulatorBlueBoxMessage(remote_client, packet);
- }
- break;
- case "instantmessage":
- if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
- {
- SendEstateBlueBoxMessage(remote_client, packet);
- }
- break;
- case "setregiondebug":
- if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
- {
- SetRegionDebug(remote_client, packet);
- }
- break;
- case "teleporthomeuser":
- if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
- {
- TeleportOneUserHome(remote_client,packet);
- }
- break;
- default:
- m_log.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString());
- break;
- }
-
-
- }
-
- private void TeleportOneUserHome(object remove_client,EstateOwnerMessagePacket packet)
- {
- LLUUID invoice = packet.MethodData.Invoice;
- LLUUID SenderID = packet.AgentData.AgentID;
- LLUUID Prey = LLUUID.Zero;
-
- Helpers.TryParse(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter),out Prey);
- if (Prey != LLUUID.Zero)
- {
- ScenePresence s = m_scene.GetScenePresence(Prey);
- if (s != null)
- {
- m_scene.TeleportClientHome(Prey, s.ControllingClient);
- }
- }
- }
-
- private void SetRegionDebug(IClientAPI remote_client, EstateOwnerMessagePacket packet)
- {
- LLUUID invoice = packet.MethodData.Invoice;
- LLUUID SenderID = packet.AgentData.AgentID;
- bool scripted = convertParamStringToBool(packet.ParamList[0].Parameter);
- bool collisionEvents = convertParamStringToBool(packet.ParamList[1].Parameter);
- bool physics = convertParamStringToBool(packet.ParamList[2].Parameter);
-
- if (physics)
- {
- m_scene.RegionInfo.EstateSettings.regionFlags |= Simulator.RegionFlags.SkipPhysics;
- }
- else
- {
- m_scene.RegionInfo.EstateSettings.regionFlags &= ~Simulator.RegionFlags.SkipPhysics;
- }
-
- if (scripted)
- {
- m_scene.RegionInfo.EstateSettings.regionFlags |= Simulator.RegionFlags.SkipScripts;
- }
- else
- {
- m_scene.RegionInfo.EstateSettings.regionFlags &= ~Simulator.RegionFlags.SkipScripts;
- }
-
-
- m_scene.SetSceneCoreDebug(scripted, collisionEvents, physics);
- }
-
- private void SendSimulatorBlueBoxMessage(IClientAPI remote_client, EstateOwnerMessagePacket packet)
- {
- LLUUID invoice = packet.MethodData.Invoice;
- LLUUID SenderID = new LLUUID(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter));
- string SenderName = Helpers.FieldToUTF8String(packet.ParamList[3].Parameter);
- string Message = Helpers.FieldToUTF8String(packet.ParamList[4].Parameter);
- m_scene.SendRegionMessageFromEstateTools(SenderID, packet.AgentData.SessionID, SenderName, Message);
-
- }
- private void SendEstateBlueBoxMessage(IClientAPI remote_client, EstateOwnerMessagePacket packet)
- {
- LLUUID invoice = packet.MethodData.Invoice;
- LLUUID SenderID = packet.AgentData.AgentID;
- string SenderName = Helpers.FieldToUTF8String(packet.ParamList[0].Parameter);
- string Message = Helpers.FieldToUTF8String(packet.ParamList[1].Parameter);
- m_scene.SendEstateMessageFromEstateTools(SenderID, packet.AgentData.SessionID, SenderName, Message);
-
- }
- private void sendDetailedEstateData(IClientAPI remote_client, EstateOwnerMessagePacket packet)
- {
-
- LLUUID invoice = packet.MethodData.Invoice;
- packet.AgentData.TransactionID = LLUUID.Random();
- packet.MethodData.Method = Helpers.StringToField("estateupdateinfo");
- EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[9];
-
- for (int i = 0; i < 9; i++)
- {
- returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
- }
-
- //Sending Estate Settings
- returnblock[0].Parameter = Helpers.StringToField(m_scene.RegionInfo.EstateSettings.estateName);
- returnblock[1].Parameter = Helpers.StringToField(m_scene.RegionInfo.MasterAvatarAssignedUUID.ToString());
- returnblock[2].Parameter = Helpers.StringToField(m_scene.RegionInfo.EstateSettings.estateID.ToString());
-
- // TODO: Resolve Magic numbers here
- returnblock[3].Parameter = Helpers.StringToField("269516800");
- returnblock[4].Parameter = Helpers.StringToField("0");
- returnblock[5].Parameter = Helpers.StringToField("1");
- returnblock[6].Parameter = Helpers.StringToField(m_scene.RegionInfo.RegionID.ToString());
- returnblock[7].Parameter = Helpers.StringToField("1160895077");
- returnblock[8].Parameter = Helpers.StringToField("1");
-
- packet.ParamList = returnblock;
- packet.Header.Reliable = false;
- //System.Console.WriteLine("[ESTATE]: SIM--->" + packet.ToString());
- remote_client.OutPacket(packet, ThrottleOutPacketType.Task);
-
- sendEstateManagerList(remote_client, packet);
-
- }
-
- private void sendEstateManagerList(IClientAPI remote_client, EstateOwnerMessagePacket packet)
- {
- LLUUID invoice = packet.MethodData.Invoice;
-
- //Sending Estate Managers
- packet = new EstateOwnerMessagePacket();
- packet.AgentData.TransactionID = LLUUID.Random();
- packet.AgentData.AgentID = remote_client.AgentId;
- packet.AgentData.SessionID = remote_client.SessionId;
- packet.MethodData.Invoice = invoice;
- packet.MethodData.Method = Helpers.StringToField("setaccess");
-
- LLUUID[] EstateManagers = m_scene.RegionInfo.EstateSettings.estateManagers;
-
- EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + EstateManagers.Length];
-
- for (int i = 0; i < (6 + EstateManagers.Length); i++)
- {
- returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
- }
- int j = 0;
-
- returnblock[j].Parameter = Helpers.StringToField(m_scene.RegionInfo.EstateSettings.estateID.ToString()); j++;
- returnblock[j].Parameter = Helpers.StringToField(((int)EstateAccessCodex.EstateManagers).ToString()); j++;
- returnblock[j].Parameter = Helpers.StringToField("0"); j++;
- returnblock[j].Parameter = Helpers.StringToField("0"); j++;
- returnblock[j].Parameter = Helpers.StringToField("0"); j++;
- returnblock[j].Parameter = Helpers.StringToField(EstateManagers.Length.ToString()); j++;
- for (int i = 0; i < EstateManagers.Length; i++)
- {
- returnblock[j].Parameter = EstateManagers[i].GetBytes(); j++;
- }
- packet.ParamList = returnblock;
- packet.Header.Reliable = false;
- //System.Console.WriteLine("[ESTATE]: SIM--->" + packet.ToString());
- remote_client.OutPacket(packet, ThrottleOutPacketType.Task);
- }
-
- private void estateAccessDelta(IClientAPI remote_client, EstateOwnerMessagePacket packet)
- {
- // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc.
- int estateAccessType = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter));
-
- switch (estateAccessType)
- {
- case 256:
-
- // This needs to be updated for SuperEstateOwnerUser.. a non existing user in the estatesettings.xml
- // So make sure you really trust your region owners. because they can add other estate manaagers to your other estates
- if (packet.AgentData.AgentID == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.PermissionsMngr.BypassPermissions)
- {
- m_scene.RegionInfo.EstateSettings.AddEstateManager(new LLUUID(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)));
- sendEstateManagerList(remote_client, packet);
- }
- else
- {
- remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
- }
-
- break;
- case 512:
- // This needs to be updated for SuperEstateOwnerUser.. a non existing user in the estatesettings.xml
- // So make sure you really trust your region owners. because they can add other estate manaagers to your other estates
- if (packet.AgentData.AgentID == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.PermissionsMngr.BypassPermissions)
- {
- m_scene.RegionInfo.EstateSettings.RemoveEstateManager(new LLUUID(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)));
- sendEstateManagerList(remote_client, packet);
- }
- else
- {
- remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
- }
- break;
-
- default:
-
- m_log.Error("EstateOwnerMessage: Unknown EstateAccessType requested in estateAccessDelta\n" + packet.ToString());
- break;
- }
- //m_log.Error("EstateOwnerMessage: estateAccessDelta\n" + packet.ToString());
-
-
- }
- private void estateSetRegionInfoHandler(EstateOwnerMessagePacket packet)
- {
- if (packet.ParamList.Length != 9)
- {
- m_log.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length");
- }
- else
- {
- m_regInfo.EstateSettings.regionFlags = Simulator.RegionFlags.None;
-
- if (convertParamStringToBool(packet.ParamList[0].Parameter))
- {
- m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
- Simulator.RegionFlags.BlockTerraform;
- }
-
- if (convertParamStringToBool(packet.ParamList[1].Parameter))
- {
- m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
- Simulator.RegionFlags.NoFly;
- }
-
- if (convertParamStringToBool(packet.ParamList[2].Parameter))
- {
- m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
- Simulator.RegionFlags.AllowDamage;
- }
-
- if (convertParamStringToBool(packet.ParamList[3].Parameter) == false)
- {
- m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
- Simulator.RegionFlags.BlockLandResell;
- }
-
-
- int tempMaxAgents =
- Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter)));
- m_regInfo.EstateSettings.maxAgents = (byte) tempMaxAgents;
-
- float tempObjectBonusFactor =
- (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
- m_regInfo.EstateSettings.objectBonusFactor = tempObjectBonusFactor;
-
- int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter));
- m_regInfo.EstateSettings.simAccess = (Simulator.SimAccess) tempMatureLevel;
-
-
- if (convertParamStringToBool(packet.ParamList[7].Parameter))
- {
- m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
- Simulator.RegionFlags.RestrictPushObject;
- }
-
- if (convertParamStringToBool(packet.ParamList[8].Parameter))
- {
- m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
- Simulator.RegionFlags.AllowParcelChanges;
- }
-
- sendRegionInfoPacketToAll();
- }
- }
-
- private void estateSetRegionTerrainHandler(EstateOwnerMessagePacket packet)
- {
- if (packet.ParamList.Length != 9)
- {
- m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
- }
- else
- {
- try
- {
- string tmp;
- tmp = Helpers.FieldToUTF8String(packet.ParamList[0].Parameter);
- if (!tmp.Contains(".")) tmp += ".00";
- float WaterHeight = (float)Convert.ToDecimal(tmp);
- tmp = Helpers.FieldToUTF8String(packet.ParamList[1].Parameter);
- if (!tmp.Contains(".")) tmp += ".00";
- float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp);
- tmp = Helpers.FieldToUTF8String(packet.ParamList[2].Parameter);
- if (!tmp.Contains(".")) tmp += ".00";
- float TerrainLowerLimit = (float)Convert.ToDecimal(tmp);
- bool UseFixedSun = convertParamStringToBool(packet.ParamList[4].Parameter);
- float SunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
-
- setRegionSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseFixedSun, SunHour);
-
- sendRegionInfoPacketToAll();
- }
- catch (Exception ex)
- {
- m_log.Error("EstateManager: Exception while setting terrain settings: \n" + packet.ToString() + "\n" + ex.ToString());
- }
- }
- }
-
- private void estateTextureHeightsHandler(EstateOwnerMessagePacket packet)
- {
- foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
- {
- string s = Helpers.FieldToUTF8String(block.Parameter);
- string[] splitField = s.Split(' ');
- if (splitField.Length == 3)
- {
- Int16 corner = Convert.ToInt16(splitField[0]);
- float lowValue = (float) Convert.ToDecimal(splitField[1]);
- float highValue = (float) Convert.ToDecimal(splitField[2]);
-
- setEstateTextureRange(corner, lowValue, highValue);
- }
- }
- }
-
- private void estateTextureDetailHandler(EstateOwnerMessagePacket packet)
- {
- foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
- {
- string s = Helpers.FieldToUTF8String(block.Parameter);
- string[] splitField = s.Split(' ');
- if (splitField.Length == 2)
- {
- Int16 corner = Convert.ToInt16(splitField[0]);
- LLUUID textureUUID = new LLUUID(splitField[1]);
-
- setTerrainTexture(corner, textureUUID);
- }
- }
- }
-
- private void estateTextureBaseHandler(EstateOwnerMessagePacket packet)
- {
- foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
- {
- string s = Helpers.FieldToUTF8String(block.Parameter);
- string[] splitField = s.Split(' ');
- if (splitField.Length == 2)
- {
- LLUUID tempUUID = new LLUUID(splitField[1]);
- switch (Convert.ToInt16(splitField[0]))
- {
- case 0:
- m_regInfo.EstateSettings.terrainBase0 = tempUUID;
- break;
- case 1:
- m_regInfo.EstateSettings.terrainBase1 = tempUUID;
- break;
- case 2:
- m_regInfo.EstateSettings.terrainBase2 = tempUUID;
- break;
- case 3:
- m_regInfo.EstateSettings.terrainBase3 = tempUUID;
- break;
- }
- }
- }
- }
-
- private void estateRestartSim(EstateOwnerMessagePacket packet)
- {
- // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
- foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
- {
- float timeSeconds = 0;
- Helpers.TryParse(Helpers.FieldToUTF8String(block.Parameter), out timeSeconds);
- timeSeconds = (int)timeSeconds;
- m_scene.Restart(timeSeconds);
-
- }
- }
-
- private void EstateChangeCovenant(EstateOwnerMessagePacket packet)
- {
- foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
- {
- LLUUID newCovenantID = new LLUUID(Helpers.FieldToUTF8String(block.Parameter));
- m_regInfo.CovenantID = newCovenantID;
- m_scene.RegionInfo.SaveEstatecovenantUUID(newCovenantID);
- }
- }
-
- public void HandleRegionInfoRequest(IClientAPI client, LLUUID sessionID)
- {
- RegionInfoPacket rinfopack = new RegionInfoPacket();
- RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
- rinfopack.AgentData.AgentID = client.AgentId;
- rinfopack.AgentData.SessionID = client.SessionId;
- rinfoblk.BillableFactor = m_regInfo.EstateSettings.billableFactor;
- rinfoblk.EstateID = m_regInfo.EstateSettings.estateID;
- rinfoblk.MaxAgents = m_regInfo.EstateSettings.maxAgents;
- rinfoblk.ObjectBonusFactor = m_regInfo.EstateSettings.objectBonusFactor;
- rinfoblk.ParentEstateID = m_regInfo.EstateSettings.parentEstateID;
- rinfoblk.PricePerMeter = m_regInfo.EstateSettings.pricePerMeter;
- rinfoblk.RedirectGridX = m_regInfo.EstateSettings.redirectGridX;
- rinfoblk.RedirectGridY = m_regInfo.EstateSettings.redirectGridY;
- rinfoblk.RegionFlags = (uint)( m_regInfo.EstateSettings.regionFlags);
- rinfoblk.SimAccess = (byte) m_regInfo.EstateSettings.simAccess;
- rinfoblk.SunHour = m_regInfo.EstateSettings.sunHour;
- rinfoblk.TerrainLowerLimit = m_regInfo.EstateSettings.terrainLowerLimit;
- rinfoblk.TerrainRaiseLimit = m_regInfo.EstateSettings.terrainRaiseLimit;
- rinfoblk.UseEstateSun = !m_regInfo.EstateSettings.useFixedSun;
- rinfoblk.WaterHeight = m_regInfo.EstateSettings.waterHeight;
- rinfoblk.SimName = Helpers.StringToField(m_regInfo.RegionName);
-
- rinfopack.RegionInfo = rinfoblk;
-
- client.OutPacket(rinfopack, ThrottleOutPacketType.Task);
- }
-
- public void HandleEstateCovenantRequest(IClientAPI client, LLUUID sessionID)
- {
- EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
- EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
- edata.CovenantID = m_regInfo.CovenantID;
- edata.CovenantTimestamp = 0;
- edata.EstateOwnerID = m_regInfo.MasterAvatarAssignedUUID;
- edata.EstateName =
- Helpers.StringToField(m_regInfo.MasterAvatarFirstName + " " + m_regInfo.MasterAvatarLastName);
- einfopack.Data = edata;
- client.OutPacket(einfopack, ThrottleOutPacketType.Task);
- }
-
- #endregion
-
- #region Outgoing Packets
-
- public void sendRegionInfoPacketToAll()
- {
- List avatars = m_scene.GetAvatars();
-
- for (int i = 0; i < avatars.Count; i++)
- {
- sendRegionInfoPacket(avatars[i].ControllingClient);
- }
- }
-
- public void sendRegionHandshakeToAll()
- {
- m_scene.Broadcast(
- sendRegionHandshake
- );
- }
-
- public void sendRegionInfoPacket(IClientAPI remote_client)
- {
- AgentCircuitData circuitData = remote_client.RequestClientInfo();
-
- RegionInfoPacket regionInfoPacket = new RegionInfoPacket();
- regionInfoPacket.AgentData.AgentID = circuitData.AgentID;
- regionInfoPacket.AgentData.SessionID = circuitData.SessionID;
- regionInfoPacket.RegionInfo.BillableFactor = m_regInfo.EstateSettings.billableFactor;
- regionInfoPacket.RegionInfo.EstateID = m_regInfo.EstateSettings.estateID;
- regionInfoPacket.RegionInfo.MaxAgents = m_regInfo.EstateSettings.maxAgents;
- regionInfoPacket.RegionInfo.ObjectBonusFactor = m_regInfo.EstateSettings.objectBonusFactor;
- regionInfoPacket.RegionInfo.ParentEstateID = m_regInfo.EstateSettings.parentEstateID;
- regionInfoPacket.RegionInfo.PricePerMeter = m_regInfo.EstateSettings.pricePerMeter;
- regionInfoPacket.RegionInfo.RedirectGridX = m_regInfo.EstateSettings.redirectGridX;
- regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.EstateSettings.redirectGridY;
- regionInfoPacket.RegionInfo.RegionFlags = (uint)(m_regInfo.EstateSettings.regionFlags);
- regionInfoPacket.RegionInfo.SimAccess = (byte) m_regInfo.EstateSettings.simAccess;
- regionInfoPacket.RegionInfo.SimName = Helpers.StringToField(m_regInfo.RegionName);
- regionInfoPacket.RegionInfo.SunHour = m_regInfo.EstateSettings.sunHour;
- regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.EstateSettings.terrainLowerLimit;
- regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_regInfo.EstateSettings.terrainRaiseLimit;
- regionInfoPacket.RegionInfo.UseEstateSun = !m_regInfo.EstateSettings.useFixedSun;
- regionInfoPacket.RegionInfo.WaterHeight = m_regInfo.EstateSettings.waterHeight;
-
-
- remote_client.OutPacket(regionInfoPacket, ThrottleOutPacketType.Task);
- }
-
- public void sendRegionHandshake(IClientAPI remoteClient)
- {
- remoteClient.SendRegionHandshake(m_regInfo);
- }
-
- #endregion
- }
-}
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSim Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+
+using libsecondlife;
+using libsecondlife.Packets;
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+using OpenSim.Framework;
+using Nini.Config;
+using log4net;
+
+namespace OpenSim.Region.Environment.Modules.World.Estate
+{
+ public class EstateManagementModule : IRegionModule
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private Scene m_scene;
+
+ public enum EstateAccessCodex : uint
+ {
+ AccessOptions = 17,
+ AllowedGroups = 18,
+ EstateBans = 20,
+ EstateManagers = 24
+ }
+
+
+ #region Helper Functions
+
+ private bool convertParamStringToBool(byte[] field)
+ {
+ string s = Helpers.FieldToUTF8String(field);
+ if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
+ {
+ return true;
+ }
+ return false;
+ }
+
+ ///
+ /// Sets terrain texture heights for each of the four corners of the region - textures are distributed as a linear range between the two heights.
+ ///
+ /// Which corner
+ /// Minimum height that texture range should cover
+ /// Maximum height that texture range should cover
+ public void setEstateTextureRange(Int16 corner, float lowValue, float highValue)
+ {
+ switch (corner)
+ {
+ case 0:
+ m_scene.RegionInfo.EstateSettings.terrainStartHeight0 = lowValue;
+ m_scene.RegionInfo.EstateSettings.terrainHeightRange0 = highValue;
+ break;
+ case 1:
+ m_scene.RegionInfo.EstateSettings.terrainStartHeight1 = lowValue;
+ m_scene.RegionInfo.EstateSettings.terrainHeightRange1 = highValue;
+ break;
+ case 2:
+ m_scene.RegionInfo.EstateSettings.terrainStartHeight2 = lowValue;
+ m_scene.RegionInfo.EstateSettings.terrainHeightRange2 = highValue;
+ break;
+ case 3:
+ m_scene.RegionInfo.EstateSettings.terrainStartHeight3 = lowValue;
+ m_scene.RegionInfo.EstateSettings.terrainHeightRange3 = highValue;
+ break;
+ }
+ }
+
+ ///
+ /// Sets the 'detail' terrain texture on each of the bands.
+ ///
+ /// Which texture band
+ /// The UUID of the texture
+ public void setTerrainTexture(Int16 band, LLUUID textureUUID)
+ {
+ switch (band)
+ {
+ case 0:
+ m_scene.RegionInfo.EstateSettings.terrainDetail0 = textureUUID;
+ break;
+ case 1:
+ m_scene.RegionInfo.EstateSettings.terrainDetail1 = textureUUID;
+ break;
+ case 2:
+ m_scene.RegionInfo.EstateSettings.terrainDetail2 = textureUUID;
+ break;
+ case 3:
+ m_scene.RegionInfo.EstateSettings.terrainDetail3 = textureUUID;
+ break;
+ }
+ }
+
+ ///
+ /// Sets common region settings
+ ///
+ /// Water height of the waterplane (may not nessecarily be one value)
+ /// Maximum amount terrain can be raised from previous baking
+ /// Minimum amount terrain can be lowered from previous baking
+ /// Use a fixed time of day on the sun?
+ /// The offset hour of the day
+ public void setRegionSettings(float WaterHeight, float TerrainRaiseLimit, float TerrainLowerLimit,
+ bool UseFixedSun, float SunHour)
+ {
+ // Water Height
+ m_scene.RegionInfo.EstateSettings.waterHeight = WaterHeight;
+
+ // Terraforming limits
+ m_scene.RegionInfo.EstateSettings.terrainRaiseLimit = TerrainRaiseLimit;
+ m_scene.RegionInfo.EstateSettings.terrainLowerLimit = TerrainLowerLimit;
+
+ // Time of day / fixed sun
+ m_scene.RegionInfo.EstateSettings.useFixedSun = UseFixedSun;
+ m_scene.RegionInfo.EstateSettings.sunHour = SunHour;
+ }
+ #endregion
+
+ #region Packet Handlers
+
+ public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client)
+ {
+ switch (Helpers.FieldToUTF8String(packet.MethodData.Method))
+ {
+ case "getinfo":
+
+ //System.Console.WriteLine("[ESTATE]: CLIENT--->" + packet.ToString());
+ //sendRegionInfoPacketToAll();
+ if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
+ {
+ sendDetailedEstateData(remote_client, packet);
+ }
+ break;
+ case "setregioninfo":
+ if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
+ estateSetRegionInfoHandler(packet);
+ break;
+ case "texturebase":
+ if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
+ estateTextureBaseHandler(packet);
+ break;
+ case "texturedetail":
+ if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
+ estateTextureDetailHandler(packet);
+ break;
+ case "textureheights":
+ if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
+ estateTextureHeightsHandler(packet);
+ break;
+ case "texturecommit":
+ sendRegionHandshakeToAll();
+ break;
+ case "setregionterrain":
+ if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
+ estateSetRegionTerrainHandler(packet);
+ break;
+ case "restart":
+ if (m_scene.PermissionsMngr.CanRestartSim(remote_client.AgentId))
+ {
+ estateRestartSim(packet);
+ }
+ break;
+ case "estatechangecovenantid":
+ if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
+ {
+ EstateChangeCovenant(packet);
+ }
+ break;
+ case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
+ if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
+ {
+ estateAccessDelta(remote_client, packet);
+ }
+ break;
+ case "simulatormessage":
+ if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
+ {
+ SendSimulatorBlueBoxMessage(remote_client, packet);
+ }
+ break;
+ case "instantmessage":
+ if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
+ {
+ SendEstateBlueBoxMessage(remote_client, packet);
+ }
+ break;
+ case "setregiondebug":
+ if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
+ {
+ SetRegionDebug(remote_client, packet);
+ }
+ break;
+ case "teleporthomeuser":
+ if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
+ {
+ TeleportOneUserHome(remote_client, packet);
+ }
+ break;
+ default:
+ m_log.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString());
+ break;
+ }
+
+
+ }
+
+ private void TeleportOneUserHome(object remove_client, EstateOwnerMessagePacket packet)
+ {
+ LLUUID invoice = packet.MethodData.Invoice;
+ LLUUID SenderID = packet.AgentData.AgentID;
+ LLUUID Prey = LLUUID.Zero;
+
+ Helpers.TryParse(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter), out Prey);
+ if (Prey != LLUUID.Zero)
+ {
+ ScenePresence s = m_scene.GetScenePresence(Prey);
+ if (s != null)
+ {
+ m_scene.TeleportClientHome(Prey, s.ControllingClient);
+ }
+ }
+ }
+
+ private void SetRegionDebug(IClientAPI remote_client, EstateOwnerMessagePacket packet)
+ {
+ LLUUID invoice = packet.MethodData.Invoice;
+ LLUUID SenderID = packet.AgentData.AgentID;
+ bool scripted = convertParamStringToBool(packet.ParamList[0].Parameter);
+ bool collisionEvents = convertParamStringToBool(packet.ParamList[1].Parameter);
+ bool physics = convertParamStringToBool(packet.ParamList[2].Parameter);
+
+ if (physics)
+ {
+ m_scene.RegionInfo.EstateSettings.regionFlags |= Simulator.RegionFlags.SkipPhysics;
+ }
+ else
+ {
+ m_scene.RegionInfo.EstateSettings.regionFlags &= ~Simulator.RegionFlags.SkipPhysics;
+ }
+
+ if (scripted)
+ {
+ m_scene.RegionInfo.EstateSettings.regionFlags |= Simulator.RegionFlags.SkipScripts;
+ }
+ else
+ {
+ m_scene.RegionInfo.EstateSettings.regionFlags &= ~Simulator.RegionFlags.SkipScripts;
+ }
+
+
+ m_scene.SetSceneCoreDebug(scripted, collisionEvents, physics);
+ }
+
+ private void SendSimulatorBlueBoxMessage(IClientAPI remote_client, EstateOwnerMessagePacket packet)
+ {
+ LLUUID invoice = packet.MethodData.Invoice;
+ LLUUID SenderID = new LLUUID(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter));
+ string SenderName = Helpers.FieldToUTF8String(packet.ParamList[3].Parameter);
+ string Message = Helpers.FieldToUTF8String(packet.ParamList[4].Parameter);
+ m_scene.SendRegionMessageFromEstateTools(SenderID, packet.AgentData.SessionID, SenderName, Message);
+
+ }
+ private void SendEstateBlueBoxMessage(IClientAPI remote_client, EstateOwnerMessagePacket packet)
+ {
+ LLUUID invoice = packet.MethodData.Invoice;
+ LLUUID SenderID = packet.AgentData.AgentID;
+ string SenderName = Helpers.FieldToUTF8String(packet.ParamList[0].Parameter);
+ string Message = Helpers.FieldToUTF8String(packet.ParamList[1].Parameter);
+ m_scene.SendEstateMessageFromEstateTools(SenderID, packet.AgentData.SessionID, SenderName, Message);
+
+ }
+ private void sendDetailedEstateData(IClientAPI remote_client, EstateOwnerMessagePacket packet)
+ {
+
+ LLUUID invoice = packet.MethodData.Invoice;
+ packet.AgentData.TransactionID = LLUUID.Random();
+ packet.MethodData.Method = Helpers.StringToField("estateupdateinfo");
+ EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[9];
+
+ for (int i = 0; i < 9; i++)
+ {
+ returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
+ }
+
+ //Sending Estate Settings
+ returnblock[0].Parameter = Helpers.StringToField(m_scene.RegionInfo.EstateSettings.estateName);
+ returnblock[1].Parameter = Helpers.StringToField(m_scene.RegionInfo.MasterAvatarAssignedUUID.ToString());
+ returnblock[2].Parameter = Helpers.StringToField(m_scene.RegionInfo.EstateSettings.estateID.ToString());
+
+ // TODO: Resolve Magic numbers here
+ returnblock[3].Parameter = Helpers.StringToField("269516800");
+ returnblock[4].Parameter = Helpers.StringToField("0");
+ returnblock[5].Parameter = Helpers.StringToField("1");
+ returnblock[6].Parameter = Helpers.StringToField(m_scene.RegionInfo.RegionID.ToString());
+ returnblock[7].Parameter = Helpers.StringToField("1160895077");
+ returnblock[8].Parameter = Helpers.StringToField("1");
+
+ packet.ParamList = returnblock;
+ packet.Header.Reliable = false;
+ //System.Console.WriteLine("[ESTATE]: SIM--->" + packet.ToString());
+ remote_client.OutPacket(packet, ThrottleOutPacketType.Task);
+
+ sendEstateManagerList(remote_client, packet);
+
+ }
+
+ private void sendEstateManagerList(IClientAPI remote_client, EstateOwnerMessagePacket packet)
+ {
+ LLUUID invoice = packet.MethodData.Invoice;
+
+ //Sending Estate Managers
+ packet = new EstateOwnerMessagePacket();
+ packet.AgentData.TransactionID = LLUUID.Random();
+ packet.AgentData.AgentID = remote_client.AgentId;
+ packet.AgentData.SessionID = remote_client.SessionId;
+ packet.MethodData.Invoice = invoice;
+ packet.MethodData.Method = Helpers.StringToField("setaccess");
+
+ LLUUID[] EstateManagers = m_scene.RegionInfo.EstateSettings.estateManagers;
+
+ EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + EstateManagers.Length];
+
+ for (int i = 0; i < (6 + EstateManagers.Length); i++)
+ {
+ returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
+ }
+ int j = 0;
+
+ returnblock[j].Parameter = Helpers.StringToField(m_scene.RegionInfo.EstateSettings.estateID.ToString()); j++;
+ returnblock[j].Parameter = Helpers.StringToField(((int)EstateAccessCodex.EstateManagers).ToString()); j++;
+ returnblock[j].Parameter = Helpers.StringToField("0"); j++;
+ returnblock[j].Parameter = Helpers.StringToField("0"); j++;
+ returnblock[j].Parameter = Helpers.StringToField("0"); j++;
+ returnblock[j].Parameter = Helpers.StringToField(EstateManagers.Length.ToString()); j++;
+ for (int i = 0; i < EstateManagers.Length; i++)
+ {
+ returnblock[j].Parameter = EstateManagers[i].GetBytes(); j++;
+ }
+ packet.ParamList = returnblock;
+ packet.Header.Reliable = false;
+ //System.Console.WriteLine("[ESTATE]: SIM--->" + packet.ToString());
+ remote_client.OutPacket(packet, ThrottleOutPacketType.Task);
+ }
+
+ private void estateAccessDelta(IClientAPI remote_client, EstateOwnerMessagePacket packet)
+ {
+ // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc.
+ int estateAccessType = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter));
+
+ switch (estateAccessType)
+ {
+ case 256:
+
+ // This needs to be updated for SuperEstateOwnerUser.. a non existing user in the estatesettings.xml
+ // So make sure you really trust your region owners. because they can add other estate manaagers to your other estates
+ if (packet.AgentData.AgentID == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.PermissionsMngr.BypassPermissions)
+ {
+ m_scene.RegionInfo.EstateSettings.AddEstateManager(new LLUUID(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)));
+ sendEstateManagerList(remote_client, packet);
+ }
+ else
+ {
+ remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
+ }
+
+ break;
+ case 512:
+ // This needs to be updated for SuperEstateOwnerUser.. a non existing user in the estatesettings.xml
+ // So make sure you really trust your region owners. because they can add other estate manaagers to your other estates
+ if (packet.AgentData.AgentID == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.PermissionsMngr.BypassPermissions)
+ {
+ m_scene.RegionInfo.EstateSettings.RemoveEstateManager(new LLUUID(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)));
+ sendEstateManagerList(remote_client, packet);
+ }
+ else
+ {
+ remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
+ }
+ break;
+
+ default:
+
+ m_log.Error("EstateOwnerMessage: Unknown EstateAccessType requested in estateAccessDelta\n" + packet.ToString());
+ break;
+ }
+ //m_log.Error("EstateOwnerMessage: estateAccessDelta\n" + packet.ToString());
+
+
+ }
+ private void estateSetRegionInfoHandler(EstateOwnerMessagePacket packet)
+ {
+ if (packet.ParamList.Length != 9)
+ {
+ m_log.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length");
+ }
+ else
+ {
+ m_scene.RegionInfo.EstateSettings.regionFlags = Simulator.RegionFlags.None;
+
+ if (convertParamStringToBool(packet.ParamList[0].Parameter))
+ {
+ m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
+ Simulator.RegionFlags.BlockTerraform;
+ }
+
+ if (convertParamStringToBool(packet.ParamList[1].Parameter))
+ {
+ m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
+ Simulator.RegionFlags.NoFly;
+ }
+
+ if (convertParamStringToBool(packet.ParamList[2].Parameter))
+ {
+ m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
+ Simulator.RegionFlags.AllowDamage;
+ }
+
+ if (convertParamStringToBool(packet.ParamList[3].Parameter) == false)
+ {
+ m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
+ Simulator.RegionFlags.BlockLandResell;
+ }
+
+
+ int tempMaxAgents =
+ Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter)));
+ m_scene.RegionInfo.EstateSettings.maxAgents = (byte)tempMaxAgents;
+
+ float tempObjectBonusFactor =
+ (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
+ m_scene.RegionInfo.EstateSettings.objectBonusFactor = tempObjectBonusFactor;
+
+ int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter));
+ m_scene.RegionInfo.EstateSettings.simAccess = (Simulator.SimAccess)tempMatureLevel;
+
+
+ if (convertParamStringToBool(packet.ParamList[7].Parameter))
+ {
+ m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
+ Simulator.RegionFlags.RestrictPushObject;
+ }
+
+ if (convertParamStringToBool(packet.ParamList[8].Parameter))
+ {
+ m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
+ Simulator.RegionFlags.AllowParcelChanges;
+ }
+
+ sendRegionInfoPacketToAll();
+ }
+ }
+
+ private void estateSetRegionTerrainHandler(EstateOwnerMessagePacket packet)
+ {
+ if (packet.ParamList.Length != 9)
+ {
+ m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
+ }
+ else
+ {
+ try
+ {
+ string tmp;
+ tmp = Helpers.FieldToUTF8String(packet.ParamList[0].Parameter);
+ if (!tmp.Contains(".")) tmp += ".00";
+ float WaterHeight = (float)Convert.ToDecimal(tmp);
+ tmp = Helpers.FieldToUTF8String(packet.ParamList[1].Parameter);
+ if (!tmp.Contains(".")) tmp += ".00";
+ float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp);
+ tmp = Helpers.FieldToUTF8String(packet.ParamList[2].Parameter);
+ if (!tmp.Contains(".")) tmp += ".00";
+ float TerrainLowerLimit = (float)Convert.ToDecimal(tmp);
+ bool UseFixedSun = convertParamStringToBool(packet.ParamList[4].Parameter);
+ float SunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
+
+ setRegionSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseFixedSun, SunHour);
+
+ sendRegionInfoPacketToAll();
+ }
+ catch (Exception ex)
+ {
+ m_log.Error("EstateManager: Exception while setting terrain settings: \n" + packet.ToString() + "\n" + ex.ToString());
+ }
+ }
+ }
+
+ private void estateTextureHeightsHandler(EstateOwnerMessagePacket packet)
+ {
+ foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
+ {
+ string s = Helpers.FieldToUTF8String(block.Parameter);
+ string[] splitField = s.Split(' ');
+ if (splitField.Length == 3)
+ {
+ Int16 corner = Convert.ToInt16(splitField[0]);
+ float lowValue = (float)Convert.ToDecimal(splitField[1]);
+ float highValue = (float)Convert.ToDecimal(splitField[2]);
+
+ setEstateTextureRange(corner, lowValue, highValue);
+ }
+ }
+ }
+
+ private void estateTextureDetailHandler(EstateOwnerMessagePacket packet)
+ {
+ foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
+ {
+ string s = Helpers.FieldToUTF8String(block.Parameter);
+ string[] splitField = s.Split(' ');
+ if (splitField.Length == 2)
+ {
+ Int16 corner = Convert.ToInt16(splitField[0]);
+ LLUUID textureUUID = new LLUUID(splitField[1]);
+
+ setTerrainTexture(corner, textureUUID);
+ }
+ }
+ }
+
+ private void estateTextureBaseHandler(EstateOwnerMessagePacket packet)
+ {
+ foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
+ {
+ string s = Helpers.FieldToUTF8String(block.Parameter);
+ string[] splitField = s.Split(' ');
+ if (splitField.Length == 2)
+ {
+ LLUUID tempUUID = new LLUUID(splitField[1]);
+ switch (Convert.ToInt16(splitField[0]))
+ {
+ case 0:
+ m_scene.RegionInfo.EstateSettings.terrainBase0 = tempUUID;
+ break;
+ case 1:
+ m_scene.RegionInfo.EstateSettings.terrainBase1 = tempUUID;
+ break;
+ case 2:
+ m_scene.RegionInfo.EstateSettings.terrainBase2 = tempUUID;
+ break;
+ case 3:
+ m_scene.RegionInfo.EstateSettings.terrainBase3 = tempUUID;
+ break;
+ }
+ }
+ }
+ }
+
+ private void estateRestartSim(EstateOwnerMessagePacket packet)
+ {
+ // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
+ foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
+ {
+ float timeSeconds = 0;
+ Helpers.TryParse(Helpers.FieldToUTF8String(block.Parameter), out timeSeconds);
+ timeSeconds = (int)timeSeconds;
+ m_scene.Restart(timeSeconds);
+
+ }
+ }
+
+ private void EstateChangeCovenant(EstateOwnerMessagePacket packet)
+ {
+ foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
+ {
+ LLUUID newCovenantID = new LLUUID(Helpers.FieldToUTF8String(block.Parameter));
+ m_scene.RegionInfo.CovenantID = newCovenantID;
+ m_scene.RegionInfo.SaveEstatecovenantUUID(newCovenantID);
+ }
+ }
+
+ public void HandleRegionInfoRequest(IClientAPI client, LLUUID sessionID)
+ {
+ RegionInfoPacket rinfopack = new RegionInfoPacket();
+ RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
+ rinfopack.AgentData.AgentID = client.AgentId;
+ rinfopack.AgentData.SessionID = client.SessionId;
+ rinfoblk.BillableFactor = m_scene.RegionInfo.EstateSettings.billableFactor;
+ rinfoblk.EstateID = m_scene.RegionInfo.EstateSettings.estateID;
+ rinfoblk.MaxAgents = m_scene.RegionInfo.EstateSettings.maxAgents;
+ rinfoblk.ObjectBonusFactor = m_scene.RegionInfo.EstateSettings.objectBonusFactor;
+ rinfoblk.ParentEstateID = m_scene.RegionInfo.EstateSettings.parentEstateID;
+ rinfoblk.PricePerMeter = m_scene.RegionInfo.EstateSettings.pricePerMeter;
+ rinfoblk.RedirectGridX = m_scene.RegionInfo.EstateSettings.redirectGridX;
+ rinfoblk.RedirectGridY = m_scene.RegionInfo.EstateSettings.redirectGridY;
+ rinfoblk.RegionFlags = (uint)(m_scene.RegionInfo.EstateSettings.regionFlags);
+ rinfoblk.SimAccess = (byte)m_scene.RegionInfo.EstateSettings.simAccess;
+ rinfoblk.SunHour = m_scene.RegionInfo.EstateSettings.sunHour;
+ rinfoblk.TerrainLowerLimit = m_scene.RegionInfo.EstateSettings.terrainLowerLimit;
+ rinfoblk.TerrainRaiseLimit = m_scene.RegionInfo.EstateSettings.terrainRaiseLimit;
+ rinfoblk.UseEstateSun = !m_scene.RegionInfo.EstateSettings.useFixedSun;
+ rinfoblk.WaterHeight = m_scene.RegionInfo.EstateSettings.waterHeight;
+ rinfoblk.SimName = Helpers.StringToField(m_scene.RegionInfo.RegionName);
+
+ rinfopack.RegionInfo = rinfoblk;
+
+ client.OutPacket(rinfopack, ThrottleOutPacketType.Task);
+ }
+
+ public void HandleEstateCovenantRequest(IClientAPI client, LLUUID sessionID)
+ {
+ EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
+ EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
+ edata.CovenantID = m_scene.RegionInfo.CovenantID;
+ edata.CovenantTimestamp = 0;
+ edata.EstateOwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
+ edata.EstateName =
+ Helpers.StringToField(m_scene.RegionInfo.MasterAvatarFirstName + " " + m_scene.RegionInfo.MasterAvatarLastName);
+ einfopack.Data = edata;
+ client.OutPacket(einfopack, ThrottleOutPacketType.Task);
+ }
+
+ #endregion
+
+ #region Outgoing Packets
+
+ public void sendRegionInfoPacketToAll()
+ {
+ List avatars = m_scene.GetAvatars();
+
+ for (int i = 0; i < avatars.Count; i++)
+ {
+ sendRegionInfoPacket(avatars[i].ControllingClient);
+ }
+ }
+
+ public void sendRegionHandshakeToAll()
+ {
+ m_scene.Broadcast(
+ sendRegionHandshake
+ );
+ }
+
+ public void sendRegionInfoPacket(IClientAPI remote_client)
+ {
+ AgentCircuitData circuitData = remote_client.RequestClientInfo();
+
+ RegionInfoPacket regionInfoPacket = new RegionInfoPacket();
+ regionInfoPacket.AgentData.AgentID = circuitData.AgentID;
+ regionInfoPacket.AgentData.SessionID = circuitData.SessionID;
+ regionInfoPacket.RegionInfo.BillableFactor = m_scene.RegionInfo.EstateSettings.billableFactor;
+ regionInfoPacket.RegionInfo.EstateID = m_scene.RegionInfo.EstateSettings.estateID;
+ regionInfoPacket.RegionInfo.MaxAgents = m_scene.RegionInfo.EstateSettings.maxAgents;
+ regionInfoPacket.RegionInfo.ObjectBonusFactor = m_scene.RegionInfo.EstateSettings.objectBonusFactor;
+ regionInfoPacket.RegionInfo.ParentEstateID = m_scene.RegionInfo.EstateSettings.parentEstateID;
+ regionInfoPacket.RegionInfo.PricePerMeter = m_scene.RegionInfo.EstateSettings.pricePerMeter;
+ regionInfoPacket.RegionInfo.RedirectGridX = m_scene.RegionInfo.EstateSettings.redirectGridX;
+ regionInfoPacket.RegionInfo.RedirectGridY = m_scene.RegionInfo.EstateSettings.redirectGridY;
+ regionInfoPacket.RegionInfo.RegionFlags = (uint)(m_scene.RegionInfo.EstateSettings.regionFlags);
+ regionInfoPacket.RegionInfo.SimAccess = (byte)m_scene.RegionInfo.EstateSettings.simAccess;
+ regionInfoPacket.RegionInfo.SimName = Helpers.StringToField(m_scene.RegionInfo.RegionName);
+ regionInfoPacket.RegionInfo.SunHour = m_scene.RegionInfo.EstateSettings.sunHour;
+ regionInfoPacket.RegionInfo.TerrainLowerLimit = m_scene.RegionInfo.EstateSettings.terrainLowerLimit;
+ regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_scene.RegionInfo.EstateSettings.terrainRaiseLimit;
+ regionInfoPacket.RegionInfo.UseEstateSun = !m_scene.RegionInfo.EstateSettings.useFixedSun;
+ regionInfoPacket.RegionInfo.WaterHeight = m_scene.RegionInfo.EstateSettings.waterHeight;
+
+
+ remote_client.OutPacket(regionInfoPacket, ThrottleOutPacketType.Task);
+ }
+
+ public void sendRegionHandshake(IClientAPI remoteClient)
+ {
+ remoteClient.SendRegionHandshake(m_scene.RegionInfo);
+ }
+
+ #endregion
+
+ #region IRegionModule Members
+
+ public void Initialise(Scene scene, IConfigSource source)
+ {
+ m_scene = scene;
+ m_scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient);
+ m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
+
+ }
+
+ void EventManager_OnNewClient(IClientAPI client)
+ {
+ client.OnEstateOwnerMessage += handleEstateOwnerMessage;
+ client.OnRegionInfoRequest += HandleRegionInfoRequest;
+ client.OnEstateCovenantRequest += HandleEstateCovenantRequest;
+ sendRegionHandshake(client);
+ }
+
+
+ public void PostInitialise()
+ {
+ }
+
+ public void Close()
+ {
+ }
+
+ public string Name
+ {
+ get { return "EstateManagementModule"; }
+ }
+
+ public bool IsSharedModule
+ {
+ get { return false; }
+ }
+
+ #endregion
+
+ #region Other Functions
+
+ public void changeWaterHeight(float height)
+ {
+ setRegionSettings(height, m_scene.RegionInfo.EstateSettings.terrainRaiseLimit, m_scene.RegionInfo.EstateSettings.terrainLowerLimit, m_scene.RegionInfo.EstateSettings.useFixedSun, m_scene.RegionInfo.EstateSettings.sunHour);
+ sendRegionInfoPacketToAll();
+ }
+ #endregion
+
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index edce960db3..13f8b61bd5 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -153,7 +153,6 @@ namespace OpenSim.Region.Environment.Scenes
get { return m_authenticateHandler; }
}
- protected readonly EstateManager m_estateManager;
// an instance to the physics plugin's Scene object.
public PhysicsScene PhysicsScene
{
@@ -167,11 +166,6 @@ namespace OpenSim.Region.Environment.Scenes
get { return m_innerScene.m_syncRoot; }
}
- public EstateManager EstateManager
- {
- get { return m_estateManager; }
- }
-
public float TimeDilation
{
get { return m_timedilation; }
@@ -256,8 +250,6 @@ namespace OpenSim.Region.Environment.Scenes
EventManager.OnLandObjectRemoved +=
new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject);
- m_estateManager = new EstateManager(this, m_regInfo);
-
m_permissionManager = permissionManager;
m_permissionManager.Initialise(this);
@@ -1514,8 +1506,6 @@ namespace OpenSim.Region.Environment.Scenes
{
m_log.Info("[REGION]: Add New Scene Presence");
- m_estateManager.sendRegionHandshake(client);
-
CreateAndAddScenePresence(client, child);
LandChannel.sendParcelOverlay(client);
@@ -1572,9 +1562,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnParcelAccessListUpdateRequest +=
new ParcelAccessListUpdateRequest(LandChannel.handleParcelAccessUpdateRequest);
- client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
- client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest;
- client.OnEstateCovenantRequest += m_estateManager.HandleEstateCovenantRequest;
+
client.OnRequestGodlikePowers += handleRequestGodlikePowers;
client.OnGodKickUser += HandleGodlikeKickUser;
client.OnObjectPermissions += HandleObjectPermissionsUpdate;
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index 53a8d0fb54..2feed78fbb 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -151,6 +151,10 @@ namespace OpenSim.Region.Environment.Scenes
public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete;
+ public delegate void RequestChangeWaterHeight(float height);
+
+ public event RequestChangeWaterHeight OnRequestChangeWaterHeight;
+
public delegate void AvatarKillData(uint KillerLocalID, ScenePresence avatar);
public event AvatarKillData OnAvatarKilled;
@@ -269,6 +273,8 @@ namespace OpenSim.Region.Environment.Scenes
private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps;
private DeregisterCapsEvent handlerDeregisterCaps = null; // OnDeregisterCaps;
private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = null;
+ private RequestChangeWaterHeight handlerRequestChangeWaterHeight = null; //OnRequestChangeWaterHeight
+
private LandBuy handlerLandBuy = null;
private LandBuy handlerValidateLandBuy = null;
private AvatarKillData handlerAvatarKill = null;
@@ -579,6 +585,15 @@ namespace OpenSim.Region.Environment.Scenes
handlerScriptNotAtTargetEvent(localID);
}
}
+
+ public void TriggerRequestChangeWaterHeight(float height)
+ {
+ handlerRequestChangeWaterHeight = OnRequestChangeWaterHeight;
+ if (handlerRequestChangeWaterHeight != null)
+ {
+ handlerRequestChangeWaterHeight(height);
+ }
+ }
public void TriggerAvatarKill(uint KillerObjectLocalID, ScenePresence DeadAvatar)
{
handlerAvatarKill = OnAvatarKilled;
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index a33fe0fd53..7649ff33cb 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -183,8 +183,7 @@ namespace OpenSim.Region.ScriptEngine.Common
//World.PermissionsMngr.GenericEstatePermission(
if (World.PermissionsMngr.GenericEstatePermission(m_host.OwnerID))
{
- World.EstateManager.setRegionSettings((float)height, 0f, 0f, false, 0.5f);
- World.EstateManager.sendRegionInfoPacketToAll();
+ World.EventManager.TriggerRequestChangeWaterHeight((float)height);
}
}