aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
authorMic Bowman2011-08-19 14:49:16 -0700
committerMic Bowman2011-08-19 14:49:16 -0700
commit384cb79a1a27c47bb3fdbdef6d601a3dcb9dfb0f (patch)
tree5e557eac5d4d3d4ad95b9e3e70a2a661e5745ec3 /OpenSim/Region/ScriptEngine/Shared/Api
parentBulletSim: add runtime setting of physics parameters. Update default values. (diff)
parentGet rid of HttpServer.dll to avoid confusion since we use HttpServer_OpenSim.... (diff)
downloadopensim-SC-384cb79a1a27c47bb3fdbdef6d601a3dcb9dfb0f.zip
opensim-SC-384cb79a1a27c47bb3fdbdef6d601a3dcb9dfb0f.tar.gz
opensim-SC-384cb79a1a27c47bb3fdbdef6d601a3dcb9dfb0f.tar.bz2
opensim-SC-384cb79a1a27c47bb3fdbdef6d601a3dcb9dfb0f.tar.xz
Merge branch 'master' into bulletsim
Conflicts: OpenSim/Region/Framework/Scenes/SceneManager.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs69
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs574
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs45
5 files changed, 524 insertions, 182 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 26969a5..c84afee 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
369 } 369 }
370 370
371 // convert a LSL_Rotation to a Quaternion 371 // convert a LSL_Rotation to a Quaternion
372 protected Quaternion Rot2Quaternion(LSL_Rotation r) 372 public static Quaternion Rot2Quaternion(LSL_Rotation r)
373 { 373 {
374 Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); 374 Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
375 q.Normalize(); 375 q.Normalize();
@@ -1204,10 +1204,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1204 1204
1205 if ((status & ScriptBaseClass.STATUS_PHANTOM) == ScriptBaseClass.STATUS_PHANTOM) 1205 if ((status & ScriptBaseClass.STATUS_PHANTOM) == ScriptBaseClass.STATUS_PHANTOM)
1206 { 1206 {
1207 if (value != 0) 1207 if (m_host.ParentGroup != null)
1208 m_host.ScriptSetPhantomStatus(true); 1208 m_host.ParentGroup.ScriptSetPhantomStatus(value != 0);
1209 else
1210 m_host.ScriptSetPhantomStatus(false);
1211 } 1209 }
1212 1210
1213 if ((status & ScriptBaseClass.STATUS_CAST_SHADOWS) == ScriptBaseClass.STATUS_CAST_SHADOWS) 1211 if ((status & ScriptBaseClass.STATUS_CAST_SHADOWS) == ScriptBaseClass.STATUS_CAST_SHADOWS)
@@ -2063,6 +2061,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2063 { 2061 {
2064 return llGetRootRotation(); 2062 return llGetRootRotation();
2065 } 2063 }
2064
2066 m_host.AddScriptLPS(1); 2065 m_host.AddScriptLPS(1);
2067 Quaternion q = m_host.GetWorldRotation(); 2066 Quaternion q = m_host.GetWorldRotation();
2068 return new LSL_Rotation(q.X, q.Y, q.Z, q.W); 2067 return new LSL_Rotation(q.X, q.Y, q.Z, q.W);
@@ -6446,9 +6445,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6446 if (m_host.ParentGroup != null) 6445 if (m_host.ParentGroup != null)
6447 { 6446 {
6448 if (!m_host.ParentGroup.IsDeleted) 6447 if (!m_host.ParentGroup.IsDeleted)
6449 { 6448 m_host.ParentGroup.ScriptSetVolumeDetect(detect != 0);
6450 m_host.ParentGroup.RootPart.ScriptSetVolumeDetect(detect!=0);
6451 }
6452 } 6449 }
6453 } 6450 }
6454 6451
@@ -6456,7 +6453,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6456 /// This is a depecated function so this just replicates the result of 6453 /// This is a depecated function so this just replicates the result of
6457 /// invoking it in SL 6454 /// invoking it in SL
6458 /// </summary> 6455 /// </summary>
6459
6460 public void llRemoteLoadScript(string target, string name, int running, int start_param) 6456 public void llRemoteLoadScript(string target, string name, int running, int start_param)
6461 { 6457 {
6462 m_host.AddScriptLPS(1); 6458 m_host.AddScriptLPS(1);
@@ -7254,14 +7250,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7254 return; 7250 return;
7255 7251
7256 string ph = rules.Data[idx++].ToString(); 7252 string ph = rules.Data[idx++].ToString();
7257 bool phantom;
7258 7253
7259 if (ph.Equals("1")) 7254 if (m_host.ParentGroup != null)
7260 phantom = true; 7255 m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1"));
7261 else
7262 phantom = false;
7263 7256
7264 part.ScriptSetPhantomStatus(phantom);
7265 break; 7257 break;
7266 7258
7267 case (int)ScriptBaseClass.PRIM_PHYSICS: 7259 case (int)ScriptBaseClass.PRIM_PHYSICS:
@@ -7282,14 +7274,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7282 if (remain < 1) 7274 if (remain < 1)
7283 return; 7275 return;
7284 string temp = rules.Data[idx++].ToString(); 7276 string temp = rules.Data[idx++].ToString();
7285 bool tempOnRez;
7286 7277
7287 if (temp.Equals("1")) 7278 if (m_host.ParentGroup != null)
7288 tempOnRez = true; 7279 m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1"));
7289 else
7290 tempOnRez = false;
7291 7280
7292 part.ScriptSetTemporaryStatus(tempOnRez);
7293 break; 7281 break;
7294 7282
7295 case (int)ScriptBaseClass.PRIM_TEXGEN: 7283 case (int)ScriptBaseClass.PRIM_TEXGEN:
@@ -7662,7 +7650,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7662 case ScriptBaseClass.PRIM_TYPE_BOX: 7650 case ScriptBaseClass.PRIM_TYPE_BOX:
7663 case ScriptBaseClass.PRIM_TYPE_CYLINDER: 7651 case ScriptBaseClass.PRIM_TYPE_CYLINDER:
7664 case ScriptBaseClass.PRIM_TYPE_PRISM: 7652 case ScriptBaseClass.PRIM_TYPE_PRISM:
7665 res.Add(new LSL_Integer(Shape.ProfileCurve)); 7653 res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
7666 res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); 7654 res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
7667 res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); 7655 res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
7668 res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); 7656 res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
@@ -7671,7 +7659,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7671 break; 7659 break;
7672 7660
7673 case ScriptBaseClass.PRIM_TYPE_SPHERE: 7661 case ScriptBaseClass.PRIM_TYPE_SPHERE:
7674 res.Add(new LSL_Integer(Shape.ProfileCurve)); 7662 res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
7675 res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); 7663 res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
7676 res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); 7664 res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
7677 res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); 7665 res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
@@ -7687,7 +7675,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7687 case ScriptBaseClass.PRIM_TYPE_TUBE: 7675 case ScriptBaseClass.PRIM_TYPE_TUBE:
7688 case ScriptBaseClass.PRIM_TYPE_TORUS: 7676 case ScriptBaseClass.PRIM_TYPE_TORUS:
7689 // holeshape 7677 // holeshape
7690 res.Add(new LSL_Integer(Shape.ProfileCurve)); 7678 res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
7691 7679
7692 // cut 7680 // cut
7693 res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); 7681 res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
@@ -10578,9 +10566,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10578 } 10566 }
10579 } 10567 }
10580 10568
10581 public static string GetLine(UUID assetID, int line, int maxLength) 10569 /// <summary>
10570 /// Get a notecard line.
10571 /// </summary>
10572 /// <param name="assetID"></param>
10573 /// <param name="line">Lines start at index 0</param>
10574 /// <returns></returns>
10575 public static string GetLine(UUID assetID, int lineNumber)
10582 { 10576 {
10583 if (line < 0) 10577 if (lineNumber < 0)
10584 return ""; 10578 return "";
10585 10579
10586 string data; 10580 string data;
@@ -10592,17 +10586,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10592 { 10586 {
10593 m_Notecards[assetID].lastRef = DateTime.Now; 10587 m_Notecards[assetID].lastRef = DateTime.Now;
10594 10588
10595 if (line >= m_Notecards[assetID].text.Length) 10589 if (lineNumber >= m_Notecards[assetID].text.Length)
10596 return "\n\n\n"; 10590 return "\n\n\n";
10597 10591
10598 data = m_Notecards[assetID].text[line]; 10592 data = m_Notecards[assetID].text[lineNumber];
10599 if (data.Length > maxLength)
10600 data = data.Substring(0, maxLength);
10601 10593
10602 return data; 10594 return data;
10603 } 10595 }
10604 } 10596 }
10605 10597
10598 /// <summary>
10599 /// Get a notecard line.
10600 /// </summary>
10601 /// <param name="assetID"></param>
10602 /// <param name="line">Lines start at index 0</param>
10603 /// <param name="maxLength">Maximum length of the returned line. Longer lines will be truncated</para>
10604 /// <returns></returns>
10605 public static string GetLine(UUID assetID, int lineNumber, int maxLength)
10606 {
10607 string line = GetLine(assetID, lineNumber);
10608
10609 if (line.Length > maxLength)
10610 line = line.Substring(0, maxLength);
10611
10612 return line;
10613 }
10614
10606 public static void CacheCheck() 10615 public static void CacheCheck()
10607 { 10616 {
10608 foreach (UUID key in new List<UUID>(m_Notecards.Keys)) 10617 foreach (UUID key in new List<UUID>(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 8093502..d791885 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 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
31using System.Runtime.Remoting.Lifetime; 33using System.Runtime.Remoting.Lifetime;
32using System.Text; 34using System.Text;
33using System.Net; 35using System.Net;
34using System.Threading; 36using System.Threading;
37using System.Xml;
38using log4net;
35using OpenMetaverse; 39using OpenMetaverse;
40using OpenMetaverse.StructuredData;
36using Nini.Config; 41using Nini.Config;
37using OpenSim; 42using OpenSim;
38using OpenSim.Framework; 43using OpenSim.Framework;
@@ -119,6 +124,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
119 [Serializable] 124 [Serializable]
120 public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi 125 public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
121 { 126 {
127// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
128
122 internal IScriptEngine m_ScriptEngine; 129 internal IScriptEngine m_ScriptEngine;
123 internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there 130 internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there
124 internal SceneObjectPart m_host; 131 internal SceneObjectPart m_host;
@@ -348,20 +355,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
348 System.Threading.Thread.Sleep(delay); 355 System.Threading.Thread.Sleep(delay);
349 } 356 }
350 357
351 //
352 // OpenSim functions
353 //
354 public LSL_Integer osSetTerrainHeight(int x, int y, double val) 358 public LSL_Integer osSetTerrainHeight(int x, int y, double val)
355 { 359 {
356 CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight"); 360 CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight");
357 return SetTerrainHeight(x, y, val); 361 return SetTerrainHeight(x, y, val);
358 } 362 }
363
359 public LSL_Integer osTerrainSetHeight(int x, int y, double val) 364 public LSL_Integer osTerrainSetHeight(int x, int y, double val)
360 { 365 {
361 CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight"); 366 CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight");
362 OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight"); 367 OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight");
363 return SetTerrainHeight(x, y, val); 368 return SetTerrainHeight(x, y, val);
364 } 369 }
370
365 private LSL_Integer SetTerrainHeight(int x, int y, double val) 371 private LSL_Integer SetTerrainHeight(int x, int y, double val)
366 { 372 {
367 m_host.AddScriptLPS(1); 373 m_host.AddScriptLPS(1);
@@ -384,12 +390,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
384 CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight"); 390 CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight");
385 return GetTerrainHeight(x, y); 391 return GetTerrainHeight(x, y);
386 } 392 }
393
387 public LSL_Float osTerrainGetHeight(int x, int y) 394 public LSL_Float osTerrainGetHeight(int x, int y)
388 { 395 {
389 CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight"); 396 CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight");
390 OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight"); 397 OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight");
391 return GetTerrainHeight(x, y); 398 return GetTerrainHeight(x, y);
392 } 399 }
400
393 private LSL_Float GetTerrainHeight(int x, int y) 401 private LSL_Float GetTerrainHeight(int x, int y)
394 { 402 {
395 m_host.AddScriptLPS(1); 403 m_host.AddScriptLPS(1);
@@ -862,7 +870,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
862 ScenePresence target = (ScenePresence)World.Entities[avatarID]; 870 ScenePresence target = (ScenePresence)World.Entities[avatarID];
863 if (target != null) 871 if (target != null)
864 { 872 {
865 UUID animID=UUID.Zero; 873 UUID animID = UUID.Zero;
866 lock (m_host.TaskInventory) 874 lock (m_host.TaskInventory)
867 { 875 {
868 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 876 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
@@ -1021,6 +1029,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1021 drawList += "PenColor " + color + "; "; 1029 drawList += "PenColor " + color + "; ";
1022 return drawList; 1030 return drawList;
1023 } 1031 }
1032
1024 // Deprecated 1033 // Deprecated
1025 public string osSetPenColour(string drawList, string colour) 1034 public string osSetPenColour(string drawList, string colour)
1026 { 1035 {
@@ -1182,11 +1191,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1182 OSSLDeprecated("osSunGetParam", "osGetSunParam"); 1191 OSSLDeprecated("osSunGetParam", "osGetSunParam");
1183 return GetSunParam(param); 1192 return GetSunParam(param);
1184 } 1193 }
1194
1185 public double osGetSunParam(string param) 1195 public double osGetSunParam(string param)
1186 { 1196 {
1187 CheckThreatLevel(ThreatLevel.None, "osGetSunParam"); 1197 CheckThreatLevel(ThreatLevel.None, "osGetSunParam");
1188 return GetSunParam(param); 1198 return GetSunParam(param);
1189 } 1199 }
1200
1190 private double GetSunParam(string param) 1201 private double GetSunParam(string param)
1191 { 1202 {
1192 m_host.AddScriptLPS(1); 1203 m_host.AddScriptLPS(1);
@@ -1208,11 +1219,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1208 OSSLDeprecated("osSunSetParam", "osSetSunParam"); 1219 OSSLDeprecated("osSunSetParam", "osSetSunParam");
1209 SetSunParam(param, value); 1220 SetSunParam(param, value);
1210 } 1221 }
1222
1211 public void osSetSunParam(string param, double value) 1223 public void osSetSunParam(string param, double value)
1212 { 1224 {
1213 CheckThreatLevel(ThreatLevel.None, "osSetSunParam"); 1225 CheckThreatLevel(ThreatLevel.None, "osSetSunParam");
1214 SetSunParam(param, value); 1226 SetSunParam(param, value);
1215 } 1227 }
1228
1216 private void SetSunParam(string param, double value) 1229 private void SetSunParam(string param, double value)
1217 { 1230 {
1218 m_host.AddScriptLPS(1); 1231 m_host.AddScriptLPS(1);
@@ -1222,10 +1235,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1222 { 1235 {
1223 module.SetSunParameter(param, value); 1236 module.SetSunParameter(param, value);
1224 } 1237 }
1225
1226 } 1238 }
1227 1239
1228
1229 public string osWindActiveModelPluginName() 1240 public string osWindActiveModelPluginName()
1230 { 1241 {
1231 CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName"); 1242 CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName");
@@ -1304,12 +1315,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1304 OSSLDeprecated(functionName, "osSetParcelDetails"); 1315 OSSLDeprecated(functionName, "osSetParcelDetails");
1305 SetParcelDetails(pos, rules, functionName); 1316 SetParcelDetails(pos, rules, functionName);
1306 } 1317 }
1318
1307 public void osSetParcelDetails(LSL_Vector pos, LSL_List rules) 1319 public void osSetParcelDetails(LSL_Vector pos, LSL_List rules)
1308 { 1320 {
1309 const string functionName = "osSetParcelDetails"; 1321 const string functionName = "osSetParcelDetails";
1310 CheckThreatLevel(ThreatLevel.High, functionName); 1322 CheckThreatLevel(ThreatLevel.High, functionName);
1311 SetParcelDetails(pos, rules, functionName); 1323 SetParcelDetails(pos, rules, functionName);
1312 } 1324 }
1325
1313 private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName) 1326 private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName)
1314 { 1327 {
1315 m_host.AddScriptLPS(1); 1328 m_host.AddScriptLPS(1);
@@ -1429,8 +1442,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1429 voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); 1442 voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID);
1430 else 1443 else
1431 OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); 1444 OSSLError("osSetParcelSIPAddress: No voice module enabled for this land");
1432
1433
1434 } 1445 }
1435 1446
1436 public string osGetScriptEngineName() 1447 public string osGetScriptEngineName()
@@ -1683,8 +1694,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1683 return jsondata; 1694 return jsondata;
1684 } 1695 }
1685 1696
1686 // send a message to to object identified by the given UUID, a script in the object must implement the dataserver function 1697 /// <summary>
1687 // the dataserver function is passed the ID of the calling function and a string message 1698 /// Send a message to to object identified by the given UUID
1699 /// </summary>
1700 /// <remarks>
1701 /// A script in the object must implement the dataserver function
1702 /// the dataserver function is passed the ID of the calling function and a string message
1703 /// </remarks>
1704 /// <param name="objectUUID"></param>
1705 /// <param name="message"></param>
1688 public void osMessageObject(LSL_Key objectUUID, string message) 1706 public void osMessageObject(LSL_Key objectUUID, string message)
1689 { 1707 {
1690 CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); 1708 CheckThreatLevel(ThreatLevel.Low, "osMessageObject");
@@ -1699,34 +1717,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1699 "dataserver", resobj, new DetectParams[0])); 1717 "dataserver", resobj, new DetectParams[0]));
1700 } 1718 }
1701 1719
1702 1720 /// <summary>
1703 // This needs ThreatLevel high. It is an excellent griefer tool, 1721 /// Write a notecard directly to the prim's inventory.
1704 // In a loop, it can cause asset bloat and DOS levels of asset 1722 /// </summary>
1705 // writes. 1723 /// <remarks>
1706 // 1724 /// This needs ThreatLevel high. It is an excellent griefer tool,
1725 /// In a loop, it can cause asset bloat and DOS levels of asset
1726 /// writes.
1727 /// </remarks>
1728 /// <param name="notecardName">The name of the notecard to write.</param>
1729 /// <param name="contents">The contents of the notecard.</param>
1707 public void osMakeNotecard(string notecardName, LSL_Types.list contents) 1730 public void osMakeNotecard(string notecardName, LSL_Types.list contents)
1708 { 1731 {
1709 CheckThreatLevel(ThreatLevel.High, "osMakeNotecard"); 1732 CheckThreatLevel(ThreatLevel.High, "osMakeNotecard");
1710 m_host.AddScriptLPS(1); 1733 m_host.AddScriptLPS(1);
1711 1734
1712 // Create new asset 1735 StringBuilder notecardData = new StringBuilder();
1713 AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString());
1714 asset.Description = "Script Generated Notecard";
1715 string notecardData = String.Empty;
1716 1736
1717 for (int i = 0; i < contents.Length; i++) { 1737 for (int i = 0; i < contents.Length; i++)
1718 notecardData += contents.GetLSLStringItem(i) + "\n"; 1738 notecardData.Append((string)(contents.GetLSLStringItem(i) + "\n"));
1719 } 1739
1740 SaveNotecard(notecardName, "Script generated notecard", notecardData.ToString(), false);
1741 }
1720 1742
1721 int textLength = notecardData.Length; 1743 /// <summary>
1722 notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " 1744 /// Save a notecard to prim inventory.
1723 + textLength.ToString() + "\n" + notecardData + "}\n"; 1745 /// </summary>
1746 /// <param name="name"></param>
1747 /// <param name="description">Description of notecard</param>
1748 /// <param name="notecardData"></param>
1749 /// <param name="forceSameName">
1750 /// If true, then if an item exists with the same name, it is replaced.
1751 /// If false, then a new item is created witha slightly different name (e.g. name 1)
1752 /// </param>
1753 /// <returns>Prim inventory item created.</returns>
1754 protected TaskInventoryItem SaveNotecard(string name, string description, string data, bool forceSameName)
1755 {
1756 // Create new asset
1757 AssetBase asset = new AssetBase(UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString());
1758 asset.Description = description;
1724 1759
1725 asset.Data = Util.UTF8.GetBytes(notecardData); 1760 int textLength = data.Length;
1761 data
1762 = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length "
1763 + textLength.ToString() + "\n" + data + "}\n";
1764
1765 asset.Data = Util.UTF8.GetBytes(data);
1726 World.AssetService.Store(asset); 1766 World.AssetService.Store(asset);
1727 1767
1728 // Create Task Entry 1768 // Create Task Entry
1729 TaskInventoryItem taskItem=new TaskInventoryItem(); 1769 TaskInventoryItem taskItem = new TaskInventoryItem();
1730 1770
1731 taskItem.ResetIDs(m_host.UUID); 1771 taskItem.ResetIDs(m_host.UUID);
1732 taskItem.ParentID = m_host.UUID; 1772 taskItem.ParentID = m_host.UUID;
@@ -1748,28 +1788,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1748 taskItem.PermsMask = 0; 1788 taskItem.PermsMask = 0;
1749 taskItem.AssetID = asset.FullID; 1789 taskItem.AssetID = asset.FullID;
1750 1790
1751 m_host.Inventory.AddInventoryItem(taskItem, false); 1791 if (forceSameName)
1792 m_host.Inventory.AddInventoryItemExclusive(taskItem, false);
1793 else
1794 m_host.Inventory.AddInventoryItem(taskItem, false);
1795
1796 return taskItem;
1752 } 1797 }
1753 1798
1799 /// <summary>
1800 /// Load the notecard data found at the given prim inventory item name or asset uuid.
1801 /// </summary>
1802 /// <param name="notecardNameOrUuid"></param>
1803 /// <returns>The text loaded. Null if no notecard was found.</returns>
1804 protected string LoadNotecard(string notecardNameOrUuid)
1805 {
1806 UUID assetID = CacheNotecard(notecardNameOrUuid);
1807 StringBuilder notecardData = new StringBuilder();
1808
1809 for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
1810 {
1811 string line = NotecardCache.GetLine(assetID, count) + "\n";
1812
1813// m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line);
1754 1814
1755 /*Instead of using the LSL Dataserver event to pull notecard data, 1815 notecardData.Append(line);
1756 this will simply read the requested line and return its data as a string. 1816 }
1757 1817
1758 Warning - due to the synchronous method this function uses to fetch assets, its use 1818 return notecardData.ToString();
1759 may be dangerous and unreliable while running in grid mode. 1819 }
1760 */
1761 public string osGetNotecardLine(string name, int line)
1762 {
1763 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine");
1764 m_host.AddScriptLPS(1);
1765 1820
1821 /// <summary>
1822 /// Cache a notecard's contents.
1823 /// </summary>
1824 /// <param name="notecardNameOrUuid"></param>
1825 /// <returns>
1826 /// The asset id of the notecard, which is used for retrieving the cached data.
1827 /// UUID.Zero if no asset could be found.
1828 /// </returns>
1829 protected UUID CacheNotecard(string notecardNameOrUuid)
1830 {
1766 UUID assetID = UUID.Zero; 1831 UUID assetID = UUID.Zero;
1767 1832
1768 if (!UUID.TryParse(name, out assetID)) 1833 if (!UUID.TryParse(notecardNameOrUuid, out assetID))
1769 { 1834 {
1770 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1835 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1771 { 1836 {
1772 if (item.Type == 7 && item.Name == name) 1837 if (item.Type == 7 && item.Name == notecardNameOrUuid)
1773 { 1838 {
1774 assetID = item.AssetID; 1839 assetID = item.AssetID;
1775 } 1840 }
@@ -1777,114 +1842,100 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1777 } 1842 }
1778 1843
1779 if (assetID == UUID.Zero) 1844 if (assetID == UUID.Zero)
1780 { 1845 return UUID.Zero;
1781 OSSLShoutError("Notecard '" + name + "' could not be found.");
1782 return "ERROR!";
1783 }
1784 1846
1785 if (!NotecardCache.IsCached(assetID)) 1847 if (!NotecardCache.IsCached(assetID))
1786 { 1848 {
1787 AssetBase a = World.AssetService.Get(assetID.ToString()); 1849 AssetBase a = World.AssetService.Get(assetID.ToString());
1788 if (a != null)
1789 {
1790 System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
1791 string data = enc.GetString(a.Data);
1792 NotecardCache.Cache(assetID, data);
1793 }
1794 else
1795 {
1796 OSSLShoutError("Notecard '" + name + "' could not be found.");
1797 return "ERROR!";
1798 }
1799 };
1800 1850
1801 return NotecardCache.GetLine(assetID, line, 255); 1851 if (a == null)
1852 return UUID.Zero;
1802 1853
1854 System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
1855 string data = enc.GetString(a.Data);
1856 NotecardCache.Cache(assetID, data);
1857 };
1803 1858
1859 return assetID;
1804 } 1860 }
1805 1861
1806 /*Instead of using the LSL Dataserver event to pull notecard data line by line, 1862 /// <summary>
1807 this will simply read the entire notecard and return its data as a string. 1863 /// Directly get an entire notecard at once.
1864 /// </summary>
1865 /// <remarks>
1866 /// Instead of using the LSL Dataserver event to pull notecard data
1867 /// this will simply read the entire notecard and return its data as a string.
1868 ///
1869 /// Warning - due to the synchronous method this function uses to fetch assets, its use
1870 /// may be dangerous and unreliable while running in grid mode.
1871 /// </remarks>
1872 /// <param name="name">Name of the notecard or its asset id</param>
1873 /// <param name="line">The line number to read. The first line is line 0</param>
1874 /// <returns>Notecard line</returns>
1875 public string osGetNotecardLine(string name, int line)
1876 {
1877 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine");
1878 m_host.AddScriptLPS(1);
1879
1880 UUID assetID = CacheNotecard(name);
1881
1882 if (assetID == UUID.Zero)
1883 {
1884 OSSLShoutError("Notecard '" + name + "' could not be found.");
1885 return "ERROR!";
1886 }
1808 1887
1809 Warning - due to the synchronous method this function uses to fetch assets, its use 1888 return NotecardCache.GetLine(assetID, line);
1810 may be dangerous and unreliable while running in grid mode. 1889 }
1811 */
1812 1890
1891 /// <summary>
1892 /// Get an entire notecard at once.
1893 /// </summary>
1894 /// <remarks>
1895 /// Instead of using the LSL Dataserver event to pull notecard data line by line,
1896 /// this will simply read the entire notecard and return its data as a string.
1897 ///
1898 /// Warning - due to the synchronous method this function uses to fetch assets, its use
1899 /// may be dangerous and unreliable while running in grid mode.
1900 /// </remarks>
1901 /// <param name="name">Name of the notecard or its asset id</param>
1902 /// <returns>Notecard text</returns>
1813 public string osGetNotecard(string name) 1903 public string osGetNotecard(string name)
1814 { 1904 {
1815 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard"); 1905 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard");
1816 m_host.AddScriptLPS(1); 1906 m_host.AddScriptLPS(1);
1817 1907
1818 UUID assetID = UUID.Zero; 1908 string text = LoadNotecard(name);
1819 string NotecardData = "";
1820
1821 if (!UUID.TryParse(name, out assetID))
1822 {
1823 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1824 {
1825 if (item.Type == 7 && item.Name == name)
1826 {
1827 assetID = item.AssetID;
1828 }
1829 }
1830 }
1831 1909
1832 if (assetID == UUID.Zero) 1910 if (text == null)
1833 { 1911 {
1834 OSSLShoutError("Notecard '" + name + "' could not be found."); 1912 OSSLShoutError("Notecard '" + name + "' could not be found.");
1835 return "ERROR!"; 1913 return "ERROR!";
1836 } 1914 }
1837 1915 else
1838 if (!NotecardCache.IsCached(assetID))
1839 {
1840 AssetBase a = World.AssetService.Get(assetID.ToString());
1841 if (a != null)
1842 {
1843 System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
1844 string data = enc.GetString(a.Data);
1845 NotecardCache.Cache(assetID, data);
1846 }
1847 else
1848 {
1849 OSSLShoutError("Notecard '" + name + "' could not be found.");
1850 return "ERROR!";
1851 }
1852 };
1853
1854 for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
1855 { 1916 {
1856 NotecardData += NotecardCache.GetLine(assetID, count, 255) + "\n"; 1917 return text;
1857 } 1918 }
1858
1859 return NotecardData;
1860
1861
1862 } 1919 }
1863 1920
1864 /*Instead of using the LSL Dataserver event to pull notecard data, 1921 /// <summary>
1865 this will simply read the number of note card lines and return this data as an integer. 1922 /// Get the number of lines in the given notecard.
1866 1923 /// </summary>
1867 Warning - due to the synchronous method this function uses to fetch assets, its use 1924 /// <remarks>
1868 may be dangerous and unreliable while running in grid mode. 1925 /// Instead of using the LSL Dataserver event to pull notecard data,
1869 */ 1926 /// this will simply read the number of note card lines and return this data as an integer.
1870 1927 ///
1928 /// Warning - due to the synchronous method this function uses to fetch assets, its use
1929 /// may be dangerous and unreliable while running in grid mode.
1930 /// </remarks>
1931 /// <param name="name">Name of the notecard or its asset id</param>
1932 /// <returns></returns>
1871 public int osGetNumberOfNotecardLines(string name) 1933 public int osGetNumberOfNotecardLines(string name)
1872 { 1934 {
1873 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines"); 1935 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines");
1874 m_host.AddScriptLPS(1); 1936 m_host.AddScriptLPS(1);
1875 1937
1876 UUID assetID = UUID.Zero; 1938 UUID assetID = CacheNotecard(name);
1877
1878 if (!UUID.TryParse(name, out assetID))
1879 {
1880 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1881 {
1882 if (item.Type == 7 && item.Name == name)
1883 {
1884 assetID = item.AssetID;
1885 }
1886 }
1887 }
1888 1939
1889 if (assetID == UUID.Zero) 1940 if (assetID == UUID.Zero)
1890 { 1941 {
@@ -1892,22 +1943,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1892 return -1; 1943 return -1;
1893 } 1944 }
1894 1945
1895 if (!NotecardCache.IsCached(assetID))
1896 {
1897 AssetBase a = World.AssetService.Get(assetID.ToString());
1898 if (a != null)
1899 {
1900 System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
1901 string data = enc.GetString(a.Data);
1902 NotecardCache.Cache(assetID, data);
1903 }
1904 else
1905 {
1906 OSSLShoutError("Notecard '" + name + "' could not be found.");
1907 return -1;
1908 }
1909 };
1910
1911 return NotecardCache.GetLines(assetID); 1946 return NotecardCache.GetLines(assetID);
1912 } 1947 }
1913 1948
@@ -1947,15 +1982,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1947 { 1982 {
1948 return ""; 1983 return "";
1949 } 1984 }
1950
1951 } 1985 }
1952 1986
1987 /// <summary>
1988 /// Get the nickname of this grid, as set in the [GridInfo] config section.
1989 /// </summary>
1990 /// <remarks>
1953 /// Threat level is Moderate because intentional abuse, for instance 1991 /// Threat level is Moderate because intentional abuse, for instance
1954 /// scripts that are written to be malicious only on one grid, 1992 /// scripts that are written to be malicious only on one grid,
1955 /// for instance in a HG scenario, are a distinct possibility. 1993 /// for instance in a HG scenario, are a distinct possibility.
1956 /// 1994 /// </remarks>
1957 /// Use value from the config file and return it. 1995 /// <returns></returns>
1958 ///
1959 public string osGetGridNick() 1996 public string osGetGridNick()
1960 { 1997 {
1961 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); 1998 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick");
@@ -2063,12 +2100,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2063 return World.RegionInfo.RegionSettings.LoadedCreationID; 2100 return World.RegionInfo.RegionSettings.LoadedCreationID;
2064 } 2101 }
2065 2102
2066 // Threat level is 'Low' because certain users could possibly be tricked into 2103 /// <summary>
2067 // dropping an unverified script into one of their own objects, which could 2104 /// Get the primitive parameters of a linked prim.
2068 // then gather the physical construction details of the object and transmit it 2105 /// </summary>
2069 // to an unscrupulous third party, thus permitting unauthorized duplication of 2106 /// <remarks>
2070 // the object's form. 2107 /// Threat level is 'Low' because certain users could possibly be tricked into
2071 // 2108 /// dropping an unverified script into one of their own objects, which could
2109 /// then gather the physical construction details of the object and transmit it
2110 /// to an unscrupulous third party, thus permitting unauthorized duplication of
2111 /// the object's form.
2112 /// </remarks>
2113 /// <param name="linknumber"></param>
2114 /// <param name="rules"></param>
2115 /// <returns></returns>
2072 public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) 2116 public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules)
2073 { 2117 {
2074 CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams"); 2118 CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams");
@@ -2083,25 +2127,122 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2083 return retVal; 2127 return retVal;
2084 } 2128 }
2085 2129
2086 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) 2130 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard)
2087 { 2131 {
2088 CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); 2132 CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
2089 //QueueUserWorkItem
2090 2133
2091 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2134 INPCModule module = World.RequestModuleInterface<INPCModule>();
2092 if (module != null) 2135 if (module != null)
2093 { 2136 {
2137 AvatarAppearance appearance = null;
2138
2139 UUID id;
2140 if (UUID.TryParse(notecard, out id))
2141 {
2142 ScenePresence clonePresence = World.GetScenePresence(id);
2143 if (clonePresence != null)
2144 appearance = clonePresence.Appearance;
2145 }
2146
2147 if (appearance == null)
2148 {
2149 string appearanceSerialized = LoadNotecard(notecard);
2150
2151 if (appearanceSerialized != null)
2152 {
2153 OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
2154 appearance = new AvatarAppearance();
2155 appearance.Unpack(appearanceOsd);
2156 }
2157 }
2158
2159 if (appearance == null)
2160 return new LSL_Key(UUID.Zero.ToString());
2161
2094 UUID x = module.CreateNPC(firstname, 2162 UUID x = module.CreateNPC(firstname,
2095 lastname, 2163 lastname,
2096 new Vector3((float) position.x, (float) position.y, (float) position.z), 2164 new Vector3((float) position.x, (float) position.y, (float) position.z),
2097 World, 2165 World,
2098 new UUID(cloneFrom)); 2166 appearance);
2099 2167
2100 return new LSL_Key(x.ToString()); 2168 return new LSL_Key(x.ToString());
2101 } 2169 }
2170
2102 return new LSL_Key(UUID.Zero.ToString()); 2171 return new LSL_Key(UUID.Zero.ToString());
2103 } 2172 }
2104 2173
2174 /// <summary>
2175 /// Save the current appearance of the NPC permanently to the named notecard.
2176 /// </summary>
2177 /// <param name="avatar"></param>
2178 /// <param name="notecard">The name of the notecard to which to save the appearance.</param>
2179 /// <returns>The asset ID of the notecard saved.</returns>
2180 public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard)
2181 {
2182 CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance");
2183
2184 INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
2185
2186 if (npcModule != null)
2187 {
2188 UUID npcId;
2189 if (!UUID.TryParse(npc.m_string, out npcId))
2190 return new LSL_Key(UUID.Zero.ToString());
2191
2192 if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
2193 return new LSL_Key(UUID.Zero.ToString());
2194
2195 return SaveAppearanceToNotecard(npcId, notecard);
2196 }
2197
2198 return new LSL_Key(UUID.Zero.ToString());
2199 }
2200
2201 public void osNpcLoadAppearance(LSL_Key npc, string notecard)
2202 {
2203 CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance");
2204
2205 INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
2206
2207 if (npcModule != null)
2208 {
2209 UUID npcId;
2210 if (!UUID.TryParse(npc.m_string, out npcId))
2211 return;
2212
2213 string appearanceSerialized = LoadNotecard(notecard);
2214 OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
2215// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
2216// Console.WriteLine("appearanceSerialized {0}", appearanceSerialized);
2217// Console.WriteLine("a.Type {0}, a.ToString() {1}", a.Type, a);
2218 AvatarAppearance appearance = new AvatarAppearance();
2219 appearance.Unpack(appearanceOsd);
2220
2221 npcModule.SetNPCAppearance(npcId, appearance, m_host.ParentGroup.Scene);
2222 }
2223 }
2224
2225 public LSL_Vector osNpcGetPos(LSL_Key npc)
2226 {
2227 CheckThreatLevel(ThreatLevel.High, "osNpcGetPos");
2228
2229 INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
2230 if (npcModule != null)
2231 {
2232 UUID npcId;
2233 if (!UUID.TryParse(npc.m_string, out npcId))
2234 return new LSL_Vector(0, 0, 0);
2235
2236 if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
2237 return new LSL_Vector(0, 0, 0);
2238
2239 Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition;
2240 return new LSL_Vector(pos.X, pos.Y, pos.Z);
2241 }
2242
2243 return new LSL_Vector(0, 0, 0);
2244 }
2245
2105 public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) 2246 public void osNpcMoveTo(LSL_Key npc, LSL_Vector position)
2106 { 2247 {
2107 CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); 2248 CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
@@ -2109,11 +2250,87 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2109 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2250 INPCModule module = World.RequestModuleInterface<INPCModule>();
2110 if (module != null) 2251 if (module != null)
2111 { 2252 {
2253 UUID npcId;
2254 if (!UUID.TryParse(npc.m_string, out npcId))
2255 return;
2256
2112 Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); 2257 Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
2113 module.MoveToTarget(new UUID(npc.m_string), World, pos); 2258 module.MoveToTarget(npcId, World, pos, false, true);
2114 } 2259 }
2115 } 2260 }
2116 2261
2262 public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options)
2263 {
2264 CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget");
2265
2266 INPCModule module = World.RequestModuleInterface<INPCModule>();
2267 if (module != null)
2268 {
2269 UUID npcId;
2270 if (!UUID.TryParse(npc.m_string, out npcId))
2271 return;
2272
2273 Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z);
2274 module.MoveToTarget(
2275 new UUID(npc.m_string),
2276 World,
2277 pos,
2278 (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
2279 (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0);
2280 }
2281 }
2282
2283 public LSL_Rotation osNpcGetRot(LSL_Key npc)
2284 {
2285 CheckThreatLevel(ThreatLevel.High, "osNpcGetRot");
2286
2287 INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
2288 if (npcModule != null)
2289 {
2290 UUID npcId;
2291 if (!UUID.TryParse(npc.m_string, out npcId))
2292 return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
2293
2294 if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
2295 return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
2296
2297 ScenePresence sp = World.GetScenePresence(npcId);
2298 Quaternion rot = sp.Rotation;
2299
2300 return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W);
2301 }
2302
2303 return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
2304 }
2305
2306 public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation)
2307 {
2308 CheckThreatLevel(ThreatLevel.High, "osNpcSetRot");
2309
2310 INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
2311 if (npcModule != null)
2312 {
2313 UUID npcId;
2314 if (!UUID.TryParse(npc.m_string, out npcId))
2315 return;
2316
2317 if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
2318 return;
2319
2320 ScenePresence sp = World.GetScenePresence(npcId);
2321 sp.Rotation = LSL_Api.Rot2Quaternion(rotation);
2322 }
2323 }
2324
2325 public void osNpcStopMoveToTarget(LSL_Key npc)
2326 {
2327 CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo");
2328
2329 INPCModule module = World.RequestModuleInterface<INPCModule>();
2330 if (module != null)
2331 module.StopMoveToTarget(new UUID(npc.m_string), World);
2332 }
2333
2117 public void osNpcSay(LSL_Key npc, string message) 2334 public void osNpcSay(LSL_Key npc, string message)
2118 { 2335 {
2119 CheckThreatLevel(ThreatLevel.High, "osNpcSay"); 2336 CheckThreatLevel(ThreatLevel.High, "osNpcSay");
@@ -2135,6 +2352,64 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2135 module.DeleteNPC(new UUID(npc.m_string), World); 2352 module.DeleteNPC(new UUID(npc.m_string), World);
2136 } 2353 }
2137 } 2354 }
2355
2356 /// <summary>
2357 /// Save the current appearance of the script owner permanently to the named notecard.
2358 /// </summary>
2359 /// <param name="notecard">The name of the notecard to which to save the appearance.</param>
2360 /// <returns>The asset ID of the notecard saved.</returns>
2361 public LSL_Key osOwnerSaveAppearance(string notecard)
2362 {
2363 CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance");
2364
2365 return SaveAppearanceToNotecard(m_host.OwnerID, notecard);
2366 }
2367
2368 public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard)
2369 {
2370 CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance");
2371
2372 return SaveAppearanceToNotecard(avatarId, notecard);
2373 }
2374
2375 protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecard)
2376 {
2377 IAvatarFactory appearanceModule = World.RequestModuleInterface<IAvatarFactory>();
2378
2379 if (appearanceModule != null)
2380 {
2381 appearanceModule.SaveBakedTextures(sp.UUID);
2382 OSDMap appearancePacked = sp.Appearance.Pack();
2383
2384 TaskInventoryItem item
2385 = SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
2386
2387 return new LSL_Key(item.AssetID.ToString());
2388 }
2389 else
2390 {
2391 return new LSL_Key(UUID.Zero.ToString());
2392 }
2393 }
2394
2395 protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecard)
2396 {
2397 ScenePresence sp = World.GetScenePresence(avatarId);
2398
2399 if (sp == null || sp.IsChildAgent)
2400 return new LSL_Key(UUID.Zero.ToString());
2401
2402 return SaveAppearanceToNotecard(sp, notecard);
2403 }
2404
2405 protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecard)
2406 {
2407 UUID avatarId;
2408 if (!UUID.TryParse(rawAvatarId, out avatarId))
2409 return new LSL_Key(UUID.Zero.ToString());
2410
2411 return SaveAppearanceToNotecard(avatarId, notecard);
2412 }
2138 2413
2139 /// <summary> 2414 /// <summary>
2140 /// Get current region's map texture UUID 2415 /// Get current region's map texture UUID
@@ -2344,10 +2619,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2344 obj.Shape.ProjectionFocus = (float)focus; 2619 obj.Shape.ProjectionFocus = (float)focus;
2345 obj.Shape.ProjectionAmbiance = (float)amb; 2620 obj.Shape.ProjectionAmbiance = (float)amb;
2346 2621
2347
2348 obj.ParentGroup.HasGroupChanged = true; 2622 obj.ParentGroup.HasGroupChanged = true;
2349 obj.ScheduleFullUpdate(); 2623 obj.ScheduleFullUpdate();
2350
2351 } 2624 }
2352 2625
2353 /// <summary> 2626 /// <summary>
@@ -2372,6 +2645,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2372 } 2645 }
2373 } 2646 }
2374 }); 2647 });
2648
2375 return result; 2649 return result;
2376 } 2650 }
2377 2651
@@ -2391,4 +2665,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2391 return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); 2665 return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
2392 } 2666 }
2393 } 2667 }
2394} 2668} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 19352f0..87cfe1a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -168,12 +168,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
168 168
169 LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); 169 LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules);
170 170
171 171 key osNpcCreate(string user, string name, vector position, string notecard);
172 key osNpcCreate(string user, string name, vector position, key cloneFrom); 172 LSL_Key osNpcSaveAppearance(key npc, string notecard);
173 void osNpcLoadAppearance(key npc, string notecard);
174 vector osNpcGetPos(key npc);
173 void osNpcMoveTo(key npc, vector position); 175 void osNpcMoveTo(key npc, vector position);
176 void osNpcMoveToTarget(key npc, vector target, int options);
177 rotation osNpcGetRot(key npc);
178 void osNpcSetRot(LSL_Key npc, rotation rot);
179 void osNpcStopMoveToTarget(LSL_Key npc);
174 void osNpcSay(key npc, string message); 180 void osNpcSay(key npc, string message);
175 void osNpcRemove(key npc); 181 void osNpcRemove(key npc);
176 182
183 LSL_Key osOwnerSaveAppearance(string notecard);
184 LSL_Key osAgentSaveAppearance(key agentId, string notecard);
185
177 key osGetMapTexture(); 186 key osGetMapTexture();
178 key osGetRegionMapTexture(string regionName); 187 key osGetRegionMapTexture(string regionName);
179 LSL_List osGetRegionStats(); 188 LSL_List osGetRegionStats();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 3f90788..e82c281 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -591,6 +591,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
591 public const int STATS_ACTIVE_SCRIPTS = 19; 591 public const int STATS_ACTIVE_SCRIPTS = 19;
592 public const int STATS_SCRIPT_LPS = 20; 592 public const int STATS_SCRIPT_LPS = 20;
593 593
594 // Constants for osNpc* functions
595 public const int OS_NPC_FLY = 0;
596 public const int OS_NPC_NO_FLY = 1;
597 public const int OS_NPC_LAND_AT_TARGET = 2;
598
594 public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; 599 public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED";
595 public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; 600 public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED";
596 601
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 7c59098..bbc8cc6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -483,11 +483,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
483 return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom); 483 return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom);
484 } 484 }
485 485
486 public key osNpcSaveAppearance(key npc, string notecard)
487 {
488 return m_OSSL_Functions.osNpcSaveAppearance(npc, notecard);
489 }
490
491 public void osNpcLoadAppearance(key npc, string notecard)
492 {
493 m_OSSL_Functions.osNpcLoadAppearance(npc, notecard);
494 }
495
496 public vector osNpcGetPos(LSL_Key npc)
497 {
498 return m_OSSL_Functions.osNpcGetPos(npc);
499 }
500
486 public void osNpcMoveTo(key npc, vector position) 501 public void osNpcMoveTo(key npc, vector position)
487 { 502 {
488 m_OSSL_Functions.osNpcMoveTo(npc, position); 503 m_OSSL_Functions.osNpcMoveTo(npc, position);
489 } 504 }
490 505
506 public void osNpcMoveToTarget(key npc, vector target, int options)
507 {
508 m_OSSL_Functions.osNpcMoveToTarget(npc, target, options);
509 }
510
511 public rotation osNpcGetRot(key npc)
512 {
513 return m_OSSL_Functions.osNpcGetRot(npc);
514 }
515
516 public void osNpcSetRot(key npc, rotation rot)
517 {
518 m_OSSL_Functions.osNpcSetRot(npc, rot);
519 }
520
521 public void osNpcStopMoveToTarget(LSL_Key npc)
522 {
523 m_OSSL_Functions.osNpcStopMoveToTarget(npc);
524 }
525
491 public void osNpcSay(key npc, string message) 526 public void osNpcSay(key npc, string message)
492 { 527 {
493 m_OSSL_Functions.osNpcSay(npc, message); 528 m_OSSL_Functions.osNpcSay(npc, message);
@@ -498,6 +533,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
498 m_OSSL_Functions.osNpcRemove(npc); 533 m_OSSL_Functions.osNpcRemove(npc);
499 } 534 }
500 535
536 public LSL_Key osOwnerSaveAppearance(string notecard)
537 {
538 return m_OSSL_Functions.osOwnerSaveAppearance(notecard);
539 }
540
541 public LSL_Key osAgentSaveAppearance(LSL_Key agentId, string notecard)
542 {
543 return m_OSSL_Functions.osAgentSaveAppearance(agentId, notecard);
544 }
545
501 public OSSLPrim Prim; 546 public OSSLPrim Prim;
502 547
503 [Serializable] 548 [Serializable]