Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

0.7.4.1
Mic Bowman 2012-03-24 22:45:17 -07:00
commit a07fa0395f
6 changed files with 88 additions and 51 deletions

View File

@ -188,19 +188,21 @@ namespace OpenSim.Framework.Console
{ {
lock (m_modulesCommands) lock (m_modulesCommands)
{ {
if (m_modulesCommands.ContainsKey(moduleName)) foreach (string key in m_modulesCommands.Keys)
{ {
List<CommandInfo> commands = m_modulesCommands[moduleName]; // Allow topic help requests to succeed whether they are upper or lowercase.
if (moduleName.ToLower() == key.ToLower())
{
List<CommandInfo> commands = m_modulesCommands[key];
var ourHelpText = commands.ConvertAll(c => string.Format("{0} - {1}", c.help_text, c.long_help)); var ourHelpText = commands.ConvertAll(c => string.Format("{0} - {1}", c.help_text, c.long_help));
ourHelpText.Sort(); ourHelpText.Sort();
helpText.AddRange(ourHelpText); helpText.AddRange(ourHelpText);
return true; return true;
} }
else
{
return false;
} }
return false;
} }
} }

View File

@ -421,12 +421,18 @@ namespace OpenSim.Framework
set { m_internalEndPoint = value; } set { m_internalEndPoint = value; }
} }
/// <summary>
/// The x co-ordinate of this region in map tiles (e.g. 1000).
/// </summary>
public uint RegionLocX public uint RegionLocX
{ {
get { return m_regionLocX.Value; } get { return m_regionLocX.Value; }
set { m_regionLocX = value; } set { m_regionLocX = value; }
} }
/// <summary>
/// The y co-ordinate of this region in map tiles (e.g. 1000).
/// </summary>
public uint RegionLocY public uint RegionLocY
{ {
get { return m_regionLocY.Value; } get { return m_regionLocY.Value; }

View File

@ -248,15 +248,16 @@ namespace OpenSim
{ {
string capitalizedTopic = char.ToUpper(topic[0]) + topic.Substring(1); string capitalizedTopic = char.ToUpper(topic[0]) + topic.Substring(1);
// This is a hack to allow the user to enter the help command in upper or lowercase. This will go
// away at some point.
m_console.Commands.AddCommand(capitalizedTopic, false, "help " + topic,
"help " + capitalizedTopic,
"Get help on plugin command '" + topic + "'",
HandleCommanderHelp);
m_console.Commands.AddCommand(capitalizedTopic, false, "help " + capitalizedTopic, m_console.Commands.AddCommand(capitalizedTopic, false, "help " + capitalizedTopic,
"help " + capitalizedTopic, "help " + capitalizedTopic,
"Get help on plugin command '" + topic + "'", "Get help on plugin command '" + topic + "'",
HandleCommanderHelp); HandleCommanderHelp);
//
// m_console.Commands.AddCommand("General", false, topic,
// topic,
// "Execute subcommand for plugin '" + topic + "'",
// null);
ICommander commander = null; ICommander commander = null;

View File

@ -132,13 +132,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
{ {
// We need to do this because: // We need to do this because:
// "Saving the image to the same file it was constructed from is not allowed and throws an exception." // "Saving the image to the same file it was constructed from is not allowed and throws an exception."
string tempName = offsetX + "_ " + offsetY + "_" + filename; string tempName = Path.GetTempFileName();
Bitmap entireBitmap = null; Bitmap entireBitmap = null;
Bitmap thisBitmap = null; Bitmap thisBitmap = null;
if (File.Exists(filename)) if (File.Exists(filename))
{ {
File.Copy(filename, tempName); File.Copy(filename, tempName, true);
entireBitmap = new Bitmap(tempName); entireBitmap = new Bitmap(tempName);
if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY) if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY)
{ {
@ -152,7 +152,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
} }
thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); thisBitmap = CreateGrayscaleBitmapFromMap(m_channel);
Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); // Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY);
for (int x = 0; x < regionSizeX; x++) for (int x = 0; x < regionSizeX; x++)
for (int y = 0; y < regionSizeY; y++) for (int y = 0; y < regionSizeY; y++)
entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y));

View File

@ -38,6 +38,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain
ITerrainChannel LoadStream(Stream stream); ITerrainChannel LoadStream(Stream stream);
void SaveFile(string filename, ITerrainChannel map); void SaveFile(string filename, ITerrainChannel map);
void SaveStream(Stream stream, ITerrainChannel map); void SaveStream(Stream stream, ITerrainChannel map);
/// <summary>
/// Save a number of map tiles to a single big image file.
/// </summary>
/// <remarks>
/// If the image file already exists then the tiles saved will replace those already in the file - other tiles
/// will be untouched.
/// </remarks>
/// <param name="filename">The terrain file to save</param>
/// <param name="offsetX">The map x co-ordinate at which to begin the save.</param>
/// <param name="offsetY">The may y co-ordinate at which to begin the save.</param>
/// <param name="fileWidth">The number of tiles to save along the X axis.</param>
/// <param name="fileHeight">The number of tiles to save along the Y axis.</param>
/// <param name="regionSizeX">The width of a map tile.</param>
/// <param name="regionSizeY">The height of a map tile.</param>
void SaveFile(ITerrainChannel map, string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int regionSizeX, int regionSizeY); void SaveFile(ITerrainChannel map, string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int regionSizeX, int regionSizeY);
} }
} }

