diff options
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLRegionData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLRegionData.cs | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 2ad7590..3dc049b 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -82,6 +82,7 @@ namespace OpenSim.Data.MySQL | |||
82 | 82 | ||
83 | public RegionData Get(int posX, int posY, UUID scopeID) | 83 | public RegionData Get(int posX, int posY, UUID scopeID) |
84 | { | 84 | { |
85 | /* fixed size regions | ||
85 | string command = "select * from `"+m_Realm+"` where locX = ?posX and locY = ?posY"; | 86 | string command = "select * from `"+m_Realm+"` where locX = ?posX and locY = ?posY"; |
86 | if (scopeID != UUID.Zero) | 87 | if (scopeID != UUID.Zero) |
87 | command += " and ScopeID = ?scopeID"; | 88 | command += " and ScopeID = ?scopeID"; |
@@ -98,6 +99,45 @@ namespace OpenSim.Data.MySQL | |||
98 | 99 | ||
99 | return ret[0]; | 100 | return ret[0]; |
100 | } | 101 | } |
102 | */ | ||
103 | // extend database search for maximum region size area | ||
104 | string command = "select * from `" + m_Realm + "` where locX between ?startX and ?endX and locY between ?startY and ?endY"; | ||
105 | if (scopeID != UUID.Zero) | ||
106 | command += " and ScopeID = ?scopeID"; | ||
107 | |||
108 | int startX = posX - (int)Constants.MaximumRegionSize; | ||
109 | int startY = posY - (int)Constants.MaximumRegionSize; | ||
110 | int endX = posX; | ||
111 | int endY = posY; | ||
112 | |||
113 | List<RegionData> ret; | ||
114 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
115 | { | ||
116 | cmd.Parameters.AddWithValue("?startX", startX.ToString()); | ||
117 | cmd.Parameters.AddWithValue("?startY", startY.ToString()); | ||
118 | cmd.Parameters.AddWithValue("?endX", endX.ToString()); | ||
119 | cmd.Parameters.AddWithValue("?endY", endY.ToString()); | ||
120 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
121 | |||
122 | ret = RunCommand(cmd); | ||
123 | } | ||
124 | |||
125 | if (ret.Count == 0) | ||
126 | return null; | ||
127 | |||
128 | // find the first that contains pos | ||
129 | RegionData rg = null; | ||
130 | foreach (RegionData r in ret) | ||
131 | { | ||
132 | if (posX >= r.posX && posX < r.posX + r.sizeX | ||
133 | && posY >= r.posY && posY < r.posY + r.sizeY) | ||
134 | { | ||
135 | rg = r; | ||
136 | break; | ||
137 | } | ||
138 | } | ||
139 | |||
140 | return rg; | ||
101 | } | 141 | } |
102 | 142 | ||
103 | public RegionData Get(UUID regionID, UUID scopeID) | 143 | public RegionData Get(UUID regionID, UUID scopeID) |
@@ -121,6 +161,7 @@ namespace OpenSim.Data.MySQL | |||
121 | 161 | ||
122 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) | 162 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) |
123 | { | 163 | { |
164 | /* fix size regions | ||
124 | string command = "select * from `"+m_Realm+"` where locX between ?startX and ?endX and locY between ?startY and ?endY"; | 165 | string command = "select * from `"+m_Realm+"` where locX between ?startX and ?endX and locY between ?startY and ?endY"; |
125 | if (scopeID != UUID.Zero) | 166 | if (scopeID != UUID.Zero) |
126 | command += " and ScopeID = ?scopeID"; | 167 | command += " and ScopeID = ?scopeID"; |
@@ -135,6 +176,38 @@ namespace OpenSim.Data.MySQL | |||
135 | 176 | ||
136 | return RunCommand(cmd); | 177 | return RunCommand(cmd); |
137 | } | 178 | } |
179 | */ | ||
180 | string command = "select * from `" + m_Realm + "` where locX between ?startX and ?endX and locY between ?startY and ?endY"; | ||
181 | if (scopeID != UUID.Zero) | ||
182 | command += " and ScopeID = ?scopeID"; | ||
183 | |||
184 | int qstartX = startX - (int)Constants.MaximumRegionSize; | ||
185 | int qstartY = startY - (int)Constants.MaximumRegionSize; | ||
186 | |||
187 | List<RegionData> dbret; | ||
188 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
189 | { | ||
190 | cmd.Parameters.AddWithValue("?startX", qstartX.ToString()); | ||
191 | cmd.Parameters.AddWithValue("?startY", qstartY.ToString()); | ||
192 | cmd.Parameters.AddWithValue("?endX", endX.ToString()); | ||
193 | cmd.Parameters.AddWithValue("?endY", endY.ToString()); | ||
194 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
195 | |||
196 | dbret = RunCommand(cmd); | ||
197 | } | ||
198 | |||
199 | List<RegionData> ret = new List<RegionData>(); | ||
200 | |||
201 | if (dbret.Count == 0) | ||
202 | return ret; | ||
203 | |||
204 | foreach (RegionData r in dbret) | ||
205 | { | ||
206 | if (r.posX + r.sizeX > startX && r.posX <= endX | ||
207 | && r.posY + r.sizeX > startY && r.posY <= endY) | ||
208 | ret.Add(r); | ||
209 | } | ||
210 | return ret; | ||
138 | } | 211 | } |
139 | 212 | ||
140 | public List<RegionData> RunCommand(MySqlCommand cmd) | 213 | public List<RegionData> RunCommand(MySqlCommand cmd) |