aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLRegionData.cs
diff options
context:
space:
mode:
authorMelanie2009-10-02 08:23:38 +0100
committerMelanie2009-10-02 08:23:38 +0100
commit31d8cec0f8cd47ff445edc7771e5e73825a57927 (patch)
treea2d60604317739fa530502c40ffc71bab2a5c494 /OpenSim/Data/MySQL/MySQLRegionData.cs
parentRestore the missing image handling to the image manager. The missing (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-31d8cec0f8cd47ff445edc7771e5e73825a57927.zip
opensim-SC_OLD-31d8cec0f8cd47ff445edc7771e5e73825a57927.tar.gz
opensim-SC_OLD-31d8cec0f8cd47ff445edc7771e5e73825a57927.tar.bz2
opensim-SC_OLD-31d8cec0f8cd47ff445edc7771e5e73825a57927.tar.xz
Merge branch 'master' into diva-textures
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLRegionData.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs38
1 files changed, 23 insertions, 15 deletions
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index ced26a4..06ef624 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Data.MySQL
39 { 39 {
40 private string m_Realm; 40 private string m_Realm;
41 private List<string> m_ColumnNames = null; 41 private List<string> m_ColumnNames = null;
42 private int m_LastExpire = 0; 42// private int m_LastExpire = 0;
43 43
44 public MySqlRegionData(string connectionString, string realm) 44 public MySqlRegionData(string connectionString, string realm)
45 : base(connectionString) 45 : base(connectionString)
@@ -77,7 +77,7 @@ namespace OpenSim.Data.MySQL
77 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); 77 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
78 78
79 List<RegionData> ret = RunCommand(cmd); 79 List<RegionData> ret = RunCommand(cmd);
80 if (ret == null) 80 if (ret.Count == 0)
81 return null; 81 return null;
82 82
83 return ret[0]; 83 return ret[0];
@@ -95,7 +95,7 @@ namespace OpenSim.Data.MySQL
95 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); 95 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
96 96
97 List<RegionData> ret = RunCommand(cmd); 97 List<RegionData> ret = RunCommand(cmd);
98 if (ret == null) 98 if (ret.Count == 0)
99 return null; 99 return null;
100 100
101 return ret[0]; 101 return ret[0];
@@ -138,6 +138,8 @@ namespace OpenSim.Data.MySQL
138 ret.RegionName = result["regionName"].ToString(); 138 ret.RegionName = result["regionName"].ToString();
139 ret.posX = Convert.ToInt32(result["locX"]); 139 ret.posX = Convert.ToInt32(result["locX"]);
140 ret.posY = Convert.ToInt32(result["locY"]); 140 ret.posY = Convert.ToInt32(result["locY"]);
141 ret.sizeX = Convert.ToInt32(result["sizeX"]);
142 ret.sizeY = Convert.ToInt32(result["sizeY"]);
141 143
142 if (m_ColumnNames == null) 144 if (m_ColumnNames == null)
143 { 145 {
@@ -170,10 +172,7 @@ namespace OpenSim.Data.MySQL
170 result.Close(); 172 result.Close();
171 CloseReaderCommand(cmd); 173 CloseReaderCommand(cmd);
172 174
173 if (retList.Count > 0) 175 return retList;
174 return retList;
175
176 return null;
177 } 176 }
178 177
179 public bool Store(RegionData data) 178 public bool Store(RegionData data)
@@ -188,21 +187,25 @@ namespace OpenSim.Data.MySQL
188 data.Data.Remove("posX"); 187 data.Data.Remove("posX");
189 if (data.Data.ContainsKey("posY")) 188 if (data.Data.ContainsKey("posY"))
190 data.Data.Remove("posY"); 189 data.Data.Remove("posY");
190 if (data.Data.ContainsKey("sizeX"))
191 data.Data.Remove("sizeX");
192 if (data.Data.ContainsKey("sizeY"))
193 data.Data.Remove("sizeY");
194 if (data.Data.ContainsKey("locX"))
195 data.Data.Remove("locX");
196 if (data.Data.ContainsKey("locY"))
197 data.Data.Remove("locY");
191 198
192 string[] fields = new List<string>(data.Data.Keys).ToArray(); 199 string[] fields = new List<string>(data.Data.Keys).ToArray();
193 200
194 MySqlCommand cmd = new MySqlCommand(); 201 MySqlCommand cmd = new MySqlCommand();
195 202
196 string update = "update `"+m_Realm+"` set "; 203 string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY";
197 bool first = true;
198 foreach (string field in fields) 204 foreach (string field in fields)
199 { 205 {
200 if (!first) 206 update += ", ";
201 update += ", ";
202 update += "`" + field + "` = ?"+field; 207 update += "`" + field + "` = ?"+field;
203 208
204 first = false;
205
206 cmd.Parameters.AddWithValue("?"+field, data.Data[field]); 209 cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
207 } 210 }
208 211
@@ -213,13 +216,18 @@ namespace OpenSim.Data.MySQL
213 216
214 cmd.CommandText = update; 217 cmd.CommandText = update;
215 cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); 218 cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString());
219 cmd.Parameters.AddWithValue("?regionName", data.RegionName);
216 cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); 220 cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString());
221 cmd.Parameters.AddWithValue("?posX", data.posX.ToString());
222 cmd.Parameters.AddWithValue("?posY", data.posY.ToString());
223 cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString());
224 cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString());
217 225
218 if (ExecuteNonQuery(cmd) < 1) 226 if (ExecuteNonQuery(cmd) < 1)
219 { 227 {
220 string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `" + 228 string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" +
221 String.Join("`, `", fields) + 229 String.Join("`, `", fields) +
222 "`) values ( ?regionID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; 230 "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")";
223 231
224 cmd.CommandText = insert; 232 cmd.CommandText = insert;
225 233