aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLRegionData.cs
diff options
context:
space:
mode:
authoronefang2019-05-19 21:24:15 +1000
committeronefang2019-05-19 21:24:15 +1000
commit5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch)
treea9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Data/MySQL/MySQLRegionData.cs
parentAdd a build script. (diff)
downloadopensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip
opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz
opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2
opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs78
1 files changed, 77 insertions, 1 deletions
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 2ad7590..46df421 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -60,6 +60,7 @@ namespace OpenSim.Data.MySQL
60 dbcon.Open(); 60 dbcon.Open();
61 Migration m = new Migration(dbcon, Assembly, "GridStore"); 61 Migration m = new Migration(dbcon, Assembly, "GridStore");
62 m.Update(); 62 m.Update();
63 dbcon.Close();
63 } 64 }
64 } 65 }
65 66
@@ -82,6 +83,7 @@ namespace OpenSim.Data.MySQL
82 83
83 public RegionData Get(int posX, int posY, UUID scopeID) 84 public RegionData Get(int posX, int posY, UUID scopeID)
84 { 85 {
86/* fixed size regions
85 string command = "select * from `"+m_Realm+"` where locX = ?posX and locY = ?posY"; 87 string command = "select * from `"+m_Realm+"` where locX = ?posX and locY = ?posY";
86 if (scopeID != UUID.Zero) 88 if (scopeID != UUID.Zero)
87 command += " and ScopeID = ?scopeID"; 89 command += " and ScopeID = ?scopeID";
@@ -98,6 +100,45 @@ namespace OpenSim.Data.MySQL
98 100
99 return ret[0]; 101 return ret[0];
100 } 102 }
103*/
104 // extend database search for maximum region size area
105 string command = "select * from `" + m_Realm + "` where locX between ?startX and ?endX and locY between ?startY and ?endY";
106 if (scopeID != UUID.Zero)
107 command += " and ScopeID = ?scopeID";
108
109 int startX = posX - (int)Constants.MaximumRegionSize;
110 int startY = posY - (int)Constants.MaximumRegionSize;
111 int endX = posX;
112 int endY = posY;
113
114 List<RegionData> ret;
115 using (MySqlCommand cmd = new MySqlCommand(command))
116 {
117 cmd.Parameters.AddWithValue("?startX", startX.ToString());
118 cmd.Parameters.AddWithValue("?startY", startY.ToString());
119 cmd.Parameters.AddWithValue("?endX", endX.ToString());
120 cmd.Parameters.AddWithValue("?endY", endY.ToString());
121 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
122
123 ret = RunCommand(cmd);
124 }
125
126 if (ret.Count == 0)
127 return null;
128
129 // find the first that contains pos
130 RegionData rg = null;
131 foreach (RegionData r in ret)
132 {
133 if (posX >= r.posX && posX < r.posX + r.sizeX
134 && posY >= r.posY && posY < r.posY + r.sizeY)
135 {
136 rg = r;
137 break;
138 }
139 }
140
141 return rg;
101 } 142 }
102 143
103 public RegionData Get(UUID regionID, UUID scopeID) 144 public RegionData Get(UUID regionID, UUID scopeID)
@@ -121,6 +162,7 @@ namespace OpenSim.Data.MySQL
121 162
122 public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) 163 public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID)
123 { 164 {
165/* fix size regions
124 string command = "select * from `"+m_Realm+"` where locX between ?startX and ?endX and locY between ?startY and ?endY"; 166 string command = "select * from `"+m_Realm+"` where locX between ?startX and ?endX and locY between ?startY and ?endY";
125 if (scopeID != UUID.Zero) 167 if (scopeID != UUID.Zero)
126 command += " and ScopeID = ?scopeID"; 168 command += " and ScopeID = ?scopeID";
@@ -135,6 +177,38 @@ namespace OpenSim.Data.MySQL
135 177
136 return RunCommand(cmd); 178 return RunCommand(cmd);
137 } 179 }
180 */
181 string command = "select * from `" + m_Realm + "` where locX between ?startX and ?endX and locY between ?startY and ?endY";
182 if (scopeID != UUID.Zero)
183 command += " and ScopeID = ?scopeID";
184
185 int qstartX = startX - (int)Constants.MaximumRegionSize;
186 int qstartY = startY - (int)Constants.MaximumRegionSize;
187
188 List<RegionData> dbret;
189 using (MySqlCommand cmd = new MySqlCommand(command))
190 {
191 cmd.Parameters.AddWithValue("?startX", qstartX.ToString());
192 cmd.Parameters.AddWithValue("?startY", qstartY.ToString());
193 cmd.Parameters.AddWithValue("?endX", endX.ToString());
194 cmd.Parameters.AddWithValue("?endY", endY.ToString());
195 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
196
197 dbret = RunCommand(cmd);
198 }
199
200 List<RegionData> ret = new List<RegionData>();
201
202 if (dbret.Count == 0)
203 return ret;
204
205 foreach (RegionData r in dbret)
206 {
207 if (r.posX + r.sizeX > startX && r.posX <= endX
208 && r.posY + r.sizeY > startY && r.posY <= endY)
209 ret.Add(r);
210 }
211 return ret;
138 } 212 }
139 213
140 public List<RegionData> RunCommand(MySqlCommand cmd) 214 public List<RegionData> RunCommand(MySqlCommand cmd)
@@ -187,6 +261,8 @@ namespace OpenSim.Data.MySQL
187 retList.Add(ret); 261 retList.Add(ret);
188 } 262 }
189 } 263 }
264 cmd.Connection = null;
265 dbcon.Close();
190 } 266 }
191 267
192 return retList; 268 return retList;
@@ -337,7 +413,7 @@ namespace OpenSim.Data.MySQL
337 using (MySqlCommand cmd = new MySqlCommand(command)) 413 using (MySqlCommand cmd = new MySqlCommand(command))
338 { 414 {
339 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); 415 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
340 416
341 return RunCommand(cmd); 417 return RunCommand(cmd);
342 } 418 }
343 } 419 }