mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
Resolve merge commits, stage 1
This commit is contained in:
@@ -28,11 +28,16 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Remoting.Lifetime;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using Nini.Config;
|
||||
using OpenSim;
|
||||
using OpenSim.Framework;
|
||||
@@ -119,6 +124,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
[Serializable]
|
||||
public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
internal IScriptEngine m_ScriptEngine;
|
||||
internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there
|
||||
internal SceneObjectPart m_host;
|
||||
@@ -357,20 +364,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
System.Threading.Thread.Sleep(delay);
|
||||
}
|
||||
|
||||
//
|
||||
// OpenSim functions
|
||||
//
|
||||
public LSL_Integer osSetTerrainHeight(int x, int y, double val)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight");
|
||||
return SetTerrainHeight(x, y, val);
|
||||
}
|
||||
|
||||
public LSL_Integer osTerrainSetHeight(int x, int y, double val)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight");
|
||||
OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight");
|
||||
return SetTerrainHeight(x, y, val);
|
||||
}
|
||||
|
||||
private LSL_Integer SetTerrainHeight(int x, int y, double val)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
@@ -393,12 +399,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight");
|
||||
return GetTerrainHeight(x, y);
|
||||
}
|
||||
|
||||
public LSL_Float osTerrainGetHeight(int x, int y)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight");
|
||||
OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight");
|
||||
return GetTerrainHeight(x, y);
|
||||
}
|
||||
|
||||
private LSL_Float GetTerrainHeight(int x, int y)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
@@ -673,13 +681,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
CheckThreatLevel(ThreatLevel.VeryLow, "osSetPrimFloatOnWater");
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
if (m_host.ParentGroup != null)
|
||||
{
|
||||
if (m_host.ParentGroup.RootPart != null)
|
||||
{
|
||||
m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN);
|
||||
}
|
||||
}
|
||||
|
||||
m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN);
|
||||
}
|
||||
|
||||
// Teleport functions
|
||||
@@ -870,7 +873,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
ScenePresence target = (ScenePresence)World.Entities[avatarID];
|
||||
if (target != null)
|
||||
{
|
||||
UUID animID=UUID.Zero;
|
||||
UUID animID = UUID.Zero;
|
||||
m_host.TaskInventory.LockItemsForRead(true);
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
@@ -1028,6 +1031,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
drawList += "PenColor " + color + "; ";
|
||||
return drawList;
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
public string osSetPenColour(string drawList, string colour)
|
||||
{
|
||||
@@ -1189,11 +1193,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
OSSLDeprecated("osSunGetParam", "osGetSunParam");
|
||||
return GetSunParam(param);
|
||||
}
|
||||
|
||||
public double osGetSunParam(string param)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.None, "osGetSunParam");
|
||||
return GetSunParam(param);
|
||||
}
|
||||
|
||||
private double GetSunParam(string param)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
@@ -1215,11 +1221,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
OSSLDeprecated("osSunSetParam", "osSetSunParam");
|
||||
SetSunParam(param, value);
|
||||
}
|
||||
|
||||
public void osSetSunParam(string param, double value)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.None, "osSetSunParam");
|
||||
SetSunParam(param, value);
|
||||
}
|
||||
|
||||
private void SetSunParam(string param, double value)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
@@ -1229,10 +1237,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
module.SetSunParameter(param, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public string osWindActiveModelPluginName()
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName");
|
||||
@@ -1311,12 +1317,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
OSSLDeprecated(functionName, "osSetParcelDetails");
|
||||
SetParcelDetails(pos, rules, functionName);
|
||||
}
|
||||
|
||||
public void osSetParcelDetails(LSL_Vector pos, LSL_List rules)
|
||||
{
|
||||
const string functionName = "osSetParcelDetails";
|
||||
CheckThreatLevel(ThreatLevel.High, functionName);
|
||||
SetParcelDetails(pos, rules, functionName);
|
||||
}
|
||||
|
||||
private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
@@ -1436,8 +1444,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID);
|
||||
else
|
||||
OSSLError("osSetParcelSIPAddress: No voice module enabled for this land");
|
||||
|
||||
|
||||
}
|
||||
|
||||
public string osGetScriptEngineName()
|
||||
@@ -1690,8 +1696,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return jsondata;
|
||||
}
|
||||
|
||||
// send a message to to object identified by the given UUID, a script in the object must implement the dataserver function
|
||||
// the dataserver function is passed the ID of the calling function and a string message
|
||||
/// <summary>
|
||||
/// Send a message to to object identified by the given UUID
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A script in the object must implement the dataserver function
|
||||
/// the dataserver function is passed the ID of the calling function and a string message
|
||||
/// </remarks>
|
||||
/// <param name="objectUUID"></param>
|
||||
/// <param name="message"></param>
|
||||
public void osMessageObject(LSL_Key objectUUID, string message)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Low, "osMessageObject");
|
||||
@@ -1706,34 +1719,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
"dataserver", resobj, new DetectParams[0]));
|
||||
}
|
||||
|
||||
|
||||
// This needs ThreatLevel high. It is an excellent griefer tool,
|
||||
// In a loop, it can cause asset bloat and DOS levels of asset
|
||||
// writes.
|
||||
//
|
||||
/// <summary>
|
||||
/// Write a notecard directly to the prim's inventory.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This needs ThreatLevel high. It is an excellent griefer tool,
|
||||
/// In a loop, it can cause asset bloat and DOS levels of asset
|
||||
/// writes.
|
||||
/// </remarks>
|
||||
/// <param name="notecardName">The name of the notecard to write.</param>
|
||||
/// <param name="contents">The contents of the notecard.</param>
|
||||
public void osMakeNotecard(string notecardName, LSL_Types.list contents)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osMakeNotecard");
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
StringBuilder notecardData = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < contents.Length; i++)
|
||||
notecardData.Append((string)(contents.GetLSLStringItem(i) + "\n"));
|
||||
|
||||
SaveNotecard(notecardName, "Script generated notecard", notecardData.ToString(), false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save a notecard to prim inventory.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="description">Description of notecard</param>
|
||||
/// <param name="notecardData"></param>
|
||||
/// <param name="forceSameName">
|
||||
/// If true, then if an item exists with the same name, it is replaced.
|
||||
/// If false, then a new item is created witha slightly different name (e.g. name 1)
|
||||
/// </param>
|
||||
/// <returns>Prim inventory item created.</returns>
|
||||
protected TaskInventoryItem SaveNotecard(string name, string description, string data, bool forceSameName)
|
||||
{
|
||||
// Create new asset
|
||||
AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString());
|
||||
asset.Description = "Script Generated Notecard";
|
||||
string notecardData = String.Empty;
|
||||
AssetBase asset = new AssetBase(UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString());
|
||||
asset.Description = description;
|
||||
|
||||
for (int i = 0; i < contents.Length; i++) {
|
||||
notecardData += contents.GetLSLStringItem(i) + "\n";
|
||||
}
|
||||
int textLength = data.Length;
|
||||
data
|
||||
= "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length "
|
||||
+ textLength.ToString() + "\n" + data + "}\n";
|
||||
|
||||
int textLength = notecardData.Length;
|
||||
notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length "
|
||||
+ textLength.ToString() + "\n" + notecardData + "}\n";
|
||||
|
||||
asset.Data = Util.UTF8.GetBytes(notecardData);
|
||||
asset.Data = Util.UTF8.GetBytes(data);
|
||||
World.AssetService.Store(asset);
|
||||
|
||||
// Create Task Entry
|
||||
TaskInventoryItem taskItem=new TaskInventoryItem();
|
||||
TaskInventoryItem taskItem = new TaskInventoryItem();
|
||||
|
||||
taskItem.ResetIDs(m_host.UUID);
|
||||
taskItem.ParentID = m_host.UUID;
|
||||
@@ -1755,35 +1790,98 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
taskItem.PermsMask = 0;
|
||||
taskItem.AssetID = asset.FullID;
|
||||
|
||||
m_host.Inventory.AddInventoryItem(taskItem, false);
|
||||
if (forceSameName)
|
||||
m_host.Inventory.AddInventoryItemExclusive(taskItem, false);
|
||||
else
|
||||
m_host.Inventory.AddInventoryItem(taskItem, false);
|
||||
|
||||
return taskItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the notecard data found at the given prim inventory item name or asset uuid.
|
||||
/// </summary>
|
||||
/// <param name="notecardNameOrUuid"></param>
|
||||
/// <returns>The text loaded. Null if no notecard was found.</returns>
|
||||
protected string LoadNotecard(string notecardNameOrUuid)
|
||||
{
|
||||
UUID assetID = CacheNotecard(notecardNameOrUuid);
|
||||
StringBuilder notecardData = new StringBuilder();
|
||||
|
||||
/*Instead of using the LSL Dataserver event to pull notecard data,
|
||||
this will simply read the requested line and return its data as a string.
|
||||
for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
|
||||
{
|
||||
string line = NotecardCache.GetLine(assetID, count) + "\n";
|
||||
|
||||
Warning - due to the synchronous method this function uses to fetch assets, its use
|
||||
may be dangerous and unreliable while running in grid mode.
|
||||
*/
|
||||
// m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line);
|
||||
|
||||
notecardData.Append(line);
|
||||
}
|
||||
|
||||
return notecardData.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cache a notecard's contents.
|
||||
/// </summary>
|
||||
/// <param name="notecardNameOrUuid"></param>
|
||||
/// <returns>
|
||||
/// The asset id of the notecard, which is used for retrieving the cached data.
|
||||
/// UUID.Zero if no asset could be found.
|
||||
/// </returns>
|
||||
protected UUID CacheNotecard(string notecardNameOrUuid)
|
||||
{
|
||||
UUID assetID = UUID.Zero;
|
||||
|
||||
if (!UUID.TryParse(notecardNameOrUuid, out assetID))
|
||||
{
|
||||
m_host.TaskInventory.LockItemsForRead(true);
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
if (item.Type == 7 && item.Name == notecardNameOrUuid)
|
||||
{
|
||||
assetID = item.AssetID;
|
||||
}
|
||||
}
|
||||
m_host.TaskInventory.LockItemsForRead(false);
|
||||
}
|
||||
|
||||
if (assetID == UUID.Zero)
|
||||
return UUID.Zero;
|
||||
|
||||
if (!NotecardCache.IsCached(assetID))
|
||||
{
|
||||
AssetBase a = World.AssetService.Get(assetID.ToString());
|
||||
|
||||
if (a == null)
|
||||
return UUID.Zero;
|
||||
|
||||
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
|
||||
string data = enc.GetString(a.Data);
|
||||
NotecardCache.Cache(assetID, data);
|
||||
};
|
||||
|
||||
return assetID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Directly get an entire notecard at once.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Instead of using the LSL Dataserver event to pull notecard data
|
||||
/// this will simply read the entire notecard and return its data as a string.
|
||||
///
|
||||
/// Warning - due to the synchronous method this function uses to fetch assets, its use
|
||||
/// may be dangerous and unreliable while running in grid mode.
|
||||
/// </remarks>
|
||||
/// <param name="name">Name of the notecard or its asset id</param>
|
||||
/// <param name="line">The line number to read. The first line is line 0</param>
|
||||
/// <returns>Notecard line</returns>
|
||||
public string osGetNotecardLine(string name, int line)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine");
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
UUID assetID = UUID.Zero;
|
||||
|
||||
if (!UUID.TryParse(name, out assetID))
|
||||
{
|
||||
m_host.TaskInventory.LockItemsForRead(true);
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
if (item.Type == 7 && item.Name == name)
|
||||
{
|
||||
assetID = item.AssetID;
|
||||
}
|
||||
}
|
||||
m_host.TaskInventory.LockItemsForRead(false);
|
||||
}
|
||||
UUID assetID = CacheNotecard(name);
|
||||
|
||||
if (assetID == UUID.Zero)
|
||||
{
|
||||
@@ -1791,113 +1889,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return "ERROR!";
|
||||
}
|
||||
|
||||
if (!NotecardCache.IsCached(assetID))
|
||||
{
|
||||
AssetBase a = World.AssetService.Get(assetID.ToString());
|
||||
if (a != null)
|
||||
{
|
||||
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
|
||||
string data = enc.GetString(a.Data);
|
||||
NotecardCache.Cache(assetID, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSSLShoutError("Notecard '" + name + "' could not be found.");
|
||||
return "ERROR!";
|
||||
}
|
||||
};
|
||||
|
||||
return NotecardCache.GetLine(assetID, line, 255);
|
||||
|
||||
|
||||
return NotecardCache.GetLine(assetID, line);
|
||||
}
|
||||
|
||||
/*Instead of using the LSL Dataserver event to pull notecard data line by line,
|
||||
this will simply read the entire notecard and return its data as a string.
|
||||
|
||||
Warning - due to the synchronous method this function uses to fetch assets, its use
|
||||
may be dangerous and unreliable while running in grid mode.
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Get an entire notecard at once.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Instead of using the LSL Dataserver event to pull notecard data line by line,
|
||||
/// this will simply read the entire notecard and return its data as a string.
|
||||
///
|
||||
/// Warning - due to the synchronous method this function uses to fetch assets, its use
|
||||
/// may be dangerous and unreliable while running in grid mode.
|
||||
/// </remarks>
|
||||
/// <param name="name">Name of the notecard or its asset id</param>
|
||||
/// <returns>Notecard text</returns>
|
||||
public string osGetNotecard(string name)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard");
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
UUID assetID = UUID.Zero;
|
||||
string NotecardData = "";
|
||||
string text = LoadNotecard(name);
|
||||
|
||||
if (!UUID.TryParse(name, out assetID))
|
||||
{
|
||||
m_host.TaskInventory.LockItemsForRead(true);
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
if (item.Type == 7 && item.Name == name)
|
||||
{
|
||||
assetID = item.AssetID;
|
||||
}
|
||||
}
|
||||
m_host.TaskInventory.LockItemsForRead(false);
|
||||
}
|
||||
|
||||
if (assetID == UUID.Zero)
|
||||
if (text == null)
|
||||
{
|
||||
OSSLShoutError("Notecard '" + name + "' could not be found.");
|
||||
return "ERROR!";
|
||||
}
|
||||
|
||||
if (!NotecardCache.IsCached(assetID))
|
||||
else
|
||||
{
|
||||
AssetBase a = World.AssetService.Get(assetID.ToString());
|
||||
if (a != null)
|
||||
{
|
||||
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
|
||||
string data = enc.GetString(a.Data);
|
||||
NotecardCache.Cache(assetID, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSSLShoutError("Notecard '" + name + "' could not be found.");
|
||||
return "ERROR!";
|
||||
}
|
||||
};
|
||||
|
||||
for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
|
||||
{
|
||||
NotecardData += NotecardCache.GetLine(assetID, count, 255) + "\n";
|
||||
return text;
|
||||
}
|
||||
|
||||
return NotecardData;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*Instead of using the LSL Dataserver event to pull notecard data,
|
||||
this will simply read the number of note card lines and return this data as an integer.
|
||||
|
||||
Warning - due to the synchronous method this function uses to fetch assets, its use
|
||||
may be dangerous and unreliable while running in grid mode.
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Get the number of lines in the given notecard.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Instead of using the LSL Dataserver event to pull notecard data,
|
||||
/// this will simply read the number of note card lines and return this data as an integer.
|
||||
///
|
||||
/// Warning - due to the synchronous method this function uses to fetch assets, its use
|
||||
/// may be dangerous and unreliable while running in grid mode.
|
||||
/// </remarks>
|
||||
/// <param name="name">Name of the notecard or its asset id</param>
|
||||
/// <returns></returns>
|
||||
public int osGetNumberOfNotecardLines(string name)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines");
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
UUID assetID = UUID.Zero;
|
||||
|
||||
if (!UUID.TryParse(name, out assetID))
|
||||
{
|
||||
m_host.TaskInventory.LockItemsForRead(true);
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
if (item.Type == 7 && item.Name == name)
|
||||
{
|
||||
assetID = item.AssetID;
|
||||
}
|
||||
}
|
||||
m_host.TaskInventory.LockItemsForRead(false);
|
||||
}
|
||||
UUID assetID = CacheNotecard(name);
|
||||
|
||||
if (assetID == UUID.Zero)
|
||||
{
|
||||
@@ -1905,25 +1947,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!NotecardCache.IsCached(assetID))
|
||||
{
|
||||
AssetBase a = World.AssetService.Get(assetID.ToString());
|
||||
if (a != null)
|
||||
{
|
||||
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
|
||||
string data = enc.GetString(a.Data);
|
||||
NotecardCache.Cache(assetID, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSSLShoutError("Notecard '" + name + "' could not be found.");
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
return NotecardCache.GetLines(assetID);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public string osAvatarName2Key(string firstname, string lastname)
|
||||
@@ -1962,15 +1986,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the nickname of this grid, as set in the [GridInfo] config section.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Threat level is Moderate because intentional abuse, for instance
|
||||
/// scripts that are written to be malicious only on one grid,
|
||||
/// for instance in a HG scenario, are a distinct possibility.
|
||||
///
|
||||
/// Use value from the config file and return it.
|
||||
///
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
public string osGetGridNick()
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick");
|
||||
@@ -2037,7 +2063,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
// Find matches beginning at start position
|
||||
Regex matcher = new Regex(pattern);
|
||||
Match match = matcher.Match(src, start);
|
||||
if (match.Success)
|
||||
while (match.Success)
|
||||
{
|
||||
foreach (System.Text.RegularExpressions.Group g in match.Groups)
|
||||
{
|
||||
@@ -2047,6 +2073,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
result.Add(new LSL_Integer(g.Index));
|
||||
}
|
||||
}
|
||||
|
||||
match = match.NextMatch();
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -2076,12 +2104,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return World.RegionInfo.RegionSettings.LoadedCreationID;
|
||||
}
|
||||
|
||||
// Threat level is 'Low' because certain users could possibly be tricked into
|
||||
// dropping an unverified script into one of their own objects, which could
|
||||
// then gather the physical construction details of the object and transmit it
|
||||
// to an unscrupulous third party, thus permitting unauthorized duplication of
|
||||
// the object's form.
|
||||
//
|
||||
/// <summary>
|
||||
/// Get the primitive parameters of a linked prim.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Threat level is 'Low' because certain users could possibly be tricked into
|
||||
/// dropping an unverified script into one of their own objects, which could
|
||||
/// then gather the physical construction details of the object and transmit it
|
||||
/// to an unscrupulous third party, thus permitting unauthorized duplication of
|
||||
/// the object's form.
|
||||
/// </remarks>
|
||||
/// <param name="linknumber"></param>
|
||||
/// <param name="rules"></param>
|
||||
/// <returns></returns>
|
||||
public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams");
|
||||
@@ -2096,25 +2131,122 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom)
|
||||
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
|
||||
//QueueUserWorkItem
|
||||
|
||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||
if (module != null)
|
||||
{
|
||||
AvatarAppearance appearance = null;
|
||||
|
||||
UUID id;
|
||||
if (UUID.TryParse(notecard, out id))
|
||||
{
|
||||
ScenePresence clonePresence = World.GetScenePresence(id);
|
||||
if (clonePresence != null)
|
||||
appearance = clonePresence.Appearance;
|
||||
}
|
||||
|
||||
if (appearance == null)
|
||||
{
|
||||
string appearanceSerialized = LoadNotecard(notecard);
|
||||
|
||||
if (appearanceSerialized != null)
|
||||
{
|
||||
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
|
||||
appearance = new AvatarAppearance();
|
||||
appearance.Unpack(appearanceOsd);
|
||||
}
|
||||
}
|
||||
|
||||
if (appearance == null)
|
||||
return new LSL_Key(UUID.Zero.ToString());
|
||||
|
||||
UUID x = module.CreateNPC(firstname,
|
||||
lastname,
|
||||
new Vector3((float) position.x, (float) position.y, (float) position.z),
|
||||
World,
|
||||
new UUID(cloneFrom));
|
||||
appearance);
|
||||
|
||||
return new LSL_Key(x.ToString());
|
||||
}
|
||||
|
||||
return new LSL_Key(UUID.Zero.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the current appearance of the NPC permanently to the named notecard.
|
||||
/// </summary>
|
||||
/// <param name="avatar"></param>
|
||||
/// <param name="notecard">The name of the notecard to which to save the appearance.</param>
|
||||
/// <returns>The asset ID of the notecard saved.</returns>
|
||||
public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance");
|
||||
|
||||
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
|
||||
|
||||
if (npcModule != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
return new LSL_Key(UUID.Zero.ToString());
|
||||
|
||||
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
|
||||
return new LSL_Key(UUID.Zero.ToString());
|
||||
|
||||
return SaveAppearanceToNotecard(npcId, notecard);
|
||||
}
|
||||
|
||||
return new LSL_Key(UUID.Zero.ToString());
|
||||
}
|
||||
|
||||
public void osNpcLoadAppearance(LSL_Key npc, string notecard)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance");
|
||||
|
||||
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
|
||||
|
||||
if (npcModule != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
return;
|
||||
|
||||
string appearanceSerialized = LoadNotecard(notecard);
|
||||
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
|
||||
// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
|
||||
// Console.WriteLine("appearanceSerialized {0}", appearanceSerialized);
|
||||
// Console.WriteLine("a.Type {0}, a.ToString() {1}", a.Type, a);
|
||||
AvatarAppearance appearance = new AvatarAppearance();
|
||||
appearance.Unpack(appearanceOsd);
|
||||
|
||||
npcModule.SetNPCAppearance(npcId, appearance, m_host.ParentGroup.Scene);
|
||||
}
|
||||
}
|
||||
|
||||
public LSL_Vector osNpcGetPos(LSL_Key npc)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcGetPos");
|
||||
|
||||
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
|
||||
if (npcModule != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
return new LSL_Vector(0, 0, 0);
|
||||
|
||||
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
|
||||
return new LSL_Vector(0, 0, 0);
|
||||
|
||||
Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition;
|
||||
return new LSL_Vector(pos.X, pos.Y, pos.Z);
|
||||
}
|
||||
|
||||
return new LSL_Vector(0, 0, 0);
|
||||
}
|
||||
|
||||
public void osNpcMoveTo(LSL_Key npc, LSL_Vector position)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
|
||||
@@ -2122,11 +2254,87 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||
if (module != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
return;
|
||||
|
||||
Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
|
||||
module.Autopilot(new UUID(npc.m_string), World, pos);
|
||||
module.MoveToTarget(npcId, World, pos, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget");
|
||||
|
||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||
if (module != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
return;
|
||||
|
||||
Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z);
|
||||
module.MoveToTarget(
|
||||
new UUID(npc.m_string),
|
||||
World,
|
||||
pos,
|
||||
(options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
|
||||
(options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
public LSL_Rotation osNpcGetRot(LSL_Key npc)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcGetRot");
|
||||
|
||||
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
|
||||
if (npcModule != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
|
||||
|
||||
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
|
||||
return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
|
||||
|
||||
ScenePresence sp = World.GetScenePresence(npcId);
|
||||
Quaternion rot = sp.Rotation;
|
||||
|
||||
return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W);
|
||||
}
|
||||
|
||||
return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
|
||||
}
|
||||
|
||||
public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcSetRot");
|
||||
|
||||
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
|
||||
if (npcModule != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
return;
|
||||
|
||||
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
|
||||
return;
|
||||
|
||||
ScenePresence sp = World.GetScenePresence(npcId);
|
||||
sp.Rotation = LSL_Api.Rot2Quaternion(rotation);
|
||||
}
|
||||
}
|
||||
|
||||
public void osNpcStopMoveToTarget(LSL_Key npc)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo");
|
||||
|
||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||
if (module != null)
|
||||
module.StopMoveToTarget(new UUID(npc.m_string), World);
|
||||
}
|
||||
|
||||
public void osNpcSay(LSL_Key npc, string message)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcSay");
|
||||
@@ -2148,6 +2356,64 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
module.DeleteNPC(new UUID(npc.m_string), World);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the current appearance of the script owner permanently to the named notecard.
|
||||
/// </summary>
|
||||
/// <param name="notecard">The name of the notecard to which to save the appearance.</param>
|
||||
/// <returns>The asset ID of the notecard saved.</returns>
|
||||
public LSL_Key osOwnerSaveAppearance(string notecard)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance");
|
||||
|
||||
return SaveAppearanceToNotecard(m_host.OwnerID, notecard);
|
||||
}
|
||||
|
||||
public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance");
|
||||
|
||||
return SaveAppearanceToNotecard(avatarId, notecard);
|
||||
}
|
||||
|
||||
protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecard)
|
||||
{
|
||||
IAvatarFactory appearanceModule = World.RequestModuleInterface<IAvatarFactory>();
|
||||
|
||||
if (appearanceModule != null)
|
||||
{
|
||||
appearanceModule.SaveBakedTextures(sp.UUID);
|
||||
OSDMap appearancePacked = sp.Appearance.Pack();
|
||||
|
||||
TaskInventoryItem item
|
||||
= SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
|
||||
|
||||
return new LSL_Key(item.AssetID.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
return new LSL_Key(UUID.Zero.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecard)
|
||||
{
|
||||
ScenePresence sp = World.GetScenePresence(avatarId);
|
||||
|
||||
if (sp == null || sp.IsChildAgent)
|
||||
return new LSL_Key(UUID.Zero.ToString());
|
||||
|
||||
return SaveAppearanceToNotecard(sp, notecard);
|
||||
}
|
||||
|
||||
protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecard)
|
||||
{
|
||||
UUID avatarId;
|
||||
if (!UUID.TryParse(rawAvatarId, out avatarId))
|
||||
return new LSL_Key(UUID.Zero.ToString());
|
||||
|
||||
return SaveAppearanceToNotecard(avatarId, notecard);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get current region's map texture UUID
|
||||
@@ -2357,10 +2623,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
obj.Shape.ProjectionFocus = (float)focus;
|
||||
obj.Shape.ProjectionAmbiance = (float)amb;
|
||||
|
||||
|
||||
obj.ParentGroup.HasGroupChanged = true;
|
||||
obj.ScheduleFullUpdate();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2385,6 +2649,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2404,4 +2669,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user