diff options
Diffstat (limited to 'OpenSim')
8 files changed, 95 insertions, 44 deletions
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs index 43c2487..ba7e653 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs | |||
@@ -36,28 +36,40 @@ using Amib.Threading; | |||
36 | 36 | ||
37 | namespace OpenSim.Region.ScriptEngine.Interfaces | 37 | namespace OpenSim.Region.ScriptEngine.Interfaces |
38 | { | 38 | { |
39 | /// <summary> | ||
40 | /// An interface for a script API module to communicate with | ||
41 | /// the engine it's running under | ||
42 | /// </summary> | ||
39 | public interface IScriptEngine | 43 | public interface IScriptEngine |
40 | { | 44 | { |
41 | // | ||
42 | // An interface for a script API module to communicate with | ||
43 | // the engine it's running under | ||
44 | // | ||
45 | |||
46 | Scene World { get; } | 45 | Scene World { get; } |
47 | IConfig Config { get; } | 46 | IConfig Config { get; } |
48 | Object AsyncCommands { get; } | 47 | Object AsyncCommands { get; } |
49 | ILog Log { get; } | 48 | ILog Log { get; } |
50 | string ScriptEngineName { get; } | 49 | string ScriptEngineName { get; } |
51 | 50 | ||
51 | /// <summary> | ||
52 | /// Post an event to a single script | ||
53 | /// </summary> | ||
52 | bool PostScriptEvent(UUID itemID, EventParams parms); | 54 | bool PostScriptEvent(UUID itemID, EventParams parms); |
55 | |||
56 | /// <summary> | ||
57 | /// Post event to an entire prim | ||
58 | /// </summary> | ||
53 | bool PostObjectEvent(uint localID, EventParams parms); | 59 | bool PostObjectEvent(uint localID, EventParams parms); |
60 | |||
54 | void ApiResetScript(UUID itemID); | 61 | void ApiResetScript(UUID itemID); |
55 | void ResetScript(UUID itemID); | 62 | void ResetScript(UUID itemID); |
56 | void SetScriptState(UUID itemID, bool state); | 63 | void SetScriptState(UUID itemID, bool state); |
57 | bool GetScriptState(UUID itemID); | 64 | bool GetScriptState(UUID itemID); |
58 | void SetState(UUID itemID, string newState); | 65 | void SetState(UUID itemID, string newState); |
59 | int GetStartParameter(UUID itemID); | 66 | int GetStartParameter(UUID itemID); |
67 | |||
68 | /// <summary> | ||
69 | /// Queue an event for execution | ||
70 | /// </summary> | ||
60 | IScriptWorkItem QueueEventHandler(object parms); | 71 | IScriptWorkItem QueueEventHandler(object parms); |
72 | |||
61 | IScriptApi GetApi(UUID itemID, string name); | 73 | IScriptApi GetApi(UUID itemID, string name); |
62 | 74 | ||
63 | DetectParams GetDetectParams(UUID item, int number); | 75 | DetectParams GetDetectParams(UUID item, int number); |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index 169955c..a05edbd 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | |||
@@ -50,6 +50,9 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
50 | bool Wait(TimeSpan t); | 50 | bool Wait(TimeSpan t); |
51 | } | 51 | } |
52 | 52 | ||
53 | /// <summary> | ||
54 | /// Interface for interaction with a particular script instance | ||
55 | /// </summary> | ||
53 | public interface IScriptInstance | 56 | public interface IScriptInstance |
54 | { | 57 | { |
55 | bool Running { get; set; } | 58 | bool Running { get; set; } |
@@ -75,6 +78,11 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
75 | void SetState(string state); | 78 | void SetState(string state); |
76 | 79 | ||
77 | void PostEvent(EventParams data); | 80 | void PostEvent(EventParams data); |
81 | |||
82 | /// <summary> | ||
83 | /// Process the next event queued for this script | ||
84 | /// </summary> | ||
85 | /// <returns></returns> | ||
78 | object EventProcessor(); | 86 | object EventProcessor(); |
79 | 87 | ||
80 | int EventTime(); | 88 | int EventTime(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 93a1a80..f331b5c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs | |||
@@ -149,6 +149,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | /// <summary> | ||
153 | /// Main loop for the manager thread | ||
154 | /// </summary> | ||
152 | private static void CmdHandlerThreadLoop() | 155 | private static void CmdHandlerThreadLoop() |
153 | { | 156 | { |
154 | while (true) | 157 | while (true) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a5ff42d..d6c33f6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -57,7 +57,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
57 | /// </summary> | 57 | /// </summary> |
58 | public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi | 58 | public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi |
59 | { | 59 | { |
60 | // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 60 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
61 | 61 | ||
62 | internal IScriptEngine m_ScriptEngine; | 62 | internal IScriptEngine m_ScriptEngine; |
63 | internal SceneObjectPart m_host; | 63 | internal SceneObjectPart m_host; |
@@ -7925,7 +7925,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7925 | } | 7925 | } |
7926 | 7926 | ||
7927 | public LSL_Types.LSLString llGetNotecardLine(string name, int line) | 7927 | public LSL_Types.LSLString llGetNotecardLine(string name, int line) |
7928 | { | 7928 | { |
7929 | m_host.AddScriptLPS(1); | 7929 | m_host.AddScriptLPS(1); |
7930 | 7930 | ||
7931 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 7931 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
@@ -7935,6 +7935,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7935 | UUID tid = AsyncCommands. | 7935 | UUID tid = AsyncCommands. |
7936 | DataserverPlugin.RegisterRequest(m_localID, | 7936 | DataserverPlugin.RegisterRequest(m_localID, |
7937 | m_itemID, item.AssetID.ToString()); | 7937 | m_itemID, item.AssetID.ToString()); |
7938 | |||
7938 | if (NotecardCache.IsCached(item.AssetID)) | 7939 | if (NotecardCache.IsCached(item.AssetID)) |
7939 | { | 7940 | { |
7940 | AsyncCommands. | 7941 | AsyncCommands. |
@@ -7943,6 +7944,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7943 | // ScriptSleep(100); | 7944 | // ScriptSleep(100); |
7944 | return tid.ToString(); | 7945 | return tid.ToString(); |
7945 | } | 7946 | } |
7947 | |||
7946 | WithNotecard(item.AssetID, delegate (UUID id, AssetBase a) | 7948 | WithNotecard(item.AssetID, delegate (UUID id, AssetBase a) |
7947 | { | 7949 | { |
7948 | System.Text.ASCIIEncoding enc = | 7950 | System.Text.ASCIIEncoding enc = |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs index 7300f10..9676cb3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs | |||
@@ -75,7 +75,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
75 | 75 | ||
76 | ds.startTime = DateTime.Now; | 76 | ds.startTime = DateTime.Now; |
77 | 77 | ||
78 | DataserverRequests[identifier]=ds; | 78 | DataserverRequests[identifier] = ds; |
79 | 79 | ||
80 | return ds.ID; | 80 | return ds.ID; |
81 | } | 81 | } |
@@ -90,7 +90,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
90 | if (!DataserverRequests.ContainsKey(identifier)) | 90 | if (!DataserverRequests.ContainsKey(identifier)) |
91 | return; | 91 | return; |
92 | 92 | ||
93 | ds=DataserverRequests[identifier]; | 93 | ds = DataserverRequests[identifier]; |
94 | DataserverRequests.Remove(identifier); | 94 | DataserverRequests.Remove(identifier); |
95 | } | 95 | } |
96 | 96 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index 8599e06..14266dd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs | |||
@@ -161,17 +161,20 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | /// <summary> | ||
165 | /// Holds all the data required to execute a scripting event. | ||
166 | /// </summary> | ||
164 | public class EventParams | 167 | public class EventParams |
165 | { | 168 | { |
166 | public EventParams(string eventName, Object[] eventParams, DetectParams[] detectParams) | 169 | public EventParams(string eventName, Object[] eventParams, DetectParams[] detectParams) |
167 | { | 170 | { |
168 | EventName=eventName; | 171 | EventName = eventName; |
169 | Params=eventParams; | 172 | Params = eventParams; |
170 | DetectParams=detectParams; | 173 | DetectParams = detectParams; |
171 | } | 174 | } |
172 | 175 | ||
173 | public string EventName; | 176 | public string EventName; |
174 | public Object[] Params; | 177 | public Object[] Params; |
175 | public DetectParams[] DetectParams; | 178 | public DetectParams[] DetectParams; |
176 | } | 179 | } |
177 | } | 180 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 8f6108d..da55858 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -35,7 +35,7 @@ using System.Reflection; | |||
35 | using System.Globalization; | 35 | using System.Globalization; |
36 | using System.Xml; | 36 | using System.Xml; |
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using log4net; | 38 | //using log4net; |
39 | using Nini.Config; | 39 | using Nini.Config; |
40 | using Amib.Threading; | 40 | using Amib.Threading; |
41 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
@@ -52,8 +52,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
52 | { | 52 | { |
53 | public class ScriptInstance : IScriptInstance | 53 | public class ScriptInstance : IScriptInstance |
54 | { | 54 | { |
55 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
56 | |||
55 | private IScriptEngine m_Engine; | 57 | private IScriptEngine m_Engine; |
56 | private IScriptWorkItem m_CurrentResult=null; | 58 | private IScriptWorkItem m_CurrentResult = null; |
57 | private Queue m_EventQueue = new Queue(32); | 59 | private Queue m_EventQueue = new Queue(32); |
58 | private bool m_RunEvents = false; | 60 | private bool m_RunEvents = false; |
59 | private UUID m_ItemID; | 61 | private UUID m_ItemID; |
@@ -455,6 +457,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
455 | } | 457 | } |
456 | } | 458 | } |
457 | 459 | ||
460 | /// <summary> | ||
461 | /// Process the next event queued for this script | ||
462 | /// </summary> | ||
463 | /// <returns></returns> | ||
458 | public object EventProcessor() | 464 | public object EventProcessor() |
459 | { | 465 | { |
460 | EventParams data = null; | 466 | EventParams data = null; |
@@ -470,6 +476,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
470 | if (data.EventName == "timer") | 476 | if (data.EventName == "timer") |
471 | m_TimerQueued = false; | 477 | m_TimerQueued = false; |
472 | } | 478 | } |
479 | |||
480 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | ||
473 | 481 | ||
474 | m_DetectParams = data.DetectParams; | 482 | m_DetectParams = data.DetectParams; |
475 | 483 | ||
@@ -721,5 +729,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
721 | return m_Apis[name]; | 729 | return m_Apis[name]; |
722 | return null; | 730 | return null; |
723 | } | 731 | } |
732 | |||
733 | public override string ToString() | ||
734 | { | ||
735 | return String.Format("{0} {1} on {2}", m_ScriptName, m_ItemID, m_PrimName); | ||
736 | } | ||
724 | } | 737 | } |
725 | } | 738 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 0dc1ade..f27a144 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -173,24 +173,24 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
173 | ThreadPriority prio = ThreadPriority.BelowNormal; | 173 | ThreadPriority prio = ThreadPriority.BelowNormal; |
174 | switch (priority) | 174 | switch (priority) |
175 | { | 175 | { |
176 | case "Lowest": | 176 | case "Lowest": |
177 | prio = ThreadPriority.Lowest; | 177 | prio = ThreadPriority.Lowest; |
178 | break; | 178 | break; |
179 | case "BelowNormal": | 179 | case "BelowNormal": |
180 | prio = ThreadPriority.BelowNormal; | 180 | prio = ThreadPriority.BelowNormal; |
181 | break; | 181 | break; |
182 | case "Normal": | 182 | case "Normal": |
183 | prio = ThreadPriority.Normal; | 183 | prio = ThreadPriority.Normal; |
184 | break; | 184 | break; |
185 | case "AboveNormal": | 185 | case "AboveNormal": |
186 | prio = ThreadPriority.AboveNormal; | 186 | prio = ThreadPriority.AboveNormal; |
187 | break; | 187 | break; |
188 | case "Highest": | 188 | case "Highest": |
189 | prio = ThreadPriority.Highest; | 189 | prio = ThreadPriority.Highest; |
190 | break; | 190 | break; |
191 | default: | 191 | default: |
192 | m_log.ErrorFormat("[XEngine] Invalid thread priority: '{0}'. Assuming BelowNormal", priority); | 192 | m_log.ErrorFormat("[XEngine] Invalid thread priority: '{0}'. Assuming BelowNormal", priority); |
193 | break; | 193 | break; |
194 | } | 194 | } |
195 | 195 | ||
196 | lock (m_ScriptEngines) | 196 | lock (m_ScriptEngines) |
@@ -659,24 +659,31 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
659 | return new XWorkItem(m_ThreadPool.QueueWorkItem( | 659 | return new XWorkItem(m_ThreadPool.QueueWorkItem( |
660 | new WorkItemCallback(this.ProcessEventHandler), | 660 | new WorkItemCallback(this.ProcessEventHandler), |
661 | parms)); | 661 | parms)); |
662 | } | 662 | } |
663 | 663 | ||
664 | // | 664 | /// <summary> |
665 | // The main script engine worker | 665 | /// Process a previously posted script event. |
666 | // | 666 | /// </summary> |
667 | /// <param name="parms"></param> | ||
668 | /// <returns></returns> | ||
667 | private object ProcessEventHandler(object parms) | 669 | private object ProcessEventHandler(object parms) |
668 | { | 670 | { |
669 | CultureInfo USCulture = new CultureInfo("en-US"); | 671 | CultureInfo USCulture = new CultureInfo("en-US"); |
670 | Thread.CurrentThread.CurrentCulture = USCulture; | 672 | Thread.CurrentThread.CurrentCulture = USCulture; |
671 | 673 | ||
672 | IScriptInstance instance = (ScriptInstance) parms; | 674 | IScriptInstance instance = (ScriptInstance) parms; |
675 | |||
676 | //m_log.DebugFormat("[XENGINE]: Processing event for {0}", instance); | ||
673 | 677 | ||
674 | return instance.EventProcessor(); | 678 | return instance.EventProcessor(); |
675 | } | 679 | } |
676 | 680 | ||
677 | // | 681 | /// <summary> |
678 | // Post event to an entire prim | 682 | /// Post event to an entire prim |
679 | // | 683 | /// </summary> |
684 | /// <param name="localID"></param> | ||
685 | /// <param name="p"></param> | ||
686 | /// <returns></returns> | ||
680 | public bool PostObjectEvent(uint localID, EventParams p) | 687 | public bool PostObjectEvent(uint localID, EventParams p) |
681 | { | 688 | { |
682 | bool result = false; | 689 | bool result = false; |
@@ -699,9 +706,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
699 | return result; | 706 | return result; |
700 | } | 707 | } |
701 | 708 | ||
702 | // | 709 | /// <summary> |
703 | // Post an event to a single script | 710 | /// Post an event to a single script |
704 | // | 711 | /// </summary> |
712 | /// <param name="itemID"></param> | ||
713 | /// <param name="p"></param> | ||
714 | /// <returns></returns> | ||
705 | public bool PostScriptEvent(UUID itemID, EventParams p) | 715 | public bool PostScriptEvent(UUID itemID, EventParams p) |
706 | { | 716 | { |
707 | if (m_Scripts.ContainsKey(itemID)) | 717 | if (m_Scripts.ContainsKey(itemID)) |