From 4276a352bcef890f3487ff701fba2de617d2c3de Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 24 Aug 2007 16:17:57 +0000 Subject: Small bit of refactoring to the startup command script code (moved it into a separate method), so that I could add a new CLI command of "command-script ", so that as well as the startup command script still being processed on startup. A user can create other command scripts and use the single command ("command-script ") to run them at any time. Could be useful for trying out various configurations etc. --- OpenSim/Region/Application/OpenSimMain.cs | 42 ++++++++++++++-------- .../Environment/LandManagement/LandManager.cs | 6 ++-- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 867f16f..07ab34d 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -205,28 +205,33 @@ namespace OpenSim //Run Startup Commands if (m_startupCommandsFile != "") { - MainLog.Instance.Verbose("Running startup command script (" + m_startupCommandsFile + ")"); - if (File.Exists(m_startupCommandsFile)) + RunCommandScript(m_startupCommandsFile); + } + else + { + MainLog.Instance.Verbose("No startup command script specified. Moving on..."); + } + } + + private void RunCommandScript(string fileName) + { + MainLog.Instance.Verbose("Running command script (" + fileName + ")"); + if (File.Exists(fileName)) + { + StreamReader readFile = File.OpenText(fileName); + string currentCommand = ""; + while ((currentCommand = readFile.ReadLine()) != null) { - StreamReader readFile = File.OpenText(m_startupCommandsFile); - string currentCommand = ""; - while ((currentCommand = readFile.ReadLine()) != null) + if (currentCommand != "") { - if (currentCommand != "") - { - MainLog.Instance.Verbose("Running '" + currentCommand + "'"); - MainLog.Instance.MainLogRunCommand(currentCommand); - } + MainLog.Instance.Verbose("Running '" + currentCommand + "'"); + MainLog.Instance.MainLogRunCommand(currentCommand); } } - else - { - MainLog.Instance.Error("Startup command script missing. Will not run startup commands"); - } } else { - MainLog.Instance.Verbose("No startup command script specified. Moving on..."); + MainLog.Instance.Error("Command script missing. Can not run commands"); } } @@ -403,6 +408,13 @@ namespace OpenSim } break; + case "command-script": + if (cmdparams.Length > 0) + { + RunCommandScript(cmdparams[0]); + } + break; + case "permissions": // Treats each user as a super-admin when disabled foreach (Scene scene in m_localScenes) diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index 2f345f4..1ed0642 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -207,8 +207,7 @@ namespace OpenSim.Region.Environment.LandManagement if (x > 63 || y > 63 || x < 0 || y < 0) { - return null; - //throw new Exception("Error: Parcel not found at point " + x + ", " + y); + throw new Exception("Error: Parcel not found at point " + x + ", " + y); } else { @@ -221,8 +220,7 @@ namespace OpenSim.Region.Environment.LandManagement { if (x > 256 || y > 256 || x < 0 || y < 0) { - return null; - //throw new Exception("Error: Parcel not found at point " + x + ", " + y); + throw new Exception("Error: Parcel not found at point " + x + ", " + y); } else { -- cgit v1.1