mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
Merge branch 'master' of /home/opensim/var/repo/opensim
This commit is contained in:
@@ -29,42 +29,43 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
public class ApiManager
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>();
|
||||
|
||||
public string[] GetApis()
|
||||
{
|
||||
if (m_Apis.Count > 0)
|
||||
if (m_Apis.Count <= 0)
|
||||
{
|
||||
List<string> l = new List<string>(m_Apis.Keys);
|
||||
return l.ToArray();
|
||||
}
|
||||
Assembly a = Assembly.GetExecutingAssembly();
|
||||
|
||||
Assembly a = Assembly.GetExecutingAssembly();
|
||||
Type[] types = a.GetExportedTypes();
|
||||
|
||||
Type[] types = a.GetExportedTypes();
|
||||
|
||||
foreach (Type t in types)
|
||||
{
|
||||
string name = t.ToString();
|
||||
int idx = name.LastIndexOf('.');
|
||||
if (idx != -1)
|
||||
name = name.Substring(idx+1);
|
||||
|
||||
if (name.EndsWith("_Api"))
|
||||
foreach (Type t in types)
|
||||
{
|
||||
name = name.Substring(0, name.Length - 4);
|
||||
m_Apis[name] = t;
|
||||
string name = t.ToString();
|
||||
int idx = name.LastIndexOf('.');
|
||||
if (idx != -1)
|
||||
name = name.Substring(idx+1);
|
||||
|
||||
if (name.EndsWith("_Api"))
|
||||
{
|
||||
name = name.Substring(0, name.Length - 4);
|
||||
m_Apis[name] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<string> ret = new List<string>(m_Apis.Keys);
|
||||
return ret.ToArray();
|
||||
// m_log.DebugFormat("[API MANAGER]: Found {0} apis", m_Apis.Keys.Count);
|
||||
|
||||
return new List<string>(m_Apis.Keys).ToArray();
|
||||
}
|
||||
|
||||
public IScriptApi CreateApi(string api)
|
||||
@@ -76,4 +77,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
protected IScriptEngine m_ScriptEngine;
|
||||
protected SceneObjectPart m_host;
|
||||
protected uint m_localID;
|
||||
|
||||
/// <summary>
|
||||
/// The UUID of the item that hosts this script
|
||||
/// </summary>
|
||||
protected UUID m_itemID;
|
||||
|
||||
protected bool throwErrorOnNotImplemented = true;
|
||||
protected AsyncCommandManager AsyncCommands = null;
|
||||
protected float m_ScriptDelayFactor = 1.0f;
|
||||
@@ -267,23 +272,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
}
|
||||
}
|
||||
|
||||
protected UUID InventorySelf()
|
||||
/// <summary>
|
||||
/// Get the inventory item that hosts ourselves.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// FIXME: It would be far easier to pass in TaskInventoryItem rather than just m_itemID so that we don't need
|
||||
/// to keep looking ourselves up.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
protected TaskInventoryItem GetSelfInventoryItem()
|
||||
{
|
||||
UUID invItemID = new UUID();
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
|
||||
{
|
||||
invItemID = inv.Key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return invItemID;
|
||||
return m_host.TaskInventory[m_itemID];
|
||||
}
|
||||
|
||||
protected UUID InventoryKey(string name, int type)
|
||||
@@ -832,8 +832,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public void llRegionSayTo(string target, int channel, string msg)
|
||||
{
|
||||
string error = String.Empty;
|
||||
|
||||
if (msg.Length > 1023)
|
||||
msg = msg.Substring(0, 1023);
|
||||
|
||||
@@ -2701,18 +2699,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public LSL_Integer llGiveMoney(string destination, int amount)
|
||||
{
|
||||
UUID invItemID=InventorySelf();
|
||||
if (invItemID == UUID.Zero)
|
||||
return 0;
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
TaskInventoryItem item = m_host.TaskInventory[invItemID];
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
item = m_host.TaskInventory[invItemID];
|
||||
}
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
if (item.PermsGranter == UUID.Zero)
|
||||
return 0;
|
||||
@@ -2955,15 +2944,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public void llTakeControls(int controls, int accept, int pass_on)
|
||||
{
|
||||
TaskInventoryItem item;
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
|
||||
return;
|
||||
else
|
||||
item = m_host.TaskInventory[InventorySelf()];
|
||||
}
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
if (item.PermsGranter != UUID.Zero)
|
||||
{
|
||||
@@ -2983,18 +2964,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public void llReleaseControls()
|
||||
{
|
||||
TaskInventoryItem item;
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
|
||||
return;
|
||||
else
|
||||
item = m_host.TaskInventory[InventorySelf()];
|
||||
}
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
if (item.PermsGranter != UUID.Zero)
|
||||
{
|
||||
ScenePresence presence = World.GetScenePresence(item.PermsGranter);
|
||||
@@ -3019,64 +2992,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
m_UrlModule.ReleaseURL(url);
|
||||
}
|
||||
|
||||
public void llAttachToAvatar(int attachment)
|
||||
/// <summary>
|
||||
/// Attach the object containing this script to the avatar that owns it.
|
||||
/// </summary>
|
||||
/// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param>
|
||||
/// <returns>true if the attach suceeded, false if it did not</returns>
|
||||
public bool AttachToAvatar(int attachmentPoint)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
SceneObjectGroup grp = m_host.ParentGroup;
|
||||
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
|
||||
|
||||
// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
|
||||
// return;
|
||||
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
|
||||
|
||||
TaskInventoryItem item;
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
|
||||
return;
|
||||
else
|
||||
item = m_host.TaskInventory[InventorySelf()];
|
||||
}
|
||||
|
||||
if (item.PermsGranter != m_host.OwnerID)
|
||||
return;
|
||||
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
|
||||
{
|
||||
SceneObjectGroup grp = m_host.ParentGroup;
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
|
||||
|
||||
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
|
||||
if (attachmentsModule != null)
|
||||
attachmentsModule.AttachObject(presence, grp, (uint)attachment, false);
|
||||
}
|
||||
if (attachmentsModule != null)
|
||||
return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public void llDetachFromAvatar()
|
||||
/// <summary>
|
||||
/// Detach the object containing this script from the avatar it is attached to.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Nothing happens if the object is not attached.
|
||||
/// </remarks>
|
||||
public void DetachFromAvatar()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
if (m_host.ParentGroup.AttachmentPoint == 0)
|
||||
return;
|
||||
|
||||
TaskInventoryItem item;
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
|
||||
return;
|
||||
else
|
||||
item = m_host.TaskInventory[InventorySelf()];
|
||||
}
|
||||
|
||||
if (item.PermsGranter != m_host.OwnerID)
|
||||
return;
|
||||
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
|
||||
{
|
||||
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
|
||||
if (attachmentsModule != null)
|
||||
Util.FireAndForget(DetachWrapper, m_host);
|
||||
}
|
||||
Util.FireAndForget(DetachWrapper, m_host);
|
||||
}
|
||||
|
||||
private void DetachWrapper(object o)
|
||||
@@ -3092,6 +3034,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
|
||||
}
|
||||
|
||||
public void llAttachToAvatar(int attachmentPoint)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
|
||||
// return;
|
||||
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
if (item.PermsGranter != m_host.OwnerID)
|
||||
return;
|
||||
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
|
||||
AttachToAvatar(attachmentPoint);
|
||||
}
|
||||
|
||||
public void llDetachFromAvatar()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
if (m_host.ParentGroup.AttachmentPoint == 0)
|
||||
return;
|
||||
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
if (item.PermsGranter != m_host.OwnerID)
|
||||
return;
|
||||
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
|
||||
DetachFromAvatar();
|
||||
}
|
||||
|
||||
public void llTakeCamera(string avatar)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
@@ -3317,19 +3291,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
UUID invItemID = InventorySelf();
|
||||
if (invItemID == UUID.Zero)
|
||||
return;
|
||||
|
||||
TaskInventoryItem item;
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
|
||||
return;
|
||||
else
|
||||
item = m_host.TaskInventory[InventorySelf()];
|
||||
}
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
if (item.PermsGranter == UUID.Zero)
|
||||
return;
|
||||
@@ -3354,19 +3316,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
UUID invItemID=InventorySelf();
|
||||
if (invItemID == UUID.Zero)
|
||||
return;
|
||||
|
||||
TaskInventoryItem item;
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
|
||||
return;
|
||||
else
|
||||
item = m_host.TaskInventory[InventorySelf()];
|
||||
}
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
if (item.PermsGranter == UUID.Zero)
|
||||
return;
|
||||
@@ -3421,22 +3371,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public void llRequestPermissions(string agent, int perm)
|
||||
{
|
||||
UUID agentID = new UUID();
|
||||
UUID agentID;
|
||||
|
||||
if (!UUID.TryParse(agent, out agentID))
|
||||
return;
|
||||
|
||||
UUID invItemID = InventorySelf();
|
||||
|
||||
if (invItemID == UUID.Zero)
|
||||
return; // Not in a prim? How??
|
||||
|
||||
TaskInventoryItem item;
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
item = m_host.TaskInventory[invItemID];
|
||||
}
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
if (agentID == UUID.Zero || perm == 0) // Releasing permissions
|
||||
{
|
||||
@@ -3470,8 +3410,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
m_host.TaskInventory[invItemID].PermsGranter = agentID;
|
||||
m_host.TaskInventory[invItemID].PermsMask = perm;
|
||||
m_host.TaskInventory[m_itemID].PermsGranter = agentID;
|
||||
m_host.TaskInventory[m_itemID].PermsMask = perm;
|
||||
}
|
||||
|
||||
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
|
||||
@@ -3494,8 +3434,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
m_host.TaskInventory[invItemID].PermsGranter = agentID;
|
||||
m_host.TaskInventory[invItemID].PermsMask = perm;
|
||||
m_host.TaskInventory[m_itemID].PermsGranter = agentID;
|
||||
m_host.TaskInventory[m_itemID].PermsMask = perm;
|
||||
}
|
||||
|
||||
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
|
||||
@@ -3519,8 +3459,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
m_host.TaskInventory[invItemID].PermsGranter = agentID;
|
||||
m_host.TaskInventory[invItemID].PermsMask = 0;
|
||||
m_host.TaskInventory[m_itemID].PermsGranter = agentID;
|
||||
m_host.TaskInventory[m_itemID].PermsMask = 0;
|
||||
}
|
||||
|
||||
presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
|
||||
@@ -3528,7 +3468,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
}
|
||||
|
||||
presence.ControllingClient.SendScriptQuestion(
|
||||
m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm);
|
||||
m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -3545,20 +3485,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
if (taskID != m_host.UUID)
|
||||
return;
|
||||
|
||||
UUID invItemID = InventorySelf();
|
||||
|
||||
if (invItemID == UUID.Zero)
|
||||
return;
|
||||
|
||||
client.OnScriptAnswer-=handleScriptAnswer;
|
||||
m_waitingForScriptAnswer=false;
|
||||
client.OnScriptAnswer -= handleScriptAnswer;
|
||||
m_waitingForScriptAnswer = false;
|
||||
|
||||
if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
|
||||
llReleaseControls();
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
m_host.TaskInventory[invItemID].PermsMask = answer;
|
||||
m_host.TaskInventory[m_itemID].PermsMask = answer;
|
||||
}
|
||||
|
||||
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
|
||||
@@ -3571,39 +3506,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
if (item.Type == 10 && item.ItemID == m_itemID)
|
||||
{
|
||||
return item.PermsGranter.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return UUID.Zero.ToString();
|
||||
return GetSelfInventoryItem().PermsGranter.ToString();
|
||||
}
|
||||
|
||||
public LSL_Integer llGetPermissions()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
if (item.Type == 10 && item.ItemID == m_itemID)
|
||||
{
|
||||
int perms = item.PermsMask;
|
||||
if (m_automaticLinkPermission)
|
||||
perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
|
||||
return perms;
|
||||
}
|
||||
}
|
||||
}
|
||||
int perms = GetSelfInventoryItem().PermsMask;
|
||||
|
||||
return 0;
|
||||
if (m_automaticLinkPermission)
|
||||
perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
|
||||
|
||||
return perms;
|
||||
}
|
||||
|
||||
public LSL_Integer llGetLinkNumber()
|
||||
@@ -3631,17 +3546,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
public void llCreateLink(string target, int parent)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
UUID invItemID = InventorySelf();
|
||||
UUID targetID;
|
||||
|
||||
if (!UUID.TryParse(target, out targetID))
|
||||
return;
|
||||
|
||||
TaskInventoryItem item;
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
item = m_host.TaskInventory[invItemID];
|
||||
}
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
|
||||
&& !m_automaticLinkPermission)
|
||||
@@ -3659,11 +3569,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
if (targetPart.ParentGroup.AttachmentPoint != 0)
|
||||
return; // Fail silently if attached
|
||||
|
||||
if (targetPart.ParentGroup.RootPart.OwnerID != m_host.ParentGroup.RootPart.OwnerID)
|
||||
return;
|
||||
|
||||
SceneObjectGroup parentPrim = null, childPrim = null;
|
||||
|
||||
if (targetPart != null)
|
||||
{
|
||||
if (parent != 0) {
|
||||
if (parent != 0)
|
||||
{
|
||||
parentPrim = m_host.ParentGroup;
|
||||
childPrim = targetPart.ParentGroup;
|
||||
}
|
||||
@@ -3675,7 +3590,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
// Required for linking
|
||||
childPrim.RootPart.ClearUpdateSchedule();
|
||||
parentPrim.LinkToGroup(childPrim);
|
||||
parentPrim.LinkToGroup(childPrim, true);
|
||||
}
|
||||
|
||||
parentPrim.TriggerScriptChangedEvent(Changed.LINK);
|
||||
@@ -3692,16 +3607,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
public void llBreakLink(int linknum)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
UUID invItemID = InventorySelf();
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
|
||||
&& !m_automaticLinkPermission)
|
||||
{
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
|
||||
&& !m_automaticLinkPermission)
|
||||
{
|
||||
ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
|
||||
return;
|
||||
}
|
||||
ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (linknum < ScriptBaseClass.LINK_THIS)
|
||||
@@ -4578,23 +4489,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public LSL_String llGetScriptName()
|
||||
{
|
||||
string result = String.Empty;
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
if (item.Type == 10 && item.ItemID == m_itemID)
|
||||
{
|
||||
result = item.Name != null ? item.Name : String.Empty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
return result;
|
||||
return item.Name != null ? item.Name : String.Empty;
|
||||
}
|
||||
|
||||
public LSL_Integer llGetLinkNumberOfSides(int link)
|
||||
@@ -9695,21 +9594,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
public LSL_Vector llGetCameraPos()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
UUID invItemID = InventorySelf();
|
||||
|
||||
if (invItemID == UUID.Zero)
|
||||
return new LSL_Vector();
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
if (item.PermsGranter == UUID.Zero)
|
||||
return new LSL_Vector();
|
||||
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
|
||||
{
|
||||
if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
|
||||
return new LSL_Vector();
|
||||
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
|
||||
{
|
||||
ShoutError("No permissions to track the camera");
|
||||
return new LSL_Vector();
|
||||
}
|
||||
ShoutError("No permissions to track the camera");
|
||||
return new LSL_Vector();
|
||||
}
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
|
||||
@@ -9724,20 +9618,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
public LSL_Rotation llGetCameraRot()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
UUID invItemID = InventorySelf();
|
||||
if (invItemID == UUID.Zero)
|
||||
return new LSL_Rotation();
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
if (item.PermsGranter == UUID.Zero)
|
||||
return new LSL_Rotation();
|
||||
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
|
||||
{
|
||||
if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
|
||||
return new LSL_Rotation();
|
||||
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
|
||||
{
|
||||
ShoutError("No permissions to track the camera");
|
||||
return new LSL_Rotation();
|
||||
}
|
||||
ShoutError("No permissions to track the camera");
|
||||
return new LSL_Rotation();
|
||||
}
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
|
||||
@@ -9911,23 +9801,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
// our key in the object we are in
|
||||
UUID invItemID = InventorySelf();
|
||||
if (invItemID == UUID.Zero) return;
|
||||
|
||||
// the object we are in
|
||||
UUID objectID = m_host.ParentUUID;
|
||||
if (objectID == UUID.Zero) return;
|
||||
if (objectID == UUID.Zero)
|
||||
return;
|
||||
|
||||
UUID agentID;
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
// we need the permission first, to know which avatar we want to set the camera for
|
||||
agentID = m_host.TaskInventory[invItemID].PermsGranter;
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
if (agentID == UUID.Zero) return;
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
|
||||
}
|
||||
// we need the permission first, to know which avatar we want to set the camera for
|
||||
UUID agentID = item.PermsGranter;
|
||||
|
||||
if (agentID == UUID.Zero)
|
||||
return;
|
||||
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
|
||||
return;
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(agentID);
|
||||
|
||||
@@ -9967,27 +9855,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
// our key in the object we are in
|
||||
UUID invItemID=InventorySelf();
|
||||
if (invItemID == UUID.Zero) return;
|
||||
|
||||
// the object we are in
|
||||
UUID objectID = m_host.ParentUUID;
|
||||
if (objectID == UUID.Zero) return;
|
||||
if (objectID == UUID.Zero)
|
||||
return;
|
||||
|
||||
TaskInventoryItem item = GetSelfInventoryItem();
|
||||
|
||||
// we need the permission first, to know which avatar we want to clear the camera for
|
||||
UUID agentID;
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
agentID = m_host.TaskInventory[invItemID].PermsGranter;
|
||||
if (agentID == UUID.Zero) return;
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
|
||||
}
|
||||
UUID agentID = item.PermsGranter;
|
||||
|
||||
if (agentID == UUID.Zero)
|
||||
return;
|
||||
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
|
||||
return;
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(agentID);
|
||||
|
||||
// we are not interested in child-agents
|
||||
if (presence.IsChildAgent) return;
|
||||
if (presence.IsChildAgent)
|
||||
return;
|
||||
|
||||
presence.ControllingClient.SendClearFollowCamProperties(objectID);
|
||||
}
|
||||
|
||||
@@ -209,6 +209,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
throw new Exception("OSSL Runtime Error: " + msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the LSL interface.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// FIXME: This is an abomination. We should be able to set this up earlier but currently we have no
|
||||
/// guarantee the interface is present on Initialize(). There needs to be another post initialize call from
|
||||
/// ScriptInstance.
|
||||
/// </remarks>
|
||||
private void InitLSL()
|
||||
{
|
||||
if (m_LSL_Api != null)
|
||||
@@ -1609,7 +1617,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public Object osParseJSONNew(string JSON)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.None, "osParseJSON");
|
||||
CheckThreatLevel(ThreatLevel.None, "osParseJSONNew");
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
@@ -3132,5 +3140,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
|
||||
}
|
||||
}
|
||||
|
||||
public void osForceAttachToAvatar(int attachmentPoint)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
InitLSL();
|
||||
((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
|
||||
}
|
||||
|
||||
public void osForceDetachFromAvatar()
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
InitLSL();
|
||||
((LSL_Api)m_LSL_Api).DetachFromAvatar();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user