diff options
author | Justin Clark-Casey (justincc) | 2013-01-15 21:13:22 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-01-15 21:13:22 +0000 |
commit | fccb03227e3f541a4c2f4e0e619074e4c1fb55dd (patch) | |
tree | aa37ee5014fe71bb07d1d4e296a7ac3821c84da4 /OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |
parent | Print full stacktrace from plugin loading failure to help determine what went... (diff) | |
download | opensim-SC-fccb03227e3f541a4c2f4e0e619074e4c1fb55dd.zip opensim-SC-fccb03227e3f541a4c2f4e0e619074e4c1fb55dd.tar.gz opensim-SC-fccb03227e3f541a4c2f4e0e619074e4c1fb55dd.tar.bz2 opensim-SC-fccb03227e3f541a4c2f4e0e619074e4c1fb55dd.tar.xz |
Instead of passing separate engine, part and item components to script APIs, pass down IScriptInstance instead.
This is to allow the future co-operative script thread terminate feature to detect and act upon termination requests.
This splits the assembly and state loading out from the ScriptInstance() constructor to a separate Load() method
in order to facilititate continued script logic regression testing.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index f172216..a2ff51b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -157,9 +157,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
157 | 157 | ||
158 | public UUID AppDomain { get; set; } | 158 | public UUID AppDomain { get; set; } |
159 | 159 | ||
160 | /// <summary> | ||
161 | /// Scene part in which this script instance is contained. | ||
162 | /// </summary> | ||
163 | public SceneObjectPart Part { get; private set; } | 160 | public SceneObjectPart Part { get; private set; } |
164 | 161 | ||
165 | public string PrimName { get; private set; } | 162 | public string PrimName { get; private set; } |
@@ -209,43 +206,52 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
209 | EventQueue.Clear(); | 206 | EventQueue.Clear(); |
210 | } | 207 | } |
211 | 208 | ||
212 | public ScriptInstance(IScriptEngine engine, SceneObjectPart part, | 209 | public ScriptInstance( |
213 | UUID itemID, UUID assetID, string assembly, | 210 | IScriptEngine engine, SceneObjectPart part, TaskInventoryItem item, |
214 | AppDomain dom, string primName, string scriptName, | 211 | int startParam, bool postOnRez, |
215 | int startParam, bool postOnRez, StateSource stateSource, | 212 | int maxScriptQueue) |
216 | int maxScriptQueue) | ||
217 | { | 213 | { |
218 | State = "default"; | 214 | State = "default"; |
219 | EventQueue = new Queue(32); | 215 | EventQueue = new Queue(32); |
220 | 216 | ||
221 | Engine = engine; | 217 | Engine = engine; |
222 | Part = part; | 218 | Part = part; |
223 | ItemID = itemID; | 219 | ScriptTask = item; |
224 | AssetID = assetID; | 220 | |
225 | PrimName = primName; | 221 | // This is currently only here to allow regression tests to get away without specifying any inventory |
226 | ScriptName = scriptName; | 222 | // item when they are testing script logic that doesn't require an item. |
227 | m_Assembly = assembly; | 223 | if (ScriptTask != null) |
224 | { | ||
225 | ScriptName = ScriptTask.Name; | ||
226 | ItemID = ScriptTask.ItemID; | ||
227 | AssetID = ScriptTask.AssetID; | ||
228 | } | ||
229 | |||
230 | PrimName = part.ParentGroup.Name; | ||
228 | StartParam = startParam; | 231 | StartParam = startParam; |
229 | m_MaxScriptQueue = maxScriptQueue; | 232 | m_MaxScriptQueue = maxScriptQueue; |
230 | m_stateSource = stateSource; | ||
231 | m_postOnRez = postOnRez; | 233 | m_postOnRez = postOnRez; |
232 | m_AttachedAvatar = Part.ParentGroup.AttachedAvatar; | 234 | m_AttachedAvatar = Part.ParentGroup.AttachedAvatar; |
233 | m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID; | 235 | m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID; |
236 | } | ||
234 | 237 | ||
235 | lock (Part.TaskInventory) | 238 | /// <summary> |
236 | { | 239 | /// Load the script from an assembly into an AppDomain. |
237 | if (Part.TaskInventory.ContainsKey(ItemID)) | 240 | /// </summary> |
238 | { | 241 | /// <param name='dom'></param> |
239 | ScriptTask = Part.TaskInventory[ItemID]; | 242 | /// <param name='assembly'></param> |
240 | } | 243 | /// <param name='stateSource'></param> |
241 | } | 244 | public void Load(AppDomain dom, string assembly, StateSource stateSource) |
245 | { | ||
246 | m_Assembly = assembly; | ||
247 | m_stateSource = stateSource; | ||
242 | 248 | ||
243 | ApiManager am = new ApiManager(); | 249 | ApiManager am = new ApiManager(); |
244 | 250 | ||
245 | foreach (string api in am.GetApis()) | 251 | foreach (string api in am.GetApis()) |
246 | { | 252 | { |
247 | m_Apis[api] = am.CreateApi(api); | 253 | m_Apis[api] = am.CreateApi(api); |
248 | m_Apis[api].Initialize(engine, part, ScriptTask); | 254 | m_Apis[api].Initialize(this); |
249 | } | 255 | } |
250 | 256 | ||
251 | try | 257 | try |
@@ -279,7 +285,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
279 | 285 | ||
280 | // // m_log.Debug("[Script] Script instance created"); | 286 | // // m_log.Debug("[Script] Script instance created"); |
281 | 287 | ||
282 | part.SetScriptEvents(ItemID, | 288 | Part.SetScriptEvents(ItemID, |
283 | (int)m_Script.GetStateEventFlags(State)); | 289 | (int)m_Script.GetStateEventFlags(State)); |
284 | } | 290 | } |
285 | catch (Exception e) | 291 | catch (Exception e) |