Fixed bug in AvatarFactoryModule that resulted in removing cloth items, not being persisted.

ThreadPoolClientBranch
MW 2008-02-15 12:39:45 +00:00
parent 5e625e5380
commit 23c7c6dabd
2 changed files with 31 additions and 29 deletions

View File

@ -57,7 +57,7 @@ namespace OpenSim.Region.Environment.Modules
public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance) public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance)
{ {
//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;
bool fetchInProgress = false; bool fetchInProgress = false;
@ -99,7 +99,6 @@ namespace OpenSim.Region.Environment.Modules
waitHandle = null; waitHandle = null;
return false; return false;
} }
} }
else else
{ {
@ -144,7 +143,7 @@ namespace OpenSim.Region.Environment.Modules
m_fetchesInProgress.Remove(avatarId); m_fetchesInProgress.Remove(avatarId);
waitHandle.Set(); waitHandle.Set();
} }
// waitHandle.Close(); // waitHandle.Close();
waitHandle = null; waitHandle = null;
return true; return true;
} }
@ -158,7 +157,7 @@ namespace OpenSim.Region.Environment.Modules
m_fetchesInProgress.Remove(avatarId); m_fetchesInProgress.Remove(avatarId);
waitHandle.Set(); waitHandle.Set();
} }
//waitHandle.Close(); //waitHandle.Close();
waitHandle = null; waitHandle = null;
return false; return false;
} }
@ -179,7 +178,6 @@ namespace OpenSim.Region.Environment.Modules
private AvatarAppearance CheckDatabase(LLUUID avatarId) private AvatarAppearance CheckDatabase(LLUUID avatarId)
{ {
AvatarAppearance appearance = null; AvatarAppearance appearance = null;
//check db
if (m_enablePersist) if (m_enablePersist)
{ {
if (m_appearanceMapper.TryGetValue(avatarId.UUID, out appearance)) if (m_appearanceMapper.TryGetValue(avatarId.UUID, out appearance))
@ -198,13 +196,11 @@ namespace OpenSim.Region.Environment.Modules
private AvatarAppearance CheckCache(LLUUID avatarId) private AvatarAppearance CheckCache(LLUUID avatarId)
{ {
AvatarAppearance appearance = null; AvatarAppearance appearance = null;
//check cache
lock (m_avatarsAppearance) lock (m_avatarsAppearance)
{ {
if (m_avatarsAppearance.ContainsKey(avatarId)) if (m_avatarsAppearance.ContainsKey(avatarId))
{ {
appearance = m_avatarsAppearance[avatarId]; appearance = m_avatarsAppearance[avatarId];
// return true;
} }
} }
return appearance; return appearance;
@ -212,10 +208,8 @@ namespace OpenSim.Region.Environment.Modules
public void Initialise(Scene scene, IConfigSource source) public void Initialise(Scene scene, IConfigSource source)
{ {
scene.RegisterModuleInterface<IAvatarFactory>(this);
scene.RegisterModuleInterface<IAvatarFactory>(this); scene.EventManager.OnNewClient += NewClient;
scene.EventManager.OnNewClient += NewClient;
if (m_scene == null) if (m_scene == null)
{ {
@ -277,32 +271,39 @@ namespace OpenSim.Region.Environment.Modules
{ {
if (profile.RootFolder != null) if (profile.RootFolder != null)
{ {
//Todo look up the assetid from the inventory cache for each itemId that is in AvatarWearingArgs if (m_avatarsAppearance.ContainsKey(clientView.AgentId))
// then store assetid and itemId and wearable type in a database
foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
{ {
if (wear.Type < 13) AvatarAppearance avatAppearance = null;
lock (m_avatarsAppearance)
{ {
LLUUID assetId; avatAppearance = m_avatarsAppearance[clientView.AgentId];
}
InventoryItemBase baseItem = profile.RootFolder.HasItem(wear.ItemID); foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
if (baseItem != null) {
if (wear.Type < 13)
{ {
assetId = baseItem.assetID; if (wear.ItemID == LLUUID.Zero)
if (m_avatarsAppearance.ContainsKey(clientView.AgentId))
{ {
AvatarAppearance avatAppearance = null; avatAppearance.Wearables[wear.Type].ItemID = LLUUID.Zero;
avatAppearance.Wearables[wear.Type].AssetID = LLUUID.Zero;
lock (m_avatarsAppearance)
{
avatAppearance = m_avatarsAppearance[clientView.AgentId];
}
avatAppearance.Wearables[wear.Type].AssetID = assetId;
avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
UpdateDatabase(clientView.AgentId, avatAppearance); UpdateDatabase(clientView.AgentId, avatAppearance);
} }
else
{
LLUUID assetId;
InventoryItemBase baseItem = profile.RootFolder.HasItem(wear.ItemID);
if (baseItem != null)
{
assetId = baseItem.assetID;
avatAppearance.Wearables[wear.Type].AssetID = assetId;
avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
UpdateDatabase(clientView.AgentId, avatAppearance);
}
}
} }
} }
} }

View File

@ -1422,6 +1422,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");
byte[] visualParams; byte[] visualParams;
AvatarWearable[] wearables; AvatarWearable[] wearables;
AvatarFactoryModule.GetDefaultAvatarAppearance(out wearables, out visualParams); AvatarFactoryModule.GetDefaultAvatarAppearance(out wearables, out visualParams);