Fix logins and avatar appearance. Contains a Migration. May contain nuts.

This will cause visual params to be persisted along with worn items. With
this, alpha and tattoo laters will be saved. Multiple layers MAY work, but
not tested because I don't use Viewer 2.
viewer-2-initial-appearance
Melanie 2010-10-30 19:06:47 +01:00
parent 09bf9d5fca
commit e98d8d500f
7 changed files with 153 additions and 76 deletions

View File

@ -10,3 +10,11 @@ CREATE TABLE Avatars (
KEY(PrincipalID)); KEY(PrincipalID));
COMMIT; COMMIT;
:VERSION 2
BEGIN;
alter table Avatars change column Value Value text;
COMMIT;

View File

@ -150,7 +150,11 @@ namespace OpenSim.Framework
m_attachments = new Dictionary<int, List<AvatarAttachment>>(); m_attachments = new Dictionary<int, List<AvatarAttachment>>();
} }
public AvatarAppearance(AvatarAppearance appearance) public AvatarAppearance(AvatarAppearance appearance) : this(appearance, true)
{
}
public AvatarAppearance(AvatarAppearance appearance, bool copyWearables)
{ {
// m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance"); // m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance");
@ -175,7 +179,7 @@ namespace OpenSim.Framework
m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES];
for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++ ) for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++ )
m_wearables[i] = new AvatarWearable(); m_wearables[i] = new AvatarWearable();
if (appearance.Wearables != null) if (copyWearables && (appearance.Wearables != null))
{ {
for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
SetWearable(i,appearance.Wearables[i]); SetWearable(i,appearance.Wearables[i]);
@ -198,6 +202,28 @@ namespace OpenSim.Framework
AppendAttachment(new AvatarAttachment(attachment)); AppendAttachment(new AvatarAttachment(attachment));
} }
public void GetAssetsFrom(AvatarAppearance app)
{
for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++ )
{
for (int j = 0 ; j < m_wearables[i].Count ; j++)
{
UUID itemID = m_wearables[i][j].ItemID;
UUID assetID = app.Wearables[i].GetAsset(itemID);
if (assetID != UUID.Zero)
m_wearables[i].Add(itemID, assetID);
}
}
}
public void ClearWearables()
{
m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES];
for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++ )
m_wearables[i] = new AvatarWearable();
}
protected virtual void SetDefaultWearables() protected virtual void SetDefaultWearables()
{ {
m_wearables = AvatarWearable.DefaultWearables; m_wearables = AvatarWearable.DefaultWearables;
@ -205,11 +231,11 @@ namespace OpenSim.Framework
protected virtual void SetDefaultParams() protected virtual void SetDefaultParams()
{ {
m_visualparams = new byte[VISUALPARAM_COUNT]; m_visualparams = new byte[] { 56,23,66,0,0,25,0,124,107,0,0,91,137,36,180,79,78,20,32,255,0,63,137,137,63,122,0,71,127,94,63,0,150,150,150,17,0,0,0,0,0,127,0,0,255,127,114,127,99,63,127,140,127,127,0,0,0,191,0,78,0,0,0,0,0,0,0,0,0,145,216,133,0,0,0,219,107,150,150,165,135,0,150,150,150,63,112,155,150,150,150,150,150,150,150,150,150,150,150,0,0,0,0,188,255,91,219,124,0,150,127,165,127,127,127,127,59,63,107,71,68,89,33,79,114,178,127,2,141,66,0,0,127,127,0,0,0,0,127,0,159,0,0,178,127,0,85,131,117,127,147,163,104,0,140,18,0,107,130,0,150,150,198,0,0,40,38,91,165,209,198,127,127,153,204,51,51,150,150,255,204,0,150,150,150,150,150,150,150,150,150,150,150,0,150,150,150,150,150,0,127,22,150,150,150,150,150,150,150,150,0,0,150,51,132,150,150,150 };
for (int i = 0; i < VISUALPARAM_COUNT; i++) // for (int i = 0; i < VISUALPARAM_COUNT; i++)
{ // {
m_visualparams[i] = 150; // m_visualparams[i] = 150;
} // }
} }
protected virtual void SetDefaultTexture() protected virtual void SetDefaultTexture()

View File

@ -82,12 +82,13 @@ namespace OpenSim.Framework
public static readonly UUID DEFAULT_PANTS_ITEM = new UUID("77c41e39-38f9-f75a-0000-5859892f1111"); public static readonly UUID DEFAULT_PANTS_ITEM = new UUID("77c41e39-38f9-f75a-0000-5859892f1111");
public static readonly UUID DEFAULT_PANTS_ASSET = new UUID("00000000-38f9-1111-024e-222222111120"); public static readonly UUID DEFAULT_PANTS_ASSET = new UUID("00000000-38f9-1111-024e-222222111120");
public static readonly UUID DEFAULT_ALPHA_ITEM = new UUID("bfb9923c-4838-4d2d-bf07-608c5b1165c8"); // public static readonly UUID DEFAULT_ALPHA_ITEM = new UUID("bfb9923c-4838-4d2d-bf07-608c5b1165c8");
public static readonly UUID DEFAULT_ALPHA_ASSET = new UUID("1578a2b1-5179-4b53-b618-fe00ca5a5594"); // public static readonly UUID DEFAULT_ALPHA_ASSET = new UUID("1578a2b1-5179-4b53-b618-fe00ca5a5594");
public static readonly UUID DEFAULT_TATTOO_ITEM = new UUID("c47e22bd-3021-4ba4-82aa-2b5cb34d35e1"); // public static readonly UUID DEFAULT_TATTOO_ITEM = new UUID("c47e22bd-3021-4ba4-82aa-2b5cb34d35e1");
public static readonly UUID DEFAULT_TATTOO_ASSET = new UUID("00000000-0000-2222-3333-100000001007"); // public static readonly UUID DEFAULT_TATTOO_ASSET = new UUID("00000000-0000-2222-3333-100000001007");
private static AvatarWearable[] defaultWearables = null;
protected Dictionary<UUID, UUID> m_items = new Dictionary<UUID, UUID>(); protected Dictionary<UUID, UUID> m_items = new Dictionary<UUID, UUID>();
protected List<UUID> m_ids = new List<UUID>(); protected List<UUID> m_ids = new List<UUID>();
@ -152,6 +153,11 @@ namespace OpenSim.Framework
m_items[itemID] = assetID; m_items[itemID] = assetID;
} }
public void Wear(WearableItem item)
{
Wear(item.ItemID, item.AssetID);
}
public void Wear(UUID itemID, UUID assetID) public void Wear(UUID itemID, UUID assetID)
{ {
Clear(); Clear();
@ -204,11 +210,21 @@ namespace OpenSim.Framework
} }
} }
public UUID GetAsset(UUID itemID)
{
if (!m_items.ContainsKey(itemID))
return UUID.Zero;
return m_items[itemID];
}
public static AvatarWearable[] DefaultWearables public static AvatarWearable[] DefaultWearables
{ {
get get
{ {
AvatarWearable[] defaultWearables = new AvatarWearable[MAX_WEARABLES]; //should be 15 of these if (defaultWearables != null)
return defaultWearables;
defaultWearables = new AvatarWearable[MAX_WEARABLES]; //should be 15 of these
for (int i = 0; i < MAX_WEARABLES; i++) for (int i = 0; i < MAX_WEARABLES; i++)
{ {
defaultWearables[i] = new AvatarWearable(); defaultWearables[i] = new AvatarWearable();
@ -229,11 +245,11 @@ namespace OpenSim.Framework
// Pants // Pants
defaultWearables[PANTS].Add(DEFAULT_PANTS_ITEM, DEFAULT_PANTS_ASSET); defaultWearables[PANTS].Add(DEFAULT_PANTS_ITEM, DEFAULT_PANTS_ASSET);
// Alpha // // Alpha
defaultWearables[ALPHA].Add(DEFAULT_ALPHA_ITEM, DEFAULT_ALPHA_ASSET); // defaultWearables[ALPHA].Add(DEFAULT_ALPHA_ITEM, DEFAULT_ALPHA_ASSET);
// Tattoo // // Tattoo
defaultWearables[TATTOO].Add(DEFAULT_TATTOO_ITEM, DEFAULT_TATTOO_ASSET); // defaultWearables[TATTOO].Add(DEFAULT_TATTOO_ITEM, DEFAULT_TATTOO_ASSET);
return defaultWearables; return defaultWearables;
} }

View File

@ -5734,6 +5734,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
AvatarWearingArgs wearingArgs = new AvatarWearingArgs(); AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
for (int i = 0; i < nowWearing.WearableData.Length; i++) for (int i = 0; i < nowWearing.WearableData.Length; i++)
{ {
m_log.DebugFormat("[XXX]: Wearable type {0} item {1}", nowWearing.WearableData[i].WearableType, nowWearing.WearableData[i].ItemID);
AvatarWearingArgs.Wearable wearable = AvatarWearingArgs.Wearable wearable =
new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID, new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
nowWearing.WearableData[i].WearableType); nowWearing.WearableData[i].WearableType);

View File

@ -356,17 +356,16 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// m_log.WarnFormat("[AVATAR FACTORY MODULE]: AvatarIsWearing called for {0}",client.AgentId); // m_log.WarnFormat("[AVATAR FACTORY MODULE]: AvatarIsWearing called for {0}",client.AgentId);
AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance); AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false);
foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
{ {
if (wear.Type < AvatarWearable.MAX_WEARABLES) if (wear.Type < AvatarWearable.MAX_WEARABLES)
{ avatAppearance.Wearables[wear.Type].Add(wear.ItemID,UUID.Zero);
AvatarWearable newWearable = new AvatarWearable(wear.ItemID,UUID.Zero);
avatAppearance.SetWearable(wear.Type, newWearable);
}
} }
avatAppearance.GetAssetsFrom(sp.Appearance);
// This could take awhile since it needs to pull inventory // This could take awhile since it needs to pull inventory
SetAppearanceAssets(sp.UUID, ref avatAppearance); SetAppearanceAssets(sp.UUID, ref avatAppearance);
@ -384,6 +383,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{ {
for (int j = 0 ; j < appearance.Wearables[j].Count ; j ++ ) for (int j = 0 ; j < appearance.Wearables[j].Count ; j ++ )
{ {
if (appearance.Wearables[i][j].ItemID == UUID.Zero)
continue;
// Ignore ruth's assets
if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID)
continue;
InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID);
baseItem = invService.GetItem(baseItem); baseItem = invService.GetItem(baseItem);

View File

@ -149,33 +149,28 @@ namespace OpenSim.Services.Interfaces
Data["Serial"] = appearance.Serial.ToString(); Data["Serial"] = appearance.Serial.ToString();
// Wearables // Wearables
Data["AvatarHeight"] = appearance.AvatarHeight.ToString(); Data["AvatarHeight"] = appearance.AvatarHeight.ToString();
Data["BodyItem"] = appearance.Wearables[AvatarWearable.BODY][0].ItemID.ToString();
Data["EyesItem"] = appearance.Wearables[AvatarWearable.EYES][0].ItemID.ToString();
Data["GlovesItem"] = appearance.Wearables[AvatarWearable.GLOVES][0].ItemID.ToString();
Data["HairItem"] = appearance.Wearables[AvatarWearable.HAIR][0].ItemID.ToString();
Data["JacketItem"] = appearance.Wearables[AvatarWearable.JACKET][0].ItemID.ToString();
Data["PantsItem"] = appearance.Wearables[AvatarWearable.PANTS][0].ItemID.ToString();
Data["ShirtItem"] = appearance.Wearables[AvatarWearable.SHIRT][0].ItemID.ToString();
Data["ShoesItem"] = appearance.Wearables[AvatarWearable.SHOES][0].ItemID.ToString();
Data["SkinItem"] = appearance.Wearables[AvatarWearable.SKIN][0].ItemID.ToString();
Data["SkirtItem"] = appearance.Wearables[AvatarWearable.SKIRT][0].ItemID.ToString();
Data["SocksItem"] = appearance.Wearables[AvatarWearable.SOCKS][0].ItemID.ToString();
Data["UnderPantsItem"] = appearance.Wearables[AvatarWearable.UNDERPANTS][0].ItemID.ToString();
Data["UnderShirtItem"] = appearance.Wearables[AvatarWearable.UNDERSHIRT][0].ItemID.ToString();
Data["BodyAsset"] = appearance.Wearables[AvatarWearable.BODY][0].AssetID.ToString(); for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++)
Data["EyesAsset"] = appearance.Wearables[AvatarWearable.EYES][0].AssetID.ToString(); {
Data["GlovesAsset"] = appearance.Wearables[AvatarWearable.GLOVES][0].AssetID.ToString(); for (int j = 0 ; j < appearance.Wearables[i].Count ; j++)
Data["HairAsset"] = appearance.Wearables[AvatarWearable.HAIR][0].AssetID.ToString(); {
Data["JacketAsset"] = appearance.Wearables[AvatarWearable.JACKET][0].AssetID.ToString(); string fieldName = String.Format("Wearable {0}:{1}", i, j);
Data["PantsAsset"] = appearance.Wearables[AvatarWearable.PANTS][0].AssetID.ToString(); Data[fieldName] = String.Format("{0}:{1}",
Data["ShirtAsset"] = appearance.Wearables[AvatarWearable.SHIRT][0].AssetID.ToString(); appearance.Wearables[i][j].ItemID.ToString(),
Data["ShoesAsset"] = appearance.Wearables[AvatarWearable.SHOES][0].AssetID.ToString(); appearance.Wearables[i][j].AssetID.ToString());
Data["SkinAsset"] = appearance.Wearables[AvatarWearable.SKIN][0].AssetID.ToString(); }
Data["SkirtAsset"] = appearance.Wearables[AvatarWearable.SKIRT][0].AssetID.ToString(); }
Data["SocksAsset"] = appearance.Wearables[AvatarWearable.SOCKS][0].AssetID.ToString();
Data["UnderPantsAsset"] = appearance.Wearables[AvatarWearable.UNDERPANTS][0].AssetID.ToString(); // Visual Params
Data["UnderShirtAsset"] = appearance.Wearables[AvatarWearable.UNDERSHIRT][0].AssetID.ToString(); string[] vps = new string[AvatarAppearance.VISUALPARAM_COUNT];
byte[] binary = appearance.VisualParams;
for (int i = 0 ; i < AvatarAppearance.VISUALPARAM_COUNT ; i++)
{
vps[i] = binary[i].ToString();
}
Data["VisualParams"] = String.Join(",", vps);
// Attachments // Attachments
List<AvatarAttachment> attachments = appearance.GetAttachments(); List<AvatarAttachment> attachments = appearance.GetAttachments();
@ -188,12 +183,17 @@ namespace OpenSim.Services.Interfaces
public AvatarAppearance ToAvatarAppearance(UUID owner) public AvatarAppearance ToAvatarAppearance(UUID owner)
{ {
AvatarAppearance appearance = new AvatarAppearance(owner); AvatarAppearance appearance = new AvatarAppearance(owner);
if (Data.Count == 0)
return appearance;
appearance.ClearWearables();
try try
{ {
if (Data.ContainsKey("Serial")) if (Data.ContainsKey("Serial"))
appearance.Serial = Int32.Parse(Data["Serial"]); appearance.Serial = Int32.Parse(Data["Serial"]);
// Wearables // Legacy Wearables
if (Data.ContainsKey("BodyItem")) if (Data.ContainsKey("BodyItem"))
appearance.Wearables[AvatarWearable.BODY].Wear( appearance.Wearables[AvatarWearable.BODY].Wear(
UUID.Parse(Data["BodyItem"]), UUID.Parse(Data["BodyItem"]),
@ -260,6 +260,35 @@ namespace OpenSim.Services.Interfaces
UUID.Parse(Data["SkirtAsset"])); UUID.Parse(Data["SkirtAsset"]));
if (Data.ContainsKey("VisualParams"))
{
string[] vps = Data["VisualParams"].Split(new char[] {','});
byte[] binary = new byte[AvatarAppearance.VISUALPARAM_COUNT];
for (int i = 0 ; i < vps.Length && i < binary.Length ; i++)
binary[i] = (byte)Convert.ToInt32(vps[i]);
appearance.VisualParams = binary;
}
// New style wearables
foreach (KeyValuePair<string, string> _kvp in Data)
{
if (_kvp.Key.StartsWith("Wearable "))
{
string wearIndex = _kvp.Key.Substring(9);
string[] wearIndices = wearIndex.Split(new char[] {':'});
int index = Convert.ToInt32(wearIndices[0]);
string[] ids = _kvp.Value.Split(new char[] {':'});
UUID itemID = new UUID(ids[0]);
UUID assetID = new UUID(ids[1]);
appearance.Wearables[index].Add(itemID, assetID);
}
}
// Attachments // Attachments
Dictionary<string, string> attchs = new Dictionary<string, string>(); Dictionary<string, string> attchs = new Dictionary<string, string>();
foreach (KeyValuePair<string, string> _kvp in Data) foreach (KeyValuePair<string, string> _kvp in Data)
@ -278,6 +307,26 @@ namespace OpenSim.Services.Interfaces
appearance.SetAttachment(point,uuid,UUID.Zero); appearance.SetAttachment(point,uuid,UUID.Zero);
} }
if (appearance.Wearables[AvatarWearable.BODY].Count == 0)
appearance.Wearables[AvatarWearable.BODY].Wear(
AvatarWearable.DefaultWearables[
AvatarWearable.BODY][0]);
if (appearance.Wearables[AvatarWearable.SKIN].Count == 0)
appearance.Wearables[AvatarWearable.SKIN].Wear(
AvatarWearable.DefaultWearables[
AvatarWearable.SKIN][0]);
if (appearance.Wearables[AvatarWearable.HAIR].Count == 0)
appearance.Wearables[AvatarWearable.HAIR].Wear(
AvatarWearable.DefaultWearables[
AvatarWearable.HAIR][0]);
if (appearance.Wearables[AvatarWearable.EYES].Count == 0)
appearance.Wearables[AvatarWearable.EYES].Wear(
AvatarWearable.DefaultWearables[
AvatarWearable.EYES][0]);
} }
catch catch
{ {

View File

@ -16,34 +16,6 @@
</Section> </Section>
--> -->
<!-- <!--
<Section Name="Tattoo">
<Key Name="inventoryID" Value="c47e22bd-3021-4ba4-82aa-2b5cb34d35e1" />
<Key Name="assetID" Value="00000000-0000-2222-3333-100000001007" />
<Key Name="folderID" Value="d499e5e0-b9bf-11dc-95ff-0800200c9a66"/>
<Key Name="description" Value="Tattoo" />
<Key Name="name" Value="Tattoo" />
<Key Name="assetType" Value="13" />
<Key Name="inventoryType" Value="18" />
<Key Name="currentPermissions" Value="2147483647" />
<Key Name="nextPermissions" Value="2147483647" />
<Key Name="everyonePermissions" Value="2147483647" />
<Key Name="basePermissions" Value="2147483647" />
</Section>
<Section Name="Alpha">
<Key Name="inventoryID" Value="bfb9923c-4838-4d2d-bf07-608c5b1165c8" />
<Key Name="assetID" Value="1578a2b1-5179-4b53-b618-fe00ca5a5594" />
<Key Name="folderID" Value="d499e5e0-b9bf-11dc-95ff-0800200c9a66"/>
<Key Name="description" Value="Hair" />
<Key Name="name" Value="Hair" />
<Key Name="assetType" Value="13" />
<Key Name="inventoryType" Value="18" />
<Key Name="currentPermissions" Value="2147483647" />
<Key Name="nextPermissions" Value="2147483647" />
<Key Name="everyonePermissions" Value="2147483647" />
<Key Name="basePermissions" Value="2147483647" />
</Section>
<Section Name="Hair"> <Section Name="Hair">
<Key Name="inventoryID" Value="d342e6c1-b9d2-11dc-95ff-0800200c9a66" /> <Key Name="inventoryID" Value="d342e6c1-b9d2-11dc-95ff-0800200c9a66" />
<Key Name="assetID" Value="d342e6c0-b9d2-11dc-95ff-0800200c9a66" /> <Key Name="assetID" Value="d342e6c0-b9d2-11dc-95ff-0800200c9a66" />