From 1da99022949b7d69e08dc63f639b06613e55ce0f Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Tue, 5 Aug 2008 17:00:35 +0000
Subject: * refactor: clean up code for selecting regions on the region console
---
OpenSim/Region/Application/OpenSim.cs | 67 +++++++++++++++++------------------
1 file changed, 32 insertions(+), 35 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 2b59e5d..85ae1f4 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -89,7 +89,7 @@ namespace OpenSim
m_log.Info("====================================================================");
m_log.InfoFormat("[OPENSIM MAIN]: Running in {0} mode", (m_sandbox ? "sandbox" : "grid"));
- m_console = CreateConsole();
+ m_console = new ConsoleBase("Region", this);
MainConsole.Instance = m_console;
base.Startup();
@@ -116,12 +116,6 @@ namespace OpenSim
PrintFileToConsole("startuplogo.txt");
RegisterCmd("echoTest", RunEchoTest, "this echos your command args to see how they are parsed");
RegisterCmd("kickuser", KickUserCommand, "kickuser [first] [last] - attempts to log off a user from any region we are serving");
-
- }
-
- protected ConsoleBase CreateConsole()
- {
- return new ConsoleBase("Region", this);
}
private void RunAutoTimerScript(object sender, EventArgs e)
@@ -132,13 +126,16 @@ namespace OpenSim
}
}
- private string GetActualSimName()
+ ///
+ /// Get the name of the region which is currently selected for single region operations
+ ///
+ ///
+ private string GetSelectedRegionName()
{
if (m_sceneManager.CurrentScene == null) return "Root";
return m_sceneManager.CurrentScene.RegionInfo.RegionName;
}
-
#region Console Commands
private void RunEchoTest(string[] cmdparams)
@@ -289,11 +286,10 @@ namespace OpenSim
{
m_console.Notice("");
m_console.Notice("create user - adds a new user.");
- }
-
+ }
m_console.Notice("");
- m_console.Notice("Serving region " + GetActualSimName());
+ m_console.Notice("Selected region: " + GetSelectedRegionName());
m_console.Notice("");
break;
@@ -386,26 +382,7 @@ namespace OpenSim
break;
case "change-region":
- if (cmdparams.Length > 0)
- {
- string regionName = CombineParams(cmdparams, 0);
-
- if (!m_sceneManager.TrySetCurrentScene(regionName))
- {
- m_console.Error("Couldn't set current region to: " + regionName);
- }
- }
-
- if (m_sceneManager.CurrentScene == null)
- {
- m_console.Error("CONSOLE", "Currently at Root level. To change region please use 'change-region '");
- }
- else
- {
- m_console.Error("CONSOLE", "Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName +
- ". To change region please use 'change-region '");
- }
-
+ ChangeWorkingRegion(cmdparams);
break;
case "export-map":
@@ -532,6 +509,25 @@ namespace OpenSim
}
///
+ /// Change the current working region. The working region is that operated upon by single region commands.
+ ///
+ ///
+ protected void ChangeWorkingRegion(string[] cmdparams)
+ {
+ if (cmdparams.Length > 0)
+ {
+ string regionName = CombineParams(cmdparams, 0);
+
+ if (!m_sceneManager.TrySetCurrentScene(regionName))
+ {
+ m_console.Error("Couldn't set current region to: " + regionName);
+ }
+ }
+
+ m_console.Notice("CONSOLE", "Selected region: " + GetSelectedRegionName());
+ }
+
+ ///
/// Execute switch for some of the create commands
///
///
@@ -674,9 +670,10 @@ namespace OpenSim
});
break;
}
- m_console.Notice("");
- m_console.Notice("Serving region " + GetActualSimName());
- m_console.Notice("");
+
+ m_console.Notice("");
+ m_console.Notice("Selected region: " + GetSelectedRegionName());
+ m_console.Notice("");
}
///
--
cgit v1.1