diff options
author | Adam Frisby | 2007-04-24 18:18:18 +0000 |
---|---|---|
committer | Adam Frisby | 2007-04-24 18:18:18 +0000 |
commit | 46eaa79cd91c97993ce09d626db3fd9a7a36dce8 (patch) | |
tree | dbad0b47f3a9289d8e9bfdc71d7eac6ce7bcde00 /OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | |
parent | Moved console input-handling function "RunTerrainCmd" into BasicTerrain itsel... (diff) | |
download | opensim-SC_OLD-46eaa79cd91c97993ce09d626db3fd9a7a36dce8.zip opensim-SC_OLD-46eaa79cd91c97993ce09d626db3fd9a7a36dce8.tar.gz opensim-SC_OLD-46eaa79cd91c97993ce09d626db3fd9a7a36dce8.tar.bz2 opensim-SC_OLD-46eaa79cd91c97993ce09d626db3fd9a7a36dce8.tar.xz |
* Added try{}catch{} to RunTerrainCmd
* Exposed Thermal Erosion functions to RunTerrainCmd
* Exposed Aerobic Erosion functions to RunTerrainCmd
Diffstat (limited to 'OpenSim.Terrain.BasicTerrain/TerrainEngine.cs')
-rw-r--r-- | OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 169 |
1 files changed, 99 insertions, 70 deletions
diff --git a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs index 73b4378..38a4989 100644 --- a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | |||
@@ -102,81 +102,110 @@ namespace OpenSim.Terrain | |||
102 | /// <summary> | 102 | /// <summary> |
103 | /// Processes a terrain-specific command | 103 | /// Processes a terrain-specific command |
104 | /// </summary> | 104 | /// </summary> |
105 | /// <remarks>TODO: Move this into BasicTerrain directly (no need to hard limit what each terrain engine can support)</remarks> | 105 | /// <param name="args">Commandline arguments (space seperated)</param> |
106 | /// <param name="args"></param> | 106 | /// <param name="resultText">Reference that returns error or help text if returning false</param> |
107 | /// <returns>If the operation was successful (if not, the error is placed into resultText)</returns> | ||
107 | public bool RunTerrainCmd(string[] args, ref string resultText) | 108 | public bool RunTerrainCmd(string[] args, ref string resultText) |
108 | { | 109 | { |
109 | string command = args[0]; | 110 | string command = args[0]; |
110 | switch (command) | 111 | |
112 | try | ||
113 | { | ||
114 | |||
115 | switch (command) | ||
116 | { | ||
117 | case "help": | ||
118 | resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n"; | ||
119 | resultText += "terrain seed <seed> - sets the random seed value to <seed>\n"; | ||
120 | resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64' or 'IMG'\n"; | ||
121 | resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32' or 'F64'\n"; | ||
122 | resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n"; | ||
123 | resultText += "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest>\n"; | ||
124 | resultText += "terrain erode thermal <talus> <rounds> <carry>\n"; | ||
125 | resultText += "terrain multiply <val> - multiplies a terrain by <val>\n"; | ||
126 | return false; | ||
127 | |||
128 | case "seed": | ||
129 | setSeed(Convert.ToInt32(args[1])); | ||
130 | break; | ||
131 | |||
132 | case "erode": | ||
133 | switch (args[1].ToLower()) | ||
134 | { | ||
135 | case "aerobic": | ||
136 | // WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest | ||
137 | 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])); | ||
138 | break; | ||
139 | case "thermal": | ||
140 | heightmap.thermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4])); | ||
141 | break; | ||
142 | default: | ||
143 | resultText = "Unknown erosion type"; | ||
144 | return false; | ||
145 | } | ||
146 | break; | ||
147 | |||
148 | case "regenerate": | ||
149 | hills(); | ||
150 | break; | ||
151 | |||
152 | case "rescale": | ||
153 | setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2])); | ||
154 | break; | ||
155 | |||
156 | case "multiply": | ||
157 | heightmap *= Convert.ToDouble(args[1]); | ||
158 | break; | ||
159 | |||
160 | case "load": | ||
161 | switch (args[1].ToLower()) | ||
162 | { | ||
163 | case "f32": | ||
164 | loadFromFileF32(args[2]); | ||
165 | break; | ||
166 | |||
167 | case "f64": | ||
168 | loadFromFileF64(args[2]); | ||
169 | break; | ||
170 | |||
171 | case "img": | ||
172 | resultText = "Error - IMG mode is presently unsupported."; | ||
173 | return false; | ||
174 | |||
175 | default: | ||
176 | resultText = "Unknown image or data format"; | ||
177 | return false; | ||
178 | } | ||
179 | break; | ||
180 | |||
181 | case "save": | ||
182 | switch (args[1].ToLower()) | ||
183 | { | ||
184 | case "f32": | ||
185 | writeToFileF32(args[2]); | ||
186 | break; | ||
187 | |||
188 | case "f64": | ||
189 | writeToFileF64(args[2]); | ||
190 | break; | ||
191 | |||
192 | default: | ||
193 | resultText = "Unknown image or data format"; | ||
194 | return false; | ||
195 | } | ||
196 | break; | ||
197 | |||
198 | default: | ||
199 | resultText = "Unknown terrain command"; | ||
200 | return false; | ||
201 | } | ||
202 | return true; | ||
203 | } | ||
204 | catch (Exception e) | ||
111 | { | 205 | { |
112 | case "help": | 206 | resultText = "Error running terrain command: " + e.ToString(); |
113 | resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n"; | 207 | return false; |
114 | resultText += "terrain seed <seed> - sets the random seed value to <seed>\n"; | ||
115 | resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64' or 'IMG'\n"; | ||
116 | resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32' or 'F64'\n"; | ||
117 | resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n"; | ||
118 | resultText += "terrain multiply <val> - multiplies a terrain by <val>\n"; | ||
119 | return false; | ||
120 | |||
121 | case "seed": | ||
122 | setSeed(Convert.ToInt32(args[1])); | ||
123 | break; | ||
124 | |||
125 | case "regenerate": | ||
126 | hills(); | ||
127 | break; | ||
128 | |||
129 | case "rescale": | ||
130 | setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2])); | ||
131 | break; | ||
132 | |||
133 | case "multiply": | ||
134 | heightmap *= Convert.ToDouble(args[1]); | ||
135 | break; | ||
136 | |||
137 | case "load": | ||
138 | switch (args[1].ToLower()) | ||
139 | { | ||
140 | case "f32": | ||
141 | loadFromFileF32(args[2]); | ||
142 | break; | ||
143 | |||
144 | case "f64": | ||
145 | loadFromFileF64(args[2]); | ||
146 | break; | ||
147 | |||
148 | case "img": | ||
149 | resultText = "Error - IMG mode is presently unsupported."; | ||
150 | return false; | ||
151 | |||
152 | default: | ||
153 | resultText = "Unknown image or data format"; | ||
154 | return false; | ||
155 | } | ||
156 | break; | ||
157 | |||
158 | case "save": | ||
159 | switch (args[1].ToLower()) | ||
160 | { | ||
161 | case "f32": | ||
162 | writeToFileF32(args[2]); | ||
163 | break; | ||
164 | |||
165 | case "f64": | ||
166 | writeToFileF64(args[2]); | ||
167 | break; | ||
168 | |||
169 | default: | ||
170 | resultText = "Unknown image or data format"; | ||
171 | return false; | ||
172 | } | ||
173 | break; | ||
174 | |||
175 | default: | ||
176 | resultText = "Unknown terrain command"; | ||
177 | return false; | ||
178 | } | 208 | } |
179 | return true; | ||
180 | } | 209 | } |
181 | 210 | ||
182 | /// <summary> | 211 | /// <summary> |