diff options
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLRegionData.cs | 28 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/Resources/004_GridStore.sql | 6 |
2 files changed, 26 insertions, 8 deletions
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index e8cab4d..64ac83f 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -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 | { |
@@ -179,21 +181,27 @@ namespace OpenSim.Data.MySQL | |||
179 | data.Data.Remove("uuid"); | 181 | data.Data.Remove("uuid"); |
180 | if (data.Data.ContainsKey("ScopeID")) | 182 | if (data.Data.ContainsKey("ScopeID")) |
181 | data.Data.Remove("ScopeID"); | 183 | data.Data.Remove("ScopeID"); |
184 | if (data.Data.ContainsKey("regionName")) | ||
185 | data.Data.Remove("regionName"); | ||
186 | if (data.Data.ContainsKey("posX")) | ||
187 | data.Data.Remove("posX"); | ||
188 | if (data.Data.ContainsKey("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"); | ||
182 | 194 | ||
183 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | 195 | string[] fields = new List<string>(data.Data.Keys).ToArray(); |
184 | 196 | ||
185 | MySqlCommand cmd = new MySqlCommand(); | 197 | MySqlCommand cmd = new MySqlCommand(); |
186 | 198 | ||
187 | string update = "update `"+m_Realm+"` set "; | 199 | string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; |
188 | bool first = true; | ||
189 | foreach (string field in fields) | 200 | foreach (string field in fields) |
190 | { | 201 | { |
191 | if (!first) | 202 | update += ", "; |
192 | update += ", "; | ||
193 | update += "`" + field + "` = ?"+field; | 203 | update += "`" + field + "` = ?"+field; |
194 | 204 | ||
195 | first = false; | ||
196 | |||
197 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); | 205 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); |
198 | } | 206 | } |
199 | 207 | ||
@@ -205,12 +213,16 @@ namespace OpenSim.Data.MySQL | |||
205 | cmd.CommandText = update; | 213 | cmd.CommandText = update; |
206 | cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); | 214 | cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); |
207 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); | 215 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); |
216 | cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); | ||
217 | cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); | ||
218 | cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); | ||
219 | cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); | ||
208 | 220 | ||
209 | if (ExecuteNonQuery(cmd) < 1) | 221 | if (ExecuteNonQuery(cmd) < 1) |
210 | { | 222 | { |
211 | string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `" + | 223 | string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `" + |
212 | String.Join("`, `", fields) + | 224 | String.Join("`, `", fields) + |
213 | "`) values ( ?regionID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; | 225 | "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?" + String.Join(", ?", fields) + ")"; |
214 | 226 | ||
215 | cmd.CommandText = insert; | 227 | cmd.CommandText = insert; |
216 | 228 | ||
diff --git a/OpenSim/Data/MySQL/Resources/004_GridStore.sql b/OpenSim/Data/MySQL/Resources/004_GridStore.sql new file mode 100644 index 0000000..2238a88 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/004_GridStore.sql | |||
@@ -0,0 +1,6 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | ALTER TABLE regions add column sizeX integer not null default 0; | ||
4 | ALTER TABLE regions add column sizeY integer not null default 0; | ||
5 | |||
6 | COMMIT; | ||