aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
authorMelanie2012-10-26 21:13:01 +0100
committerMelanie2012-10-26 21:13:01 +0100
commit26cc57b6cafda5168baab49cabe34d96f01dbd6d (patch)
tree94e078a75ab68825e64b15498f67d82988858dc9 /OpenSim/Region/ScriptEngine/Shared/Api
parentMerge branch 'master' into careminster (diff)
parentminor: Make the error thrown logged when a simulator in grid mode is trying t... (diff)
downloadopensim-SC-26cc57b6cafda5168baab49cabe34d96f01dbd6d.zip
opensim-SC-26cc57b6cafda5168baab49cabe34d96f01dbd6d.tar.gz
opensim-SC-26cc57b6cafda5168baab49cabe34d96f01dbd6d.tar.bz2
opensim-SC-26cc57b6cafda5168baab49cabe34d96f01dbd6d.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs98
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs10
6 files changed, 143 insertions, 27 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index de49d6d..8d8df1d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -11578,12 +11578,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11578 11578
11579 internal void Deprecated(string command) 11579 internal void Deprecated(string command)
11580 { 11580 {
11581 throw new Exception("Command deprecated: " + command); 11581 throw new ScriptException("Command deprecated: " + command);
11582 } 11582 }
11583 11583
11584 internal void LSLError(string msg) 11584 internal void LSLError(string msg)
11585 { 11585 {
11586 throw new Exception("LSL Runtime Error: " + msg); 11586 throw new ScriptException("LSL Runtime Error: " + msg);
11587 } 11587 }
11588 11588
11589 public delegate void AssetRequestCallback(UUID assetID, AssetBase asset); 11589 public delegate void AssetRequestCallback(UUID assetID, AssetBase asset);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 6809c09..8f34833 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -95,13 +95,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
95 95
96 internal void MODError(string msg) 96 internal void MODError(string msg)
97 { 97 {
98 throw new Exception("MOD Runtime Error: " + msg); 98 throw new ScriptException("MOD Runtime Error: " + msg);
99 } 99 }
100 100
101 // 101 /// <summary>
102 //Dumps an error message on the debug console. 102 /// Dumps an error message on the debug console.
103 // 103 /// </summary>
104 104 /// <param name='message'></param>
105 internal void MODShoutError(string message) 105 internal void MODShoutError(string message)
106 { 106 {
107 if (message.Length > 1023) 107 if (message.Length > 1023)
@@ -359,20 +359,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
359 result[i] = (string)(LSL_String)plist[i]; 359 result[i] = (string)(LSL_String)plist[i];
360 else if (plist[i] is LSL_Integer) 360 else if (plist[i] is LSL_Integer)
361 result[i] = (int)(LSL_Integer)plist[i]; 361 result[i] = (int)(LSL_Integer)plist[i];
362 // The int check exists because of the many plain old int script constants in ScriptBase which
363 // are not LSL_Integers.
364 else if (plist[i] is int)
365 result[i] = plist[i];
362 else if (plist[i] is LSL_Float) 366 else if (plist[i] is LSL_Float)
363 result[i] = (float)(LSL_Float)plist[i]; 367 result[i] = (float)(LSL_Float)plist[i];
364 else if (plist[i] is LSL_Key) 368 else if (plist[i] is LSL_Key)
365 result[i] = new UUID((LSL_Key)plist[i]); 369 result[i] = new UUID((LSL_Key)plist[i]);
366 else if (plist[i] is LSL_Rotation) 370 else if (plist[i] is LSL_Rotation)
367 { 371 result[i] = (Quaternion)((LSL_Rotation)plist[i]);
368 result[i] = (OpenMetaverse.Quaternion)(
369 (LSL_Rotation)plist[i]);
370 }
371 else if (plist[i] is LSL_Vector) 372 else if (plist[i] is LSL_Vector)
372 { 373 result[i] = (Vector3)((LSL_Vector)plist[i]);
373 result[i] = (OpenMetaverse.Vector3)(
374 (LSL_Vector)plist[i]);
375 }
376 else 374 else
377 MODError(String.Format("{0}: unknown LSL list element type", fname)); 375 MODError(String.Format("{0}: unknown LSL list element type", fname));
378 } 376 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 17277d7..51c8c7e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -218,7 +218,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
218 } 218 }
219 else 219 else
220 { 220 {
221 throw new Exception("OSSL Runtime Error: " + msg); 221 throw new ScriptException("OSSL Runtime Error: " + msg);
222 } 222 }
223 } 223 }
224 224
@@ -1789,18 +1789,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1789 protected string LoadNotecard(string notecardNameOrUuid) 1789 protected string LoadNotecard(string notecardNameOrUuid)
1790 { 1790 {
1791 UUID assetID = CacheNotecard(notecardNameOrUuid); 1791 UUID assetID = CacheNotecard(notecardNameOrUuid);
1792 StringBuilder notecardData = new StringBuilder();
1793 1792
1794 for (int count = 0; count < NotecardCache.GetLines(assetID); count++) 1793 if (assetID != UUID.Zero)
1795 { 1794 {
1796 string line = NotecardCache.GetLine(assetID, count) + "\n"; 1795 StringBuilder notecardData = new StringBuilder();
1797 1796
1798// m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line); 1797 for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
1799 1798 {
1800 notecardData.Append(line); 1799 string line = NotecardCache.GetLine(assetID, count) + "\n";
1800
1801 // m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line);
1802
1803 notecardData.Append(line);
1804 }
1805
1806 return notecardData.ToString();
1801 } 1807 }
1802 1808
1803 return notecardData.ToString(); 1809 return null;
1804 } 1810 }
1805 1811
1806 /// <summary> 1812 /// <summary>
@@ -2373,11 +2379,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2373 return UUID.Zero.ToString(); 2379 return UUID.Zero.ToString();
2374 } 2380 }
2375 } 2381 }
2382 else
2383 {
2384 OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
2385 }
2376 } 2386 }
2377 2387
2378 if (appearance == null)
2379 return new LSL_Key(UUID.Zero.ToString());
2380
2381 UUID ownerID = UUID.Zero; 2388 UUID ownerID = UUID.Zero;
2382 if (owned) 2389 if (owned)
2383 ownerID = m_host.OwnerID; 2390 ownerID = m_host.OwnerID;
@@ -2446,6 +2453,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2446 return; 2453 return;
2447 2454
2448 string appearanceSerialized = LoadNotecard(notecard); 2455 string appearanceSerialized = LoadNotecard(notecard);
2456
2457 if (appearanceSerialized == null)
2458 OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
2459
2449 OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); 2460 OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
2450// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); 2461// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
2451// Console.WriteLine("appearanceSerialized {0}", appearanceSerialized); 2462// Console.WriteLine("appearanceSerialized {0}", appearanceSerialized);
@@ -3691,5 +3702,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3691 3702
3692 DropAttachmentAt(false, pos, rot); 3703 DropAttachmentAt(false, pos, rot);
3693 } 3704 }
3705
3706 public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield)
3707 {
3708 CheckThreatLevel(ThreatLevel.Low, "osListenRegex");
3709 m_host.AddScriptLPS(1);
3710 UUID keyID;
3711 UUID.TryParse(ID, out keyID);
3712
3713 // if we want the name to be used as a regular expression, ensure it is valid first.
3714 if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_NAME) == ScriptBaseClass.OS_LISTEN_REGEX_NAME)
3715 {
3716 try
3717 {
3718 Regex.IsMatch("", name);
3719 }
3720 catch (Exception)
3721 {
3722 OSSLShoutError("Name regex is invalid.");
3723 return -1;
3724 }
3725 }
3726
3727 // if we want the msg to be used as a regular expression, ensure it is valid first.
3728 if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE) == ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE)
3729 {
3730 try
3731 {
3732 Regex.IsMatch("", msg);
3733 }
3734 catch (Exception)
3735 {
3736 OSSLShoutError("Message regex is invalid.");
3737 return -1;
3738 }
3739 }
3740
3741 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
3742 return (wComm == null) ? -1 : wComm.Listen(
3743 m_host.LocalId,
3744 m_item.ItemID,
3745 m_host.UUID,
3746 channelID,
3747 name,
3748 keyID,
3749 msg,
3750 regexBitfield
3751 );
3752 }
3753
3754 public LSL_Integer osRegexIsMatch(string input, string pattern)
3755 {
3756 CheckThreatLevel(ThreatLevel.Low, "osRegexIsMatch");
3757 m_host.AddScriptLPS(1);
3758 try
3759 {
3760 return Regex.IsMatch(input, pattern) ? 1 : 0;
3761 }
3762 catch (Exception)
3763 {
3764 OSSLShoutError("Possible invalid regular expression detected.");
3765 return 0;
3766 }
3767 }
3694 } 3768 }
3695} 3769}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index b1fbed5..c447d1f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -418,5 +418,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
418 /// <param name="pos"></param> 418 /// <param name="pos"></param>
419 /// <param name="rot"></param> 419 /// <param name="rot"></param>
420 void osForceDropAttachmentAt(vector pos, rotation rot); 420 void osForceDropAttachmentAt(vector pos, rotation rot);
421
422 /// <summary>
423 /// Identical to llListen except for a bitfield which indicates which
424 /// string parameters should be parsed as regex patterns.
425 /// </summary>
426 /// <param name="channelID"></param>
427 /// <param name="name"></param>
428 /// <param name="ID"></param>
429 /// <param name="msg"></param>
430 /// <param name="regexBitfield">
431 /// OS_LISTEN_REGEX_NAME
432 /// OS_LISTEN_REGEX_MESSAGE
433 /// </param>
434 /// <returns></returns>
435 LSL_Integer osListenRegex(int channelID, string name, string ID,
436 string msg, int regexBitfield);
437
438 /// <summary>
439 /// Wraps to bool Regex.IsMatch(string input, string pattern)
440 /// </summary>
441 /// <param name="input">string to test for match</param>
442 /// <param name="regex">string to use as pattern</param>
443 /// <returns>boolean</returns>
444 LSL_Integer osRegexIsMatch(string input, string pattern);
421 } 445 }
422} 446}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index bf66eb6..0dd5a57 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -741,5 +741,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
741 public const int KFM_CMD_PLAY = 0; 741 public const int KFM_CMD_PLAY = 0;
742 public const int KFM_CMD_STOP = 1; 742 public const int KFM_CMD_STOP = 1;
743 public const int KFM_CMD_PAUSE = 2; 743 public const int KFM_CMD_PAUSE = 2;
744
745 /// <summary>
746 /// process name parameter as regex
747 /// </summary>
748 public const int OS_LISTEN_REGEX_NAME = 0x1;
749
750 /// <summary>
751 /// process message parameter as regex
752 /// </summary>
753 public const int OS_LISTEN_REGEX_MESSAGE = 0x2;
744 } 754 }
745} 755}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index dee1b28..afa9ae0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -992,5 +992,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
992 { 992 {
993 m_OSSL_Functions.osForceDropAttachmentAt(pos, rot); 993 m_OSSL_Functions.osForceDropAttachmentAt(pos, rot);
994 } 994 }
995
996 public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield)
997 {
998 return m_OSSL_Functions.osListenRegex(channelID, name, ID, msg, regexBitfield);
999 }
1000
1001 public LSL_Integer osRegexIsMatch(string input, string pattern)
1002 {
1003 return m_OSSL_Functions.osRegexIsMatch(input, pattern);
1004 }
995 } 1005 }
996} 1006}