Moved console input-handling function "RunTerrainCmd" into BasicTerrain itself, this allows independent versions of BasicTerrain to have different functionality exposed directly.

0.1-prestable
Adam Frisby 2007-04-24 18:01:37 +00:00
parent d82466ec82
commit 7dd98f3094
2 changed files with 85 additions and 80 deletions

View File

@ -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":
@ -535,85 +539,6 @@ namespace OpenSim
}
}
/// <summary>
/// Processes a terrain-specific command
/// </summary>
/// <remarks>TODO: Move this into BasicTerrain directly (no need to hard limit what each terrain engine can support)</remarks>
/// <param name="args"></param>
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 <seed> - sets the random seed value to <seed>");
m_console.WriteLine("terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64' or 'IMG'");
m_console.WriteLine("terrain save <type> <filename> - saves a terrain to disk, type can be 'F32' or 'F64'");
m_console.WriteLine("terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high");
m_console.WriteLine("terrain multiply <val> - multiplies a terrain by <val>");
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;
}
}
/// <summary>
/// Outputs to the console information about the region
/// </summary>

View File

@ -99,6 +99,86 @@ namespace OpenSim.Terrain
tainted++;
}
/// <summary>
/// Processes a terrain-specific command
/// </summary>
/// <remarks>TODO: Move this into BasicTerrain directly (no need to hard limit what each terrain engine can support)</remarks>
/// <param name="args"></param>
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 <seed> - sets the random seed value to <seed>\n";
resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64' or 'IMG'\n";
resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32' or 'F64'\n";
resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n";
resultText += "terrain multiply <val> - multiplies a terrain by <val>\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;
}
/// <summary>
/// Renormalises the array between min and max
/// </summary>