diff options
author | Justin Clark-Casey (justincc) | 2013-01-11 01:46:36 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-01-11 01:46:36 +0000 |
commit | 05ac6d3209afb640926995d252e8513ef3003819 (patch) | |
tree | 4c085af053946755502294dba28367f8918cddb0 | |
parent | Fix a regression in the last few scene commands changes where setting these v... (diff) | |
download | opensim-SC_OLD-05ac6d3209afb640926995d252e8513ef3003819.zip opensim-SC_OLD-05ac6d3209afb640926995d252e8513ef3003819.tar.gz opensim-SC_OLD-05ac6d3209afb640926995d252e8513ef3003819.tar.bz2 opensim-SC_OLD-05ac6d3209afb640926995d252e8513ef3003819.tar.xz |
Save attachments on detach/exit if a contained script state has been changed.
This involves making Attachments module listen for start/stop script changes.
It also involves removing the script from the region on detach in the same manner as every other DeleteSceneObject() call rather than simply stopping it
This is necessary tue to the bad assymetry of start and stop script triggers but it appears to be the correct behaviour anyway, as detached objects are completely gone from the sim.
Not just in a state where their scripts have been stopped.
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 18 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/EventManager.cs | 3 |
2 files changed, 20 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 58ed554..f9c2142 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -75,10 +75,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
75 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); | 75 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); |
76 | 76 | ||
77 | if (Enabled) | 77 | if (Enabled) |
78 | { | ||
78 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; | 79 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; |
80 | m_scene.EventManager.OnStartScript += HandleScriptStateChange; | ||
81 | m_scene.EventManager.OnStopScript += HandleScriptStateChange; | ||
82 | } | ||
79 | 83 | ||
80 | // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI | 84 | // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI |
81 | } | 85 | } |
86 | |||
87 | /// <summary> | ||
88 | /// Listen for client triggered running state changes so that we can persist the script's object if necessary. | ||
89 | /// </summary> | ||
90 | /// <param name='localID'></param> | ||
91 | /// <param name='itemID'></param> | ||
92 | private void HandleScriptStateChange(uint localID, UUID itemID) | ||
93 | { | ||
94 | SceneObjectGroup sog = m_scene.GetGroupByPrim(localID); | ||
95 | if (sog != null && sog.IsAttachment) | ||
96 | sog.HasGroupChanged = true; | ||
97 | } | ||
82 | 98 | ||
83 | public void RemoveRegion(Scene scene) | 99 | public void RemoveRegion(Scene scene) |
84 | { | 100 | { |
@@ -743,7 +759,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
743 | // Remove the object from the scene so no more updates | 759 | // Remove the object from the scene so no more updates |
744 | // are sent. Doing this before the below changes will ensure | 760 | // are sent. Doing this before the below changes will ensure |
745 | // updates can't cause "HUD artefacts" | 761 | // updates can't cause "HUD artefacts" |
746 | m_scene.DeleteSceneObject(so, false, false); | 762 | m_scene.DeleteSceneObject(so, false); |
747 | 763 | ||
748 | // Prepare sog for storage | 764 | // Prepare sog for storage |
749 | so.AttachedAvatar = UUID.Zero; | 765 | so.AttachedAvatar = UUID.Zero; |
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 6b08e0f..902ded1 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -339,6 +339,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
339 | /// in <see cref="Scene.SetScriptRunning"/> | 339 | /// in <see cref="Scene.SetScriptRunning"/> |
340 | /// via <see cref="OpenSim.Framework.IClientAPI.OnSetScriptRunning"/>, | 340 | /// via <see cref="OpenSim.Framework.IClientAPI.OnSetScriptRunning"/>, |
341 | /// via <see cref="OpenSim.Region.ClientStack.LindenUDP.HandleSetScriptRunning"/> | 341 | /// via <see cref="OpenSim.Region.ClientStack.LindenUDP.HandleSetScriptRunning"/> |
342 | /// XXX: This is only triggered when it is the client that starts the script, not in other situations where | ||
343 | /// a script is started, unlike OnStopScript! | ||
342 | /// </remarks> | 344 | /// </remarks> |
343 | public event StartScript OnStartScript; | 345 | public event StartScript OnStartScript; |
344 | 346 | ||
@@ -352,6 +354,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
352 | /// in <see cref="SceneObjectPartInventory.CreateScriptInstance"/>, | 354 | /// in <see cref="SceneObjectPartInventory.CreateScriptInstance"/>, |
353 | /// <see cref="SceneObjectPartInventory.StopScriptInstance"/>, | 355 | /// <see cref="SceneObjectPartInventory.StopScriptInstance"/>, |
354 | /// <see cref="Scene.SetScriptRunning"/> | 356 | /// <see cref="Scene.SetScriptRunning"/> |
357 | /// XXX: This is triggered when a sciprt is stopped for any reason, unlike OnStartScript! | ||
355 | /// </remarks> | 358 | /// </remarks> |
356 | public event StopScript OnStopScript; | 359 | public event StopScript OnStopScript; |
357 | 360 | ||