From 77af32cdbf939422d7f76ba6bb1de8f67c7b16e1 Mon Sep 17 00:00:00 2001 From: Mandarinka Tasty Date: Mon, 30 May 2016 01:25:06 +0200 Subject: Enhancement of osRegionRestart Signed-off-by: Mandarinka Tasty Signed-off-by: Melanie Thielker --- .../Shared/Api/Implementation/OSSL_Api.cs | 58 ++++++++++++++++++---- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 ++ 3 files changed, 53 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7e88365..b215ae1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -523,23 +523,34 @@ 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) + RegionRestart(seconds, String.Empty); + return 1; + } + else + { + return 0; + } + } + + 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) { - times.Add((int)seconds); - if (seconds > 300) - seconds -= 120; - else if (seconds > 30) - seconds -= 30; - else - seconds -= 15; + restartModule.AbortRestart("Region restart has been aborted\n"); + return 1; } - restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); + RegionRestart(seconds, msg); return 1; } else @@ -548,6 +559,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + 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 6fc5db4..e1bb139 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 ee07eee..0022020 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); -- cgit v1.1