From d8bab61af424d22c35519557f343145f3c685edc Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 8 Feb 2010 21:24:04 +0000 Subject: Convert NullRegionData to a singleton pattern, since that is required for a standalone --- OpenSim/Data/Null/NullRegionData.cs | 55 +++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index dc68edb..5b9898c 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs @@ -31,20 +31,31 @@ using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Data; +using System.Reflection; +using log4net; namespace OpenSim.Data.Null { public class NullRegionData : IRegionData { + private static NullRegionData Instance = null; + + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + Dictionary m_regionData = new Dictionary(); public NullRegionData(string connectionString, string realm) { + if (Instance == null) + Instance = this; //Console.WriteLine("[XXX] NullRegionData constructor"); } public List Get(string regionName, UUID scopeID) { + if (Instance != this) + return Instance.Get(regionName, scopeID); + List ret = new List(); foreach (RegionData r in m_regionData.Values) @@ -69,6 +80,9 @@ namespace OpenSim.Data.Null public RegionData Get(int posX, int posY, UUID scopeID) { + if (Instance != this) + return Instance.Get(posX, posY, scopeID); + List ret = new List(); foreach (RegionData r in m_regionData.Values) @@ -85,6 +99,9 @@ namespace OpenSim.Data.Null public RegionData Get(UUID regionID, UUID scopeID) { + if (Instance != this) + return Instance.Get(regionID, scopeID); + if (m_regionData.ContainsKey(regionID)) return m_regionData[regionID]; @@ -93,6 +110,9 @@ namespace OpenSim.Data.Null public List Get(int startX, int startY, int endX, int endY, UUID scopeID) { + if (Instance != this) + return Instance.Get(startX, startY, endX, endY, scopeID); + List ret = new List(); foreach (RegionData r in m_regionData.Values) @@ -106,6 +126,9 @@ namespace OpenSim.Data.Null public bool Store(RegionData data) { + if (Instance != this) + return Instance.Store(data); + m_regionData[data.RegionID] = data; return true; @@ -113,6 +136,9 @@ namespace OpenSim.Data.Null public bool SetDataItem(UUID regionID, string item, string value) { + if (Instance != this) + return Instance.SetDataItem(regionID, item, value); + if (!m_regionData.ContainsKey(regionID)) return false; @@ -123,6 +149,9 @@ namespace OpenSim.Data.Null public bool Delete(UUID regionID) { + if (Instance != this) + return Instance.Delete(regionID); + if (!m_regionData.ContainsKey(regionID)) return false; @@ -133,12 +162,34 @@ namespace OpenSim.Data.Null public List GetDefaultRegions(UUID scopeID) { - return new List(); + if (Instance != this) + return Instance.GetDefaultRegions(scopeID); + + List ret = new List(); + + foreach (RegionData r in m_regionData.Values) + { + if ((Convert.ToInt32(r.Data["flags"]) & 1) != 0) + ret.Add(r); + } + + return ret; } public List GetFallbackRegions(UUID scopeID, int x, int y) { - return new List(); + if (Instance != this) + return Instance.GetFallbackRegions(scopeID, x, y); + + List ret = new List(); + + foreach (RegionData r in m_regionData.Values) + { + if ((Convert.ToInt32(r.Data["flags"]) & 2) != 0) + ret.Add(r); + } + + return ret; } } } -- cgit v1.1