aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Null/NullRegionData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/Null/NullRegionData.cs')
-rw-r--r--OpenSim/Data/Null/NullRegionData.cs48
1 files changed, 38 insertions, 10 deletions
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs
index 2065355..53e5207 100644
--- a/OpenSim/Data/Null/NullRegionData.cs
+++ b/OpenSim/Data/Null/NullRegionData.cs
@@ -51,28 +51,56 @@ namespace OpenSim.Data.Null
51 //Console.WriteLine("[XXX] NullRegionData constructor"); 51 //Console.WriteLine("[XXX] NullRegionData constructor");
52 } 52 }
53 53
54 private delegate bool Matcher(string value);
55
54 public List<RegionData> Get(string regionName, UUID scopeID) 56 public List<RegionData> Get(string regionName, UUID scopeID)
55 { 57 {
56 if (Instance != this) 58 if (Instance != this)
57 return Instance.Get(regionName, scopeID); 59 return Instance.Get(regionName, scopeID);
58 60
59 List<RegionData> ret = new List<RegionData>(); 61 string cleanName = regionName.ToLower();
60 62
61 foreach (RegionData r in m_regionData.Values) 63 // Handle SQL wildcards
64 const string wildcard = "%";
65 bool wildcardPrefix = false;
66 bool wildcardSuffix = false;
67 if (cleanName.Equals(wildcard))
62 { 68 {
63 if (regionName.Contains("%")) 69 wildcardPrefix = wildcardSuffix = true;
70 cleanName = string.Empty;
71 }
72 else
73 {
74 if (cleanName.StartsWith(wildcard))
64 { 75 {
65 string cleanname = regionName.Replace("%", ""); 76 wildcardPrefix = true;
66 m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanname.ToLower(), r.RegionName.ToLower()); 77 cleanName = cleanName.Substring(1);
67 if (r.RegionName.ToLower().Contains(cleanname.ToLower()))
68 ret.Add(r);
69 } 78 }
70 else 79 if (regionName.EndsWith(wildcard))
71 { 80 {
72 if (r.RegionName.ToLower() == regionName.ToLower()) 81 wildcardSuffix = true;
73 ret.Add(r); 82 cleanName = cleanName.Remove(cleanName.Length - 1);
74 } 83 }
75 } 84 }
85 Matcher queryMatch;
86 if (wildcardPrefix && wildcardSuffix)
87 queryMatch = delegate(string s) { return s.Contains(cleanName); };
88 else if (wildcardSuffix)
89 queryMatch = delegate(string s) { return s.StartsWith(cleanName); };
90 else if (wildcardPrefix)
91 queryMatch = delegate(string s) { return s.EndsWith(cleanName); };
92 else
93 queryMatch = delegate(string s) { return s.Equals(cleanName); };
94
95 // Find region data
96 List<RegionData> ret = new List<RegionData>();
97
98 foreach (RegionData r in m_regionData.Values)
99 {
100 m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanName, r.RegionName.ToLower());
101 if (queryMatch(r.RegionName.ToLower()))
102 ret.Add(r);
103 }
76 104
77 if (ret.Count > 0) 105 if (ret.Count > 0)
78 return ret; 106 return ret;