From 4c83b5e719ad288b1250fbed3f74698fa34eff21 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 7 May 2013 00:31:11 +0100 Subject: [PATCH] Step one of estate settings sharing - port the Avination Estate module (complete module) as changes are too extensive to apply manually --- .../EntityTransfer/EntityTransferModule.cs | 13 ++++- .../EntityTransfer/HGEntityTransferModule.cs | 21 ++++--- .../World/Estate/EstateManagementModule.cs | 57 ++++++++++++++----- .../Interfaces/IEntityTransferModule.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 5 +- 5 files changed, 71 insertions(+), 27 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index ca0cef1ea8..eac0da7ff7 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected virtual void OnNewClient(IClientAPI client) { - client.OnTeleportHomeRequest += TeleportHome; + client.OnTeleportHomeRequest += TriggerTeleportHome; client.OnTeleportLandmarkRequest += RequestTeleportLandmark; if (!DisableInterRegionTeleportCancellation) @@ -1071,7 +1071,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #region Teleport Home - public virtual void TeleportHome(UUID id, IClientAPI client) + public virtual void TriggerTeleportHome(UUID id, IClientAPI client) + { + TeleportHome(id, client); + } + + public virtual bool TeleportHome(UUID id, IClientAPI client) { m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); @@ -1086,7 +1091,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { // can't find the Home region: Tell viewer and abort client.SendTeleportFailed("Your home region could not be found."); - return; + return false; } m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Home region of {0} is {1} ({2}-{3})", @@ -1096,6 +1101,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer ((Scene)(client.Scene)).RequestTeleportLocation( client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); + return true; } else { @@ -1103,6 +1109,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer "[ENTITY TRANSFER MODULE]: No grid user information found for {0} {1}. Cannot send home.", client.Name, client.AgentId); } + return false; } #endregion diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 33ea063600..02ed1a08e3 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -184,7 +184,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected override void OnNewClient(IClientAPI client) { - client.OnTeleportHomeRequest += TeleportHome; + client.OnTeleportHomeRequest += TriggerTeleportHome; client.OnTeleportLandmarkRequest += RequestTeleportLandmark; client.OnConnectionClosed += new Action(OnConnectionClosed); } @@ -409,7 +409,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // return base.UpdateAgent(reg, finalDestination, agentData, sp); //} - public override void TeleportHome(UUID id, IClientAPI client) + public virtual void TriggerTeleportHome(UUID id, IClientAPI client) + { + TeleportHome(id, client); + } + + public override bool TeleportHome(UUID id, IClientAPI client) { m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); @@ -420,8 +425,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { // local grid user m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); - base.TeleportHome(id, client); - return; + return base.TeleportHome(id, client); } // Foreign user wants to go home @@ -431,7 +435,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { client.SendTeleportFailed("Your information has been lost"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); - return; + return false; } IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); @@ -441,7 +445,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { client.SendTeleportFailed("Your home region could not be found"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found"); - return; + return false; } ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId); @@ -449,7 +453,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { client.SendTeleportFailed("Internal error"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be"); - return; + return false; } GridRegion homeGatekeeper = MakeRegion(aCircuit); @@ -460,6 +464,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer DoTeleport( sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); + return true; } /// @@ -586,4 +591,4 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return region; } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 60f67396db..91f6501a32 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -32,6 +32,7 @@ using System.IO; using System.Linq; using System.Reflection; using System.Security; +using System.Timers; using log4net; using Mono.Addins; using Nini.Config; @@ -48,6 +49,7 @@ namespace OpenSim.Region.CoreModules.World.Estate { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Timer m_regionChangeTimer = new Timer(); public Scene Scene { get; private set; } public IUserManagement UserManager { get; private set; } @@ -65,6 +67,8 @@ namespace OpenSim.Region.CoreModules.World.Estate public event ChangeDelegate OnEstateInfoChange; public event MessageDelegate OnEstateMessage; + private int m_delayCount = 0; + #region Region Module interface public string Name { get { return "EstateManagementModule"; } } @@ -114,6 +118,12 @@ namespace OpenSim.Region.CoreModules.World.Estate #region Packet Data Responders + private void clientSendDetailedEstateData(IClientAPI remote_client, UUID invoice) + { + sendDetailedEstateData(remote_client, invoice); + sendEstateLists(remote_client, invoice); + } + private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) { uint sun = 0; @@ -136,7 +146,10 @@ namespace OpenSim.Region.CoreModules.World.Estate (uint) Scene.RegionInfo.RegionSettings.CovenantChangedDateTime, Scene.RegionInfo.EstateSettings.AbuseEmail, estateOwner); + } + private void sendEstateLists(IClientAPI remote_client, UUID invoice) + { remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, @@ -330,7 +343,7 @@ namespace OpenSim.Region.CoreModules.World.Estate timeInSeconds -= 15; } - restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); + restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), false); m_log.InfoFormat( "User {0} requested restart of region {1} in {2} seconds", @@ -546,7 +559,11 @@ namespace OpenSim.Region.CoreModules.World.Estate { if (!s.IsChildAgent) { - Scene.TeleportClientHome(user, s.ControllingClient); + if (!Scene.TeleportClientHome(user, s.ControllingClient)) + { + s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out."); + s.ControllingClient.Close(); + } } } @@ -555,7 +572,7 @@ namespace OpenSim.Region.CoreModules.World.Estate { remote_client.SendAlertMessage("User is already on the region ban list"); } - //m_scene.RegionInfo.regionBanlist.Add(Manager(user); + //Scene.RegionInfo.regionBanlist.Add(Manager(user); remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); } else @@ -611,7 +628,7 @@ namespace OpenSim.Region.CoreModules.World.Estate remote_client.SendAlertMessage("User is not on the region ban list"); } - //m_scene.RegionInfo.regionBanlist.Add(Manager(user); + //Scene.RegionInfo.regionBanlist.Add(Manager(user); remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); } else @@ -777,7 +794,11 @@ namespace OpenSim.Region.CoreModules.World.Estate ScenePresence s = Scene.GetScenePresence(prey); if (s != null) { - Scene.TeleportClientHome(prey, s.ControllingClient); + if (!Scene.TeleportClientHome(prey, s.ControllingClient)) + { + s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); + s.ControllingClient.Close(); + } } } } @@ -795,7 +816,13 @@ namespace OpenSim.Region.CoreModules.World.Estate // Also make sure they are actually in the region ScenePresence p; if(Scene.TryGetScenePresence(client.AgentId, out p)) - Scene.TeleportClientHome(p.UUID, p.ControllingClient); + { + if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient)) + { + p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); + p.ControllingClient.Close(); + } + } } }); } @@ -1170,7 +1197,7 @@ namespace OpenSim.Region.CoreModules.World.Estate private void EventManager_OnNewClient(IClientAPI client) { - client.OnDetailedEstateDataRequest += sendDetailedEstateData; + client.OnDetailedEstateDataRequest += clientSendDetailedEstateData; client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler; // client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture; client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture; @@ -1218,8 +1245,6 @@ namespace OpenSim.Region.CoreModules.World.Estate flags |= RegionFlags.NoFly; if (Scene.RegionInfo.RegionSettings.RestrictPushing) flags |= RegionFlags.RestrictPushObject; - if (Scene.RegionInfo.RegionSettings.AllowLandJoinDivide) - flags |= RegionFlags.AllowParcelChanges; if (Scene.RegionInfo.RegionSettings.BlockShowInSearch) flags |= RegionFlags.BlockParcelSearch; @@ -1229,11 +1254,11 @@ namespace OpenSim.Region.CoreModules.World.Estate flags |= RegionFlags.Sandbox; if (Scene.RegionInfo.EstateSettings.AllowVoice) flags |= RegionFlags.AllowVoice; + if (Scene.RegionInfo.EstateSettings.BlockDwell) + flags |= RegionFlags.BlockDwell; + if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport) + flags |= RegionFlags.ResetHomeOnTeleport; - // Fudge these to always on, so the menu options activate - // - flags |= RegionFlags.AllowLandmark; - flags |= RegionFlags.AllowSetHome; // TODO: SkipUpdateInterestList @@ -1293,6 +1318,12 @@ namespace OpenSim.Region.CoreModules.World.Estate } public void TriggerRegionInfoChange() + { + m_regionChangeTimer.Stop(); + m_regionChangeTimer.Start(); + } + + protected void RaiseRegionInfoChange(object sender, ElapsedEventArgs e) { ChangeDelegate change = OnRegionInfoChange; diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs index 69be83eb41..1c43a25e31 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs @@ -72,7 +72,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// /// - void TeleportHome(UUID id, IClientAPI client); + bool TeleportHome(UUID id, IClientAPI client); /// /// Show whether the given agent is being teleported. diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8fe2d72bdc..2aba2dda4e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3230,17 +3230,18 @@ namespace OpenSim.Region.Framework.Scenes /// /// The avatar's Unique ID /// The IClientAPI for the client - public virtual void TeleportClientHome(UUID agentId, IClientAPI client) + public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) { if (EntityTransferModule != null) { - EntityTransferModule.TeleportHome(agentId, client); + return EntityTransferModule.TeleportHome(agentId, client); } else { m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); client.SendTeleportFailed("Unable to perform teleports on this simulator."); } + return false; } ///