From 5759313f7f3ff121d20e5eb44013e2bbb4bc2eee Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 19 May 2012 04:56:47 +0100 Subject: Add size of region to OAR control file. Megaregions (sw root OARs when saved) will have a size larger than 256x256 Not yet read. Do not rely on this information yet, it may change. --- .../Archiver/ArchiveWriteRequestPreparation.cs | 38 ++++++++++++++-------- .../Framework/Interfaces/IRegionCombinerModule.cs | 16 ++++++++- .../RegionCombinerModule/RegionCombinerModule.cs | 19 +++++++++-- 3 files changed, 56 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index e54774b..504f09b 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -391,36 +391,46 @@ namespace OpenSim.Region.CoreModules.World.Archiver xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); xtw.WriteElementString("id", UUID.Random().ToString()); xtw.WriteEndElement(); - - xtw.WriteElementString("assets_included", SaveAssets.ToString()); - + + xtw.WriteStartElement("region_info"); + bool isMegaregion; + Vector2 size; + IRegionCombinerModule rcMod = null; // FIXME: This is only here for regression test purposes since they do not supply a module. Need to fix // this, possibly by doing control file creation somewhere else. - if (m_module != null && m_module.RegionCombinerModule != null) - { - IRegionCombinerModule mod = m_module.RegionCombinerModule; - isMegaregion = mod.IsRootForMegaregion(m_scene.RegionInfo.RegionID); - } + if (m_module != null) + rcMod = m_module.RegionCombinerModule; + + if (rcMod != null) + isMegaregion = rcMod.IsRootForMegaregion(m_scene.RegionInfo.RegionID); else - { isMegaregion = false; - } - + + if (isMegaregion) + size = rcMod.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); + else + size = new Vector2((float)Constants.RegionSize, (float)Constants.RegionSize); + xtw.WriteElementString("is_megaregion", isMegaregion.ToString()); + xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y)); + + xtw.WriteEndElement(); + xtw.WriteElementString("assets_included", SaveAssets.ToString()); + xtw.WriteEndElement(); xtw.Flush(); - xtw.Close(); } s = sw.ToString(); } -// Console.WriteLine( -// "[ARCHIVE WRITE REQUEST PREPARATION]: Control file for {0} is: {1}", m_scene.RegionInfo.RegionName, s); + if (m_scene != null) + Console.WriteLine( + "[ARCHIVE WRITE REQUEST PREPARATION]: Control file for {0} is: {1}", m_scene.RegionInfo.RegionName, s); return s; } diff --git a/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs index ca4ed5c..e03ac5a 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs @@ -40,6 +40,20 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Does the given id belong to the root region of a megaregion? /// - bool IsRootForMegaregion(UUID sceneId); + bool IsRootForMegaregion(UUID regionId); + + /// + /// Gets the size of megaregion. + /// + /// + /// Returns size in meters. + /// Do not rely on this method remaining the same - this area is actively under development. + /// + /// + /// The id of the root region for a megaregion. + /// This may change in the future to allow any region id that makes up a megaregion. + /// Currently, will throw an exception if this does not match a root region. + /// + Vector2 GetSizeOfMegaregion(UUID regionId); } } \ No newline at end of file diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 81ed339..98becce 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -113,10 +113,25 @@ namespace OpenSim.Region.RegionCombinerModule } } - public bool IsRootForMegaregion(UUID sceneId) + public bool IsRootForMegaregion(UUID regionId) { lock (m_regions) - return m_regions.ContainsKey(sceneId); + return m_regions.ContainsKey(regionId); + } + + public Vector2 GetSizeOfMegaregion(UUID regionId) + { + lock (m_regions) + { + if (m_regions.ContainsKey(regionId)) + { + RegionConnections rootConn = m_regions[regionId]; + + return new Vector2((float)rootConn.XEnd, (float)rootConn.YEnd); + } + } + + throw new Exception(string.Format("Region with id {0} not found", regionId)); } private void NewPresence(ScenePresence presence) -- cgit v1.1