Get osNpcCreate() and osNpcLoadAppearance() to generate a script error if appearance notecard does not exist, rather than returning UUID.Zero or silently failing.
parent
28ced402d8
commit
01a8a65d75
|
@ -2325,10 +2325,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
appearance = new AvatarAppearance();
|
appearance = new AvatarAppearance();
|
||||||
appearance.Unpack(appearanceOsd);
|
appearance.Unpack(appearanceOsd);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appearance == null)
|
|
||||||
return new LSL_Key(UUID.Zero.ToString());
|
|
||||||
|
|
||||||
UUID ownerID = UUID.Zero;
|
UUID ownerID = UUID.Zero;
|
||||||
if (owned)
|
if (owned)
|
||||||
|
@ -2394,7 +2395,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
string appearanceSerialized = LoadNotecard(notecard);
|
string appearanceSerialized = LoadNotecard(notecard);
|
||||||
|
|
||||||
if (appearanceSerialized == null)
|
if (appearanceSerialized == null)
|
||||||
return;
|
OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
|
||||||
|
|
||||||
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
|
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
|
||||||
// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
|
// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
|
||||||
|
|
|
@ -127,11 +127,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||||
OSSL_Api osslApi = new OSSL_Api();
|
OSSL_Api osslApi = new OSSL_Api();
|
||||||
osslApi.Initialize(m_engine, so.RootPart, null);
|
osslApi.Initialize(m_engine, so.RootPart, null);
|
||||||
|
|
||||||
string npcRaw
|
string npcRaw;
|
||||||
|
bool gotExpectedException = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
npcRaw
|
||||||
= osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name");
|
= osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name");
|
||||||
|
}
|
||||||
|
catch (ScriptException)
|
||||||
|
{
|
||||||
|
gotExpectedException = true;
|
||||||
|
}
|
||||||
|
|
||||||
UUID npcId = new UUID(npcRaw);
|
Assert.That(gotExpectedException, Is.True);
|
||||||
Assert.That(npcId, Is.EqualTo(UUID.Zero));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -233,7 +241,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||||
string npcRaw
|
string npcRaw
|
||||||
= osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName);
|
= osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName);
|
||||||
|
|
||||||
|
bool gotExpectedException = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
|
osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
|
||||||
|
}
|
||||||
|
catch (ScriptException)
|
||||||
|
{
|
||||||
|
gotExpectedException = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.That(gotExpectedException, Is.True);
|
||||||
|
|
||||||
UUID npcId = new UUID(npcRaw);
|
UUID npcId = new UUID(npcRaw);
|
||||||
ScenePresence npc = m_scene.GetScenePresence(npcId);
|
ScenePresence npc = m_scene.GetScenePresence(npcId);
|
||||||
|
|
Loading…
Reference in New Issue