diff options
author | onefang | 2019-09-11 16:36:50 +1000 |
---|---|---|
committer | onefang | 2019-09-11 16:36:50 +1000 |
commit | 50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch) | |
tree | 52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |
parent | Renamed branch to SledjChisl. (diff) | |
parent | Bump to release flavour, build 0. (diff) | |
download | opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2 opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz |
Merge branch 'SledjChisl'
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 205 |
1 files changed, 126 insertions, 79 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index fa6e6fc..5342c28 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -51,7 +51,8 @@ using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | |||
51 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | 51 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
52 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; | 52 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; |
53 | using OpenSim.Region.ScriptEngine.Interfaces; | 53 | using OpenSim.Region.ScriptEngine.Interfaces; |
54 | using System.Diagnostics; | 54 | |
55 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
55 | 56 | ||
56 | namespace OpenSim.Region.ScriptEngine.Shared.Instance | 57 | namespace OpenSim.Region.ScriptEngine.Shared.Instance |
57 | { | 58 | { |
@@ -87,7 +88,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
87 | 88 | ||
88 | // The following is for setting a minimum delay between events | 89 | // The following is for setting a minimum delay between events |
89 | private double m_minEventDelay; | 90 | private double m_minEventDelay; |
90 | 91 | ||
91 | private long m_eventDelayTicks; | 92 | private long m_eventDelayTicks; |
92 | private long m_nextEventTimeTicks; | 93 | private long m_nextEventTimeTicks; |
93 | private bool m_startOnInit = true; | 94 | private bool m_startOnInit = true; |
@@ -121,7 +122,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
121 | { | 122 | { |
122 | if (value > 0.001) | 123 | if (value > 0.001) |
123 | m_minEventDelay = value; | 124 | m_minEventDelay = value; |
124 | else | 125 | else |
125 | m_minEventDelay = 0.0; | 126 | m_minEventDelay = 0.0; |
126 | 127 | ||
127 | m_eventDelayTicks = (long)(m_minEventDelay * 10000000L); | 128 | m_eventDelayTicks = (long)(m_minEventDelay * 10000000L); |
@@ -153,7 +154,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
153 | { | 154 | { |
154 | bool wasSuspended = m_Suspended; | 155 | bool wasSuspended = m_Suspended; |
155 | m_Suspended = value; | 156 | m_Suspended = value; |
156 | 157 | ||
157 | if (wasSuspended && !m_Suspended) | 158 | if (wasSuspended && !m_Suspended) |
158 | { | 159 | { |
159 | lock (EventQueue) | 160 | lock (EventQueue) |
@@ -200,11 +201,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
200 | 201 | ||
201 | public long EventsQueued | 202 | public long EventsQueued |
202 | { | 203 | { |
203 | get | 204 | get |
204 | { | 205 | { |
205 | lock (EventQueue) | 206 | lock (EventQueue) |
206 | return EventQueue.Count; | 207 | return EventQueue.Count; |
207 | } | 208 | } |
208 | } | 209 | } |
209 | 210 | ||
210 | public long EventsProcessed { get; private set; } | 211 | public long EventsProcessed { get; private set; } |
@@ -220,7 +221,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
220 | private static readonly int MeasurementWindow = 30 * 1000; // show the *recent* time used by the script, to find currently active scripts | 221 | private static readonly int MeasurementWindow = 30 * 1000; // show the *recent* time used by the script, to find currently active scripts |
221 | 222 | ||
222 | private bool m_coopTermination; | 223 | private bool m_coopTermination; |
223 | 224 | ||
224 | private EventWaitHandle m_coopSleepHandle; | 225 | private EventWaitHandle m_coopSleepHandle; |
225 | 226 | ||
226 | public void ClearQueue() | 227 | public void ClearQueue() |
@@ -256,8 +257,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
256 | StartParam = startParam; | 257 | StartParam = startParam; |
257 | m_MaxScriptQueue = maxScriptQueue; | 258 | m_MaxScriptQueue = maxScriptQueue; |
258 | m_postOnRez = postOnRez; | 259 | m_postOnRez = postOnRez; |
259 | m_AttachedAvatar = Part.ParentGroup.AttachedAvatar; | 260 | m_AttachedAvatar = part.ParentGroup.AttachedAvatar; |
260 | m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID; | 261 | m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; |
261 | 262 | ||
262 | m_SaveState = StatePersistedHere; | 263 | m_SaveState = StatePersistedHere; |
263 | 264 | ||
@@ -280,7 +281,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
280 | /// <param name='stateSource'></param> | 281 | /// <param name='stateSource'></param> |
281 | /// <returns>false if load failed, true if suceeded</returns> | 282 | /// <returns>false if load failed, true if suceeded</returns> |
282 | public bool Load( | 283 | public bool Load( |
283 | IScript script, EventWaitHandle coopSleepHandle, string assemblyPath, | 284 | IScript script, EventWaitHandle coopSleepHandle, string assemblyPath, |
284 | string dataPath, StateSource stateSource, bool coopTermination) | 285 | string dataPath, StateSource stateSource, bool coopTermination) |
285 | { | 286 | { |
286 | m_Script = script; | 287 | m_Script = script; |
@@ -323,13 +324,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
323 | return false; | 324 | return false; |
324 | } | 325 | } |
325 | 326 | ||
326 | // For attachments, XEngine saves the state into a .state file when XEngine.SetXMLState() is called. | 327 | // For attachments, XEngine saves the state into a .state file when XEngine.SetXMLState() is called. |
327 | string savedState = Path.Combine(m_dataPath, ItemID.ToString() + ".state"); | 328 | string savedState = Path.Combine(m_dataPath, ItemID.ToString() + ".state"); |
328 | 329 | ||
329 | if (File.Exists(savedState)) | 330 | if (File.Exists(savedState)) |
330 | { | 331 | { |
331 | // m_log.DebugFormat( | 332 | // m_log.DebugFormat( |
332 | // "[SCRIPT INSTANCE]: Found state for script {0} for {1} ({2}) at {3} in {4}", | 333 | // "[SCRIPT INSTANCE]: Found state for script {0} for {1} ({2}) at {3} in {4}", |
333 | // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); | 334 | // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); |
334 | 335 | ||
335 | string xml = String.Empty; | 336 | string xml = String.Empty; |
@@ -394,7 +395,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
394 | // else | 395 | // else |
395 | // { | 396 | // { |
396 | // m_log.DebugFormat( | 397 | // m_log.DebugFormat( |
397 | // "[SCRIPT INSTANCE]: Did not find state for script {0} for {1} ({2}) at {3} in {4}", | 398 | // "[SCRIPT INSTANCE]: Did not find state for script {0} for {1} ({2}) at {3} in {4}", |
398 | // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); | 399 | // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); |
399 | // } | 400 | // } |
400 | 401 | ||
@@ -406,16 +407,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
406 | if (ShuttingDown) | 407 | if (ShuttingDown) |
407 | return; | 408 | return; |
408 | 409 | ||
409 | if (m_startedFromSavedState) | 410 | if (m_startedFromSavedState) |
410 | { | 411 | { |
411 | if (m_startOnInit) | 412 | if (m_startOnInit) |
412 | Start(); | 413 | Start(); |
413 | if (m_postOnRez) | 414 | if (m_postOnRez) |
414 | { | 415 | { |
415 | PostEvent(new EventParams("on_rez", | 416 | PostEvent(new EventParams("on_rez", |
416 | new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0])); | 417 | new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0])); |
417 | } | 418 | } |
418 | |||
419 | if (m_stateSource == StateSource.AttachedRez) | 419 | if (m_stateSource == StateSource.AttachedRez) |
420 | { | 420 | { |
421 | PostEvent(new EventParams("attach", | 421 | PostEvent(new EventParams("attach", |
@@ -439,13 +439,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
439 | new Object[] { new LSL_Types.LSLInteger((int)Changed.TELEPORT) }, new DetectParams[0])); | 439 | new Object[] { new LSL_Types.LSLInteger((int)Changed.TELEPORT) }, new DetectParams[0])); |
440 | } | 440 | } |
441 | } | 441 | } |
442 | else | 442 | else |
443 | { | 443 | { |
444 | if (m_startOnInit) | 444 | if (m_startOnInit) |
445 | Start(); | 445 | Start(); |
446 | PostEvent(new EventParams("state_entry", | 446 | PostEvent(new EventParams("state_entry", |
447 | new Object[0], new DetectParams[0])); | 447 | new Object[0], new DetectParams[0])); |
448 | if (m_postOnRez) | 448 | if (m_postOnRez) |
449 | { | 449 | { |
450 | PostEvent(new EventParams("on_rez", | 450 | PostEvent(new EventParams("on_rez", |
451 | new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0])); | 451 | new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0])); |
@@ -461,22 +461,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
461 | 461 | ||
462 | private void ReleaseControls() | 462 | private void ReleaseControls() |
463 | { | 463 | { |
464 | int permsMask; | 464 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
465 | UUID permsGranter; | 465 | |
466 | lock (Part.TaskInventory) | 466 | if (part != null) |
467 | { | 467 | { |
468 | if (!Part.TaskInventory.ContainsKey(ItemID)) | 468 | int permsMask; |
469 | UUID permsGranter; | ||
470 | part.TaskInventory.LockItemsForRead(true); | ||
471 | if (!part.TaskInventory.ContainsKey(ItemID)) | ||
472 | { | ||
473 | part.TaskInventory.LockItemsForRead(false); | ||
469 | return; | 474 | return; |
475 | } | ||
476 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
477 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
478 | part.TaskInventory.LockItemsForRead(false); | ||
470 | 479 | ||
471 | permsGranter = Part.TaskInventory[ItemID].PermsGranter; | 480 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
472 | permsMask = Part.TaskInventory[ItemID].PermsMask; | 481 | { |
473 | } | 482 | ScenePresence presence = Engine.World.GetScenePresence(permsGranter); |
474 | 483 | if (presence != null) | |
475 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 484 | presence.UnRegisterControlEventsToScript(LocalID, ItemID); |
476 | { | 485 | } |
477 | ScenePresence presence = Engine.World.GetScenePresence(permsGranter); | ||
478 | if (presence != null) | ||
479 | presence.UnRegisterControlEventsToScript(LocalID, ItemID); | ||
480 | } | 486 | } |
481 | } | 487 | } |
482 | 488 | ||
@@ -502,8 +508,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
502 | { | 508 | { |
503 | m_log.Warn( | 509 | m_log.Warn( |
504 | string.Format( | 510 | string.Format( |
505 | "[SCRIPT INSTANCE]: Could not delete script state {0} for script {1} (id {2}) in part {3} (id {4}) in object {5} in {6}. Exception ", | 511 | "[SCRIPT INSTANCE]: Could not delete script state {0} for script {1} (id {2}) in part {3} (id {4}) in object {5} in {6}. Exception ", |
506 | savedState, ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name), | 512 | savedState, ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name), |
507 | e); | 513 | e); |
508 | } | 514 | } |
509 | } | 515 | } |
@@ -625,7 +631,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
625 | if (!m_InSelfDelete) | 631 | if (!m_InSelfDelete) |
626 | { | 632 | { |
627 | m_log.DebugFormat( | 633 | m_log.DebugFormat( |
628 | "[SCRIPT INSTANCE]: Aborting unstopped script {0} {1} in prim {2}, localID {3}, timeout was {4} ms", | 634 | "[SCRIPT INSTANCE]: Aborting unstopped script {0} {1} in prim {2}, localID {3}, timeout was {4} ms", |
629 | ScriptName, ItemID, PrimName, LocalID, timeout); | 635 | ScriptName, ItemID, PrimName, LocalID, timeout); |
630 | 636 | ||
631 | workItem.Abort(); | 637 | workItem.Abort(); |
@@ -639,6 +645,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
639 | return true; | 645 | return true; |
640 | } | 646 | } |
641 | 647 | ||
648 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
642 | public void SetState(string state) | 649 | public void SetState(string state) |
643 | { | 650 | { |
644 | if (state == State) | 651 | if (state == State) |
@@ -702,7 +709,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
702 | lock (EventQueue) | 709 | lock (EventQueue) |
703 | { | 710 | { |
704 | // The only events that persist across state changes are timers | 711 | // The only events that persist across state changes are timers |
705 | if (m_StateChangeInProgress && data.EventName != "timer") | 712 | if (m_StateChangeInProgress && data.EventName != "timer") |
706 | return; | 713 | return; |
707 | 714 | ||
708 | if (EventQueue.Count >= m_MaxScriptQueue) | 715 | if (EventQueue.Count >= m_MaxScriptQueue) |
@@ -764,6 +771,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
764 | /// <returns></returns> | 771 | /// <returns></returns> |
765 | public object EventProcessor() | 772 | public object EventProcessor() |
766 | { | 773 | { |
774 | // EventParams data = null; | ||
767 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. | 775 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. |
768 | if (!Running) | 776 | if (!Running) |
769 | return 0; | 777 | return 0; |
@@ -776,7 +784,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
776 | return 0; | 784 | return 0; |
777 | 785 | ||
778 | ExecutionTimer.Restart(); | 786 | ExecutionTimer.Restart(); |
779 | 787 | ||
780 | try | 788 | try |
781 | { | 789 | { |
782 | return EventProcessorInt(); | 790 | return EventProcessorInt(); |
@@ -797,9 +805,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
797 | lock (EventQueue) | 805 | lock (EventQueue) |
798 | { | 806 | { |
799 | data = (EventParams)EventQueue.Dequeue(); | 807 | data = (EventParams)EventQueue.Dequeue(); |
800 | if (data == null) // Shouldn't happen | 808 | if (data == null) |
801 | { | 809 | { |
802 | if (EventQueue.Count > 0 && Running && !ShuttingDown) | 810 | // check if a null event was enqueued or if its really empty |
811 | if (EventQueue.Count > 0 && Running && !ShuttingDown && !m_InSelfDelete) | ||
803 | { | 812 | { |
804 | m_CurrentWorkItem = Engine.QueueEventHandler(this); | 813 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
805 | } | 814 | } |
@@ -850,7 +859,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
850 | Part.ParentGroup.UUID, | 859 | Part.ParentGroup.UUID, |
851 | Part.AbsolutePosition, | 860 | Part.AbsolutePosition, |
852 | Part.ParentGroup.Scene.Name); | 861 | Part.ParentGroup.Scene.Name); |
853 | |||
854 | AsyncCommandManager.StateChange(Engine, | 862 | AsyncCommandManager.StateChange(Engine, |
855 | LocalID, ItemID); | 863 | LocalID, ItemID); |
856 | // we are effectively in the new state now, so we can resume queueing | 864 | // we are effectively in the new state now, so we can resume queueing |
@@ -861,6 +869,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
861 | } | 869 | } |
862 | else | 870 | else |
863 | { | 871 | { |
872 | Exception e = null; | ||
873 | |||
864 | if (Engine.World.PipeEventsForScript(LocalID) || | 874 | if (Engine.World.PipeEventsForScript(LocalID) || |
865 | data.EventName == "control") // Don't freeze avies! | 875 | data.EventName == "control") // Don't freeze avies! |
866 | { | 876 | { |
@@ -870,7 +880,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
870 | try | 880 | try |
871 | { | 881 | { |
872 | m_CurrentEvent = data.EventName; | 882 | m_CurrentEvent = data.EventName; |
873 | m_EventStart = DateTime.Now; | 883 | m_EventStart = DateTime.UtcNow; |
874 | m_InEvent = true; | 884 | m_InEvent = true; |
875 | 885 | ||
876 | try | 886 | try |
@@ -881,6 +891,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
881 | { | 891 | { |
882 | m_InEvent = false; | 892 | m_InEvent = false; |
883 | m_CurrentEvent = String.Empty; | 893 | m_CurrentEvent = String.Empty; |
894 | lock (EventQueue) | ||
895 | m_CurrentWorkItem = null; // no longer in a event that can be canceled | ||
884 | } | 896 | } |
885 | 897 | ||
886 | if (m_SaveState) | 898 | if (m_SaveState) |
@@ -893,7 +905,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
893 | m_SaveState = false; | 905 | m_SaveState = false; |
894 | } | 906 | } |
895 | } | 907 | } |
896 | catch (Exception e) | 908 | catch (Exception exx) |
909 | { | ||
910 | e = exx; | ||
911 | } | ||
912 | |||
913 | if(e != null) | ||
897 | { | 914 | { |
898 | // m_log.DebugFormat( | 915 | // m_log.DebugFormat( |
899 | // "[SCRIPT] Exception in script {0} {1}: {2}{3}", | 916 | // "[SCRIPT] Exception in script {0} {1}: {2}{3}", |
@@ -907,39 +924,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
907 | { | 924 | { |
908 | try | 925 | try |
909 | { | 926 | { |
910 | // DISPLAY ERROR INWORLD | 927 | |
911 | string text = FormatException(e); | 928 | if(e.InnerException != null && e.InnerException is ScriptException) |
912 | 929 | { | |
913 | if (text.Length > 1000) | 930 | string text = e.InnerException.Message + |
914 | text = text.Substring(0, 1000); | 931 | "(script: " + ScriptName + |
915 | Engine.World.SimChat(Utils.StringToBytes(text), | 932 | " event: " + data.EventName + |
916 | ChatTypeEnum.DebugChannel, 2147483647, | 933 | " at " + Part.AbsolutePosition + ")"; |
917 | Part.AbsolutePosition, | 934 | if (text.Length > 1000) |
918 | Part.Name, Part.UUID, false); | 935 | text = text.Substring(0, 1000); |
919 | 936 | Engine.World.SimChat(Utils.StringToBytes(text), | |
920 | 937 | ChatTypeEnum.DebugChannel, 2147483647, | |
921 | m_log.Debug(string.Format( | 938 | Part.AbsolutePosition, |
922 | "[SCRIPT INSTANCE]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ", | 939 | Part.Name, Part.UUID, false); |
923 | ScriptName, | 940 | m_log.Debug(string.Format( |
924 | data.EventName, | 941 | "[SCRIPT INSTANCE]: {0} (at event {1}, part {2} {3} at {4} in {5}", |
925 | PrimName, | 942 | e.InnerException.Message, |
926 | Part.UUID, | 943 | data.EventName, |
927 | Part.AbsolutePosition, | 944 | PrimName, |
928 | Part.ParentGroup.Scene.Name), | 945 | Part.UUID, |
929 | e); | 946 | Part.AbsolutePosition, |
947 | Part.ParentGroup.Scene.Name)); | ||
948 | |||
949 | } | ||
950 | else | ||
951 | { | ||
952 | |||
953 | // DISPLAY ERROR INWORLD | ||
954 | string text = FormatException(e); | ||
955 | |||
956 | if (text.Length > 1000) | ||
957 | text = text.Substring(0, 1000); | ||
958 | Engine.World.SimChat(Utils.StringToBytes(text), | ||
959 | ChatTypeEnum.DebugChannel, 2147483647, | ||
960 | Part.AbsolutePosition, | ||
961 | Part.Name, Part.UUID, false); | ||
962 | |||
963 | |||
964 | m_log.Debug(string.Format( | ||
965 | "[SCRIPT INSTANCE]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ", | ||
966 | ScriptName, | ||
967 | data.EventName, | ||
968 | PrimName, | ||
969 | Part.UUID, | ||
970 | Part.AbsolutePosition, | ||
971 | Part.ParentGroup.Scene.Name), | ||
972 | e); | ||
973 | } | ||
930 | } | 974 | } |
931 | catch (Exception) | 975 | catch (Exception) |
932 | { | 976 | { |
933 | } | 977 | } |
934 | // catch (Exception e2) // LEGIT: User Scripting | ||
935 | // { | ||
936 | // m_log.Error("[SCRIPT]: "+ | ||
937 | // "Error displaying error in-world: " + | ||
938 | // e2.ToString()); | ||
939 | // m_log.Error("[SCRIPT]: " + | ||
940 | // "Errormessage: Error compiling script:\r\n" + | ||
941 | // e.ToString()); | ||
942 | // } | ||
943 | } | 978 | } |
944 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | 979 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) |
945 | { | 980 | { |
@@ -978,7 +1013,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
978 | ScriptTask.ItemID, ScriptTask.AssetID, data.EventName, EventsProcessed); | 1013 | ScriptTask.ItemID, ScriptTask.AssetID, data.EventName, EventsProcessed); |
979 | } | 1014 | } |
980 | 1015 | ||
981 | if (EventQueue.Count > 0 && Running && !ShuttingDown) | 1016 | if (EventQueue.Count > 0 && Running && !ShuttingDown && !m_InSelfDelete) |
982 | { | 1017 | { |
983 | m_CurrentWorkItem = Engine.QueueEventHandler(this); | 1018 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
984 | } | 1019 | } |
@@ -998,7 +1033,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
998 | if (!m_InEvent) | 1033 | if (!m_InEvent) |
999 | return 0; | 1034 | return 0; |
1000 | 1035 | ||
1001 | return (DateTime.Now - m_EventStart).Seconds; | 1036 | return (DateTime.UtcNow - m_EventStart).Seconds; |
1002 | } | 1037 | } |
1003 | 1038 | ||
1004 | public void ResetScript(int timeout) | 1039 | public void ResetScript(int timeout) |
@@ -1012,15 +1047,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1012 | ReleaseControls(); | 1047 | ReleaseControls(); |
1013 | 1048 | ||
1014 | Stop(timeout); | 1049 | Stop(timeout); |
1015 | Part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 1050 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
1016 | Part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 1051 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
1052 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | ||
1053 | part.CollisionSound = UUID.Zero; | ||
1017 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 1054 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
1055 | |||
1056 | m_TimerQueued = false; | ||
1057 | m_StateChangeInProgress = false; | ||
1018 | EventQueue.Clear(); | 1058 | EventQueue.Clear(); |
1059 | |||
1019 | m_Script.ResetVars(); | 1060 | m_Script.ResetVars(); |
1020 | StartParam = 0; | 1061 | StartParam = 0; |
1021 | State = "default"; | 1062 | State = "default"; |
1022 | 1063 | ||
1023 | Part.SetScriptEvents(ItemID, | 1064 | |
1065 | part.SetScriptEvents(ItemID, | ||
1024 | (int)m_Script.GetStateEventFlags(State)); | 1066 | (int)m_Script.GetStateEventFlags(State)); |
1025 | if (running) | 1067 | if (running) |
1026 | Start(); | 1068 | Start(); |
@@ -1031,6 +1073,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1031 | new Object[0], new DetectParams[0])); | 1073 | new Object[0], new DetectParams[0])); |
1032 | } | 1074 | } |
1033 | 1075 | ||
1076 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
1034 | public void ApiResetScript() | 1077 | public void ApiResetScript() |
1035 | { | 1078 | { |
1036 | // bool running = Running; | 1079 | // bool running = Running; |
@@ -1039,17 +1082,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1039 | ReleaseControls(); | 1082 | ReleaseControls(); |
1040 | 1083 | ||
1041 | m_Script.ResetVars(); | 1084 | m_Script.ResetVars(); |
1042 | Part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 1085 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
1043 | Part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 1086 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
1087 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | ||
1088 | part.CollisionSound = UUID.Zero; | ||
1044 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 1089 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
1045 | 1090 | ||
1091 | m_TimerQueued = false; | ||
1092 | m_StateChangeInProgress = false; | ||
1046 | EventQueue.Clear(); | 1093 | EventQueue.Clear(); |
1047 | m_Script.ResetVars(); | 1094 | m_Script.ResetVars(); |
1048 | string oldState = State; | 1095 | string oldState = State; |
1049 | StartParam = 0; | 1096 | StartParam = 0; |
1050 | State = "default"; | 1097 | State = "default"; |
1051 | 1098 | ||
1052 | Part.SetScriptEvents(ItemID, | 1099 | part.SetScriptEvents(ItemID, |
1053 | (int)m_Script.GetStateEventFlags(State)); | 1100 | (int)m_Script.GetStateEventFlags(State)); |
1054 | 1101 | ||
1055 | if (m_CurrentEvent != "state_entry" || oldState != "default") | 1102 | if (m_CurrentEvent != "state_entry" || oldState != "default") |
@@ -1170,7 +1217,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1170 | 1217 | ||
1171 | return null; | 1218 | return null; |
1172 | } | 1219 | } |
1173 | 1220 | ||
1174 | public override string ToString() | 1221 | public override string ToString() |
1175 | { | 1222 | { |
1176 | return String.Format("{0} {1} on {2}", ScriptName, ItemID, PrimName); | 1223 | return String.Format("{0} {1} on {2}", ScriptName, ItemID, PrimName); |