diff options
author | Justin Clark-Casey (justincc) | 2011-11-22 22:13:57 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-11-22 22:13:57 +0000 |
commit | b0fe0464af9a11dda184d3613eca734cd8c9f21e (patch) | |
tree | 27a8a50451c139f954d86d4348ca6e10a552c34e /OpenSim | |
parent | slightly simplify OdeScene.Simulate() by removing bool processtaints, since w... (diff) | |
download | opensim-SC_OLD-b0fe0464af9a11dda184d3613eca734cd8c9f21e.zip opensim-SC_OLD-b0fe0464af9a11dda184d3613eca734cd8c9f21e.tar.gz opensim-SC_OLD-b0fe0464af9a11dda184d3613eca734cd8c9f21e.tar.bz2 opensim-SC_OLD-b0fe0464af9a11dda184d3613eca734cd8c9f21e.tar.xz |
Stop an exception being thrown and a teleport/border cross failing if the desintation sim has no active script engines.
This involves getting IScene.RequestModuleInterfaces() to return an empty array (as was stated in the method doc) rather than an array containing one null entry.
Callers adjusted to stop checking for the list reference being null (which never happened anyway)
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/IScene.cs | 22 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 13 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneBase.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 10 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 26 |
5 files changed, 41 insertions, 32 deletions
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index f1b4732..76b731f 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs | |||
@@ -102,12 +102,28 @@ namespace OpenSim.Framework | |||
102 | 102 | ||
103 | bool TryGetScenePresence(UUID agentID, out object scenePresence); | 103 | bool TryGetScenePresence(UUID agentID, out object scenePresence); |
104 | 104 | ||
105 | T RequestModuleInterface<T>(); | 105 | /// <summary> |
106 | T[] RequestModuleInterfaces<T>(); | 106 | /// Register an interface to a region module. This allows module methods to be called directly as |
107 | 107 | /// well as via events. If there is already a module registered for this interface, it is not replaced | |
108 | /// (is this the best behaviour?) | ||
109 | /// </summary> | ||
110 | /// <param name="mod"></param> | ||
108 | void RegisterModuleInterface<M>(M mod); | 111 | void RegisterModuleInterface<M>(M mod); |
112 | |||
109 | void StackModuleInterface<M>(M mod); | 113 | void StackModuleInterface<M>(M mod); |
110 | 114 | ||
115 | /// <summary> | ||
116 | /// For the given interface, retrieve the region module which implements it. | ||
117 | /// </summary> | ||
118 | /// <returns>null if there is no registered module implementing that interface</returns> | ||
119 | T RequestModuleInterface<T>(); | ||
120 | |||
121 | /// <summary> | ||
122 | /// For the given interface, retrieve an array of region modules that implement it. | ||
123 | /// </summary> | ||
124 | /// <returns>an empty array if there are no registered modules implementing that interface</returns> | ||
125 | T[] RequestModuleInterfaces<T>(); | ||
126 | |||
111 | // void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); | 127 | // void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); |
112 | 128 | ||
113 | ISceneObject DeserializeObject(string representation); | 129 | ISceneObject DeserializeObject(string representation); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 663aa22..26eb729 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -82,16 +82,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
82 | m_log.Info("[PRIM INVENTORY]: Starting scripts in scene"); | 82 | m_log.Info("[PRIM INVENTORY]: Starting scripts in scene"); |
83 | 83 | ||
84 | IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>(); | 84 | IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>(); |
85 | if (engines != null) | 85 | |
86 | { | 86 | foreach (IScriptModule engine in engines) |
87 | foreach (IScriptModule engine in engines) | 87 | engine.StartProcessing(); |
88 | { | ||
89 | if (engine != null) | ||
90 | { | ||
91 | engine.StartProcessing(); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | } | 88 | } |
96 | 89 | ||
97 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) | 90 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index dee2ecb..0336fe5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -449,7 +449,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
449 | } | 449 | } |
450 | else | 450 | else |
451 | { | 451 | { |
452 | return new T[] { default(T) }; | 452 | return new T[] {}; |
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 9446741..d80944b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -232,8 +232,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
232 | ArrayList ret = new ArrayList(); | 232 | ArrayList ret = new ArrayList(); |
233 | 233 | ||
234 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 234 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
235 | if (engines == null) // No engine at all | ||
236 | return ret; | ||
237 | 235 | ||
238 | foreach (IScriptModule e in engines) | 236 | foreach (IScriptModule e in engines) |
239 | { | 237 | { |
@@ -329,7 +327,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
329 | private void RestoreSavedScriptState(UUID oldID, UUID newID) | 327 | private void RestoreSavedScriptState(UUID oldID, UUID newID) |
330 | { | 328 | { |
331 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 329 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
332 | if (engines == null) // No engine at all | 330 | if (engines.Length == 0) // No engine at all |
333 | return; | 331 | return; |
334 | 332 | ||
335 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) | 333 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) |
@@ -369,6 +367,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
369 | 367 | ||
370 | m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; | 368 | m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; |
371 | } | 369 | } |
370 | |||
372 | foreach (IScriptModule e in engines) | 371 | foreach (IScriptModule e in engines) |
373 | { | 372 | { |
374 | if (e != null) | 373 | if (e != null) |
@@ -377,6 +376,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
377 | break; | 376 | break; |
378 | } | 377 | } |
379 | } | 378 | } |
379 | |||
380 | m_part.ParentGroup.m_savedScriptState.Remove(oldID); | 380 | m_part.ParentGroup.m_savedScriptState.Remove(oldID); |
381 | } | 381 | } |
382 | } | 382 | } |
@@ -1129,7 +1129,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1129 | 1129 | ||
1130 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 1130 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
1131 | 1131 | ||
1132 | if (engines == null) // No engine at all | 1132 | if (engines.Length == 0) // No engine at all |
1133 | return ret; | 1133 | return ret; |
1134 | 1134 | ||
1135 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 1135 | List<TaskInventoryItem> scripts = GetInventoryScripts(); |
@@ -1157,7 +1157,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1157 | public void ResumeScripts() | 1157 | public void ResumeScripts() |
1158 | { | 1158 | { |
1159 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 1159 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
1160 | if (engines == null) | 1160 | if (engines.Length == 0) |
1161 | return; | 1161 | return; |
1162 | 1162 | ||
1163 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 1163 | List<TaskInventoryItem> scripts = GetInventoryScripts(); |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7d901c9..c2d3501 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3525,23 +3525,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
3525 | /// <param name="args">The arguments for the event</param> | 3525 | /// <param name="args">The arguments for the event</param> |
3526 | public void SendScriptEventToAttachments(string eventName, Object[] args) | 3526 | public void SendScriptEventToAttachments(string eventName, Object[] args) |
3527 | { | 3527 | { |
3528 | if (m_scriptEngines != null) | 3528 | if (m_scriptEngines.Length == 0) |
3529 | return; | ||
3530 | |||
3531 | lock (m_attachments) | ||
3529 | { | 3532 | { |
3530 | lock (m_attachments) | 3533 | foreach (SceneObjectGroup grp in m_attachments) |
3531 | { | 3534 | { |
3532 | foreach (SceneObjectGroup grp in m_attachments) | 3535 | // 16384 is CHANGED_ANIMATION |
3536 | // | ||
3537 | // Send this to all attachment root prims | ||
3538 | // | ||
3539 | foreach (IScriptModule m in m_scriptEngines) | ||
3533 | { | 3540 | { |
3534 | // 16384 is CHANGED_ANIMATION | 3541 | if (m == null) // No script engine loaded |
3535 | // | 3542 | continue; |
3536 | // Send this to all attachment root prims | ||
3537 | // | ||
3538 | foreach (IScriptModule m in m_scriptEngines) | ||
3539 | { | ||
3540 | if (m == null) // No script engine loaded | ||
3541 | continue; | ||
3542 | 3543 | ||
3543 | m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); | 3544 | m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); |
3544 | } | ||
3545 | } | 3545 | } |
3546 | } | 3546 | } |
3547 | } | 3547 | } |