diff options
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/Implementation/OSSL_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 98 |
1 files changed, 86 insertions, 12 deletions
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 | } |