From 7161689a97edcdeceee3d3eeeaee7eadc4e06a89 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 14 Aug 2008 19:59:32 +0000 Subject: Adds UserFlags and GodLevel to the user data store and plumbs then in. This will have no effect unless both the UGAI and the region are this revision or later --- OpenSim/Data/MySQL/MySQLManager.cs | 15 ++++++++++--- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- OpenSim/Data/MySQL/Resources/003_UserStore.sql | 6 ++++++ OpenSim/Data/SQLite/Resources/003_UserStore.sql | 6 ++++++ OpenSim/Data/SQLite/SQLiteUserData.cs | 6 ++++++ OpenSim/Framework/UserProfileData.cs | 20 ++++++++++++++++- OpenSim/Grid/UserServer/UserManager.cs | 25 ++++++++++++++++++++++ .../Region/Communications/OGS1/OGS1UserServices.cs | 7 ++++++ 8 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/003_UserStore.sql create mode 100644 OpenSim/Data/SQLite/Resources/003_UserStore.sql diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 297b1a7..5e9e259 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -587,6 +587,9 @@ namespace OpenSim.Data.MySQL LLUUID.TryParse((string)reader["webLoginKey"], out tmp); retval.WebLoginKey = tmp; } + + retval.UserFlags = Convert.ToInt32(reader["userFlags"].ToString()); + retval.GodLevel = Convert.ToInt32(reader["godLevel"].ToString()); } else @@ -728,14 +731,14 @@ namespace OpenSim.Data.MySQL "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; sql += "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; - sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`) VALUES "; + sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`, `userFlags`, `godLevel`) VALUES "; sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, "; sql += "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; sql += "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; - sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey)"; + sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey, ?userFlags, ?godLevel)"; Dictionary parameters = new Dictionary(); parameters["?UUID"] = uuid.ToString(); @@ -761,6 +764,9 @@ namespace OpenSim.Data.MySQL parameters["?profileImage"] = profileImage.ToString(); parameters["?profileFirstImage"] = firstImage.ToString(); parameters["?webLoginKey"] = string.Empty; + parameters["?userFlags"] = "0"; + parameters["?godLevel"] = "0"; + bool returnval = false; @@ -815,7 +821,7 @@ namespace OpenSim.Data.MySQL float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, - LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey) + LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey, int userFlags, int godLevel) { string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname "; sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; @@ -827,6 +833,7 @@ namespace OpenSim.Data.MySQL sql += "`profileCanDoMask` = ?profileCanDoMask , `profileWantDoMask` = ?profileWantDoMask , "; sql += "`profileAboutText` = ?profileAboutText , `profileFirstText` = ?profileFirstText, "; sql += "`profileImage` = ?profileImage , `profileFirstImage` = ?profileFirstImage , "; + sql += "`userFlags` = ?userFlags , `godLevel` = ?godLevel , "; sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID"; Dictionary parameters = new Dictionary(); @@ -854,6 +861,8 @@ namespace OpenSim.Data.MySQL parameters["?profileImage"] = profileImage.ToString(); parameters["?profileFirstImage"] = firstImage.ToString(); parameters["?webLoginKey"] = webLoginKey.ToString(); + parameters["?userFlags"] = userFlags.ToString(); + parameters["?godLevel"] = userFlags.ToString(); bool returnval = false; try diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index d7bf2a8..b7f4cbd 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -685,7 +685,7 @@ namespace OpenSim.Data.MySQL user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, - user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey); + user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel); } return true; diff --git a/OpenSim/Data/MySQL/Resources/003_UserStore.sql b/OpenSim/Data/MySQL/Resources/003_UserStore.sql new file mode 100644 index 0000000..6f890ee --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_UserStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE users add userFlags integer NOT NULL default 0; +ALTER TABLE users add godLevel integer NOT NULL default 0; + +COMMIT; diff --git a/OpenSim/Data/SQLite/Resources/003_UserStore.sql b/OpenSim/Data/SQLite/Resources/003_UserStore.sql new file mode 100644 index 0000000..6f890ee --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/003_UserStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE users add userFlags integer NOT NULL default 0; +ALTER TABLE users add godLevel integer NOT NULL default 0; + +COMMIT; diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs index 21c9dbc..c55eee8 100644 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserData.cs @@ -681,6 +681,8 @@ namespace OpenSim.Data.SQLite SQLiteUtil.createCol(users, "profileImage", typeof (String)); SQLiteUtil.createCol(users, "profileFirstImage", typeof (String)); SQLiteUtil.createCol(users, "webLoginKey", typeof(String)); + SQLiteUtil.createCol(users, "userFlags", typeof (Int32)); + SQLiteUtil.createCol(users, "godLevel", typeof (Int32)); // Add in contraints users.PrimaryKey = new DataColumn[] {users.Columns["UUID"]}; return users; @@ -789,6 +791,8 @@ namespace OpenSim.Data.SQLite LLUUID.TryParse((String)row["profileFirstImage"], out tmp); user.FirstLifeImage = tmp; user.WebLoginKey = new LLUUID((String) row["webLoginKey"]); + user.UserFlags = Convert.ToInt32(row["userFlags"]); + user.GodLevel = Convert.ToInt32(row["godLevel"]); return user; } @@ -829,6 +833,8 @@ namespace OpenSim.Data.SQLite row["profileImage"] = user.Image; row["profileFirstImage"] = user.FirstLifeImage; row["webLoginKey"] = user.WebLoginKey; + row["userFlags"] = user.UserFlags; + row["godLevel"] = user.GodLevel; // ADO.NET doesn't handle NULL very well foreach (DataColumn col in ds.Tables["users"].Columns) diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs index 2b0e15f..ec9c473 100644 --- a/OpenSim/Framework/UserProfileData.cs +++ b/OpenSim/Framework/UserProfileData.cs @@ -136,6 +136,12 @@ namespace OpenSim.Framework /// private LLUUID _webLoginKey; + // Data for estates and other goodies + // to get away from per-machine configs a little + // + private int _userFlags; + private int _godLevel; + /// /// The regionhandle of the users preffered home region. If multiple sims occupy the same spot, the grid may decide which region the user logs into /// @@ -330,5 +336,17 @@ namespace OpenSim.Framework get { return _currentAgent; } set { _currentAgent = value; } } + + public virtual int UserFlags + { + get { return _userFlags; } + set { _userFlags = value; } + } + + public virtual int GodLevel + { + get { return _godLevel; } + set { _godLevel = value; } + } } -} \ No newline at end of file +} diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index 36f2a0d..5506631 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -156,6 +156,9 @@ namespace OpenSim.Grid.UserServer responseData["home_look_x"] = profile.HomeLookAt.X.ToString(); responseData["home_look_y"] = profile.HomeLookAt.Y.ToString(); responseData["home_look_z"] = profile.HomeLookAt.Z.ToString(); + + responseData["user_flags"] = profile.UserFlags.ToString(); + responseData["god_level"] = profile.GodLevel.ToString(); response.Value = responseData; return response; @@ -638,6 +641,28 @@ namespace OpenSim.Grid.UserServer m_log.Error("[PROFILE]:Failed to set home lookat z"); } } + if (requestData.Contains("user_flags")) + { + try + { + userProfile.UserFlags = Convert.ToInt32((string)requestData["user_flags"]); + } + catch (InvalidCastException) + { + m_log.Error("[PROFILE]:Failed to set user flags"); + } + } + if (requestData.Contains("god_level")) + { + try + { + userProfile.GodLevel = Convert.ToInt32((string)requestData["god_level"]); + } + catch (InvalidCastException) + { + m_log.Error("[PROFILE]:Failed to set god level"); + } + } // call plugin! bool ret = UpdateUserProfileProperties(userProfile); responseData["returnString"] = ret.ToString(); diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 2d37e2f..ee5c7bb 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -85,6 +85,11 @@ namespace OpenSim.Region.Communications.OGS1 new LLVector3((float) Convert.ToDecimal((string) data["home_look_x"]), (float) Convert.ToDecimal((string) data["home_look_y"]), (float) Convert.ToDecimal((string) data["home_look_z"])); + if(data.Contains("user_flags")) + userData.UserFlags = Convert.ToInt32((string) data["user_flags"]); + if(data.Contains("god_level")) + userData.GodLevel = Convert.ToInt32((string) data["god_level"]); + return userData; } @@ -462,6 +467,8 @@ namespace OpenSim.Region.Communications.OGS1 param["home_look_x"] = UserProfile.HomeLookAtX.ToString(); param["home_look_y"] = UserProfile.HomeLookAtY.ToString(); param["home_look_z"] = UserProfile.HomeLookAtZ.ToString(); + param["user_flags"] = UserProfile.UserFlags.ToString(); + param["god_level"] = UserProfile.GodLevel.ToString(); IList parameters = new ArrayList(); parameters.Add(param); -- cgit v1.1