diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 231c0dc54e..729fd9a2e6 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1801,8 +1801,7 @@ namespace OpenSim.Region.Environment.Scenes !m_AvatarFactory.TryGetAvatarAppearance(client.AgentId, out appearance)) { // not found Appearance - m_log.Warn("[AVATAR DEBUGGING]: Couldn't fetch avatar appearance from factory, please report this to the opensim mantis"); - appearance = new AvatarAppearance(); + m_log.Warn("[APPEARANCE]: Appearance not found, creating default"); } } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 1aa800ab2a..0dbd6dd085 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -1466,11 +1466,11 @@ namespace OpenSim.Region.Environment.Scenes { m_log.Info("[APPEARANCE] Sending Own Appearance"); ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); - ControllingClient.SendAppearance( - m_appearance.Owner, - m_appearance.VisualParams, - m_appearance.Texture.ToBytes() - ); + // ControllingClient.SendAppearance( + // m_appearance.Owner, + // m_appearance.VisualParams, + // m_appearance.Texture.ToBytes() + // ); } /// diff --git a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs index 4b8eee76a3..e66113d774 100644 --- a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs @@ -46,20 +46,25 @@ namespace OpenSim.Region.Modules.AvatarFactory { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene = null; + private static readonly AvatarAppearance def = new AvatarAppearance(); public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance) { - appearance = m_scene.CommsManager.UserService.GetUserAppearance(avatarId); - if (appearance != null) + CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(avatarId); + if ((profile != null) && (profile.RootFolder != null)) { - m_log.InfoFormat("[APPEARANCE] found : {0}", appearance.ToString()); - return true; - } - else - { - m_log.InfoFormat("[APPEARANCE] appearance not found for {0}", avatarId.ToString()); - return false; + appearance = m_scene.CommsManager.UserService.GetUserAppearance(avatarId); + if (appearance != null) + { + SetAppearanceAssets(profile, ref appearance); + m_log.InfoFormat("[APPEARANCE] found : {0}", appearance.ToString()); + return true; + } } + + appearance = CreateDefault(avatarId); + m_log.InfoFormat("[APPEARANCE] appearance not found for {0}, creating default", avatarId.ToString()); + return false; } private AvatarAppearance CreateDefault(LLUUID avatarId) @@ -113,6 +118,41 @@ namespace OpenSim.Region.Modules.AvatarFactory // client.OnAvatarNowWearing -= AvatarIsWearing; } + + public void SetAppearanceAssets(CachedUserInfo profile, ref AvatarAppearance appearance) + { + if (profile.RootFolder != null) + { + for (int i = 0; i < 13; i++) + { + if (appearance.Wearables[i].ItemID == LLUUID.Zero) + { + appearance.Wearables[i].AssetID = LLUUID.Zero; + } + else + { + LLUUID assetId; + + InventoryItemBase baseItem = profile.RootFolder.FindItem(appearance.Wearables[i].ItemID); + + if (baseItem != null) + { + appearance.Wearables[i].AssetID = baseItem.AssetID; + } + else + { + m_log.ErrorFormat("[APPEARANCE] Can't find inventory item {0}, setting to default", appearance.Wearables[i].ItemID); + appearance.Wearables[i].AssetID = def.Wearables[i].AssetID; + } + } + } + } + else + { + m_log.Error("[APPEARANCE] you have no inventory, appearance stuff isn't going to work"); + } + } + public void AvatarIsWearing(Object sender, AvatarWearingArgs e) { IClientAPI clientView = (IClientAPI)sender; @@ -138,30 +178,11 @@ namespace OpenSim.Region.Modules.AvatarFactory { if (wear.Type < 13) { - if (wear.ItemID == LLUUID.Zero) - { - avatAppearance.Wearables[wear.Type].ItemID = LLUUID.Zero; - avatAppearance.Wearables[wear.Type].AssetID = LLUUID.Zero; - } - else - { - LLUUID assetId; - - InventoryItemBase baseItem = profile.RootFolder.FindItem(wear.ItemID); - - if (baseItem != null) - { - assetId = baseItem.AssetID; - avatAppearance.Wearables[wear.Type].AssetID = assetId; - avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID; - } - else - { - m_log.ErrorFormat("[APPEARANCE] Can't find inventory item {0}, not wearing", wear.ItemID); - } - } + avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID; } } + SetAppearanceAssets(profile, ref avatAppearance); + m_scene.CommsManager.UserService.UpdateUserAppearance(clientView.AgentId, avatAppearance); avatar.Appearance = avatAppearance; }