aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
diff options
context:
space:
mode:
authorUbitUmarov2015-09-01 14:54:35 +0100
committerUbitUmarov2015-09-01 14:54:35 +0100
commit371c9dd2af01a2e7422ec901ee1f80757284a78c (patch)
tree058d2a513cacb12efcce0c0df0ae14ad135dbfe2 /OpenSim/Data/MySQL
parentremove lixo (diff)
parentdont change camera on crossings (diff)
downloadopensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.zip
opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.gz
opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.bz2
opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.xz
bad merge?
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r--OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs41
-rw-r--r--OpenSim/Data/MySQL/MySQLFramework.cs21
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs7
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs73
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs306
-rw-r--r--OpenSim/Data/MySQL/MySQLUserAccountData.cs46
-rw-r--r--OpenSim/Data/MySQL/MySQLUserProfilesData.cs33
-rw-r--r--OpenSim/Data/MySQL/MySQLXAssetData.cs2
-rw-r--r--OpenSim/Data/MySQL/Resources/RegionStore.migrations5
-rw-r--r--OpenSim/Data/MySQL/Resources/UserProfiles.migrations3
11 files changed, 432 insertions, 107 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs
index ed0ab98..17f1374 100644
--- a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs
+++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 5d8da17..cb5a38e 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -154,7 +154,7 @@ namespace OpenSim.Data.MySQL
154 /// </summary> 154 /// </summary>
155 /// <param name="asset">Asset UUID to create</param> 155 /// <param name="asset">Asset UUID to create</param>
156 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> 156 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
157 override public void StoreAsset(AssetBase asset) 157 override public bool StoreAsset(AssetBase asset)
158 { 158 {
159 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 159 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
160 { 160 {
@@ -203,6 +203,43 @@ namespace OpenSim.Data.MySQL
203 cmd.Parameters.AddWithValue("?data", asset.Data); 203 cmd.Parameters.AddWithValue("?data", asset.Data);
204 cmd.ExecuteNonQuery(); 204 cmd.ExecuteNonQuery();
205 } 205 }
206
207 string assetDescription = asset.Description;
208 if (asset.Description.Length > 64)
209 {
210 assetDescription = asset.Description.Substring(0, 64);
211 m_log.WarnFormat(
212 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
213 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
214 }
215
216 try
217 {
218 using (cmd)
219 {
220 // create unix epoch time
221 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
222 cmd.Parameters.AddWithValue("?id", asset.ID);
223 cmd.Parameters.AddWithValue("?name", assetName);
224 cmd.Parameters.AddWithValue("?description", assetDescription);
225 cmd.Parameters.AddWithValue("?assetType", asset.Type);
226 cmd.Parameters.AddWithValue("?local", asset.Local);
227 cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
228 cmd.Parameters.AddWithValue("?create_time", now);
229 cmd.Parameters.AddWithValue("?access_time", now);
230 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
231 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
232 cmd.Parameters.AddWithValue("?data", asset.Data);
233 cmd.ExecuteNonQuery();
234 return true;
235 }
236 }
237 catch (Exception e)
238 {
239 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
240 asset.FullID, asset.Name, e.Message);
241 return false;
242 }
206 } 243 }
207 catch (Exception e) 244 catch (Exception e)
208 { 245 {
@@ -364,4 +401,4 @@ namespace OpenSim.Data.MySQL
364 401
365 #endregion 402 #endregion
366 } 403 }
367} \ No newline at end of file 404}
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs
index 5820a90..a522912 100644
--- a/OpenSim/Data/MySQL/MySQLFramework.cs
+++ b/OpenSim/Data/MySQL/MySQLFramework.cs
@@ -45,14 +45,21 @@ namespace OpenSim.Data.MySQL
45 System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 45 System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 protected string m_connectionString; 47 protected string m_connectionString;
48 protected object m_dbLock = new object();
48 49
49 protected MySqlFramework(string connectionString) 50 protected MySqlFramework(string connectionString)
50 { 51 {
51 m_connectionString = connectionString; 52 m_connectionString = connectionString;
52 } 53 }
53 54
55 //////////////////////////////////////////////////////////////
56 //
57 // All non queries are funneled through one connection
58 // to increase performance a little
59 //
54 protected int ExecuteNonQuery(MySqlCommand cmd) 60 protected int ExecuteNonQuery(MySqlCommand cmd)
55 { 61 {
62 lock (m_dbLock)
56 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 63 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
57 { 64 {
58 dbcon.Open(); 65 dbcon.Open();
@@ -60,7 +67,19 @@ namespace OpenSim.Data.MySQL
60 67
61 try 68 try
62 { 69 {
63 return cmd.ExecuteNonQuery(); 70 dbcon.Open();
71 cmd.Connection = dbcon;
72
73 try
74 {
75 return cmd.ExecuteNonQuery();
76 }
77 catch (Exception e)
78 {
79 m_log.Error(e.Message, e);
80 m_log.Error(Environment.StackTrace.ToString());
81 return 0;
82 }
64 } 83 }
65 catch (Exception e) 84 catch (Exception e)
66 { 85 {
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index 35fa89f..dc657c8 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -175,6 +175,11 @@ namespace OpenSim.Data.MySQL
175 int v = Convert.ToInt32(reader[name]); 175 int v = Convert.ToInt32(reader[name]);
176 m_Fields[name].SetValue(row, v); 176 m_Fields[name].SetValue(row, v);
177 } 177 }
178 else if (m_Fields[name].FieldType == typeof(uint))
179 {
180 uint v = Convert.ToUInt32(reader[name]);
181 m_Fields[name].SetValue(row, v);
182 }
178 else 183 else
179 { 184 {
180 m_Fields[name].SetValue(row, reader[name]); 185 m_Fields[name].SetValue(row, reader[name]);
@@ -362,4 +367,4 @@ namespace OpenSim.Data.MySQL
362 } 367 }
363 368
364 } 369 }
365} \ No newline at end of file 370}
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)
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index bb0ab75..81b5ec4 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -76,7 +76,7 @@ namespace OpenSim.Data.MySQL
76 Initialise(connectionString); 76 Initialise(connectionString);
77 } 77 }
78 78
79 public void Initialise(string connectionString) 79 public virtual void Initialise(string connectionString)
80 { 80 {
81 m_connectionString = connectionString; 81 m_connectionString = connectionString;
82 82
@@ -123,7 +123,7 @@ namespace OpenSim.Data.MySQL
123 123
124 public void Dispose() {} 124 public void Dispose() {}
125 125
126 public void StoreObject(SceneObjectGroup obj, UUID regionUUID) 126 public virtual void StoreObject(SceneObjectGroup obj, UUID regionUUID)
127 { 127 {
128 uint flags = obj.RootPart.GetEffectiveObjectFlags(); 128 uint flags = obj.RootPart.GetEffectiveObjectFlags();
129 129
@@ -183,10 +183,11 @@ namespace OpenSim.Data.MySQL
183 "ParticleSystem, ClickAction, Material, " + 183 "ParticleSystem, ClickAction, Material, " +
184 "CollisionSound, CollisionSoundVolume, " + 184 "CollisionSound, CollisionSoundVolume, " +
185 "PassTouches, " + 185 "PassTouches, " +
186 "LinkNumber, MediaURL, AttachedPosX, " + 186 "PassCollisions, " +
187 "AttachedPosY, AttachedPosZ, KeyframeMotion, " + 187 "LinkNumber, MediaURL, KeyframeMotion, AttachedPosX, " +
188 "AttachedPosY, AttachedPosZ, " +
188 "PhysicsShapeType, Density, GravityModifier, " + 189 "PhysicsShapeType, Density, GravityModifier, " +
189 "Friction, Restitution, DynAttrs " + 190 "Friction, Restitution, Vehicle, DynAttrs " +
190 ") values (" + "?UUID, " + 191 ") values (" + "?UUID, " +
191 "?CreationDate, ?Name, ?Text, " + 192 "?CreationDate, ?Name, ?Text, " +
192 "?Description, ?SitName, ?TouchName, " + 193 "?Description, ?SitName, ?TouchName, " +
@@ -218,11 +219,11 @@ namespace OpenSim.Data.MySQL
218 "?SaleType, ?ColorR, ?ColorG, " + 219 "?SaleType, ?ColorR, ?ColorG, " +
219 "?ColorB, ?ColorA, ?ParticleSystem, " + 220 "?ColorB, ?ColorA, ?ParticleSystem, " +
220 "?ClickAction, ?Material, ?CollisionSound, " + 221 "?ClickAction, ?Material, ?CollisionSound, " +
221 "?CollisionSoundVolume, ?PassTouches, " + 222 "?CollisionSoundVolume, ?PassTouches, ?PassCollisions, " +
222 "?LinkNumber, ?MediaURL, ?AttachedPosX, " + 223 "?LinkNumber, ?MediaURL, ?KeyframeMotion, ?AttachedPosX, " +
223 "?AttachedPosY, ?AttachedPosZ, ?KeyframeMotion, " + 224 "?AttachedPosY, ?AttachedPosZ, " +
224 "?PhysicsShapeType, ?Density, ?GravityModifier, " + 225 "?PhysicsShapeType, ?Density, ?GravityModifier, " +
225 "?Friction, ?Restitution, ?DynAttrs)"; 226 "?Friction, ?Restitution, ?Vehicle, ?DynAttrs)";
226 227
227 FillPrimCommand(cmd, prim, obj.UUID, regionUUID); 228 FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
228 229
@@ -262,7 +263,7 @@ namespace OpenSim.Data.MySQL
262 } 263 }
263 } 264 }
264 265
265 public void RemoveObject(UUID obj, UUID regionUUID) 266 public virtual void RemoveObject(UUID obj, UUID regionUUID)
266 { 267 {
267// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID); 268// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID);
268 269
@@ -317,7 +318,8 @@ namespace OpenSim.Data.MySQL
317 /// <param name="uuid">the Item UUID</param> 318 /// <param name="uuid">the Item UUID</param>
318 private void RemoveItems(UUID uuid) 319 private void RemoveItems(UUID uuid)
319 { 320 {
320 lock (m_dbLock) 321 // locked by caller
322// lock (m_dbLock)
321 { 323 {
322 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 324 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
323 { 325 {
@@ -411,7 +413,7 @@ namespace OpenSim.Data.MySQL
411 } 413 }
412 } 414 }
413 415
414 public List<SceneObjectGroup> LoadObjects(UUID regionID) 416 public virtual List<SceneObjectGroup> LoadObjects(UUID regionID)
415 { 417 {
416 const int ROWS_PER_QUERY = 5000; 418 const int ROWS_PER_QUERY = 5000;
417 419
@@ -590,40 +592,53 @@ namespace OpenSim.Data.MySQL
590 592
591 public void StoreTerrain(TerrainData terrData, UUID regionID) 593 public void StoreTerrain(TerrainData terrData, UUID regionID)
592 { 594 {
593 lock (m_dbLock) 595 Util.FireAndForget(delegate(object x)
594 { 596 {
595 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 597 m_log.Info("[REGION DB]: Storing terrain");
596 {
597 dbcon.Open();
598 598
599 using (MySqlCommand cmd = dbcon.CreateCommand()) 599 lock (m_dbLock)
600 {
601 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
600 { 602 {
601 cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; 603 dbcon.Open();
602 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
603
604 ExecuteNonQuery(cmd);
605 604
606 int terrainDBRevision; 605 using (MySqlCommand cmd = dbcon.CreateCommand())
607 Array terrainDBblob; 606 {
608 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); 607 cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID";
608 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
609 609
610 m_log.InfoFormat("{0} Storing terrain. X={1}, Y={2}, rev={3}", 610 using (MySqlCommand cmd2 = dbcon.CreateCommand())
611 LogHeader, terrData.SizeX, terrData.SizeY, terrainDBRevision); 611 {
612 try
613 {
614 cmd2.CommandText = "insert into terrain (RegionUUID, " +
615 "Revision, Heightfield) values (?RegionUUID, " +
616 "?Revision, ?Heightfield)";
612 617
613 cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)" 618 int terrainDBRevision;
614 + "values (?RegionUUID, ?Revision, ?Heightfield)"; 619 Array terrainDBblob;
620 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
615 621
616 cmd.Parameters.AddWithValue("Revision", terrainDBRevision); 622 cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
617 cmd.Parameters.AddWithValue("Heightfield", terrainDBblob); 623 cmd2.Parameters.AddWithValue("Revision", terrainDBRevision);
624 cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob);
618 625
619 ExecuteNonQuery(cmd); 626 ExecuteNonQuery(cmd);
627 ExecuteNonQuery(cmd2);
628 }
629 catch (Exception e)
630 {
631 m_log.ErrorFormat(e.ToString());
632 }
633 }
634 }
620 } 635 }
621 } 636 }
622 } 637 });
623 } 638 }
624 639
625 // Legacy region loading 640 // Legacy region loading
626 public double[,] LoadTerrain(UUID regionID) 641 public virtual double[,] LoadTerrain(UUID regionID)
627 { 642 {
628 double[,] ret = null; 643 double[,] ret = null;
629 TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); 644 TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
@@ -655,8 +670,11 @@ namespace OpenSim.Data.MySQL
655 while (reader.Read()) 670 while (reader.Read())
656 { 671 {
657 int rev = Convert.ToInt32(reader["Revision"]); 672 int rev = Convert.ToInt32(reader["Revision"]);
658 byte[] blob = (byte[])reader["Heightfield"]; 673 if ((reader["Heightfield"] != DBNull.Value))
659 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); 674 {
675 byte[] blob = (byte[])reader["Heightfield"];
676 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
677 }
660 } 678 }
661 } 679 }
662 } 680 }
@@ -666,7 +684,7 @@ namespace OpenSim.Data.MySQL
666 return terrData; 684 return terrData;
667 } 685 }
668 686
669 public void RemoveLandObject(UUID globalID) 687 public virtual void RemoveLandObject(UUID globalID)
670 { 688 {
671 lock (m_dbLock) 689 lock (m_dbLock)
672 { 690 {
@@ -685,7 +703,7 @@ namespace OpenSim.Data.MySQL
685 } 703 }
686 } 704 }
687 705
688 public void StoreLandObject(ILandObject parcel) 706 public virtual void StoreLandObject(ILandObject parcel)
689 { 707 {
690 lock (m_dbLock) 708 lock (m_dbLock)
691 { 709 {
@@ -705,7 +723,8 @@ namespace OpenSim.Data.MySQL
705 "UserLocationX, UserLocationY, UserLocationZ, " + 723 "UserLocationX, UserLocationY, UserLocationZ, " +
706 "UserLookAtX, UserLookAtY, UserLookAtZ, " + 724 "UserLookAtX, UserLookAtY, UserLookAtZ, " +
707 "AuthbuyerID, OtherCleanTime, Dwell, MediaType, MediaDescription, " + 725 "AuthbuyerID, OtherCleanTime, Dwell, MediaType, MediaDescription, " +
708 "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + 726 "MediaSize, MediaLoop, ObscureMusic, ObscureMedia, " +
727 "SeeAVs, AnyAVSounds, GroupAVSounds) values (" +
709 "?UUID, ?RegionUUID, " + 728 "?UUID, ?RegionUUID, " +
710 "?LocalLandID, ?Bitmap, ?Name, ?Description, " + 729 "?LocalLandID, ?Bitmap, ?Name, ?Description, " +
711 "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + 730 "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " +
@@ -716,7 +735,8 @@ namespace OpenSim.Data.MySQL
716 "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + 735 "?UserLocationX, ?UserLocationY, ?UserLocationZ, " +
717 "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + 736 "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " +
718 "?AuthbuyerID, ?OtherCleanTime, ?Dwell, ?MediaType, ?MediaDescription, "+ 737 "?AuthbuyerID, ?OtherCleanTime, ?Dwell, ?MediaType, ?MediaDescription, "+
719 "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; 738 "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia, " +
739 "?SeeAVs, ?AnyAVSounds, ?GroupAVSounds)";
720 740
721 FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); 741 FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID);
722 742
@@ -742,7 +762,7 @@ namespace OpenSim.Data.MySQL
742 } 762 }
743 } 763 }
744 764
745 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) 765 public virtual RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
746 { 766 {
747 RegionLightShareData nWP = new RegionLightShareData(); 767 RegionLightShareData nWP = new RegionLightShareData();
748 nWP.OnSave += StoreRegionWindlightSettings; 768 nWP.OnSave += StoreRegionWindlightSettings;
@@ -840,7 +860,7 @@ namespace OpenSim.Data.MySQL
840 return nWP; 860 return nWP;
841 } 861 }
842 862
843 public RegionSettings LoadRegionSettings(UUID regionUUID) 863 public virtual RegionSettings LoadRegionSettings(UUID regionUUID)
844 { 864 {
845 RegionSettings rs = null; 865 RegionSettings rs = null;
846 866
@@ -880,7 +900,7 @@ namespace OpenSim.Data.MySQL
880 return rs; 900 return rs;
881 } 901 }
882 902
883 public void StoreRegionWindlightSettings(RegionLightShareData wl) 903 public virtual void StoreRegionWindlightSettings(RegionLightShareData wl)
884 { 904 {
885 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 905 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
886 { 906 {
@@ -983,7 +1003,7 @@ namespace OpenSim.Data.MySQL
983 } 1003 }
984 } 1004 }
985 1005
986 public void RemoveRegionWindlightSettings(UUID regionID) 1006 public virtual void RemoveRegionWindlightSettings(UUID regionID)
987 { 1007 {
988 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 1008 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
989 { 1009 {
@@ -1060,7 +1080,7 @@ namespace OpenSim.Data.MySQL
1060 } 1080 }
1061 #endregion 1081 #endregion
1062 1082
1063 public void StoreRegionSettings(RegionSettings rs) 1083 public virtual void StoreRegionSettings(RegionSettings rs)
1064 { 1084 {
1065 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 1085 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
1066 { 1086 {
@@ -1105,7 +1125,44 @@ namespace OpenSim.Data.MySQL
1105 "?TerrainImageID, " + 1125 "?TerrainImageID, " +
1106 "?TelehubObject, ?ParcelImageID)"; 1126 "?TelehubObject, ?ParcelImageID)";
1107 1127
1108 FillRegionSettingsCommand(cmd, rs); 1128 using (MySqlCommand cmd = dbcon.CreateCommand())
1129 {
1130 cmd.CommandText = "replace into regionsettings (regionUUID, " +
1131 "block_terraform, block_fly, allow_damage, " +
1132 "restrict_pushing, allow_land_resell, " +
1133 "allow_land_join_divide, block_show_in_search, " +
1134 "agent_limit, object_bonus, maturity, " +
1135 "disable_scripts, disable_collisions, " +
1136 "disable_physics, terrain_texture_1, " +
1137 "terrain_texture_2, terrain_texture_3, " +
1138 "terrain_texture_4, elevation_1_nw, " +
1139 "elevation_2_nw, elevation_1_ne, " +
1140 "elevation_2_ne, elevation_1_se, " +
1141 "elevation_2_se, elevation_1_sw, " +
1142 "elevation_2_sw, water_height, " +
1143 "terrain_raise_limit, terrain_lower_limit, " +
1144 "use_estate_sun, fixed_sun, sun_position, " +
1145 "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " +
1146 "sunvectorz, loaded_creation_datetime, " +
1147 "loaded_creation_id, map_tile_ID, block_search, casino, " +
1148 "TelehubObject, parcel_tile_ID) " +
1149 "values (?RegionUUID, ?BlockTerraform, " +
1150 "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
1151 "?AllowLandResell, ?AllowLandJoinDivide, " +
1152 "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " +
1153 "?Maturity, ?DisableScripts, ?DisableCollisions, " +
1154 "?DisablePhysics, ?TerrainTexture1, " +
1155 "?TerrainTexture2, ?TerrainTexture3, " +
1156 "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " +
1157 "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " +
1158 "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " +
1159 "?WaterHeight, ?TerrainRaiseLimit, " +
1160 "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " +
1161 "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " +
1162 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
1163 "?LoadedCreationDateTime, ?LoadedCreationID, " +
1164 "?TerrainImageID, ?block_search, ?casino, " +
1165 "?TelehubObject, ?ParcelImageID)";
1109 1166
1110 ExecuteNonQuery(cmd); 1167 ExecuteNonQuery(cmd);
1111 } 1168 }
@@ -1114,7 +1171,7 @@ namespace OpenSim.Data.MySQL
1114 SaveSpawnPoints(rs); 1171 SaveSpawnPoints(rs);
1115 } 1172 }
1116 1173
1117 public List<LandData> LoadLandObjects(UUID regionUUID) 1174 public virtual List<LandData> LoadLandObjects(UUID regionUUID)
1118 { 1175 {
1119 List<LandData> landData = new List<LandData>(); 1176 List<LandData> landData = new List<LandData>();
1120 1177
@@ -1296,6 +1353,7 @@ namespace OpenSim.Data.MySQL
1296 prim.CollisionSoundVolume = (float)(double)row["CollisionSoundVolume"]; 1353 prim.CollisionSoundVolume = (float)(double)row["CollisionSoundVolume"];
1297 1354
1298 prim.PassTouches = ((sbyte)row["PassTouches"] != 0); 1355 prim.PassTouches = ((sbyte)row["PassTouches"] != 0);
1356 prim.PassCollisions = ((sbyte)row["PassCollisions"] != 0);
1299 prim.LinkNum = (int)row["LinkNumber"]; 1357 prim.LinkNum = (int)row["LinkNumber"];
1300 1358
1301 if (!(row["MediaURL"] is System.DBNull)) 1359 if (!(row["MediaURL"] is System.DBNull))
@@ -1334,6 +1392,15 @@ namespace OpenSim.Data.MySQL
1334 prim.Friction = (float)(double)row["Friction"]; 1392 prim.Friction = (float)(double)row["Friction"];
1335 prim.Restitution = (float)(double)row["Restitution"]; 1393 prim.Restitution = (float)(double)row["Restitution"];
1336 1394
1395 SOPVehicle vehicle = null;
1396
1397 if (row["Vehicle"].ToString() != String.Empty)
1398 {
1399 vehicle = SOPVehicle.FromXml2(row["Vehicle"].ToString());
1400 if (vehicle != null)
1401 prim.VehicleParams = vehicle;
1402 }
1403
1337 return prim; 1404 return prim;
1338 } 1405 }
1339 1406
@@ -1344,32 +1411,40 @@ namespace OpenSim.Data.MySQL
1344 /// <returns></returns> 1411 /// <returns></returns>
1345 private static TaskInventoryItem BuildItem(IDataReader row) 1412 private static TaskInventoryItem BuildItem(IDataReader row)
1346 { 1413 {
1347 TaskInventoryItem taskItem = new TaskInventoryItem(); 1414 try
1348 1415 {
1349 taskItem.ItemID = DBGuid.FromDB(row["itemID"]); 1416 TaskInventoryItem taskItem = new TaskInventoryItem();
1350 taskItem.ParentPartID = DBGuid.FromDB(row["primID"]); 1417
1351 taskItem.AssetID = DBGuid.FromDB(row["assetID"]); 1418 taskItem.ItemID = DBGuid.FromDB(row["itemID"]);
1352 taskItem.ParentID = DBGuid.FromDB(row["parentFolderID"]); 1419 taskItem.ParentPartID = DBGuid.FromDB(row["primID"]);
1353 1420 taskItem.AssetID = DBGuid.FromDB(row["assetID"]);
1354 taskItem.InvType = Convert.ToInt32(row["invType"]); 1421 taskItem.ParentID = DBGuid.FromDB(row["parentFolderID"]);
1355 taskItem.Type = Convert.ToInt32(row["assetType"]); 1422
1356 1423 taskItem.InvType = Convert.ToInt32(row["invType"]);
1357 taskItem.Name = (String)row["name"]; 1424 taskItem.Type = Convert.ToInt32(row["assetType"]);
1358 taskItem.Description = (String)row["description"]; 1425
1359 taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); 1426 taskItem.Name = (String)row["name"];
1360 taskItem.CreatorIdentification = (String)row["creatorID"]; 1427 taskItem.Description = (String)row["description"];
1361 taskItem.OwnerID = DBGuid.FromDB(row["ownerID"]); 1428 taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]);
1362 taskItem.LastOwnerID = DBGuid.FromDB(row["lastOwnerID"]); 1429 taskItem.CreatorIdentification = (String)row["creatorID"];
1363 taskItem.GroupID = DBGuid.FromDB(row["groupID"]); 1430 taskItem.OwnerID = DBGuid.FromDB(row["ownerID"]);
1364 1431 taskItem.LastOwnerID = DBGuid.FromDB(row["lastOwnerID"]);
1365 taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); 1432 taskItem.GroupID = DBGuid.FromDB(row["groupID"]);
1366 taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); 1433
1367 taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); 1434 taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]);
1368 taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); 1435 taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]);
1369 taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); 1436 taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]);
1370 taskItem.Flags = Convert.ToUInt32(row["flags"]); 1437 taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]);
1371 1438 taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]);
1372 return taskItem; 1439 taskItem.Flags = Convert.ToUInt32(row["flags"]);
1440
1441 return taskItem;
1442 }
1443 catch
1444 {
1445 m_log.ErrorFormat("[MYSQL DB]: Error reading task inventory: itemID was {0}, primID was {1}", row["itemID"].ToString(), row["primID"].ToString());
1446 throw;
1447 }
1373 } 1448 }
1374 1449
1375 private static RegionSettings BuildRegionSettings(IDataReader row) 1450 private static RegionSettings BuildRegionSettings(IDataReader row)
@@ -1427,6 +1502,9 @@ namespace OpenSim.Data.MySQL
1427 newSettings.ParcelImageID = DBGuid.FromDB(row["parcel_tile_ID"]); 1502 newSettings.ParcelImageID = DBGuid.FromDB(row["parcel_tile_ID"]);
1428 newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]); 1503 newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]);
1429 1504
1505 newSettings.GodBlockSearch = Convert.ToBoolean(row["block_search"]);
1506 newSettings.Casino = Convert.ToBoolean(row["casino"]);
1507
1430 return newSettings; 1508 return newSettings;
1431 } 1509 }
1432 1510
@@ -1503,6 +1581,13 @@ namespace OpenSim.Data.MySQL
1503 1581
1504 newData.ParcelAccessList = new List<LandAccessEntry>(); 1582 newData.ParcelAccessList = new List<LandAccessEntry>();
1505 1583
1584 if (!(row["SeeAVs"] is System.DBNull))
1585 newData.SeeAVs = Convert.ToInt32(row["SeeAVs"]) != 0 ? true : false;
1586 if (!(row["AnyAVSounds"] is System.DBNull))
1587 newData.AnyAVSounds = Convert.ToInt32(row["AnyAVSounds"]) != 0 ? true : false;
1588 if (!(row["GroupAVSounds"] is System.DBNull))
1589 newData.GroupAVSounds = Convert.ToInt32(row["GroupAVSounds"]) != 0 ? true : false;
1590
1506 return newData; 1591 return newData;
1507 } 1592 }
1508 1593
@@ -1521,6 +1606,34 @@ namespace OpenSim.Data.MySQL
1521 } 1606 }
1522 1607
1523 /// <summary> 1608 /// <summary>
1609 ///
1610 /// </summary>
1611 /// <param name="val"></param>
1612 /// <returns></returns>
1613 private static Array SerializeTerrain(double[,] val, double[,] oldTerrain)
1614 {
1615 MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double));
1616 BinaryWriter bw = new BinaryWriter(str);
1617
1618 // TODO: COMPATIBILITY - Add byte-order conversions
1619 for (int x = 0; x < (int)Constants.RegionSize; x++)
1620 for (int y = 0; y < (int)Constants.RegionSize; y++)
1621 {
1622 double height = 20.0;
1623 if (oldTerrain != null)
1624 height = oldTerrain[x, y];
1625 if (!double.IsNaN(val[x, y]))
1626 height = val[x, y];
1627 if (height == 0.0)
1628 height = double.Epsilon;
1629
1630 bw.Write(height);
1631 }
1632
1633 return str.ToArray();
1634 }
1635
1636 /// <summary>
1524 /// Fill the prim command with prim values 1637 /// Fill the prim command with prim values
1525 /// </summary> 1638 /// </summary>
1526 /// <param name="row"></param> 1639 /// <param name="row"></param>
@@ -1654,6 +1767,11 @@ namespace OpenSim.Data.MySQL
1654 else 1767 else
1655 cmd.Parameters.AddWithValue("PassTouches", 0); 1768 cmd.Parameters.AddWithValue("PassTouches", 0);
1656 1769
1770 if (prim.PassCollisions)
1771 cmd.Parameters.AddWithValue("PassCollisions", 1);
1772 else
1773 cmd.Parameters.AddWithValue("PassCollisions", 0);
1774
1657 cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); 1775 cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum);
1658 cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); 1776 cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl);
1659 if (prim.AttachedPos != null) 1777 if (prim.AttachedPos != null)
@@ -1668,6 +1786,11 @@ namespace OpenSim.Data.MySQL
1668 else 1786 else
1669 cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]); 1787 cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]);
1670 1788
1789 if (prim.VehicleParams != null)
1790 cmd.Parameters.AddWithValue("Vehicle", prim.VehicleParams.ToXml2());
1791 else
1792 cmd.Parameters.AddWithValue("Vehicle", String.Empty);
1793
1671 if (prim.DynAttrs.CountNamespaces > 0) 1794 if (prim.DynAttrs.CountNamespaces > 0)
1672 cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); 1795 cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml());
1673 else 1796 else
@@ -1756,6 +1879,8 @@ namespace OpenSim.Data.MySQL
1756 cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); 1879 cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime);
1757 cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); 1880 cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID);
1758 cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); 1881 cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID);
1882 cmd.Parameters.AddWithValue("block_search", settings.GodBlockSearch);
1883 cmd.Parameters.AddWithValue("casino", settings.Casino);
1759 1884
1760 cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID); 1885 cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID);
1761 cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); 1886 cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject);
@@ -1813,6 +1938,10 @@ namespace OpenSim.Data.MySQL
1813 cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop); 1938 cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop);
1814 cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic); 1939 cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic);
1815 cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia); 1940 cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia);
1941 cmd.Parameters.AddWithValue("SeeAVs", land.SeeAVs ? 1 : 0);
1942 cmd.Parameters.AddWithValue("AnyAVSounds", land.AnyAVSounds ? 1 : 0);
1943 cmd.Parameters.AddWithValue("GroupAVSounds", land.GroupAVSounds ? 1 : 0);
1944
1816 } 1945 }
1817 1946
1818 /// <summary> 1947 /// <summary>
@@ -1919,7 +2048,7 @@ namespace OpenSim.Data.MySQL
1919 cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); 2048 cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml());
1920 } 2049 }
1921 2050
1922 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) 2051 public virtual void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
1923 { 2052 {
1924 lock (m_dbLock) 2053 lock (m_dbLock)
1925 { 2054 {
@@ -1963,6 +2092,37 @@ namespace OpenSim.Data.MySQL
1963 } 2092 }
1964 } 2093 }
1965 2094
2095 public UUID[] GetObjectIDs(UUID regionID)
2096 {
2097 List<UUID> uuids = new List<UUID>();
2098
2099 lock (m_dbLock)
2100 {
2101 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
2102 {
2103 dbcon.Open();
2104
2105 using (MySqlCommand cmd = dbcon.CreateCommand())
2106 {
2107 cmd.CommandText = "select UUID from prims where RegionUUID = ?RegionUUID and SceneGroupID = UUID";
2108 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
2109
2110 using (IDataReader reader = ExecuteReader(cmd))
2111 {
2112 while (reader.Read())
2113 {
2114 UUID id = new UUID(reader["UUID"].ToString());
2115
2116 uuids.Add(id);
2117 }
2118 }
2119 }
2120 }
2121 }
2122
2123 return uuids.ToArray();
2124 }
2125
1966 private void LoadSpawnPoints(RegionSettings rs) 2126 private void LoadSpawnPoints(RegionSettings rs)
1967 { 2127 {
1968 rs.ClearSpawnPoints(); 2128 rs.ClearSpawnPoints();
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
index e964295..4ff3175 100644
--- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
@@ -46,17 +46,21 @@ namespace OpenSim.Data.MySQL
46 { 46 {
47 string[] words = query.Split(new char[] {' '}); 47 string[] words = query.Split(new char[] {' '});
48 48
49 bool valid = false;
50
49 for (int i = 0 ; i < words.Length ; i++) 51 for (int i = 0 ; i < words.Length ; i++)
50 { 52 {
51 if (words[i].Length < 3) 53 if (words[i].Length > 2)
52 { 54 valid = true;
53 if (i != words.Length - 1) 55// if (words[i].Length < 3)
54 Array.Copy(words, i + 1, words, i, words.Length - i - 1); 56// {
55 Array.Resize(ref words, words.Length - 1); 57// if (i != words.Length - 1)
56 } 58// Array.Copy(words, i + 1, words, i, words.Length - i - 1);
59// Array.Resize(ref words, words.Length - 1);
60// }
57 } 61 }
58 62
59 if (words.Length == 0) 63 if ((!valid) || words.Length == 0)
60 return new UserAccountData[0]; 64 return new UserAccountData[0];
61 65
62 if (words.Length > 2) 66 if (words.Length > 2)
@@ -66,20 +70,36 @@ namespace OpenSim.Data.MySQL
66 { 70 {
67 if (words.Length == 1) 71 if (words.Length == 1)
68 { 72 {
69 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search)", m_Realm); 73 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search) and active=1", m_Realm);
70 cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); 74 cmd.Parameters.AddWithValue("?search", words[0] + "%");
71 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 75 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
72 } 76 }
73 else 77 else
74 { 78 {
75 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm); 79 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast) and active=1", m_Realm);
76 cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); 80 cmd.Parameters.AddWithValue("?searchFirst", words[0] + "%");
77 cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); 81 cmd.Parameters.AddWithValue("?searchLast", words[1] + "%");
78 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 82 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
79 } 83 }
80 84
81 return DoQuery(cmd); 85 return DoQuery(cmd);
82 } 86 }
83 } 87 }
88
89 public UserAccountData[] GetUsersWhere(UUID scopeID, string where)
90 {
91 using (MySqlCommand cmd = new MySqlCommand())
92 {
93 if (scopeID != UUID.Zero)
94 {
95 where = "(ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (" + where + ")";
96 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
97 }
98
99 cmd.CommandText = String.Format("select * from {0} where " + where, m_Realm);
100
101 return DoQuery(cmd);
102 }
103 }
84 } 104 }
85} \ No newline at end of file 105}
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
index b35595d..c213dd1 100644
--- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
@@ -631,6 +631,8 @@ namespace OpenSim.Data.MySQL
631 { 631 {
632 if(reader.HasRows) 632 if(reader.HasRows)
633 { 633 {
634 m_log.DebugFormat("[PROFILES_DATA]" +
635 ": Getting data for {0}.", props.UserId);
634 reader.Read(); 636 reader.Read();
635 props.WebUrl = (string)reader["profileURL"]; 637 props.WebUrl = (string)reader["profileURL"];
636 UUID.TryParse((string)reader["profileImage"], out props.ImageId); 638 UUID.TryParse((string)reader["profileImage"], out props.ImageId);
@@ -646,6 +648,9 @@ namespace OpenSim.Data.MySQL
646 } 648 }
647 else 649 else
648 { 650 {
651 m_log.DebugFormat("[PROFILES_DATA]" +
652 ": No data for {0}", props.UserId);
653
649 props.WebUrl = string.Empty; 654 props.WebUrl = string.Empty;
650 props.ImageId = UUID.Zero; 655 props.ImageId = UUID.Zero;
651 props.AboutText = string.Empty; 656 props.AboutText = string.Empty;
@@ -891,7 +896,7 @@ namespace OpenSim.Data.MySQL
891 } 896 }
892 897
893 #region User Preferences 898 #region User Preferences
894 public bool GetUserPreferences(ref UserPreferences pref, ref string result) 899 public OSDArray GetUserPreferences(UUID avatarId)
895 { 900 {
896 string query = string.Empty; 901 string query = string.Empty;
897 902
@@ -908,16 +913,19 @@ namespace OpenSim.Data.MySQL
908 dbcon.Open(); 913 dbcon.Open();
909 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 914 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
910 { 915 {
911 cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); 916 cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
912 917
913 using (MySqlDataReader reader = cmd.ExecuteReader()) 918 using (MySqlDataReader reader = cmd.ExecuteReader())
914 { 919 {
915 if(reader.HasRows) 920 if(reader.HasRows)
916 { 921 {
917 reader.Read(); 922 reader.Read();
918 bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); 923 OSDMap record = new OSDMap();
919 bool.TryParse((string)reader["visible"], out pref.Visible); 924
920 pref.EMail = (string)reader["email"]; 925 record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"]));
926 record.Add("visible",OSD.FromString((string)reader["visible"]));
927 record.Add("email",OSD.FromString((string)reader["email"]));
928 data.Add(record);
921 } 929 }
922 else 930 else
923 { 931 {
@@ -930,8 +938,8 @@ namespace OpenSim.Data.MySQL
930 using (MySqlCommand put = new MySqlCommand(query, dbcon)) 938 using (MySqlCommand put = new MySqlCommand(query, dbcon))
931 { 939 {
932 940
933 put.Parameters.AddWithValue("?Email", pref.EMail); 941// put.Parameters.AddWithValue("?Email", pref.EMail);
934 put.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); 942// put.Parameters.AddWithValue("?uuid", pref.UserId.ToString());
935 943
936 put.ExecuteNonQuery(); 944 put.ExecuteNonQuery();
937 } 945 }
@@ -944,17 +952,15 @@ namespace OpenSim.Data.MySQL
944 { 952 {
945 m_log.ErrorFormat("[PROFILES_DATA]" + 953 m_log.ErrorFormat("[PROFILES_DATA]" +
946 ": Get preferences exception {0}", e.Message); 954 ": Get preferences exception {0}", e.Message);
947 result = e.Message;
948 return false;
949 } 955 }
950 return true; 956 return data;
951 } 957 }
952 958
953 public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) 959 public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId )
954 { 960 {
955 string query = string.Empty; 961 string query = string.Empty;
956 962
957 query += "UPDATE usersettings SET "; 963 query += "UPDATE userpsettings SET ";
958 query += "imviaemail=?ImViaEmail, "; 964 query += "imviaemail=?ImViaEmail, ";
959 query += "visible=?Visible, "; 965 query += "visible=?Visible, ";
960 query += "email=?EMail "; 966 query += "email=?EMail ";
@@ -980,7 +986,6 @@ namespace OpenSim.Data.MySQL
980 { 986 {
981 m_log.ErrorFormat("[PROFILES_DATA]" + 987 m_log.ErrorFormat("[PROFILES_DATA]" +
982 ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException); 988 ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException);
983 result = e.Message;
984 return false; 989 return false;
985 } 990 }
986 return true; 991 return true;
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
index af7e876..68e1a5a 100644
--- a/OpenSim/Data/MySQL/MySQLXAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -500,4 +500,4 @@ namespace OpenSim.Data.MySQL
500 500
501 #endregion 501 #endregion
502 } 502 }
503} \ No newline at end of file 503}
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
index ac31380..738f5c2 100644
--- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
@@ -717,7 +717,7 @@ ALTER TABLE regionsettings ADD COLUMN loaded_creation_datetime int unsigned NOT
717 717
718COMMIT; 718COMMIT;
719 719
720:VERSION 32 720:VERSION 32 #---------------------
721 721
722BEGIN; 722BEGIN;
723CREATE TABLE `regionwindlight` ( 723CREATE TABLE `regionwindlight` (
@@ -939,6 +939,7 @@ ALTER TABLE prims ADD COLUMN AttachedPosY double default 0;
939ALTER TABLE prims ADD COLUMN AttachedPosZ double default 0; 939ALTER TABLE prims ADD COLUMN AttachedPosZ double default 0;
940ALTER TABLE primshapes ADD COLUMN LastAttachPoint int(4) not null default '0'; 940ALTER TABLE primshapes ADD COLUMN LastAttachPoint int(4) not null default '0';
941COMMIT; 941COMMIT;
942<<<<<<< HEAD
942 943
943:VERSION 50 #---- Change LandFlags to unsigned 944:VERSION 50 #---- Change LandFlags to unsigned
944 945
@@ -948,3 +949,5 @@ ALTER TABLE land CHANGE COLUMN LandFlags LandFlags int unsigned default null;
948 949
949COMMIT; 950COMMIT;
950 951
952=======
953>>>>>>> avn/ubitvar
diff --git a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations
index 87e99fa..3df9b9b 100644
--- a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations
+++ b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations
@@ -81,6 +81,7 @@ CREATE TABLE IF NOT EXISTS `userdata` (
81 81
82commit; 82commit;
83 83
84<<<<<<< HEAD
84:VERSION 3 # ------------------------------- 85:VERSION 3 # -------------------------------
85begin; 86begin;
86CREATE TABLE IF NOT EXISTS `usersettings` ( 87CREATE TABLE IF NOT EXISTS `usersettings` (
@@ -96,3 +97,5 @@ commit;
96begin; 97begin;
97ALTER TABLE userpicks ADD COLUMN gatekeeper varchar(255); 98ALTER TABLE userpicks ADD COLUMN gatekeeper varchar(255);
98commit; 99commit;
100=======
101>>>>>>> avn/ubitvar