diff options
author | Justin Clark-Casey (justincc) | 2012-06-28 00:58:36 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-06-28 01:01:18 +0100 |
commit | 25baa2d894e9bbbb173eb4e6ebe1478d2e3c1265 (patch) | |
tree | d06e688c8dd97f3d3a81e1868b609e132c96a215 /OpenSim | |
parent | minor: reuse colon index calculation in XEngine.OnRezScript. The index if a ... (diff) | |
download | opensim-SC-25baa2d894e9bbbb173eb4e6ebe1478d2e3c1265.zip opensim-SC-25baa2d894e9bbbb173eb4e6ebe1478d2e3c1265.tar.gz opensim-SC-25baa2d894e9bbbb173eb4e6ebe1478d2e3c1265.tar.bz2 opensim-SC-25baa2d894e9bbbb173eb4e6ebe1478d2e3c1265.tar.xz |
Avoid reporting false positives when a colon is in a comment in the first line of a script where the user was not trying to select a different script engine.
This works by only posting the "Selected engine unavailable" message if we're falling back on XEngine and the language is one handled by XEngine.
In cases where the language is not handled or not allowed, the user will still be notified by the later compiler error.
This avoids the overwhelming majority of false positives where the first line contains a : for other reasons (e.g. source control systems, vim settings, etc.)
Ultimately, I think it would be better to detect script language/engine with a mechanism that didn't just rely on : detection (e.g like #! in unix scripts).
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 73d384d..a709be3 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -779,24 +779,48 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
779 | { | 779 | { |
780 | if (engine == ScriptEngineName) | 780 | if (engine == ScriptEngineName) |
781 | { | 781 | { |
782 | SceneObjectPart part = | 782 | // If we are falling back on XEngine as the default engine, then only complain to the user |
783 | m_Scene.GetSceneObjectPart( | 783 | // if a script language has been explicitly set and it's one that we recognize. If it's |
784 | localID); | 784 | // explicitly not allowed or the script is not in LSL then the user will be informed by a later compiler message. |
785 | 785 | // | |
786 | TaskInventoryItem item = | 786 | // This avoids the overwhelming number of false positives where we're in this code because |
787 | part.Inventory.GetInventoryItem(itemID); | 787 | // there's a colon in a comment in the first line of a script for entirely |
788 | 788 | // unrelated reasons (e.g. vim settings). | |
789 | ScenePresence presence = | 789 | // |
790 | m_Scene.GetScenePresence( | 790 | // TODO: A better fix would be to deprecate simple : detection and look for some less likely |
791 | item.OwnerID); | 791 | // string to begin the comment (like #! in unix shell scripts). |
792 | 792 | bool scriptExplicitlyInXEngineLanguage = false; | |
793 | if (presence != null) | 793 | string restOfScript = script.Substring(colon + 1); |
794 | |||
795 | // FIXME: These are hardcoded because they are currently hardcoded in Compiler.cs | ||
796 | if (restOfScript.StartsWith("c#") | ||
797 | || restOfScript.StartsWith("vb") | ||
798 | || restOfScript.StartsWith("lsl") | ||
799 | || restOfScript.StartsWith("js") | ||
800 | || restOfScript.StartsWith("yp")) | ||
801 | scriptExplicitlyInXEngineLanguage = true; | ||
802 | |||
803 | if (scriptExplicitlyInXEngineLanguage) | ||
794 | { | 804 | { |
795 | presence.ControllingClient.SendAgentAlertMessage( | 805 | SceneObjectPart part = |
796 | "Selected engine unavailable. "+ | 806 | m_Scene.GetSceneObjectPart( |
797 | "Running script on "+ | 807 | localID); |
798 | ScriptEngineName, | 808 | |
799 | false); | 809 | TaskInventoryItem item = |
810 | part.Inventory.GetInventoryItem(itemID); | ||
811 | |||
812 | ScenePresence presence = | ||
813 | m_Scene.GetScenePresence( | ||
814 | item.OwnerID); | ||
815 | |||
816 | if (presence != null) | ||
817 | { | ||
818 | presence.ControllingClient.SendAgentAlertMessage( | ||
819 | "Selected engine unavailable. "+ | ||
820 | "Running script on "+ | ||
821 | ScriptEngineName, | ||
822 | false); | ||
823 | } | ||
800 | } | 824 | } |
801 | } | 825 | } |
802 | } | 826 | } |