From 8e091f590375d2b63c100e45a187b6cbfa76e161 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Sep 2009 21:17:23 +0100 Subject: Add the Migration for the regions table --- OpenSim/Data/MySQL/MySQLRegionData.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLRegionData.cs') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index ced26a4..0d71c23 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -138,6 +138,8 @@ namespace OpenSim.Data.MySQL ret.RegionName = result["regionName"].ToString(); ret.posX = Convert.ToInt32(result["locX"]); ret.posY = Convert.ToInt32(result["locY"]); + ret.sizeX = Convert.ToInt32(result["sizeX"]); + ret.sizeY = Convert.ToInt32(result["sizeY"]); if (m_ColumnNames == null) { @@ -188,21 +190,21 @@ namespace OpenSim.Data.MySQL data.Data.Remove("posX"); if (data.Data.ContainsKey("posY")) data.Data.Remove("posY"); + if (data.Data.ContainsKey("sizeX")) + data.Data.Remove("sizeX"); + if (data.Data.ContainsKey("sizeY")) + data.Data.Remove("sizeY"); string[] fields = new List(data.Data.Keys).ToArray(); MySqlCommand cmd = new MySqlCommand(); - string update = "update `"+m_Realm+"` set "; - bool first = true; + string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; foreach (string field in fields) { - if (!first) - update += ", "; + update += ", "; update += "`" + field + "` = ?"+field; - first = false; - cmd.Parameters.AddWithValue("?"+field, data.Data[field]); } @@ -214,12 +216,16 @@ namespace OpenSim.Data.MySQL cmd.CommandText = update; cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); + cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); + cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); + cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); if (ExecuteNonQuery(cmd) < 1) { - string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `" + + string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `" + String.Join("`, `", fields) + - "`) values ( ?regionID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; + "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?" + String.Join(", ?", fields) + ")"; cmd.CommandText = insert; -- cgit v1.1