aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs100
1 files changed, 87 insertions, 13 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 29bc163..828288d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -210,7 +210,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
210 210
211 internal void OSSLError(string msg) 211 internal void OSSLError(string msg)
212 { 212 {
213 throw new Exception("OSSL Runtime Error: " + msg); 213 throw new ScriptException("OSSL Runtime Error: " + msg);
214 } 214 }
215 215
216 /// <summary> 216 /// <summary>
@@ -1780,18 +1780,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1780 protected string LoadNotecard(string notecardNameOrUuid) 1780 protected string LoadNotecard(string notecardNameOrUuid)
1781 { 1781 {
1782 UUID assetID = CacheNotecard(notecardNameOrUuid); 1782 UUID assetID = CacheNotecard(notecardNameOrUuid);
1783 StringBuilder notecardData = new StringBuilder();
1784 1783
1785 for (int count = 0; count < NotecardCache.GetLines(assetID); count++) 1784 if (assetID != UUID.Zero)
1786 { 1785 {
1787 string line = NotecardCache.GetLine(assetID, count) + "\n"; 1786 StringBuilder notecardData = new StringBuilder();
1788 1787
1789// m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line); 1788 for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
1790 1789 {
1791 notecardData.Append(line); 1790 string line = NotecardCache.GetLine(assetID, count) + "\n";
1791
1792 // m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line);
1793
1794 notecardData.Append(line);
1795 }
1796
1797 return notecardData.ToString();
1792 } 1798 }
1793 1799
1794 return notecardData.ToString(); 1800 return null;
1795 } 1801 }
1796 1802
1797 /// <summary> 1803 /// <summary>
@@ -2340,11 +2346,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2340 appearance = new AvatarAppearance(); 2346 appearance = new AvatarAppearance();
2341 appearance.Unpack(appearanceOsd); 2347 appearance.Unpack(appearanceOsd);
2342 } 2348 }
2349 else
2350 {
2351 OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
2352 }
2343 } 2353 }
2344 2354
2345 if (appearance == null)
2346 return new LSL_Key(UUID.Zero.ToString());
2347
2348 UUID ownerID = UUID.Zero; 2355 UUID ownerID = UUID.Zero;
2349 if (owned) 2356 if (owned)
2350 ownerID = m_host.OwnerID; 2357 ownerID = m_host.OwnerID;
@@ -2407,6 +2414,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2407 return; 2414 return;
2408 2415
2409 string appearanceSerialized = LoadNotecard(notecard); 2416 string appearanceSerialized = LoadNotecard(notecard);
2417
2418 if (appearanceSerialized == null)
2419 OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
2420
2410 OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); 2421 OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
2411// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); 2422// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized);
2412// Console.WriteLine("appearanceSerialized {0}", appearanceSerialized); 2423// Console.WriteLine("appearanceSerialized {0}", appearanceSerialized);
@@ -3636,5 +3647,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3636 3647
3637 DropAttachmentAt(false, pos, rot); 3648 DropAttachmentAt(false, pos, rot);
3638 } 3649 }
3650
3651 public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield)
3652 {
3653 CheckThreatLevel(ThreatLevel.Low, "osListenRegex");
3654 m_host.AddScriptLPS(1);
3655 UUID keyID;
3656 UUID.TryParse(ID, out keyID);
3657
3658 // if we want the name to be used as a regular expression, ensure it is valid first.
3659 if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_NAME) == ScriptBaseClass.OS_LISTEN_REGEX_NAME)
3660 {
3661 try
3662 {
3663 Regex.IsMatch("", name);
3664 }
3665 catch (Exception)
3666 {
3667 OSSLShoutError("Name regex is invalid.");
3668 return -1;
3669 }
3670 }
3671
3672 // if we want the msg to be used as a regular expression, ensure it is valid first.
3673 if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE) == ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE)
3674 {
3675 try
3676 {
3677 Regex.IsMatch("", msg);
3678 }
3679 catch (Exception)
3680 {
3681 OSSLShoutError("Message regex is invalid.");
3682 return -1;
3683 }
3684 }
3685
3686 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
3687 return (wComm == null) ? -1 : wComm.Listen(
3688 m_host.LocalId,
3689 m_item.ItemID,
3690 m_host.UUID,
3691 channelID,
3692 name,
3693 keyID,
3694 msg,
3695 regexBitfield
3696 );
3697 }
3698
3699 public LSL_Integer osRegexIsMatch(string input, string pattern)
3700 {
3701 CheckThreatLevel(ThreatLevel.Low, "osRegexIsMatch");
3702 m_host.AddScriptLPS(1);
3703 try
3704 {
3705 return Regex.IsMatch(input, pattern) ? 1 : 0;
3706 }
3707 catch (Exception)
3708 {
3709 OSSLShoutError("Possible invalid regular expression detected.");
3710 return 0;
3711 }
3712 }
3639 } 3713 }
3640} \ No newline at end of file 3714}