View File

@ -561,20 +561,31 @@ namespace OpenSim.Region.CoreModules.World.Terrain
} }
/// <summary> /// <summary>
/// Saves the terrain to a larger terrain file. /// Save a number of map tiles to a single big image file.
/// </summary> /// </summary>
/// <remarks>
/// If the image file already exists then the tiles saved will replace those already in the file - other tiles
/// will be untouched.
/// </remarks>
/// <param name="filename">The terrain file to save</param> /// <param name="filename">The terrain file to save</param>
/// <param name="fileWidth">The width of the file in units</param> /// <param name="fileWidth">The number of tiles to save along the X axis.</param>
/// <param name="fileHeight">The height of the file in units</param> /// <param name="fileHeight">The number of tiles to save along the Y axis.</param>
/// <param name="fileStartX">Where to begin our slice</param> /// <param name="fileStartX">The map x co-ordinate at which to begin the save.</param>
/// <param name="fileStartY">Where to begin our slice</param> /// <param name="fileStartY">The may y co-ordinate at which to begin the save.</param>
public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY)
{ {
int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX; int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX;
int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY; int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY;
if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) if (offsetX < 0 || offsetX >= fileWidth || offsetY < 0 || offsetY >= fileHeight)
{ {
MainConsole.Instance.OutputFormat(
"ERROR: file width + minimum X tile and file height + minimum Y tile must incorporate the current region at ({0},{1}). File width {2} from {3} and file height {4} from {5} does not.",
m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, fileWidth, fileStartX, fileHeight, fileStartY);
return;
}
// this region is included in the tile request // this region is included in the tile request
foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
{ {
@ -587,24 +598,20 @@ namespace OpenSim.Region.CoreModules.World.Terrain
(int)Constants.RegionSize, (int)Constants.RegionSize,
(int)Constants.RegionSize); (int)Constants.RegionSize);
m_log.InfoFormat("[TERRAIN]: Saved terrain from {0} to {1}", m_scene.RegionInfo.RegionName, filename); MainConsole.Instance.OutputFormat(
"Saved terrain from ({0},{1}) to ({2},{3}) from {4} to {5}",
fileStartX, fileStartY, fileStartX + fileWidth - 1, fileStartY + fileHeight - 1,
m_scene.RegionInfo.RegionName, filename);
} }
return; return;
} }
} }
m_log.ErrorFormat( MainConsole.Instance.OutputFormat(
"[TERRAIN]: Could not save terrain from {0} to {1}. Valid file extensions are {2}", "ERROR: Could not save terrain from {0} to {1}. Valid file extensions are {2}",
m_scene.RegionInfo.RegionName, filename, m_supportedFileExtensions); m_scene.RegionInfo.RegionName, filename, m_supportedFileExtensions);
} }
// else
// {
// m_log.ErrorFormat(
// "[TERRAIN]: Could not save terrain from {0} to {1}. {2} {3} {4} {5} {6} {7}",
// m_scene.RegionInfo.RegionName, filename, fileWidth, fileHeight, fileStartX, fileStartY, offsetX, offsetY);
// }
}
/// <summary> /// <summary>
/// Performs updates to the region periodically, synchronising physics and other heightmap aware sections /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections
@ -1192,6 +1199,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain
"Integer"); "Integer");
saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file",
"Integer"); "Integer");
saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first tile on the file\n"
+ "= Example =\n"
+ "To save a PNG file for a set of map tiles 2 regions wide and 3 regions high from map co-ordinate (9910,10234)\n"
+ " # terrain save-tile ST06.png 2 3 9910 10234\n",
"Integer");
// Terrain adjustments // Terrain adjustments
Command fillRegionCommand = Command fillRegionCommand =
new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value.");