aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/RegionInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/RegionInfo.cs')
-rw-r--r--OpenSim/Framework/RegionInfo.cs126
1 files changed, 115 insertions, 11 deletions
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 6a264a6..eee078e 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -29,9 +29,11 @@ using System;
29using System.Net; 29using System.Net;
30using System.Net.Sockets; 30using System.Net.Sockets;
31using System.Xml; 31using System.Xml;
32using System.IO;
32using Nini.Config; 33using Nini.Config;
33using OpenMetaverse; 34using OpenMetaverse;
34using OpenMetaverse.StructuredData; 35using OpenMetaverse.StructuredData;
36using OpenSim.Framework.Console;
35 37
36namespace OpenSim.Framework 38namespace OpenSim.Framework
37{ 39{
@@ -250,6 +252,16 @@ namespace OpenSim.Framework
250 252
251 if (filename.ToLower().EndsWith(".ini")) 253 if (filename.ToLower().EndsWith(".ini"))
252 { 254 {
255 if (!File.Exists(filename)) // New region config request
256 {
257 IniConfigSource newFile = new IniConfigSource();
258 ReadNiniConfig(newFile, String.Empty);
259
260 newFile.Save(filename);
261
262 return;
263 }
264
253 IConfigSource source = new IniConfigSource(filename); 265 IConfigSource source = new IniConfigSource(filename);
254 266
255 ReadNiniConfig(source, configName); 267 ReadNiniConfig(source, configName);
@@ -390,11 +402,28 @@ namespace OpenSim.Framework
390 402
391 private void ReadNiniConfig(IConfigSource source, string name) 403 private void ReadNiniConfig(IConfigSource source, string name)
392 { 404 {
405 bool creatingNew = false;
406
407 if (source.Configs.Count == 0)
408 {
409 name = MainConsole.Instance.CmdPrompt("New region name", String.Empty);
410 if (name == String.Empty)
411 throw new Exception("Cannot interactively create region with no name");
412
413 IConfig newRegion = source.AddConfig(name);
414
415 creatingNew = true;
416 }
417
393 if (name == String.Empty) 418 if (name == String.Empty)
394 name = source.Configs[0].Name; 419 name = source.Configs[0].Name;
395 420
396 if (source.Configs[name] == null) 421 if (source.Configs[name] == null)
397 throw new Exception("Config name does not exist"); 422 {
423 IConfig newRegion = source.AddConfig(name);
424
425 creatingNew = true;
426 }
398 427
399 IConfig config = source.Configs[name]; 428 IConfig config = source.Configs[name];
400 429
@@ -403,7 +432,12 @@ namespace OpenSim.Framework
403 string regionUUID = config.GetString("RegionUUID", string.Empty); 432 string regionUUID = config.GetString("RegionUUID", string.Empty);
404 433
405 if (regionUUID == String.Empty) 434 if (regionUUID == String.Empty)
406 throw new Exception("A region UUID is required"); 435 {
436 UUID newID = UUID.Random();
437
438 regionUUID = MainConsole.Instance.CmdPrompt("Region UUID", newID.ToString());
439 config.Set("RegionUUID", regionUUID);
440 }
407 441
408 RegionID = new UUID(regionUUID); 442 RegionID = new UUID(regionUUID);
409 originRegionID = RegionID; // What IS this?! 443 originRegionID = RegionID; // What IS this?!
@@ -419,7 +453,10 @@ namespace OpenSim.Framework
419 string location = config.GetString("Location", String.Empty); 453 string location = config.GetString("Location", String.Empty);
420 454
421 if (location == String.Empty) 455 if (location == String.Empty)
422 throw new Exception("Location is required"); 456 {
457 location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
458 config.Set("Location", location);
459 }
423 460
424 string[] locationElements = location.Split(new char[] {','}); 461 string[] locationElements = location.Split(new char[] {','});
425 462
@@ -434,16 +471,57 @@ namespace OpenSim.Framework
434 471
435 // Internal IP 472 // Internal IP
436 // 473 //
437 IPAddress address = IPAddress.Parse(config.GetString("InternalAddress", "127.0.0.1")); 474 IPAddress address;
438 int port = config.GetInt("InternalPort", 9000); 475
476 if (config.Contains("InternalAddress"))
477 {
478 address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
479 }
480 else
481 {
482 address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "127.0.0.1"));
483 config.Set("InternalAddress", address.ToString());
484 }
485
486 int port;
487
488 if (config.Contains("InternalPort"))
489 {
490 port = config.GetInt("InternalPort", 9000);
491 }
492 else
493 {
494 port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
495 config.Set("InternalPort", port);
496 }
439 497
440 m_internalEndPoint = new IPEndPoint(address, port); 498 m_internalEndPoint = new IPEndPoint(address, port);
441 499
442 m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true); 500 if (config.Contains("AllowAlternatePorts"))
501 {
502 m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
503 }
504 else
505 {
506 m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));
507
508 config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
509 }
443 510
444 // External IP 511 // External IP
445 // 512 //
446 string externalName = config.GetString("ExternalHostName", "SYSTEMIP"); 513 string externalName;
514
515 if (config.Contains("ExternalHostName"))
516 {
517 externalName = config.GetString("ExternalHostName", "SYSTEMIP");
518 }
519 else
520 {
521 externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP");
522 config.Set("ExternalHostName", externalName);
523 }
524
447 if (externalName == "SYSTEMIP") 525 if (externalName == "SYSTEMIP")
448 m_externalHostName = Util.GetLocalHost().ToString(); 526 m_externalHostName = Util.GetLocalHost().ToString();
449 else 527 else
@@ -452,12 +530,38 @@ namespace OpenSim.Framework
452 530
453 // Master avatar cruft 531 // Master avatar cruft
454 // 532 //
455 string masterAvatarUUID = config.GetString("MasterAvatarUUID", UUID.Zero.ToString()); 533 string masterAvatarUUID;
534 if (!creatingNew)
535 {
536 masterAvatarUUID = config.GetString("MasterAvatarUUID", UUID.Zero.ToString());
537 MasterAvatarFirstName = config.GetString("MasterAvatarFirstName", String.Empty);
538 MasterAvatarLastName = config.GetString("MasterAvatarLastName", String.Empty);
539 MasterAvatarSandboxPassword = config.GetString("MasterAvatarSandboxPassword", String.Empty);
540 }
541 else
542 {
543 masterAvatarUUID = MainConsole.Instance.CmdPrompt("Master Avatar UUID", UUID.Zero.ToString());
544 if (masterAvatarUUID != UUID.Zero.ToString())
545 {
546 config.Set("MasterAvatarUUID", masterAvatarUUID);
547 }
548 else
549 {
550 MasterAvatarFirstName = MainConsole.Instance.CmdPrompt("Master Avatar first name (enter for no master avatar)", String.Empty);
551 if (MasterAvatarFirstName != String.Empty)
552 {
553 MasterAvatarLastName = MainConsole.Instance.CmdPrompt("Master Avatar last name", String.Empty);
554 MasterAvatarSandboxPassword = MainConsole.Instance.CmdPrompt("Master Avatar sandbox password", String.Empty);
555
556 config.Set("MasterAvatarFirstName", MasterAvatarFirstName);
557 config.Set("MasterAvatarLastName", MasterAvatarLastName);
558 config.Set("MasterAvatarSandboxPassword", MasterAvatarSandboxPassword);
559 }
560 }
561 }
562
456 MasterAvatarAssignedUUID = new UUID(masterAvatarUUID); 563 MasterAvatarAssignedUUID = new UUID(masterAvatarUUID);
457 564
458 MasterAvatarFirstName = config.GetString("MasterAvatarFirstName", String.Empty);
459 MasterAvatarLastName = config.GetString("MasterAvatarLastName", String.Empty);
460 MasterAvatarSandboxPassword = config.GetString("MasterAvatarSandboxPassword", String.Empty);
461 565
462 566
463 // Prim stuff 567 // Prim stuff