From ae554a48d0cea61d05dc931c04f336d83de4834b Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 20 Aug 2010 08:36:23 +0100 Subject: Add some maptile options, change maptile generation from OpenSimBase to Scene to make it more configurable. --- OpenSim/Region/Application/OpenSimBase.cs | 8 ---- OpenSim/Region/Framework/Scenes/Scene.cs | 63 ++++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index eb18e83..b80d17d 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -347,14 +347,6 @@ namespace OpenSim // Prims have to be loaded after module configuration since some modules may be invoked during the load scene.LoadPrimsFromStorage(regionInfo.originRegionID); - // moved these here as the map texture has to be created after the modules are initialized - // and has to happen before the region is registered with the grid. - IWorldMapModule mapModule = scene.RequestModuleInterface(); - if (mapModule != null) - mapModule.GenerateMaptile(); - else - m_log.WarnFormat("[STARTUP]: No map module available to generate map tile"); - // TODO : Try setting resource for region xstats here on scene MainServer.Instance.AddStreamHandler(new Region.Framework.Scenes.RegionStatsHandler(regionInfo)); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 18705a8..2890ecd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -396,6 +396,9 @@ namespace OpenSim.Region.Framework.Scenes private double m_rootReprioritizationDistance = 10.0; private double m_childReprioritizationDistance = 20.0; + private Timer m_mapGenerationTimer = new Timer(); + bool m_generateMaptiles = false; + #endregion #region Properties @@ -646,6 +649,29 @@ namespace OpenSim.Region.Framework.Scenes } m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); + + m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); + if (m_generateMaptiles) + { + int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); + if (maptileRefresh != 0) + { + m_mapGenerationTimer.Interval = maptileRefresh * 1000; + m_mapGenerationTimer.Elapsed += RegenerateMaptile; + m_mapGenerationTimer.AutoReset = true; + m_mapGenerationTimer.Start(); + } + } + else + { + string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); + UUID tileID; + + if (UUID.TryParse(tile, out tileID)) + { + RegionInfo.RegionSettings.TerrainImageID = tileID; + } + } } catch { @@ -1662,16 +1688,21 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.SetScene(this); - // These two 'commands' *must be* next to each other or sim rebooting fails. - //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); - - GridRegion region = new GridRegion(RegionInfo); - string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); - if (error != String.Empty) + // If we generate maptiles internally at all, the maptile generator + // will register the region. If not, do it here + if (m_generateMaptiles) { - throw new Exception(error); + RegenerateMaptile(null, null); + } + else + { + GridRegion region = new GridRegion(RegionInfo); + string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); + if (error != String.Empty) + { + throw new Exception(error); + } } - } #endregion @@ -4878,5 +4909,19 @@ namespace OpenSim.Region.Framework.Scenes return offsets.ToArray(); } + + public void RegenerateMaptile(object sender, ElapsedEventArgs e) + { + IWorldMapModule mapModule = RequestModuleInterface(); + if (mapModule != null) + { + mapModule.GenerateMaptile(); + + string error = GridService.RegisterRegion(RegionInfo.ScopeID, new GridRegion(RegionInfo)); + + if (error != String.Empty) + throw new Exception(error); + } + } } -} \ No newline at end of file +} -- cgit v1.1