From 53bcf2139e7c8c9da2fbbcafc45704eae3bc5daa Mon Sep 17 00:00:00 2001
From: Sean Dague
Date: Wed, 21 May 2008 18:02:09 +0000
Subject: this removes use of the mapper for wearables, and I can confirm
things get saved to the database. There are still issues on wearing things
after a cleared cache that I'm looking at now.
---
OpenSim/Data/MSSQL/MSSQLUserData.cs | 18 ++---
OpenSim/Data/MySQL/MySQLManager.cs | 86 ++++++++++++----------
OpenSim/Data/MySQL/MySQLUserData.cs | 48 +++++++-----
.../MySQL/Resources/CreateAvatarAppearance.sql | 63 ++++++++--------
OpenSim/Data/NHibernate/NHibernateUserData.cs | 4 +-
OpenSim/Data/SQLite/SQLiteUserData.cs | 18 ++---
OpenSim/Data/UserDataBase.cs | 30 ++++----
OpenSim/Region/Environment/Scenes/ScenePresence.cs | 3 +-
.../Modules/AvatarFactory/AvatarFactoryModule.cs | 5 ++
9 files changed, 151 insertions(+), 124 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/MSSQL/MSSQLUserData.cs b/OpenSim/Data/MSSQL/MSSQLUserData.cs
index 9dc6812..0d3563f 100644
--- a/OpenSim/Data/MSSQL/MSSQLUserData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLUserData.cs
@@ -747,15 +747,15 @@ namespace OpenSim.Data.MSSQL
/// Appearance
/// TODO: stubs for now to get us to a compiling state gently
- // override public AvatarAppearance GetUserAppearance(LLUUID user)
- // {
- // return new AvatarAppearance();
- // }
-
- // override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
- // {
- // return;
- // }
+ override public AvatarAppearance GetUserAppearance(LLUUID user)
+ {
+ return new AvatarAppearance();
+ }
+
+ override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
+ {
+ return;
+ }
override public void AddAttachment(LLUUID user, LLUUID item)
{
diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs
index 7e1b405..4b11739 100644
--- a/OpenSim/Data/MySQL/MySQLManager.cs
+++ b/OpenSim/Data/MySQL/MySQLManager.cs
@@ -191,6 +191,12 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery();
}
+ public void ExecuteSql(string sql)
+ {
+ MySqlCommand cmd = new MySqlCommand(sql, dbcon);
+ cmd.ExecuteNonQuery();
+ }
+
///
/// Given a list of tables, return the version of the tables, as seen in the database
///
@@ -532,38 +538,42 @@ namespace OpenSim.Data.MySQL
public AvatarAppearance readAppearanceRow(IDataReader reader)
{
- AvatarAppearance appearance = new AvatarAppearance();
- appearance.Owner = new LLUUID((string)reader["owner"]);
- appearance.Serial = Convert.ToInt32(reader["serial"]);
- appearance.VisualParams = (byte[])reader["visual_params"];
- appearance.Texture = new LLObject.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length);
- appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]);
- appearance.BodyItem = new LLUUID((string)reader["body_item"]);
- appearance.BodyAsset = new LLUUID((string)reader["body_asset"]);
- appearance.SkinItem = new LLUUID((string)reader["skin_item"]);
- appearance.SkinAsset = new LLUUID((string)reader["skin_asset"]);
- appearance.HairItem = new LLUUID((string)reader["hair_item"]);
- appearance.HairAsset = new LLUUID((string)reader["hair_asset"]);
- appearance.EyesItem = new LLUUID((string)reader["eyes_item"]);
- appearance.EyesAsset = new LLUUID((string)reader["eyes_asset"]);
- appearance.ShirtItem = new LLUUID((string)reader["shirt_item"]);
- appearance.ShirtAsset = new LLUUID((string)reader["shirt_asset"]);
- appearance.PantsItem = new LLUUID((string)reader["pants_item"]);
- appearance.PantsAsset = new LLUUID((string)reader["pants_asset"]);
- appearance.ShoesItem = new LLUUID((string)reader["shoes_item"]);
- appearance.ShoesAsset = new LLUUID((string)reader["shoes_asset"]);
- appearance.SocksItem = new LLUUID((string)reader["socks_item"]);
- appearance.SocksAsset = new LLUUID((string)reader["socks_asset"]);
- appearance.JacketItem = new LLUUID((string)reader["jacket_item"]);
- appearance.JacketAsset = new LLUUID((string)reader["jacket_asset"]);
- appearance.GlovesItem = new LLUUID((string)reader["gloves_item"]);
- appearance.GlovesAsset = new LLUUID((string)reader["gloves_asset"]);
- appearance.UnderShirtItem = new LLUUID((string)reader["undershirt_item"]);
- appearance.UnderShirtAsset = new LLUUID((string)reader["undershirt_asset"]);
- appearance.UnderPantsItem = new LLUUID((string)reader["underpants_item"]);
- appearance.UnderPantsAsset = new LLUUID((string)reader["underpants_asset"]);
- appearance.SkirtItem = new LLUUID((string)reader["skirt_item"]);
- appearance.SkirtAsset = new LLUUID((string)reader["skirt_asset"]);
+ AvatarAppearance appearance = null;
+ if (reader.Read())
+ {
+ appearance = new AvatarAppearance();
+ appearance.Owner = new LLUUID((string)reader["owner"]);
+ appearance.Serial = Convert.ToInt32(reader["serial"]);
+ appearance.VisualParams = (byte[])reader["visual_params"];
+ appearance.Texture = new LLObject.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length);
+ appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]);
+ appearance.BodyItem = new LLUUID((string)reader["body_item"]);
+ appearance.BodyAsset = new LLUUID((string)reader["body_asset"]);
+ appearance.SkinItem = new LLUUID((string)reader["skin_item"]);
+ appearance.SkinAsset = new LLUUID((string)reader["skin_asset"]);
+ appearance.HairItem = new LLUUID((string)reader["hair_item"]);
+ appearance.HairAsset = new LLUUID((string)reader["hair_asset"]);
+ appearance.EyesItem = new LLUUID((string)reader["eyes_item"]);
+ appearance.EyesAsset = new LLUUID((string)reader["eyes_asset"]);
+ appearance.ShirtItem = new LLUUID((string)reader["shirt_item"]);
+ appearance.ShirtAsset = new LLUUID((string)reader["shirt_asset"]);
+ appearance.PantsItem = new LLUUID((string)reader["pants_item"]);
+ appearance.PantsAsset = new LLUUID((string)reader["pants_asset"]);
+ appearance.ShoesItem = new LLUUID((string)reader["shoes_item"]);
+ appearance.ShoesAsset = new LLUUID((string)reader["shoes_asset"]);
+ appearance.SocksItem = new LLUUID((string)reader["socks_item"]);
+ appearance.SocksAsset = new LLUUID((string)reader["socks_asset"]);
+ appearance.JacketItem = new LLUUID((string)reader["jacket_item"]);
+ appearance.JacketAsset = new LLUUID((string)reader["jacket_asset"]);
+ appearance.GlovesItem = new LLUUID((string)reader["gloves_item"]);
+ appearance.GlovesAsset = new LLUUID((string)reader["gloves_asset"]);
+ appearance.UnderShirtItem = new LLUUID((string)reader["undershirt_item"]);
+ appearance.UnderShirtAsset = new LLUUID((string)reader["undershirt_asset"]);
+ appearance.UnderPantsItem = new LLUUID((string)reader["underpants_item"]);
+ appearance.UnderPantsAsset = new LLUUID((string)reader["underpants_asset"]);
+ appearance.SkirtItem = new LLUUID((string)reader["skirt_item"]);
+ appearance.SkirtAsset = new LLUUID((string)reader["skirt_asset"]);
+ }
return appearance;
}
@@ -1007,10 +1017,10 @@ namespace OpenSim.Data.MySQL
MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand();
cmd.CommandText = sql;
cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString());
- cmd.Parameters.AddWithValue("?serial", appearance.Serial.ToString());
+ cmd.Parameters.AddWithValue("?serial", appearance.Serial);
cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams);
cmd.Parameters.AddWithValue("?texture", appearance.Texture.ToBytes());
- cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight.ToString());
+ cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight);
cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString());
cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString());
cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString());
@@ -1037,12 +1047,10 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString());
cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString());
cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString());
-
- int x;
- if ((x = cmd.ExecuteNonQuery()) > 0)
- {
+
+ if (cmd.ExecuteNonQuery() > 0)
returnval = true;
- }
+
cmd.Dispose();
}
catch (Exception e)
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs
index 56bdcbf..35bcb1d 100644
--- a/OpenSim/Data/MySQL/MySQLUserData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserData.cs
@@ -34,8 +34,6 @@ using libsecondlife;
using log4net;
using OpenSim.Framework;
using OpenSim.Data.Base;
-using OpenSim.Data.MapperFactory;
-using OpenSim.Data.MySQLMapper;
namespace OpenSim.Data.MySQL
{
@@ -56,8 +54,6 @@ namespace OpenSim.Data.MySQL
private string m_userFriendsTableName;
private string m_appearanceTableName = "avatarappearance";
private string m_connectString;
- private BaseDatabaseConnector m_databaseMapper;
- private AppearanceTableMapper m_appearanceMapper;
///
/// Loads and initialises the MySQL storage plugin
@@ -107,15 +103,6 @@ namespace OpenSim.Data.MySQL
database = new MySQLManager(m_connectString);
}
- string mapperTypeStr = "MySQL";
- DataMapperFactory.MAPPER_TYPE mapperType =
- (DataMapperFactory.MAPPER_TYPE)
- Enum.Parse(typeof (DataMapperFactory.MAPPER_TYPE), mapperTypeStr);
-
- m_databaseMapper = DataMapperFactory.GetDataBaseMapper(mapperType, m_connectString);
-
- m_appearanceMapper = new AppearanceTableMapper(m_databaseMapper, "AvatarAppearance");
-
TestTables();
}
@@ -203,6 +190,12 @@ namespace OpenSim.Data.MySQL
{
database.ExecuteResourceSql("CreateAvatarAppearance.sql");
return;
+ }
+ else if (oldVersion.Contains("Rev.1"))
+ {
+ database.ExecuteSql("drop table avatarappearance");
+ database.ExecuteResourceSql("CreateAvatarAppearance.sql");
+ return;
}
}
@@ -676,18 +669,35 @@ namespace OpenSim.Data.MySQL
// override
override public AvatarAppearance GetUserAppearance(LLUUID user)
{
- AvatarAppearance appearance = null;
- if (!m_appearanceMapper.TryGetValue(user.UUID, out appearance))
+ try {
+ lock (database)
+ {
+ Dictionary param = new Dictionary();
+ param["?owner"] = user.ToString();
+
+ IDbCommand result = database.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param);
+ IDataReader reader = result.ExecuteReader();
+
+ AvatarAppearance appearance = database.readAppearanceRow(reader);
+
+ reader.Close();
+ result.Dispose();
+
+ return appearance;
+ }
+ }
+ catch (Exception e)
{
- appearance = null;
+ database.Reconnect();
+ m_log.Error(e.ToString());
+ return null;
}
- return appearance;
}
-
// override
override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
{
- m_appearanceMapper.Update(user.UUID, appearance);
+ appearance.Owner = user;
+ database.insertAppearanceRow(appearance);
}
override public void AddAttachment(LLUUID user, LLUUID item)
diff --git a/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql b/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql
index 0deb099..475c933 100644
--- a/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql
+++ b/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql
@@ -4,36 +4,39 @@
DROP TABLE IF EXISTS `avatarappearance`;
CREATE TABLE `avatarappearance` (
- `UUID` char(36) NOT NULL,
- `Serial` int(10) unsigned NOT NULL,
- `WearableItem0` char(36) NOT NULL,
- `WearableAsset0` char(36) NOT NULL,
- `WearableItem1` char(36) NOT NULL,
- `WearableAsset1` char(36) NOT NULL,
- `WearableItem2` char(36) NOT NULL,
- `WearableAsset2` char(36) NOT NULL,
- `WearableItem3` char(36) NOT NULL,
- `WearableAsset3` char(36) NOT NULL,
- `WearableItem4` char(36) NOT NULL,
- `WearableAsset4` char(36) NOT NULL,
- `WearableItem5` char(36) NOT NULL,
- `WearableAsset5` char(36) NOT NULL,
- `WearableItem6` char(36) NOT NULL,
- `WearableAsset6` char(36) NOT NULL,
- `WearableItem7` char(36) NOT NULL,
- `WearableAsset7` char(36) NOT NULL,
- `WearableItem8` char(36) NOT NULL,
- `WearableAsset8` char(36) NOT NULL,
- `WearableItem9` char(36) NOT NULL,
- `WearableAsset9` char(36) NOT NULL,
- `WearableItem10` char(36) NOT NULL,
- `WearableAsset10` char(36) NOT NULL,
- `WearableItem11` char(36) NOT NULL,
- `WearableAsset11` char(36) NOT NULL,
- `WearableItem12` char(36) NOT NULL,
- `WearableAsset12` char(36) NOT NULL,
+ Owner char(36) NOT NULL,
+ Serial int(10) unsigned NOT NULL,
+ Visual_Params blob NOT NULL,
+ Texture blob NOT NULL,
+ Avatar_Height float NOT NULL,
+ Body_Item char(36) NOT NULL,
+ Body_Asset char(36) NOT NULL,
+ Skin_Item char(36) NOT NULL,
+ Skin_Asset char(36) NOT NULL,
+ Hair_Item char(36) NOT NULL,
+ Hair_Asset char(36) NOT NULL,
+ Eyes_Item char(36) NOT NULL,
+ Eyes_Asset char(36) NOT NULL,
+ Shirt_Item char(36) NOT NULL,
+ Shirt_Asset char(36) NOT NULL,
+ Pants_Item char(36) NOT NULL,
+ Pants_Asset char(36) NOT NULL,
+ Shoes_Item char(36) NOT NULL,
+ Shoes_Asset char(36) NOT NULL,
+ Socks_Item char(36) NOT NULL,
+ Socks_Asset char(36) NOT NULL,
+ Jacket_Item char(36) NOT NULL,
+ Jacket_Asset char(36) NOT NULL,
+ Gloves_Item char(36) NOT NULL,
+ Gloves_Asset char(36) NOT NULL,
+ Undershirt_Item char(36) NOT NULL,
+ Undershirt_Asset char(36) NOT NULL,
+ Underpants_Item char(36) NOT NULL,
+ Underpants_Asset char(36) NOT NULL,
+ Skirt_Item char(36) NOT NULL,
+ Skirt_Asset char(36) NOT NULL,
- PRIMARY KEY (`UUID`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1';
+ PRIMARY KEY (`Owner`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.2';
diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs
index 678ec04..b757496 100644
--- a/OpenSim/Data/NHibernate/NHibernateUserData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs
@@ -306,7 +306,7 @@ namespace OpenSim.Data.NHibernate
/// Appearance
/// TODO: stubs for now to get us to a compiling state gently
- public AvatarAppearance GetUserAppearance(LLUUID user)
+ public override AvatarAppearance GetUserAppearance(LLUUID user)
{
AvatarAppearance appearance;
// TODO: I'm sure I'll have to do something silly here
@@ -328,7 +328,7 @@ namespace OpenSim.Data.NHibernate
}
- public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
+ public override void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
{
bool exists = ExistsAppearance(user);
using (ISession session = factory.OpenSession())
diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs
index d8b140c..d943f53 100644
--- a/OpenSim/Data/SQLite/SQLiteUserData.cs
+++ b/OpenSim/Data/SQLite/SQLiteUserData.cs
@@ -480,15 +480,15 @@ namespace OpenSim.Data.SQLite
/// Appearance
/// TODO: stubs for now to get us to a compiling state gently
- // override public AvatarAppearance GetUserAppearance(LLUUID user)
- // {
- // return new AvatarAppearance();
- // }
-
- // override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
- // {
- // return;
- // }
+ override public AvatarAppearance GetUserAppearance(LLUUID user)
+ {
+ return new AvatarAppearance();
+ }
+
+ override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
+ {
+ return;
+ }
override public void AddAttachment(LLUUID user, LLUUID item)
{
diff --git a/OpenSim/Data/UserDataBase.cs b/OpenSim/Data/UserDataBase.cs
index ad40bbc..cbf24a7 100644
--- a/OpenSim/Data/UserDataBase.cs
+++ b/OpenSim/Data/UserDataBase.cs
@@ -59,20 +59,22 @@ namespace OpenSim.Data
public abstract string Name {get;}
public abstract void Initialise(string connect);
public abstract List GeneratePickerResults(LLUUID queryID, string query);
- public virtual AvatarAppearance GetUserAppearance(LLUUID user) {
- AvatarAppearance aa = null;
- try {
- aa = aplist[user];
- m_log.Info("[APPEARANCE] Found appearance for " + user.ToString() + aa.ToString());
- } catch (System.Collections.Generic.KeyNotFoundException e) {
- m_log.Info("[APPEARANCE] No appearance found for " + user.ToString());
- }
- return aa;
- }
- public virtual void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) {
- aplist[user] = appearance;
- m_log.Info("[APPEARANCE] Setting appearance for " + user.ToString() + appearance.ToString());
- }
+ public abstract AvatarAppearance GetUserAppearance(LLUUID user);
+ public abstract void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance);
+ // public virtual AvatarAppearance GetUserAppearance(LLUUID user) {
+ // AvatarAppearance aa = null;
+ // try {
+ // aa = aplist[user];
+ // m_log.Info("[APPEARANCE] Found appearance for " + user.ToString() + aa.ToString());
+ // } catch (System.Collections.Generic.KeyNotFoundException e) {
+ // m_log.Info("[APPEARANCE] No appearance found for " + user.ToString());
+ // }
+ // return aa;
+ // }
+ // public virtual void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) {
+ // aplist[user] = appearance;
+ // m_log.Info("[APPEARANCE] Setting appearance for " + user.ToString() + appearance.ToString());
+ // }
public abstract void AddAttachment(LLUUID user, LLUUID item);
public abstract void RemoveAttachment(LLUUID user, LLUUID item);
public abstract List GetAttachments(LLUUID user);
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index d0b87fd..f70eb45 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -1456,8 +1456,7 @@ namespace OpenSim.Region.Environment.Scenes
SendFullUpdateToAllClients();
SendAppearanceToAllOtherAgents();
- // This is probably egregious
- m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
+ SendOwnAppearance();
}
diff --git a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs
index 37b7e8d..5c5cb17 100644
--- a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs
@@ -61,9 +61,14 @@ namespace OpenSim.Region.Modules.AvatarFactory
{
appearance = m_scene.CommsManager.UserService.GetUserAppearance(avatarId);
if (appearance != null)
+ {
return true;
+ }
else
+ {
+ m_log.InfoFormat("[APPEARANCE] appearance not found for {0}", avatarId.ToString());
return false;
+ }
// //should only let one thread at a time do this part
// EventWaitHandle waitHandle = null;
--
cgit v1.1