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