mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
This commit is contained in:
@@ -11578,12 +11578,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
internal void Deprecated(string command)
|
||||
{
|
||||
throw new Exception("Command deprecated: " + command);
|
||||
throw new ScriptException("Command deprecated: " + command);
|
||||
}
|
||||
|
||||
internal void LSLError(string msg)
|
||||
{
|
||||
throw new Exception("LSL Runtime Error: " + msg);
|
||||
throw new ScriptException("LSL Runtime Error: " + msg);
|
||||
}
|
||||
|
||||
public delegate void AssetRequestCallback(UUID assetID, AssetBase asset);
|
||||
|
||||
@@ -95,13 +95,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
internal void MODError(string msg)
|
||||
{
|
||||
throw new Exception("MOD Runtime Error: " + msg);
|
||||
throw new ScriptException("MOD Runtime Error: " + msg);
|
||||
}
|
||||
|
||||
//
|
||||
//Dumps an error message on the debug console.
|
||||
//
|
||||
|
||||
/// <summary>
|
||||
/// Dumps an error message on the debug console.
|
||||
/// </summary>
|
||||
/// <param name='message'></param>
|
||||
internal void MODShoutError(string message)
|
||||
{
|
||||
if (message.Length > 1023)
|
||||
@@ -359,20 +359,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
result[i] = (string)(LSL_String)plist[i];
|
||||
else if (plist[i] is LSL_Integer)
|
||||
result[i] = (int)(LSL_Integer)plist[i];
|
||||
// The int check exists because of the many plain old int script constants in ScriptBase which
|
||||
// are not LSL_Integers.
|
||||
else if (plist[i] is int)
|
||||
result[i] = plist[i];
|
||||
else if (plist[i] is LSL_Float)
|
||||
result[i] = (float)(LSL_Float)plist[i];
|
||||
else if (plist[i] is LSL_Key)
|
||||
result[i] = new UUID((LSL_Key)plist[i]);
|
||||
else if (plist[i] is LSL_Rotation)
|
||||
{
|
||||
result[i] = (OpenMetaverse.Quaternion)(
|
||||
(LSL_Rotation)plist[i]);
|
||||
}
|
||||
result[i] = (Quaternion)((LSL_Rotation)plist[i]);
|
||||
else if (plist[i] is LSL_Vector)
|
||||
{
|
||||
result[i] = (OpenMetaverse.Vector3)(
|
||||
(LSL_Vector)plist[i]);
|
||||
}
|
||||
result[i] = (Vector3)((LSL_Vector)plist[i]);
|
||||
else
|
||||
MODError(String.Format("{0}: unknown LSL list element type", fname));
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("OSSL Runtime Error: " + msg);
|
||||
throw new ScriptException("OSSL Runtime Error: " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1789,18 +1789,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
protected string LoadNotecard(string notecardNameOrUuid)
|
||||
{
|
||||
UUID assetID = CacheNotecard(notecardNameOrUuid);
|
||||
StringBuilder notecardData = new StringBuilder();
|
||||
|
||||
for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
|
||||
if (assetID != UUID.Zero)
|
||||
{
|
||||
string line = NotecardCache.GetLine(assetID, count) + "\n";
|
||||
|
||||
// m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line);
|
||||
|
||||
notecardData.Append(line);
|
||||
StringBuilder notecardData = new StringBuilder();
|
||||
|
||||
for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
|
||||
{
|
||||
string line = NotecardCache.GetLine(assetID, count) + "\n";
|
||||
|
||||
// m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line);
|
||||
|
||||
notecardData.Append(line);
|
||||
}
|
||||
|
||||
return notecardData.ToString();
|
||||
}
|
||||
|
||||
return notecardData.ToString();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2373,11 +2379,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return UUID.Zero.ToString();
|
||||
}
|
||||
}
|
||||
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;
|
||||
if (owned)
|
||||
ownerID = m_host.OwnerID;
|
||||
@@ -2446,6 +2453,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return;
|
||||
|
||||
string appearanceSerialized = LoadNotecard(notecard);
|
||||
|
||||
if (appearanceSerialized == null)
|
||||
OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
|
||||
|
||||
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
|
||||
// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
|
||||
// Console.WriteLine("appearanceSerialized {0}", appearanceSerialized);
|
||||
@@ -3691,5 +3702,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
DropAttachmentAt(false, pos, rot);
|
||||
}
|
||||
|
||||
public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Low, "osListenRegex");
|
||||
m_host.AddScriptLPS(1);
|
||||
UUID keyID;
|
||||
UUID.TryParse(ID, out keyID);
|
||||
|
||||
// if we want the name to be used as a regular expression, ensure it is valid first.
|
||||
if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_NAME) == ScriptBaseClass.OS_LISTEN_REGEX_NAME)
|
||||
{
|
||||
try
|
||||
{
|
||||
Regex.IsMatch("", name);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
OSSLShoutError("Name regex is invalid.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// if we want the msg to be used as a regular expression, ensure it is valid first.
|
||||
if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE) == ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE)
|
||||
{
|
||||
try
|
||||
{
|
||||
Regex.IsMatch("", msg);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
OSSLShoutError("Message regex is invalid.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
|
||||
return (wComm == null) ? -1 : wComm.Listen(
|
||||
m_host.LocalId,
|
||||
m_item.ItemID,
|
||||
m_host.UUID,
|
||||
channelID,
|
||||
name,
|
||||
keyID,
|
||||
msg,
|
||||
regexBitfield
|
||||
);
|
||||
}
|
||||
|
||||
public LSL_Integer osRegexIsMatch(string input, string pattern)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Low, "osRegexIsMatch");
|
||||
m_host.AddScriptLPS(1);
|
||||
try
|
||||
{
|
||||
return Regex.IsMatch(input, pattern) ? 1 : 0;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
OSSLShoutError("Possible invalid regular expression detected.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,5 +418,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
/// <param name="pos"></param>
|
||||
/// <param name="rot"></param>
|
||||
void osForceDropAttachmentAt(vector pos, rotation rot);
|
||||
|
||||
/// <summary>
|
||||
/// Identical to llListen except for a bitfield which indicates which
|
||||
/// string parameters should be parsed as regex patterns.
|
||||
/// </summary>
|
||||
/// <param name="channelID"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="ID"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="regexBitfield">
|
||||
/// OS_LISTEN_REGEX_NAME
|
||||
/// OS_LISTEN_REGEX_MESSAGE
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
LSL_Integer osListenRegex(int channelID, string name, string ID,
|
||||
string msg, int regexBitfield);
|
||||
|
||||
/// <summary>
|
||||
/// Wraps to bool Regex.IsMatch(string input, string pattern)
|
||||
/// </summary>
|
||||
/// <param name="input">string to test for match</param>
|
||||
/// <param name="regex">string to use as pattern</param>
|
||||
/// <returns>boolean</returns>
|
||||
LSL_Integer osRegexIsMatch(string input, string pattern);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -741,5 +741,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public const int KFM_CMD_PLAY = 0;
|
||||
public const int KFM_CMD_STOP = 1;
|
||||
public const int KFM_CMD_PAUSE = 2;
|
||||
|
||||
/// <summary>
|
||||
/// process name parameter as regex
|
||||
/// </summary>
|
||||
public const int OS_LISTEN_REGEX_NAME = 0x1;
|
||||
|
||||
/// <summary>
|
||||
/// process message parameter as regex
|
||||
/// </summary>
|
||||
public const int OS_LISTEN_REGEX_MESSAGE = 0x2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -992,5 +992,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
{
|
||||
m_OSSL_Functions.osForceDropAttachmentAt(pos, rot);
|
||||
}
|
||||
|
||||
public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield)
|
||||
{
|
||||
return m_OSSL_Functions.osListenRegex(channelID, name, ID, msg, regexBitfield);
|
||||
}
|
||||
|
||||
public LSL_Integer osRegexIsMatch(string input, string pattern)
|
||||
{
|
||||
return m_OSSL_Functions.osRegexIsMatch(input, pattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
OpenSim/Region/ScriptEngine/Shared/ScriptException.cs
Normal file
40
OpenSim/Region/ScriptEngine/Shared/ScriptException.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.Shared
|
||||
{
|
||||
public class ScriptException : Exception
|
||||
{
|
||||
public ScriptException() : base() {}
|
||||
|
||||
public ScriptException(string message) : base(message) {}
|
||||
|
||||
public ScriptException(string message, Exception innerException) : base(message, innerException) {}
|
||||
}
|
||||
}
|
||||
@@ -75,76 +75,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
m_engine.AddRegion(m_scene);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test creation of an NPC where the appearance data comes from a notecard
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestOsNpcCreateUsingAppearanceFromNotecard()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
// Store an avatar with a different height from default in a notecard.
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
float newHeight = 1.9f;
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
||||
sp.Appearance.AvatarHeight = newHeight;
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
OSSL_Api osslApi = new OSSL_Api();
|
||||
osslApi.Initialize(m_engine, part, null);
|
||||
|
||||
string notecardName = "appearanceNc";
|
||||
osslApi.osOwnerSaveAppearance(notecardName);
|
||||
|
||||
// Try creating a bot using the appearance in the notecard.
|
||||
string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName);
|
||||
Assert.That(npcRaw, Is.Not.Null);
|
||||
|
||||
UUID npcId = new UUID(npcRaw);
|
||||
ScenePresence npc = m_scene.GetScenePresence(npcId);
|
||||
Assert.That(npc, Is.Not.Null);
|
||||
Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test creation of an NPC where the appearance data comes from an avatar already in the region.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestOsNpcCreateUsingAppearanceFromAvatar()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
// Store an avatar with a different height from default in a notecard.
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
float newHeight = 1.9f;
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
||||
sp.Appearance.AvatarHeight = newHeight;
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
OSSL_Api osslApi = new OSSL_Api();
|
||||
osslApi.Initialize(m_engine, part, null);
|
||||
|
||||
string notecardName = "appearanceNc";
|
||||
osslApi.osOwnerSaveAppearance(notecardName);
|
||||
|
||||
// Try creating a bot using the existing avatar's appearance
|
||||
string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), sp.UUID.ToString());
|
||||
Assert.That(npcRaw, Is.Not.Null);
|
||||
|
||||
UUID npcId = new UUID(npcRaw);
|
||||
ScenePresence npc = m_scene.GetScenePresence(npcId);
|
||||
Assert.That(npc, Is.Not.Null);
|
||||
Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOsOwnerSaveAppearance()
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.CoreModules.Avatar.Attachments;
|
||||
using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
|
||||
using OpenSim.Region.OptionalModules.World.NPC;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
@@ -71,13 +72,193 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
config.Set("Enabled", "true");
|
||||
|
||||
m_scene = new SceneHelpers().SetupScene();
|
||||
SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule());
|
||||
SceneHelpers.SetupSceneModules(
|
||||
m_scene, initConfigSource, new AvatarFactoryModule(), new AttachmentsModule(), new NPCModule());
|
||||
|
||||
m_engine = new XEngine.XEngine();
|
||||
m_engine.Initialise(initConfigSource);
|
||||
m_engine.AddRegion(m_scene);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test creation of an NPC where the appearance data comes from a notecard
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestOsNpcCreateUsingAppearanceFromNotecard()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
// Store an avatar with a different height from default in a notecard.
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
float newHeight = 1.9f;
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
||||
sp.Appearance.AvatarHeight = newHeight;
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
OSSL_Api osslApi = new OSSL_Api();
|
||||
osslApi.Initialize(m_engine, part, null);
|
||||
|
||||
string notecardName = "appearanceNc";
|
||||
osslApi.osOwnerSaveAppearance(notecardName);
|
||||
|
||||
// Try creating a bot using the appearance in the notecard.
|
||||
string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName);
|
||||
Assert.That(npcRaw, Is.Not.Null);
|
||||
|
||||
UUID npcId = new UUID(npcRaw);
|
||||
ScenePresence npc = m_scene.GetScenePresence(npcId);
|
||||
Assert.That(npc, Is.Not.Null);
|
||||
Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOsNpcCreateNotExistingNotecard()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
OSSL_Api osslApi = new OSSL_Api();
|
||||
osslApi.Initialize(m_engine, so.RootPart, null);
|
||||
|
||||
string npcRaw;
|
||||
bool gotExpectedException = false;
|
||||
try
|
||||
{
|
||||
npcRaw
|
||||
= osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name");
|
||||
}
|
||||
catch (ScriptException)
|
||||
{
|
||||
gotExpectedException = true;
|
||||
}
|
||||
|
||||
Assert.That(gotExpectedException, Is.True);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test creation of an NPC where the appearance data comes from an avatar already in the region.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestOsNpcCreateUsingAppearanceFromAvatar()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
// Store an avatar with a different height from default in a notecard.
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
float newHeight = 1.9f;
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
||||
sp.Appearance.AvatarHeight = newHeight;
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
OSSL_Api osslApi = new OSSL_Api();
|
||||
osslApi.Initialize(m_engine, part, null);
|
||||
|
||||
string notecardName = "appearanceNc";
|
||||
osslApi.osOwnerSaveAppearance(notecardName);
|
||||
|
||||
// Try creating a bot using the existing avatar's appearance
|
||||
string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), sp.UUID.ToString());
|
||||
Assert.That(npcRaw, Is.Not.Null);
|
||||
|
||||
UUID npcId = new UUID(npcRaw);
|
||||
ScenePresence npc = m_scene.GetScenePresence(npcId);
|
||||
Assert.That(npc, Is.Not.Null);
|
||||
Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOsNpcLoadAppearance()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
// Store an avatar with a different height from default in a notecard.
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
float firstHeight = 1.9f;
|
||||
float secondHeight = 2.1f;
|
||||
string firstAppearanceNcName = "appearanceNc1";
|
||||
string secondAppearanceNcName = "appearanceNc2";
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
||||
sp.Appearance.AvatarHeight = firstHeight;
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
OSSL_Api osslApi = new OSSL_Api();
|
||||
osslApi.Initialize(m_engine, part, null);
|
||||
|
||||
osslApi.osOwnerSaveAppearance(firstAppearanceNcName);
|
||||
|
||||
string npcRaw
|
||||
= osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName);
|
||||
|
||||
// Create a second appearance notecard with a different height
|
||||
sp.Appearance.AvatarHeight = secondHeight;
|
||||
osslApi.osOwnerSaveAppearance(secondAppearanceNcName);
|
||||
|
||||
osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
|
||||
|
||||
UUID npcId = new UUID(npcRaw);
|
||||
ScenePresence npc = m_scene.GetScenePresence(npcId);
|
||||
Assert.That(npc, Is.Not.Null);
|
||||
Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(secondHeight));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOsNpcLoadAppearanceNotExistingNotecard()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
// Store an avatar with a different height from default in a notecard.
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
float firstHeight = 1.9f;
|
||||
float secondHeight = 2.1f;
|
||||
string firstAppearanceNcName = "appearanceNc1";
|
||||
string secondAppearanceNcName = "appearanceNc2";
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
||||
sp.Appearance.AvatarHeight = firstHeight;
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
OSSL_Api osslApi = new OSSL_Api();
|
||||
osslApi.Initialize(m_engine, part, null);
|
||||
|
||||
osslApi.osOwnerSaveAppearance(firstAppearanceNcName);
|
||||
|
||||
string npcRaw
|
||||
= osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName);
|
||||
|
||||
bool gotExpectedException = false;
|
||||
try
|
||||
{
|
||||
osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
|
||||
}
|
||||
catch (ScriptException)
|
||||
{
|
||||
gotExpectedException = true;
|
||||
}
|
||||
|
||||
Assert.That(gotExpectedException, Is.True);
|
||||
|
||||
UUID npcId = new UUID(npcRaw);
|
||||
ScenePresence npc = m_scene.GetScenePresence(npcId);
|
||||
Assert.That(npc, Is.Not.Null);
|
||||
Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(firstHeight));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test removal of an owned NPC.
|
||||
/// </summary>
|
||||
@@ -85,7 +266,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
public void TestOsNpcRemoveOwned()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
// Store an avatar with a different height from default in a notecard.
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
|
||||
Reference in New Issue
Block a user