From 46eaa79cd91c97993ce09d626db3fd9a7a36dce8 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 24 Apr 2007 18:18:18 +0000 Subject: [PATCH] * Added try{}catch{} to RunTerrainCmd * Exposed Thermal Erosion functions to RunTerrainCmd * Exposed Aerobic Erosion functions to RunTerrainCmd --- OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 145 +++++++++++------- 1 file changed, 87 insertions(+), 58 deletions(-) diff --git a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs index 73b43787ca..38a4989d5e 100644 --- a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs @@ -102,81 +102,110 @@ 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) - /// + /// Commandline arguments (space seperated) + /// Reference that returns error or help text if returning false + /// If the operation was successful (if not, the error is placed into resultText) public bool RunTerrainCmd(string[] args, ref string resultText) { string command = args[0]; - switch (command) + + try { - 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; + 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 erode aerobic \n"; + resultText += "terrain erode thermal \n"; + resultText += "terrain multiply - multiplies a terrain by \n"; + return false; - case "regenerate": - hills(); - break; + case "seed": + setSeed(Convert.ToInt32(args[1])); + break; - case "rescale": - setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2])); - break; + case "erode": + switch (args[1].ToLower()) + { + case "aerobic": + // WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest + heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToDouble(args[5]), Convert.ToInt32(args[6]), Convert.ToBoolean(args[7])); + break; + case "thermal": + heightmap.thermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4])); + break; + default: + resultText = "Unknown erosion type"; + return false; + } + break; - case "multiply": - heightmap *= Convert.ToDouble(args[1]); - break; + case "regenerate": + hills(); + break; - case "load": - switch (args[1].ToLower()) - { - case "f32": - loadFromFileF32(args[2]); - break; + case "rescale": + setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2])); + break; - case "f64": - loadFromFileF64(args[2]); - break; + case "multiply": + heightmap *= Convert.ToDouble(args[1]); + break; - case "img": - resultText = "Error - IMG mode is presently unsupported."; - return false; + case "load": + switch (args[1].ToLower()) + { + case "f32": + loadFromFileF32(args[2]); + break; - default: - resultText = "Unknown image or data format"; - return false; - } - break; + case "f64": + loadFromFileF64(args[2]); + break; - case "save": - switch (args[1].ToLower()) - { - case "f32": - writeToFileF32(args[2]); - break; + case "img": + resultText = "Error - IMG mode is presently unsupported."; + return false; - case "f64": - writeToFileF64(args[2]); - break; + default: + resultText = "Unknown image or data format"; + return false; + } + break; - default: - resultText = "Unknown image or data format"; - return false; - } - break; + case "save": + switch (args[1].ToLower()) + { + case "f32": + writeToFileF32(args[2]); + break; - default: - resultText = "Unknown terrain command"; - return false; + 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; + } + catch (Exception e) + { + resultText = "Error running terrain command: " + e.ToString(); + return false; } - return true; } ///