diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs index 395b71d920..7a7d5d3c2b 100644 --- a/OpenSim/Framework/Constants.cs +++ b/OpenSim/Framework/Constants.cs @@ -31,5 +31,13 @@ namespace OpenSim.Framework { public const uint RegionSize = 256; public const byte TerrainPatchSize = 16; + + public enum EstateAccessCodex : uint + { + AccessOptions = 17, + AllowedGroups = 18, + EstateBans = 20, + EstateManagers = 24 + } } } \ No newline at end of file diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 02dfc8c23d..b413c2c3e3 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -355,9 +355,9 @@ namespace OpenSim.Framework public delegate void EstateOwnerMessageRequest(EstateOwnerMessagePacket packet, IClientAPI remote_client); - public delegate void RegionInfoRequest(IClientAPI remote_client, LLUUID sessionID); + public delegate void RegionInfoRequest(IClientAPI remote_client); - public delegate void EstateCovenantRequest(IClientAPI remote_client, LLUUID sessionID); + public delegate void EstateCovenantRequest(IClientAPI remote_client); public delegate void UUIDNameRequest(LLUUID id, IClientAPI remote_client); @@ -456,6 +456,22 @@ namespace OpenSim.Framework public delegate void ScriptAnswer(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID, int answer); public delegate void RequestPayPrice(IClientAPI remoteClient, LLUUID objectID); + + //Estate Requests + public delegate void DetailedEstateDataRequest(IClientAPI remoteClient, LLUUID invoice); + public delegate void SetEstateFlagsRequest(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor, int matureLevel, bool restrictPushObject, bool allowParcelChanges); + public delegate void SetEstateTerrainBaseTexture(IClientAPI remoteClient, int corner, LLUUID side); + public delegate void SetEstateTerrainDetailTexture(IClientAPI remoteClient, int corner, LLUUID side); + public delegate void SetEstateTerrainTextureHeights(IClientAPI remoteClient, int corner, float lowVal, float highVal); + public delegate void CommitEstateTerrainTextureRequest(IClientAPI remoteClient); + public delegate void SetRegionTerrainSettings(float waterHeight, float terrainRaiseLimit, float terrainLowerLimit, bool fixedSun, float sunHour); + public delegate void EstateRestartSimRequest(IClientAPI remoteClient, int secondsTilReboot); + public delegate void EstateChangeCovenantRequest(IClientAPI remoteClient, LLUUID newCovenantID); + public delegate void UpdateEstateAccessDeltaRequest(IClientAPI remote_client, LLUUID invoice, int estateAccessType, LLUUID user); + public delegate void SimulatorBlueBoxMessageRequest(IClientAPI remoteClient, LLUUID invoice, LLUUID senderID, LLUUID sessionID, string senderName, string message); + public delegate void EstateBlueBoxMessageRequest(IClientAPI remoteClient, LLUUID invoice, LLUUID senderID, LLUUID sessionID, string senderName, string message); + public delegate void EstateDebugRegionRequest(IClientAPI remoteClient, LLUUID invoice, LLUUID senderID, bool scripted, bool collisionEvents, bool physics); + public delegate void EstateTeleportOneUserHomeRequest(IClientAPI remoteClient, LLUUID invoice, LLUUID senderID, LLUUID prey); public interface IClientAPI { @@ -587,7 +603,6 @@ namespace OpenSim.Framework event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; event ParcelSelectObjects OnParcelSelectObjects; event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; - event EstateOwnerMessageRequest OnEstateOwnerMessage; event RegionInfoRequest OnRegionInfoRequest; event EstateCovenantRequest OnEstateCovenantRequest; @@ -613,6 +628,24 @@ namespace OpenSim.Framework event AgentSit OnUndo; + event DetailedEstateDataRequest OnDetailedEstateDataRequest; + event SetEstateFlagsRequest OnSetEstateFlagsRequest; + event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture; + event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture; + event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights; + event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest; + event SetRegionTerrainSettings OnSetRegionTerrainSettings; + event EstateRestartSimRequest OnEstateRestartSimRequest; + event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; + event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest; + event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest; + event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest; + event EstateDebugRegionRequest OnEstateDebugRegionRequest; + event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest; + + + + void OutPacket(Packet newPack, ThrottleOutPacketType packType); void SendWearables(AvatarWearable[] wearables, int serial); void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry); @@ -731,6 +764,11 @@ namespace OpenSim.Framework void SendScriptQuestion(LLUUID taskID, string taskName, string ownerName, LLUUID itemID, int question); void SendHealth(float health); + + void sendEstateManagersList(LLUUID invoice); + void sendRegionInfoToEstateMenu(); + void sendEstateCovenantInformation(); + byte[] GetThrottlesPacked(float multiplier); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index c890b31e0f..7ca505069f 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -214,7 +214,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP private ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = null; //OnParcelPropertiesUpdateRequest; private ParcelSelectObjects handlerParcelSelectObjects = null; //OnParcelSelectObjects; private ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = null; //OnParcelObjectOwnerRequest; - private EstateOwnerMessageRequest handlerEstateOwnerMessage = null; //OnEstateOwnerMessage; private RegionInfoRequest handlerRegionInfoRequest = null; //OnRegionInfoRequest; private EstateCovenantRequest handlerEstateCovenantRequest = null; //OnEstateCovenantRequest; private RequestGodlikePowers handlerReqGodlikePowers = null; //OnRequestGodlikePowers; @@ -781,7 +780,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; public event ParcelSelectObjects OnParcelSelectObjects; public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; - public event EstateOwnerMessageRequest OnEstateOwnerMessage; public event RegionInfoRequest OnRegionInfoRequest; public event EstateCovenantRequest OnEstateCovenantRequest; @@ -803,6 +801,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event RequestPayPrice OnRequestPayPrice; public event AgentSit OnUndo; + public event DetailedEstateDataRequest OnDetailedEstateDataRequest; + public event SetEstateFlagsRequest OnSetEstateFlagsRequest; + public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture; + public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture; + public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights; + public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest; + public event SetRegionTerrainSettings OnSetRegionTerrainSettings; + public event EstateRestartSimRequest OnEstateRestartSimRequest; + public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; + public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest; + public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest; + public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest; + public event EstateDebugRegionRequest OnEstateDebugRegionRequest; + public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest; + #region Scene/Avatar to Client /// @@ -2142,6 +2155,93 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion + #region Estate Data Sending Methods + 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; + } + + public void sendEstateManagersList(LLUUID invoice) + { + EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket(); + packet.AgentData.TransactionID = LLUUID.Random(); + packet.AgentData.AgentID = this.AgentId; + packet.AgentData.SessionID = this.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)Constants.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; + this.OutPacket(packet, ThrottleOutPacketType.Task); + } + + public void sendRegionInfoToEstateMenu() + { + RegionInfoPacket rinfopack = new RegionInfoPacket(); + RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock(); + rinfopack.AgentData.AgentID = this.AgentId; + rinfopack.AgentData.SessionID = this.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; + + this.OutPacket(rinfopack, ThrottleOutPacketType.Task); + } + + public void sendEstateCovenantInformation() + { + 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; + this.OutPacket(einfopack, ThrottleOutPacketType.Task); + } + #endregion + #region Helper Methods protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, @@ -4604,11 +4704,199 @@ namespace OpenSim.Region.ClientStack.LindenUDP case PacketType.EstateOwnerMessage: EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; - handlerEstateOwnerMessage = OnEstateOwnerMessage; - if (handlerEstateOwnerMessage != null) + switch (Helpers.FieldToUTF8String(messagePacket.MethodData.Method)) { - handlerEstateOwnerMessage(messagePacket, this); + case "getinfo": + + if (((Scene)m_scene).PermissionsMngr.GenericEstatePermission(this.AgentId)) + { + OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice); + } + break; + case "setregioninfo": + if (((Scene)m_scene).PermissionsMngr.CanEditEstateTerrain(this.AgentId)) + { + OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter),convertParamStringToBool(messagePacket.ParamList[1].Parameter), + convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter), + Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(messagePacket.ParamList[4].Parameter))), + (float)Convert.ToDecimal(Helpers.FieldToUTF8String(messagePacket.ParamList[5].Parameter)), + Convert.ToInt16(Helpers.FieldToUTF8String(messagePacket.ParamList[6].Parameter)), + convertParamStringToBool(messagePacket.ParamList[7].Parameter),convertParamStringToBool(messagePacket.ParamList[8].Parameter)); + + } + + break; + case "texturebase": + if (((Scene)m_scene).PermissionsMngr.CanEditEstateTerrain(this.AgentId)) + { + foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) + { + string s = Helpers.FieldToUTF8String(block.Parameter); + string[] splitField = s.Split(' '); + if (splitField.Length == 2) + { + LLUUID tempUUID = new LLUUID(splitField[1]); + OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID); + } + } + } + break; + case "texturedetail": + if (((Scene)m_scene).PermissionsMngr.CanEditEstateTerrain(this.AgentId)) + { + foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.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]); + + OnSetEstateTerrainDetailTexture(this, corner,textureUUID); + } + } + } + + break; + case "textureheights": + if (((Scene)m_scene).PermissionsMngr.CanEditEstateTerrain(this.AgentId)) + { + foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.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]); + + OnSetEstateTerrainTextureHeights(this,corner,lowValue,highValue); + } + } + } + break; + case "texturecommit": + OnCommitEstateTerrainTextureRequest(this); + break; + case "setregionterrain": + if (((Scene)m_scene).PermissionsMngr.CanEditEstateTerrain(this.AgentId)) + { + if (messagePacket.ParamList.Length != 9) + { + m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length"); + } + else + { + try + { + string tmp; + tmp = Helpers.FieldToUTF8String(messagePacket.ParamList[0].Parameter); + if (!tmp.Contains(".")) tmp += ".00"; + float WaterHeight = (float)Convert.ToDecimal(tmp); + tmp = Helpers.FieldToUTF8String(messagePacket.ParamList[1].Parameter); + if (!tmp.Contains(".")) tmp += ".00"; + float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp); + tmp = Helpers.FieldToUTF8String(messagePacket.ParamList[2].Parameter); + if (!tmp.Contains(".")) tmp += ".00"; + float TerrainLowerLimit = (float)Convert.ToDecimal(tmp); + bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter); + float SunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(messagePacket.ParamList[5].Parameter)); + + OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseFixedSun, SunHour); + + } + catch (Exception ex) + { + m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket.ToString() + "\n" + ex.ToString()); + } + } + } + + break; + case "restart": + if (((Scene)m_scene).PermissionsMngr.CanRestartSim(this.AgentId)) + { + // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart. + foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) + { + float timeSeconds = 0; + Helpers.TryParse(Helpers.FieldToUTF8String(block.Parameter), out timeSeconds); + timeSeconds = (int)timeSeconds; + OnEstateRestartSimRequest(this, (int)timeSeconds); + + } + } + break; + case "estatechangecovenantid": + if (((Scene)m_scene).PermissionsMngr.CanEditEstateTerrain(this.AgentId)) + { + foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) + { + LLUUID newCovenantID = new LLUUID(Helpers.FieldToUTF8String(block.Parameter)); + OnEstateChangeCovenantRequest(this, newCovenantID); + } + } + break; + case "estateaccessdelta": // Estate access delta manages the banlist and allow list too. + if (((Scene)m_scene).PermissionsMngr.GenericEstatePermission(this.AgentId)) + { + int estateAccessType = Convert.ToInt16(Helpers.FieldToUTF8String(messagePacket.ParamList[1].Parameter)); + OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice,estateAccessType,new LLUUID(Helpers.FieldToUTF8String(messagePacket.ParamList[2].Parameter))); + + } + break; + case "simulatormessage": + if (((Scene)m_scene).PermissionsMngr.GenericEstatePermission(this.AgentId)) + { + LLUUID invoice = messagePacket.MethodData.Invoice; + LLUUID SenderID = new LLUUID(Helpers.FieldToUTF8String(messagePacket.ParamList[2].Parameter)); + string SenderName = Helpers.FieldToUTF8String(messagePacket.ParamList[3].Parameter); + string Message = Helpers.FieldToUTF8String(messagePacket.ParamList[4].Parameter); + LLUUID sessionID = messagePacket.AgentData.SessionID; + OnSimulatorBlueBoxMessageRequest(this,invoice,SenderID, sessionID, SenderName,Message); + } + break; + case "instantmessage": + if (((Scene)m_scene).PermissionsMngr.GenericEstatePermission(this.AgentId)) + { + LLUUID invoice = messagePacket.MethodData.Invoice; + LLUUID SenderID = new LLUUID(Helpers.FieldToUTF8String(messagePacket.ParamList[2].Parameter)); + string SenderName = Helpers.FieldToUTF8String(messagePacket.ParamList[3].Parameter); + string Message = Helpers.FieldToUTF8String(messagePacket.ParamList[4].Parameter); + LLUUID sessionID = messagePacket.AgentData.SessionID; + OnEstateBlueBoxMessageRequest(this,invoice,SenderID, sessionID, SenderName,Message); + } + break; + case "setregiondebug": + if (((Scene)m_scene).PermissionsMngr.GenericEstatePermission(this.AgentId)) + { + LLUUID invoice = messagePacket.MethodData.Invoice; + LLUUID SenderID = messagePacket.AgentData.AgentID; + bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter); + bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter); + bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter); + + OnEstateDebugRegionRequest(this, invoice,SenderID,scripted,collisionEvents,physics); + } + break; + case "teleporthomeuser": + if (((Scene)m_scene).PermissionsMngr.GenericEstatePermission(this.AgentId)) + { + LLUUID invoice = messagePacket.MethodData.Invoice; + LLUUID SenderID = messagePacket.AgentData.AgentID; + LLUUID Prey = LLUUID.Zero; + + Helpers.TryParse(Helpers.FieldToUTF8String(messagePacket.ParamList[1].Parameter), out Prey); + + OnEstateTeleportOneUserHomeRequest(this,invoice,SenderID,Prey); + } + break; + default: + m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket.ToString()); + break; } break; case PacketType.RequestRegionInfo: @@ -4617,7 +4905,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerRegionInfoRequest = OnRegionInfoRequest; if (handlerRegionInfoRequest != null) { - handlerRegionInfoRequest(this, mPacket.SessionID); + handlerRegionInfoRequest(this); } break; case PacketType.EstateCovenantRequest: @@ -4628,7 +4916,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerEstateCovenantRequest = OnEstateCovenantRequest; if (handlerEstateCovenantRequest != null) { - handlerEstateCovenantRequest(this, epack.SessionID); + handlerEstateCovenantRequest(this); } break; diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs index daabd9b0a8..e0bf11b10e 100644 --- a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs @@ -30,7 +30,6 @@ 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; @@ -45,261 +44,15 @@ namespace OpenSim.Region.Environment.Modules.World.Estate 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) + #region Packet Data Responders + private void sendDetailedEstateData(IClientAPI remote_client, LLUUID invoice) { - LLUUID invoice = packet.MethodData.Invoice; + EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket(); + packet.MethodData.Invoice = invoice; packet.AgentData.TransactionID = LLUUID.Random(); packet.MethodData.Method = Helpers.StringToField("estateupdateinfo"); EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[9]; @@ -327,52 +80,161 @@ namespace OpenSim.Region.Environment.Modules.World.Estate //System.Console.WriteLine("[ESTATE]: SIM--->" + packet.ToString()); remote_client.OutPacket(packet, ThrottleOutPacketType.Task); - sendEstateManagerList(remote_client, packet); + remote_client.sendEstateManagersList(invoice); } - private void sendEstateManagerList(IClientAPI remote_client, EstateOwnerMessagePacket packet) + private void estateSetRegionInfoHandler(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor, int matureLevel, bool restrictPushObject, bool allowParcelChanges) { - LLUUID invoice = packet.MethodData.Invoice; + + m_scene.RegionInfo.EstateSettings.regionFlags = Simulator.RegionFlags.None; - //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++) + if (blockTerraform) { - returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock(); + m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags | + Simulator.RegionFlags.BlockTerraform; } - 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++) + if (noFly) { - returnblock[j].Parameter = EstateManagers[i].GetBytes(); j++; + m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags | + Simulator.RegionFlags.NoFly; } - packet.ParamList = returnblock; - packet.Header.Reliable = false; - //System.Console.WriteLine("[ESTATE]: SIM--->" + packet.ToString()); - remote_client.OutPacket(packet, ThrottleOutPacketType.Task); + + if (allowDamage) + { + m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags | + Simulator.RegionFlags.AllowDamage; + } + + if (blockLandResell) + { + m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags | + Simulator.RegionFlags.BlockLandResell; + } + + m_scene.RegionInfo.EstateSettings.maxAgents = (byte)maxAgents; + + m_scene.RegionInfo.EstateSettings.objectBonusFactor = objectBonusFactor; + + m_scene.RegionInfo.EstateSettings.simAccess = (Simulator.SimAccess)matureLevel; + + + if (restrictPushObject) + { + m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags | + Simulator.RegionFlags.RestrictPushObject; + } + + if (allowParcelChanges) + { + m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags | + Simulator.RegionFlags.AllowParcelChanges; + } + + sendRegionInfoPacketToAll(); + } - private void estateAccessDelta(IClientAPI remote_client, EstateOwnerMessagePacket packet) + public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int corner, LLUUID texture) + { + switch (corner) + { + case 0: + m_scene.RegionInfo.EstateSettings.terrainBase0 = texture; + break; + case 1: + m_scene.RegionInfo.EstateSettings.terrainBase1 = texture; + break; + case 2: + m_scene.RegionInfo.EstateSettings.terrainBase2 = texture; + break; + case 3: + m_scene.RegionInfo.EstateSettings.terrainBase3 = texture; + break; + } + } + + public void setEstateTerrainDetailTexture(IClientAPI client, int corner, LLUUID textureUUID) + { + switch (corner) + { + 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; + } + } + + public void setEstateTerrainTextureHeights(IClientAPI client, int 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; + } + } + + private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient) + { + sendRegionHandshakeToAll(); + } + + public void setRegionTerrainSettings(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; + + sendRegionInfoPacketToAll(); + } + + private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds) + { + m_scene.Restart(timeInSeconds); + } + + private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, LLUUID estateCovenantID) + { + + m_scene.RegionInfo.CovenantID = estateCovenantID; + m_scene.RegionInfo.SaveEstatecovenantUUID(estateCovenantID); + + } + + private void handleEstateAccessDeltaRequest(IClientAPI remote_client, LLUUID invoice, int estateAccessType, LLUUID user) { // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc. - int estateAccessType = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter)); switch (estateAccessType) { @@ -380,10 +242,10 @@ namespace OpenSim.Region.Environment.Modules.World.Estate // 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) + if (remote_client.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); + m_scene.RegionInfo.EstateSettings.AddEstateManager(user); + remote_client.sendEstateManagersList(invoice); } else { @@ -394,10 +256,10 @@ namespace OpenSim.Region.Environment.Modules.World.Estate 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) + if (remote_client.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); + m_scene.RegionInfo.EstateSettings.RemoveEstateManager(user); + remote_client.sendEstateManagersList(invoice); } else { @@ -407,236 +269,73 @@ namespace OpenSim.Region.Environment.Modules.World.Estate default: - m_log.Error("EstateOwnerMessage: Unknown EstateAccessType requested in estateAccessDelta\n" + packet.ToString()); + m_log.Error("EstateOwnerMessage: Unknown EstateAccessType requested in estateAccessDelta"); break; } - //m_log.Error("EstateOwnerMessage: estateAccessDelta\n" + packet.ToString()); + } + private void SendSimulatorBlueBoxMessage(IClientAPI remote_client, LLUUID invoice, LLUUID senderID, LLUUID sessionID, string senderName, string message) + { + m_scene.SendRegionMessageFromEstateTools(senderID, sessionID, senderName, message); } - private void estateSetRegionInfoHandler(EstateOwnerMessagePacket packet) + private void SendEstateBlueBoxMessage(IClientAPI remote_client, LLUUID invoice, LLUUID senderID, LLUUID sessionID, string senderName, string message) { - if (packet.ParamList.Length != 9) + m_scene.SendEstateMessageFromEstateTools(senderID, sessionID, senderName, message); + } + + private void handleEstateDebugRegionRequest(IClientAPI remote_client, LLUUID invoice, LLUUID senderID, bool scripted, bool collisionEvents, bool physics) + { + + + if (physics) { - m_log.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length"); + m_scene.RegionInfo.EstateSettings.regionFlags |= Simulator.RegionFlags.SkipPhysics; } 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(); + m_scene.RegionInfo.EstateSettings.regionFlags &= ~Simulator.RegionFlags.SkipPhysics; } - } - private void estateSetRegionTerrainHandler(EstateOwnerMessagePacket packet) - { - if (packet.ParamList.Length != 9) + if (scripted) { - m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length"); + m_scene.RegionInfo.EstateSettings.regionFlags |= Simulator.RegionFlags.SkipScripts; } 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)); + m_scene.RegionInfo.EstateSettings.regionFlags &= ~Simulator.RegionFlags.SkipScripts; + } - setRegionSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseFixedSun, SunHour); - sendRegionInfoPacketToAll(); - } - catch (Exception ex) + m_scene.SetSceneCoreDebug(scripted, collisionEvents, physics); + } + + private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, LLUUID invoice, LLUUID senderID, LLUUID prey) + { + + if (prey != LLUUID.Zero) + { + ScenePresence s = m_scene.GetScenePresence(prey); + if (s != null) { - m_log.Error("EstateManager: Exception while setting terrain settings: \n" + packet.ToString() + "\n" + ex.ToString()); + m_scene.TeleportClientHome(prey, s.ControllingClient); } } } - private void estateTextureHeightsHandler(EstateOwnerMessagePacket packet) + private void HandleRegionInfoRequest(IClientAPI remote_client) { - 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); - } - } + remote_client.sendRegionInfoToEstateMenu(); } - private void estateTextureDetailHandler(EstateOwnerMessagePacket packet) + private void HandleEstateCovenantRequest(IClientAPI remote_client) { - 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); - } - } + remote_client.sendEstateCovenantInformation(); } - 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); +#endregion - } - } - - 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 @@ -646,9 +345,13 @@ namespace OpenSim.Region.Environment.Modules.World.Estate for (int i = 0; i < avatars.Count; i++) { - sendRegionInfoPacket(avatars[i].ControllingClient); + avatars[i].ControllingClient.sendRegionInfoToEstateMenu(); } } + public void sendRegionHandshake(IClientAPI remoteClient) + { + remoteClient.SendRegionHandshake(m_scene.RegionInfo); + } public void sendRegionHandshakeToAll() { @@ -657,39 +360,6 @@ namespace OpenSim.Region.Environment.Modules.World.Estate ); } - 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 @@ -704,7 +374,21 @@ namespace OpenSim.Region.Environment.Modules.World.Estate void EventManager_OnNewClient(IClientAPI client) { - client.OnEstateOwnerMessage += handleEstateOwnerMessage; + client.OnDetailedEstateDataRequest += sendDetailedEstateData; + client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler; + client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture; + client.OnSetEstateTerrainDetailTexture += setEstateTerrainDetailTexture; + client.OnSetEstateTerrainTextureHeights += setEstateTerrainTextureHeights; + client.OnCommitEstateTerrainTextureRequest += handleCommitEstateTerrainTextureRequest; + client.OnSetRegionTerrainSettings += setRegionTerrainSettings; + client.OnEstateRestartSimRequest += handleEstateRestartSimRequest; + client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest; + client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest; + client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage; + client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage; + client.OnEstateDebugRegionRequest += handleEstateDebugRegionRequest; + client.OnEstateTeleportOneUserHomeRequest += handleEstateTeleportOneUserHomeRequest; + client.OnRegionInfoRequest += HandleRegionInfoRequest; client.OnEstateCovenantRequest += HandleEstateCovenantRequest; sendRegionHandshake(client); @@ -735,7 +419,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate 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); + setRegionTerrainSettings(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/Modules/World/Land/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs index 877bed5d71..f891332239 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs @@ -28,6 +28,7 @@ using Nini.Config; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; +using OpenSim.Framework; namespace OpenSim.Region.Environment.Modules.World.Land { @@ -49,6 +50,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement); m_scene.EventManager.OnValidateLandBuy += landChannel.handleLandValidationRequest; m_scene.EventManager.OnLandBuy += landChannel.handleLandBuyRequest; + m_scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); lock (m_scene) { @@ -56,6 +58,19 @@ namespace OpenSim.Region.Environment.Modules.World.Land } } + void EventManager_OnNewClient(IClientAPI client) + { + //Register some client events + client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(landChannel.handleParcelPropertiesRequest); + client.OnParcelDivideRequest += new ParcelDivideRequest(landChannel.handleParcelDivideRequest); + client.OnParcelJoinRequest += new ParcelJoinRequest(landChannel.handleParcelJoinRequest); + client.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(landChannel.handleParcelPropertiesUpdateRequest); + client.OnParcelSelectObjects += new ParcelSelectObjects(landChannel.handleParcelSelectObjectsRequest); + client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(landChannel.handleParcelObjectOwnersRequest); + client.OnParcelAccessListRequest += new ParcelAccessListRequest(landChannel.handleParcelAccessRequest); + client.OnParcelAccessListUpdateRequest += new ParcelAccessListUpdateRequest(landChannel.handleParcelAccessUpdateRequest); + } + public void PostInitialise() { } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 13f8b61bd5..3cc2cbc43d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1550,18 +1550,6 @@ namespace OpenSim.Region.Environment.Scenes client.OnObjectDuplicateOnRay += doObjectDuplicateOnRay; client.OnUpdatePrimFlags += m_innerScene.UpdatePrimFlags; client.OnRequestObjectPropertiesFamily += m_innerScene.RequestObjectPropertiesFamily; - client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(LandChannel.handleParcelPropertiesRequest); - client.OnParcelDivideRequest += new ParcelDivideRequest(LandChannel.handleParcelDivideRequest); - client.OnParcelJoinRequest += new ParcelJoinRequest(LandChannel.handleParcelJoinRequest); - client.OnParcelPropertiesUpdateRequest += - new ParcelPropertiesUpdateRequest(LandChannel.handleParcelPropertiesUpdateRequest); - client.OnParcelSelectObjects += new ParcelSelectObjects(LandChannel.handleParcelSelectObjectsRequest); - client.OnParcelObjectOwnerRequest += - new ParcelObjectOwnerRequest(LandChannel.handleParcelObjectOwnersRequest); - client.OnParcelAccessListRequest += new ParcelAccessListRequest(LandChannel.handleParcelAccessRequest); - client.OnParcelAccessListUpdateRequest += - new ParcelAccessListUpdateRequest(LandChannel.handleParcelAccessUpdateRequest); - client.OnRequestGodlikePowers += handleRequestGodlikePowers; client.OnGodKickUser += HandleGodlikeKickUser; @@ -1599,7 +1587,7 @@ namespace OpenSim.Region.Environment.Scenes client.OnSetStartLocationRequest += SetHomeRezPoint; client.OnUndo += m_innerScene.HandleUndo; - + EventManager.TriggerOnNewClient(client); } public virtual void TeleportClientHome(LLUUID AgentId, IClientAPI client) diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 25c9093be7..672e34bfbc 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -151,7 +151,6 @@ namespace OpenSim.Region.Examples.SimpleModule public event ParcelSelectObjects OnParcelSelectObjects; public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; public event ObjectDeselect OnObjectDeselect; - public event EstateOwnerMessageRequest OnEstateOwnerMessage; public event RegionInfoRequest OnRegionInfoRequest; public event EstateCovenantRequest OnEstateCovenantRequest; @@ -173,6 +172,21 @@ namespace OpenSim.Region.Examples.SimpleModule public event RequestPayPrice OnRequestPayPrice; public event AgentSit OnUndo; + public event DetailedEstateDataRequest OnDetailedEstateDataRequest; + public event SetEstateFlagsRequest OnSetEstateFlagsRequest; + public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture; + public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture; + public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights; + public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest; + public event SetRegionTerrainSettings OnSetRegionTerrainSettings; + public event EstateRestartSimRequest OnEstateRestartSimRequest; + public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; + public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest; + public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest; + public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest; + public event EstateDebugRegionRequest OnEstateDebugRegionRequest; + public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest; + #pragma warning restore 67 @@ -618,5 +632,15 @@ namespace OpenSim.Region.Examples.SimpleModule public void SendHealth(float health) { } + + public void sendEstateManagersList(LLUUID invoice) + { + } + public void sendRegionInfoToEstateMenu() + { + } + public void sendEstateCovenantInformation() + { + } } }