add error handling

master
Christopher 2020-06-28 13:59:38 +02:00
parent c35f8b3f1b
commit 61cb8c2e85
1 changed files with 48 additions and 42 deletions

View File

@ -107,53 +107,59 @@ namespace OpenSim.Modules.TextureFetcher
m_log.Info("[" + Name + "] Process part '" + part.Name + "'"); m_log.Info("[" + Name + "] Process part '" + part.Name + "'");
List<UUID> allTextures = new List<UUID>(); try
List<TaskInventoryItem> inventoryItems = new List<TaskInventoryItem>();
//Get all Textures from the scene object
Primitive.TextureEntry textures = part.Shape.Textures;
int allSides = part.GetNumberOfSides();
for (uint i = 0; i < allSides; i++)
if (textures.FaceTextures[i] != null)
allTextures.Add(textures.FaceTextures[i].TextureID);
//Convert texture uuid list to inventar items.
foreach (UUID texture in allTextures)
{ {
if (texture != UUID.Zero) List<UUID> allTextures = new List<UUID>();
List<TaskInventoryItem> inventoryItems = new List<TaskInventoryItem>();
//Get all Textures from the scene object
Primitive.TextureEntry textures = part.Shape.Textures;
int allSides = part.GetNumberOfSides();
for (uint i = 0; i < allSides; i++)
if (textures.FaceTextures[i] != null)
allTextures.Add(textures.FaceTextures[i].TextureID);
//Convert texture uuid list to inventar items.
foreach (UUID texture in allTextures)
{ {
TaskInventoryItem item = new TaskInventoryItem(); if (texture != UUID.Zero)
item.AssetID = texture; {
item.ItemID = UUID.Random(); TaskInventoryItem item = new TaskInventoryItem();
item.OwnerID = part.OwnerID; item.AssetID = texture;
item.CurrentPermissions = 581639; item.ItemID = UUID.Random();
item.Name = "tf-" + texture.ToString(); item.OwnerID = part.OwnerID;
item.Description = "This item was generated by the texture fetcher module."; item.CurrentPermissions = 581639;
item.OwnerID = part.OwnerID; item.Name = "tf-" + texture.ToString();
item.CreatorID = part.OwnerID; item.Description = "This item was generated by the texture fetcher module.";
item.LastOwnerID = part.OwnerID; item.OwnerID = part.OwnerID;
inventoryItems.Add(item); item.CreatorID = part.OwnerID;
item.LastOwnerID = part.OwnerID;
inventoryItems.Add(item);
}
}
//Check if the item is allready in the inventory and then add it.
bool updateNeeded = false;
foreach (TaskInventoryItem item in inventoryItems)
{
if (!isAssetInInventory(part, item.AssetID))
{
updateNeeded = true;
part.Inventory.AddInventoryItem(item, false);
m_log.Info("[" + Name + "] Add item '" + item.Name + "' to '" + part.Name + "'.");
}
}
if (updateNeeded == true)
{
part.SendFullUpdateToAllClients();
} }
} }
catch(Exception _error)
//Check if the item is allready in the inventory and then add it.
bool updateNeeded = false;
foreach (TaskInventoryItem item in inventoryItems)
{ {
if(!isAssetInInventory(part, item.AssetID)) m_log.Error("[" + Name + "] ERROR: " + _error.Message);
{
updateNeeded = true;
part.Inventory.AddInventoryItem(item, false);
m_log.Info("[" + Name + "] Add item '" + item.Name + "' to '" + part.Name + "'.");
}
} }
if(updateNeeded == true)
{
part.SendFullUpdateToAllClients();
}
} }
} }
} }