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.
0.6.0-stable
Sean Dague 2008-05-21 18:02:09 +00:00
parent 0b719286a4
commit 53bcf2139e
9 changed files with 151 additions and 124 deletions

View File

@ -747,15 +747,15 @@ namespace OpenSim.Data.MSSQL
/// Appearance /// Appearance
/// TODO: stubs for now to get us to a compiling state gently /// TODO: stubs for now to get us to a compiling state gently
// override public AvatarAppearance GetUserAppearance(LLUUID user) override public AvatarAppearance GetUserAppearance(LLUUID user)
// { {
// return new AvatarAppearance(); return new AvatarAppearance();
// } }
// override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
// { {
// return; return;
// } }
override public void AddAttachment(LLUUID user, LLUUID item) override public void AddAttachment(LLUUID user, LLUUID item)
{ {

View File

@ -191,6 +191,12 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
public void ExecuteSql(string sql)
{
MySqlCommand cmd = new MySqlCommand(sql, dbcon);
cmd.ExecuteNonQuery();
}
/// <summary> /// <summary>
/// Given a list of tables, return the version of the tables, as seen in the database /// Given a list of tables, return the version of the tables, as seen in the database
/// </summary> /// </summary>
@ -532,38 +538,42 @@ namespace OpenSim.Data.MySQL
public AvatarAppearance readAppearanceRow(IDataReader reader) public AvatarAppearance readAppearanceRow(IDataReader reader)
{ {
AvatarAppearance appearance = new AvatarAppearance(); AvatarAppearance appearance = null;
appearance.Owner = new LLUUID((string)reader["owner"]); if (reader.Read())
appearance.Serial = Convert.ToInt32(reader["serial"]); {
appearance.VisualParams = (byte[])reader["visual_params"]; appearance = new AvatarAppearance();
appearance.Texture = new LLObject.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length); appearance.Owner = new LLUUID((string)reader["owner"]);
appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]); appearance.Serial = Convert.ToInt32(reader["serial"]);
appearance.BodyItem = new LLUUID((string)reader["body_item"]); appearance.VisualParams = (byte[])reader["visual_params"];
appearance.BodyAsset = new LLUUID((string)reader["body_asset"]); appearance.Texture = new LLObject.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length);
appearance.SkinItem = new LLUUID((string)reader["skin_item"]); appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]);
appearance.SkinAsset = new LLUUID((string)reader["skin_asset"]); appearance.BodyItem = new LLUUID((string)reader["body_item"]);
appearance.HairItem = new LLUUID((string)reader["hair_item"]); appearance.BodyAsset = new LLUUID((string)reader["body_asset"]);
appearance.HairAsset = new LLUUID((string)reader["hair_asset"]); appearance.SkinItem = new LLUUID((string)reader["skin_item"]);
appearance.EyesItem = new LLUUID((string)reader["eyes_item"]); appearance.SkinAsset = new LLUUID((string)reader["skin_asset"]);
appearance.EyesAsset = new LLUUID((string)reader["eyes_asset"]); appearance.HairItem = new LLUUID((string)reader["hair_item"]);
appearance.ShirtItem = new LLUUID((string)reader["shirt_item"]); appearance.HairAsset = new LLUUID((string)reader["hair_asset"]);
appearance.ShirtAsset = new LLUUID((string)reader["shirt_asset"]); appearance.EyesItem = new LLUUID((string)reader["eyes_item"]);
appearance.PantsItem = new LLUUID((string)reader["pants_item"]); appearance.EyesAsset = new LLUUID((string)reader["eyes_asset"]);
appearance.PantsAsset = new LLUUID((string)reader["pants_asset"]); appearance.ShirtItem = new LLUUID((string)reader["shirt_item"]);
appearance.ShoesItem = new LLUUID((string)reader["shoes_item"]); appearance.ShirtAsset = new LLUUID((string)reader["shirt_asset"]);
appearance.ShoesAsset = new LLUUID((string)reader["shoes_asset"]); appearance.PantsItem = new LLUUID((string)reader["pants_item"]);
appearance.SocksItem = new LLUUID((string)reader["socks_item"]); appearance.PantsAsset = new LLUUID((string)reader["pants_asset"]);
appearance.SocksAsset = new LLUUID((string)reader["socks_asset"]); appearance.ShoesItem = new LLUUID((string)reader["shoes_item"]);
appearance.JacketItem = new LLUUID((string)reader["jacket_item"]); appearance.ShoesAsset = new LLUUID((string)reader["shoes_asset"]);
appearance.JacketAsset = new LLUUID((string)reader["jacket_asset"]); appearance.SocksItem = new LLUUID((string)reader["socks_item"]);
appearance.GlovesItem = new LLUUID((string)reader["gloves_item"]); appearance.SocksAsset = new LLUUID((string)reader["socks_asset"]);
appearance.GlovesAsset = new LLUUID((string)reader["gloves_asset"]); appearance.JacketItem = new LLUUID((string)reader["jacket_item"]);
appearance.UnderShirtItem = new LLUUID((string)reader["undershirt_item"]); appearance.JacketAsset = new LLUUID((string)reader["jacket_asset"]);
appearance.UnderShirtAsset = new LLUUID((string)reader["undershirt_asset"]); appearance.GlovesItem = new LLUUID((string)reader["gloves_item"]);
appearance.UnderPantsItem = new LLUUID((string)reader["underpants_item"]); appearance.GlovesAsset = new LLUUID((string)reader["gloves_asset"]);
appearance.UnderPantsAsset = new LLUUID((string)reader["underpants_asset"]); appearance.UnderShirtItem = new LLUUID((string)reader["undershirt_item"]);
appearance.SkirtItem = new LLUUID((string)reader["skirt_item"]); appearance.UnderShirtAsset = new LLUUID((string)reader["undershirt_asset"]);
appearance.SkirtAsset = new LLUUID((string)reader["skirt_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; return appearance;
} }
@ -1007,10 +1017,10 @@ namespace OpenSim.Data.MySQL
MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand();
cmd.CommandText = sql; cmd.CommandText = sql;
cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString()); 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("?visual_params", appearance.VisualParams);
cmd.Parameters.AddWithValue("?texture", appearance.Texture.ToBytes()); 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_item", appearance.BodyItem.ToString());
cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString()); cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString());
cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString()); cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString());
@ -1038,11 +1048,9 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString());
cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString());
int x; if (cmd.ExecuteNonQuery() > 0)
if ((x = cmd.ExecuteNonQuery()) > 0)
{
returnval = true; returnval = true;
}
cmd.Dispose(); cmd.Dispose();
} }
catch (Exception e) catch (Exception e)

View File

@ -34,8 +34,6 @@ using libsecondlife;
using log4net; using log4net;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Data.Base; using OpenSim.Data.Base;
using OpenSim.Data.MapperFactory;
using OpenSim.Data.MySQLMapper;
namespace OpenSim.Data.MySQL namespace OpenSim.Data.MySQL
{ {
@ -56,8 +54,6 @@ namespace OpenSim.Data.MySQL
private string m_userFriendsTableName; private string m_userFriendsTableName;
private string m_appearanceTableName = "avatarappearance"; private string m_appearanceTableName = "avatarappearance";
private string m_connectString; private string m_connectString;
private BaseDatabaseConnector m_databaseMapper;
private AppearanceTableMapper m_appearanceMapper;
/// <summary> /// <summary>
/// Loads and initialises the MySQL storage plugin /// Loads and initialises the MySQL storage plugin
@ -107,15 +103,6 @@ namespace OpenSim.Data.MySQL
database = new MySQLManager(m_connectString); 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(); TestTables();
} }
@ -204,6 +191,12 @@ namespace OpenSim.Data.MySQL
database.ExecuteResourceSql("CreateAvatarAppearance.sql"); database.ExecuteResourceSql("CreateAvatarAppearance.sql");
return; return;
} }
else if (oldVersion.Contains("Rev.1"))
{
database.ExecuteSql("drop table avatarappearance");
database.ExecuteResourceSql("CreateAvatarAppearance.sql");
return;
}
} }
#endregion #endregion
@ -676,18 +669,35 @@ namespace OpenSim.Data.MySQL
// override // override
override public AvatarAppearance GetUserAppearance(LLUUID user) override public AvatarAppearance GetUserAppearance(LLUUID user)
{ {
AvatarAppearance appearance = null; try {
if (!m_appearanceMapper.TryGetValue(user.UUID, out appearance)) lock (database)
{ {
appearance = null; Dictionary<string, string> param = new Dictionary<string, string>();
} param["?owner"] = user.ToString();
return appearance;
}
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)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
}
// override // override
override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) 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) override public void AddAttachment(LLUUID user, LLUUID item)

View File

