// File based loading
        //

        /// <summary>
        /// Initializes a new instance of a regions when loaded from a definition file"/> class.
        /// </summary>
        /// <param name="fileName">File name.</param>
        public void LoadRegionConfig(string fileName) 
        {
            RegionInfo ri = (RegionInfo)DeserializeObject(fileName);

            RegionID = ri.RegionID;
            RegionName = ri.RegionName;
            RegionPort = ri.RegionPort;
            RegionLocX = ri.RegionLocX;
            RegionLocY = ri.RegionLocY;
            RegionType = ri.RegionType;
            RegionSizeX = ri.RegionSizeX;
            RegionSizeY = ri.RegionSizeY;
            RegionSizeZ = ri.RegionSizeZ;
            ObjectCapacity = ri.ObjectCapacity;
            SeeIntoThisSimFromNeighbor = ri.SeeIntoThisSimFromNeighbor;
            InfiniteRegion = ri.InfiniteRegion;
            EstateSettings = ri.EstateSettings;
            RegionSettings = ri.RegionSettings;
            //GridSecureSessionID = ri.GridSecureSessionID;
            OpenRegionSettings = ri.OpenRegionSettings;
            EnvironmentSettings =  ri.EnvironmentSettings;
            RegionTerrain = ri.RegionTerrain;
            RegionArea = ri.RegionArea;

        }
        public void UnpackRegionInfoData(OSDMap args)
        {
            if (args.ContainsKey("region_id"))
                RegionID = args["region_id"].AsUUID();
            if (args.ContainsKey("region_name"))
                RegionName = args["region_name"].AsString();
            if (args.ContainsKey("http_port"))
                UInt32.TryParse(args["http_port"].AsString(), out m_httpPort);
            if (args.ContainsKey("region_xloc"))
            {
                int locx;
                Int32.TryParse(args["region_xloc"].AsString(), out locx);
                RegionLocX = locx;
            }
            if (args.ContainsKey("region_yloc"))
            {
                int locy;
                Int32.TryParse(args["region_yloc"].AsString(), out locy);
                RegionLocY = locy;
            }
            if (args.ContainsKey("region_type"))
                m_regionType = args["region_type"].AsString();

            if (args.ContainsKey("scope_id"))
                ScopeID = args["scope_id"].AsUUID();
            if (args.ContainsKey("all_scope_ids"))
                AllScopeIDs = ((OSDArray) args["all_scope_ids"]).ConvertAll<UUID>(o => o);

            if (args.ContainsKey("region_size_x"))
                RegionSizeX = args["region_size_x"].AsInteger();
            if (args.ContainsKey("region_size_y"))
                RegionSizeY = args["region_size_y"].AsInteger();
            if (args.ContainsKey("region_size_z"))
                RegionSizeZ = args["region_size_z"].AsInteger();

            if (args.ContainsKey("object_capacity"))
                m_objectCapacity = args["object_capacity"].AsInteger();
            if (args.ContainsKey("region_type"))
                RegionType = args["region_type"].AsString();
            if (args.ContainsKey("see_into_this_sim_from_neighbor"))
                SeeIntoThisSimFromNeighbor = args["see_into_this_sim_from_neighbor"].AsBoolean();
            if (args.ContainsKey("startupType"))
                Startup = (StartupType) args["startupType"].AsInteger();
            if (args.ContainsKey("InfiniteRegion"))
                InfiniteRegion = args["InfiniteRegion"].AsBoolean();
            if (args.ContainsKey("RegionSettings"))
            {
                RegionSettings = new RegionSettings();
                RegionSettings.FromOSD((OSDMap) args["RegionSettings"]);
            }
            if (args.ContainsKey("GridSecureSessionID"))
                GridSecureSessionID = args["GridSecureSessionID"];
            if (args.ContainsKey("OpenRegionSettings"))
            {
                OpenRegionSettings = new OpenRegionSettings();
                OpenRegionSettings.FromOSD((OSDMap) args["OpenRegionSettings"]);
            }
            else
                OpenRegionSettings = new OpenRegionSettings();
            if (args.ContainsKey("EnvironmentSettings"))
                EnvironmentSettings = args["EnvironmentSettings"];
        }
 public void AddRegion(IScene scene)
 {
     m_scene = scene;
     scene.EventManager.OnMakeRootAgent += OnNewClient;
     scene.EventManager.OnRegisterCaps += OnRegisterCaps;
     m_settings = scene.RegionInfo.OpenRegionSettings;
     scene.RegisterModuleInterface<IOpenRegionSettingsModule>(this);
     RegionInfo reg = m_scene.RegionInfo;
     ReadOpenRegionSettings(m_scene.Config.Configs["OpenRegionSettings"], ref reg);
     m_scene.RegionInfo = reg;
 }