mirror of
https://github.com/opensim/opensim.git
synced 2026-08-21 21:55:38 +08:00
Merge branch 'master' into careminster
Conflicts: OpenSim/Framework/Watchdog.cs OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs OpenSim/Region/Framework/Scenes/Scene.cs OpenSim/Region/Framework/Scenes/SceneObjectPart.cs OpenSim/Region/Framework/Scenes/ScenePresence.cs
This commit is contained in:
@@ -2725,6 +2725,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
}
|
||||
}
|
||||
|
||||
public void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcTouch");
|
||||
m_host.AddScriptLPS(1);
|
||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||
int linkNum = link_num.value;
|
||||
if (module != null || (linkNum < 0 && linkNum != ScriptBaseClass.LINK_THIS))
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npcLSL_Key, out npcId) || !module.CheckPermissions(npcId, m_host.OwnerID))
|
||||
return;
|
||||
SceneObjectPart part = null;
|
||||
UUID objectId;
|
||||
if (UUID.TryParse(LSL_String.ToString(object_key), out objectId))
|
||||
part = World.GetSceneObjectPart(objectId);
|
||||
if (part == null)
|
||||
return;
|
||||
if (linkNum != ScriptBaseClass.LINK_THIS)
|
||||
{
|
||||
if (linkNum == 0 || linkNum == ScriptBaseClass.LINK_ROOT)
|
||||
{ // 0 and 1 are treated as root, find the root if the current part isnt it
|
||||
if (!part.IsRoot)
|
||||
part = part.ParentGroup.RootPart;
|
||||
}
|
||||
else
|
||||
{ // Find the prim with the given link number if not found then fail silently
|
||||
part = part.ParentGroup.GetLinkNumPart(linkNum);
|
||||
if (part == null)
|
||||
return;
|
||||
}
|
||||
}
|
||||
module.Touch(npcId, part.UUID);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the current appearance of the script owner permanently to the named notecard.
|
||||
/// </summary>
|
||||
@@ -3203,13 +3238,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory");
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
ForceAttachToAvatarFromInventory(m_host.OwnerID, itemName, attachmentPoint);
|
||||
}
|
||||
|
||||
public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Severe, "osForceAttachToOtherAvatarFromInventory");
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
UUID avatarId;
|
||||
|
||||
if (!UUID.TryParse(rawAvatarId, out avatarId))
|
||||
return;
|
||||
|
||||
ForceAttachToAvatarFromInventory(avatarId, itemName, attachmentPoint);
|
||||
}
|
||||
|
||||
public void ForceAttachToAvatarFromInventory(UUID avatarId, string itemName, int attachmentPoint)
|
||||
{
|
||||
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
|
||||
|
||||
if (attachmentsModule == null)
|
||||
return;
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
InitLSL();
|
||||
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
|
||||
@@ -3232,7 +3286,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return;
|
||||
}
|
||||
|
||||
ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
|
||||
ScenePresence sp = World.GetScenePresence(avatarId);
|
||||
|
||||
if (sp == null)
|
||||
return;
|
||||
|
||||
@@ -101,18 +101,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
// Attachment commands
|
||||
|
||||
/// <summary>
|
||||
/// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH
|
||||
/// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH
|
||||
/// </summary>
|
||||
/// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
|
||||
void osForceAttachToAvatar(int attachment);
|
||||
|
||||
/// <summary>
|
||||
/// Attach the inventory item in the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH
|
||||
/// Attach an inventory item in the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Nothing happens if the owner is not in the region.
|
||||
/// </remarks>
|
||||
/// <param name='itemName'>Tha name of the item. If this is not found then a warning is said to the owner</param>
|
||||
/// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
|
||||
void osForceAttachToAvatarFromInventory(string itemName, int attachment);
|
||||
|
||||
/// <summary>
|
||||
/// Attach an inventory item in the object containing this script to any avatar in the region without asking for PERMISSION_ATTACH
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Nothing happens if the avatar is not in the region.
|
||||
/// </remarks>
|
||||
/// <param name='rawAvatarId'>The UUID of the avatar to which to attach. Nothing happens if this is not a UUID</para>
|
||||
/// <param name='itemName'>The name of the item. If this is not found then a warning is said to the owner</param>
|
||||
/// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
|
||||
void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint);
|
||||
|
||||
/// <summary>
|
||||
/// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH
|
||||
/// </summary>
|
||||
@@ -231,6 +245,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
void osNpcRemove(key npc);
|
||||
void osNpcPlayAnimation(LSL_Key npc, string animation);
|
||||
void osNpcStopAnimation(LSL_Key npc, string animation);
|
||||
void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num);
|
||||
void osNpcWhisper(key npc, int channel, string message);
|
||||
|
||||
LSL_Key osOwnerSaveAppearance(string notecard);
|
||||
|
||||
@@ -301,6 +301,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
m_OSSL_Functions.osForceAttachToAvatarFromInventory(itemName, attachmentPoint);
|
||||
}
|
||||
|
||||
public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint)
|
||||
{
|
||||
m_OSSL_Functions.osForceAttachToOtherAvatarFromInventory(rawAvatarId, itemName, attachmentPoint);
|
||||
}
|
||||
|
||||
public void osForceDetachFromAvatar()
|
||||
{
|
||||
m_OSSL_Functions.osForceDetachFromAvatar();
|
||||
@@ -626,6 +631,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
m_OSSL_Functions.osNpcWhisper(npc, channel, message);
|
||||
}
|
||||
|
||||
public void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num)
|
||||
{
|
||||
m_OSSL_Functions.osNpcTouch(npcLSL_Key, object_key, link_num);
|
||||
}
|
||||
|
||||
public LSL_Key osOwnerSaveAppearance(string notecard)
|
||||
{
|
||||
return m_OSSL_Functions.osOwnerSaveAppearance(notecard);
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
/// Test creation of an NPC where the appearance data comes from a notecard
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestOsNpcCreateFromNotecard()
|
||||
public void TestOsNpcCreateUsingAppearanceFromNotecard()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
@@ -90,7 +90,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
||||
sp.Appearance.AvatarHeight = newHeight;
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
@@ -114,10 +114,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
/// Test creation of an NPC where the appearance data comes from an avatar already in the region.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestOsNpcCreateFromAvatar()
|
||||
public void TestOsNpcCreateUsingAppearanceFromAvatar()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
// Store an avatar with a different height from default in a notecard.
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
@@ -125,7 +125,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
||||
sp.Appearance.AvatarHeight = newHeight;
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
||||
sp.Appearance.AvatarHeight = newHeight;
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, nonOwnerId);
|
||||
sp.Appearance.AvatarHeight = newHeight;
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId);
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId, 0x10);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
{
|
||||
osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
exceptionCaught = true;
|
||||
}
|
||||
@@ -174,5 +174,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments();
|
||||
Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOsForceAttachToOtherAvatarFromInventory()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
string taskInvObjItemName = "sphere";
|
||||
UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000");
|
||||
AttachmentPoint attachPoint = AttachmentPoint.Chin;
|
||||
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, "user", "one", 0x1, "pass");
|
||||
UserAccount ua2 = UserAccountHelpers.CreateUserWithInventory(m_scene, "user", "two", 0x2, "pass");
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1);
|
||||
SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID);
|
||||
TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart);
|
||||
|
||||
new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem);
|
||||
OSSL_Api osslApi = new OSSL_Api();
|
||||
osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem);
|
||||
|
||||
// Create an object embedded inside the first
|
||||
TaskInventoryHelpers.AddSceneObject(m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID);
|
||||
|
||||
ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, ua2);
|
||||
|
||||
osslApi.osForceAttachToOtherAvatarFromInventory(sp2.UUID.ToString(), taskInvObjItemName, (int)attachPoint);
|
||||
|
||||
// Check scene presence status
|
||||
Assert.That(sp.HasAttachments(), Is.False);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(0));
|
||||
|
||||
Assert.That(sp2.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments2 = sp2.GetAttachments();
|
||||
Assert.That(attachments2.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup attSo = attachments2[0];
|
||||
Assert.That(attSo.Name, Is.EqualTo(taskInvObjItemName));
|
||||
Assert.That(attSo.OwnerID, Is.EqualTo(ua2.PrincipalID));
|
||||
Assert.That(attSo.AttachmentPoint, Is.EqualTo((uint)attachPoint));
|
||||
Assert.That(attSo.IsAttachment);
|
||||
Assert.That(attSo.UsesPhysics, Is.False);
|
||||
Assert.That(attSo.IsTemporary, Is.False);
|
||||
|
||||
// Check appearance status
|
||||
List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments();
|
||||
Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0));
|
||||
|
||||
List<AvatarAttachment> attachmentsInAppearance2 = sp2.Appearance.GetAttachments();
|
||||
Assert.That(attachmentsInAppearance2.Count, Is.EqualTo(1));
|
||||
Assert.That(sp2.Appearance.GetAttachpoint(attachmentsInAppearance2[0].ItemID), Is.EqualTo((uint)attachPoint));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,11 +97,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
||||
sp.Appearance.AvatarHeight = newHeight;
|
||||
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
SceneObjectGroup otherSo = SceneHelpers.CreateSceneObject(1, otherUserId);
|
||||
SceneObjectGroup otherSo = SceneHelpers.CreateSceneObject(1, otherUserId, 0x20);
|
||||
SceneObjectPart otherPart = otherSo.RootPart;
|
||||
m_scene.AddSceneObject(otherSo);
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
||||
sp.Appearance.AvatarHeight = newHeight;
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
|
||||
@@ -1662,7 +1662,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
{
|
||||
IScriptInstance instance = GetInstance(itemID);
|
||||
if (instance != null)
|
||||
instance.Stop(0);
|
||||
{
|
||||
// Give the script some time to finish processing its last event. Simply aborting the script thread can
|
||||
// cause issues on mono 2.6, 2.10 and possibly later where locks are not released properly on abort.
|
||||
instance.Stop(1000);
|
||||
}
|
||||
}
|
||||
|
||||
public DetectParams GetDetectParams(UUID itemID, int idx)
|
||||
|
||||
Reference in New Issue
Block a user