aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs27
1 files changed, 22 insertions, 5 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 79e4774..9498aa8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -58,6 +58,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
58 { 58 {
59 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 59 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
60 60
61 public bool StatePersistedHere { get { return m_AttachedAvatar == UUID.Zero; } }
62
61 /// <summary> 63 /// <summary>
62 /// The current work item if an event for this script is running or waiting to run, 64 /// The current work item if an event for this script is running or waiting to run,
63 /// </summary> 65 /// </summary>
@@ -76,7 +78,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
76 private string m_CurrentEvent = String.Empty; 78 private string m_CurrentEvent = String.Empty;
77 private bool m_InSelfDelete; 79 private bool m_InSelfDelete;
78 private int m_MaxScriptQueue; 80 private int m_MaxScriptQueue;
79 private bool m_SaveState = true; 81 private bool m_SaveState;
80 private int m_ControlEventsInQueue; 82 private int m_ControlEventsInQueue;
81 private int m_LastControlLevel; 83 private int m_LastControlLevel;
82 private bool m_CollisionInQueue; 84 private bool m_CollisionInQueue;
@@ -238,6 +240,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
238 m_postOnRez = postOnRez; 240 m_postOnRez = postOnRez;
239 m_AttachedAvatar = Part.ParentGroup.AttachedAvatar; 241 m_AttachedAvatar = Part.ParentGroup.AttachedAvatar;
240 m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID; 242 m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID;
243
244 m_SaveState = StatePersistedHere;
245
246// m_log.DebugFormat(
247// "[SCRIPT INSTANCE]: Instantiated script instance {0} (id {1}) in part {2} (id {3}) in object {4} attached avatar {5} in {6}",
248// ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, m_AttachedAvatar, Engine.World.Name);
241 } 249 }
242 250
243 /// <summary> 251 /// <summary>
@@ -339,8 +347,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
339 return false; 347 return false;
340 } 348 }
341 349
342 m_SaveState = true; 350 // For attachments, XEngine saves the state into a .state file when XEngine.SetXMLState() is called.
343
344 string savedState = Path.Combine(m_dataPath, ItemID.ToString() + ".state"); 351 string savedState = Path.Combine(m_dataPath, ItemID.ToString() + ".state");
345 352
346 if (File.Exists(savedState)) 353 if (File.Exists(savedState))
@@ -389,6 +396,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
389 m_SaveState = false; 396 m_SaveState = false;
390 m_startedFromSavedState = true; 397 m_startedFromSavedState = true;
391 } 398 }
399
400 // If this script is in an attachment then we no longer need the state file.
401 if (!StatePersistedHere)
402 RemoveState();
392 } 403 }
393// else 404// else
394// { 405// {
@@ -984,7 +995,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
984 (int)m_Script.GetStateEventFlags(State)); 995 (int)m_Script.GetStateEventFlags(State));
985 if (running) 996 if (running)
986 Start(); 997 Start();
987 m_SaveState = true; 998
999 m_SaveState = StatePersistedHere;
1000
988 PostEvent(new EventParams("state_entry", 1001 PostEvent(new EventParams("state_entry",
989 new Object[0], new DetectParams[0])); 1002 new Object[0], new DetectParams[0]));
990 } 1003 }
@@ -1010,7 +1023,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
1010 1023
1011 if (m_CurrentEvent != "state_entry") 1024 if (m_CurrentEvent != "state_entry")
1012 { 1025 {
1013 m_SaveState = true; 1026 m_SaveState = StatePersistedHere;
1014 PostEvent(new EventParams("state_entry", 1027 PostEvent(new EventParams("state_entry",
1015 new Object[0], new DetectParams[0])); 1028 new Object[0], new DetectParams[0]));
1016 throw new EventAbortException(); 1029 throw new EventAbortException();
@@ -1060,6 +1073,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
1060 return; 1073 return;
1061 } 1074 }
1062 1075
1076// m_log.DebugFormat(
1077// "[SCRIPT INSTANCE]: Saving state for script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}",
1078// ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name);
1079
1063 PluginData = AsyncCommandManager.GetSerializationData(Engine, ItemID); 1080 PluginData = AsyncCommandManager.GetSerializationData(Engine, ItemID);
1064 1081
1065 string xml = ScriptSerializer.Serialize(this); 1082 string xml = ScriptSerializer.Serialize(this);