diff options
author | UbitUmarov | 2015-09-01 14:54:35 +0100 |
---|---|---|
committer | UbitUmarov | 2015-09-01 14:54:35 +0100 |
commit | 371c9dd2af01a2e7422ec901ee1f80757284a78c (patch) | |
tree | 058d2a513cacb12efcce0c0df0ae14ad135dbfe2 /OpenSim/Region/ScriptEngine/Shared/Instance | |
parent | remove lixo (diff) | |
parent | dont change camera on crossings (diff) | |
download | opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.zip opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.gz opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.bz2 opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.xz |
bad merge?
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 210 |
1 files changed, 179 insertions, 31 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index fa6e6fc..49df5e7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -30,6 +30,7 @@ using System.Collections; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Globalization; | 31 | using System.Globalization; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
33 | using System.Reflection; | 34 | using System.Reflection; |
34 | using System.Runtime.Remoting; | 35 | using System.Runtime.Remoting; |
35 | using System.Runtime.Remoting.Lifetime; | 36 | using System.Runtime.Remoting.Lifetime; |
@@ -186,13 +187,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
186 | 187 | ||
187 | public UUID ItemID { get; private set; } | 188 | public UUID ItemID { get; private set; } |
188 | 189 | ||
189 | public UUID ObjectID { get { return Part.UUID; } } | 190 | public UUID ObjectID { get; private set; } |
190 | 191 | ||
191 | public uint LocalID { get { return Part.LocalId; } } | 192 | public uint LocalID { get; private set; } |
192 | 193 | ||
193 | public UUID RootObjectID { get { return Part.ParentGroup.UUID; } } | 194 | public UUID RootObjectID { get; private set; } |
194 | 195 | ||
195 | public uint RootLocalID { get { return Part.ParentGroup.LocalId; } } | 196 | public uint RootLocalID { get; private set; } |
196 | 197 | ||
197 | public UUID AssetID { get; private set; } | 198 | public UUID AssetID { get; private set; } |
198 | 199 | ||
@@ -251,13 +252,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
251 | ItemID = ScriptTask.ItemID; | 252 | ItemID = ScriptTask.ItemID; |
252 | AssetID = ScriptTask.AssetID; | 253 | AssetID = ScriptTask.AssetID; |
253 | } | 254 | } |
255 | LocalID = part.LocalId; | ||
254 | 256 | ||
255 | PrimName = part.ParentGroup.Name; | 257 | PrimName = part.ParentGroup.Name; |
256 | StartParam = startParam; | 258 | StartParam = startParam; |
257 | m_MaxScriptQueue = maxScriptQueue; | 259 | m_MaxScriptQueue = maxScriptQueue; |
258 | m_postOnRez = postOnRez; | 260 | m_postOnRez = postOnRez; |
259 | m_AttachedAvatar = Part.ParentGroup.AttachedAvatar; | 261 | m_AttachedAvatar = part.ParentGroup.AttachedAvatar; |
260 | m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID; | 262 | m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; |
261 | 263 | ||
262 | m_SaveState = StatePersistedHere; | 264 | m_SaveState = StatePersistedHere; |
263 | 265 | ||
@@ -456,27 +458,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
456 | PostEvent(new EventParams("attach", | 458 | PostEvent(new EventParams("attach", |
457 | new object[] { new LSL_Types.LSLString(m_AttachedAvatar.ToString()) }, new DetectParams[0])); | 459 | new object[] { new LSL_Types.LSLString(m_AttachedAvatar.ToString()) }, new DetectParams[0])); |
458 | } | 460 | } |
461 | |||
459 | } | 462 | } |
460 | } | 463 | } |
461 | 464 | ||
462 | private void ReleaseControls() | 465 | private void ReleaseControls() |
463 | { | 466 | { |
464 | int permsMask; | 467 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
465 | UUID permsGranter; | 468 | |
466 | lock (Part.TaskInventory) | 469 | if (part != null) |
467 | { | 470 | { |
468 | if (!Part.TaskInventory.ContainsKey(ItemID)) | 471 | int permsMask; |
472 | UUID permsGranter; | ||
473 | part.TaskInventory.LockItemsForRead(true); | ||
474 | if (!part.TaskInventory.ContainsKey(ItemID)) | ||
475 | { | ||
476 | part.TaskInventory.LockItemsForRead(false); | ||
469 | return; | 477 | return; |
478 | } | ||
479 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
480 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
481 | part.TaskInventory.LockItemsForRead(false); | ||
470 | 482 | ||
471 | permsGranter = Part.TaskInventory[ItemID].PermsGranter; | 483 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
472 | permsMask = Part.TaskInventory[ItemID].PermsMask; | 484 | { |
473 | } | 485 | ScenePresence presence = Engine.World.GetScenePresence(permsGranter); |
474 | 486 | if (presence != null) | |
475 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 487 | presence.UnRegisterControlEventsToScript(LocalID, ItemID); |
476 | { | 488 | } |
477 | ScenePresence presence = Engine.World.GetScenePresence(permsGranter); | ||
478 | if (presence != null) | ||
479 | presence.UnRegisterControlEventsToScript(LocalID, ItemID); | ||
480 | } | 489 | } |
481 | } | 490 | } |
482 | 491 | ||
@@ -639,11 +648,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
639 | return true; | 648 | return true; |
640 | } | 649 | } |
641 | 650 | ||
651 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
642 | public void SetState(string state) | 652 | public void SetState(string state) |
643 | { | 653 | { |
644 | if (state == State) | 654 | if (state == State) |
645 | return; | 655 | return; |
646 | 656 | ||
657 | <<<<<<< HEAD | ||
647 | EventParams lastTimerEv = null; | 658 | EventParams lastTimerEv = null; |
648 | 659 | ||
649 | lock (EventQueue) | 660 | lock (EventQueue) |
@@ -671,6 +682,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
671 | m_StateChangeInProgress = true; | 682 | m_StateChangeInProgress = true; |
672 | } | 683 | } |
673 | 684 | ||
685 | ======= | ||
686 | PostEvent(new EventParams("state_exit", new Object[0], | ||
687 | new DetectParams[0])); | ||
688 | PostEvent(new EventParams("state", new Object[] { state }, | ||
689 | new DetectParams[0])); | ||
690 | PostEvent(new EventParams("state_entry", new Object[0], | ||
691 | new DetectParams[0])); | ||
692 | |||
693 | >>>>>>> avn/ubitvar | ||
674 | throw new EventAbortException(); | 694 | throw new EventAbortException(); |
675 | } | 695 | } |
676 | 696 | ||
@@ -764,14 +784,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
764 | /// <returns></returns> | 784 | /// <returns></returns> |
765 | public object EventProcessor() | 785 | public object EventProcessor() |
766 | { | 786 | { |
787 | EventParams data = null; | ||
767 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. | 788 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. |
768 | if (!Running) | 789 | if (!Running) |
769 | return 0; | 790 | return 0; |
770 | 791 | ||
771 | lock (m_Script) | ||
772 | { | ||
773 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); | 792 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); |
774 | 793 | ||
794 | <<<<<<< HEAD | ||
775 | if (Suspended) | 795 | if (Suspended) |
776 | return 0; | 796 | return 0; |
777 | 797 | ||
@@ -797,6 +817,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
797 | lock (EventQueue) | 817 | lock (EventQueue) |
798 | { | 818 | { |
799 | data = (EventParams)EventQueue.Dequeue(); | 819 | data = (EventParams)EventQueue.Dequeue(); |
820 | ======= | ||
821 | if (Suspended) | ||
822 | return 0; | ||
823 | |||
824 | lock (EventQueue) | ||
825 | { | ||
826 | data = (EventParams) EventQueue.Dequeue(); | ||
827 | >>>>>>> avn/ubitvar | ||
800 | if (data == null) // Shouldn't happen | 828 | if (data == null) // Shouldn't happen |
801 | { | 829 | { |
802 | if (EventQueue.Count > 0 && Running && !ShuttingDown) | 830 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
@@ -821,6 +849,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
821 | m_CollisionInQueue = false; | 849 | m_CollisionInQueue = false; |
822 | } | 850 | } |
823 | 851 | ||
852 | <<<<<<< HEAD | ||
824 | if (DebugLevel >= 2) | 853 | if (DebugLevel >= 2) |
825 | m_log.DebugFormat( | 854 | m_log.DebugFormat( |
826 | "[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", | 855 | "[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", |
@@ -850,6 +879,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
850 | Part.ParentGroup.UUID, | 879 | Part.ParentGroup.UUID, |
851 | Part.AbsolutePosition, | 880 | Part.AbsolutePosition, |
852 | Part.ParentGroup.Scene.Name); | 881 | Part.ParentGroup.Scene.Name); |
882 | ======= | ||
883 | lock(m_Script) | ||
884 | { | ||
885 | |||
886 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); | ||
887 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); | ||
888 | |||
889 | if (DebugLevel >= 2) | ||
890 | m_log.DebugFormat( | ||
891 | "[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", | ||
892 | data.EventName, | ||
893 | ScriptName, | ||
894 | part.Name, | ||
895 | part.LocalId, | ||
896 | part.ParentGroup.Name, | ||
897 | part.ParentGroup.UUID, | ||
898 | part.AbsolutePosition, | ||
899 | part.ParentGroup.Scene.Name); | ||
900 | >>>>>>> avn/ubitvar | ||
853 | 901 | ||
854 | AsyncCommandManager.StateChange(Engine, | 902 | AsyncCommandManager.StateChange(Engine, |
855 | LocalID, ItemID); | 903 | LocalID, ItemID); |
@@ -867,7 +915,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
867 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", | 915 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", |
868 | // PrimName, ScriptName, data.EventName, State); | 916 | // PrimName, ScriptName, data.EventName, State); |
869 | 917 | ||
918 | <<<<<<< HEAD | ||
870 | try | 919 | try |
920 | ======= | ||
921 | if (DebugLevel >= 1) | ||
922 | m_log.DebugFormat( | ||
923 | "[SCRIPT INSTANCE]: Changing state to {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", | ||
924 | State, | ||
925 | ScriptName, | ||
926 | part.Name, | ||
927 | part.LocalId, | ||
928 | part.ParentGroup.Name, | ||
929 | part.ParentGroup.UUID, | ||
930 | part.AbsolutePosition, | ||
931 | part.ParentGroup.Scene.Name); | ||
932 | |||
933 | AsyncCommandManager.RemoveScript(Engine, | ||
934 | LocalID, ItemID); | ||
935 | |||
936 | if (part != null) | ||
937 | { | ||
938 | part.SetScriptEvents(ItemID, | ||
939 | (int)m_Script.GetStateEventFlags(State)); | ||
940 | } | ||
941 | } | ||
942 | else | ||
943 | { | ||
944 | if (Engine.World.PipeEventsForScript(LocalID) || | ||
945 | data.EventName == "control") // Don't freeze avies! | ||
946 | >>>>>>> avn/ubitvar | ||
871 | { | 947 | { |
872 | m_CurrentEvent = data.EventName; | 948 | m_CurrentEvent = data.EventName; |
873 | m_EventStart = DateTime.Now; | 949 | m_EventStart = DateTime.Now; |
@@ -905,6 +981,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
905 | && !(e.InnerException is ScriptCoopStopException))) | 981 | && !(e.InnerException is ScriptCoopStopException))) |
906 | && !(e is ThreadAbortException)) | 982 | && !(e is ThreadAbortException)) |
907 | { | 983 | { |
984 | <<<<<<< HEAD | ||
908 | try | 985 | try |
909 | { | 986 | { |
910 | // DISPLAY ERROR INWORLD | 987 | // DISPLAY ERROR INWORLD |
@@ -927,9 +1004,78 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
927 | Part.AbsolutePosition, | 1004 | Part.AbsolutePosition, |
928 | Part.ParentGroup.Scene.Name), | 1005 | Part.ParentGroup.Scene.Name), |
929 | e); | 1006 | e); |
1007 | ======= | ||
1008 | // m_log.DebugFormat( | ||
1009 | // "[SCRIPT] Exception in script {0} {1}: {2}{3}", | ||
1010 | // ScriptName, ItemID, e.Message, e.StackTrace); | ||
1011 | |||
1012 | m_InEvent = false; | ||
1013 | m_CurrentEvent = String.Empty; | ||
1014 | |||
1015 | if ((!(e is TargetInvocationException) | ||
1016 | || (!(e.InnerException is SelfDeleteException) | ||
1017 | && !(e.InnerException is ScriptDeleteException) | ||
1018 | && !(e.InnerException is ScriptCoopStopException))) | ||
1019 | && !(e is ThreadAbortException)) | ||
1020 | { | ||
1021 | try | ||
1022 | { | ||
1023 | // DISPLAY ERROR INWORLD | ||
1024 | string text = FormatException(e); | ||
1025 | |||
1026 | if (text.Length > 1000) | ||
1027 | text = text.Substring(0, 1000); | ||
1028 | Engine.World.SimChat(Utils.StringToBytes(text), | ||
1029 | ChatTypeEnum.DebugChannel, 2147483647, | ||
1030 | part.AbsolutePosition, | ||
1031 | part.Name, part.UUID, false); | ||
1032 | |||
1033 | |||
1034 | m_log.DebugFormat( | ||
1035 | "[SCRIPT INSTANCE]: Runtime error in script {0}, part {1} {2} at {3} in {4}, displayed error {5}, actual exception {6}", | ||
1036 | ScriptName, | ||
1037 | PrimName, | ||
1038 | part.UUID, | ||
1039 | part.AbsolutePosition, | ||
1040 | part.ParentGroup.Scene.Name, | ||
1041 | text.Replace("\n", "\\n"), | ||
1042 | e.InnerException); | ||
1043 | } | ||
1044 | catch (Exception) | ||
1045 | { | ||
1046 | } | ||
1047 | // catch (Exception e2) // LEGIT: User Scripting | ||
1048 | // { | ||
1049 | // m_log.Error("[SCRIPT]: "+ | ||
1050 | // "Error displaying error in-world: " + | ||
1051 | // e2.ToString()); | ||
1052 | // m_log.Error("[SCRIPT]: " + | ||
1053 | // "Errormessage: Error compiling script:\r\n" + | ||
1054 | // e.ToString()); | ||
1055 | // } | ||
1056 | } | ||
1057 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | ||
1058 | { | ||
1059 | m_InSelfDelete = true; | ||
1060 | if (part != null) | ||
1061 | Engine.World.DeleteSceneObject(part.ParentGroup, false); | ||
1062 | >>>>>>> avn/ubitvar | ||
930 | } | 1063 | } |
931 | catch (Exception) | 1064 | catch (Exception) |
932 | { | 1065 | { |
1066 | <<<<<<< HEAD | ||
1067 | ======= | ||
1068 | m_InSelfDelete = true; | ||
1069 | if (part != null) | ||
1070 | part.Inventory.RemoveInventoryItem(ItemID); | ||
1071 | } | ||
1072 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptCoopStopException)) | ||
1073 | { | ||
1074 | if (DebugLevel >= 1) | ||
1075 | m_log.DebugFormat( | ||
1076 | "[SCRIPT INSTANCE]: Script {0}.{1} in event {2}, state {3} stopped co-operatively.", | ||
1077 | PrimName, ScriptName, data.EventName, State); | ||
1078 | >>>>>>> avn/ubitvar | ||
933 | } | 1079 | } |
934 | // catch (Exception e2) // LEGIT: User Scripting | 1080 | // catch (Exception e2) // LEGIT: User Scripting |
935 | // { | 1081 | // { |
@@ -1012,15 +1158,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1012 | ReleaseControls(); | 1158 | ReleaseControls(); |
1013 | 1159 | ||
1014 | Stop(timeout); | 1160 | Stop(timeout); |
1015 | Part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 1161 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
1016 | Part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 1162 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
1163 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | ||
1164 | part.CollisionSound = UUID.Zero; | ||
1017 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 1165 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
1018 | EventQueue.Clear(); | 1166 | EventQueue.Clear(); |
1019 | m_Script.ResetVars(); | 1167 | m_Script.ResetVars(); |
1020 | StartParam = 0; | 1168 | StartParam = 0; |
1021 | State = "default"; | 1169 | State = "default"; |
1022 | 1170 | ||
1023 | Part.SetScriptEvents(ItemID, | 1171 | part.SetScriptEvents(ItemID, |
1024 | (int)m_Script.GetStateEventFlags(State)); | 1172 | (int)m_Script.GetStateEventFlags(State)); |
1025 | if (running) | 1173 | if (running) |
1026 | Start(); | 1174 | Start(); |
@@ -1031,6 +1179,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1031 | new Object[0], new DetectParams[0])); | 1179 | new Object[0], new DetectParams[0])); |
1032 | } | 1180 | } |
1033 | 1181 | ||
1182 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
1034 | public void ApiResetScript() | 1183 | public void ApiResetScript() |
1035 | { | 1184 | { |
1036 | // bool running = Running; | 1185 | // bool running = Running; |
@@ -1039,8 +1188,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1039 | ReleaseControls(); | 1188 | ReleaseControls(); |
1040 | 1189 | ||
1041 | m_Script.ResetVars(); | 1190 | m_Script.ResetVars(); |
1042 | Part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 1191 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
1043 | Part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 1192 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
1193 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | ||
1194 | part.CollisionSound = UUID.Zero; | ||
1044 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 1195 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
1045 | 1196 | ||
1046 | EventQueue.Clear(); | 1197 | EventQueue.Clear(); |
@@ -1049,7 +1200,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1049 | StartParam = 0; | 1200 | StartParam = 0; |
1050 | State = "default"; | 1201 | State = "default"; |
1051 | 1202 | ||
1052 | Part.SetScriptEvents(ItemID, | 1203 | part.SetScriptEvents(ItemID, |
1053 | (int)m_Script.GetStateEventFlags(State)); | 1204 | (int)m_Script.GetStateEventFlags(State)); |
1054 | 1205 | ||
1055 | if (m_CurrentEvent != "state_entry" || oldState != "default") | 1206 | if (m_CurrentEvent != "state_entry" || oldState != "default") |
@@ -1063,10 +1214,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1063 | 1214 | ||
1064 | public Dictionary<string, object> GetVars() | 1215 | public Dictionary<string, object> GetVars() |
1065 | { | 1216 | { |
1066 | if (m_Script != null) | 1217 | return m_Script.GetVars(); |
1067 | return m_Script.GetVars(); | ||
1068 | else | ||
1069 | return new Dictionary<string, object>(); | ||
1070 | } | 1218 | } |
1071 | 1219 | ||
1072 | public void SetVars(Dictionary<string, object> vars) | 1220 | public void SetVars(Dictionary<string, object> vars) |