don't trust appearance assetid, instead do an inventory
lookup any time we get it from the server. This should preventent unwearable appearance.0.6.0-stable
parent
811cd3e0bf
commit
1c49752a44
|
@ -1801,8 +1801,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
!m_AvatarFactory.TryGetAvatarAppearance(client.AgentId, out appearance))
|
!m_AvatarFactory.TryGetAvatarAppearance(client.AgentId, out appearance))
|
||||||
{
|
{
|
||||||
// not found Appearance
|
// not found Appearance
|
||||||
m_log.Warn("[AVATAR DEBUGGING]: Couldn't fetch avatar appearance from factory, please report this to the opensim mantis");
|
m_log.Warn("[APPEARANCE]: Appearance not found, creating default");
|
||||||
appearance = new AvatarAppearance();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1466,11 +1466,11 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
m_log.Info("[APPEARANCE] Sending Own Appearance");
|
m_log.Info("[APPEARANCE] Sending Own Appearance");
|
||||||
ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
|
ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
|
||||||
ControllingClient.SendAppearance(
|
// ControllingClient.SendAppearance(
|
||||||
m_appearance.Owner,
|
// m_appearance.Owner,
|
||||||
m_appearance.VisualParams,
|
// m_appearance.VisualParams,
|
||||||
m_appearance.Texture.ToBytes()
|
// m_appearance.Texture.ToBytes()
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -46,20 +46,25 @@ namespace OpenSim.Region.Modules.AvatarFactory
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private Scene m_scene = null;
|
private Scene m_scene = null;
|
||||||
|
private static readonly AvatarAppearance def = new AvatarAppearance();
|
||||||
|
|
||||||
public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance)
|
public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance)
|
||||||
{
|
{
|
||||||
appearance = m_scene.CommsManager.UserService.GetUserAppearance(avatarId);
|
CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(avatarId);
|
||||||
if (appearance != null)
|
if ((profile != null) && (profile.RootFolder != null))
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[APPEARANCE] found : {0}", appearance.ToString());
|
appearance = m_scene.CommsManager.UserService.GetUserAppearance(avatarId);
|
||||||
return true;
|
if (appearance != null)
|
||||||
}
|
{
|
||||||
else
|
SetAppearanceAssets(profile, ref appearance);
|
||||||
{
|
m_log.InfoFormat("[APPEARANCE] found : {0}", appearance.ToString());
|
||||||
m_log.InfoFormat("[APPEARANCE] appearance not found for {0}", avatarId.ToString());
|
return true;
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appearance = CreateDefault(avatarId);
|
||||||
|
m_log.InfoFormat("[APPEARANCE] appearance not found for {0}, creating default", avatarId.ToString());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AvatarAppearance CreateDefault(LLUUID avatarId)
|
private AvatarAppearance CreateDefault(LLUUID avatarId)
|
||||||
|
@ -113,6 +118,41 @@ namespace OpenSim.Region.Modules.AvatarFactory
|
||||||
// client.OnAvatarNowWearing -= AvatarIsWearing;
|
// 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)
|
public void AvatarIsWearing(Object sender, AvatarWearingArgs e)
|
||||||
{
|
{
|
||||||
IClientAPI clientView = (IClientAPI)sender;
|
IClientAPI clientView = (IClientAPI)sender;
|
||||||
|
@ -138,30 +178,11 @@ namespace OpenSim.Region.Modules.AvatarFactory
|
||||||
{
|
{
|
||||||
if (wear.Type < 13)
|
if (wear.Type < 13)
|
||||||
{
|
{
|
||||||
if (wear.ItemID == LLUUID.Zero)
|
avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SetAppearanceAssets(profile, ref avatAppearance);
|
||||||
|
|
||||||
m_scene.CommsManager.UserService.UpdateUserAppearance(clientView.AgentId, avatAppearance);
|
m_scene.CommsManager.UserService.UpdateUserAppearance(clientView.AgentId, avatAppearance);
|
||||||
avatar.Appearance = avatAppearance;
|
avatar.Appearance = avatAppearance;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue