From c6c91e6599de6d4402ec0258da03cc975147da90 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 6 Aug 2011 00:13:08 +0100
Subject: refactor: Fold most SOP.ScriptSet* methods back into script code.
Simplify.
---
.../Shared/Api/Implementation/LSL_Api.cs | 27 ++++++----------------
1 file changed, 7 insertions(+), 20 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 26969a5..7c21ba9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1204,10 +1204,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((status & ScriptBaseClass.STATUS_PHANTOM) == ScriptBaseClass.STATUS_PHANTOM)
{
- if (value != 0)
- m_host.ScriptSetPhantomStatus(true);
- else
- m_host.ScriptSetPhantomStatus(false);
+ if (m_host.ParentGroup != null)
+ m_host.ParentGroup.ScriptSetPhantomStatus(value != 0);
}
if ((status & ScriptBaseClass.STATUS_CAST_SHADOWS) == ScriptBaseClass.STATUS_CAST_SHADOWS)
@@ -6446,9 +6444,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (m_host.ParentGroup != null)
{
if (!m_host.ParentGroup.IsDeleted)
- {
- m_host.ParentGroup.RootPart.ScriptSetVolumeDetect(detect!=0);
- }
+ m_host.ParentGroup.ScriptSetVolumeDetect(detect != 0);
}
}
@@ -6456,7 +6452,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// This is a depecated function so this just replicates the result of
/// invoking it in SL
///
-
public void llRemoteLoadScript(string target, string name, int running, int start_param)
{
m_host.AddScriptLPS(1);
@@ -7254,14 +7249,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return;
string ph = rules.Data[idx++].ToString();
- bool phantom;
- if (ph.Equals("1"))
- phantom = true;
- else
- phantom = false;
+ if (m_host.ParentGroup != null)
+ m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1"));
- part.ScriptSetPhantomStatus(phantom);
break;
case (int)ScriptBaseClass.PRIM_PHYSICS:
@@ -7282,14 +7273,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (remain < 1)
return;
string temp = rules.Data[idx++].ToString();
- bool tempOnRez;
- if (temp.Equals("1"))
- tempOnRez = true;
- else
- tempOnRez = false;
+ if (m_host.ParentGroup != null)
+ m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1"));
- part.ScriptSetTemporaryStatus(tempOnRez);
break;
case (int)ScriptBaseClass.PRIM_TEXGEN:
--
cgit v1.1
From 78d8ce3816cde8702cfd4f5d198e2c69aff0a7be Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 8 Aug 2011 23:22:47 +0100
Subject: refactor: split out generic parts of osMakeNotecard() into a
separate. Add method doc. Other minor tidies.
---
.../Shared/Api/Implementation/OSSL_Api.cs | 157 +++++++++++++--------
1 file changed, 99 insertions(+), 58 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 8093502..32ad21f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -348,20 +348,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);
@@ -384,12 +383,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);
@@ -1021,6 +1022,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
drawList += "PenColor " + color + "; ";
return drawList;
}
+
// Deprecated
public string osSetPenColour(string drawList, string colour)
{
@@ -1182,11 +1184,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);
@@ -1208,11 +1212,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);
@@ -1222,10 +1228,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
module.SetSunParameter(param, value);
}
-
}
-
public string osWindActiveModelPluginName()
{
CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName");
@@ -1304,12 +1308,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);
@@ -1429,8 +1435,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()
@@ -1683,8 +1687,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
+ ///
+ /// 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
+ ///
+ ///
+ ///
public void osMessageObject(LSL_Key objectUUID, string message)
{
CheckThreatLevel(ThreatLevel.Low, "osMessageObject");
@@ -1699,24 +1710,34 @@ 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.
- //
+ ///
+ /// Write a notecard directly to the prim's inventory.
+ ///
+ ///
+ /// This needs ThreatLevel high. It is an excellent griefer tool,
+ /// In a loop, it can cause asset bloat and DOS levels of asset
+ /// writes.
+ ///
+ /// The name of the notecard to write.
+ /// The contents of the notecard.
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, notecardData.ToString());
+ }
+
+ protected void SaveNotecard(string notecardName, string notecardData)
+ {
// 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;
-
- for (int i = 0; i < contents.Length; i++) {
- notecardData += contents.GetLSLStringItem(i) + "\n";
- }
int textLength = notecardData.Length;
notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length "
@@ -1726,7 +1747,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
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;
@@ -1751,13 +1772,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.Inventory.AddInventoryItem(taskItem, false);
}
-
- /*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.
-
- Warning - due to the synchronous method this function uses to fetch assets, its use
- may be dangerous and unreliable while running in grid mode.
- */
+ ///
+ /// Directly get an entire notecard at once.
+ ///
+ ///
+ /// 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.
+ ///
+ /// Name of the notecard or its asset id
+ /// The line number to read. The first line is line 0
+ /// Notecard line
public string osGetNotecardLine(string name, int line)
{
CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine");
@@ -1799,17 +1826,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
};
return NotecardCache.GetLine(assetID, line, 255);
-
-
}
- /*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.
- */
-
+ ///
+ /// Get an entire notecard at once.
+ ///
+ ///
+ /// 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.
+ ///
+ /// Name of the notecard or its asset id
+ /// Notecard text
public string osGetNotecard(string name)
{
CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard");
@@ -1857,17 +1887,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
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.
- */
-
+ ///
+ /// Get the number of lines in the given notecard.
+ ///
+ ///
+ /// 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.
+ ///
+ /// Name of the notecard or its asset id
+ ///
public int osGetNumberOfNotecardLines(string name)
{
CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines");
@@ -1947,15 +1980,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
return "";
}
-
}
+ ///
+ /// Get the nickname of this grid, as set in the [GridInfo] config section.
+ ///
+ ///
/// 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.
- ///
+ ///
+ ///
public string osGetGridNick()
{
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick");
@@ -2063,12 +2098,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.
- //
+ ///
+ /// Get the primitive parameters of a linked prim.
+ ///
+ ///
+ /// 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.
+ ///
+ ///
+ ///
+ ///
public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules)
{
CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams");
@@ -2344,10 +2386,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
obj.Shape.ProjectionFocus = (float)focus;
obj.Shape.ProjectionAmbiance = (float)amb;
-
obj.ParentGroup.HasGroupChanged = true;
obj.ScheduleFullUpdate();
-
}
///
@@ -2372,6 +2412,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
});
+
return result;
}
@@ -2391,4 +2432,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
}
}
-}
+}
\ No newline at end of file
--
cgit v1.1
From 3e16a0fbdd9477f24a93e0e70311bfca7995e339 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 9 Aug 2011 00:12:41 +0100
Subject: factor out common notecard caching code from 3 methods.
---
.../Shared/Api/Implementation/OSSL_Api.cs | 167 +++++++++------------
1 file changed, 74 insertions(+), 93 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 32ad21f..154179c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1733,7 +1733,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
SaveNotecard(notecardName, notecardData.ToString());
}
- protected void SaveNotecard(string notecardName, string notecardData)
+ ///
+ /// Save a notecard to prim inventory.
+ ///
+ ///
+ ///
+ /// Prim inventory item created.
+ protected TaskInventoryItem SaveNotecard(string notecardName, string notecardData)
{
// Create new asset
AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString());
@@ -1770,6 +1776,66 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
taskItem.AssetID = asset.FullID;
m_host.Inventory.AddInventoryItem(taskItem, false);
+
+ return taskItem;
+ }
+
+ ///
+ /// Load the notecard data found at the given prim inventory item name or asset uuid.
+ ///
+ ///
+ /// The text loaded. Null if no notecard was found.
+ protected string LoadNotecard(string notecardNameOrUuid)
+ {
+ UUID assetID = CacheNotecard(notecardNameOrUuid);
+ StringBuilder notecardData = new StringBuilder();
+
+ for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
+ notecardData.Append(NotecardCache.GetLine(assetID, count, 255) + "\n");
+
+ return notecardData.ToString();
+ }
+
+ ///
+ /// Cache a notecard's contents.
+ ///
+ ///
+ ///
+ /// The asset id of the notecard, which is used for retrieving the cached data.
+ /// UUID.Zero if no asset could be found.
+ ///
+ protected UUID CacheNotecard(string notecardNameOrUuid)
+ {
+ UUID assetID = UUID.Zero;
+ StringBuilder notecardData = new StringBuilder();
+
+ if (!UUID.TryParse(notecardNameOrUuid, out assetID))
+ {
+ foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
+ {
+ if (item.Type == 7 && item.Name == notecardNameOrUuid)
+ {
+ assetID = item.AssetID;
+ }
+ }
+ }
+
+ 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;
}
///
@@ -1790,18 +1856,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine");
m_host.AddScriptLPS(1);
- UUID assetID = UUID.Zero;
-
- if (!UUID.TryParse(name, out assetID))
- {
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
- {
- if (item.Type == 7 && item.Name == name)
- {
- assetID = item.AssetID;
- }
- }
- }
+ UUID assetID = CacheNotecard(name);
if (assetID == UUID.Zero)
{
@@ -1809,22 +1864,6 @@ 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);
}
@@ -1845,48 +1884,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard");
m_host.AddScriptLPS(1);
- UUID assetID = UUID.Zero;
- string NotecardData = "";
-
- if (!UUID.TryParse(name, out assetID))
- {
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
- {
- if (item.Type == 7 && item.Name == name)
- {
- assetID = item.AssetID;
- }
- }
- }
+ string text = LoadNotecard(name);
- if (assetID == UUID.Zero)
+ if (text == null)
{
OSSLShoutError("Notecard '" + name + "' could not be found.");
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!";
- }
- };
-
- for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
+ else
{
- NotecardData += NotecardCache.GetLine(assetID, count, 255) + "\n";
+ return text;
}
-
- return NotecardData;
}
///
@@ -1906,18 +1914,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines");
m_host.AddScriptLPS(1);
- UUID assetID = UUID.Zero;
-
- if (!UUID.TryParse(name, out assetID))
- {
- foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
- {
- if (item.Type == 7 && item.Name == name)
- {
- assetID = item.AssetID;
- }
- }
- }
+ UUID assetID = CacheNotecard(name);
if (assetID == UUID.Zero)
{
@@ -1925,22 +1922,6 @@ 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);
}
@@ -2412,7 +2393,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
});
-
+
return result;
}
--
cgit v1.1
From e869eeb0bfc48c769f680970f99e4c67dd5a1a70 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 9 Aug 2011 03:51:34 +0100
Subject: Implement first draft functions for saving and loading NPC appearance
from storage.
This works by serializing and deserializing NPC AvatarAppearance to a notecard in the prim inventory and making the required baked textures permanent.
By using notecards, we avoid lots of awkward, technical and user-unfriendly issues concerning retaining asset references and creating a new asset type.
Notecards also allow different appearances to be swapped and manipulated easily.
This also allows stored NPC appearances to work transparently with OARs/IARs since the UUID scan will pick up and store the necessary references from the notecard text.
This works in my basic test but is not at all ready for user use or bug reporting yet.
---
.../Shared/Api/Implementation/LSL_Api.cs | 33 +++++--
.../Shared/Api/Implementation/OSSL_Api.cs | 104 ++++++++++++++++++---
2 files changed, 118 insertions(+), 19 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 7c21ba9..86ee28a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -10565,9 +10565,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
- public static string GetLine(UUID assetID, int line, int maxLength)
+ ///
+ /// Get a notecard line.
+ ///
+ ///
+ /// Lines start at index 0
+ ///
+ public static string GetLine(UUID assetID, int lineNumber)
{
- if (line < 0)
+ if (lineNumber < 0)
return "";
string data;
@@ -10579,17 +10585,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_Notecards[assetID].lastRef = DateTime.Now;
- if (line >= m_Notecards[assetID].text.Length)
+ if (lineNumber >= m_Notecards[assetID].text.Length)
return "\n\n\n";
- data = m_Notecards[assetID].text[line];
- if (data.Length > maxLength)
- data = data.Substring(0, maxLength);
+ data = m_Notecards[assetID].text[lineNumber];
return data;
}
}
+ ///
+ /// Get a notecard line.
+ ///
+ ///
+ /// Lines start at index 0
+ /// Maximum length of the returned line. Longer lines will be truncated
+ ///
+ public static string GetLine(UUID assetID, int lineNumber, int maxLength)
+ {
+ string line = GetLine(assetID, lineNumber);
+
+ if (line.Length > maxLength)
+ line = line.Substring(0, maxLength);
+
+ return line;
+ }
+
public static void CacheCheck()
{
foreach (UUID key in new List(m_Notecards.Keys))
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 154179c..07b36de 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -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;
@@ -1730,26 +1737,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
for (int i = 0; i < contents.Length; i++)
notecardData.Append((string)(contents.GetLSLStringItem(i) + "\n"));
- SaveNotecard(notecardName, notecardData.ToString());
+ SaveNotecard(notecardName, "Script generated notecard", notecardData.ToString(), false);
}
///
/// Save a notecard to prim inventory.
///
- ///
+ ///
+ /// Description of notecard
///
+ ///
+ /// 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)
+ ///
/// Prim inventory item created.
- protected TaskInventoryItem SaveNotecard(string notecardName, string notecardData)
+ 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";
+ AssetBase asset = new AssetBase(UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString());
+ asset.Description = description;
- int textLength = notecardData.Length;
- notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length "
- + textLength.ToString() + "\n" + notecardData + "}\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";
- asset.Data = Util.UTF8.GetBytes(notecardData);
+ asset.Data = Util.UTF8.GetBytes(data);
World.AssetService.Store(asset);
// Create Task Entry
@@ -1775,7 +1788,10 @@ 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;
}
@@ -1791,7 +1807,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
StringBuilder notecardData = new StringBuilder();
for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
- notecardData.Append(NotecardCache.GetLine(assetID, count, 255) + "\n");
+ {
+ 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();
}
@@ -1807,7 +1829,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected UUID CacheNotecard(string notecardNameOrUuid)
{
UUID assetID = UUID.Zero;
- StringBuilder notecardData = new StringBuilder();
if (!UUID.TryParse(notecardNameOrUuid, out assetID))
{
@@ -1864,7 +1885,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return "ERROR!";
}
- return NotecardCache.GetLine(assetID, line, 255);
+ return NotecardCache.GetLine(assetID, line);
}
///
@@ -2122,9 +2143,66 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Key(x.ToString());
}
+
return new LSL_Key(UUID.Zero.ToString());
}
+ public LSL_Key osNpcSaveAppearance(string avatar, string notecardName)
+ {
+ CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance");
+
+ INPCModule npcModule = World.RequestModuleInterface();
+ IAvatarFactory appearanceModule = World.RequestModuleInterface();
+
+ if (npcModule != null && appearanceModule != null)
+ {
+ UUID avatarId = UUID.Zero;
+ if (!UUID.TryParse(avatar, out avatarId))
+ return new LSL_Key(UUID.Zero.ToString());
+
+ if (!npcModule.IsNPC(avatarId, m_host.ParentGroup.Scene))
+ return new LSL_Key(UUID.Zero.ToString());
+
+ appearanceModule.SaveBakedTextures(avatarId);
+ ScenePresence sp = m_host.ParentGroup.Scene.GetScenePresence(avatarId);
+ OSDMap appearancePacked = sp.Appearance.Pack();
+
+ TaskInventoryItem item
+ = SaveNotecard(notecardName, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
+
+ return new LSL_Key(item.AssetID.ToString());
+ }
+
+ return new LSL_Key(UUID.Zero.ToString());
+ }
+
+ public void osNpcLoadAppearance(string avatar, string notecardNameOrUuid)
+ {
+ CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance");
+
+ INPCModule npcModule = World.RequestModuleInterface();
+
+ if (npcModule != null)
+ {
+ UUID avatarId = UUID.Zero;
+ if (!UUID.TryParse(avatar, out avatarId))
+ return;
+
+ if (!npcModule.IsNPC(avatarId, m_host.ParentGroup.Scene))
+ return;
+
+ string appearanceSerialized = LoadNotecard(notecardNameOrUuid);
+ 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(avatarId, appearance, m_host.ParentGroup.Scene);
+ }
+ }
+
public void osNpcMoveTo(LSL_Key npc, LSL_Vector position)
{
CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
--
cgit v1.1
From 795c8e6c22d4174d942ad56e70a0acbe507e2ec7 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 9 Aug 2011 22:05:47 +0100
Subject: Add osOwnerSaveAppearance() to help with setting up NPC appearances.
Not yet ready for user use.
Adds regression test.
---
.../Shared/Api/Implementation/OSSL_Api.cs | 51 +++++++++++++++++-----
1 file changed, 41 insertions(+), 10 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 07b36de..a05c623 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2147,14 +2147,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Key(UUID.Zero.ToString());
}
+ ///
+ /// Save the current appearance of the NPC permanently to the named notecard.
+ ///
+ ///
+ /// The name of the notecard to which to save the appearance.
+ /// The asset ID of the notecard saved.
public LSL_Key osNpcSaveAppearance(string avatar, string notecardName)
{
CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance");
INPCModule npcModule = World.RequestModuleInterface();
- IAvatarFactory appearanceModule = World.RequestModuleInterface();
- if (npcModule != null && appearanceModule != null)
+ if (npcModule != null)
{
UUID avatarId = UUID.Zero;
if (!UUID.TryParse(avatar, out avatarId))
@@ -2163,14 +2168,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!npcModule.IsNPC(avatarId, m_host.ParentGroup.Scene))
return new LSL_Key(UUID.Zero.ToString());
- appearanceModule.SaveBakedTextures(avatarId);
- ScenePresence sp = m_host.ParentGroup.Scene.GetScenePresence(avatarId);
- OSDMap appearancePacked = sp.Appearance.Pack();
-
- TaskInventoryItem item
- = SaveNotecard(notecardName, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
-
- return new LSL_Key(item.AssetID.ToString());
+ return SaveAppearanceToNotecard(avatarId, notecardName);
}
return new LSL_Key(UUID.Zero.ToString());
@@ -2236,6 +2234,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
module.DeleteNPC(new UUID(npc.m_string), World);
}
}
+
+ ///
+ /// Save the current appearance of the script owner permanently to the named notecard.
+ ///
+ /// The name of the notecard to which to save the appearance.
+ /// The asset ID of the notecard saved.
+ public LSL_Key osOwnerSaveAppearance(string notecardName)
+ {
+ CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance");
+
+ return SaveAppearanceToNotecard(m_host.OwnerID, notecardName);
+ }
+
+ protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecardName)
+ {
+ IAvatarFactory appearanceModule = World.RequestModuleInterface();
+
+ if (appearanceModule != null)
+ {
+ appearanceModule.SaveBakedTextures(m_host.OwnerID);
+ ScenePresence sp = m_host.ParentGroup.Scene.GetScenePresence(m_host.OwnerID);
+ OSDMap appearancePacked = sp.Appearance.Pack();
+
+ TaskInventoryItem item
+ = SaveNotecard(notecardName, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
+
+ return new LSL_Key(item.AssetID.ToString());
+ }
+ else
+ {
+ return new LSL_Key(UUID.Zero.ToString());
+ }
+ }
///
/// Get current region's map texture UUID
--
cgit v1.1
From 195c1dc9b8b8511980d9a607a242b24a5a91da17 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 10 Aug 2011 00:26:38 +0100
Subject: implement osNpcStopMoveTo() to cancel any current move target
---
.../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 9 +++++++++
1 file changed, 9 insertions(+)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index a05c623..9c32029 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2213,6 +2213,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
+ public void osNpcStopMoveTo(LSL_Key npc)
+ {
+ CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo");
+
+ INPCModule module = World.RequestModuleInterface();
+ if (module != null)
+ module.StopMoveToTarget(new UUID(npc.m_string), World);
+ }
+
public void osNpcSay(LSL_Key npc, string message)
{
CheckThreatLevel(ThreatLevel.High, "osNpcSay");
--
cgit v1.1
From 5d6c9644faf6aeac38410af9cff97adfef88d7aa Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 10 Aug 2011 01:47:37 +0100
Subject: early code to allow scripts to force npcs not to fly when moving to
target
this is to allow walking on prims. it will be up to the script writer to be sure that there is a continuous path.
currently implemented in osNpcMoveToTarget(), but none of this is final.
---
.../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 9c32029..63c882d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2209,7 +2209,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (module != null)
{
Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
- module.MoveToTarget(new UUID(npc.m_string), World, pos);
+ module.MoveToTarget(new UUID(npc.m_string), World, pos, false);
+ }
+ }
+
+ public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int noFly)
+ {
+ CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget");
+
+ INPCModule module = World.RequestModuleInterface();
+ if (module != null)
+ {
+ Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
+ module.MoveToTarget(new UUID(npc.m_string), World, pos, noFly != 0);
}
}
--
cgit v1.1
From fb92678b83dca1c1f64cc91f3ac887170408a455 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 10 Aug 2011 22:34:42 +0100
Subject: fly and no fly constants for osNpcMoveToTarget()
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 63c882d..9b5d8d9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2220,7 +2220,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
INPCModule module = World.RequestModuleInterface();
if (module != null)
{
- Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
+ Vector3 pos = new Vector3((float)position.x, (float)position.y, (float)position.z);
module.MoveToTarget(new UUID(npc.m_string), World, pos, noFly != 0);
}
}
--
cgit v1.1
From 7f499ff3f386d57bcd81ebb3f58f110011100604 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 10 Aug 2011 23:56:19 +0100
Subject: Add a OS_NPC_LAND_AT_TARGET option to osMoveToTarget()
Default for this function is now not to automatically land.
This allows better control by scripts when an avatar is going to be landing on a prim rather than the ground.
Stopping the avatar involves faking a collision, to avoid the pid controller making it overshoot.
A better approach would be to gradually slow the avatar as we near the target
---
.../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 9b5d8d9..f83304b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2209,11 +2209,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (module != null)
{
Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
- module.MoveToTarget(new UUID(npc.m_string), World, pos, false);
+ module.MoveToTarget(new UUID(npc.m_string), World, pos, false, true);
}
}
- public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int noFly)
+ public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int moveParams)
{
CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget");
@@ -2221,7 +2221,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (module != null)
{
Vector3 pos = new Vector3((float)position.x, (float)position.y, (float)position.z);
- module.MoveToTarget(new UUID(npc.m_string), World, pos, noFly != 0);
+ module.MoveToTarget(
+ new UUID(npc.m_string),
+ World,
+ pos,
+ (moveParams & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
+ (moveParams & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0);
}
}
--
cgit v1.1
From 4402851b086e7faf0d441d2ae0d5f6a3e1ea04b8 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 11 Aug 2011 01:56:42 +0100
Subject: Get NPCs to revert to the correct 'resting' animation (e.g. stand or
hover) after finishing their movement. This also fixes judder after an
avatar has finished "go here"/autopilot movement in a viewer.
This meant reseting the SP.AgentControlFlags since the Animator uses these to determine the correct default animation.
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index f83304b..71fc15f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -870,7 +870,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence target = (ScenePresence)World.Entities[avatarID];
if (target != null)
{
- UUID animID=UUID.Zero;
+ UUID animID = UUID.Zero;
lock (m_host.TaskInventory)
{
foreach (KeyValuePair inv in m_host.TaskInventory)
--
cgit v1.1
From ee22569c9262277467df9a4b15674a1472fa0b71 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 11 Aug 2011 02:19:13 +0100
Subject: only accept npc UUIDs to osNpc* functions, not names (except for
create)
---
.../Shared/Api/Implementation/OSSL_Api.cs | 26 +++++++++-------------
1 file changed, 11 insertions(+), 15 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 71fc15f..91ac3b7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2153,7 +2153,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
///
/// The name of the notecard to which to save the appearance.
/// The asset ID of the notecard saved.
- public LSL_Key osNpcSaveAppearance(string avatar, string notecardName)
+ public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecardName)
{
CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance");
@@ -2161,20 +2161,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (npcModule != null)
{
- UUID avatarId = UUID.Zero;
- if (!UUID.TryParse(avatar, out avatarId))
- return new LSL_Key(UUID.Zero.ToString());
+ UUID npcId = new UUID(npc.m_string);
- if (!npcModule.IsNPC(avatarId, m_host.ParentGroup.Scene))
+ if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
return new LSL_Key(UUID.Zero.ToString());
- return SaveAppearanceToNotecard(avatarId, notecardName);
+ return SaveAppearanceToNotecard(npcId, notecardName);
}
return new LSL_Key(UUID.Zero.ToString());
}
- public void osNpcLoadAppearance(string avatar, string notecardNameOrUuid)
+ public void osNpcLoadAppearance(LSL_Key npc, string notecardNameOrUuid)
{
CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance");
@@ -2182,11 +2180,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (npcModule != null)
{
- UUID avatarId = UUID.Zero;
- if (!UUID.TryParse(avatar, out avatarId))
- return;
+ UUID npcId = new UUID(npc.m_string);
- if (!npcModule.IsNPC(avatarId, m_host.ParentGroup.Scene))
+ if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
return;
string appearanceSerialized = LoadNotecard(notecardNameOrUuid);
@@ -2197,7 +2193,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
AvatarAppearance appearance = new AvatarAppearance();
appearance.Unpack(appearanceOsd);
- npcModule.SetNPCAppearance(avatarId, appearance, m_host.ParentGroup.Scene);
+ npcModule.SetNPCAppearance(npcId, appearance, m_host.ParentGroup.Scene);
}
}
@@ -2213,7 +2209,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
- public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int moveParams)
+ public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int options)
{
CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget");
@@ -2225,8 +2221,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
new UUID(npc.m_string),
World,
pos,
- (moveParams & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
- (moveParams & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0);
+ (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
+ (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0);
}
}
--
cgit v1.1
From 50945dd56029a1280c581ea9b29213ab0e162a0a Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 11 Aug 2011 21:43:26 +0100
Subject: add regression test for osNpcCreate when cloning an in-region avatar
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 91ac3b7..b18aa3b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2135,11 +2135,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
INPCModule module = World.RequestModuleInterface();
if (module != null)
{
+ ScenePresence clonePresence = World.GetScenePresence(new UUID(cloneFrom.m_string));
+ if (clonePresence == 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));
+ clonePresence.Appearance);
return new LSL_Key(x.ToString());
}
--
cgit v1.1
From b1ae930c6b8e7d985e2c148a4e18a59ac880dcbd Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 11 Aug 2011 22:26:47 +0100
Subject: Implement osAgentSaveAppearance() to save the appearance of an avatar
in the region to a notecard
This is separate from osOwnerSaveAppearance() so that owner saves can be allowed without allowing arbitrary avatar saves
---
.../Shared/Api/Implementation/OSSL_Api.cs | 35 +++++++++++++++++++---
1 file changed, 31 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index b18aa3b..939602a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2165,7 +2165,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (npcModule != null)
{
- UUID npcId = new UUID(npc.m_string);
+ 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());
@@ -2273,14 +2275,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return SaveAppearanceToNotecard(m_host.OwnerID, notecardName);
}
- protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecardName)
+ public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecardName)
+ {
+ CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance");
+
+ return SaveAppearanceToNotecard(avatarId, notecardName);
+ }
+
+ protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecardName)
{
IAvatarFactory appearanceModule = World.RequestModuleInterface();
if (appearanceModule != null)
{
- appearanceModule.SaveBakedTextures(m_host.OwnerID);
- ScenePresence sp = m_host.ParentGroup.Scene.GetScenePresence(m_host.OwnerID);
+ appearanceModule.SaveBakedTextures(sp.UUID);
OSDMap appearancePacked = sp.Appearance.Pack();
TaskInventoryItem item
@@ -2293,6 +2301,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Key(UUID.Zero.ToString());
}
}
+
+ protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecardName)
+ {
+ ScenePresence sp = World.GetScenePresence(avatarId);
+
+ if (sp == null || sp.IsChildAgent)
+ return new LSL_Key(UUID.Zero.ToString());
+
+ return SaveAppearanceToNotecard(sp, notecardName);
+ }
+
+ protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecardName)
+ {
+ UUID avatarId;
+ if (!UUID.TryParse(rawAvatarId, out avatarId))
+ return new LSL_Key(UUID.Zero.ToString());
+
+ return SaveAppearanceToNotecard(avatarId, notecardName);
+ }
///
/// Get current region's map texture UUID
--
cgit v1.1
From a21e98ae1a3e2f570cc119e020d4d4ea111e0ad2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 11 Aug 2011 23:28:14 +0100
Subject: implement osNpcGetRot() and osNpcSetRot()
Rotation works if done around the z axis. Anything else leads to random results.
---
.../Shared/Api/Implementation/LSL_Api.cs | 3 +-
.../Shared/Api/Implementation/OSSL_Api.cs | 57 ++++++++++++++++++++--
2 files changed, 55 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 86ee28a..8a281d4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -369,7 +369,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// convert a LSL_Rotation to a Quaternion
- protected Quaternion Rot2Quaternion(LSL_Rotation r)
+ public static Quaternion Rot2Quaternion(LSL_Rotation r)
{
Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
q.Normalize();
@@ -2061,6 +2061,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
return llGetRootRotation();
}
+
m_host.AddScriptLPS(1);
Quaternion q = m_host.GetWorldRotation();
return new LSL_Rotation(q.X, q.Y, q.Z, q.W);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 939602a..1874826 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2186,9 +2186,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (npcModule != null)
{
- UUID npcId = new UUID(npc.m_string);
-
- if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
+ UUID npcId;
+ if (!UUID.TryParse(npc.m_string, out npcId))
return;
string appearanceSerialized = LoadNotecard(notecardNameOrUuid);
@@ -2210,8 +2209,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
INPCModule module = World.RequestModuleInterface();
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.MoveToTarget(new UUID(npc.m_string), World, pos, false, true);
+ module.MoveToTarget(npcId, World, pos, false, true);
}
}
@@ -2222,6 +2225,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
INPCModule module = World.RequestModuleInterface();
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.MoveToTarget(
new UUID(npc.m_string),
@@ -2232,6 +2239,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
+ public LSL_Rotation osNpcGetRot(LSL_Key npc)
+ {
+ CheckThreatLevel(ThreatLevel.High, "osNpcGetRot");
+
+ INPCModule npcModule = World.RequestModuleInterface();
+ 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();
+ 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 osNpcStopMoveTo(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo");
--
cgit v1.1
From d23d37d2aa7c5a3d9c6ec1726aef7941d5e52519 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 11 Aug 2011 23:36:22 +0100
Subject: implement osNpcGetPos()
---
.../Shared/Api/Implementation/OSSL_Api.cs | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 1874826..b1066b5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2202,6 +2202,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
+ public LSL_Vector osNpcGetPos(LSL_Key npc)
+ {
+ CheckThreatLevel(ThreatLevel.High, "osNpcGetPos");
+
+ INPCModule npcModule = World.RequestModuleInterface();
+ 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");
--
cgit v1.1
From 0a1bbc27d26a430c53e84e22b7aad0df2f1f4a09 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 12 Aug 2011 00:14:06 +0100
Subject: Allow the osNpcCreate() function to accept a notecard name or asset
for initial appearance
---
.../Shared/Api/Implementation/OSSL_Api.cs | 28 ++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index b1066b5..90c4636 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2130,20 +2130,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom)
{
CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
- //QueueUserWorkItem
INPCModule module = World.RequestModuleInterface();
if (module != null)
{
- ScenePresence clonePresence = World.GetScenePresence(new UUID(cloneFrom.m_string));
- if (clonePresence == null)
+ AvatarAppearance appearance = null;
+
+ UUID cloneId;
+ if (UUID.TryParse(cloneFrom, out cloneId))
+ {
+ ScenePresence clonePresence = World.GetScenePresence(new UUID(cloneFrom.m_string));
+ if (clonePresence != null)
+ appearance = clonePresence.Appearance;
+ }
+
+ if (appearance == null)
+ {
+ string appearanceSerialized = LoadNotecard(cloneFrom.m_string);
+
+ 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,
- clonePresence.Appearance);
+ appearance);
return new LSL_Key(x.ToString());
}
--
cgit v1.1
From aebd46a4348cf55d25eaa56325940a0f33d8b8fe Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 12 Aug 2011 01:32:49 +0100
Subject: rename osNpcStopMoveTo() to osNpcStopMoveToTarget()
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 90c4636..07473e5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2322,7 +2322,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
- public void osNpcStopMoveTo(LSL_Key npc)
+ public void osNpcStopMoveToTarget(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo");
--
cgit v1.1
From 16ac5413ddb57ac347addebc82d425364a083637 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 12 Aug 2011 01:52:12 +0100
Subject: rename position parameter in osNpcMoveToTarget to target
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 07473e5..2e28907 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2259,7 +2259,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
- public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int options)
+ public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options)
{
CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget");
@@ -2270,7 +2270,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(npc.m_string, out npcId))
return;
- Vector3 pos = new Vector3((float)position.x, (float)position.y, (float)position.z);
+ Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z);
module.MoveToTarget(
new UUID(npc.m_string),
World,
--
cgit v1.1
From 76e0afe83f012e451a66a145c50e79c1bd047f37 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 12 Aug 2011 02:46:44 +0100
Subject: tidy up some OSSL NPC parameter names
---
.../Shared/Api/Implementation/OSSL_Api.cs | 42 +++++++++++-----------
1 file changed, 21 insertions(+), 21 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 2e28907..d791885 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2127,7 +2127,7 @@ 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");
@@ -2136,17 +2136,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
AvatarAppearance appearance = null;
- UUID cloneId;
- if (UUID.TryParse(cloneFrom, out cloneId))
+ UUID id;
+ if (UUID.TryParse(notecard, out id))
{
- ScenePresence clonePresence = World.GetScenePresence(new UUID(cloneFrom.m_string));
+ ScenePresence clonePresence = World.GetScenePresence(id);
if (clonePresence != null)
appearance = clonePresence.Appearance;
}
if (appearance == null)
{
- string appearanceSerialized = LoadNotecard(cloneFrom.m_string);
+ string appearanceSerialized = LoadNotecard(notecard);
if (appearanceSerialized != null)
{
@@ -2175,9 +2175,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// Save the current appearance of the NPC permanently to the named notecard.
///
///
- /// The name of the notecard to which to save the appearance.
+ /// The name of the notecard to which to save the appearance.
/// The asset ID of the notecard saved.
- public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecardName)
+ public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard)
{
CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance");
@@ -2192,13 +2192,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
return new LSL_Key(UUID.Zero.ToString());
- return SaveAppearanceToNotecard(npcId, notecardName);
+ return SaveAppearanceToNotecard(npcId, notecard);
}
return new LSL_Key(UUID.Zero.ToString());
}
- public void osNpcLoadAppearance(LSL_Key npc, string notecardNameOrUuid)
+ public void osNpcLoadAppearance(LSL_Key npc, string notecard)
{
CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance");
@@ -2210,7 +2210,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(npc.m_string, out npcId))
return;
- string appearanceSerialized = LoadNotecard(notecardNameOrUuid);
+ string appearanceSerialized = LoadNotecard(notecard);
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
// Console.WriteLine("appearanceSerialized {0}", appearanceSerialized);
@@ -2356,23 +2356,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
///
/// Save the current appearance of the script owner permanently to the named notecard.
///
- /// The name of the notecard to which to save the appearance.
+ /// The name of the notecard to which to save the appearance.
/// The asset ID of the notecard saved.
- public LSL_Key osOwnerSaveAppearance(string notecardName)
+ public LSL_Key osOwnerSaveAppearance(string notecard)
{
CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance");
- return SaveAppearanceToNotecard(m_host.OwnerID, notecardName);
+ return SaveAppearanceToNotecard(m_host.OwnerID, notecard);
}
- public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecardName)
+ public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard)
{
CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance");
- return SaveAppearanceToNotecard(avatarId, notecardName);
+ return SaveAppearanceToNotecard(avatarId, notecard);
}
- protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecardName)
+ protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecard)
{
IAvatarFactory appearanceModule = World.RequestModuleInterface();
@@ -2382,7 +2382,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
OSDMap appearancePacked = sp.Appearance.Pack();
TaskInventoryItem item
- = SaveNotecard(notecardName, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
+ = SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
return new LSL_Key(item.AssetID.ToString());
}
@@ -2392,23 +2392,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
- protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecardName)
+ 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, notecardName);
+ return SaveAppearanceToNotecard(sp, notecard);
}
- protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecardName)
+ 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, notecardName);
+ return SaveAppearanceToNotecard(avatarId, notecard);
}
///
--
cgit v1.1
From b80dfb6572438cb583e95884c0f607342f0c88d4 Mon Sep 17 00:00:00 2001
From: Micheil Merlin
Date: Fri, 12 Aug 2011 21:09:01 -0500
Subject: llGetPrimitiveParams fix prim hollow/hole shape value
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 8a281d4..c84afee 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7650,7 +7650,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case ScriptBaseClass.PRIM_TYPE_BOX:
case ScriptBaseClass.PRIM_TYPE_CYLINDER:
case ScriptBaseClass.PRIM_TYPE_PRISM:
- res.Add(new LSL_Integer(Shape.ProfileCurve));
+ res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
@@ -7659,7 +7659,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
case ScriptBaseClass.PRIM_TYPE_SPHERE:
- res.Add(new LSL_Integer(Shape.ProfileCurve));
+ res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
@@ -7675,7 +7675,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case ScriptBaseClass.PRIM_TYPE_TUBE:
case ScriptBaseClass.PRIM_TYPE_TORUS:
// holeshape
- res.Add(new LSL_Integer(Shape.ProfileCurve));
+ res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
// cut
res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
--
cgit v1.1