create user with model: do not copy missing items; convert v1.0 to v2.0 wearables, fail if model has missing wearables
parent
cf1ea3b093
commit
0d83b9edc3
|
@ -825,7 +825,6 @@ namespace OpenSim.Services.UserAccountService
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CopyWearablesAndAttachments(destinationAgent, modelAccount.PrincipalID, modelAppearance);
|
CopyWearablesAndAttachments(destinationAgent, modelAccount.PrincipalID, modelAppearance);
|
||||||
|
@ -849,19 +848,24 @@ namespace OpenSim.Services.UserAccountService
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance)
|
private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
AvatarWearable[] wearables = avatarAppearance.Wearables;
|
||||||
|
if(wearables.Length == 0)
|
||||||
|
throw new Exception("Model does not have wearables");
|
||||||
|
|
||||||
// Get Clothing folder of receiver
|
// Get Clothing folder of receiver
|
||||||
InventoryFolderBase destinationFolder = m_InventoryService.GetFolderForType(destination, FolderType.Clothing);
|
InventoryFolderBase destinationFolder = m_InventoryService.GetFolderForType(destination, FolderType.Clothing);
|
||||||
|
|
||||||
|
if (destinationFolder == null)
|
||||||
|
throw new Exception("Cannot locate new clothing folder(s)");
|
||||||
|
|
||||||
// Get Current Outfit folder
|
// Get Current Outfit folder
|
||||||
InventoryFolderBase currentOutfitFolder = m_InventoryService.GetFolderForType(destination, FolderType.CurrentOutfit);
|
InventoryFolderBase currentOutfitFolder = m_InventoryService.GetFolderForType(destination, FolderType.CurrentOutfit);
|
||||||
|
|
||||||
if (destinationFolder == null)
|
// wrong destination folder type? create new
|
||||||
throw new Exception("Cannot locate folder(s)");
|
|
||||||
|
|
||||||
// Missing destination folder? This should *never* be the case
|
|
||||||
if (destinationFolder.Type != (short)FolderType.Clothing)
|
if (destinationFolder.Type != (short)FolderType.Clothing)
|
||||||
{
|
{
|
||||||
destinationFolder = new InventoryFolderBase();
|
destinationFolder = new InventoryFolderBase();
|
||||||
|
|
||||||
destinationFolder.ID = UUID.Random();
|
destinationFolder.ID = UUID.Random();
|
||||||
destinationFolder.Name = "Clothing";
|
destinationFolder.Name = "Clothing";
|
||||||
destinationFolder.Owner = destination;
|
destinationFolder.Owner = destination;
|
||||||
|
@ -869,21 +873,31 @@ namespace OpenSim.Services.UserAccountService
|
||||||
destinationFolder.ParentID = m_InventoryService.GetRootFolder(destination).ID;
|
destinationFolder.ParentID = m_InventoryService.GetRootFolder(destination).ID;
|
||||||
destinationFolder.Version = 1;
|
destinationFolder.Version = 1;
|
||||||
m_InventoryService.AddFolder(destinationFolder); // store base record
|
m_InventoryService.AddFolder(destinationFolder); // store base record
|
||||||
m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Created folder for destination {0}", source);
|
m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Created folder for destination {0} Clothing", source);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wearables
|
// Wearables
|
||||||
AvatarWearable[] wearables = avatarAppearance.Wearables;
|
AvatarWearable basewearable;
|
||||||
AvatarWearable wearable;
|
AvatarWearable newbasewearable;
|
||||||
|
WearableItem wearable;
|
||||||
|
|
||||||
|
// copy wearables creating new inventory entries
|
||||||
|
// converting from v1.0 wearables to v2.0
|
||||||
for (int i = 0; i < wearables.Length; i++)
|
for (int i = 0; i < wearables.Length; i++)
|
||||||
{
|
{
|
||||||
wearable = wearables[i];
|
basewearable = wearables[i];
|
||||||
if (wearable[0].ItemID != UUID.Zero)
|
if(basewearable == null || basewearable.Count == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
newbasewearable = new AvatarWearable();
|
||||||
|
int j = basewearable.Count - 1;
|
||||||
|
|
||||||
|
wearable = basewearable[j];
|
||||||
|
if (wearable.ItemID != UUID.Zero)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[XXX]: Getting item {0} from avie {1}", wearable[0].ItemID, source);
|
m_log.DebugFormat("[XXX]: Getting item {0} from avie {1}", wearable.ItemID, source);
|
||||||
// Get inventory item and copy it
|
// Get inventory item and copy it
|
||||||
InventoryItemBase item = m_InventoryService.GetItem(source, wearable[0].ItemID);
|
InventoryItemBase item = m_InventoryService.GetItem(source, wearable.ItemID);
|
||||||
|
|
||||||
if(item != null && item.AssetType == (int)AssetType.Link)
|
if(item != null && item.AssetType == (int)AssetType.Link)
|
||||||
{
|
{
|
||||||
|
@ -922,22 +936,22 @@ namespace OpenSim.Services.UserAccountService
|
||||||
m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);
|
m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);
|
||||||
|
|
||||||
// Wear item
|
// Wear item
|
||||||
AvatarWearable newWearable = new AvatarWearable();
|
newbasewearable.Add(destinationItem.ID,wearable.AssetID);
|
||||||
newWearable.Wear(destinationItem.ID, wearable[0].AssetID);
|
|
||||||
avatarAppearance.SetWearable(i, newWearable);
|
|
||||||
|
|
||||||
// Add to Current Outfit
|
// Add to Current Outfit
|
||||||
CreateCurrentOutfitLink((int)InventoryType.Wearable, item.Flags, item.Name, destinationItem.ID, destination, currentOutfitFolder.ID);
|
CreateCurrentOutfitLink((int)InventoryType.Wearable, item.Flags, item.Name, destinationItem.ID, destination, currentOutfitFolder.ID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", wearable[0].ItemID, destinationFolder.ID);
|
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", wearable.ItemID, destinationFolder.ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
avatarAppearance.SetWearable(i, newbasewearable);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attachments
|
// Attachments
|
||||||
List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();
|
List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();
|
||||||
|
avatarAppearance.ClearAttachments();
|
||||||
|
|
||||||
foreach (AvatarAttachment attachment in attachments)
|
foreach (AvatarAttachment attachment in attachments)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue