diff options
author | onefang | 2019-05-19 21:24:15 +1000 |
---|---|---|
committer | onefang | 2019-05-19 21:24:15 +1000 |
commit | 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch) | |
tree | a9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Region/ScriptEngine/Shared/Instance | |
parent | Add a build script. (diff) | |
download | opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2 opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz |
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance')
4 files changed, 170 insertions, 122 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs index b7c4bab..411d49c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs | |||
@@ -2,7 +2,7 @@ | |||
2 | using System.Runtime.CompilerServices; | 2 | using System.Runtime.CompilerServices; |
3 | using System.Runtime.InteropServices; | 3 | using System.Runtime.InteropServices; |
4 | 4 | ||
5 | // General Information about an assembly is controlled through the following | 5 | // General Information about an assembly is controlled through the following |
6 | // set of attributes. Change these attribute values to modify the information | 6 | // set of attributes. Change these attribute values to modify the information |
7 | // associated with an assembly. | 7 | // associated with an assembly. |
8 | [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared.Instance")] | 8 | [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared.Instance")] |
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices; | |||
14 | [assembly: AssemblyTrademark("")] | 14 | [assembly: AssemblyTrademark("")] |
15 | [assembly: AssemblyCulture("")] | 15 | [assembly: AssemblyCulture("")] |
16 | 16 | ||
17 | // Setting ComVisible to false makes the types in this assembly not visible | 17 | // Setting ComVisible to false makes the types in this assembly not visible |
18 | // to COM components. If you need to access a type in this assembly from | 18 | // to COM components. If you need to access a type in this assembly from |
19 | // COM, set the ComVisible attribute to true on that type. | 19 | // COM, set the ComVisible attribute to true on that type. |
20 | [assembly: ComVisible(false)] | 20 | [assembly: ComVisible(false)] |
21 | 21 | ||
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices; | |||
25 | // Version information for an assembly consists of the following four values: | 25 | // Version information for an assembly consists of the following four values: |
26 | // | 26 | // |
27 | // Major Version | 27 | // Major Version |
28 | // Minor Version | 28 | // Minor Version |
29 | // Build Number | 29 | // Build Number |
30 | // Revision | 30 | // Revision |
31 | // | 31 | // |
32 | [assembly: AssemblyVersion("0.8.3.*")] | 32 | [assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] |
33 | 33 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index fa6e6fc..9d72b1c 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); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs index bcdc7bf..cfe21fc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs | |||
@@ -207,6 +207,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
207 | public static void Deserialize(string xml, ScriptInstance instance) | 207 | public static void Deserialize(string xml, ScriptInstance instance) |
208 | { | 208 | { |
209 | XmlDocument doc = new XmlDocument(); | 209 | XmlDocument doc = new XmlDocument(); |
210 | doc.XmlResolver=null; | ||
210 | 211 | ||
211 | Dictionary<string, object> vars = instance.GetVars(); | 212 | Dictionary<string, object> vars = instance.GetVars(); |
212 | 213 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs index 5b9794b..8138117 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs | |||
@@ -79,7 +79,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
79 | m_xEngine.DebugLevel = 1; | 79 | m_xEngine.DebugLevel = 1; |
80 | 80 | ||
81 | IniConfigSource configSource = new IniConfigSource(); | 81 | IniConfigSource configSource = new IniConfigSource(); |
82 | 82 | ||
83 | IConfig startupConfig = configSource.AddConfig("Startup"); | 83 | IConfig startupConfig = configSource.AddConfig("Startup"); |
84 | startupConfig.Set("DefaultScriptEngine", "XEngine"); | 84 | startupConfig.Set("DefaultScriptEngine", "XEngine"); |
85 | 85 | ||
@@ -124,9 +124,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
124 | TestHelpers.InMethod(); | 124 | TestHelpers.InMethod(); |
125 | // TestHelpers.EnableLogging(); | 125 | // TestHelpers.EnableLogging(); |
126 | 126 | ||
127 | string script = | 127 | string script = |
128 | @"default | 128 | @"default |
129 | { | 129 | { |
130 | state_entry() | 130 | state_entry() |
131 | { | 131 | { |
132 | llSay(0, ""Thin Lizzy""); | 132 | llSay(0, ""Thin Lizzy""); |
@@ -143,12 +143,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
143 | TestHelpers.InMethod(); | 143 | TestHelpers.InMethod(); |
144 | // TestHelpers.EnableLogging(); | 144 | // TestHelpers.EnableLogging(); |
145 | 145 | ||
146 | string script = | 146 | string script = |
147 | @"default | 147 | @"default |
148 | { | 148 | { |
149 | state_entry() | 149 | state_entry() |
150 | { | 150 | { |
151 | integer i = 0; | 151 | integer i = 0; |
152 | for (i = 0; i <= 1; i++) llSay(0, ""Iter "" + (string)i); | 152 | for (i = 0; i <= 1; i++) llSay(0, ""Iter "" + (string)i); |
153 | } | 153 | } |
154 | }"; | 154 | }"; |
@@ -162,14 +162,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
162 | TestHelpers.InMethod(); | 162 | TestHelpers.InMethod(); |
163 | // TestHelpers.EnableLogging(); | 163 | // TestHelpers.EnableLogging(); |
164 | 164 | ||
165 | string script = | 165 | string script = |
166 | @"default | 166 | @"default |
167 | { | 167 | { |
168 | state_entry() | 168 | state_entry() |
169 | { | 169 | { |
170 | integer i = 0; | 170 | integer i = 0; |
171 | llSay(0, ""Thin Lizzy""); | 171 | llSay(0, ""Thin Lizzy""); |
172 | 172 | ||
173 | for (i = 0; i < 2147483647; i++) llSay(0, ""Iter "" + (string)i); | 173 | for (i = 0; i < 2147483647; i++) llSay(0, ""Iter "" + (string)i); |
174 | } | 174 | } |
175 | }"; | 175 | }"; |
@@ -183,15 +183,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
183 | TestHelpers.InMethod(); | 183 | TestHelpers.InMethod(); |
184 | // TestHelpers.EnableLogging(); | 184 | // TestHelpers.EnableLogging(); |
185 | 185 | ||
186 | string script = | 186 | string script = |
187 | @"default | 187 | @"default |
188 | { | 188 | { |
189 | state_entry() | 189 | state_entry() |
190 | { | 190 | { |
191 | integer i = 0; | 191 | integer i = 0; |
192 | llSay(0, ""Thin Lizzy""); | 192 | llSay(0, ""Thin Lizzy""); |
193 | 193 | ||
194 | for (i = 0; i < 2147483647; i++) | 194 | for (i = 0; i < 2147483647; i++) |
195 | { | 195 | { |
196 | llSay(0, ""Iter "" + (string)i); | 196 | llSay(0, ""Iter "" + (string)i); |
197 | } | 197 | } |
@@ -207,12 +207,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
207 | TestHelpers.InMethod(); | 207 | TestHelpers.InMethod(); |
208 | // TestHelpers.EnableLogging(); | 208 | // TestHelpers.EnableLogging(); |
209 | 209 | ||
210 | string script = | 210 | string script = |
211 | @"default | 211 | @"default |
212 | { | 212 | { |
213 | state_entry() | 213 | state_entry() |
214 | { | 214 | { |
215 | integer i = 0; | 215 | integer i = 0; |
216 | while (i < 2) llSay(0, ""Iter "" + (string)i++); | 216 | while (i < 2) llSay(0, ""Iter "" + (string)i++); |
217 | } | 217 | } |
218 | }"; | 218 | }"; |
@@ -226,15 +226,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
226 | TestHelpers.InMethod(); | 226 | TestHelpers.InMethod(); |
227 | // TestHelpers.EnableLogging(); | 227 | // TestHelpers.EnableLogging(); |
228 | 228 | ||
229 | string script = | 229 | string script = |
230 | @"default | 230 | @"default |
231 | { | 231 | { |
232 | state_entry() | 232 | state_entry() |
233 | { | 233 | { |
234 | integer i = 0; | 234 | integer i = 0; |
235 | llSay(0, ""Thin Lizzy""); | 235 | llSay(0, ""Thin Lizzy""); |
236 | 236 | ||
237 | while (1 == 1) | 237 | while (1 == 1) |
238 | llSay(0, ""Iter "" + (string)i++); | 238 | llSay(0, ""Iter "" + (string)i++); |
239 | } | 239 | } |
240 | }"; | 240 | }"; |
@@ -248,15 +248,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
248 | TestHelpers.InMethod(); | 248 | TestHelpers.InMethod(); |
249 | // TestHelpers.EnableLogging(); | 249 | // TestHelpers.EnableLogging(); |
250 | 250 | ||
251 | string script = | 251 | string script = |
252 | @"default | 252 | @"default |
253 | { | 253 | { |
254 | state_entry() | 254 | state_entry() |
255 | { | 255 | { |
256 | integer i = 0; | 256 | integer i = 0; |
257 | llSay(0, ""Thin Lizzy""); | 257 | llSay(0, ""Thin Lizzy""); |
258 | 258 | ||
259 | while (1 == 1) | 259 | while (1 == 1) |
260 | { | 260 | { |
261 | llSay(0, ""Iter "" + (string)i++); | 261 | llSay(0, ""Iter "" + (string)i++); |
262 | } | 262 | } |
@@ -272,9 +272,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
272 | TestHelpers.InMethod(); | 272 | TestHelpers.InMethod(); |
273 | // TestHelpers.EnableLogging(); | 273 | // TestHelpers.EnableLogging(); |
274 | 274 | ||
275 | string script = | 275 | string script = |
276 | @"default | 276 | @"default |
277 | { | 277 | { |
278 | state_entry() | 278 | state_entry() |
279 | { | 279 | { |
280 | integer i = 0; | 280 | integer i = 0; |
@@ -293,9 +293,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
293 | TestHelpers.InMethod(); | 293 | TestHelpers.InMethod(); |
294 | // TestHelpers.EnableLogging(); | 294 | // TestHelpers.EnableLogging(); |
295 | 295 | ||
296 | string script = | 296 | string script = |
297 | @"default | 297 | @"default |
298 | { | 298 | { |
299 | state_entry() | 299 | state_entry() |
300 | { | 300 | { |
301 | integer i = 0; | 301 | integer i = 0; |
@@ -315,15 +315,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
315 | TestHelpers.InMethod(); | 315 | TestHelpers.InMethod(); |
316 | // TestHelpers.EnableLogging(); | 316 | // TestHelpers.EnableLogging(); |
317 | 317 | ||
318 | string script = | 318 | string script = |
319 | @"default | 319 | @"default |
320 | { | 320 | { |
321 | state_entry() | 321 | state_entry() |
322 | { | 322 | { |
323 | integer i = 0; | 323 | integer i = 0; |
324 | llSay(0, ""Thin Lizzy""); | 324 | llSay(0, ""Thin Lizzy""); |
325 | 325 | ||
326 | do | 326 | do |
327 | { | 327 | { |
328 | llSay(0, ""Iter "" + (string)i++); | 328 | llSay(0, ""Iter "" + (string)i++); |
329 | } while (1 == 1); | 329 | } while (1 == 1); |
@@ -339,15 +339,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
339 | TestHelpers.InMethod(); | 339 | TestHelpers.InMethod(); |
340 | TestHelpers.EnableLogging(); | 340 | TestHelpers.EnableLogging(); |
341 | 341 | ||
342 | string script = | 342 | string script = |
343 | @"default | 343 | @"default |
344 | { | 344 | { |
345 | state_entry() | 345 | state_entry() |
346 | { | 346 | { |
347 | integer i = 0; | 347 | integer i = 0; |
348 | llSay(0, ""Thin Lizzy""); | 348 | llSay(0, ""Thin Lizzy""); |
349 | 349 | ||
350 | @p1; | 350 | @p1; |
351 | llSay(0, ""Iter "" + (string)i++); | 351 | llSay(0, ""Iter "" + (string)i++); |
352 | jump p1; | 352 | jump p1; |
353 | } | 353 | } |
@@ -364,7 +364,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
364 | TestHelpers.InMethod(); | 364 | TestHelpers.InMethod(); |
365 | // TestHelpers.EnableLogging(); | 365 | // TestHelpers.EnableLogging(); |
366 | 366 | ||
367 | string script = | 367 | string script = |
368 | @" | 368 | @" |
369 | integer i = 0; | 369 | integer i = 0; |
370 | 370 | ||
@@ -375,7 +375,7 @@ ufn1() | |||
375 | } | 375 | } |
376 | 376 | ||
377 | default | 377 | default |
378 | { | 378 | { |
379 | state_entry() | 379 | state_entry() |
380 | { | 380 | { |
381 | integer i = 0; | 381 | integer i = 0; |
@@ -396,9 +396,9 @@ default | |||
396 | TestHelpers.InMethod(); | 396 | TestHelpers.InMethod(); |
397 | // TestHelpers.EnableLogging(); | 397 | // TestHelpers.EnableLogging(); |
398 | 398 | ||
399 | string script = | 399 | string script = |
400 | @"default | 400 | @"default |
401 | { | 401 | { |
402 | state_entry() | 402 | state_entry() |
403 | { | 403 | { |
404 | integer i = 0; | 404 | integer i = 0; |
@@ -417,7 +417,7 @@ default | |||
417 | // UUID objectId = TestHelpers.ParseTail(0x100); | 417 | // UUID objectId = TestHelpers.ParseTail(0x100); |
418 | // UUID itemId = TestHelpers.ParseTail(0x3); | 418 | // UUID itemId = TestHelpers.ParseTail(0x3); |
419 | 419 | ||
420 | SceneObjectGroup so | 420 | SceneObjectGroup so |
421 | = SceneHelpers.CreateSceneObject(1, userId, string.Format("Object for {0}", itemName), 0x100); | 421 | = SceneHelpers.CreateSceneObject(1, userId, string.Format("Object for {0}", itemName), 0x100); |
422 | m_scene.AddNewSceneObject(so, true); | 422 | m_scene.AddNewSceneObject(so, true); |
423 | 423 | ||
@@ -505,7 +505,7 @@ default | |||
505 | 505 | ||
506 | if (++m_chatMessagesReceived >= m_chatMessagesThreshold) | 506 | if (++m_chatMessagesReceived >= m_chatMessagesThreshold) |
507 | { | 507 | { |
508 | m_scene.EventManager.OnChatFromWorld -= OnChatFromWorld; | 508 | m_scene.EventManager.OnChatFromWorld -= OnChatFromWorld; |
509 | m_chatEvent.Set(); | 509 | m_chatEvent.Set(); |
510 | } | 510 | } |
511 | } | 511 | } |