aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Application/OpenSim.cs127
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs239
2 files changed, 215 insertions, 151 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 145875b..59b6b21 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -225,12 +225,12 @@ namespace OpenSim
225 /// </summary> 225 /// </summary>
226 private void RegisterConsoleCommands() 226 private void RegisterConsoleCommands()
227 { 227 {
228 m_console.Commands.AddCommand("region", false, "force update", 228 m_console.Commands.AddCommand("Regions", false, "force update",
229 "force update", 229 "force update",
230 "Force the update of all objects on clients", 230 "Force the update of all objects on clients",
231 HandleForceUpdate); 231 HandleForceUpdate);
232 232
233 m_console.Commands.AddCommand("region", false, "debug packet", 233 m_console.Commands.AddCommand("Comms", false, "debug packet",
234 "debug packet <level> [<avatar-first-name> <avatar-last-name>]", 234 "debug packet <level> [<avatar-first-name> <avatar-last-name>]",
235 "Turn on packet debugging", 235 "Turn on packet debugging",
236 "If level > 255 then all incoming and outgoing packets are logged.\n" 236 "If level > 255 then all incoming and outgoing packets are logged.\n"
@@ -242,7 +242,7 @@ namespace OpenSim
242 + "If an avatar name is given then only packets from that avatar are logged", 242 + "If an avatar name is given then only packets from that avatar are logged",
243 Debug); 243 Debug);
244 244
245 m_console.Commands.AddCommand("region", false, "debug http", 245 m_console.Commands.AddCommand("Comms", false, "debug http",
246 "debug http <level>", 246 "debug http <level>",
247 "Turn on inbound http request debugging for everything except the event queue (see debug eq).", 247 "Turn on inbound http request debugging for everything except the event queue (see debug eq).",
248 "If level >= 2 then the handler used to service the request is logged.\n" 248 "If level >= 2 then the handler used to service the request is logged.\n"
@@ -250,37 +250,37 @@ namespace OpenSim
250 + "If level <= 0 then no extra http logging is done.\n", 250 + "If level <= 0 then no extra http logging is done.\n",
251 Debug); 251 Debug);
252 252
253 m_console.Commands.AddCommand("region", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug); 253 m_console.Commands.AddCommand("Comms", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug);
254 254
255 m_console.Commands.AddCommand("region", false, "debug scene", 255 m_console.Commands.AddCommand("Regions", false, "debug scene",
256 "debug scene <scripting> <collisions> <physics>", 256 "debug scene <scripting> <collisions> <physics>",
257 "Turn on scene debugging", Debug); 257 "Turn on scene debugging", Debug);
258 258
259 m_console.Commands.AddCommand("region", false, "change region", 259 m_console.Commands.AddCommand("General", false, "change region",
260 "change region <region name>", 260 "change region <region name>",
261 "Change current console region", ChangeSelectedRegion); 261 "Change current console region", ChangeSelectedRegion);
262 262
263 m_console.Commands.AddCommand("region", false, "save xml", 263 m_console.Commands.AddCommand("Archiving", false, "save xml",
264 "save xml", 264 "save xml",
265 "Save a region's data in XML format", SaveXml); 265 "Save a region's data in XML format", SaveXml);
266 266
267 m_console.Commands.AddCommand("region", false, "save xml2", 267 m_console.Commands.AddCommand("Archiving", false, "save xml2",
268 "save xml2", 268 "save xml2",
269 "Save a region's data in XML2 format", SaveXml2); 269 "Save a region's data in XML2 format", SaveXml2);
270 270
271 m_console.Commands.AddCommand("region", false, "load xml", 271 m_console.Commands.AddCommand("Archiving", false, "load xml",
272 "load xml [-newIDs [<x> <y> <z>]]", 272 "load xml [-newIDs [<x> <y> <z>]]",
273 "Load a region's data from XML format", LoadXml); 273 "Load a region's data from XML format", LoadXml);
274 274
275 m_console.Commands.AddCommand("region", false, "load xml2", 275 m_console.Commands.AddCommand("Archiving", false, "load xml2",
276 "load xml2", 276 "load xml2",
277 "Load a region's data from XML2 format", LoadXml2); 277 "Load a region's data from XML2 format", LoadXml2);
278 278
279 m_console.Commands.AddCommand("region", false, "save prims xml2", 279 m_console.Commands.AddCommand("Archiving", false, "save prims xml2",
280 "save prims xml2 [<prim name> <file name>]", 280 "save prims xml2 [<prim name> <file name>]",
281 "Save named prim to XML2", SavePrimsXml2); 281 "Save named prim to XML2", SavePrimsXml2);
282 282
283 m_console.Commands.AddCommand("region", false, "load oar", 283 m_console.Commands.AddCommand("Archiving", false, "load oar",
284 "load oar [--merge] [--skip-assets] [<OAR path>]", 284 "load oar [--merge] [--skip-assets] [<OAR path>]",
285 "Load a region's data from an OAR archive.", 285 "Load a region's data from an OAR archive.",
286 "--merge will merge the OAR with the existing scene." + Environment.NewLine 286 "--merge will merge the OAR with the existing scene." + Environment.NewLine
@@ -289,7 +289,7 @@ namespace OpenSim
289 + " If this is not given then the command looks for an OAR named region.oar in the current directory.", 289 + " If this is not given then the command looks for an OAR named region.oar in the current directory.",
290 LoadOar); 290 LoadOar);
291 291
292 m_console.Commands.AddCommand("region", false, "save oar", 292 m_console.Commands.AddCommand("Archiving", false, "save oar",
293 //"save oar [-v|--version=<N>] [-p|--profile=<url>] [<OAR path>]", 293 //"save oar [-v|--version=<N>] [-p|--profile=<url>] [<OAR path>]",
294 "save oar [-h|--home=<url>] [--noassets] [--publish] [--perm=<permissions>] [<OAR path>]", 294 "save oar [-h|--home=<url>] [--noassets] [--publish] [--perm=<permissions>] [<OAR path>]",
295 "Save a region's data to an OAR archive.", 295 "Save a region's data to an OAR archive.",
@@ -306,54 +306,54 @@ namespace OpenSim
306 + " If this is not given then the oar is saved to region.oar in the current directory.", 306 + " If this is not given then the oar is saved to region.oar in the current directory.",
307 SaveOar); 307 SaveOar);
308 308
309 m_console.Commands.AddCommand("region", false, "edit scale", 309 m_console.Commands.AddCommand("Regions", false, "edit scale",
310 "edit scale <name> <x> <y> <z>", 310 "edit scale <name> <x> <y> <z>",
311 "Change the scale of a named prim", HandleEditScale); 311 "Change the scale of a named prim", HandleEditScale);
312 312
313 m_console.Commands.AddCommand("region", false, "kick user", 313 m_console.Commands.AddCommand("Users", false, "kick user",
314 "kick user <first> <last> [message]", 314 "kick user <first> <last> [message]",
315 "Kick a user off the simulator", KickUserCommand); 315 "Kick a user off the simulator", KickUserCommand);
316 316
317 m_console.Commands.AddCommand("region", false, "show users", 317 m_console.Commands.AddCommand("Users", false, "show users",
318 "show users [full]", 318 "show users [full]",
319 "Show user data for users currently on the region", 319 "Show user data for users currently on the region",
320 "Without the 'full' option, only users actually on the region are shown." 320 "Without the 'full' option, only users actually on the region are shown."
321 + " With the 'full' option child agents of users in neighbouring regions are also shown.", 321 + " With the 'full' option child agents of users in neighbouring regions are also shown.",
322 HandleShow); 322 HandleShow);
323 323
324 m_console.Commands.AddCommand("region", false, "show connections", 324 m_console.Commands.AddCommand("Comms", false, "show connections",
325 "show connections", 325 "show connections",
326 "Show connection data", HandleShow); 326 "Show connection data", HandleShow);
327 327
328 m_console.Commands.AddCommand("region", false, "show circuits", 328 m_console.Commands.AddCommand("Comms", false, "show circuits",
329 "show circuits", 329 "show circuits",
330 "Show agent circuit data", HandleShow); 330 "Show agent circuit data", HandleShow);
331 331
332 m_console.Commands.AddCommand("region", false, "show http-handlers", 332 m_console.Commands.AddCommand("Comms", false, "show http-handlers",
333 "show http-handlers", 333 "show http-handlers",
334 "Show all registered http handlers", HandleShow); 334 "Show all registered http handlers", HandleShow);
335 335
336 m_console.Commands.AddCommand("region", false, "show pending-objects", 336 m_console.Commands.AddCommand("Comms", false, "show pending-objects",
337 "show pending-objects", 337 "show pending-objects",
338 "Show # of objects on the pending queues of all scene viewers", HandleShow); 338 "Show # of objects on the pending queues of all scene viewers", HandleShow);
339 339
340 m_console.Commands.AddCommand("region", false, "show modules", 340 m_console.Commands.AddCommand("General", false, "show modules",
341 "show modules", 341 "show modules",
342 "Show module data", HandleShow); 342 "Show module data", HandleShow);
343 343
344 m_console.Commands.AddCommand("region", false, "show regions", 344 m_console.Commands.AddCommand("Regions", false, "show regions",
345 "show regions", 345 "show regions",
346 "Show region data", HandleShow); 346 "Show region data", HandleShow);
347 347
348 m_console.Commands.AddCommand("region", false, "show ratings", 348 m_console.Commands.AddCommand("Regions", false, "show ratings",
349 "show ratings", 349 "show ratings",
350 "Show rating data", HandleShow); 350 "Show rating data", HandleShow);
351 351
352 m_console.Commands.AddCommand("region", false, "backup", 352 m_console.Commands.AddCommand("Regions", false, "backup",
353 "backup", 353 "backup",
354 "Persist currently unsaved object changes immediately instead of waiting for the normal persistence call.", RunCommand); 354 "Persist currently unsaved object changes immediately instead of waiting for the normal persistence call.", RunCommand);
355 355
356 m_console.Commands.AddCommand("region", false, "create region", 356 m_console.Commands.AddCommand("Regions", false, "create region",
357 "create region [\"region name\"] <region_file.ini>", 357 "create region [\"region name\"] <region_file.ini>",
358 "Create a new region.", 358 "Create a new region.",
359 "The settings for \"region name\" are read from <region_file.ini>. Paths specified with <region_file.ini> are relative to your Regions directory, unless an absolute path is given." 359 "The settings for \"region name\" are read from <region_file.ini>. Paths specified with <region_file.ini> are relative to your Regions directory, unless an absolute path is given."
@@ -362,62 +362,57 @@ namespace OpenSim
362 + "If <region_file.ini> does not exist, it will be created.", 362 + "If <region_file.ini> does not exist, it will be created.",
363 HandleCreateRegion); 363 HandleCreateRegion);
364 364
365 m_console.Commands.AddCommand("region", false, "restart", 365 m_console.Commands.AddCommand("Regions", false, "restart",
366 "restart", 366 "restart",
367 "Restart all sims in this instance", RunCommand); 367 "Restart all sims in this instance", RunCommand);
368 368
369 m_console.Commands.AddCommand("region", false, "config set", 369 m_console.Commands.AddCommand("General", false, "config set",
370 "config set <section> <key> <value>", 370 "config set <section> <key> <value>",
371 "Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig); 371 "Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig);
372 372
373 m_console.Commands.AddCommand("region", false, "config get", 373 m_console.Commands.AddCommand("General", false, "config get",
374 "config get [<section>] [<key>]", 374 "config get [<section>] [<key>]",
375 "Synonym for config show", 375 "Synonym for config show",
376 HandleConfig); 376 HandleConfig);
377 377
378 m_console.Commands.AddCommand("region", false, "config show", 378 m_console.Commands.AddCommand("General", false, "config show",
379 "config show [<section>] [<key>]", 379 "config show [<section>] [<key>]",
380 "Show config information", 380 "Show config information",
381 "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine 381 "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
382 + "If a section is given but not a field, then all fields in that section are printed.", 382 + "If a section is given but not a field, then all fields in that section are printed.",
383 HandleConfig); 383 HandleConfig);
384 384
385 m_console.Commands.AddCommand("region", false, "config save", 385 m_console.Commands.AddCommand("General", false, "config save",
386 "config save <path>", 386 "config save <path>",
387 "Save current configuration to a file at the given path", HandleConfig); 387 "Save current configuration to a file at the given path", HandleConfig);
388 388
389 m_console.Commands.AddCommand("region", false, "command-script", 389 m_console.Commands.AddCommand("General", false, "command-script",
390 "command-script <script>", 390 "command-script <script>",
391 "Run a command script from file", RunCommand); 391 "Run a command script from file", RunCommand);
392 392
393 m_console.Commands.AddCommand("region", false, "remove-region", 393 m_console.Commands.AddCommand("Regions", false, "remove-region",
394 "remove-region <name>", 394 "remove-region <name>",
395 "Remove a region from this simulator", RunCommand); 395 "Remove a region from this simulator", RunCommand);
396 396
397 m_console.Commands.AddCommand("region", false, "delete-region", 397 m_console.Commands.AddCommand("Regions", false, "delete-region",
398 "delete-region <name>", 398 "delete-region <name>",
399 "Delete a region from disk", RunCommand); 399 "Delete a region from disk", RunCommand);
400 400
401 m_console.Commands.AddCommand("region", false, "modules list", 401 m_console.Commands.AddCommand("General", false, "modules list",
402 "modules list", 402 "modules list",
403 "List modules", HandleModules); 403 "List modules", HandleModules);
404 404
405 m_console.Commands.AddCommand("region", false, "modules load", 405 m_console.Commands.AddCommand("General", false, "modules load",
406 "modules load <name>", 406 "modules load <name>",
407 "Load a module", HandleModules); 407 "Load a module", HandleModules);
408 408
409 m_console.Commands.AddCommand("region", false, "modules unload", 409 m_console.Commands.AddCommand("General", false, "modules unload",
410 "modules unload <name>", 410 "modules unload <name>",
411 "Unload a module", HandleModules); 411 "Unload a module", HandleModules);
412 412
413 m_console.Commands.AddCommand("region", false, "Add-InventoryHost", 413 m_console.Commands.AddCommand("Regions", false, "kill uuid",
414 "Add-InventoryHost <host>",
415 String.Empty, RunCommand);
416
417 m_console.Commands.AddCommand("region", false, "kill uuid",
418 "kill uuid <UUID>", 414 "kill uuid <UUID>",
419 "Kill an object by UUID", KillUUID); 415 "Kill an object by UUID", KillUUID);
420
421 } 416 }
422 417
423 public override void ShutdownSpecific() 418 public override void ShutdownSpecific()
@@ -508,7 +503,11 @@ namespace OpenSim
508 string currentCommand; 503 string currentCommand;
509 while ((currentCommand = readFile.ReadLine()) != null) 504 while ((currentCommand = readFile.ReadLine()) != null)
510 { 505 {
511 if (currentCommand != String.Empty) 506 currentCommand = currentCommand.Trim();
507 if (!(currentCommand == ""
508 || currentCommand.StartsWith(";")
509 || currentCommand.StartsWith("//")
510 || currentCommand.StartsWith("#")))
512 { 511 {
513 m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); 512 m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'");
514 m_console.RunCommand(currentCommand); 513 m_console.RunCommand(currentCommand);
@@ -829,14 +828,6 @@ namespace OpenSim
829 case "restart": 828 case "restart":
830 m_sceneManager.RestartCurrentScene(); 829 m_sceneManager.RestartCurrentScene();
831 break; 830 break;
832
833 case "Add-InventoryHost":
834 if (cmdparams.Length > 0)
835 {
836 MainConsole.Instance.Output("Not implemented.");
837 }
838 break;
839
840 } 831 }
841 } 832 }
842 833
@@ -928,7 +919,7 @@ namespace OpenSim
928 break; 919 break;
929 920
930 case "scene": 921 case "scene":
931 if (args.Length == 5) 922 if (args.Length == 4)
932 { 923 {
933 if (m_sceneManager.CurrentScene == null) 924 if (m_sceneManager.CurrentScene == null)
934 { 925 {
@@ -936,39 +927,21 @@ namespace OpenSim
936 } 927 }
937 else 928 else
938 { 929 {
939 bool scriptingOn = !Convert.ToBoolean(args[2]); 930 string key = args[2];
940 bool collisionsOn = !Convert.ToBoolean(args[3]); 931 string value = args[3];
941 bool physicsOn = !Convert.ToBoolean(args[4]); 932 m_sceneManager.CurrentScene.SetSceneCoreDebug(
942 m_sceneManager.CurrentScene.SetSceneCoreDebug(scriptingOn, collisionsOn, physicsOn); 933 new Dictionary<string, string>() { { key, value } });
943 934
944 MainConsole.Instance.Output( 935 MainConsole.Instance.OutputFormat("Set debug scene {0} = {1}", key, value);
945 String.Format(
946 "Set debug scene scripting = {0}, collisions = {1}, physics = {2}",
947 !scriptingOn, !collisionsOn, !physicsOn));
948 } 936 }
949 } 937 }
950 else 938 else
951 { 939 {
952 MainConsole.Instance.Output("Usage: debug scene <scripting> <collisions> <physics> (where inside <> is true/false)"); 940 MainConsole.Instance.Output("Usage: debug scene scripting|collisions|physics|teleport true|false");
953 } 941 }
954 942
955 break; 943 break;
956 944
957 case "teleport":
958 foreach(Scene s in m_sceneManager.Scenes)
959 {
960 if (s.DEBUG)
961 {
962 s.DEBUG = false;
963 MainConsole.Instance.Output("Teleport debugging is disabled!");
964 }
965 else{
966 s.DEBUG = true;
967 MainConsole.Instance.Output("Teleport debugging is enabled!");
968 }
969 }
970 break;
971
972 default: 945 default:
973 MainConsole.Instance.Output("Unknown debug command"); 946 MainConsole.Instance.Output("Unknown debug command");
974 break; 947 break;
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index f482d8f..5de3f25 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Linq;
31using System.Net; 32using System.Net;
32using System.Reflection; 33using System.Reflection;
33using System.Text; 34using System.Text;
@@ -67,6 +68,9 @@ namespace OpenSim
67 private const string PLUGIN_ASSET_CACHE = "/OpenSim/AssetCache"; 68 private const string PLUGIN_ASSET_CACHE = "/OpenSim/AssetCache";
68 private const string PLUGIN_ASSET_SERVER_CLIENT = "/OpenSim/AssetClient"; 69 private const string PLUGIN_ASSET_SERVER_CLIENT = "/OpenSim/AssetClient";
69 70
71 // OpenSim.ini Section name for ESTATES Settings
72 public const string ESTATE_SECTION_NAME = "Estates";
73
70 protected string proxyUrl; 74 protected string proxyUrl;
71 protected int proxyOffset = 0; 75 protected int proxyOffset = 0;
72 76
@@ -242,15 +246,18 @@ namespace OpenSim
242 246
243 foreach (string topic in topics) 247 foreach (string topic in topics)
244 { 248 {
245 m_console.Commands.AddCommand("plugin", false, "help " + topic, 249 string capitalizedTopic = char.ToUpper(topic[0]) + topic.Substring(1);
246 "help " + topic, 250
251 // This is a hack to allow the user to enter the help command in upper or lowercase. This will go
252 // away at some point.
253 m_console.Commands.AddCommand(capitalizedTopic, false, "help " + topic,
254 "help " + capitalizedTopic,
255 "Get help on plugin command '" + topic + "'",
256 HandleCommanderHelp);
257 m_console.Commands.AddCommand(capitalizedTopic, false, "help " + capitalizedTopic,
258 "help " + capitalizedTopic,
247 "Get help on plugin command '" + topic + "'", 259 "Get help on plugin command '" + topic + "'",
248 HandleCommanderHelp); 260 HandleCommanderHelp);
249
250 m_console.Commands.AddCommand("plugin", false, topic,
251 topic,
252 "Execute subcommand for plugin '" + topic + "'",
253 null);
254 261
255 ICommander commander = null; 262 ICommander commander = null;
256 263
@@ -267,7 +274,7 @@ namespace OpenSim
267 274
268 foreach (string command in commander.Commands.Keys) 275 foreach (string command in commander.Commands.Keys)
269 { 276 {
270 m_console.Commands.AddCommand(topic, false, 277 m_console.Commands.AddCommand(capitalizedTopic, false,
271 topic + " " + command, 278 topic + " " + command,
272 topic + " " + commander.Commands[command].ShortHelp(), 279 topic + " " + commander.Commands[command].ShortHelp(),
273 String.Empty, HandleCommanderCommand); 280 String.Empty, HandleCommanderCommand);
@@ -286,7 +293,7 @@ namespace OpenSim
286 // Only safe for the interactive console, since it won't 293 // Only safe for the interactive console, since it won't
287 // let us come here unless both scene and commander exist 294 // let us come here unless both scene and commander exist
288 // 295 //
289 ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(cmd[1]); 296 ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(cmd[1].ToLower());
290 if (moduleCommander != null) 297 if (moduleCommander != null)
291 m_console.Output(moduleCommander.Help); 298 m_console.Output(moduleCommander.Help);
292 } 299 }
@@ -424,7 +431,7 @@ namespace OpenSim
424 431
425 mscene = scene; 432 mscene = scene;
426 433
427 scene.StartTimer(); 434 scene.Start();
428 435
429 scene.StartScripts(); 436 scene.StartScripts();
430 437
@@ -443,12 +450,42 @@ namespace OpenSim
443 { 450 {
444 RegionInfo regionInfo = scene.RegionInfo; 451 RegionInfo regionInfo = scene.RegionInfo;
445 452
453 string estateOwnerFirstName = null;
454 string estateOwnerLastName = null;
455 string estateOwnerEMail = null;
456 string estateOwnerPassword = null;
457 string rawEstateOwnerUuid = null;
458
459 if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null)
460 {
461 string defaultEstateOwnerName
462 = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim();
463 string[] ownerNames = defaultEstateOwnerName.Split(' ');
464
465 if (ownerNames.Length >= 2)
466 {
467 estateOwnerFirstName = ownerNames[0];
468 estateOwnerLastName = ownerNames[1];
469 }
470
471 // Info to be used only on Standalone Mode
472 rawEstateOwnerUuid = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null);
473 estateOwnerEMail = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null);
474 estateOwnerPassword = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null);
475 }
476
446 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName); 477 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName);
447 List<char> excluded = new List<char>(new char[1]{' '}); 478 List<char> excluded = new List<char>(new char[1]{' '});
448 string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded);
449 string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded);
450 479
451 UserAccount account = scene.UserAccountService.GetUserAccount(regionInfo.ScopeID, first, last); 480
481 if (estateOwnerFirstName == null || estateOwnerLastName == null)
482 {
483 estateOwnerFirstName = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded);
484 estateOwnerLastName = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded);
485 }
486
487 UserAccount account
488 = scene.UserAccountService.GetUserAccount(regionInfo.ScopeID, estateOwnerFirstName, estateOwnerLastName);
452 489
453 if (account == null) 490 if (account == null)
454 { 491 {
@@ -467,23 +504,35 @@ namespace OpenSim
467 504
468 if (scene.UserAccountService is UserAccountService) 505 if (scene.UserAccountService is UserAccountService)
469 { 506 {
470 string password = MainConsole.Instance.PasswdPrompt("Password"); 507 if (estateOwnerPassword == null)
471 string email = MainConsole.Instance.CmdPrompt("Email", ""); 508 estateOwnerPassword = MainConsole.Instance.PasswdPrompt("Password");
472 509
473 string rawPrincipalId = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString()); 510 if (estateOwnerEMail == null)
511 estateOwnerEMail = MainConsole.Instance.CmdPrompt("Email");
512
513 if (rawEstateOwnerUuid == null)
514 rawEstateOwnerUuid = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString());
474 515
475 UUID principalId = UUID.Zero; 516 UUID estateOwnerUuid = UUID.Zero;
476 if (!UUID.TryParse(rawPrincipalId, out principalId)) 517 if (!UUID.TryParse(rawEstateOwnerUuid, out estateOwnerUuid))
477 { 518 {
478 m_log.ErrorFormat("[OPENSIM]: ID {0} is not a valid UUID", rawPrincipalId); 519 m_log.ErrorFormat("[OPENSIM]: ID {0} is not a valid UUID", rawEstateOwnerUuid);
479 return; 520 return;
480 } 521 }
481 522
523 // If we've been given a zero uuid then this signals that we should use a random user id
524 if (estateOwnerUuid == UUID.Zero)
525 estateOwnerUuid = UUID.Random();
526
482 account 527 account
483 = ((UserAccountService)scene.UserAccountService).CreateUser( 528 = ((UserAccountService)scene.UserAccountService).CreateUser(
484 regionInfo.ScopeID, principalId, first, last, password, email); 529 regionInfo.ScopeID,
530 estateOwnerUuid,
531 estateOwnerFirstName,
532 estateOwnerLastName,
533 estateOwnerPassword,
534 estateOwnerEMail);
485 } 535 }
486// }
487 } 536 }
488 537
489 if (account == null) 538 if (account == null)
@@ -883,15 +932,21 @@ namespace OpenSim
883 /// This method doesn't allow an estate to be created with the same name as existing estates. 932 /// This method doesn't allow an estate to be created with the same name as existing estates.
884 /// </remarks> 933 /// </remarks>
885 /// <param name="regInfo"></param> 934 /// <param name="regInfo"></param>
886 /// <param name="existingName">A list of estate names that already exist.</param> 935 /// <param name="estatesByName">A list of estate names that already exist.</param>
936 /// <param name="estateName">Estate name to create if already known</param>
887 /// <returns>true if the estate was created, false otherwise</returns> 937 /// <returns>true if the estate was created, false otherwise</returns>
888 public bool CreateEstate(RegionInfo regInfo, List<string> existingNames) 938 public bool CreateEstate(RegionInfo regInfo, Dictionary<string, EstateSettings> estatesByName, string estateName)
889 { 939 {
890 // Create a new estate 940 // Create a new estate
891 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); 941 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true);
892 string newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
893 942
894 if (existingNames.Contains(newName)) 943 string newName;
944 if (estateName != null && estateName != "")
945 newName = estateName;
946 else
947 newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
948
949 if (estatesByName.ContainsKey(newName))
895 { 950 {
896 MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName); 951 MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName);
897 return false; 952 return false;
@@ -918,66 +973,102 @@ namespace OpenSim
918 if (EstateDataService != null) 973 if (EstateDataService != null)
919 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, false); 974 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, false);
920 975
921 if (regInfo.EstateSettings.EstateID == 0) // No record at all 976 if (regInfo.EstateSettings.EstateID != 0)
977 return;
978
979 m_log.WarnFormat("[ESTATE] Region {0} is not part of an estate.", regInfo.RegionName);
980
981 List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll();
982 Dictionary<string, EstateSettings> estatesByName = new Dictionary<string, EstateSettings>();
983
984 foreach (EstateSettings estate in estates)
985 estatesByName[estate.EstateName] = estate;
986
987 string defaultEstateName = null;
988
989 if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null)
922 { 990 {
923 m_log.WarnFormat("[ESTATE] Region {0} is not part of an estate.", regInfo.RegionName); 991 defaultEstateName = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null);
924 992
925 List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll(); 993 if (defaultEstateName != null)
926 List<string> estateNames = new List<string>();
927 foreach (EstateSettings estate in estates)
928 estateNames.Add(estate.EstateName);
929
930 while (true)
931 { 994 {
932 if (estates.Count == 0) 995 EstateSettings defaultEstate;
933 { 996 bool defaultEstateJoined = false;
934 m_log.Info("[ESTATE] No existing estates found. You must create a new one."); 997
935 998 if (estatesByName.ContainsKey(defaultEstateName))
936 if (CreateEstate(regInfo, estateNames)) 999 {
937 break; 1000 defaultEstate = estatesByName[defaultEstateName];
1001
1002 if (EstateDataService.LinkRegion(regInfo.RegionID, (int)defaultEstate.EstateID))
1003 defaultEstateJoined = true;
1004 }
1005 else
1006 {
1007 if (CreateEstate(regInfo, estatesByName, defaultEstateName))
1008 defaultEstateJoined = true;
1009 }
1010
1011 if (defaultEstateJoined)
1012 return;
1013 else
1014 m_log.ErrorFormat(
1015 "[OPENSIM BASE]: Joining default estate {0} failed", defaultEstateName);
1016 }
1017 }
1018
1019 // If we have no default estate or creation of the default estate failed then ask the user.
1020 while (true)
1021 {
1022 if (estates.Count == 0)
1023 {
1024 m_log.Info("[ESTATE]: No existing estates found. You must create a new one.");
1025
1026 if (CreateEstate(regInfo, estatesByName, null))
1027 break;
1028 else
1029 continue;
1030 }
1031 else
1032 {
1033 string response
1034 = MainConsole.Instance.CmdPrompt(
1035 string.Format(
1036 "Do you wish to join region {0} to an existing estate (yes/no)?", regInfo.RegionName),
1037 "yes",
1038 new List<string>() { "yes", "no" });
1039
1040 if (response == "no")
1041 {
1042 if (CreateEstate(regInfo, estatesByName, null))
1043 break;
938 else 1044 else
939 continue; 1045 continue;
940 } 1046 }
941 else 1047 else
942 { 1048 {
943 string response 1049 string[] estateNames = estatesByName.Keys.ToArray();
1050 response
944 = MainConsole.Instance.CmdPrompt( 1051 = MainConsole.Instance.CmdPrompt(
945 string.Format( 1052 string.Format(
946 "Do you wish to join region {0} to an existing estate (yes/no)?", regInfo.RegionName), 1053 "Name of estate to join. Existing estate names are ({0})",
947 "yes", 1054 string.Join(", ", estateNames)),
948 new List<string>() { "yes", "no" }); 1055 estateNames[0]);
949 1056
950 if (response == "no") 1057 List<int> estateIDs = EstateDataService.GetEstates(response);
1058 if (estateIDs.Count < 1)
951 { 1059 {
952 if (CreateEstate(regInfo, estateNames)) 1060 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again.");
953 break; 1061 continue;
954 else
955 continue;
956 }
957 else
958 {
959 response
960 = MainConsole.Instance.CmdPrompt(
961 string.Format(
962 "Name of estate to join. Existing estate names are ({0})", string.Join(", ", estateNames.ToArray())),
963 estateNames[0]);
964
965 List<int> estateIDs = EstateDataService.GetEstates(response);
966 if (estateIDs.Count < 1)
967 {
968 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again.");
969 continue;
970 }
971
972 int estateID = estateIDs[0];
973
974 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID);
975
976 if (EstateDataService.LinkRegion(regInfo.RegionID, estateID))
977 break;
978
979 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
980 } 1062 }
1063
1064 int estateID = estateIDs[0];
1065
1066 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID);
1067
1068 if (EstateDataService.LinkRegion(regInfo.RegionID, estateID))
1069 break;
1070
1071 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
981 } 1072 }
982 } 1073 }
983 } 1074 }