diff options
-rw-r--r-- | OpenSim.RegionServer/OpenSimMain.cs | 85 | ||||
-rw-r--r-- | 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 | |||
522 | break; | 522 | break; |
523 | 523 | ||
524 | case "terrain": | 524 | case "terrain": |
525 | RunTerrainCmd(cmdparams); | 525 | string result = ""; |
526 | if (!LocalWorld.Terrain.RunTerrainCmd(cmdparams,ref result)) | ||
527 | { | ||
528 | m_console.WriteLine(result); | ||
529 | } | ||
526 | break; | 530 | break; |
527 | 531 | ||
528 | case "shutdown": | 532 | case "shutdown": |
@@ -536,85 +540,6 @@ namespace OpenSim | |||
536 | } | 540 | } |
537 | 541 | ||
538 | /// <summary> | 542 | /// <summary> |
539 | /// Processes a terrain-specific command | ||
540 | /// </summary> | ||
541 | /// <remarks>TODO: Move this into BasicTerrain directly (no need to hard limit what each terrain engine can support)</remarks> | ||
542 | /// <param name="args"></param> | ||
543 | public void RunTerrainCmd(string[] args) | ||
544 | { | ||
545 | string command = args[0]; | ||
546 | switch (command) | ||
547 | { | ||
548 | case "help": | ||
549 | m_console.WriteLine("terrain regenerate - rebuilds the sims terrain using a default algorithm"); | ||
550 | m_console.WriteLine("terrain seed <seed> - sets the random seed value to <seed>"); | ||
551 | m_console.WriteLine("terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64' or 'IMG'"); | ||
552 | m_console.WriteLine("terrain save <type> <filename> - saves a terrain to disk, type can be 'F32' or 'F64'"); | ||
553 | m_console.WriteLine("terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high"); | ||
554 | m_console.WriteLine("terrain multiply <val> - multiplies a terrain by <val>"); | ||
555 | break; | ||
556 | |||
557 | case "seed": | ||
558 | LocalWorld.Terrain.setSeed(Convert.ToInt32(args[1])); | ||
559 | break; | ||
560 | |||
561 | case "regenerate": | ||
562 | LocalWorld.Terrain.hills(); | ||
563 | break; | ||
564 | |||
565 | case "rescale": | ||
566 | LocalWorld.Terrain.setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2])); | ||
567 | break; | ||
568 | |||
569 | case "multiply": | ||
570 | LocalWorld.Terrain *= Convert.ToDouble(args[1]); | ||
571 | break; | ||
572 | |||
573 | case "load": | ||
574 | switch (args[1].ToLower()) | ||
575 | { | ||
576 | case "f32": | ||
577 | LocalWorld.Terrain.loadFromFileF32(args[2]); | ||
578 | break; | ||
579 | |||
580 | case "f64": | ||
581 | LocalWorld.Terrain.loadFromFileF64(args[2]); | ||
582 | break; | ||
583 | |||
584 | case "img": | ||
585 | m_console.WriteLine("Error - IMG mode is presently unsupported."); | ||
586 | break; | ||
587 | |||
588 | default: | ||
589 | m_console.WriteLine("Unknown image or data format"); | ||
590 | break; | ||
591 | } | ||
592 | break; | ||
593 | |||
594 | case "save": | ||
595 | switch (args[1].ToLower()) | ||
596 | { | ||
597 | case "f32": | ||
598 | LocalWorld.Terrain.writeToFileF32(args[2]); | ||
599 | break; | ||
600 | |||
601 | case "f64": | ||
602 | LocalWorld.Terrain.writeToFileF64(args[2]); | ||
603 | break; | ||
604 | |||
605 | default: | ||
606 | m_console.WriteLine("Unknown image or data format"); | ||
607 | break; | ||
608 | } | ||
609 | break; | ||
610 | |||
611 | default: | ||
612 | m_console.WriteLine("Unknown terrain command"); | ||
613 | break; | ||
614 | } | ||
615 | } | ||
616 | |||
617 | /// <summary> | ||
618 | /// Outputs to the console information about the region | 543 | /// Outputs to the console information about the region |
619 | /// </summary> | 544 | /// </summary> |
620 | /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param> | 545 | /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param> |
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 | |||
100 | } | 100 | } |
101 | 101 | ||
102 | /// <summary> | 102 | /// <summary> |
103 | /// Processes a terrain-specific command | ||
104 | /// </summary> | ||
105 | /// <remarks>TODO: Move this into BasicTerrain directly (no need to hard limit what each terrain engine can support)</remarks> | ||
106 | /// <param name="args"></param> | ||
107 | public bool RunTerrainCmd(string[] args, ref string resultText) | ||
108 | { | ||
109 | string command = args[0]; | ||
110 | switch (command) | ||
111 | { | ||
112 | case "help": | ||
113 | resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n"; | ||
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 | } | ||
179 | return true; | ||
180 | } | ||
181 | |||
182 | /// <summary> | ||
103 | /// Renormalises the array between min and max | 183 | /// Renormalises the array between min and max |
104 | /// </summary> | 184 | /// </summary> |
105 | /// <param name="min">Minimum value of the new array</param> | 185 | /// <param name="min">Minimum value of the new array</param> |