From 7dd98f30943f66e7f0c4c63db1190fad2f437185 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Tue, 24 Apr 2007 18:01:37 +0000
Subject: Moved console input-handling function "RunTerrainCmd" into
BasicTerrain itself, this allows independent versions of BasicTerrain to have
different functionality exposed directly.
---
OpenSim.RegionServer/OpenSimMain.cs | 85 ++-------------------------
OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 80 +++++++++++++++++++++++++
2 files changed, 85 insertions(+), 80 deletions(-)
diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs
index 1c3454d..151ac51 100644
--- a/OpenSim.RegionServer/OpenSimMain.cs
+++ b/OpenSim.RegionServer/OpenSimMain.cs
@@ -522,7 +522,11 @@ namespace OpenSim
break;
case "terrain":
- RunTerrainCmd(cmdparams);
+ string result = "";
+ if (!LocalWorld.Terrain.RunTerrainCmd(cmdparams,ref result))
+ {
+ m_console.WriteLine(result);
+ }
break;
case "shutdown":
@@ -536,85 +540,6 @@ namespace OpenSim
}
///
- /// Processes a terrain-specific command
- ///
- /// TODO: Move this into BasicTerrain directly (no need to hard limit what each terrain engine can support)
- ///
- public void RunTerrainCmd(string[] args)
- {
- string command = args[0];
- switch (command)
- {
- case "help":
- m_console.WriteLine("terrain regenerate - rebuilds the sims terrain using a default algorithm");
- m_console.WriteLine("terrain seed - sets the random seed value to ");
- m_console.WriteLine("terrain load - loads a terrain from disk, type can be 'F32', 'F64' or 'IMG'");
- m_console.WriteLine("terrain save - saves a terrain to disk, type can be 'F32' or 'F64'");
- m_console.WriteLine("terrain rescale - rescales a terrain to be between and meters high");
- m_console.WriteLine("terrain multiply - multiplies a terrain by ");
- break;
-
- case "seed":
- LocalWorld.Terrain.setSeed(Convert.ToInt32(args[1]));
- break;
-
- case "regenerate":
- LocalWorld.Terrain.hills();
- break;
-
- case "rescale":
- LocalWorld.Terrain.setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2]));
- break;
-
- case "multiply":
- LocalWorld.Terrain *= Convert.ToDouble(args[1]);
- break;
-
- case "load":
- switch (args[1].ToLower())
- {
- case "f32":
- LocalWorld.Terrain.loadFromFileF32(args[2]);
- break;
-
- case "f64":
- LocalWorld.Terrain.loadFromFileF64(args[2]);
- break;
-
- case "img":
- m_console.WriteLine("Error - IMG mode is presently unsupported.");
- break;
-
- default:
- m_console.WriteLine("Unknown image or data format");
- break;
- }
- break;
-
- case "save":
- switch (args[1].ToLower())
- {
- case "f32":
- LocalWorld.Terrain.writeToFileF32(args[2]);
- break;
-
- case "f64":
- LocalWorld.Terrain.writeToFileF64(args[2]);
- break;
-
- default:
- m_console.WriteLine("Unknown image or data format");
- break;
- }
- break;
-
- default:
- m_console.WriteLine("Unknown terrain command");
- break;
- }
- }
-
- ///
/// Outputs to the console information about the region
///
/// What information to display (valid arguments are "uptime", "users")
diff --git a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
index 38c4d0f..73b4378 100644
--- a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
@@ -100,6 +100,86 @@ namespace OpenSim.Terrain
}
///
+ /// Processes a terrain-specific command
+ ///
+ /// TODO: Move this into BasicTerrain directly (no need to hard limit what each terrain engine can support)
+ ///
+ public bool RunTerrainCmd(string[] args, ref string resultText)
+ {
+ string command = args[0];
+ switch (command)
+ {
+ case "help":
+ resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n";
+ resultText += "terrain seed - sets the random seed value to \n";
+ resultText += "terrain load - loads a terrain from disk, type can be 'F32', 'F64' or 'IMG'\n";
+ resultText += "terrain save - saves a terrain to disk, type can be 'F32' or 'F64'\n";
+ resultText += "terrain rescale - rescales a terrain to be between and meters high\n";
+ resultText += "terrain multiply - multiplies a terrain by \n";
+ return false;
+
+ case "seed":
+ setSeed(Convert.ToInt32(args[1]));
+ break;
+
+ case "regenerate":
+ hills();
+ break;
+
+ case "rescale":
+ setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2]));
+ break;
+
+ case "multiply":
+ heightmap *= Convert.ToDouble(args[1]);
+ break;
+
+ case "load":
+ switch (args[1].ToLower())
+ {
+ case "f32":
+ loadFromFileF32(args[2]);
+ break;
+
+ case "f64":
+ loadFromFileF64(args[2]);
+ break;
+
+ case "img":
+ resultText = "Error - IMG mode is presently unsupported.";
+ return false;
+
+ default:
+ resultText = "Unknown image or data format";
+ return false;
+ }
+ break;
+
+ case "save":
+ switch (args[1].ToLower())
+ {
+ case "f32":
+ writeToFileF32(args[2]);
+ break;
+
+ case "f64":
+ writeToFileF64(args[2]);
+ break;
+
+ default:
+ resultText = "Unknown image or data format";
+ return false;
+ }
+ break;
+
+ default:
+ resultText = "Unknown terrain command";
+ return false;
+ }
+ return true;
+ }
+
+ ///
/// Renormalises the array between min and max
///
/// Minimum value of the new array
--
cgit v1.1