diff options
author | Melanie | 2010-11-25 02:37:50 +0100 |
---|---|---|
committer | Melanie | 2010-11-25 02:37:50 +0100 |
commit | 152256792084639f67ec085fe4d19abb95b68e1d (patch) | |
tree | 72e0f314a3819d86c0ac010732705aaf5006583b /OpenSim/Region/CoreModules | |
parent | Merge branch 'careminster-presence-refactor' of ssh://melanie@3dhosting.de/va... (diff) | |
download | opensim-SC_OLD-152256792084639f67ec085fe4d19abb95b68e1d.zip opensim-SC_OLD-152256792084639f67ec085fe4d19abb95b68e1d.tar.gz opensim-SC_OLD-152256792084639f67ec085fe4d19abb95b68e1d.tar.bz2 opensim-SC_OLD-152256792084639f67ec085fe4d19abb95b68e1d.tar.xz |
Finish the RestartModule and fix some bugs. Add new console commands:
region restart bluebox <msg> <time> ...
region restart notice <msg> <time> ...
region restart abort [<message>]
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Region/RestartModule.cs | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs index 1c26c38..5a5239a 100644 --- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs +++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs | |||
@@ -34,12 +34,15 @@ using log4net; | |||
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Console; | ||
37 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
39 | using Timer=System.Timers.Timer; | 40 | using Timer=System.Timers.Timer; |
41 | using Mono.Addins; | ||
40 | 42 | ||
41 | namespace OpenSim.Region.CoreModules.World.Region | 43 | namespace OpenSim.Region.CoreModules.World.Region |
42 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RestartModule")] | ||
43 | public class RestartModule : INonSharedRegionModule, IRestartModule | 46 | public class RestartModule : INonSharedRegionModule, IRestartModule |
44 | { | 47 | { |
45 | private static readonly ILog m_log = | 48 | private static readonly ILog m_log = |
@@ -62,6 +65,18 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
62 | { | 65 | { |
63 | m_Scene = scene; | 66 | m_Scene = scene; |
64 | m_DialogModule = m_Scene.RequestModuleInterface<IDialogModule>(); | 67 | m_DialogModule = m_Scene.RequestModuleInterface<IDialogModule>(); |
68 | MainConsole.Instance.Commands.AddCommand("RestartModule", | ||
69 | false, "region restart bluebox", | ||
70 | "region restart bluebox <message> <time> ...", | ||
71 | "Restart the region", HandleRegionRestart); | ||
72 | MainConsole.Instance.Commands.AddCommand("RestartModule", | ||
73 | false, "region restart notice", | ||
74 | "region restart notice <message> <time> ...", | ||
75 | "Restart the region", HandleRegionRestart); | ||
76 | MainConsole.Instance.Commands.AddCommand("RestartModule", | ||
77 | false, "region restart abort", | ||
78 | "region restart abort [<message>]", | ||
79 | "Restart the region", HandleRegionRestart); | ||
65 | } | 80 | } |
66 | 81 | ||
67 | public void RegionLoaded(Scene scene) | 82 | public void RegionLoaded(Scene scene) |
@@ -137,6 +152,7 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
137 | continue; | 152 | continue; |
138 | } | 153 | } |
139 | nextAlert = m_Alerts[1]; | 154 | nextAlert = m_Alerts[1]; |
155 | break; | ||
140 | } | 156 | } |
141 | 157 | ||
142 | int currentAlert = m_Alerts[0]; | 158 | int currentAlert = m_Alerts[0]; |
@@ -144,7 +160,7 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
144 | m_Alerts.RemoveAt(0); | 160 | m_Alerts.RemoveAt(0); |
145 | 161 | ||
146 | int minutes = currentAlert / 60; | 162 | int minutes = currentAlert / 60; |
147 | string currentAlertString = ""; | 163 | string currentAlertString = String.Empty; |
148 | if (minutes > 0) | 164 | if (minutes > 0) |
149 | { | 165 | { |
150 | if (minutes == 1) | 166 | if (minutes == 1) |
@@ -165,7 +181,7 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
165 | 181 | ||
166 | string msg = String.Format(m_Message, currentAlertString); | 182 | string msg = String.Format(m_Message, currentAlertString); |
167 | 183 | ||
168 | if (m_DialogModule != null) | 184 | if (m_DialogModule != null && msg != String.Empty) |
169 | { | 185 | { |
170 | if (m_Notice) | 186 | if (m_Notice) |
171 | m_DialogModule.SendGeneralAlert(msg); | 187 | m_DialogModule.SendGeneralAlert(msg); |
@@ -198,7 +214,49 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
198 | { | 214 | { |
199 | m_CountdownTimer.Stop(); | 215 | m_CountdownTimer.Stop(); |
200 | m_CountdownTimer = null; | 216 | m_CountdownTimer = null; |
217 | if (m_DialogModule != null && message != String.Empty) | ||
218 | m_DialogModule.SendGeneralAlert(message); | ||
201 | } | 219 | } |
202 | } | 220 | } |
221 | |||
222 | private void HandleRegionRestart(string module, string[] args) | ||
223 | { | ||
224 | if (!(MainConsole.Instance.ConsoleScene is Scene)) | ||
225 | return; | ||
226 | |||
227 | if (MainConsole.Instance.ConsoleScene != m_Scene) | ||
228 | return; | ||
229 | |||
230 | if (args.Length < 5) | ||
231 | { | ||
232 | if (args.Length > 2) | ||
233 | { | ||
234 | if (args[2] == "abort") | ||
235 | { | ||
236 | string msg = String.Empty; | ||
237 | if (args.Length > 3) | ||
238 | msg = args[3]; | ||
239 | |||
240 | AbortRestart(msg); | ||
241 | |||
242 | MainConsole.Instance.Output("Region restart aborted"); | ||
243 | return; | ||
244 | } | ||
245 | } | ||
246 | |||
247 | MainConsole.Instance.Output("Error: restart region <mode> <name> <time> ..."); | ||
248 | return; | ||
249 | } | ||
250 | |||
251 | bool notice = false; | ||
252 | if (args[2] == "notice") | ||
253 | notice = true; | ||
254 | |||
255 | List<int> times = new List<int>(); | ||
256 | for (int i = 4 ; i < args.Length ; i++) | ||
257 | times.Add(Convert.ToInt32(args[i])); | ||
258 | |||
259 | ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); | ||
260 | } | ||
203 | } | 261 | } |
204 | } | 262 | } |