@ -4,36 +4,39 @@
DROP TABLE IF EXISTS `avatarappearance`; DROP TABLE IF EXISTS `avatarappearance`;
CREATE TABLE `avatarappearance` ( CREATE TABLE `avatarappearance` (
`UUID` char(36) NOT NULL, Owner char(36) NOT NULL,
`Serial` int(10) unsigned NOT NULL, Serial int(10) unsigned NOT NULL,
`WearableItem0` char(36) NOT NULL, Visual_Params blob NOT NULL,
`WearableAsset0` char(36) NOT NULL, Texture blob NOT NULL,
`WearableItem1` char(36) NOT NULL, Avatar_Height float NOT NULL,
`WearableAsset1` char(36) NOT NULL, Body_Item char(36) NOT NULL,
`WearableItem2` char(36) NOT NULL, Body_Asset char(36) NOT NULL,
`WearableAsset2` char(36) NOT NULL, Skin_Item char(36) NOT NULL,
`WearableItem3` char(36) NOT NULL, Skin_Asset char(36) NOT NULL,
`WearableAsset3` char(36) NOT NULL, Hair_Item char(36) NOT NULL,
`WearableItem4` char(36) NOT NULL, Hair_Asset char(36) NOT NULL,
`WearableAsset4` char(36) NOT NULL, Eyes_Item char(36) NOT NULL,
`WearableItem5` char(36) NOT NULL, Eyes_Asset char(36) NOT NULL,
`WearableAsset5` char(36) NOT NULL, Shirt_Item char(36) NOT NULL,
`WearableItem6` char(36) NOT NULL, Shirt_Asset char(36) NOT NULL,
`WearableAsset6` char(36) NOT NULL, Pants_Item char(36) NOT NULL,
`WearableItem7` char(36) NOT NULL, Pants_Asset char(36) NOT NULL,
`WearableAsset7` char(36) NOT NULL, Shoes_Item char(36) NOT NULL,
`WearableItem8` char(36) NOT NULL, Shoes_Asset char(36) NOT NULL,
`WearableAsset8` char(36) NOT NULL, Socks_Item char(36) NOT NULL,
`WearableItem9` char(36) NOT NULL, Socks_Asset char(36) NOT NULL,
`WearableAsset9` char(36) NOT NULL, Jacket_Item char(36) NOT NULL,
`WearableItem10` char(36) NOT NULL, Jacket_Asset char(36) NOT NULL,
`WearableAsset10` char(36) NOT NULL, Gloves_Item char(36) NOT NULL,
`WearableItem11` char(36) NOT NULL, Gloves_Asset char(36) NOT NULL,
`WearableAsset11` char(36) NOT NULL, Undershirt_Item char(36) NOT NULL,
`WearableItem12` char(36) NOT NULL, Undershirt_Asset char(36) NOT NULL,
`WearableAsset12` 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`) PRIMARY KEY (`Owner`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.2';

View File

@ -306,7 +306,7 @@ namespace OpenSim.Data.NHibernate
/// Appearance /// Appearance
/// TODO: stubs for now to get us to a compiling state gently /// 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; AvatarAppearance appearance;
// TODO: I'm sure I'll have to do something silly here // 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); bool exists = ExistsAppearance(user);
using (ISession session = factory.OpenSession()) using (ISession session = factory.OpenSession())

View File

@ -480,15 +480,15 @@ namespace OpenSim.Data.SQLite
/// Appearance /// Appearance
/// TODO: stubs for now to get us to a compiling state gently /// TODO: stubs for now to get us to a compiling state gently
// override public AvatarAppearance GetUserAppearance(LLUUID user) override public AvatarAppearance GetUserAppearance(LLUUID user)
// { {
// return new AvatarAppearance(); return new AvatarAppearance();
// } }
// override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
// { {
// return; return;
// } }
override public void AddAttachment(LLUUID user, LLUUID item) override public void AddAttachment(LLUUID user, LLUUID item)
{ {

View File

@ -59,20 +59,22 @@ namespace OpenSim.Data
public abstract string Name {get;} public abstract string Name {get;}
public abstract void Initialise(string connect); public abstract void Initialise(string connect);
public abstract List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query); public abstract List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query);
public virtual AvatarAppearance GetUserAppearance(LLUUID user) { public abstract AvatarAppearance GetUserAppearance(LLUUID user);
AvatarAppearance aa = null; public abstract void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance);
try { // public virtual AvatarAppearance GetUserAppearance(LLUUID user) {
aa = aplist[user]; // AvatarAppearance aa = null;
m_log.Info("[APPEARANCE] Found appearance for " + user.ToString() + aa.ToString()); // try {
} catch (System.Collections.Generic.KeyNotFoundException e) { // aa = aplist[user];
m_log.Info("[APPEARANCE] No appearance found for " + user.ToString()); // m_log.Info("[APPEARANCE] Found appearance for " + user.ToString() + aa.ToString());
} // } catch (System.Collections.Generic.KeyNotFoundException e) {
return aa; // m_log.Info("[APPEARANCE] No appearance found for " + user.ToString());
} // }
public virtual void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) { // return aa;
aplist[user] = appearance; // }
m_log.Info("[APPEARANCE] Setting appearance for " + user.ToString() + appearance.ToString()); // 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 AddAttachment(LLUUID user, LLUUID item);
public abstract void RemoveAttachment(LLUUID user, LLUUID item); public abstract void RemoveAttachment(LLUUID user, LLUUID item);
public abstract List<LLUUID> GetAttachments(LLUUID user); public abstract List<LLUUID> GetAttachments(LLUUID user);

View File

@ -1456,8 +1456,7 @@ namespace OpenSim.Region.Environment.Scenes
SendFullUpdateToAllClients(); SendFullUpdateToAllClients();
SendAppearanceToAllOtherAgents(); SendAppearanceToAllOtherAgents();
// This is probably egregious SendOwnAppearance();
m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
} }

View File

@ -61,9 +61,14 @@ namespace OpenSim.Region.Modules.AvatarFactory
{ {
appearance = m_scene.CommsManager.UserService.GetUserAppearance(avatarId); appearance = m_scene.CommsManager.UserService.GetUserAppearance(avatarId);
if (appearance != null) if (appearance != null)
{
return true; return true;
}
else else
{
m_log.InfoFormat("[APPEARANCE] appearance not found for {0}", avatarId.ToString());
return false; return false;
}
// //should only let one thread at a time do this part // //should only let one thread at a time do this part
// EventWaitHandle waitHandle = null; // EventWaitHandle waitHandle = null;