From 77af32cdbf939422d7f76ba6bb1de8f67c7b16e1 Mon Sep 17 00:00:00 2001 From: Mandarinka Tasty Date: Mon, 30 May 2016 01:25:06 +0200 Subject: [PATCH] Enhancement of osRegionRestart Signed-off-by: Mandarinka Tasty Signed-off-by: Melanie Thielker --- .../Shared/Api/Implementation/OSSL_Api.cs | 64 +++++++++++++++---- .../Shared/Api/Interface/IOSSL_Api.cs | 1 + .../Shared/Api/Runtime/OSSL_Stub.cs | 5 ++ 3 files changed, 56 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7e883651f3..b215ae169c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -523,23 +523,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (seconds < 15) { - restartModule.AbortRestart("Restart aborted"); + restartModule.AbortRestart("Region restart has been aborted\n"); return 1; } - List times = new List(); - while (seconds > 0) - { - times.Add((int)seconds); - if (seconds > 300) - seconds -= 120; - else if (seconds > 30) - seconds -= 30; - else - seconds -= 15; - } - - restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); + RegionRestart(seconds, String.Empty); return 1; } else @@ -548,6 +536,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public int osRegionRestart(double seconds, string msg) + { + CheckThreatLevel(ThreatLevel.High, "osRegionRestart"); + + IRestartModule restartModule = World.RequestModuleInterface(); + m_host.AddScriptLPS(1); + if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false) && (restartModule != null)) + { + if (seconds < 15) + { + restartModule.AbortRestart("Region restart has been aborted\n"); + return 1; + } + + RegionRestart(seconds, msg); + return 1; + } + else + { + return 0; + } + } + + private void RegionRestart(double seconds, string msg) + { + IRestartModule restartModule = World.RequestModuleInterface(); + + List times = new List(); + while (seconds > 0) + { + times.Add((int)seconds); + if (seconds > 300) + seconds -= 120; + else if (seconds > 120) + seconds -= 60; + else if (seconds > 60) + seconds -= 30; + else + seconds -= 15; + } + + if (msg == String.Empty) + restartModule.ScheduleRestart(UUID.Zero, "Region: " + World.RegionInfo.RegionName + " is about to restart.\n\nIf You stay here You will be logged out.\n\n\nTime remained: {0}.\n", times.ToArray(), true); + + else + restartModule.ScheduleRestart(UUID.Zero, msg + "\n\nTime remained: {0}.\n", times.ToArray(), true); + } + public void osRegionNotice(string msg) { // This implementation provides absolutely no security diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 6fc5db44e6..e1bb139e1e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -135,6 +135,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osTerrainFlush(); int osRegionRestart(double seconds); + int osRegionRestart(double seconds, string msg); void osRegionNotice(string msg); bool osConsoleCommand(string Command); void osSetParcelMediaURL(string url); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index ee07eeeedd..00220202d8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -209,6 +209,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osRegionRestart(seconds); } + public int osRegionRestart(double seconds, string msg) + { + return m_OSSL_Functions.osRegionRestart(seconds, msg); + } + public void osRegionNotice(string msg) { m_OSSL_Functions.osRegionNotice(msg);