prevent "create region" console command from being able to create a region with the same id as one that already exists.

Addresses http://opensimulator.org/mantis/view.php?id=5617
bulletsim
Justin Clark-Casey (justincc) 2011-08-06 01:35:01 +01:00
parent 76f46b2545
commit 2b26d2f1a5
1 changed files with 15 additions and 1 deletions

View File

@ -549,6 +549,7 @@ namespace OpenSim
{ {
string regionName = string.Empty; string regionName = string.Empty;
string regionFile = string.Empty; string regionFile = string.Empty;
if (cmd.Length == 3) if (cmd.Length == 3)
{ {
regionFile = cmd[2]; regionFile = cmd[2];
@ -558,14 +559,17 @@ namespace OpenSim
regionName = cmd[2]; regionName = cmd[2];
regionFile = cmd[3]; regionFile = cmd[3];
} }
string extension = Path.GetExtension(regionFile).ToLower(); string extension = Path.GetExtension(regionFile).ToLower();
bool isXml = extension.Equals(".xml"); bool isXml = extension.Equals(".xml");
bool isIni = extension.Equals(".ini"); bool isIni = extension.Equals(".ini");
if (!isXml && !isIni) if (!isXml && !isIni)
{ {
MainConsole.Instance.Output("Usage: create region [\"region name\"] <region_file.ini>"); MainConsole.Instance.Output("Usage: create region [\"region name\"] <region_file.ini>");
return; return;
} }
if (!Path.IsPathRooted(regionFile)) if (!Path.IsPathRooted(regionFile))
{ {
string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim(); string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
@ -582,8 +586,18 @@ namespace OpenSim
regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source, regionName); regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source, regionName);
} }
IScene scene; Scene existingScene;
if (SceneManager.TryGetScene(regInfo.RegionID, out existingScene))
{
MainConsole.Instance.OutputFormat(
"ERROR: Cannot create region {0} with ID {1}, this ID is already assigned to region {2}",
regInfo.RegionName, regInfo.RegionID, existingScene.RegionInfo.RegionName);
return;
}
PopulateRegionEstateInfo(regInfo); PopulateRegionEstateInfo(regInfo);
IScene scene;
CreateRegion(regInfo, true, out scene); CreateRegion(regInfo, true, out scene);
regInfo.EstateSettings.Save(); regInfo.EstateSettings.Save();
} }