add more error handling
parent
49cb60bd8a
commit
90bf8b7487
|
@ -74,49 +74,67 @@ namespace OpenSim.Modules.Appearance2Avatar
|
|||
SceneObjectPart _host = m_scene.GetSceneObjectPart(hostID);
|
||||
ScenePresence sp = m_scene.GetScenePresence(UUID.Parse(targetAvatar));
|
||||
|
||||
if(sp != null)
|
||||
if(_host != null)
|
||||
{
|
||||
TaskInventoryItem notecardItem = _host.Inventory.GetInventoryItems().Find(X => X.Name == notecard);
|
||||
|
||||
if(notecardItem != null)
|
||||
if (sp != null)
|
||||
{
|
||||
if(notecardItem.Type != 7)
|
||||
TaskInventoryItem notecardItem = _host.Inventory.GetInventoryItems().Find(X => X.Name == notecard);
|
||||
|
||||
if (notecardItem != null)
|
||||
{
|
||||
m_log.Error("[" + Name + "] ERROR: Given item is not a notecard");
|
||||
throw new Exception("Given item is not a notecard.");
|
||||
return;
|
||||
}
|
||||
if (notecardItem.Type != 7)
|
||||
{
|
||||
m_log.Error("[" + Name + "] ERROR: Given item is not a notecard");
|
||||
throw new Exception("Given item is not a notecard.");
|
||||
return;
|
||||
}
|
||||
|
||||
AssetBase asset = m_scene.AssetService.Get(notecardItem.AssetID.ToString());
|
||||
m_log.Info("[" + Name + "] Info: Fetch asset data for notecard.");
|
||||
AssetBase asset = m_scene.AssetService.Get(notecardItem.AssetID.ToString());
|
||||
|
||||
if(asset != null)
|
||||
{
|
||||
String _appearanceNotecard = new ASCIIEncoding().GetString(asset.Data);
|
||||
if (asset != null)
|
||||
{
|
||||
m_log.Info("[" + Name + "] Info: Convert notecard to string.");
|
||||
String _appearanceNotecard = new ASCIIEncoding().GetString(asset.Data);
|
||||
|
||||
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(_appearanceNotecard);
|
||||
AvatarAppearance appearance = new AvatarAppearance();
|
||||
appearance.Unpack(appearanceOsd);
|
||||
m_log.Info("[" + Name + "] Info: Deserialize notecard.");
|
||||
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(_appearanceNotecard);
|
||||
AvatarAppearance appearance = new AvatarAppearance();
|
||||
appearance.Unpack(appearanceOsd);
|
||||
|
||||
m_log.Info("[" + Name + "] Info: Overwrite appearance");
|
||||
sp.Appearance = appearance;
|
||||
sp.TriggerScenePresenceUpdated();
|
||||
|
||||
m_scene.ForEachClient(
|
||||
client =>
|
||||
{
|
||||
sp.SendFullUpdateToClient(client);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Error("[" + Name + "] ERROR: Cant get asset data for appearance notecard");
|
||||
throw new Exception("Cant get asset data for appearance notecard");
|
||||
}
|
||||
|
||||
sp.Appearance = appearance;
|
||||
sp.TriggerScenePresenceUpdated();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Error("[" + Name + "] ERROR: Cant get asset data for appearance notecard");
|
||||
throw new Exception("Cant get asset data for appearance notecard");
|
||||
m_log.Error("[" + Name + "] ERROR: Notecard not found in objekt inventory");
|
||||
throw new Exception("Notecard not found in objekt inventory");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Error("[" + Name + "] ERROR: Notecard not found in objekt inventory");
|
||||
throw new Exception("Notecard not found in objekt inventory");
|
||||
m_log.Error("[" + Name + "] ERROR: Target not found in region");
|
||||
throw new Exception("Target not found in region");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Error("[" + Name + "] ERROR: Target not found in region");
|
||||
throw new Exception("Target not found in region");
|
||||
m_log.Error("[" + Name + "] ERROR: Cant find objekt inworld");
|
||||
throw new Exception("Cant find objekt inworld");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue