Make "terrain save" more friendly by telling the user if we have saved and putting out a useful complaint message if we haven't for some reason

0.7.2-post-fixes
Justin Clark-Casey (justincc) 2011-11-17 22:13:32 +00:00
parent 8c0d8e72aa
commit 123322569d
1 changed files with 32 additions and 18 deletions

View File

@ -86,6 +86,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
private volatile bool m_tainted; private volatile bool m_tainted;
private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5); private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5);
/// <summary>
/// Human readable list of terrain file extensions that are supported.
/// </summary>
private string m_supportedFileExtensions = "";
#region ICommandableModule Members #region ICommandableModule Members
public ICommander CommandInterface public ICommander CommandInterface
@ -135,6 +140,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
InstallDefaultEffects(); InstallDefaultEffects();
LoadPlugins(); LoadPlugins();
// Generate user-readable extensions list
string supportedFilesSeparator = "";
foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
{
m_supportedFileExtensions += supportedFilesSeparator + loader.Key + " (" + loader.Value + ")";
supportedFilesSeparator = ", ";
}
} }
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
@ -251,20 +265,20 @@ namespace OpenSim.Region.CoreModules.World.Terrain
if (filename.EndsWith(loader.Key)) if (filename.EndsWith(loader.Key))
{ {
loader.Value.SaveFile(filename, m_channel); loader.Value.SaveFile(filename, m_channel);
m_log.InfoFormat("[TERRAIN]: Saved terrain from {0} to {1}", m_scene.RegionInfo.RegionName, filename);
return; return;
} }
} }
} }
catch (NotImplementedException)
{
m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented.");
throw new TerrainException(String.Format("Unable to save heightmap: saving of this file format not implemented"));
}
catch (IOException ioe) catch (IOException ioe)
{ {
m_log.Error(String.Format("[TERRAIN]: Unable to save to {0}, {1}", filename, ioe.Message)); m_log.Error(String.Format("[TERRAIN]: Unable to save to {0}, {1}", filename, ioe.Message));
throw new TerrainException(String.Format("Unable to save heightmap: {0}", ioe.Message)); throw new TerrainException(String.Format("Unable to save heightmap: {0}", ioe.Message));
} }
m_log.ErrorFormat(
"[TERRAIN]: Could not save terrain from {0} to {1}. Valid file extensions are {2}",
m_scene.RegionInfo.RegionName, filename, m_supportedFileExtensions);
} }
/// <summary> /// <summary>
@ -345,6 +359,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
float duration = 0.25f; float duration = 0.25f;
if (action == 0) if (action == 0)
duration = 4.0f; duration = 4.0f;
client_OnModifyTerrain(user, (float)pos.Z, duration, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId); client_OnModifyTerrain(user, (float)pos.Z, duration, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId);
} }
@ -534,6 +549,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
m_channel = channel; m_channel = channel;
UpdateRevertMap(); UpdateRevertMap();
} }
return; return;
} }
} }
@ -566,10 +582,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain
fileWidth, fileHeight, fileWidth, fileHeight,
(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);
} }
return; return;
} }
} }
m_log.ErrorFormat(
"[TERRAIN]: Could not save terrain from {0} to {1}. Valid file extensions are {2}",
m_scene.RegionInfo.RegionName, filename, m_supportedFileExtensions);
} }
} }
@ -1124,32 +1147,23 @@ namespace OpenSim.Region.CoreModules.World.Terrain
private void InstallInterfaces() private void InstallInterfaces()
{ {
// Load / Save
string supportedFileExtensions = "";
string supportedFilesSeparator = "";
foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
{
supportedFileExtensions += supportedFilesSeparator + loader.Key + " (" + loader.Value + ")";
supportedFilesSeparator = ", ";
}
Command loadFromFileCommand = Command loadFromFileCommand =
new Command("load", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLoadFile, "Loads a terrain from a specified file."); new Command("load", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLoadFile, "Loads a terrain from a specified file.");
loadFromFileCommand.AddArgument("filename", loadFromFileCommand.AddArgument("filename",
"The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " +
supportedFileExtensions, "String"); m_supportedFileExtensions, "String");
Command saveToFileCommand = Command saveToFileCommand =
new Command("save", CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveFile, "Saves the current heightmap to a specified file."); new Command("save", CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveFile, "Saves the current heightmap to a specified file.");
saveToFileCommand.AddArgument("filename", saveToFileCommand.AddArgument("filename",
"The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " + "The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " +
supportedFileExtensions, "String"); m_supportedFileExtensions, "String");
Command loadFromTileCommand = Command loadFromTileCommand =
new Command("load-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLoadTileFile, "Loads a terrain from a section of a larger file."); new Command("load-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLoadTileFile, "Loads a terrain from a section of a larger file.");
loadFromTileCommand.AddArgument("filename", loadFromTileCommand.AddArgument("filename",
"The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " +
supportedFileExtensions, "String"); m_supportedFileExtensions, "String");
loadFromTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer"); loadFromTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer");
loadFromTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer"); loadFromTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer");
loadFromTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file", loadFromTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file",
@ -1161,7 +1175,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
new Command("save-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceSaveTileFile, "Saves the current heightmap to the larger file."); new Command("save-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceSaveTileFile, "Saves the current heightmap to the larger file.");
saveToTileCommand.AddArgument("filename", saveToTileCommand.AddArgument("filename",
"The file you wish to save to, the file extension determines the loader to be used. Supported extensions include: " + "The file you wish to save to, the file extension determines the loader to be used. Supported extensions include: " +
supportedFileExtensions, "String"); m_supportedFileExtensions, "String");
saveToTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer"); saveToTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer");
saveToTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer"); saveToTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer");
saveToTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file", saveToTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file",