From 8d035b196df31ddb41e4917a757e83acdbb03d78 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 7 Jan 2009 18:46:27 +0000 Subject: * Apply http://opensimulator.org/mantis/view.php?id=2948 * This fixes adding and updating user profiles in MySQL on platforms that have a commas as a decimal separator * Thanks Tommil! --- OpenSim/Data/MySQL/MySQLGridData.cs | 12 +++--- OpenSim/Data/MySQL/MySQLManager.cs | 74 ++++++++++++++++++------------------- OpenSim/Data/MySQL/MySQLUserData.cs | 24 ++++++------ 3 files changed, 55 insertions(+), 55 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index da01ad3..437747b 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -245,7 +245,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?xmin"] = xmin.ToString(); param["?ymin"] = ymin.ToString(); param["?xmax"] = xmax.ToString(); @@ -294,7 +294,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?name"] = namePrefix + "%"; IDbCommand result = @@ -339,7 +339,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?handle"] = handle.ToString(); IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); @@ -374,7 +374,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); @@ -409,7 +409,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); // Add % because this is a like query. param["?regionName"] = regionName + "%"; // Order by statement will return shorter matches first. Only returns one record or no record. @@ -546,7 +546,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?x"] = x.ToString(); param["?y"] = y.ToString(); IDbCommand result = diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index a54c020..f16795e 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -340,7 +340,7 @@ namespace OpenSim.Data.MySQL /// The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y /// The parameters - index so that @y is indexed as 'y' /// A MySQL DB Command - public IDbCommand Query(string sql, Dictionary parameters) + public IDbCommand Query(string sql, Dictionary parameters) { try { @@ -348,7 +348,7 @@ namespace OpenSim.Data.MySQL MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); dbcommand.CommandText = sql; - foreach (KeyValuePair param in parameters) + foreach (KeyValuePair param in parameters) { dbcommand.Parameters.AddWithValue(param.Key, param.Value); } @@ -714,7 +714,7 @@ namespace OpenSim.Data.MySQL string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)"; - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); parameters["?server"] = serverDaemon; parameters["?target"] = target; parameters["?method"] = methodCall; @@ -793,34 +793,34 @@ namespace OpenSim.Data.MySQL "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey, ?userFlags, ?godLevel, ?customType, ?partner)"; - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); parameters["?UUID"] = uuid.ToString(); parameters["?username"] = username; parameters["?lastname"] = lastname; parameters["?email"] = email; parameters["?passwordHash"] = passwordHash; parameters["?passwordSalt"] = passwordSalt; - parameters["?homeRegion"] = homeRegion.ToString(); + parameters["?homeRegion"] = homeRegion; parameters["?homeRegionID"] = homeRegionID.ToString(); - parameters["?homeLocationX"] = homeLocX.ToString(); - parameters["?homeLocationY"] = homeLocY.ToString(); - parameters["?homeLocationZ"] = homeLocZ.ToString(); - parameters["?homeLookAtX"] = homeLookAtX.ToString(); - parameters["?homeLookAtY"] = homeLookAtY.ToString(); - parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); - parameters["?created"] = created.ToString(); - parameters["?lastLogin"] = lastlogin.ToString(); + parameters["?homeLocationX"] = homeLocX; + parameters["?homeLocationY"] = homeLocY; + parameters["?homeLocationZ"] = homeLocZ; + parameters["?homeLookAtX"] = homeLookAtX; + parameters["?homeLookAtY"] = homeLookAtY; + parameters["?homeLookAtZ"] = homeLookAtZ; + parameters["?created"] = created; + parameters["?lastLogin"] = lastlogin; parameters["?userInventoryURI"] = inventoryURI; parameters["?userAssetURI"] = assetURI; - parameters["?profileCanDoMask"] = canDoMask.ToString(); - parameters["?profileWantDoMask"] = wantDoMask.ToString(); + parameters["?profileCanDoMask"] = canDoMask; + parameters["?profileWantDoMask"] = wantDoMask; parameters["?profileAboutText"] = aboutText; parameters["?profileFirstText"] = firstText; parameters["?profileImage"] = profileImage.ToString(); parameters["?profileFirstImage"] = firstImage.ToString(); parameters["?webLoginKey"] = webLoginKey.ToString(); - parameters["?userFlags"] = userFlags.ToString(); - parameters["?godLevel"] = godLevel.ToString(); + parameters["?userFlags"] = userFlags; + parameters["?godLevel"] = godLevel; parameters["?customType"] = customType == null ? "" : customType; parameters["?partner"] = partner.ToString(); bool returnval = false; @@ -892,35 +892,35 @@ namespace OpenSim.Data.MySQL sql += "`customType` = ?customType , `partner` = ?partner , "; sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID"; - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); parameters["?UUID"] = uuid.ToString(); parameters["?username"] = username; parameters["?lastname"] = lastname; parameters["?email"] = email; parameters["?passwordHash"] = passwordHash; parameters["?passwordSalt"] = passwordSalt; - parameters["?homeRegion"] = homeRegion.ToString(); + parameters["?homeRegion"] = homeRegion; parameters["?homeRegionID"] = homeRegionID.ToString(); - parameters["?homeLocationX"] = homeLocX.ToString(); - parameters["?homeLocationY"] = homeLocY.ToString(); - parameters["?homeLocationZ"] = homeLocZ.ToString(); - parameters["?homeLookAtX"] = homeLookAtX.ToString(); - parameters["?homeLookAtY"] = homeLookAtY.ToString(); - parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); - parameters["?created"] = created.ToString(); - parameters["?lastLogin"] = lastlogin.ToString(); + parameters["?homeLocationX"] = homeLocX; + parameters["?homeLocationY"] = homeLocY; + parameters["?homeLocationZ"] = homeLocZ; + parameters["?homeLookAtX"] = homeLookAtX; + parameters["?homeLookAtY"] = homeLookAtY; + parameters["?homeLookAtZ"] = homeLookAtZ; + parameters["?created"] = created; + parameters["?lastLogin"] = lastlogin; parameters["?userInventoryURI"] = inventoryURI; parameters["?userAssetURI"] = assetURI; - parameters["?profileCanDoMask"] = canDoMask.ToString(); - parameters["?profileWantDoMask"] = wantDoMask.ToString(); + parameters["?profileCanDoMask"] = canDoMask; + parameters["?profileWantDoMask"] = wantDoMask; parameters["?profileAboutText"] = aboutText; parameters["?profileFirstText"] = firstText; parameters["?profileImage"] = profileImage.ToString(); parameters["?profileFirstImage"] = firstImage.ToString(); parameters["?webLoginKey"] = webLoginKey.ToString(); - parameters["?userFlags"] = userFlags.ToString(); - parameters["?godLevel"] = godLevel.ToString(); - parameters["?customType"] = customType == null ? "" : customType.ToString(); + parameters["?userFlags"] = userFlags; + parameters["?godLevel"] = godLevel; + parameters["?customType"] = customType == null ? "" : customType; parameters["?partner"] = partner.ToString(); bool returnval = false; @@ -993,7 +993,7 @@ namespace OpenSim.Data.MySQL sql += ";"; } - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); parameters["?regionHandle"] = regiondata.regionHandle.ToString(); parameters["?regionName"] = regiondata.regionName.ToString(); @@ -1063,7 +1063,7 @@ namespace OpenSim.Data.MySQL string sql = "DELETE FROM regions WHERE uuid = ?uuid;"; - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); try { @@ -1102,7 +1102,7 @@ namespace OpenSim.Data.MySQL sql += "REPLACE INTO "; sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos, currentLookAt) VALUES "; sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos, ?currentLookAt);"; - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); parameters["?UUID"] = agentdata.ProfileID.ToString(); parameters["?sessionID"] = agentdata.SessionID.ToString(); @@ -1114,8 +1114,8 @@ namespace OpenSim.Data.MySQL parameters["?logoutTime"] = agentdata.LogoutTime.ToString(); parameters["?currentRegion"] = agentdata.Region.ToString(); parameters["?currentHandle"] = agentdata.Handle.ToString(); - parameters["?currentPos"] = "<" + (agentdata.Position.X).ToString() + "," + (agentdata.Position.Y).ToString() + "," + (agentdata.Position.Z).ToString() + ">"; - parameters["?currentLookAt"] = "<" + (agentdata.LookAt.X).ToString() + "," + (agentdata.LookAt.Y).ToString() + "," + (agentdata.LookAt.Z).ToString() + ">"; + parameters["?currentPos"] = "<" + (agentdata.Position.X).ToString().Replace(",", ".") + "," + (agentdata.Position.Y).ToString().Replace(",", ".") + "," + (agentdata.Position.Z).ToString().Replace(",", ".") + ">"; + parameters["?currentLookAt"] = "<" + (agentdata.LookAt.X).ToString().Replace(",", ".") + "," + (agentdata.LookAt.Y).ToString().Replace(",", ".") + "," + (agentdata.LookAt.Z).ToString().Replace(",", ".") + ">"; bool returnval = false; diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 14d178b..f6a9af3 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -176,7 +176,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?first"] = user; param["?second"] = last; @@ -209,7 +209,7 @@ namespace OpenSim.Data.MySQL { int dtvalue = Util.UnixTimeSinceEpoch(); - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); param["?friendID"] = friend.ToString(); param["?friendPerms"] = perms.ToString(); @@ -251,7 +251,7 @@ namespace OpenSim.Data.MySQL public override void RemoveUserFriend(UUID friendlistowner, UUID friend) { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); param["?friendID"] = friend.ToString(); @@ -285,7 +285,7 @@ namespace OpenSim.Data.MySQL public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); param["?friendID"] = friend.ToString(); param["?friendPerms"] = perms.ToString(); @@ -318,7 +318,7 @@ namespace OpenSim.Data.MySQL { List Lfli = new List(); - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); MySQLSuperManager dbm = GetLockedConnection("GetUserFriendList"); @@ -373,7 +373,7 @@ namespace OpenSim.Data.MySQL { foreach (UUID uuid in uuids) { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); IDbCommand result = dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + @@ -419,7 +419,7 @@ namespace OpenSim.Data.MySQL querysplit = query.Split(' '); if (querysplit.Length > 1 && querysplit[1].Trim() != String.Empty) { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%"; MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults"); @@ -461,7 +461,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; IDbCommand result = @@ -506,7 +506,7 @@ namespace OpenSim.Data.MySQL MySQLSuperManager dbm = GetLockedConnection("GetUserByUUID"); try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); @@ -596,7 +596,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", @@ -744,7 +744,7 @@ namespace OpenSim.Data.MySQL MySQLSuperManager dbm = GetLockedConnection("GetUserAppearance"); try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?owner"] = user.ToString(); IDbCommand result = dbm.Manager.Query( @@ -825,7 +825,7 @@ namespace OpenSim.Data.MySQL public Hashtable GetUserAttachments(UUID agentID) { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?uuid"] = agentID.ToString(); MySQLSuperManager dbm = GetLockedConnection("GetUserAttachments"); -- cgit v1.1