aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs66
1 files changed, 36 insertions, 30 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 637c556..b983be9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -71,7 +71,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
71 private bool m_TimerQueued; 71 private bool m_TimerQueued;
72 private DateTime m_EventStart; 72 private DateTime m_EventStart;
73 private bool m_InEvent; 73 private bool m_InEvent;
74 private string m_Assembly; 74 private string m_assemblyPath;
75 private string m_dataPath;
75 private string m_CurrentEvent = String.Empty; 76 private string m_CurrentEvent = String.Empty;
76 private bool m_InSelfDelete; 77 private bool m_InSelfDelete;
77 private int m_MaxScriptQueue; 78 private int m_MaxScriptQueue;
@@ -244,12 +245,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
244 /// </summary> 245 /// </summary>
245 /// <param name='dom'></param> 246 /// <param name='dom'></param>
246 /// <param name='assembly'></param> 247 /// <param name='assembly'></param>
248 /// <param name='dataPath'>
249 /// Path for all script associated data (state, etc.). In a multi-region set up
250 /// with all scripts loading into the same AppDomain this may not be the same place as the DLL itself.
251 /// </param>
247 /// <param name='stateSource'></param> 252 /// <param name='stateSource'></param>
248 /// <returns>false if load failed, true if suceeded</returns> 253 /// <returns>false if load failed, true if suceeded</returns>
249 public bool Load(AppDomain dom, Assembly scriptAssembly, StateSource stateSource) 254 public bool Load(AppDomain dom, Assembly scriptAssembly, string dataPath, StateSource stateSource)
250 { 255 {
251 //m_Assembly = scriptAssembly.CodeBase; 256 m_assemblyPath = scriptAssembly.Location;
252 m_Assembly = scriptAssembly.Location; 257 m_dataPath = dataPath;
253 m_stateSource = stateSource; 258 m_stateSource = stateSource;
254 259
255 try 260 try
@@ -270,14 +275,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
270 constructorParams = null; 275 constructorParams = null;
271 } 276 }
272 277
273// m_log.DebugFormat(
274// "[SCRIP
275// scriptType.FullName, m_Assembly, Engine.World.Name);
276
277 if (dom != System.AppDomain.CurrentDomain) 278 if (dom != System.AppDomain.CurrentDomain)
278 m_Script 279 m_Script
279 = (IScript)dom.CreateInstanceAndUnwrap( 280 = (IScript)dom.CreateInstanceAndUnwrap(
280 Path.GetFileNameWithoutExtension(m_Assembly), 281 Path.GetFileNameWithoutExtension(m_assemblyPath),
281 scriptType.FullName, 282 scriptType.FullName,
282 false, 283 false,
283 BindingFlags.Default, 284 BindingFlags.Default,
@@ -305,7 +306,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
305 { 306 {
306 m_log.ErrorFormat( 307 m_log.ErrorFormat(
307 "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Error loading assembly {6}. Exception {7}{8}", 308 "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Error loading assembly {6}. Exception {7}{8}",
308 ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, m_Assembly, e.Message, e.StackTrace); 309 ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, scriptAssembly.Location, e.Message, e.StackTrace);
309 310
310 return false; 311 return false;
311 } 312 }
@@ -340,10 +341,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
340 341
341 m_SaveState = true; 342 m_SaveState = true;
342 343
343 string savedState = Path.Combine(Path.GetDirectoryName(m_Assembly), ItemID.ToString() + ".state"); 344 string savedState = Path.Combine(m_dataPath, ItemID.ToString() + ".state");
344 345
345 if (File.Exists(savedState)) 346 if (File.Exists(savedState))
346 { 347 {
348// m_log.DebugFormat(
349// "[SCRIPT INSTANCE]: Found state for script {0} for {1} ({2}) at {3} in {4}",
350// ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name);
351
347 string xml = String.Empty; 352 string xml = String.Empty;
348 353
349 try 354 try
@@ -385,12 +390,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
385 m_startedFromSavedState = true; 390 m_startedFromSavedState = true;
386 } 391 }
387 } 392 }
388 else 393// else
389 { 394// {
390 m_log.WarnFormat( 395// m_log.WarnFormat(
391 "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Unable to load script state file {6}. Memory limit exceeded.", 396// "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Unable to load script state file {6}. Memory limit exceeded.",
392 ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState); 397// ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState);
393 } 398// }
394 } 399 }
395 catch (Exception e) 400 catch (Exception e)
396 { 401 {
@@ -401,11 +406,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
401 } 406 }
402// else 407// else
403// { 408// {
404// ScenePresence presence = Engine.World.GetScenePresence(part.OwnerID); 409// m_log.DebugFormat(
405 410// "[SCRIPT INSTANCE]: Did not find state for script {0} for {1} ({2}) at {3} in {4}",
406// if (presence != null && (!postOnRez)) 411// ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name);
407// presence.ControllingClient.SendAgentAlertMessage("Compile successful", false);
408
409// } 412// }
410 413
411 return true; 414 return true;
@@ -498,8 +501,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
498 501
499 public void RemoveState() 502 public void RemoveState()
500 { 503 {
501 string savedState = Path.Combine(Path.GetDirectoryName(m_Assembly), 504 string savedState = Path.Combine(m_dataPath, ItemID.ToString() + ".state");
502 ItemID.ToString() + ".state"); 505
506// m_log.DebugFormat(
507// "[SCRIPT INSTANCE]: Deleting state {0} for script {1} (id {2}) in part {3} (id {4}) in object {5} in {6}.",
508// savedState, ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name);
503 509
504 try 510 try
505 { 511 {
@@ -822,8 +828,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
822 if (Engine.World.PipeEventsForScript(LocalID) || 828 if (Engine.World.PipeEventsForScript(LocalID) ||
823 data.EventName == "control") // Don't freeze avies! 829 data.EventName == "control") // Don't freeze avies!
824 { 830 {
825 // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", 831// m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
826 // PrimName, ScriptName, data.EventName, State); 832// PrimName, ScriptName, data.EventName, State);
827 833
828 try 834 try
829 { 835 {
@@ -849,7 +855,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
849 // This will be the very first event we deliver 855 // This will be the very first event we deliver
850 // (state_entry) in default state 856 // (state_entry) in default state
851 // 857 //
852 SaveState(m_Assembly); 858 SaveState();
853 859
854 m_SaveState = false; 860 m_SaveState = false;
855 } 861 }
@@ -1043,7 +1049,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
1043 return m_DetectParams[idx].Key; 1049 return m_DetectParams[idx].Key;
1044 } 1050 }
1045 1051
1046 public void SaveState(string assembly) 1052 public void SaveState()
1047 { 1053 {
1048 // If we're currently in an event, just tell it to save upon return 1054 // If we're currently in an event, just tell it to save upon return
1049 // 1055 //
@@ -1065,7 +1071,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
1065 { 1071 {
1066 try 1072 try
1067 { 1073 {
1068 using (FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state"))) 1074 using (FileStream fs = File.Create(Path.Combine(m_dataPath, ItemID.ToString() + ".state")))
1069 { 1075 {
1070 Byte[] buf = Util.UTF8NoBomEncoding.GetBytes(xml); 1076 Byte[] buf = Util.UTF8NoBomEncoding.GetBytes(xml);
1071 fs.Write(buf, 0, buf.Length); 1077 fs.Write(buf, 0, buf.Length);
@@ -1149,7 +1155,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
1149 1155
1150 public string GetAssemblyName() 1156 public string GetAssemblyName()
1151 { 1157 {
1152 return m_Assembly; 1158 return m_assemblyPath;
1153 } 1159 }
1154 1160
1155 public string GetXMLState() 1161 public string GetXMLState()