From 79ac01fb0c33fc318b6a2d5a56fbfaeca7ad1043 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 22 Sep 2008 02:11:40 +0000 Subject: Prevent scripts from running under multiple engines at once --- .../ScriptEngine/Common/ScriptEngineBase/EventManager.cs | 12 ++++++++---- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs index 9999d9c..04fe4cd 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs @@ -194,12 +194,16 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine) { - if (script.Length > 15) + int lineEnd = script.IndexOf('\n'); + + if (lineEnd != 1) { - if (script.Substring(0, 15) == "//DotNetEngine:") + string firstline = script.Substring(0, lineEnd).Trim(); + + int colon = firstline.IndexOf(':'); + if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1) { - script = "//" + script.Substring(15); - engine = "DotNetEngine"; + engine = firstline.Substring(2, colon-2); } } diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 161fd8c..934a1b9 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -341,12 +341,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine) { - if (script.Length > 10) + int lineEnd = script.IndexOf('\n'); + + if (lineEnd != 1) { - if (script.Substring(0, 10) == "//XEngine:") + string firstline = script.Substring(0, lineEnd).Trim(); + + int colon = firstline.IndexOf(':'); + if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1) { - script = "//" + script.Substring(10); - engine = "XEngine"; + engine = firstline.Substring(2, colon-2); } } -- cgit v1.1