diff options
author | Charles Krinke | 2008-06-28 16:08:12 +0000 |
---|---|---|
committer | Charles Krinke | 2008-06-28 16:08:12 +0000 |
commit | 9a0ef22ed979433f4d017a252173f38fe5e56892 (patch) | |
tree | 98bd25e3a49a38922b37728df4de9e0fa5b7366a /OpenSim/Region/ScriptEngine | |
parent | plumbing for multiple inventory servers. Mostly done on the region server side. (diff) | |
download | opensim-SC_OLD-9a0ef22ed979433f4d017a252173f38fe5e56892.zip opensim-SC_OLD-9a0ef22ed979433f4d017a252173f38fe5e56892.tar.gz opensim-SC_OLD-9a0ef22ed979433f4d017a252173f38fe5e56892.tar.bz2 opensim-SC_OLD-9a0ef22ed979433f4d017a252173f38fe5e56892.tar.xz |
Mantis#1616. Applied Melanie's patch. This may or may
not break trunk.
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
8 files changed, 165 insertions, 33 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 6f4943d..c240573 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |||
@@ -2344,8 +2344,8 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
2344 | public LSL_Types.LSLInteger llGetStartParameter() | 2344 | public LSL_Types.LSLInteger llGetStartParameter() |
2345 | { | 2345 | { |
2346 | m_host.AddScriptLPS(1); | 2346 | m_host.AddScriptLPS(1); |
2347 | // NotImplemented("llGetStartParameter"); | 2347 | NotImplemented("llGetStartParameter"); |
2348 | return m_host.ParentGroup.StartParameter; | 2348 | return 0; |
2349 | } | 2349 | } |
2350 | 2350 | ||
2351 | public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) | 2351 | public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) |
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs index 5a3ebc7..93b68d4 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs | |||
@@ -186,7 +186,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
186 | myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { new LSL_Types.LSLInteger(1) }); | 186 | myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { new LSL_Types.LSLInteger(1) }); |
187 | } | 187 | } |
188 | 188 | ||
189 | public void OnRezScript(uint localID, LLUUID itemID, string script) | 189 | public void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez) |
190 | { | 190 | { |
191 | Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + | 191 | Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + |
192 | script.Length); | 192 | script.Length); |
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs index 59f828d..f04ac01 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs | |||
@@ -39,7 +39,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
39 | public interface RemoteEvents | 39 | public interface RemoteEvents |
40 | { | 40 | { |
41 | void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient); | 41 | void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient); |
42 | void OnRezScript(uint localID, LLUUID itemID, string script); | 42 | void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez); |
43 | void OnRemoveScript(uint localID, LLUUID itemID); | 43 | void OnRemoveScript(uint localID, LLUUID itemID); |
44 | void state_exit(uint localID); | 44 | void state_exit(uint localID); |
45 | void touch(uint localID, LLUUID itemID); | 45 | void touch(uint localID, LLUUID itemID); |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs index 2fa67a4..579af31 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs | |||
@@ -53,6 +53,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
53 | void SetScriptState(LLUUID itemID, bool state); | 53 | void SetScriptState(LLUUID itemID, bool state); |
54 | bool GetScriptState(LLUUID itemID); | 54 | bool GetScriptState(LLUUID itemID); |
55 | void SetState(LLUUID itemID, string newState); | 55 | void SetState(LLUUID itemID, string newState); |
56 | int GetStartParameter(LLUUID itemID); | ||
56 | 57 | ||
57 | DetectParams GetDetectParams(LLUUID item, int number); | 58 | DetectParams GetDetectParams(LLUUID item, int number); |
58 | } | 59 | } |
diff --git a/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs b/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs index 54a6643..6924dd2 100644 --- a/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs | |||
@@ -77,7 +77,7 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer | |||
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | public void OnRezScript(uint localID, LLUUID itemID, string script) | 80 | public void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez) |
81 | { | 81 | { |
82 | // WE ARE CREATING A NEW SCRIPT ... CREATE SCRIPT, GET A REMOTEID THAT WE MAP FROM LOCALID | 82 | // WE ARE CREATING A NEW SCRIPT ... CREATE SCRIPT, GET A REMOTEID THAT WE MAP FROM LOCALID |
83 | myScriptEngine.Log.Info("[RemoteEngine]: Creating new script (with connection)"); | 83 | myScriptEngine.Log.Info("[RemoteEngine]: Creating new script (with connection)"); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index afdd898..0320857 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -2200,8 +2200,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2200 | public LSL_Types.LSLInteger llGetStartParameter() | 2200 | public LSL_Types.LSLInteger llGetStartParameter() |
2201 | { | 2201 | { |
2202 | m_host.AddScriptLPS(1); | 2202 | m_host.AddScriptLPS(1); |
2203 | // NotImplemented("llGetStartParameter"); | 2203 | return m_ScriptEngine.GetStartParameter(m_itemID); |
2204 | return m_host.ParentGroup.StartParameter; | ||
2205 | } | 2204 | } |
2206 | 2205 | ||
2207 | public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) | 2206 | public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs index 8bfef79..3fd4942 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | |||
@@ -53,7 +53,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
53 | myScriptEngine.Log.Info("[XEngine] Hooking up to server events"); | 53 | myScriptEngine.Log.Info("[XEngine] Hooking up to server events"); |
54 | myScriptEngine.World.EventManager.OnObjectGrab += touch_start; | 54 | myScriptEngine.World.EventManager.OnObjectGrab += touch_start; |
55 | myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end; | 55 | myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end; |
56 | myScriptEngine.World.EventManager.OnRezEvent += on_rez; | ||
57 | myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; | 56 | myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; |
58 | myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target; | 57 | myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target; |
59 | myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target; | 58 | myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target; |
@@ -254,14 +253,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
254 | // timer: not handled here | 253 | // timer: not handled here |
255 | // listen: not handled here | 254 | // listen: not handled here |
256 | 255 | ||
257 | public void on_rez(uint localID, LLUUID itemID, int startParam) | ||
258 | { | ||
259 | myScriptEngine.PostObjectEvent(localID, new EventParams( | ||
260 | "on_rez",new object[] { | ||
261 | new LSL_Types.LSLInteger(startParam)}, | ||
262 | new DetectParams[0])); | ||
263 | } | ||
264 | |||
265 | public void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change) | 256 | public void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change) |
266 | { | 257 | { |
267 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 258 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index f025090..4c9ffd0 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -49,7 +49,7 @@ using OpenSim.Region.ScriptEngine.Interfaces; | |||
49 | 49 | ||
50 | namespace OpenSim.Region.ScriptEngine.XEngine | 50 | namespace OpenSim.Region.ScriptEngine.XEngine |
51 | { | 51 | { |
52 | public class XEngine : IRegionModule, IScriptEngine | 52 | public class XEngine : IScriptModule, IScriptEngine |
53 | { | 53 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 55 | ||
@@ -64,6 +64,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
64 | private int m_EventLimit; | 64 | private int m_EventLimit; |
65 | private bool m_KillTimedOutScripts; | 65 | private bool m_KillTimedOutScripts; |
66 | public AsyncCommandManager m_AsyncCommands; | 66 | public AsyncCommandManager m_AsyncCommands; |
67 | bool m_firstStart = true; | ||
67 | 68 | ||
68 | private static List<XEngine> m_ScriptEngines = | 69 | private static List<XEngine> m_ScriptEngines = |
69 | new List<XEngine>(); | 70 | new List<XEngine>(); |
@@ -93,6 +94,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
93 | private Dictionary<LLUUID, List<LLUUID> > m_DomainScripts = | 94 | private Dictionary<LLUUID, List<LLUUID> > m_DomainScripts = |
94 | new Dictionary<LLUUID, List<LLUUID> >(); | 95 | new Dictionary<LLUUID, List<LLUUID> >(); |
95 | 96 | ||
97 | private Queue m_CompileQueue = new Queue(100); | ||
98 | IWorkItemResult m_CurrentCompile = null; | ||
99 | |||
96 | public string ScriptEngineName | 100 | public string ScriptEngineName |
97 | { | 101 | { |
98 | get { return "XEngine"; } | 102 | get { return "XEngine"; } |
@@ -202,6 +206,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
202 | m_Scene.EventManager.OnRezScript += OnRezScript; | 206 | m_Scene.EventManager.OnRezScript += OnRezScript; |
203 | m_Scene.EventManager.OnRemoveScript += OnRemoveScript; | 207 | m_Scene.EventManager.OnRemoveScript += OnRemoveScript; |
204 | m_Scene.EventManager.OnScriptReset += OnScriptReset; | 208 | m_Scene.EventManager.OnScriptReset += OnScriptReset; |
209 | m_Scene.EventManager.OnStartScript += OnStartScript; | ||
210 | m_Scene.EventManager.OnStopScript += OnStopScript; | ||
205 | 211 | ||
206 | m_AsyncCommands = new AsyncCommandManager(this); | 212 | m_AsyncCommands = new AsyncCommandManager(this); |
207 | 213 | ||
@@ -217,6 +223,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
217 | m_ThreadPool.QueueWorkItem(new WorkItemCallback( | 223 | m_ThreadPool.QueueWorkItem(new WorkItemCallback( |
218 | this.DoBackup), new Object[] { saveTime }); | 224 | this.DoBackup), new Object[] { saveTime }); |
219 | } | 225 | } |
226 | |||
227 | scene.RegisterModuleInterface<IScriptModule>(this); | ||
220 | } | 228 | } |
221 | 229 | ||
222 | public void PostInitialise() | 230 | public void PostInitialise() |
@@ -314,23 +322,90 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
314 | get { return m_MaxScriptQueue; } | 322 | get { return m_MaxScriptQueue; } |
315 | } | 323 | } |
316 | 324 | ||
317 | // | 325 | public void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez) |
318 | // Hooks | ||
319 | // | ||
320 | public void OnRezScript(uint localID, LLUUID itemID, string script) | ||
321 | { | 326 | { |
322 | // m_ThreadPool.QueueWorkItem(new WorkItemCallback( | 327 | Object[] parms = new Object[] |
323 | // this.DoOnRezScript), new Object[] | 328 | { localID, itemID, script, startParam, postOnRez}; |
324 | // { localID, itemID, script}); | 329 | |
325 | DoOnRezScript(new Object[] { localID, itemID, script}); | 330 | lock(m_CompileQueue) |
331 | { | ||
332 | m_CompileQueue.Enqueue(parms); | ||
333 | if(m_CurrentCompile == null) | ||
334 | { | ||
335 | if(m_firstStart) | ||
336 | { | ||
337 | m_firstStart = false; | ||
338 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( | ||
339 | new WorkItemCallback( | ||
340 | this.DoScriptWait), new Object[0]); | ||
341 | return; | ||
342 | } | ||
343 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( | ||
344 | new WorkItemCallback( | ||
345 | this.DoOnRezScriptQueue), new Object[0]); | ||
346 | } | ||
347 | } | ||
326 | } | 348 | } |
327 | 349 | ||
328 | private object DoOnRezScript(object parm) | 350 | public Object DoScriptWait(Object dummy) |
351 | { | ||
352 | Thread.Sleep(30000); | ||
353 | |||
354 | lock(m_CompileQueue) | ||
355 | { | ||
356 | if(m_CompileQueue.Count > 0) | ||
357 | { | ||
358 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( | ||
359 | new WorkItemCallback( | ||
360 | this.DoOnRezScriptQueue), new Object[0]); | ||
361 | } | ||
362 | else | ||
363 | { | ||
364 | m_CurrentCompile = null; | ||
365 | } | ||
366 | } | ||
367 | return null; | ||
368 | } | ||
369 | |||
370 | public Object DoOnRezScriptQueue(Object dummy) | ||
371 | { | ||
372 | Object o; | ||
373 | lock(m_CompileQueue) | ||
374 | { | ||
375 | o = m_CompileQueue.Dequeue(); | ||
376 | if(o == null) | ||
377 | { | ||
378 | m_CurrentCompile = null; | ||
379 | return null; | ||
380 | } | ||
381 | } | ||
382 | |||
383 | DoOnRezScript(o); | ||
384 | |||
385 | lock(m_CompileQueue) | ||
386 | { | ||
387 | if(m_CompileQueue.Count > 0) | ||
388 | { | ||
389 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( | ||
390 | new WorkItemCallback( | ||
391 | this.DoOnRezScriptQueue), new Object[0]); | ||
392 | } | ||
393 | else | ||
394 | { | ||
395 | m_CurrentCompile = null; | ||
396 | } | ||
397 | } | ||
398 | return null; | ||
399 | } | ||
400 | |||
401 | private bool DoOnRezScript(object parm) | ||
329 | { | 402 | { |
330 | Object[] p = (Object[])parm; | 403 | Object[] p = (Object[])parm; |
331 | uint localID = (uint)p[0]; | 404 | uint localID = (uint)p[0]; |
332 | LLUUID itemID = (LLUUID)p[1]; | 405 | LLUUID itemID = (LLUUID)p[1]; |
333 | string script =(string)p[2]; | 406 | string script =(string)p[2]; |
407 | int startParam = (int)p[3]; | ||
408 | bool postOnRez = (bool)p[4]; | ||
334 | 409 | ||
335 | // Get the asset ID of the script, so we can check if we | 410 | // Get the asset ID of the script, so we can check if we |
336 | // already have it. | 411 | // already have it. |
@@ -427,7 +502,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
427 | part.UUID, itemID, assetID, assembly, | 502 | part.UUID, itemID, assetID, assembly, |
428 | m_AppDomains[appDomain], | 503 | m_AppDomains[appDomain], |
429 | part.ParentGroup.RootPart.Name, | 504 | part.ParentGroup.RootPart.Name, |
430 | item.Name, XScriptInstance.StateSource.NewRez); | 505 | item.Name, startParam, postOnRez, |
506 | XScriptInstance.StateSource.NewRez); | ||
431 | 507 | ||
432 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", | 508 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", |
433 | part.ParentGroup.RootPart.Name, item.Name); | 509 | part.ParentGroup.RootPart.Name, item.Name); |
@@ -505,6 +581,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
505 | ResetScript(itemID); | 581 | ResetScript(itemID); |
506 | } | 582 | } |
507 | 583 | ||
584 | public void OnStartScript(uint localID, LLUUID itemID) | ||
585 | { | ||
586 | StartScript(itemID); | ||
587 | } | ||
588 | |||
589 | public void OnStopScript(uint localID, LLUUID itemID) | ||
590 | { | ||
591 | StopScript(itemID); | ||
592 | } | ||
593 | |||
508 | private void CleanAssemblies() | 594 | private void CleanAssemblies() |
509 | { | 595 | { |
510 | List<LLUUID> assetIDList = new List<LLUUID>(m_Assemblies.Keys); | 596 | List<LLUUID> assetIDList = new List<LLUUID>(m_Assemblies.Keys); |
@@ -674,7 +760,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
674 | if (running) | 760 | if (running) |
675 | instance.Start(); | 761 | instance.Start(); |
676 | else | 762 | else |
677 | instance.Stop(500); | 763 | instance.Stop(100); |
678 | } | 764 | } |
679 | } | 765 | } |
680 | 766 | ||
@@ -693,6 +779,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
693 | instance.ResetScript(); | 779 | instance.ResetScript(); |
694 | } | 780 | } |
695 | 781 | ||
782 | public void StartScript(LLUUID itemID) | ||
783 | { | ||
784 | XScriptInstance instance = GetInstance(itemID); | ||
785 | if (instance != null) | ||
786 | instance.Start(); | ||
787 | } | ||
788 | |||
789 | public void StopScript(LLUUID itemID) | ||
790 | { | ||
791 | XScriptInstance instance = GetInstance(itemID); | ||
792 | if (instance != null) | ||
793 | instance.Stop(0); | ||
794 | } | ||
795 | |||
696 | public DetectParams GetDetectParams(LLUUID itemID, int idx) | 796 | public DetectParams GetDetectParams(LLUUID itemID, int idx) |
697 | { | 797 | { |
698 | XScriptInstance instance = GetInstance(itemID); | 798 | XScriptInstance instance = GetInstance(itemID); |
@@ -723,6 +823,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
723 | return "default"; | 823 | return "default"; |
724 | return instance.State; | 824 | return instance.State; |
725 | } | 825 | } |
826 | |||
827 | public int GetStartParameter(LLUUID itemID) | ||
828 | { | ||
829 | XScriptInstance instance = GetInstance(itemID); | ||
830 | if (instance == null) | ||
831 | return 0; | ||
832 | return instance.StartParam; | ||
833 | } | ||
834 | |||
835 | public bool GetScriptRunning(LLUUID objectID, LLUUID itemID) | ||
836 | { | ||
837 | return GetScriptState(itemID); | ||
838 | } | ||
726 | } | 839 | } |
727 | 840 | ||
728 | public class XScriptInstance | 841 | public class XScriptInstance |
@@ -745,6 +858,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
745 | private string m_PrimName; | 858 | private string m_PrimName; |
746 | private string m_ScriptName; | 859 | private string m_ScriptName; |
747 | private string m_Assembly; | 860 | private string m_Assembly; |
861 | private int m_StartParam = 0; | ||
862 | |||
748 | private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); | 863 | private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); |
749 | 864 | ||
750 | public enum StateSource | 865 | public enum StateSource |
@@ -823,9 +938,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
823 | m_EventQueue.Clear(); | 938 | m_EventQueue.Clear(); |
824 | } | 939 | } |
825 | 940 | ||
941 | public int StartParam | ||
942 | { | ||
943 | get { return m_StartParam; } | ||
944 | set { m_StartParam = value; } | ||
945 | } | ||
946 | |||
826 | public XScriptInstance(XEngine engine, uint localID, LLUUID objectID, | 947 | public XScriptInstance(XEngine engine, uint localID, LLUUID objectID, |
827 | LLUUID itemID, LLUUID assetID, string assembly, AppDomain dom, | 948 | LLUUID itemID, LLUUID assetID, string assembly, AppDomain dom, |
828 | string primName, string scriptName, StateSource stateSource) | 949 | string primName, string scriptName, int startParam, |
950 | bool postOnRez, StateSource stateSource) | ||
829 | { | 951 | { |
830 | m_Engine = engine; | 952 | m_Engine = engine; |
831 | 953 | ||
@@ -836,6 +958,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
836 | m_PrimName = primName; | 958 | m_PrimName = primName; |
837 | m_ScriptName = scriptName; | 959 | m_ScriptName = scriptName; |
838 | m_Assembly = assembly; | 960 | m_Assembly = assembly; |
961 | m_StartParam = startParam; | ||
839 | 962 | ||
840 | ApiManager am = new ApiManager(); | 963 | ApiManager am = new ApiManager(); |
841 | 964 | ||
@@ -918,6 +1041,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
918 | { | 1041 | { |
919 | m_RunEvents = false; | 1042 | m_RunEvents = false; |
920 | Start(); | 1043 | Start(); |
1044 | if(postOnRez) | ||
1045 | PostEvent(new EventParams("on_rez", | ||
1046 | new Object[] {new LSL_Types.LSLInteger(startParam)}, new DetectParams[0])); | ||
921 | } | 1047 | } |
922 | 1048 | ||
923 | // we get new rez events on sim restart, too | 1049 | // we get new rez events on sim restart, too |
@@ -934,25 +1060,36 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
934 | else | 1060 | else |
935 | { | 1061 | { |
936 | m_Engine.Log.Error("[XEngine] Unable to load script state: Memory limit exceeded"); | 1062 | m_Engine.Log.Error("[XEngine] Unable to load script state: Memory limit exceeded"); |
1063 | Start(); | ||
937 | PostEvent(new EventParams("state_entry", | 1064 | PostEvent(new EventParams("state_entry", |
938 | new Object[0], new DetectParams[0])); | 1065 | new Object[0], new DetectParams[0])); |
939 | Start(); | 1066 | if(postOnRez) |
1067 | PostEvent(new EventParams("on_rez", | ||
1068 | new Object[] {new LSL_Types.LSLInteger(startParam)}, new DetectParams[0])); | ||
1069 | |||
940 | } | 1070 | } |
941 | } | 1071 | } |
942 | catch (Exception e) | 1072 | catch (Exception e) |
943 | { | 1073 | { |
944 | m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state from xml: {0}\n"+e.ToString(), xml); | 1074 | m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state from xml: {0}\n"+e.ToString(), xml); |
1075 | Start(); | ||
945 | PostEvent(new EventParams("state_entry", | 1076 | PostEvent(new EventParams("state_entry", |
946 | new Object[0], new DetectParams[0])); | 1077 | new Object[0], new DetectParams[0])); |
947 | Start(); | 1078 | if(postOnRez) |
1079 | PostEvent(new EventParams("on_rez", | ||
1080 | new Object[] {new LSL_Types.LSLInteger(startParam)}, new DetectParams[0])); | ||
948 | } | 1081 | } |
949 | } | 1082 | } |
950 | else | 1083 | else |
951 | { | 1084 | { |
952 | m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state, file not found"); | 1085 | // m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state, file not found"); |
1086 | Start(); | ||
953 | PostEvent(new EventParams("state_entry", | 1087 | PostEvent(new EventParams("state_entry", |
954 | new Object[0], new DetectParams[0])); | 1088 | new Object[0], new DetectParams[0])); |
955 | Start(); | 1089 | |
1090 | if(postOnRez) | ||
1091 | PostEvent(new EventParams("on_rez", | ||
1092 | new Object[] {new LSL_Types.LSLInteger(startParam)}, new DetectParams[0])); | ||
956 | } | 1093 | } |
957 | } | 1094 | } |
958 | 1095 | ||
@@ -1062,6 +1199,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1062 | { | 1199 | { |
1063 | // m_Engine.Log.DebugFormat("[XEngine] Posted event {2} in state {3} to {0}.{1}", | 1200 | // m_Engine.Log.DebugFormat("[XEngine] Posted event {2} in state {3} to {0}.{1}", |
1064 | // m_PrimName, m_ScriptName, data.EventName, m_State); | 1201 | // m_PrimName, m_ScriptName, data.EventName, m_State); |
1202 | |||
1203 | if(!Running) | ||
1204 | return; | ||
1205 | |||
1065 | lock (m_EventQueue) | 1206 | lock (m_EventQueue) |
1066 | { | 1207 | { |
1067 | if (m_EventQueue.Count >= m_Engine.MaxScriptQueue) | 1208 | if (m_EventQueue.Count >= m_Engine.MaxScriptQueue) |