//Returns true if the source should be updated. Returns false if it does not.
        public bool ReadNiniConfig(RegionInfo region, IConfigSource source, string name)
        {
            //            bool creatingNew = false;

            if (name == String.Empty || source.Configs.Count == 0)
            {
                MainConsole.Instance.Info ("=====================================\n");
                MainConsole.Instance.Info ("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Info ("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Info ("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Info ("=====================================\n");
            }

            bool NeedsUpdate = false;
            if (name == String.Empty)
                name = MainConsole.Instance.Prompt("New region name", name);
            if (name == String.Empty)
                throw new Exception("Cannot interactively create region with no name");

            if (source.Configs.Count == 0)
            {
                source.AddConfig(name);

                //                creatingNew = true;
                NeedsUpdate = true;
            }

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);
                NeedsUpdate = true;
                //                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                NeedsUpdate = true;
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.Prompt("Region UUID for region " + name, newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            region.RegionID = new UUID(regionUUID);

            region.RegionName = name;
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                NeedsUpdate = true;
                location = MainConsole.Instance.Prompt("Region Location for region " + name, "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new[] { ',' });

            region.RegionLocX = Convert.ToInt32(locationElements[0]) * Constants.RegionSize;
            region.RegionLocY = Convert.ToInt32(locationElements[1]) * Constants.RegionSize;

            int regionSizeX = config.GetInt("RegionSizeX", 0);
            if (regionSizeX == 0 || ((region.RegionSizeX % Constants.MinRegionSize) != 0))
            {
                NeedsUpdate = true;
                while (true)
                {
                    if (int.TryParse(MainConsole.Instance.Prompt("Region X Size for region " + name, "256"), out regionSizeX))
                        break;
                }
                config.Set("RegionSizeX", regionSizeX);
            }
            region.RegionSizeX = Convert.ToInt32(regionSizeX);

            int regionSizeY = config.GetInt("RegionSizeY", 0);
            if (regionSizeY == 0 || ((region.RegionSizeY % Constants.MinRegionSize) != 0))
            {
                NeedsUpdate = true;
                while(true)
                {
                    if(int.TryParse(MainConsole.Instance.Prompt("Region Y Size for region " + name, "256"), out regionSizeY))
                        break;
                }
                config.Set("RegionSizeY", regionSizeY);
            }
            region.RegionSizeY = regionSizeY;

            int regionSizeZ = config.GetInt("RegionSizeZ", 1024);
            //if (regionSizeZ == String.Empty)
            //{
            //    NeedsUpdate = true;
            //    regionSizeZ = MainConsole.Instance.CmdPrompt("Region Z Size for region " + name, "1024");
            //    config.Set("RegionSizeZ", regionSizeZ);
            //}
            region.RegionSizeZ = regionSizeZ;

            // Internal IP
            IPAddress address;

            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                NeedsUpdate = true;
                address = IPAddress.Parse(MainConsole.Instance.Prompt("Internal IP address for region " + name, "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                NeedsUpdate = true;
                port = Convert.ToInt32(MainConsole.Instance.Prompt("Internal port for region " + name, "9000"));
                config.Set("InternalPort", port);
            }
            region.UDPPorts.Add (port);
            region.InternalEndPoint = new IPEndPoint(address, port);

            // External IP
            //
            string externalName;
            if (config.Contains("ExternalHostName"))
            {
                //Let's know our external IP (by Enrico Nirvana)
                externalName = config.GetString("ExternalHostName", Aurora.Framework.Utilities.GetExternalIp());
            }
            else
            {
                NeedsUpdate = true;
                //Let's know our external IP (by Enrico Nirvana)
                externalName = MainConsole.Instance.Prompt("External host name for region " + name, Aurora.Framework.Utilities.GetExternalIp());
                config.Set("ExternalHostName", externalName);
                //ended here (by Enrico Nirvana)
            }

            region.RegionType = config.GetString("RegionType", region.RegionType);

            if (region.RegionType == String.Empty)
            {
                NeedsUpdate = true;
                region.RegionType = MainConsole.Instance.Prompt("Region Type for region " + name, "Mainland");
                config.Set("RegionType", region.RegionType);
            }

            region.AllowPhysicalPrims = config.GetBoolean("AllowPhysicalPrims", region.AllowPhysicalPrims);

            region.AllowScriptCrossing = config.GetBoolean("AllowScriptCrossing", region.AllowScriptCrossing);

            region.TrustBinariesFromForeignSims = config.GetBoolean("TrustBinariesFromForeignSims", region.TrustBinariesFromForeignSims);

            region.SeeIntoThisSimFromNeighbor = config.GetBoolean("SeeIntoThisSimFromNeighbor", region.SeeIntoThisSimFromNeighbor);

            region.ObjectCapacity = config.GetInt ("MaxPrims", region.ObjectCapacity);

            region.Startup = (StartupType)Enum.Parse(typeof(StartupType), config.GetString ("StartupType", region.Startup.ToString()));


            // Multi-tenancy
            //
            region.ScopeID = new UUID(config.GetString("ScopeID", region.ScopeID.ToString()));

            //Do this last so that we can save the password immediately if it doesn't exist
            UUID password = region.Password; //Save the pass as this TryParse will wipe it out
            if (!UUID.TryParse(config.GetString("NeighborPassword", ""), out region.Password))
            {
                region.Password = password;
                config.Set("NeighborPassword", password);
                region.WriteNiniConfig(source);
            }

            return NeedsUpdate;
        }