diff options
author | Melanie | 2013-01-16 15:47:55 +0000 |
---|---|---|
committer | Melanie | 2013-01-16 15:47:55 +0000 |
commit | 818254916cb562422b3a3301b9f35fafd64ee3fe (patch) | |
tree | e8655f6472b305d43a2f23059c375c90e7004a2b | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC-818254916cb562422b3a3301b9f35fafd64ee3fe.zip opensim-SC-818254916cb562422b3a3301b9f35fafd64ee3fe.tar.gz opensim-SC-818254916cb562422b3a3301b9f35fafd64ee3fe.tar.bz2 opensim-SC-818254916cb562422b3a3301b9f35fafd64ee3fe.tar.xz |
JustinCC's core re-merge
Diffstat (limited to '')
19 files changed, 236 insertions, 92 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 65c50bf..9f0a0e2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -1783,6 +1783,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1783 | /// <returns>The part where the script was rezzed if successful. False otherwise.</returns> | 1783 | /// <returns>The part where the script was rezzed if successful. False otherwise.</returns> |
1784 | public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase) | 1784 | public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase) |
1785 | { | 1785 | { |
1786 | return RezNewScript( | ||
1787 | agentID, | ||
1788 | itemBase, | ||
1789 | "default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"); | ||
1790 | } | ||
1791 | |||
1792 | /// <summary> | ||
1793 | /// Rez a new script from nothing with given script text. | ||
1794 | /// </summary> | ||
1795 | /// <param name="remoteClient"></param> | ||
1796 | /// <param name="itemBase">Template item.</param> | ||
1797 | /// <param name="scriptText"></param> | ||
1798 | /// <returns>The part where the script was rezzed if successful. False otherwise.</returns> | ||
1799 | public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase, string scriptText) | ||
1800 | { | ||
1786 | // The part ID is the folder ID! | 1801 | // The part ID is the folder ID! |
1787 | SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); | 1802 | SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); |
1788 | if (part == null) | 1803 | if (part == null) |
@@ -1802,9 +1817,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1802 | return null; | 1817 | return null; |
1803 | } | 1818 | } |
1804 | 1819 | ||
1805 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1820 | AssetBase asset |
1806 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), | 1821 | = CreateAsset( |
1807 | agentID); | 1822 | itemBase.Name, |
1823 | itemBase.Description, | ||
1824 | (sbyte)itemBase.AssetType, | ||
1825 | Encoding.ASCII.GetBytes(scriptText), | ||
1826 | agentID); | ||
1827 | |||
1808 | AssetService.Store(asset); | 1828 | AssetService.Store(asset); |
1809 | 1829 | ||
1810 | TaskInventoryItem taskItem = new TaskInventoryItem(); | 1830 | TaskInventoryItem taskItem = new TaskInventoryItem(); |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs index 2027ca6..d2323f5 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs | |||
@@ -26,9 +26,11 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Threading; | ||
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
31 | using OpenSim.Region.Framework.Scenes; | 32 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Region.ScriptEngine.Shared; | ||
32 | 34 | ||
33 | namespace OpenSim.Region.ScriptEngine.Interfaces | 35 | namespace OpenSim.Region.ScriptEngine.Interfaces |
34 | { | 36 | { |
@@ -38,11 +40,12 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
38 | /// Initialize the API | 40 | /// Initialize the API |
39 | /// </summary> | 41 | /// </summary> |
40 | /// <remarks> | 42 | /// <remarks> |
41 | /// Each API has an identifier, which is used to load the | 43 | /// Each API has an identifier, which is used to load the proper runtime assembly at load time. |
42 | /// proper runtime assembly at load time. | 44 | /// <param name='scriptEngine'>/param> |
43 | /// <param name='engine'>/param> | 45 | /// <param name='host'>/param> |
44 | /// <param name='part'></param> | 46 | /// <param name='item'>/param> |
45 | /// <param name='item'></param> | 47 | /// <param name='coopSleepHandle'>/param> |
46 | void Initialize(IScriptEngine engine, SceneObjectPart part, TaskInventoryItem item); | 48 | void Initialize( |
49 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, EventWaitHandle coopSleepHandle); | ||
47 | } | 50 | } |
48 | } \ No newline at end of file | 51 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index 2f5b526..f68612c 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | |||
@@ -28,9 +28,11 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Threading; | ||
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
32 | using log4net; | 33 | using log4net; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Region.Framework.Scenes; | ||
34 | using OpenSim.Region.ScriptEngine.Shared; | 36 | using OpenSim.Region.ScriptEngine.Shared; |
35 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
36 | 38 | ||
@@ -105,6 +107,11 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
105 | /// </summary> | 107 | /// </summary> |
106 | long MeasurementPeriodExecutionTime { get; } | 108 | long MeasurementPeriodExecutionTime { get; } |
107 | 109 | ||
110 | /// <summary> | ||
111 | /// Scene part in which this script instance is contained. | ||
112 | /// </summary> | ||
113 | SceneObjectPart Part { get; } | ||
114 | |||
108 | IScriptEngine Engine { get; } | 115 | IScriptEngine Engine { get; } |
109 | UUID AppDomain { get; set; } | 116 | UUID AppDomain { get; set; } |
110 | string PrimName { get; } | 117 | string PrimName { get; } |
@@ -124,6 +131,12 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
124 | 131 | ||
125 | uint LocalID { get; } | 132 | uint LocalID { get; } |
126 | UUID AssetID { get; } | 133 | UUID AssetID { get; } |
134 | |||
135 | /// <summary> | ||
136 | /// Inventory item containing the script used. | ||
137 | /// </summary> | ||
138 | TaskInventoryItem ScriptTask { get; } | ||
139 | |||
127 | Queue EventQueue { get; } | 140 | Queue EventQueue { get; } |
128 | 141 | ||
129 | /// <summary> | 142 | /// <summary> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs index b5fa6de..d03955b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Threading; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using System.Collections; | 31 | using System.Collections; |
31 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
@@ -62,7 +63,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
62 | internal TaskInventoryItem m_item; | 63 | internal TaskInventoryItem m_item; |
63 | internal bool m_CMFunctionsEnabled = false; | 64 | internal bool m_CMFunctionsEnabled = false; |
64 | 65 | ||
65 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 66 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item, EventWaitHandle coopSleepHandle) |
66 | { | 67 | { |
67 | m_ScriptEngine = ScriptEngine; | 68 | m_ScriptEngine = ScriptEngine; |
68 | m_host = host; | 69 | m_host = host; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 4ce2afd..e83bbbb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -87,10 +87,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
87 | public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi | 87 | public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi |
88 | { | 88 | { |
89 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 89 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
90 | |||
90 | protected IScriptEngine m_ScriptEngine; | 91 | protected IScriptEngine m_ScriptEngine; |
91 | protected SceneObjectPart m_host; | 92 | protected SceneObjectPart m_host; |
92 | 93 | ||
93 | /// <summary> | 94 | /// <summary> |
95 | /// Used for script sleeps when we are using co-operative script termination. | ||
96 | /// </summary> | ||
97 | /// <remarks>null if co-operative script termination is not active</remarks> | ||
98 | EventWaitHandle m_coopSleepHandle; | ||
99 | |||
100 | /// <summary> | ||
94 | /// The item that hosts this script | 101 | /// The item that hosts this script |
95 | /// </summary> | 102 | /// </summary> |
96 | protected TaskInventoryItem m_item; | 103 | protected TaskInventoryItem m_item; |
@@ -142,33 +149,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
142 | {"TURNRIGHT", "Turning Right"} | 149 | {"TURNRIGHT", "Turning Right"} |
143 | }; | 150 | }; |
144 | 151 | ||
145 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 152 | public void Initialize( |
153 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, EventWaitHandle coopSleepHandle) | ||
146 | { | 154 | { |
147 | /* | ||
148 | m_ShoutSayTimer = new Timer(1000); | ||
149 | m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed; | ||
150 | m_ShoutSayTimer.AutoReset = true; | ||
151 | m_ShoutSayTimer.Start(); | ||
152 | */ | ||
153 | m_lastSayShoutCheck = DateTime.UtcNow; | 155 | m_lastSayShoutCheck = DateTime.UtcNow; |
154 | 156 | ||
155 | m_ScriptEngine = ScriptEngine; | 157 | m_ScriptEngine = scriptEngine; |
156 | m_host = host; | 158 | m_host = host; |
157 | m_item = item; | 159 | m_item = item; |
158 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | 160 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); |
161 | m_coopSleepHandle = coopSleepHandle; | ||
159 | 162 | ||
160 | LoadLimits(); // read script limits from config. | 163 | LoadConfig(); |
161 | 164 | ||
162 | m_TransferModule = | 165 | m_TransferModule = |
163 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); | 166 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); |
164 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | 167 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); |
165 | m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>(); | 168 | m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>(); |
166 | 169 | ||
167 | AsyncCommands = new AsyncCommandManager(ScriptEngine); | 170 | AsyncCommands = new AsyncCommandManager(m_ScriptEngine); |
168 | } | 171 | } |
169 | 172 | ||
170 | /* load configuration items that affect script, object and run-time behavior. */ | 173 | /// <summary> |
171 | private void LoadLimits() | 174 | /// Load configuration items that affect script, object and run-time behavior. */ |
175 | /// </summary> | ||
176 | private void LoadConfig() | ||
172 | { | 177 | { |
173 | m_ScriptDelayFactor = | 178 | m_ScriptDelayFactor = |
174 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); | 179 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); |
@@ -182,12 +187,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
182 | m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255); | 187 | m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255); |
183 | if (m_notecardLineReadCharsMax > 65535) | 188 | if (m_notecardLineReadCharsMax > 65535) |
184 | m_notecardLineReadCharsMax = 65535; | 189 | m_notecardLineReadCharsMax = 65535; |
190 | |||
185 | // load limits for particular subsystems. | 191 | // load limits for particular subsystems. |
186 | IConfig SMTPConfig; | 192 | IConfig SMTPConfig; |
187 | if ((SMTPConfig = m_ScriptEngine.ConfigSource.Configs["SMTP"]) != null) { | 193 | if ((SMTPConfig = m_ScriptEngine.ConfigSource.Configs["SMTP"]) != null) { |
188 | // there's an smtp config, so load in the snooze time. | 194 | // there's an smtp config, so load in the snooze time. |
189 | EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME); | 195 | EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME); |
190 | } | 196 | } |
197 | |||
191 | // Rezzing an object with a velocity can create recoil. This feature seems to have been | 198 | // Rezzing an object with a velocity can create recoil. This feature seems to have been |
192 | // removed from recent versions of SL. The code computes recoil (vel*mass) and scales | 199 | // removed from recent versions of SL. The code computes recoil (vel*mass) and scales |
193 | // it by this factor. May be zero to turn off recoil all together. | 200 | // it by this factor. May be zero to turn off recoil all together. |
@@ -212,7 +219,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
212 | delay = (int)((float)delay * m_ScriptDelayFactor); | 219 | delay = (int)((float)delay * m_ScriptDelayFactor); |
213 | if (delay == 0) | 220 | if (delay == 0) |
214 | return; | 221 | return; |
215 | System.Threading.Thread.Sleep(delay); | 222 | |
223 | Sleep(delay); | ||
224 | } | ||
225 | |||
226 | protected virtual void Sleep(int delay) | ||
227 | { | ||
228 | if (m_coopSleepHandle == null) | ||
229 | System.Threading.Thread.Sleep(delay); | ||
230 | else if (m_coopSleepHandle.WaitOne(delay)) | ||
231 | throw new ScriptCoopStopException(); | ||
216 | } | 232 | } |
217 | 233 | ||
218 | public Scene World | 234 | public Scene World |
@@ -3228,7 +3244,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3228 | { | 3244 | { |
3229 | // m_log.Info("llSleep snoozing " + sec + "s."); | 3245 | // m_log.Info("llSleep snoozing " + sec + "s."); |
3230 | m_host.AddScriptLPS(1); | 3246 | m_host.AddScriptLPS(1); |
3231 | Thread.Sleep((int)(sec * 1000)); | 3247 | |
3248 | Sleep((int)(sec * 1000)); | ||
3232 | } | 3249 | } |
3233 | 3250 | ||
3234 | public LSL_Float llGetMass() | 3251 | public LSL_Float llGetMass() |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index ceb4660..a08ccc8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | |||
@@ -30,6 +30,7 @@ using System.Reflection; | |||
30 | using System.Collections; | 30 | using System.Collections; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
33 | using System.Threading; | ||
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using Nini.Config; | 35 | using Nini.Config; |
35 | using OpenSim; | 36 | using OpenSim; |
@@ -61,9 +62,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
61 | internal bool m_LSFunctionsEnabled = false; | 62 | internal bool m_LSFunctionsEnabled = false; |
62 | internal IScriptModuleComms m_comms = null; | 63 | internal IScriptModuleComms m_comms = null; |
63 | 64 | ||
64 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 65 | public void Initialize( |
66 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, EventWaitHandle coopSleepHandle) | ||
65 | { | 67 | { |
66 | m_ScriptEngine = ScriptEngine; | 68 | m_ScriptEngine = scriptEngine; |
67 | m_host = host; | 69 | m_host = host; |
68 | 70 | ||
69 | if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) | 71 | if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) |
@@ -92,10 +94,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
92 | get { return m_ScriptEngine.World; } | 94 | get { return m_ScriptEngine.World; } |
93 | } | 95 | } |
94 | 96 | ||
95 | // | 97 | /// <summary> |
96 | //Dumps an error message on the debug console. | 98 | /// Dumps an error message on the debug console. |
97 | // | 99 | /// </summary> |
98 | |||
99 | internal void LSShoutError(string message) | 100 | internal void LSShoutError(string message) |
100 | { | 101 | { |
101 | if (message.Length > 1023) | 102 | if (message.Length > 1023) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 8f34833..981499e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -30,6 +30,7 @@ using System.Reflection; | |||
30 | using System.Collections; | 30 | using System.Collections; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
33 | using System.Threading; | ||
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using Nini.Config; | 35 | using Nini.Config; |
35 | using OpenSim; | 36 | using OpenSim; |
@@ -61,9 +62,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
61 | internal bool m_MODFunctionsEnabled = false; | 62 | internal bool m_MODFunctionsEnabled = false; |
62 | internal IScriptModuleComms m_comms = null; | 63 | internal IScriptModuleComms m_comms = null; |
63 | 64 | ||
64 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 65 | public void Initialize( |
66 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, EventWaitHandle coopSleepHandle) | ||
65 | { | 67 | { |
66 | m_ScriptEngine = ScriptEngine; | 68 | m_ScriptEngine = scriptEngine; |
67 | m_host = host; | 69 | m_host = host; |
68 | m_item = item; | 70 | m_item = item; |
69 | 71 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 4a46398..49857cf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -143,9 +143,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
143 | 143 | ||
144 | protected IUrlModule m_UrlModule = null; | 144 | protected IUrlModule m_UrlModule = null; |
145 | 145 | ||
146 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 146 | public void Initialize( |
147 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, EventWaitHandle coopSleepHandle) | ||
147 | { | 148 | { |
148 | m_ScriptEngine = ScriptEngine; | 149 | m_ScriptEngine = scriptEngine; |
149 | m_host = host; | 150 | m_host = host; |
150 | m_item = item; | 151 | m_item = item; |
151 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | 152 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index 22804f5..e44a106 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs | |||
@@ -82,6 +82,24 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | /// <summary> | ||
86 | /// Used to signal when the script is stopping in co-operation with the script engine | ||
87 | /// (instead of through Thread.Abort()). | ||
88 | /// </summary> | ||
89 | [Serializable] | ||
90 | public class ScriptCoopStopException : Exception | ||
91 | { | ||
92 | public ScriptCoopStopException() | ||
93 | { | ||
94 | } | ||
95 | |||
96 | protected ScriptCoopStopException( | ||
97 | SerializationInfo info, | ||
98 | StreamingContext context) | ||
99 | { | ||
100 | } | ||
101 | } | ||
102 | |||
85 | public class DetectParams | 103 | public class DetectParams |
86 | { | 104 | { |
87 | public const int AGENT = 1; | 105 | public const int AGENT = 1; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index ff4d130..a869a6a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -158,6 +158,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
158 | 158 | ||
159 | public UUID AppDomain { get; set; } | 159 | public UUID AppDomain { get; set; } |
160 | 160 | ||
161 | public SceneObjectPart Part { get; private set; } | ||
162 | |||
161 | public string PrimName { get; private set; } | 163 | public string PrimName { get; private set; } |
162 | 164 | ||
163 | public string ScriptName { get; private set; } | 165 | public string ScriptName { get; private set; } |
@@ -199,54 +201,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
199 | 201 | ||
200 | public static readonly long MaxMeasurementPeriod = 30 * TimeSpan.TicksPerMinute; | 202 | public static readonly long MaxMeasurementPeriod = 30 * TimeSpan.TicksPerMinute; |
201 | 203 | ||
204 | private bool m_coopTermination; | ||
205 | |||
206 | private EventWaitHandle m_coopSleepHandle; | ||
207 | |||
202 | public void ClearQueue() | 208 | public void ClearQueue() |
203 | { | 209 | { |
204 | m_TimerQueued = false; | 210 | m_TimerQueued = false; |
205 | EventQueue.Clear(); | 211 | EventQueue.Clear(); |
206 | } | 212 | } |
207 | 213 | ||
208 | public ScriptInstance(IScriptEngine engine, SceneObjectPart part, | 214 | public ScriptInstance( |
209 | UUID itemID, UUID assetID, string assembly, | 215 | IScriptEngine engine, SceneObjectPart part, TaskInventoryItem item, |
210 | AppDomain dom, string primName, string scriptName, | 216 | int startParam, bool postOnRez, |
211 | int startParam, bool postOnRez, StateSource stateSource, | 217 | int maxScriptQueue) |
212 | int maxScriptQueue) | ||
213 | { | 218 | { |
214 | State = "default"; | 219 | State = "default"; |
215 | EventQueue = new Queue(32); | 220 | EventQueue = new Queue(32); |
216 | 221 | ||
217 | Engine = engine; | 222 | Engine = engine; |
218 | LocalID = part.LocalId; | 223 | Part = part; |
219 | ObjectID = part.UUID; | 224 | ScriptTask = item; |
220 | RootLocalID = part.ParentGroup.LocalId; | 225 | |
221 | RootObjectID = part.ParentGroup.UUID; | 226 | // This is currently only here to allow regression tests to get away without specifying any inventory |
222 | ItemID = itemID; | 227 | // item when they are testing script logic that doesn't require an item. |
223 | AssetID = assetID; | 228 | if (ScriptTask != null) |
224 | PrimName = primName; | 229 | { |
225 | ScriptName = scriptName; | 230 | ScriptName = ScriptTask.Name; |
226 | m_Assembly = assembly; | 231 | ItemID = ScriptTask.ItemID; |
232 | AssetID = ScriptTask.AssetID; | ||
233 | } | ||
234 | |||
235 | PrimName = part.ParentGroup.Name; | ||
227 | StartParam = startParam; | 236 | StartParam = startParam; |
228 | m_MaxScriptQueue = maxScriptQueue; | 237 | m_MaxScriptQueue = maxScriptQueue; |
229 | m_stateSource = stateSource; | ||
230 | m_postOnRez = postOnRez; | 238 | m_postOnRez = postOnRez; |
231 | m_AttachedAvatar = part.ParentGroup.AttachedAvatar; | 239 | m_AttachedAvatar = part.ParentGroup.AttachedAvatar; |
232 | m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; | 240 | m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; |
233 | 241 | ||
234 | if (part != null) | 242 | if (Engine.Config.GetString("ScriptStopStrategy", "abort") == "co-op") |
235 | { | 243 | { |
236 | part.TaskInventory.LockItemsForRead(true); | 244 | m_coopTermination = true; |
237 | if (part.TaskInventory.ContainsKey(ItemID)) | 245 | m_coopSleepHandle = new AutoResetEvent(false); |
238 | { | ||
239 | ScriptTask = part.TaskInventory[ItemID]; | ||
240 | } | ||
241 | part.TaskInventory.LockItemsForRead(false); | ||
242 | } | 246 | } |
247 | } | ||
248 | |||
249 | /// <summary> | ||
250 | /// Load the script from an assembly into an AppDomain. | ||
251 | /// </summary> | ||
252 | /// <param name='dom'></param> | ||
253 | /// <param name='assembly'></param> | ||
254 | /// <param name='stateSource'></param> | ||
255 | public void Load(AppDomain dom, string assembly, StateSource stateSource) | ||
256 | { | ||
257 | m_Assembly = assembly; | ||
258 | m_stateSource = stateSource; | ||
243 | 259 | ||
244 | ApiManager am = new ApiManager(); | 260 | ApiManager am = new ApiManager(); |
245 | 261 | ||
246 | foreach (string api in am.GetApis()) | 262 | foreach (string api in am.GetApis()) |
247 | { | 263 | { |
248 | m_Apis[api] = am.CreateApi(api); | 264 | m_Apis[api] = am.CreateApi(api); |
249 | m_Apis[api].Initialize(engine, part, ScriptTask); | 265 | m_Apis[api].Initialize(Engine, Part, ScriptTask, m_coopSleepHandle); |
250 | } | 266 | } |
251 | 267 | ||
252 | try | 268 | try |
@@ -280,7 +296,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
280 | 296 | ||
281 | // // m_log.Debug("[Script] Script instance created"); | 297 | // // m_log.Debug("[Script] Script instance created"); |
282 | 298 | ||
283 | part.SetScriptEvents(ItemID, | 299 | Part.SetScriptEvents(ItemID, |
284 | (int)m_Script.GetStateEventFlags(State)); | 300 | (int)m_Script.GetStateEventFlags(State)); |
285 | } | 301 | } |
286 | catch (Exception e) | 302 | catch (Exception e) |
@@ -322,7 +338,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
322 | 338 | ||
323 | // m_log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", PrimName, m_ScriptName); | 339 | // m_log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", PrimName, m_ScriptName); |
324 | 340 | ||
325 | part.SetScriptEvents(ItemID, | 341 | Part.SetScriptEvents(ItemID, |
326 | (int)m_Script.GetStateEventFlags(State)); | 342 | (int)m_Script.GetStateEventFlags(State)); |
327 | 343 | ||
328 | if (!Running) | 344 | if (!Running) |
@@ -534,9 +550,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
534 | } | 550 | } |
535 | 551 | ||
536 | // Wait for the current event to complete. | 552 | // Wait for the current event to complete. |
537 | if (!m_InSelfDelete && workItem.Wait(new TimeSpan((long)timeout * 100000))) | 553 | if (!m_InSelfDelete) |
538 | { | 554 | { |
539 | return true; | 555 | if (!m_coopTermination) |
556 | { | ||
557 | // If we're not co-operative terminating then try and wait for the event to complete before stopping | ||
558 | if (workItem.Wait(new TimeSpan((long)timeout * 100000))) | ||
559 | return true; | ||
560 | } | ||
561 | else | ||
562 | { | ||
563 | m_log.DebugFormat( | ||
564 | "[SCRIPT INSTANCE]: Co-operatively stopping script {0} {1} in {2} {3}", | ||
565 | ScriptName, ItemID, PrimName, ObjectID); | ||
566 | |||
567 | // This will terminate the event on next handle check by the script. | ||
568 | m_coopSleepHandle.Set(); | ||
569 | |||
570 | // For now, we will wait forever since the event should always cleanly terminate once LSL loop | ||
571 | // checking is implemented. May want to allow a shorter timeout option later. | ||
572 | if (workItem.Wait(TimeSpan.MaxValue)) | ||
573 | { | ||
574 | m_log.DebugFormat( | ||
575 | "[SCRIPT INSTANCE]: Co-operatively stopped script {0} {1} in {2} {3}", | ||
576 | ScriptName, ItemID, PrimName, ObjectID); | ||
577 | |||
578 | return true; | ||
579 | } | ||
580 | } | ||
540 | } | 581 | } |
541 | 582 | ||
542 | lock (EventQueue) | 583 | lock (EventQueue) |
@@ -549,6 +590,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
549 | 590 | ||
550 | // If the event still hasn't stopped and we the stop isn't the result of script or object removal, then | 591 | // If the event still hasn't stopped and we the stop isn't the result of script or object removal, then |
551 | // forcibly abort the work item (this aborts the underlying thread). | 592 | // forcibly abort the work item (this aborts the underlying thread). |
593 | // Co-operative termination should never reach this point. | ||
552 | if (!m_InSelfDelete) | 594 | if (!m_InSelfDelete) |
553 | { | 595 | { |
554 | m_log.DebugFormat( | 596 | m_log.DebugFormat( |
@@ -796,7 +838,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
796 | m_InEvent = false; | 838 | m_InEvent = false; |
797 | m_CurrentEvent = String.Empty; | 839 | m_CurrentEvent = String.Empty; |
798 | 840 | ||
799 | if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) | 841 | if ((!(e is TargetInvocationException) |
842 | || (!(e.InnerException is SelfDeleteException) | ||
843 | && !(e.InnerException is ScriptDeleteException) | ||
844 | && !(e.InnerException is ScriptCoopStopException))) | ||
845 | && !(e is ThreadAbortException)) | ||
800 | { | 846 | { |
801 | try | 847 | try |
802 | { | 848 | { |
@@ -846,6 +892,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
846 | if (part != null) | 892 | if (part != null) |
847 | part.Inventory.RemoveInventoryItem(ItemID); | 893 | part.Inventory.RemoveInventoryItem(ItemID); |
848 | } | 894 | } |
895 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptCoopStopException)) | ||
896 | { | ||
897 | m_log.DebugFormat( | ||
898 | "[SCRIPT INSTANCE]: Script {0}.{1} in event {2}, state {3} stopped co-operatively.", | ||
899 | PrimName, ScriptName, data.EventName, State); | ||
900 | } | ||
849 | } | 901 | } |
850 | } | 902 | } |
851 | } | 903 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs index cb7291a..6dd6c17 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs | |||
@@ -41,6 +41,7 @@ using OpenSim.Region.OptionalModules.World.NPC; | |||
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.ScriptEngine.Shared; | 42 | using OpenSim.Region.ScriptEngine.Shared; |
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | 43 | using OpenSim.Region.ScriptEngine.Shared.Api; |
44 | using OpenSim.Region.ScriptEngine.Shared.Instance; | ||
44 | using OpenSim.Services.Interfaces; | 45 | using OpenSim.Services.Interfaces; |
45 | using OpenSim.Tests.Common; | 46 | using OpenSim.Tests.Common; |
46 | using OpenSim.Tests.Common.Mock; | 47 | using OpenSim.Tests.Common.Mock; |
@@ -93,7 +94,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
93 | TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, userId); | 94 | TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, userId); |
94 | 95 | ||
95 | LSL_Api api = new LSL_Api(); | 96 | LSL_Api api = new LSL_Api(); |
96 | api.Initialize(m_engine, so1.RootPart, null); | 97 | api.Initialize(m_engine, so1.RootPart, null, null); |
97 | 98 | ||
98 | // Create a second object | 99 | // Create a second object |
99 | SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, userId, "so2", 0x100); | 100 | SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, userId, "so2", 0x100); |
@@ -126,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
126 | SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); | 127 | SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); |
127 | m_scene.AddSceneObject(so1); | 128 | m_scene.AddSceneObject(so1); |
128 | LSL_Api api = new LSL_Api(); | 129 | LSL_Api api = new LSL_Api(); |
129 | api.Initialize(m_engine, so1.RootPart, null); | 130 | api.Initialize(m_engine, so1.RootPart, null, null); |
130 | 131 | ||
131 | // Create an object embedded inside the first | 132 | // Create an object embedded inside the first |
132 | UUID itemId = TestHelpers.ParseTail(0x20); | 133 | UUID itemId = TestHelpers.ParseTail(0x20); |
@@ -136,7 +137,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
136 | SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); | 137 | SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); |
137 | m_scene.AddSceneObject(so2); | 138 | m_scene.AddSceneObject(so2); |
138 | LSL_Api api2 = new LSL_Api(); | 139 | LSL_Api api2 = new LSL_Api(); |
139 | api2.Initialize(m_engine, so2.RootPart, null); | 140 | api2.Initialize(m_engine, so2.RootPart, null, null); |
140 | 141 | ||
141 | // *** Firstly, we test where llAllowInventoryDrop() has not been called. *** | 142 | // *** Firstly, we test where llAllowInventoryDrop() has not been called. *** |
142 | api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); | 143 | api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs index d9b17d7..5b57bbe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs | |||
@@ -41,6 +41,7 @@ using OpenSim.Region.OptionalModules.World.NPC; | |||
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.ScriptEngine.Shared; | 42 | using OpenSim.Region.ScriptEngine.Shared; |
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | 43 | using OpenSim.Region.ScriptEngine.Shared.Api; |
44 | using OpenSim.Region.ScriptEngine.Shared.Instance; | ||
44 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | 45 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
45 | using OpenSim.Services.Interfaces; | 46 | using OpenSim.Services.Interfaces; |
46 | using OpenSim.Tests.Common; | 47 | using OpenSim.Tests.Common; |
@@ -104,7 +105,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
104 | m_scene.AddSceneObject(grp2); | 105 | m_scene.AddSceneObject(grp2); |
105 | 106 | ||
106 | LSL_Api apiGrp1 = new LSL_Api(); | 107 | LSL_Api apiGrp1 = new LSL_Api(); |
107 | apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item); | 108 | apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item, null); |
108 | 109 | ||
109 | apiGrp1.llCreateLink(grp2.UUID.ToString(), ScriptBaseClass.TRUE); | 110 | apiGrp1.llCreateLink(grp2.UUID.ToString(), ScriptBaseClass.TRUE); |
110 | 111 | ||
@@ -131,7 +132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
131 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 132 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
132 | 133 | ||
133 | LSL_Api apiGrp1 = new LSL_Api(); | 134 | LSL_Api apiGrp1 = new LSL_Api(); |
134 | apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item); | 135 | apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item, null); |
135 | 136 | ||
136 | apiGrp1.llBreakLink(2); | 137 | apiGrp1.llBreakLink(2); |
137 | 138 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs index 98017d8..60de5cb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs | |||
@@ -34,6 +34,7 @@ using OpenSim.Region.ScriptEngine.Shared; | |||
34 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using OpenSim.Region.ScriptEngine.Shared.Api; | 36 | using OpenSim.Region.ScriptEngine.Shared.Api; |
37 | using OpenSim.Region.ScriptEngine.Shared.Instance; | ||
37 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | 38 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
38 | using OpenMetaverse; | 39 | using OpenMetaverse; |
39 | using OpenSim.Tests.Common.Mock; | 40 | using OpenSim.Tests.Common.Mock; |
@@ -67,7 +68,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
67 | engine.AddRegion(scene); | 68 | engine.AddRegion(scene); |
68 | 69 | ||
69 | m_lslApi = new LSL_Api(); | 70 | m_lslApi = new LSL_Api(); |
70 | m_lslApi.Initialize(engine, part, null); | 71 | m_lslApi.Initialize(engine, part, null, null); |
71 | } | 72 | } |
72 | 73 | ||
73 | [Test] | 74 | [Test] |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index c41d1e7..e97ae06 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | |||
@@ -33,6 +33,7 @@ using OpenSim.Region.ScriptEngine.Shared; | |||
33 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Region.ScriptEngine.Shared.Api; | 35 | using OpenSim.Region.ScriptEngine.Shared.Api; |
36 | using OpenSim.Region.ScriptEngine.Shared.Instance; | ||
36 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | 37 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
37 | using OpenMetaverse; | 38 | using OpenMetaverse; |
38 | using System; | 39 | using System; |
@@ -66,7 +67,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
66 | engine.AddRegion(scene); | 67 | engine.AddRegion(scene); |
67 | 68 | ||
68 | m_lslApi = new LSL_Api(); | 69 | m_lslApi = new LSL_Api(); |
69 | m_lslApi.Initialize(engine, part, null); | 70 | m_lslApi.Initialize(engine, part, null, null); |
70 | } | 71 | } |
71 | 72 | ||
72 | [Test] | 73 | [Test] |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs index 1381d2b..c88bad5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs | |||
@@ -41,6 +41,7 @@ using OpenSim.Region.OptionalModules.World.NPC; | |||
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.ScriptEngine.Shared; | 42 | using OpenSim.Region.ScriptEngine.Shared; |
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | 43 | using OpenSim.Region.ScriptEngine.Shared.Api; |
44 | using OpenSim.Region.ScriptEngine.Shared.Instance; | ||
44 | using OpenSim.Services.Interfaces; | 45 | using OpenSim.Services.Interfaces; |
45 | using OpenSim.Tests.Common; | 46 | using OpenSim.Tests.Common; |
46 | using OpenSim.Tests.Common.Mock; | 47 | using OpenSim.Tests.Common.Mock; |
@@ -93,7 +94,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
93 | m_scene.AddSceneObject(so); | 94 | m_scene.AddSceneObject(so); |
94 | 95 | ||
95 | OSSL_Api osslApi = new OSSL_Api(); | 96 | OSSL_Api osslApi = new OSSL_Api(); |
96 | osslApi.Initialize(m_engine, part, null); | 97 | osslApi.Initialize(m_engine, part, null, null); |
97 | 98 | ||
98 | string notecardName = "appearanceNc"; | 99 | string notecardName = "appearanceNc"; |
99 | 100 | ||
@@ -134,7 +135,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
134 | m_scene.AddSceneObject(so); | 135 | m_scene.AddSceneObject(so); |
135 | 136 | ||
136 | OSSL_Api osslApi = new OSSL_Api(); | 137 | OSSL_Api osslApi = new OSSL_Api(); |
137 | osslApi.Initialize(m_engine, part, null); | 138 | osslApi.Initialize(m_engine, part, null, null); |
138 | 139 | ||
139 | string notecardName = "appearanceNc"; | 140 | string notecardName = "appearanceNc"; |
140 | 141 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs index 5ed1f3d..b2803a1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs | |||
@@ -41,6 +41,7 @@ using OpenSim.Region.CoreModules.Framework.InventoryAccess; | |||
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.ScriptEngine.Shared; | 42 | using OpenSim.Region.ScriptEngine.Shared; |
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | 43 | using OpenSim.Region.ScriptEngine.Shared.Api; |
44 | using OpenSim.Region.ScriptEngine.Shared.Instance; | ||
44 | using OpenSim.Services.Interfaces; | 45 | using OpenSim.Services.Interfaces; |
45 | using OpenSim.Tests.Common; | 46 | using OpenSim.Tests.Common; |
46 | using OpenSim.Tests.Common.Mock; | 47 | using OpenSim.Tests.Common.Mock; |
@@ -98,9 +99,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
98 | SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); | 99 | SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); |
99 | TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); | 100 | TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); |
100 | 101 | ||
101 | new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); | 102 | new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); |
102 | OSSL_Api osslApi = new OSSL_Api(); | 103 | OSSL_Api osslApi = new OSSL_Api(); |
103 | osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); | 104 | osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); |
104 | 105 | ||
105 | // SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ua1.PrincipalID); | 106 | // SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ua1.PrincipalID); |
106 | 107 | ||
@@ -144,9 +145,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
144 | SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); | 145 | SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); |
145 | TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); | 146 | TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); |
146 | 147 | ||
147 | new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); | 148 | new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); |
148 | OSSL_Api osslApi = new OSSL_Api(); | 149 | OSSL_Api osslApi = new OSSL_Api(); |
149 | osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); | 150 | osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); |
150 | 151 | ||
151 | // Create an object embedded inside the first | 152 | // Create an object embedded inside the first |
152 | TaskInventoryHelpers.AddNotecard( | 153 | TaskInventoryHelpers.AddNotecard( |
@@ -192,12 +193,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
192 | SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); | 193 | SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); |
193 | TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); | 194 | TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); |
194 | 195 | ||
195 | new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); | 196 | new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); |
196 | OSSL_Api osslApi = new OSSL_Api(); | 197 | OSSL_Api osslApi = new OSSL_Api(); |
197 | osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); | 198 | osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); |
198 | 199 | ||
199 | // Create an object embedded inside the first | 200 | // Create an object embedded inside the first |
200 | TaskInventoryHelpers.AddSceneObject(m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); | 201 | TaskInventoryHelpers.AddSceneObject( |
202 | m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); | ||
201 | 203 | ||
202 | ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, ua2); | 204 | ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, ua2); |
203 | 205 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs index d6c82f1..1f8a6e5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | |||
@@ -42,6 +42,7 @@ using OpenSim.Region.OptionalModules.World.NPC; | |||
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
43 | using OpenSim.Region.ScriptEngine.Shared; | 43 | using OpenSim.Region.ScriptEngine.Shared; |
44 | using OpenSim.Region.ScriptEngine.Shared.Api; | 44 | using OpenSim.Region.ScriptEngine.Shared.Api; |
45 | using OpenSim.Region.ScriptEngine.Shared.Instance; | ||
45 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | 46 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
46 | using OpenSim.Services.Interfaces; | 47 | using OpenSim.Services.Interfaces; |
47 | using OpenSim.Tests.Common; | 48 | using OpenSim.Tests.Common; |
@@ -99,7 +100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
99 | m_scene.AddSceneObject(so); | 100 | m_scene.AddSceneObject(so); |
100 | 101 | ||
101 | OSSL_Api osslApi = new OSSL_Api(); | 102 | OSSL_Api osslApi = new OSSL_Api(); |
102 | osslApi.Initialize(m_engine, part, null); | 103 | osslApi.Initialize(m_engine, part, null, null); |
103 | 104 | ||
104 | string notecardName = "appearanceNc"; | 105 | string notecardName = "appearanceNc"; |
105 | osslApi.osOwnerSaveAppearance(notecardName); | 106 | osslApi.osOwnerSaveAppearance(notecardName); |
@@ -125,7 +126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
125 | m_scene.AddSceneObject(so); | 126 | m_scene.AddSceneObject(so); |
126 | 127 | ||
127 | OSSL_Api osslApi = new OSSL_Api(); | 128 | OSSL_Api osslApi = new OSSL_Api(); |
128 | osslApi.Initialize(m_engine, so.RootPart, null); | 129 | osslApi.Initialize(m_engine, so.RootPart, null, null); |
129 | 130 | ||
130 | bool gotExpectedException = false; | 131 | bool gotExpectedException = false; |
131 | try | 132 | try |
@@ -160,7 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
160 | m_scene.AddSceneObject(so); | 161 | m_scene.AddSceneObject(so); |
161 | 162 | ||
162 | OSSL_Api osslApi = new OSSL_Api(); | 163 | OSSL_Api osslApi = new OSSL_Api(); |
163 | osslApi.Initialize(m_engine, part, null); | 164 | osslApi.Initialize(m_engine, part, null, null); |
164 | 165 | ||
165 | string notecardName = "appearanceNc"; | 166 | string notecardName = "appearanceNc"; |
166 | osslApi.osOwnerSaveAppearance(notecardName); | 167 | osslApi.osOwnerSaveAppearance(notecardName); |
@@ -194,7 +195,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
194 | m_scene.AddSceneObject(so); | 195 | m_scene.AddSceneObject(so); |
195 | 196 | ||
196 | OSSL_Api osslApi = new OSSL_Api(); | 197 | OSSL_Api osslApi = new OSSL_Api(); |
197 | osslApi.Initialize(m_engine, part, null); | 198 | osslApi.Initialize(m_engine, part, null, null); |
198 | 199 | ||
199 | osslApi.osOwnerSaveAppearance(firstAppearanceNcName); | 200 | osslApi.osOwnerSaveAppearance(firstAppearanceNcName); |
200 | 201 | ||
@@ -232,7 +233,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
232 | m_scene.AddSceneObject(so); | 233 | m_scene.AddSceneObject(so); |
233 | 234 | ||
234 | OSSL_Api osslApi = new OSSL_Api(); | 235 | OSSL_Api osslApi = new OSSL_Api(); |
235 | osslApi.Initialize(m_engine, part, null); | 236 | osslApi.Initialize(m_engine, part, null, null); |
236 | 237 | ||
237 | osslApi.osOwnerSaveAppearance(firstAppearanceNcName); | 238 | osslApi.osOwnerSaveAppearance(firstAppearanceNcName); |
238 | 239 | ||
@@ -284,10 +285,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
284 | m_scene.AddSceneObject(otherSo); | 285 | m_scene.AddSceneObject(otherSo); |
285 | 286 | ||
286 | OSSL_Api osslApi = new OSSL_Api(); | 287 | OSSL_Api osslApi = new OSSL_Api(); |
287 | osslApi.Initialize(m_engine, part, null); | 288 | osslApi.Initialize(m_engine, part, null, null); |
288 | 289 | ||
289 | OSSL_Api otherOsslApi = new OSSL_Api(); | 290 | OSSL_Api otherOsslApi = new OSSL_Api(); |
290 | otherOsslApi.Initialize(m_engine, otherPart, null); | 291 | otherOsslApi.Initialize(m_engine, otherPart, null, null); |
291 | 292 | ||
292 | string notecardName = "appearanceNc"; | 293 | string notecardName = "appearanceNc"; |
293 | osslApi.osOwnerSaveAppearance(notecardName); | 294 | osslApi.osOwnerSaveAppearance(notecardName); |
@@ -331,7 +332,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
331 | m_scene.AddSceneObject(so); | 332 | m_scene.AddSceneObject(so); |
332 | 333 | ||
333 | OSSL_Api osslApi = new OSSL_Api(); | 334 | OSSL_Api osslApi = new OSSL_Api(); |
334 | osslApi.Initialize(m_engine, part, null); | 335 | osslApi.Initialize(m_engine, part, null, null); |
335 | 336 | ||
336 | string notecardName = "appearanceNc"; | 337 | string notecardName = "appearanceNc"; |
337 | osslApi.osOwnerSaveAppearance(notecardName); | 338 | osslApi.osOwnerSaveAppearance(notecardName); |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 34fcf0c..2065a46 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1356,12 +1356,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1356 | m_DomainScripts[appDomain].Add(itemID); | 1356 | m_DomainScripts[appDomain].Add(itemID); |
1357 | 1357 | ||
1358 | instance = new ScriptInstance(this, part, | 1358 | instance = new ScriptInstance(this, part, |
1359 | itemID, assetID, assembly, | 1359 | item, |
1360 | m_AppDomains[appDomain], | 1360 | startParam, postOnRez, |
1361 | part.ParentGroup.RootPart.Name, | 1361 | m_MaxScriptQueue); |
1362 | item.Name, startParam, postOnRez, | ||
1363 | stateSource, m_MaxScriptQueue); | ||
1364 | 1362 | ||
1363 | instance.Load(m_AppDomains[appDomain], assembly, stateSource); | ||
1365 | // m_log.DebugFormat( | 1364 | // m_log.DebugFormat( |
1366 | // "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", | 1365 | // "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", |
1367 | // part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, | 1366 | // part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, |
@@ -1808,9 +1807,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1808 | IScriptInstance instance = GetInstance(itemID); | 1807 | IScriptInstance instance = GetInstance(itemID); |
1809 | 1808 | ||
1810 | if (instance != null) | 1809 | if (instance != null) |
1810 | { | ||
1811 | instance.Stop(m_WaitForEventCompletionOnScriptStop); | 1811 | instance.Stop(m_WaitForEventCompletionOnScriptStop); |
1812 | } | ||
1812 | else | 1813 | else |
1814 | { | ||
1815 | // m_log.DebugFormat("[XENGINE]: Could not find script with ID {0} to stop in {1}", itemID, World.Name); | ||
1813 | m_runFlags.AddOrUpdate(itemID, false, 240); | 1816 | m_runFlags.AddOrUpdate(itemID, false, 240); |
1817 | } | ||
1814 | } | 1818 | } |
1815 | 1819 | ||
1816 | public DetectParams GetDetectParams(UUID itemID, int idx) | 1820 | public DetectParams GetDetectParams(UUID itemID, int idx) |
diff --git a/prebuild.xml b/prebuild.xml index fa7f9e9..f1964f3 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -2541,7 +2541,9 @@ | |||
2541 | <Reference name="log4net" path="../../../../../bin/"/> | 2541 | <Reference name="log4net" path="../../../../../bin/"/> |
2542 | 2542 | ||
2543 | <Files> | 2543 | <Files> |
2544 | <Match pattern="*.cs" recurse="true"/> | 2544 | <Match pattern="*.cs" recurse="true"> |
2545 | <Exclude name="Tests" pattern="Tests"/> | ||
2546 | </Match> | ||
2545 | </Files> | 2547 | </Files> |
2546 | </Project> | 2548 | </Project> |
2547 | 2549 | ||
@@ -3409,6 +3411,7 @@ | |||
3409 | <Reference name="OpenSim.Region.ScriptEngine.Shared"/> | 3411 | <Reference name="OpenSim.Region.ScriptEngine.Shared"/> |
3410 | <Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/> | 3412 | <Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/> |
3411 | <Reference name="OpenSim.Region.ScriptEngine.Shared.Api.Runtime"/> | 3413 | <Reference name="OpenSim.Region.ScriptEngine.Shared.Api.Runtime"/> |
3414 | <Reference name="OpenSim.Region.ScriptEngine.Shared.Instance"/> | ||
3412 | <Reference name="OpenSim.Region.ScriptEngine.XEngine"/> | 3415 | <Reference name="OpenSim.Region.ScriptEngine.XEngine"/> |
3413 | <Reference name="OpenSim.Services.Interfaces"/> | 3416 | <Reference name="OpenSim.Services.Interfaces"/> |
3414 | <Reference name="OpenSim.Tests.Common"/> | 3417 | <Reference name="OpenSim.Tests.Common"/> |
@@ -3432,6 +3435,7 @@ | |||
3432 | <!-- SADLY the way this works means you need to keep adding these paths --> | 3435 | <!-- SADLY the way this works means you need to keep adding these paths --> |
3433 | <Match path="Shared/Tests" pattern="*.cs" recurse="true"/> | 3436 | <Match path="Shared/Tests" pattern="*.cs" recurse="true"/> |
3434 | <Match path="Shared/CodeTools/Tests" pattern="*.cs" recurse="true"/> | 3437 | <Match path="Shared/CodeTools/Tests" pattern="*.cs" recurse="true"/> |
3438 | <Match path="Shared/Instance/Tests" pattern="*.cs" recurse="true"/> | ||
3435 | <Match path="XEngine/Tests" pattern="*.cs" recurse="true"/> | 3439 | <Match path="XEngine/Tests" pattern="*.cs" recurse="true"/> |
3436 | </Files> | 3440 | </Files> |
3437 | </Project> | 3441 | </Project> |