aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-25 05:13:44 +0000
committerMelanie Thielker2008-09-25 05:13:44 +0000
commitf3c8963c86dbc969541ede80ae37eb59d26b7809 (patch)
treeff1e5cea74e9d5c2b73c476320a7bddf11d93766
parentMantis#2123. Thank you kindly, Idb for a patch that solves: (diff)
downloadopensim-SC_OLD-f3c8963c86dbc969541ede80ae37eb59d26b7809.zip
opensim-SC_OLD-f3c8963c86dbc969541ede80ae37eb59d26b7809.tar.gz
opensim-SC_OLD-f3c8963c86dbc969541ede80ae37eb59d26b7809.tar.bz2
opensim-SC_OLD-f3c8963c86dbc969541ede80ae37eb59d26b7809.tar.xz
Convergence is almost complete. This brings the diff between the API to < 10k
and makes it use a common set of types in both engine. Fixes the issues with running both engines and HTTP requests / listens / timers etc.. Also fixes a couple of minor Scene issues and a CTB by nullref.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs3
-rw-r--r--OpenSim/Region/Environment/Interfaces/IScriptModule.cs38
-rw-r--r--OpenSim/Region/Environment/Scenes/EventManager.cs11
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs19
-rw-r--r--OpenSim/Region/ScriptEngine/Common/IScript.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs233
-rw-r--r--OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptBaseClass.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs234
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Dataserver.cs127
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs98
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs76
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs334
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs139
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs130
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs345
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs28
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs25
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs19
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs116
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs22
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs39
-rw-r--r--prebuild.xml2
30 files changed, 391 insertions, 1724 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index f1dc20e..983e1a9 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -502,7 +502,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
502 // horribly tangly. Hopefully it should be possible to greatly simplify it. 502 // horribly tangly. Hopefully it should be possible to greatly simplify it.
503 if (shutdownCircuit) 503 if (shutdownCircuit)
504 { 504 {
505 OnConnectionClosed(this); 505 if (OnConnectionClosed != null)
506 OnConnectionClosed(this);
506 } 507 }
507 else 508 else
508 { 509 {
diff --git a/OpenSim/Region/Environment/Interfaces/IScriptModule.cs b/OpenSim/Region/Environment/Interfaces/IScriptModule.cs
deleted file mode 100644
index efe7944..0000000
--- a/OpenSim/Region/Environment/Interfaces/IScriptModule.cs
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenSim.Framework;
30using OpenMetaverse;
31
32namespace OpenSim.Region.Environment.Interfaces
33{
34 public interface IScriptModule : IRegionModule
35 {
36 bool GetScriptRunning(UUID objectID, UUID itemID);
37 }
38}
diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs
index 42cbdfc..87f3de1 100644
--- a/OpenSim/Region/Environment/Scenes/EventManager.cs
+++ b/OpenSim/Region/Environment/Scenes/EventManager.cs
@@ -192,6 +192,8 @@ namespace OpenSim.Region.Environment.Scenes
192 public event ScriptTimerEvent OnScriptTimerEvent; 192 public event ScriptTimerEvent OnScriptTimerEvent;
193 193
194 public delegate void EstateToolsTimeUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour); 194 public delegate void EstateToolsTimeUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour);
195 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID);
196
195 public event EstateToolsTimeUpdate OnEstateToolsTimeUpdate; 197 public event EstateToolsTimeUpdate OnEstateToolsTimeUpdate;
196 198
197 public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); 199 public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj);
@@ -211,6 +213,7 @@ namespace OpenSim.Region.Environment.Scenes
211 213
212 public delegate void ParcelPrimCountTainted(); 214 public delegate void ParcelPrimCountTainted();
213 public event ParcelPrimCountTainted OnParcelPrimCountTainted; 215 public event ParcelPrimCountTainted OnParcelPrimCountTainted;
216 public event GetScriptRunning OnGetScriptRunning;
214 217
215 /// <summary> 218 /// <summary>
216 /// RegisterCapsEvent is called by Scene after the Caps object 219 /// RegisterCapsEvent is called by Scene after the Caps object
@@ -368,9 +371,17 @@ namespace OpenSim.Region.Environment.Scenes
368 private ScriptColliding handlerCollidingStart = null; 371 private ScriptColliding handlerCollidingStart = null;
369 private ScriptColliding handlerColliding = null; 372 private ScriptColliding handlerColliding = null;
370 private ScriptColliding handlerCollidingEnd = null; 373 private ScriptColliding handlerCollidingEnd = null;
374 private GetScriptRunning handlerGetScriptRunning = null;
371 375
372 private SunLindenHour handlerSunGetLindenHour = null; 376 private SunLindenHour handlerSunGetLindenHour = null;
373 377
378 public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
379 {
380 handlerGetScriptRunning = OnGetScriptRunning;
381 if (handlerGetScriptRunning != null)
382 handlerGetScriptRunning(controllingClient, objectID, itemID);
383 }
384
374 public void TriggerOnScriptChangedEvent(uint localID, uint change) 385 public void TriggerOnScriptChangedEvent(uint localID, uint change)
375 { 386 {
376 handlerScriptChangedEvent = OnScriptChangedEvent; 387 handlerScriptChangedEvent = OnScriptChangedEvent;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 015b140..2a9be81 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -445,7 +445,6 @@ namespace OpenSim.Region.Environment.Scenes
445 } 445 }
446 else 446 else
447 { 447 {
448 Console.WriteLine("Non-Prim item ==>");
449 itemCopy.BasePermissions = item.BasePermissions & item.NextPermissions; 448 itemCopy.BasePermissions = item.BasePermissions & item.NextPermissions;
450 } 449 }
451 450
@@ -896,6 +895,9 @@ namespace OpenSim.Region.Environment.Scenes
896 if (group != null) 895 if (group != null)
897 { 896 {
898 TaskInventoryItem item = group.GetInventoryItem(localID, itemID); 897 TaskInventoryItem item = group.GetInventoryItem(localID, itemID);
898 if (item == null)
899 return;
900
899 if (item.Type == 10) 901 if (item.Type == 10)
900 { 902 {
901 EventManager.TriggerRemoveScript(localID, itemID); 903 EventManager.TriggerRemoveScript(localID, itemID);
@@ -2311,16 +2313,6 @@ System.Console.WriteLine("Item asset {0}, request asset {1}", prevItem.AssetID.T
2311 2313
2312 } 2314 }
2313 2315
2314 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
2315 {
2316 IScriptModule scriptModule = RequestModuleInterface<IScriptModule>();
2317 if (scriptModule == null)
2318 return;
2319
2320 controllingClient.SendScriptRunningReply(objectID, itemID,
2321 scriptModule.GetScriptRunning(objectID, itemID));
2322 }
2323
2324 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) 2316 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
2325 { 2317 {
2326 SceneObjectPart part = GetSceneObjectPart(objectID); 2318 SceneObjectPart part = GetSceneObjectPart(objectID);
@@ -2388,5 +2380,10 @@ System.Console.WriteLine("Item asset {0}, request asset {1}", prevItem.AssetID.T
2388 } 2380 }
2389 m_innerScene.DetachSingleAttachmentToInv(itemID, remoteClient); 2381 m_innerScene.DetachSingleAttachmentToInv(itemID, remoteClient);
2390 } 2382 }
2383
2384 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
2385 {
2386 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID);
2387 }
2391 } 2388 }
2392} 2389}
diff --git a/OpenSim/Region/ScriptEngine/Common/IScript.cs b/OpenSim/Region/ScriptEngine/Common/IScript.cs
index cad3707..754e86b 100644
--- a/OpenSim/Region/ScriptEngine/Common/IScript.cs
+++ b/OpenSim/Region/ScriptEngine/Common/IScript.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; 28using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
29using OpenSim.Region.ScriptEngine.Shared;
29 30
30namespace OpenSim.Region.ScriptEngine.Common 31namespace OpenSim.Region.ScriptEngine.Common
31{ 32{
@@ -36,6 +37,5 @@ namespace OpenSim.Region.ScriptEngine.Common
36 ExecutorBase Exec { get; } 37 ExecutorBase Exec { get; }
37 string Source { get; set; } 38 string Source { get; set; }
38 void Start(BuilIn_Commands BuiltIn_Commands); 39 void Start(BuilIn_Commands BuiltIn_Commands);
39 EventQueueManager.Queue_llDetectParams_Struct llDetectParams { get; set; }
40 } 40 }
41} 41}
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index 795baac..8e24543 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -45,6 +45,7 @@ using OpenSim.Region.Environment.Scenes;
45using OpenSim.Region.Physics.Manager; 45using OpenSim.Region.Physics.Manager;
46using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; 46using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
47using OpenSim.Region.ScriptEngine.Shared; 47using OpenSim.Region.ScriptEngine.Shared;
48using OpenSim.Region.ScriptEngine.Shared.Api;
48 49
49using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; 50using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
50using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; 51using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
@@ -79,7 +80,8 @@ namespace OpenSim.Region.ScriptEngine.Common
79 m_localID = localID; 80 m_localID = localID;
80 m_itemID = itemID; 81 m_itemID = itemID;
81 82
82 AsyncCommands = m_ScriptEngine.m_ASYNCLSLCommandManager; 83 AsyncCommands = new AsyncCommandManager(m_ScriptEngine);
84
83 //m_log.Info(ScriptEngineName, "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]"); 85 //m_log.Info(ScriptEngineName, "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]");
84 86
85 87
@@ -759,256 +761,95 @@ namespace OpenSim.Region.ScriptEngine.Common
759 public LSL_String llDetectedName(int number) 761 public LSL_String llDetectedName(int number)
760 { 762 {
761 m_host.AddScriptLPS(1); 763 m_host.AddScriptLPS(1);
762 LSL_List SenseList = AsyncCommands.SensorRepeatPlugin.GetSensorList(m_localID, m_itemID); 764 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
763 if (SenseList != null) 765 if (d == null)
764 {
765 if ((number >= 0) && (number < SenseList.Length))
766 {
767 UUID SensedUUID = (UUID)SenseList.Data[number];
768 return resolveName(SensedUUID);
769 }
770 }
771 else
772 {
773 ScriptManager sm;
774 IScript script = null;
775
776 if ((sm = m_ScriptEngine.m_ScriptManager) != null)
777 {
778 if (sm.Scripts.ContainsKey(m_localID))
779 {
780 if ((script = sm.GetScript(m_localID, m_itemID)) != null)
781 {
782 //System.Console.WriteLine(number + " - " + script.llDetectParams._key.Length);
783 if (script.llDetectParams._string != null)
784 {
785 if (script.llDetectParams._string.Length > number)
786 {
787 if (script.llDetectParams._string[number] != null)
788 {
789 return script.llDetectParams._string[number];
790 }
791 }
792 }
793 }
794 }
795 }
796 }
797 return String.Empty; 766 return String.Empty;
798 } 767 return d.Name;
799
800 public UUID uuidDetectedKey(int number)
801 {
802 LSL_List SenseList = AsyncCommands.SensorRepeatPlugin.GetSensorList(m_localID, m_itemID);
803 if (SenseList != null)
804 {
805 if ((number >= 0) && (number < SenseList.Length))
806 {
807 UUID SensedUUID = (UUID)SenseList.Data[number];
808 return SensedUUID;
809 }
810 }
811 else
812 {
813 ScriptManager sm;
814 IScript script = null;
815
816 if ((sm = m_ScriptEngine.m_ScriptManager) != null)
817 {
818 if (sm.Scripts.ContainsKey(m_localID))
819 {
820 if ((script = sm.GetScript(m_localID, m_itemID)) != null)
821 {
822 //System.Console.WriteLine(number + " - " + script.llDetectParams._key.Length);
823 if (script.llDetectParams._key.Length > number)
824 {
825 if (script.llDetectParams._key[number])
826 {
827 return new UUID(script.llDetectParams._key[number]);
828 }
829 }
830 }
831 }
832 }
833 }
834 return UUID.Zero;
835 }
836
837 public EntityBase entityDetectedKey(int number)
838 {
839 LSL_List SenseList = AsyncCommands.SensorRepeatPlugin.GetSensorList(m_localID, m_itemID);
840 if (SenseList != null)
841 {
842 if ((number >= 0) && (number < SenseList.Length))
843 {
844 UUID SensedUUID = (UUID)SenseList.Data[number];
845 EntityBase SensedObject = null;
846 lock (World.Entities)
847 {
848 World.Entities.TryGetValue(SensedUUID, out SensedObject);
849 }
850 return SensedObject;
851 }
852 }
853 else
854 {
855 ScriptManager sm;
856 IScript script = null;
857
858 if ((sm = m_ScriptEngine.m_ScriptManager) != null)
859 {
860 if (sm.Scripts.ContainsKey(m_localID))
861 {
862 if ((script = sm.GetScript(m_localID, m_itemID)) != null)
863 {
864 //System.Console.WriteLine(number + " - " + script.llDetectParams._key.Length);
865 if (script.llDetectParams._key.Length > number)
866 {
867 if (script.llDetectParams._key[number])
868 {
869 UUID SensedUUID = new UUID(script.llDetectParams._key[number]);
870 EntityBase SensedObject = null;
871 lock (World.Entities)
872 {
873 World.Entities.TryGetValue(SensedUUID, out SensedObject);
874 }
875 return SensedObject;
876 }
877 }
878 }
879 }
880 }
881 }
882
883 return null;
884 } 768 }
885 769
886 public LSL_String llDetectedKey(int number) 770 public LSL_String llDetectedKey(int number)
887 { 771 {
888 m_host.AddScriptLPS(1); 772 m_host.AddScriptLPS(1);
889 UUID SensedUUID = uuidDetectedKey(number); 773 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
890 if (SensedUUID == UUID.Zero) 774 if (d == null)
891 return String.Empty; 775 return String.Empty;
892 return SensedUUID.ToString(); 776 return d.Key.ToString();
893 } 777 }
894 778
895 public LSL_String llDetectedOwner(int number) 779 public LSL_String llDetectedOwner(int number)
896 { 780 {
897 // returns UUID of owner of object detected
898 m_host.AddScriptLPS(1); 781 m_host.AddScriptLPS(1);
899 EntityBase SensedObject = entityDetectedKey(number); 782 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
900 if (SensedObject ==null) 783 if (d == null)
901 return String.Empty; 784 return String.Empty;
902 UUID SensedUUID = uuidDetectedKey(number); 785 return d.Owner.ToString();
903 if (World.GetScenePresence(SensedUUID) == null)
904 {
905 // sensed object is not an avatar
906 // so get the owner of the sensed object
907 SceneObjectPart SOP = World.GetSceneObjectPart(SensedUUID);
908 if (SOP != null) { return SOP.ObjectOwner.ToString(); }
909 }
910 else
911 {
912 // sensed object is an avatar, and so must be its own owner
913 return SensedUUID.ToString();
914 }
915
916
917 return String.Empty;
918
919 } 786 }
920 787
921 public LSL_Integer llDetectedType(int number) 788 public LSL_Integer llDetectedType(int number)
922 { 789 {
923 m_host.AddScriptLPS(1); 790 m_host.AddScriptLPS(1);
924 EntityBase SensedObject = entityDetectedKey(number); 791 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
925 if (SensedObject == null) 792 if (d == null)
926 return 0; 793 return 0;
927 int mask = 0; 794 return new LSL_Integer(d.Type);
928
929 UUID SensedUUID = uuidDetectedKey(number);
930 LSL_Vector ZeroVector = new LSL_Vector(0, 0, 0);
931
932 if (World.GetScenePresence(SensedUUID) != null) mask |= 0x01; // actor
933 if (SensedObject.Velocity.Equals(ZeroVector))
934 mask |= 0x04; // passive non-moving
935 else
936 mask |= 0x02; // active moving
937 if (SensedObject is IScript) mask |= 0x08; // Scripted. It COULD have one hidden ...
938 return mask;
939 } 795 }
940 796
941 public LSL_Vector llDetectedPos(int number) 797 public LSL_Vector llDetectedPos(int number)
942 { 798 {
943 m_host.AddScriptLPS(1); 799 m_host.AddScriptLPS(1);
944 EntityBase SensedObject = entityDetectedKey(number); 800 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
945 if (SensedObject == null) 801 if (d == null)
946 return new LSL_Vector(0, 0, 0); 802 return new LSL_Vector();
947 return new LSL_Vector( 803 return d.Position;
948 SensedObject.AbsolutePosition.X,
949 SensedObject.AbsolutePosition.Y,
950 SensedObject.AbsolutePosition.Z);
951 } 804 }
952 805
953 public LSL_Vector llDetectedVel(int number) 806 public LSL_Vector llDetectedVel(int number)
954 { 807 {
955 m_host.AddScriptLPS(1); 808 m_host.AddScriptLPS(1);
956 EntityBase SensedObject = entityDetectedKey(number); 809 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
957 if (SensedObject == null) 810 if (d == null)
958 return new LSL_Vector(0, 0, 0); 811 return new LSL_Vector();
959 return new LSL_Vector( 812 return d.Velocity;
960 SensedObject.Velocity.X,
961 SensedObject.Velocity.Y,
962 SensedObject.Velocity.Z);
963 } 813 }
964 814
965 public LSL_Vector llDetectedGrab(int number) 815 public LSL_Vector llDetectedGrab(int number)
966 { 816 {
967 m_host.AddScriptLPS(1); 817 m_host.AddScriptLPS(1);
968 EntityBase SensedObject = entityDetectedKey(number); 818 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number);
969 if (SensedObject == null) 819 if (parms == null)
970 return new LSL_Vector(0, 0, 0); 820 return new LSL_Vector(0, 0, 0);
971 821
972 return new LSL_Vector( 822 return parms.OffsetPos;
973 SensedObject.AbsolutePosition.X,
974 SensedObject.AbsolutePosition.Y,
975 SensedObject.AbsolutePosition.Z);
976 } 823 }
977 824
978 public LSL_Rotation llDetectedRot(int number) 825 public LSL_Rotation llDetectedRot(int number)
979 { 826 {
980 m_host.AddScriptLPS(1); 827 m_host.AddScriptLPS(1);
981 EntityBase SensedObject = entityDetectedKey(number); 828 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
982 if (SensedObject == null) 829 if (d == null)
983 return new LSL_Rotation(); 830 return new LSL_Rotation();
984 return new LSL_Rotation( 831 return d.Rotation;
985 SensedObject.Rotation.X,
986 SensedObject.Rotation.Y,
987 SensedObject.Rotation.Z,
988 SensedObject.Rotation.W);
989 } 832 }
990 833
991 public LSL_Integer llDetectedGroup(int number) 834 public LSL_Integer llDetectedGroup(int number)
992 { 835 {
993 m_host.AddScriptLPS(1); 836 m_host.AddScriptLPS(1);
994 UUID SensedUUID = uuidDetectedKey(number); 837 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
995 if (SensedUUID == UUID.Zero) 838 if (d == null)
996 return new LSL_Integer(0); 839 return new LSL_Integer(0);
997 ScenePresence presence = World.GetScenePresence(SensedUUID); 840 if (m_host.GroupID == d.Group)
998 IClientAPI client = presence.ControllingClient;
999 if (m_host.GroupID == client.ActiveGroupId)
1000 return new LSL_Integer(1); 841 return new LSL_Integer(1);
1001 else
1002 return new LSL_Integer(0); 842 return new LSL_Integer(0);
1003 } 843 }
1004 844
1005 public LSL_Integer llDetectedLinkNumber(int number) 845 public LSL_Integer llDetectedLinkNumber(int number)
1006 { 846 {
1007 m_host.AddScriptLPS(1); 847 m_host.AddScriptLPS(1);
1008 EntityBase SensedObject = entityDetectedKey(number); 848 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number);
1009 if (SensedObject == null) 849 if (parms == null)
1010 return 0; 850 return new LSL_Integer(0);
1011 return m_host.LinkNum; 851
852 return new LSL_Integer(parms.LinkNum);
1012 } 853 }
1013 854
1014 public LSL_Vector llDetectedTouchBinormal(int index) 855 public LSL_Vector llDetectedTouchBinormal(int index)
diff --git a/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs
index 5ca3e7d..0ef909f 100644
--- a/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs
@@ -577,7 +577,7 @@ namespace OpenSim.Region.ScriptEngine.Common
577 { 577 {
578 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, new UUID(channel)); 578 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, new UUID(channel));
579 object[] resobj = new object[] { new LSL_Types.LSLInteger(1), new LSL_Types.LSLString(channelID.ToString()), new LSL_Types.LSLString(UUID.Zero.ToString()), new LSL_Types.LSLString(String.Empty), new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(String.Empty) }; 579 object[] resobj = new object[] { new LSL_Types.LSLInteger(1), new LSL_Types.LSLString(channelID.ToString()), new LSL_Types.LSLString(UUID.Zero.ToString()), new LSL_Types.LSLString(String.Empty), new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(String.Empty) };
580 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj); 580 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", new DetectParams[0], resobj);
581 } 581 }
582 } 582 }
583 583
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptBaseClass.cs b/OpenSim/Region/ScriptEngine/Common/ScriptBaseClass.cs
index 3e8450d..d665bcc 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptBaseClass.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptBaseClass.cs
@@ -30,6 +30,7 @@ using System.Runtime.Remoting.Lifetime;
30using System.Threading; 30using System.Threading;
31using OpenSim.Region.Environment.Interfaces; 31using OpenSim.Region.Environment.Interfaces;
32using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; 32using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
33using OpenSim.Region.ScriptEngine.Shared;
33 34
34using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; 35using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
35using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; 36using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
@@ -68,13 +69,6 @@ namespace OpenSim.Region.ScriptEngine.Common
68 return lease; 69 return lease;
69 } 70 }
70 71
71 public EventQueueManager.Queue_llDetectParams_Struct _llDetectParams;
72 EventQueueManager.Queue_llDetectParams_Struct IScript.llDetectParams
73 {
74 get { return _llDetectParams; }
75 set { _llDetectParams = value; }
76 }
77
78 private Executor m_Exec; 72 private Executor m_Exec;
79 73
80 ExecutorBase IScript.Exec 74 ExecutorBase IScript.Exec
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs
deleted file mode 100644
index 5fa6010..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs
+++ /dev/null
@@ -1,234 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections;
29using System.Threading;
30using OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Region.Environment.Interfaces;
33using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins;
34using Timer=OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins.Timer;
35
36namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
37{
38 /// <summary>
39 /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
40 /// </summary>
41 public class AsyncCommandManager : iScriptEngineFunctionModule
42 {
43 private static Thread cmdHandlerThread;
44 private static int cmdHandlerThreadCycleSleepms;
45
46 public ScriptEngine m_ScriptEngine;
47
48 private Timer m_Timer;
49 private HttpRequest m_HttpRequest;
50 private Listener m_Listener;
51 private SensorRepeat m_SensorRepeat;
52 private XmlRequest m_XmlRequest;
53 private Dataserver m_Dataserver;
54
55 public Dataserver DataserverPlugin
56 {
57 get { return m_Dataserver; }
58 }
59
60 public Timer TimerPlugin
61 {
62 get { return m_Timer; }
63 }
64
65 public HttpRequest HttpRequestPlugin
66 {
67 get { return m_HttpRequest; }
68 }
69
70 public Listener ListenerPlugin
71 {
72 get { return m_Listener; }
73 }
74
75 public SensorRepeat SensorRepeatPlugin
76 {
77 get { return m_SensorRepeat; }
78 }
79
80 public XmlRequest XmlRequestPlugin
81 {
82 get { return m_XmlRequest; }
83 }
84
85 public AsyncCommandManager(ScriptEngine _ScriptEngine)
86 {
87 m_ScriptEngine = _ScriptEngine;
88 ReadConfig();
89
90 // Create instances of all plugins
91 m_Timer = new Timer(this);
92 m_HttpRequest = new HttpRequest(this);
93 m_Listener = new Listener(this);
94 m_SensorRepeat = new SensorRepeat(this);
95 m_XmlRequest = new XmlRequest(this);
96 m_Dataserver = new Dataserver(this);
97
98 StartThread();
99 }
100
101 private static void StartThread()
102 {
103 if (cmdHandlerThread == null)
104 {
105 // Start the thread that will be doing the work
106 cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
107 cmdHandlerThread.Name = "AsyncLSLCmdHandlerThread";
108 cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
109 cmdHandlerThread.IsBackground = true;
110 cmdHandlerThread.Start();
111 ThreadTracker.Add(cmdHandlerThread);
112 }
113 }
114
115 public void ReadConfig()
116 {
117 cmdHandlerThreadCycleSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("AsyncLLCommandLoopms", 100);
118 }
119
120 ~AsyncCommandManager()
121 {
122 // Shut down thread
123 try
124 {
125 if (cmdHandlerThread != null)
126 {
127 if (cmdHandlerThread.IsAlive == true)
128 {
129 cmdHandlerThread.Abort();
130 //cmdHandlerThread.Join();
131 }
132 }
133 }
134 catch
135 {
136 }
137 }
138
139 private static void CmdHandlerThreadLoop()
140 {
141 while (true)
142 {
143 try
144 {
145 while (true)
146 {
147 Thread.Sleep(cmdHandlerThreadCycleSleepms);
148 //lock (ScriptEngine.ScriptEngines)
149 //{
150 foreach (ScriptEngine se in new ArrayList(ScriptEngine.ScriptEngines))
151 {
152 se.m_ASYNCLSLCommandManager.DoOneCmdHandlerPass();
153 }
154 //}
155 // Sleep before next cycle
156 //Thread.Sleep(cmdHandlerThreadCycleSleepms);
157 }
158 }
159 catch
160 {
161 }
162 }
163 }
164
165 internal void DoOneCmdHandlerPass()
166 {
167 // Check timers
168 m_Timer.CheckTimerEvents();
169 // Check HttpRequests
170 m_HttpRequest.CheckHttpRequests();
171 // Check XMLRPCRequests
172 m_XmlRequest.CheckXMLRPCRequests();
173 // Check Listeners
174 m_Listener.CheckListeners();
175 // Check Sensors
176 m_SensorRepeat.CheckSenseRepeaterEvents();
177 // Check dataserver
178 m_Dataserver.ExpireRequests();
179 }
180
181 /// <summary>
182 /// Remove a specific script (and all its pending commands)
183 /// </summary>
184 /// <param name="localID"></param>
185 /// <param name="itemID"></param>
186 public void RemoveScript(uint localID, UUID itemID)
187 {
188 // Remove a specific script
189
190 // Remove from: Timers
191 m_Timer.UnSetTimerEvents(localID, itemID);
192
193 // Remove from: HttpRequest
194 IHttpRequests iHttpReq =
195 m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
196 iHttpReq.StopHttpRequest(localID, itemID);
197
198 IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
199 comms.DeleteListener(itemID);
200
201 IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
202 xmlrpc.DeleteChannels(itemID);
203 xmlrpc.CancelSRDRequests(itemID);
204
205 // Remove Sensors
206 m_SensorRepeat.UnSetSenseRepeaterEvents(localID, itemID);
207
208 // Remove queries
209 m_Dataserver.RemoveEvents(localID, itemID);
210
211 }
212
213
214 #region Check llRemoteData channels
215
216
217 #endregion
218
219 #region Check llListeners
220
221
222 #endregion
223
224 /// <summary>
225 /// If set to true then threads and stuff should try to make a graceful exit
226 /// </summary>
227 public bool PleaseShutdown
228 {
229 get { return _PleaseShutdown; }
230 set { _PleaseShutdown = value; }
231 }
232 private bool _PleaseShutdown = false;
233 }
234}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Dataserver.cs
deleted file mode 100644
index 96d7b30..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Dataserver.cs
+++ /dev/null
@@ -1,127 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using OpenMetaverse;
32using OpenSim.Region.ScriptEngine.Shared;
33
34namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
35
36{
37 public class Dataserver
38 {
39 public AsyncCommandManager m_CmdManager;
40
41 private Dictionary<string, DataserverRequest> DataserverRequests =
42 new Dictionary<string, DataserverRequest>();
43
44 public Dataserver(AsyncCommandManager CmdManager)
45 {
46 m_CmdManager = CmdManager;
47 }
48
49 private class DataserverRequest
50 {
51 public uint localID;
52 public UUID itemID;
53
54 public UUID ID;
55 public string handle;
56
57 public DateTime startTime;
58 }
59
60 public UUID RegisterRequest(uint localID, UUID itemID,
61 string identifier)
62 {
63 lock (DataserverRequests)
64 {
65 if (DataserverRequests.ContainsKey(identifier))
66 return UUID.Zero;
67
68 DataserverRequest ds = new DataserverRequest();
69
70 ds.localID = localID;
71 ds.itemID = itemID;
72
73 ds.ID = UUID.Random();
74 ds.handle = identifier;
75
76 ds.startTime = DateTime.Now;
77
78 DataserverRequests[identifier]=ds;
79
80 return ds.ID;
81 }
82 }
83
84 public void DataserverReply(string identifier, string reply)
85 {
86 DataserverRequest ds;
87
88 lock (DataserverRequests)
89 {
90 if (!DataserverRequests.ContainsKey(identifier))
91 return;
92
93 ds=DataserverRequests[identifier];
94 DataserverRequests.Remove(identifier);
95 }
96
97 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToObjectQueue(
98 ds.localID, "dataserver", EventQueueManager.llDetectNull,
99 new Object[] { new LSL_Types.LSLString(ds.ID.ToString()),
100 new LSL_Types.LSLString(reply)});
101 }
102
103 public void RemoveEvents(uint localID, UUID itemID)
104 {
105 lock (DataserverRequests)
106 {
107 foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values))
108 {
109 if (ds.itemID == itemID)
110 DataserverRequests.Remove(ds.handle);
111 }
112 }
113 }
114
115 public void ExpireRequests()
116 {
117 lock (DataserverRequests)
118 {
119 foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values))
120 {
121 if (ds.startTime > DateTime.Now.AddSeconds(30))
122 DataserverRequests.Remove(ds.handle);
123 }
124 }
125 }
126 }
127}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs
deleted file mode 100644
index 5b4cb83..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.Scripting.HttpRequest;
31using OpenSim.Region.ScriptEngine.Shared;
32
33namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
34{
35 public class HttpRequest
36 {
37 public AsyncCommandManager m_CmdManager;
38
39 public HttpRequest(AsyncCommandManager CmdManager)
40 {
41 m_CmdManager = CmdManager;
42 }
43
44 public void CheckHttpRequests()
45 {
46 if (m_CmdManager.m_ScriptEngine.World == null)
47 return;
48
49 IHttpRequests iHttpReq =
50 m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
51
52 HttpRequestClass httpInfo = null;
53
54 if (iHttpReq != null)
55 httpInfo = iHttpReq.GetNextCompletedRequest();
56
57 while (httpInfo != null)
58 {
59 //m_ScriptEngine.Log.Info("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status);
60
61 // Deliver data to prim's remote_data handler
62 //
63 // TODO: Returning null for metadata, since the lsl function
64 // only returns the byte for HTTP_BODY_TRUNCATED, which is not
65 // implemented here yet anyway. Should be fixed if/when maxsize
66 // is supported
67
68 bool handled = false;
69 iHttpReq.RemoveCompletedRequest(httpInfo.reqID);
70 foreach (ScriptEngine sman in ScriptEngine.ScriptEngines)
71 {
72 if (sman.m_ScriptManager.GetScript(httpInfo.localID, httpInfo.itemID) != null)
73 {
74 object[] resobj = new object[]
75 {
76 new LSL_Types.LSLString(httpInfo.reqID.ToString()), new LSL_Types.LSLInteger(httpInfo.status), null, new LSL_Types.LSLString(httpInfo.response_body)
77 };
78
79 sman.m_EventQueueManager.AddToScriptQueue(
80 httpInfo.localID, httpInfo.itemID, "http_response", EventQueueManager.llDetectNull, resobj
81 );
82
83 handled = true;
84 break;
85 //Thread.Sleep(2500);
86 }
87 }
88
89 if (!handled)
90 {
91 Console.WriteLine("Unhandled http_response: " + httpInfo.reqID);
92 }
93
94 httpInfo = iHttpReq.GetNextCompletedRequest();
95 }
96 }
97 }
98}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs
deleted file mode 100644
index 0bac22c..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs
+++ /dev/null
@@ -1,76 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using OpenSim.Region.Environment.Interfaces;
29using OpenSim.Region.Environment.Modules.Scripting.WorldComm;
30using OpenSim.Region.ScriptEngine.Shared;
31
32namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
33{
34 public class Listener
35 {
36 // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
37
38 public AsyncCommandManager m_CmdManager;
39
40 public Listener(AsyncCommandManager CmdManager)
41 {
42 m_CmdManager = CmdManager;
43 }
44
45 public void CheckListeners()
46 {
47 if (m_CmdManager.m_ScriptEngine.World == null)
48 return;
49 IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
50
51 if (comms != null)
52 {
53 while (comms.HasMessages())
54 {
55 ListenerInfo lInfo = comms.GetNextMessage();
56 if (m_CmdManager.m_ScriptEngine.m_ScriptManager.GetScript(
57 lInfo.GetLocalID(), lInfo.GetItemID()) != null)
58 {
59 //Deliver data to prim's listen handler
60 object[] resobj = new object[]
61 {
62 //lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage()
63 new LSL_Types.LSLInteger(lInfo.GetChannel()), new LSL_Types.LSLString(lInfo.GetName()), new LSL_Types.LSLString(lInfo.GetID().ToString()), new LSL_Types.LSLString(lInfo.GetMessage())
64 };
65
66 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
67 lInfo.GetLocalID(), lInfo.GetItemID(), "listen", EventQueueManager.llDetectNull, resobj
68 );
69 }
70 // else
71 // m_log.Info("[ScriptEngineBase.AsyncCommandPlugins: received a listen event for a (no longer) existing script ("+lInfo.GetLocalID().AsString()+")");
72 }
73 }
74 }
75 }
76}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs
deleted file mode 100644
index 7059a1b..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs
+++ /dev/null
@@ -1,334 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27//#define SPAM
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Region.Environment.Scenes;
33using OpenSim.Framework.Communications.Cache;
34using OpenSim.Region.ScriptEngine.Shared;
35
36namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
37{
38 public class SensorRepeat
39 {
40 public AsyncCommandManager m_CmdManager;
41
42 public SensorRepeat(AsyncCommandManager CmdManager)
43 {
44 m_CmdManager = CmdManager;
45 }
46
47 public Dictionary<uint, Dictionary<UUID, LSL_Types.list>> SenseEvents =
48 new Dictionary<uint, Dictionary<UUID, LSL_Types.list>>();
49 private Object SenseLock = new Object();
50
51 //
52 // SenseRepeater and Sensors
53 //
54 private class SenseRepeatClass
55 {
56 public uint localID;
57 public UUID itemID;
58 public double interval;
59 public DateTime next;
60
61 public string name;
62 public UUID keyID;
63 public int type;
64 public double range;
65 public double arc;
66 public SceneObjectPart host;
67 }
68
69 private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>();
70 private object SenseRepeatListLock = new object();
71
72 public void SetSenseRepeatEvent(uint m_localID, UUID m_itemID,
73 string name, UUID keyID, int type, double range, double arc, double sec, SceneObjectPart host)
74 {
75 #if SPAM
76 Console.WriteLine("SetSensorEvent");
77 #endif
78 // Always remove first, in case this is a re-set
79 UnSetSenseRepeaterEvents(m_localID, m_itemID);
80 if (sec == 0) // Disabling timer
81 return;
82
83 // Add to timer
84 SenseRepeatClass ts = new SenseRepeatClass();
85 ts.localID = m_localID;
86 ts.itemID = m_itemID;
87 ts.interval = sec;
88 ts.name = name;
89 ts.keyID = keyID;
90 ts.type = type;
91 ts.range = range;
92 ts.arc = arc;
93 ts.host = host;
94
95 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
96 lock (SenseRepeatListLock)
97 {
98 SenseRepeaters.Add(ts);
99 }
100 }
101
102 public void UnSetSenseRepeaterEvents(uint m_localID, UUID m_itemID)
103 {
104 // Remove from timer
105 lock (SenseRepeatListLock)
106 {
107 List<SenseRepeatClass> NewSensors = new List<SenseRepeatClass>();
108 foreach (SenseRepeatClass ts in SenseRepeaters)
109 {
110 if (ts.localID != m_localID && ts.itemID != m_itemID)
111 {
112 NewSensors.Add(ts);
113 }
114 }
115 SenseRepeaters.Clear();
116 SenseRepeaters = NewSensors;
117 }
118 }
119
120 public void CheckSenseRepeaterEvents()
121 {
122 // Nothing to do here?
123 if (SenseRepeaters.Count == 0)
124 return;
125
126 lock (SenseRepeatListLock)
127 {
128 // Go through all timers
129 foreach (SenseRepeatClass ts in SenseRepeaters)
130 {
131 // Time has passed?
132 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
133 {
134 SensorSweep(ts);
135 // set next interval
136 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
137 }
138 }
139 } // lock
140 }
141
142 public void SenseOnce(uint m_localID, UUID m_itemID,
143 string name, UUID keyID, int type,
144 double range, double arc, SceneObjectPart host)
145 {
146 // Add to timer
147 SenseRepeatClass ts = new SenseRepeatClass();
148 ts.localID = m_localID;
149 ts.itemID = m_itemID;
150 ts.interval = 0;
151 ts.name = name;
152 ts.keyID = keyID;
153 ts.type = type;
154 ts.range = range;
155 ts.arc = arc;
156 ts.host = host;
157 SensorSweep(ts);
158 }
159
160 public LSL_Types.list GetSensorList(uint m_localID, UUID m_itemID)
161 {
162 lock (SenseLock)
163 {
164 Dictionary<UUID, LSL_Types.list> Obj = null;
165 if (!SenseEvents.TryGetValue(m_localID, out Obj))
166 {
167 #if SPAM
168 m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing localID: " + m_localID);
169 #endif
170 return null;
171 }
172 lock (Obj)
173 {
174 // Get script
175 LSL_Types.list SenseList = null;
176 if (!Obj.TryGetValue(m_itemID, out SenseList))
177 {
178 #if SPAM
179 m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing itemID: " + m_itemID);
180 #endif
181 return null;
182 }
183 return SenseList;
184 }
185 }
186 }
187
188 private void SensorSweep(SenseRepeatClass ts)
189 {
190 //m_ScriptEngine.Log.Info("[AsyncLSL]:Enter SensorSweep");
191 SceneObjectPart SensePoint = ts.host;
192
193 if (SensePoint == null)
194 {
195
196 #if SPAM
197 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep (SensePoint == null) for "+ts.itemID.ToString());
198 #endif
199 return;
200 }
201 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep Scan");
202
203 Vector3 sensorPos = SensePoint.AbsolutePosition;
204 Vector3 regionPos = new Vector3(m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocX * Constants.RegionSize, m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocY * Constants.RegionSize, 0);
205 Vector3 fromRegionPos = sensorPos + regionPos;
206
207 Quaternion q = SensePoint.RotationOffset;
208 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
209 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
210 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
211
212 // Here we should do some smart culling ...
213 // math seems quicker than strings so try that first
214 LSL_Types.list SensedObjects = new LSL_Types.list();
215 LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0);
216
217 foreach (EntityBase ent in m_CmdManager.m_ScriptEngine.World.Entities.Values)
218 {
219 Vector3 toRegionPos = ent.AbsolutePosition + regionPos;
220 double dis = Math.Abs((double)Util.GetDistanceTo(toRegionPos, fromRegionPos));
221 if (dis <= ts.range)
222 {
223 // In Range, is it the right Type ?
224 int objtype = 0;
225
226 if (m_CmdManager.m_ScriptEngine.World.GetScenePresence(ent.UUID) != null) objtype |= 0x01; // actor
227 if (ent.Velocity.Equals(ZeroVector))
228 objtype |= 0x04; // passive non-moving
229 else
230 objtype |= 0x02; // active moving
231 if (ent is IScript) objtype |= 0x08; // Scripted. It COULD have one hidden ...
232
233 if (((ts.type & objtype) != 0) || ((ts.type & objtype) == ts.type))
234 {
235 // docs claim AGENT|ACTIVE should find agent objects OR active objects
236 // so the bitwise AND with object type should be non-zero
237
238 // Right type too, what about the other params , key and name ?
239 bool keep = true;
240 if (ts.arc < Math.PI)
241 {
242 // not omni-directional. Can you see it ?
243 // vec forward_dir = llRot2Fwd(llGetRot())
244 // vec obj_dir = toRegionPos-fromRegionPos
245 // dot=dot(forward_dir,obj_dir)
246 // mag_fwd = mag(forward_dir)
247 // mag_obj = mag(obj_dir)
248 // ang = acos(dot /(mag_fwd*mag_obj))
249 double ang_obj = 0;
250 try
251 {
252 Vector3 diff = toRegionPos - fromRegionPos;
253 LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z);
254 double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir);
255 double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
256 ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
257 }
258 catch
259 {
260 }
261
262 if (ang_obj > ts.arc) keep = false;
263 }
264
265 if (keep && (ts.keyID != UUID.Zero) && (ts.keyID != ent.UUID))
266 {
267 keep = false;
268 }
269
270 if (keep && (ts.name.Length > 0))
271 {
272 string avatarname=null;
273 string objectname=null;
274 string entname =ent.Name;
275
276 // try avatar username surname
277 CachedUserInfo profile = m_CmdManager.m_ScriptEngine.World.CommsManager.UserProfileCacheService.GetUserDetails(ent.UUID);
278 if (profile != null && profile.UserProfile != null)
279 {
280 avatarname = profile.UserProfile.FirstName + " " + profile.UserProfile.SurName;
281 }
282 // try an scene object
283 SceneObjectPart SOP = m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart(ent.UUID);
284 if (SOP != null)
285 {
286 objectname = SOP.Name;
287 }
288
289 if ((ts.name != entname) && (ts.name != avatarname) && (ts.name != objectname))
290 {
291 keep = false;
292 }
293 }
294
295 if (keep == true) SensedObjects.Add(ent.UUID);
296 }
297 }
298 }
299 #if SPAM
300 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep SenseLock");
301 #endif
302 lock (SenseLock)
303 {
304 // Create object if it doesn't exist
305 if (SenseEvents.ContainsKey(ts.localID) == false)
306 {
307 SenseEvents.Add(ts.localID, new Dictionary<UUID, LSL_Types.list>());
308 }
309 // clear if previous traces exist
310 Dictionary<UUID, LSL_Types.list> Obj;
311 SenseEvents.TryGetValue(ts.localID, out Obj);
312 if (Obj.ContainsKey(ts.itemID) == true)
313 Obj.Remove(ts.itemID);
314
315 // note list may be zero length
316 Obj.Add(ts.itemID, SensedObjects);
317
318 if (SensedObjects.Length == 0)
319 {
320 // send a "no_sensor"
321 // Add it to queue
322 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "no_sensor", EventQueueManager.llDetectNull,
323 new object[] { });
324 }
325 else
326 {
327 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "sensor", EventQueueManager.llDetectNull,
328 new object[] { new LSL_Types.LSLInteger(SensedObjects.Length) });
329 }
330 m_CmdManager.m_ScriptEngine.World.EventManager.TriggerTimerEvent(ts.localID, ts.interval);
331 }
332 }
333 }
334}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs
deleted file mode 100644
index 7940b36..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs
+++ /dev/null
@@ -1,139 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using OpenMetaverse;
32
33namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
34{
35 public class Timer
36 {
37 public AsyncCommandManager m_CmdManager;
38
39 public Timer(AsyncCommandManager CmdManager)
40 {
41 m_CmdManager = CmdManager;
42 }
43
44 //
45 // TIMER
46 //
47 private class TimerClass
48 {
49 public uint localID;
50 public UUID itemID;
51 //public double interval;
52 public long interval;
53 //public DateTime next;
54 public long next;
55 }
56
57 private List<TimerClass> Timers = new List<TimerClass>();
58 private object TimerListLock = new object();
59
60 public void SetTimerEvent(uint m_localID, UUID m_itemID, double sec)
61 {
62 // Console.WriteLine("SetTimerEvent");
63
64 // Always remove first, in case this is a re-set
65 UnSetTimerEvents(m_localID, m_itemID);
66 if (sec == 0) // Disabling timer
67 return;
68
69 // Add to timer
70 TimerClass ts = new TimerClass();
71 ts.localID = m_localID;
72 ts.itemID = m_itemID;
73 ts.interval = Convert.ToInt64(sec * 10000000); // How many 100 nanoseconds (ticks) should we wait
74 // 2193386136332921 ticks
75 // 219338613 seconds
76
77 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
78 ts.next = DateTime.Now.Ticks + ts.interval;
79 lock (TimerListLock)
80 {
81 Timers.Add(ts);
82 }
83 }
84
85 public void UnSetTimerEvents(uint m_localID, UUID m_itemID)
86 {
87 // Remove from timer
88 lock (TimerListLock)
89 {
90 foreach (TimerClass ts in new ArrayList(Timers))
91 {
92 if (ts.localID == m_localID && ts.itemID == m_itemID)
93 Timers.Remove(ts);
94 }
95 }
96
97 // Old method: Create new list
98 //List<TimerClass> NewTimers = new List<TimerClass>();
99 //foreach (TimerClass ts in Timers)
100 //{
101 // if (ts.localID != m_localID && ts.itemID != m_itemID)
102 // {
103 // NewTimers.Add(ts);
104 // }
105 //}
106 //Timers.Clear();
107 //Timers = NewTimers;
108 //}
109 }
110
111 public void CheckTimerEvents()
112 {
113 // Nothing to do here?
114 if (Timers.Count == 0)
115 return;
116
117 lock (TimerListLock)
118 {
119 // Go through all timers
120 foreach (TimerClass ts in Timers)
121 {
122 // Time has passed?
123 if (ts.next < DateTime.Now.Ticks)
124 {
125 // Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
126 // Add it to queue
127 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", EventQueueManager.llDetectNull,
128 null);
129 m_CmdManager.m_ScriptEngine.World.EventManager.TriggerTimerEvent(ts.localID, ((double)ts.interval / 10000000));
130 // set next interval
131
132 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
133 ts.next = DateTime.Now.Ticks + ts.interval;
134 }
135 }
136 }
137 }
138 }
139}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs
deleted file mode 100644
index 9a01cc4..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs
+++ /dev/null
@@ -1,130 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.Scripting.XMLRPC;
31using OpenSim.Region.ScriptEngine.Shared;
32
33namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
34{
35 public class XmlRequest
36 {
37 public AsyncCommandManager m_CmdManager;
38
39 public XmlRequest(AsyncCommandManager CmdManager)
40 {
41 m_CmdManager = CmdManager;
42 }
43
44 public void CheckXMLRPCRequests()
45 {
46 if (m_CmdManager.m_ScriptEngine.World == null)
47 return;
48
49 IXMLRPC xmlrpc = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
50 if (null == xmlrpc)
51 return;
52
53 // Process the completed request queue
54 RPCRequestInfo rInfo = xmlrpc.GetNextCompletedRequest();
55
56 while (rInfo != null)
57 {
58 bool handled = false;
59
60 // Request must be taken out of the queue in case there is no handler, otherwise we loop infinitely
61 xmlrpc.RemoveCompletedRequest(rInfo.GetMessageID());
62
63 // And since the xmlrpc request queue is actually shared among all regions on the simulator, we need
64 // to look in each one for the appropriate handler
65 foreach (ScriptEngine sman in ScriptEngine.ScriptEngines) {
66 if (sman.m_ScriptManager.GetScript(rInfo.GetLocalID(),rInfo.GetItemID()) != null) {
67
68 //Deliver data to prim's remote_data handler
69 object[] resobj = new object[]
70 {
71 new LSL_Types.LSLInteger(2), new LSL_Types.LSLString(rInfo.GetChannelKey().ToString()), new LSL_Types.LSLString(rInfo.GetMessageID().ToString()), new LSL_Types.LSLString(String.Empty),
72 new LSL_Types.LSLInteger(rInfo.GetIntValue()),
73 new LSL_Types.LSLString(rInfo.GetStrVal())
74 };
75 sman.m_EventQueueManager.AddToScriptQueue(
76 rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", EventQueueManager.llDetectNull, resobj
77 );
78
79 handled = true;
80 }
81 }
82
83 if (! handled)
84 {
85 Console.WriteLine("Unhandled xml_request: " + rInfo.GetItemID());
86 }
87
88 rInfo = xmlrpc.GetNextCompletedRequest();
89 }
90
91 // Process the send queue
92 SendRemoteDataRequest srdInfo = xmlrpc.GetNextCompletedSRDRequest();
93
94 while (srdInfo != null)
95 {
96 bool handled = false;
97
98 // Request must be taken out of the queue in case there is no handler, otherwise we loop infinitely
99 xmlrpc.RemoveCompletedSRDRequest(srdInfo.GetReqID());
100
101 // And this is another shared queue... so we check each of the script engines for a handler
102 foreach (ScriptEngine sman in ScriptEngine.ScriptEngines)
103 {
104 if (sman.m_ScriptManager.GetScript(srdInfo.m_localID,srdInfo.m_itemID) != null) {
105
106 //Deliver data to prim's remote_data handler
107 object[] resobj = new object[]
108 {
109 new LSL_Types.LSLInteger(3), new LSL_Types.LSLString(srdInfo.channel.ToString()), new LSL_Types.LSLString(srdInfo.GetReqID().ToString()), new LSL_Types.LSLString(String.Empty),
110 new LSL_Types.LSLInteger(srdInfo.idata),
111 new LSL_Types.LSLString(srdInfo.sdata)
112 };
113 sman.m_EventQueueManager.AddToScriptQueue(
114 srdInfo.m_localID, srdInfo.m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj
115 );
116
117 handled = true;
118 }
119 }
120
121 if (! handled)
122 {
123 Console.WriteLine("Unhandled xml_srdrequest: " + srdInfo.GetReqID());
124 }
125
126 srdInfo = xmlrpc.GetNextCompletedSRDRequest();
127 }
128 }
129 }
130}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
index d52b642..c8c9cd8 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
@@ -114,83 +114,103 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
114 public void changed(uint localID, uint change) 114 public void changed(uint localID, uint change)
115 { 115 {
116 // Add to queue for all scripts in localID, Object pass change. 116 // Add to queue for all scripts in localID, Object pass change.
117 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "changed", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(change) }); 117 myScriptEngine.PostObjectEvent(localID, new EventParams(
118 "changed",new object[] { new LSL_Types.LSLInteger(change) },
119 new DetectParams[0]));
118 } 120 }
119 121
120 public void state_entry(uint localID) 122 public void state_entry(uint localID)
121 { 123 {
122 // Add to queue for all scripts in ObjectID object 124 // Add to queue for all scripts in ObjectID object
123 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "state_entry", EventQueueManager.llDetectNull, new object[] { }); 125 myScriptEngine.PostObjectEvent(localID, new EventParams(
126 "state_entry",new object[] { },
127 new DetectParams[0]));
124 } 128 }
125 129
126 public void touch_start(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient) 130 public void touch_start(uint localID, uint originalID, Vector3 offsetPos,
131 IClientAPI remoteClient)
127 { 132 {
128 // Add to queue for all scripts in ObjectID object 133 // Add to queue for all scripts in ObjectID object
129 EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); 134 DetectParams[] det = new DetectParams[1];
130 detstruct._key = new LSL_Types.key[1]; 135 det[0] = new DetectParams();
131 detstruct._key2 = new LSL_Types.key[1]; 136 det[0].Key = remoteClient.AgentId;
132 detstruct._string = new string[1]; 137 det[0].Populate(myScriptEngine.World);
133 detstruct._Vector3 = new LSL_Types.Vector3[1]; 138
134 detstruct._Vector32 = new LSL_Types.Vector3[1]; 139 if (originalID == 0)
135 detstruct._Quaternion = new LSL_Types.Quaternion[1]; 140 {
136 detstruct._int = new int[1]; 141 SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID);
137 ScenePresence av = myScriptEngine.World.GetScenePresence(remoteClient.AgentId); 142 if (part == null)
138 if (av != null) 143 return;
144
145 det[0].LinkNum = part.LinkNum;
146 }
147 else
148 {
149 SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID);
150 det[0].LinkNum = originalPart.LinkNum;
151 }
152
153 myScriptEngine.PostObjectEvent(localID, new EventParams(
154 "touch_start", new Object[] { new LSL_Types.LSLInteger(1) },
155 det));
156 }
157
158 public void touch(uint localID, uint originalID, Vector3 offsetPos,
159 IClientAPI remoteClient)
160 {
161 // Add to queue for all scripts in ObjectID object
162 DetectParams[] det = new DetectParams[1];
163 det[0] = new DetectParams();
164 det[0].Key = remoteClient.AgentId;
165 det[0].Populate(myScriptEngine.World);
166 det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X,
167 offsetPos.Y,
168 offsetPos.Z);
169
170 if (originalID == 0)
139 { 171 {
140 detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); 172 SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID);
141 detstruct._key2[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); 173 if (part == null)
142 detstruct._string[0] = remoteClient.Name; 174 return;
143 detstruct._int[0] = 0; 175
144 detstruct._Quaternion[0] = new LSL_Types.Quaternion(av.Rotation.X,av.Rotation.Y,av.Rotation.Z,av.Rotation.W); 176 det[0].LinkNum = part.LinkNum;
145 detstruct._Vector3[0] = new LSL_Types.Vector3(av.AbsolutePosition.X,av.AbsolutePosition.Y,av.AbsolutePosition.Z);
146 detstruct._Vector32[0] = new LSL_Types.Vector3(av.Velocity.X,av.Velocity.Y,av.Velocity.Z);
147 } 177 }
148 else 178 else
149 { 179 {
150 detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); 180 SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID);
151 detstruct._key2[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); 181 det[0].LinkNum = originalPart.LinkNum;
152 detstruct._string[0] = remoteClient.Name;
153 detstruct._int[0] = 0;
154 detstruct._Quaternion[0] = new LSL_Types.Quaternion(0, 0, 0, 1);
155 detstruct._Vector3[0] = new LSL_Types.Vector3(0, 0, 0);
156 detstruct._Vector32[0] = new LSL_Types.Vector3(0, 0, 0);
157 } 182 }
158 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", detstruct, new object[] { new LSL_Types.LSLInteger(1) }); 183
184 myScriptEngine.PostObjectEvent(localID, new EventParams(
185 "touch", new Object[] { new LSL_Types.LSLInteger(1) },
186 det));
159 } 187 }
160 188
161 public void touch_end(uint localID, uint originalID, IClientAPI remoteClient) 189 public void touch_end(uint localID, uint originalID, IClientAPI remoteClient)
162 { 190 {
163 // Add to queue for all scripts in ObjectID object 191 // Add to queue for all scripts in ObjectID object
164 EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); 192 DetectParams[] det = new DetectParams[1];
165 detstruct._key = new LSL_Types.key[1]; 193 det[0] = new DetectParams();
166 detstruct._key2 = new LSL_Types.key[1]; 194 det[0].Key = remoteClient.AgentId;
167 detstruct._string = new string[1]; 195 det[0].Populate(myScriptEngine.World);
168 detstruct._Vector3 = new LSL_Types.Vector3[1]; 196
169 detstruct._Vector32 = new LSL_Types.Vector3[1]; 197 if (originalID == 0)
170 detstruct._Quaternion = new LSL_Types.Quaternion[1];
171 detstruct._int = new int[1];
172 ScenePresence av = myScriptEngine.World.GetScenePresence(remoteClient.AgentId);
173 if (av != null)
174 { 198 {
175 detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); 199 SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID);
176 detstruct._key2[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); 200 if (part == null)
177 detstruct._string[0] = remoteClient.Name; 201 return;
178 detstruct._int[0] = 0; 202
179 detstruct._Quaternion[0] = new LSL_Types.Quaternion(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W); 203 det[0].LinkNum = part.LinkNum;
180 detstruct._Vector3[0] = new LSL_Types.Vector3(av.AbsolutePosition.X, av.AbsolutePosition.Y, av.AbsolutePosition.Z);
181 detstruct._Vector32[0] = new LSL_Types.Vector3(av.Velocity.X, av.Velocity.Y, av.Velocity.Z);
182 } 204 }
183 else 205 else
184 { 206 {
185 detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); 207 SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID);
186 detstruct._key2[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); 208 det[0].LinkNum = originalPart.LinkNum;
187 detstruct._string[0] = remoteClient.Name;
188 detstruct._int[0] = 0;
189 detstruct._Quaternion[0] = new LSL_Types.Quaternion(0, 0, 0, 1);
190 detstruct._Vector3[0] = new LSL_Types.Vector3(0, 0, 0);
191 detstruct._Vector32[0] = new LSL_Types.Vector3(0, 0, 0);
192 } 209 }
193 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { new LSL_Types.LSLInteger(1) }); 210
211 myScriptEngine.PostObjectEvent(localID, new EventParams(
212 "touch_end", new Object[] { new LSL_Types.LSLInteger(1) },
213 det));
194 } 214 }
195 215
196 public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine) 216 public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
@@ -228,7 +248,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
228 248
229 public void money(uint localID, UUID agentID, int amount) 249 public void money(uint localID, UUID agentID, int amount)
230 { 250 {
231 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "money", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLString(agentID.ToString()), new LSL_Types.LSLInteger(amount) }); 251 myScriptEngine.PostObjectEvent(localID, new EventParams(
252 "money", new object[] {
253 new LSL_Types.LSLString(agentID.ToString()),
254 new LSL_Types.LSLInteger(amount) },
255 new DetectParams[0]));
232 } 256 }
233 257
234 // TODO: Replace placeholders below 258 // TODO: Replace placeholders below
@@ -239,225 +263,196 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
239 263
240 public void state_exit(uint localID) 264 public void state_exit(uint localID)
241 { 265 {
242 // Add to queue for all scripts in ObjectID object 266 myScriptEngine.PostObjectEvent(localID, new EventParams(
243 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "state_exit", EventQueueManager.llDetectNull, new object[] { }); 267 "state_exit", new object[] { },
244 } 268 new DetectParams[0]));
245
246 public void touch(uint localID, uint originalID, UUID itemID)
247 {
248 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch", EventQueueManager.llDetectNull);
249 }
250
251 public void touch_end(uint localID, uint originalID, UUID itemID)
252 {
253 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(1) });
254 } 269 }
255 270
256 public void collision_start(uint localID, ColliderArgs col) 271 public void collision_start(uint localID, ColliderArgs col)
257 { 272 {
258 EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); 273 // Add to queue for all scripts in ObjectID object
259 detstruct._string = new string[col.Colliders.Count]; 274 List<DetectParams> det = new List<DetectParams>();
260 detstruct._Quaternion = new LSL_Types.Quaternion[col.Colliders.Count]; 275
261 detstruct._int = new int[col.Colliders.Count];
262 detstruct._key = new LSL_Types.key[col.Colliders.Count];
263 detstruct._key2 = new LSL_Types.key[col.Colliders.Count];
264 detstruct._Vector3 = new LSL_Types.Vector3[col.Colliders.Count];
265 detstruct._Vector32 = new LSL_Types.Vector3[col.Colliders.Count];
266 detstruct._bool = new bool[col.Colliders.Count];
267
268 int i = 0;
269 foreach (DetectedObject detobj in col.Colliders) 276 foreach (DetectedObject detobj in col.Colliders)
270 { 277 {
271 detstruct._key[i] = new LSL_Types.key(detobj.keyUUID.ToString()); 278 DetectParams d = new DetectParams();
272 detstruct._key2[i] = new LSL_Types.key(detobj.ownerUUID.ToString()); 279 d.Key =detobj.keyUUID;
273 detstruct._Quaternion[i] = new LSL_Types.Quaternion(detobj.rotQuat.X, detobj.rotQuat.Y, detobj.rotQuat.Z, detobj.rotQuat.W); 280 d.Populate(myScriptEngine.World);
274 detstruct._string[i] = detobj.nameStr; 281 det.Add(d);
275 detstruct._int[i] = detobj.colliderType;
276 detstruct._Vector3[i] = new LSL_Types.Vector3(detobj.posVector.X, detobj.posVector.Y, detobj.posVector.Z);
277 detstruct._Vector32[i] = new LSL_Types.Vector3(detobj.velVector.X, detobj.velVector.Y, detobj.velVector.Z);
278 detstruct._bool[i] = true; // Apparently the script engine uses this to see if this is a valid entry...
279 i++;
280 } 282 }
281 283
282 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "collision_start", detstruct, new object[] { new LSL_Types.LSLInteger(col.Colliders.Count) }); 284 if (det.Count > 0)
285 myScriptEngine.PostObjectEvent(localID, new EventParams(
286 "collision_start",
287 new Object[] { new LSL_Types.LSLInteger(det.Count) },
288 det.ToArray()));
283 } 289 }
284 290
285 public void collision(uint localID, ColliderArgs col) 291 public void collision(uint localID, ColliderArgs col)
286 { 292 {
287 EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); 293 // Add to queue for all scripts in ObjectID object
288 detstruct._string = new string[col.Colliders.Count]; 294 List<DetectParams> det = new List<DetectParams>();
289 detstruct._Quaternion = new LSL_Types.Quaternion[col.Colliders.Count]; 295
290 detstruct._int = new int[col.Colliders.Count];
291 detstruct._key = new LSL_Types.key[col.Colliders.Count];
292 detstruct._key2 = new LSL_Types.key[col.Colliders.Count];
293 detstruct._Vector3 = new LSL_Types.Vector3[col.Colliders.Count];
294 detstruct._Vector32 = new LSL_Types.Vector3[col.Colliders.Count];
295 detstruct._bool = new bool[col.Colliders.Count];
296
297 int i = 0;
298 foreach (DetectedObject detobj in col.Colliders) 296 foreach (DetectedObject detobj in col.Colliders)
299 { 297 {
300 detstruct._key[i] = new LSL_Types.key(detobj.keyUUID.ToString()); 298 DetectParams d = new DetectParams();
301 detstruct._key2[i] = new LSL_Types.key(detobj.ownerUUID.ToString()); 299 d.Key =detobj.keyUUID;
302 detstruct._Quaternion[i] = new LSL_Types.Quaternion(detobj.rotQuat.X, detobj.rotQuat.Y, detobj.rotQuat.Z, detobj.rotQuat.W); 300 d.Populate(myScriptEngine.World);
303 detstruct._string[i] = detobj.nameStr; 301 det.Add(d);
304 detstruct._int[i] = detobj.colliderType;
305 detstruct._Vector3[i] = new LSL_Types.Vector3(detobj.posVector.X, detobj.posVector.Y, detobj.posVector.Z);
306 detstruct._Vector32[i] = new LSL_Types.Vector3(detobj.velVector.X, detobj.velVector.Y, detobj.velVector.Z);
307 detstruct._bool[i] = true; // Apparently the script engine uses this to see if this is a valid entry... i++;
308 } 302 }
309 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "collision", detstruct, new object[] { new LSL_Types.LSLInteger(col.Colliders.Count) }); 303
304 if (det.Count > 0)
305 myScriptEngine.PostObjectEvent(localID, new EventParams(
306 "collision", new Object[] { new LSL_Types.LSLInteger(det.Count) },
307 det.ToArray()));
310 } 308 }
311 309
312 public void collision_end(uint localID, ColliderArgs col) 310 public void collision_end(uint localID, ColliderArgs col)
313 { 311 {
314 EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); 312 // Add to queue for all scripts in ObjectID object
315 detstruct._string = new string[col.Colliders.Count]; 313 List<DetectParams> det = new List<DetectParams>();
316 detstruct._Quaternion = new LSL_Types.Quaternion[col.Colliders.Count]; 314
317 detstruct._int = new int[col.Colliders.Count];
318 detstruct._key = new LSL_Types.key[col.Colliders.Count];
319 detstruct._key2 = new LSL_Types.key[col.Colliders.Count];
320 detstruct._Vector3 = new LSL_Types.Vector3[col.Colliders.Count];
321 detstruct._Vector32 = new LSL_Types.Vector3[col.Colliders.Count];
322 detstruct._bool = new bool[col.Colliders.Count];
323
324 int i = 0;
325 foreach (DetectedObject detobj in col.Colliders) 315 foreach (DetectedObject detobj in col.Colliders)
326 { 316 {
327 detstruct._key[i] = new LSL_Types.key(detobj.keyUUID.ToString()); 317 DetectParams d = new DetectParams();
328 detstruct._key2[i] = new LSL_Types.key(detobj.ownerUUID.ToString()); 318 d.Key =detobj.keyUUID;
329 detstruct._Quaternion[i] = new LSL_Types.Quaternion(detobj.rotQuat.X, detobj.rotQuat.Y, detobj.rotQuat.Z, detobj.rotQuat.W); 319 d.Populate(myScriptEngine.World);
330 detstruct._string[i] = detobj.nameStr; 320 det.Add(d);
331 detstruct._int[i] = detobj.colliderType;
332 detstruct._Vector3[i] = new LSL_Types.Vector3(detobj.posVector.X, detobj.posVector.Y, detobj.posVector.Z);
333 detstruct._Vector32[i] = new LSL_Types.Vector3(detobj.velVector.X, detobj.velVector.Y, detobj.velVector.Z);
334 detstruct._bool[i] = true; // Apparently the script engine uses this to see if this is a valid entry...
335 i++;
336 } 321 }
337 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "collision_end", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(col.Colliders.Count) }); 322
323 if (det.Count > 0)
324 myScriptEngine.PostObjectEvent(localID, new EventParams(
325 "collision_end",
326 new Object[] { new LSL_Types.LSLInteger(det.Count) },
327 det.ToArray()));
338 } 328 }
339 329
340 public void land_collision_start(uint localID, UUID itemID) 330 public void land_collision_start(uint localID, UUID itemID)
341 { 331 {
342 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_start", EventQueueManager.llDetectNull); 332 myScriptEngine.PostObjectEvent(localID, new EventParams(
333 "land_collision_start",
334 new object[0],
335 new DetectParams[0]));
343 } 336 }
344 337
345 public void land_collision(uint localID, ColliderArgs col) 338 public void land_collision(uint localID, UUID itemID)
346 { 339 {
347 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "land_collision", EventQueueManager.llDetectNull); 340 myScriptEngine.PostObjectEvent(localID, new EventParams(
341 "land_collision",
342 new object[0],
343 new DetectParams[0]));
348 } 344 }
349 345
350 public void land_collision_end(uint localID, UUID itemID) 346 public void land_collision_end(uint localID, UUID itemID)
351 { 347 {
352 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_end", EventQueueManager.llDetectNull); 348 myScriptEngine.PostObjectEvent(localID, new EventParams(
349 "land_collision_end",
350 new object[0],
351 new DetectParams[0]));
353 } 352 }
354 353
355 // Handled by long commands 354 // Handled by long commands
356 public void timer(uint localID, UUID itemID) 355 public void timer(uint localID, UUID itemID)
357 { 356 {
358 //myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, String.Empty);
359 } 357 }
360 358
361 public void listen(uint localID, UUID itemID) 359 public void listen(uint localID, UUID itemID)
362 { 360 {
363 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "listen", EventQueueManager.llDetectNull);
364 }
365
366 public void on_rez(uint localID, UUID itemID)
367 {
368 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez", EventQueueManager.llDetectNull);
369 }
370
371 public void sensor(uint localID, UUID itemID)
372 {
373 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "sensor", EventQueueManager.llDetectNull);
374 }
375
376 public void no_sensor(uint localID, UUID itemID)
377 {
378 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor", EventQueueManager.llDetectNull);
379 } 361 }
380 362
381 public void control(uint localID, UUID itemID, UUID agentID, uint held, uint change) 363 public void control(uint localID, UUID itemID, UUID agentID, uint held, uint change)
382 { 364 {
383 if ((change == 0) && (myScriptEngine.m_EventQueueManager.CheckEeventQueueForEvent(localID,"control"))) return; 365 if ((change == 0) && (myScriptEngine.m_EventQueueManager.CheckEeventQueueForEvent(localID,"control"))) return;
384 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLString(agentID.ToString()), new LSL_Types.LSLInteger(held), new LSL_Types.LSLInteger(change)}); 366 myScriptEngine.PostObjectEvent(localID, new EventParams(
367 "control",new object[] {
368 new LSL_Types.LSLString(agentID.ToString()),
369 new LSL_Types.LSLInteger(held),
370 new LSL_Types.LSLInteger(change)},
371 new DetectParams[0]));
385 } 372 }
386 373
387 public void email(uint localID, UUID itemID) 374 public void email(uint localID, UUID itemID, string timeSent,
375 string address, string subject, string message, int numLeft)
388 { 376 {
389 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "email", EventQueueManager.llDetectNull); 377 myScriptEngine.PostObjectEvent(localID, new EventParams(
378 "email",new object[] {
379 new LSL_Types.LSLString(timeSent),
380 new LSL_Types.LSLString(address),
381 new LSL_Types.LSLString(subject),
382 new LSL_Types.LSLString(message),
383 new LSL_Types.LSLInteger(numLeft)},
384 new DetectParams[0]));
390 } 385 }
391 386
392 public void at_target(uint localID, uint handle, Vector3 targetpos, Vector3 atpos) 387 public void at_target(uint localID, uint handle, Vector3 targetpos,
388 Vector3 atpos)
393 { 389 {
394 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "at_target", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(handle), new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) }); 390 myScriptEngine.PostObjectEvent(localID, new EventParams(
391 "at_target", new object[] {
392 new LSL_Types.LSLInteger(handle),
393 new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z),
394 new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) },
395 new DetectParams[0]));
395 } 396 }
396 397
397 public void not_at_target(uint localID) 398 public void not_at_target(uint localID)
398 { 399 {
399 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "not_at_target", EventQueueManager.llDetectNull); 400 myScriptEngine.PostObjectEvent(localID, new EventParams(
401 "not_at_target",new object[0],
402 new DetectParams[0]));
400 } 403 }
401 404
402 public void at_rot_target(uint localID, UUID itemID) 405 public void at_rot_target(uint localID, UUID itemID)
403 { 406 {
404 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_rot_target", EventQueueManager.llDetectNull); 407 myScriptEngine.PostObjectEvent(localID, new EventParams(
408 "at_rot_target",new object[0],
409 new DetectParams[0]));
405 } 410 }
406 411
407 public void not_at_rot_target(uint localID, UUID itemID) 412 public void not_at_rot_target(uint localID, UUID itemID)
408 { 413 {
409 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_rot_target", EventQueueManager.llDetectNull); 414 myScriptEngine.PostObjectEvent(localID, new EventParams(
410 } 415 "not_at_rot_target",new object[0],
411 416 new DetectParams[0]));
412 public void run_time_permissions(uint localID, UUID itemID)
413 {
414 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "run_time_permissions", EventQueueManager.llDetectNull);
415 }
416
417 public void changed(uint localID, UUID itemID)
418 {
419 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "changed", EventQueueManager.llDetectNull);
420 } 417 }
421 418
422 public void attach(uint localID, UUID itemID) 419 public void attach(uint localID, UUID itemID)
423 { 420 {
424 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "attach", EventQueueManager.llDetectNull);
425 } 421 }
426 422
427 public void dataserver(uint localID, UUID itemID) 423 public void dataserver(uint localID, UUID itemID)
428 { 424 {
429 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "dataserver", EventQueueManager.llDetectNull);
430 } 425 }
431 426
432 public void link_message(uint localID, UUID itemID) 427 public void link_message(uint localID, UUID itemID)
433 { 428 {
434 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "link_message", EventQueueManager.llDetectNull);
435 } 429 }
436 430
437 public void moving_start(uint localID, UUID itemID) 431 public void moving_start(uint localID, UUID itemID)
438 { 432 {
439 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_start", EventQueueManager.llDetectNull); 433 myScriptEngine.PostObjectEvent(localID, new EventParams(
434 "moving_start",new object[0],
435 new DetectParams[0]));
440 } 436 }
441 437
442 public void moving_end(uint localID, UUID itemID) 438 public void moving_end(uint localID, UUID itemID)
443 { 439 {
444 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_end", EventQueueManager.llDetectNull); 440 myScriptEngine.PostObjectEvent(localID, new EventParams(
441 "moving_end",new object[0],
442 new DetectParams[0]));
445 } 443 }
446 444
447 public void object_rez(uint localID, UUID itemID) 445 public void object_rez(uint localID, UUID itemID)
448 { 446 {
449 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "object_rez", EventQueueManager.llDetectNull);
450 } 447 }
451 448
452 public void remote_data(uint localID, UUID itemID) 449 public void remote_data(uint localID, UUID itemID)
453 { 450 {
454 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "remote_data", EventQueueManager.llDetectNull);
455 } 451 }
456 452
457 // Handled by long commands 453 // Handled by long commands
458 public void http_response(uint localID, UUID itemID) 454 public void http_response(uint localID, UUID itemID)
459 { 455 {
460 // myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "http_response", EventQueueManager.llDetectNull);
461 } 456 }
462 457
463 /// <summary> 458 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
index 8c7834a..b13ab21 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
@@ -137,32 +137,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
137 public uint localID; 137 public uint localID;
138 public UUID itemID; 138 public UUID itemID;
139 public string functionName; 139 public string functionName;
140 public Queue_llDetectParams_Struct llDetectParams; 140 public DetectParams[] llDetectParams;
141 public object[] param; 141 public object[] param;
142 } 142 }
143 143
144 /// <summary>
145 /// Shared empty llDetectNull
146 /// </summary>
147 public readonly static Queue_llDetectParams_Struct llDetectNull = new Queue_llDetectParams_Struct();
148
149 /// <summary>
150 /// Structure to hold data for llDetect* commands
151 /// </summary>
152 [Serializable]
153 public struct Queue_llDetectParams_Struct
154 {
155 // More or less just a placeholder for the actual moving of additional data
156 // should be fixed to something better :)
157 public LSL_Types.key[] _key; // detected key
158 public LSL_Types.key[] _key2; // ownerkey
159 public LSL_Types.Quaternion[] _Quaternion;
160 public LSL_Types.Vector3[] _Vector3; // Pos
161 public LSL_Types.Vector3[] _Vector32; // Vel
162 public bool[] _bool;
163 public int[] _int;
164 public string[] _string;
165 }
166 #endregion 144 #endregion
167 145
168 #region " Initialization / Startup " 146 #region " Initialization / Startup "
@@ -322,7 +300,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
322 /// <param name="localID">Region object ID</param> 300 /// <param name="localID">Region object ID</param>
323 /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param> 301 /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
324 /// <param name="param">Array of parameters to match event mask</param> 302 /// <param name="param">Array of parameters to match event mask</param>
325 public bool AddToObjectQueue(uint localID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param) 303 public bool AddToObjectQueue(uint localID, string FunctionName, DetectParams[] qParams, params object[] param)
326 { 304 {
327 // Determine all scripts in Object and add to their queue 305 // Determine all scripts in Object and add to their queue
328 //myScriptEngine.log.Info("[" + ScriptEngineName + "]: EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName); 306 //myScriptEngine.log.Info("[" + ScriptEngineName + "]: EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
@@ -353,7 +331,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
353 /// <param name="itemID">Region script ID</param> 331 /// <param name="itemID">Region script ID</param>
354 /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param> 332 /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
355 /// <param name="param">Array of parameters to match event mask</param> 333 /// <param name="param">Array of parameters to match event mask</param>
356 public bool AddToScriptQueue(uint localID, UUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param) 334 public bool AddToScriptQueue(uint localID, UUID itemID, string FunctionName, DetectParams[] qParams, params object[] param)
357 { 335 {
358 List<UUID> keylist = m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID); 336 List<UUID> keylist = m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
359 337
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
index c972683..b09a30b 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
@@ -57,7 +57,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
57 public EventQueueManager m_EventQueueManager; // Executes events, handles script threads 57 public EventQueueManager m_EventQueueManager; // Executes events, handles script threads
58 public ScriptManager m_ScriptManager; // Load, unload and execute scripts 58 public ScriptManager m_ScriptManager; // Load, unload and execute scripts
59 public AppDomainManager m_AppDomainManager; // Handles loading/unloading of scripts into AppDomains 59 public AppDomainManager m_AppDomainManager; // Handles loading/unloading of scripts into AppDomains
60 public AsyncCommandManager m_ASYNCLSLCommandManager; // Asyncronous LSL commands (commands that returns with an event)
61 public static MaintenanceThread m_MaintenanceThread; // Thread that does different kinds of maintenance, for example refreshing config and killing scripts that has been running too long 60 public static MaintenanceThread m_MaintenanceThread; // Thread that does different kinds of maintenance, for example refreshing config and killing scripts that has been running too long
62 61
63 public IConfigSource ConfigSource; 62 public IConfigSource ConfigSource;
@@ -121,7 +120,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
121 // We need to start it 120 // We need to start it
122 m_ScriptManager = newScriptManager; 121 m_ScriptManager = newScriptManager;
123 m_AppDomainManager = new AppDomainManager(this); 122 m_AppDomainManager = new AppDomainManager(this);
124 m_ASYNCLSLCommandManager = new AsyncCommandManager(this);
125 if (m_MaintenanceThread == null) 123 if (m_MaintenanceThread == null)
126 m_MaintenanceThread = new MaintenanceThread(); 124 m_MaintenanceThread = new MaintenanceThread();
127 125
@@ -172,7 +170,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
172 if (m_EventManager != null) m_EventManager.ReadConfig(); 170 if (m_EventManager != null) m_EventManager.ReadConfig();
173 if (m_ScriptManager != null) m_ScriptManager.ReadConfig(); 171 if (m_ScriptManager != null) m_ScriptManager.ReadConfig();
174 if (m_AppDomainManager != null) m_AppDomainManager.ReadConfig(); 172 if (m_AppDomainManager != null) m_AppDomainManager.ReadConfig();
175 if (m_ASYNCLSLCommandManager != null) m_ASYNCLSLCommandManager.ReadConfig();
176 if (m_MaintenanceThread != null) m_MaintenanceThread.ReadConfig(); 173 if (m_MaintenanceThread != null) m_MaintenanceThread.ReadConfig();
177 } 174 }
178 175
@@ -196,15 +193,33 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
196 193
197 public bool PostObjectEvent(uint localID, EventParams p) 194 public bool PostObjectEvent(uint localID, EventParams p)
198 { 195 {
199 return m_EventQueueManager.AddToObjectQueue(localID, p.EventName, EventQueueManager.llDetectNull, p.Params); 196 return m_EventQueueManager.AddToObjectQueue(localID, p.EventName, p.DetectParams, p.Params);
200 } 197 }
201 198
202 public bool PostScriptEvent(UUID itemID, EventParams p) 199 public bool PostScriptEvent(UUID itemID, EventParams p)
203 { 200 {
204 uint localID = m_ScriptManager.GetLocalID(itemID); 201 uint localID = m_ScriptManager.GetLocalID(itemID);
205 return m_EventQueueManager.AddToScriptQueue(localID, itemID, p.EventName, EventQueueManager.llDetectNull, p.Params); 202 return m_EventQueueManager.AddToScriptQueue(localID, itemID, p.EventName, p.DetectParams, p.Params);
206 } 203 }
207 204
205 public DetectParams GetDetectParams(UUID itemID, int number)
206 {
207 uint localID = m_ScriptManager.GetLocalID(itemID);
208 if (localID == 0)
209 return null;
210
211 IScript Script = m_ScriptManager.GetScript(localID, itemID);
212
213 if (Script == null)
214 return null;
215
216 DetectParams[] det = m_ScriptManager.GetDetectParams(Script);
217
218 if (number < 0 || number >= det.Length)
219 return null;
220
221 return det[number];
222 }
208 #endregion 223 #endregion
209 } 224 }
210} 225}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
index ff8e16f..095e11f 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
@@ -33,6 +33,7 @@ using System.Runtime.Serialization.Formatters.Binary;
33using System.Threading; 33using System.Threading;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
36using OpenSim.Region.ScriptEngine.Shared;
36 37
37namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase 38namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
38{ 39{
@@ -65,6 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
65 private int LoadUnloadMaxQueueSize; 66 private int LoadUnloadMaxQueueSize;
66 private Object scriptLock = new Object(); 67 private Object scriptLock = new Object();
67 private bool m_started = false; 68 private bool m_started = false;
69 private Dictionary<IScript, DetectParams[]> detparms = new Dictionary<IScript, DetectParams[]>();
68 70
69 // Load/Unload structure 71 // Load/Unload structure
70 private struct LUStruct 72 private struct LUStruct
@@ -228,6 +230,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
228 if (item.Action == LUType.Unload) 230 if (item.Action == LUType.Unload)
229 { 231 {
230 _StopScript(item.localID, item.itemID); 232 _StopScript(item.localID, item.itemID);
233 RemoveScript(item.localID, item.itemID);
231 } 234 }
232 else if (item.Action == LUType.Load) 235 else if (item.Action == LUType.Load)
233 { 236 {
@@ -318,7 +321,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
318 /// <param name="itemID">Script ID</param> 321 /// <param name="itemID">Script ID</param>
319 /// <param name="FunctionName">Name of function</param> 322 /// <param name="FunctionName">Name of function</param>
320 /// <param name="args">Arguments to pass to function</param> 323 /// <param name="args">Arguments to pass to function</param>
321 internal void ExecuteEvent(uint localID, UUID itemID, string FunctionName, EventQueueManager.Queue_llDetectParams_Struct qParams, object[] args) 324 internal void ExecuteEvent(uint localID, UUID itemID, string FunctionName, DetectParams[] qParams, object[] args)
322 { 325 {
323 //cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined 326 //cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined
324 ///#if DEBUG 327 ///#if DEBUG
@@ -337,8 +340,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
337 /// Console.WriteLine("ScriptEngine: Executing event: " + FunctionName); 340 /// Console.WriteLine("ScriptEngine: Executing event: " + FunctionName);
338 ///#endif 341 ///#endif
339 // Must be done in correct AppDomain, so leaving it up to the script itself 342 // Must be done in correct AppDomain, so leaving it up to the script itself
340 Script.llDetectParams = qParams; 343 detparms[Script] = qParams;
341 Script.Exec.ExecuteEvent(FunctionName, args); 344 Script.Exec.ExecuteEvent(FunctionName, args);
345 detparms.Remove(Script);
342 } 346 }
343 347
344 public uint GetLocalID(UUID itemID) 348 public uint GetLocalID(UUID itemID)
@@ -430,6 +434,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
430 434
431 public void RemoveScript(uint localID, UUID itemID) 435 public void RemoveScript(uint localID, UUID itemID)
432 { 436 {
437 if (localID == 0)
438 localID = GetLocalID(itemID);
439
433 // Don't have that object? 440 // Don't have that object?
434 if (Scripts.ContainsKey(localID) == false) 441 if (Scripts.ContainsKey(localID) == false)
435 return; 442 return;
@@ -486,5 +493,13 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
486 // set { _PleaseShutdown = value; } 493 // set { _PleaseShutdown = value; }
487 //} 494 //}
488 //private bool _PleaseShutdown = false; 495 //private bool _PleaseShutdown = false;
496
497 public DetectParams[] GetDetectParams(IScript script)
498 {
499 if (detparms.ContainsKey(script))
500 return detparms[script];
501
502 return null;
503 }
489 } 504 }
490} 505}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
index aa8dc61..14eef15 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
@@ -30,6 +30,7 @@ using Nini.Config;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Region.Environment.Scenes; 31using OpenSim.Region.Environment.Scenes;
32using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; 32using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
33using OpenSim.Region.ScriptEngine.Shared;
33 34
34 35
35namespace OpenSim.Region.ScriptEngine.Common 36namespace OpenSim.Region.ScriptEngine.Common
@@ -42,28 +43,29 @@ namespace OpenSim.Region.ScriptEngine.Common
42 void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine); 43 void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine);
43 void OnRemoveScript(uint localID, UUID itemID); 44 void OnRemoveScript(uint localID, UUID itemID);
44 void state_exit(uint localID); 45 void state_exit(uint localID);
45 void touch(uint localID, uint originalID, UUID itemID); 46 void touch(uint localID, uint originalID, Vector3 offsetPos,
46 void touch_end(uint localID, uint originalID, UUID itemID); 47 IClientAPI remoteClient);
48 void touch_end(uint localID, uint originalID, IClientAPI remoteClient);
47 void collision_start(uint localID, ColliderArgs col); 49 void collision_start(uint localID, ColliderArgs col);
48 void collision(uint localID, ColliderArgs col); 50 void collision(uint localID, ColliderArgs col);
49 void collision_end(uint localID, ColliderArgs col); 51 void collision_end(uint localID, ColliderArgs col);
50 void land_collision_start(uint localID, UUID itemID); 52// void land_collision_start(uint localID, UUID itemID);
51 void land_collision(uint localID, ColliderArgs col); 53// void land_collision(uint localID, ColliderArgs col);
52 void land_collision_end(uint localID, UUID itemID); 54// void land_collision_end(uint localID, UUID itemID);
53 void timer(uint localID, UUID itemID); 55 void timer(uint localID, UUID itemID);
54 void listen(uint localID, UUID itemID); 56 void listen(uint localID, UUID itemID);
55 void on_rez(uint localID, UUID itemID); 57// void on_rez(uint localID, UUID itemID);
56 void sensor(uint localID, UUID itemID); 58// void sensor(uint localID, UUID itemID);
57 void no_sensor(uint localID, UUID itemID); 59// void no_sensor(uint localID, UUID itemID);
58 void control(uint localID, UUID itemID, UUID agentID, uint held, uint change); 60 void control(uint localID, UUID itemID, UUID agentID, uint held, uint change);
59 void money(uint LocalID, UUID agentID, int amount); 61 void money(uint LocalID, UUID agentID, int amount);
60 void email(uint localID, UUID itemID); 62// void email(uint localID, UUID itemID);
61 void at_target(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); 63 void at_target(uint localID, uint handle, Vector3 targetpos, Vector3 atpos);
62 void not_at_target(uint localID); 64 void not_at_target(uint localID);
63 void at_rot_target(uint localID, UUID itemID); 65 void at_rot_target(uint localID, UUID itemID);
64 void not_at_rot_target(uint localID, UUID itemID); 66 void not_at_rot_target(uint localID, UUID itemID);
65 void run_time_permissions(uint localID, UUID itemID); 67// void run_time_permissions(uint localID, UUID itemID);
66 void changed(uint localID, UUID itemID); 68// void changed(uint localID, UUID itemID);
67 void attach(uint localID, UUID itemID); 69 void attach(uint localID, UUID itemID);
68 void dataserver(uint localID, UUID itemID); 70 void dataserver(uint localID, UUID itemID);
69 void link_message(uint localID, UUID itemID); 71 void link_message(uint localID, UUID itemID);
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
index 5bdc753..9a9eba7 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
@@ -33,6 +33,7 @@ using OpenSim.Framework;
33using OpenSim.Region.Environment.Scenes; 33using OpenSim.Region.Environment.Scenes;
34using OpenSim.Region.ScriptEngine.Common; 34using OpenSim.Region.ScriptEngine.Common;
35using OpenSim.Region.ScriptEngine.Shared; 35using OpenSim.Region.ScriptEngine.Shared;
36using OpenSim.Region.ScriptEngine.Shared.Api;
36using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; 37using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
37 38
38namespace OpenSim.Region.ScriptEngine.DotNetEngine 39namespace OpenSim.Region.ScriptEngine.DotNetEngine
@@ -139,10 +140,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
139 // Fire the first start-event 140 // Fire the first start-event
140 int eventFlags = m_scriptEngine.m_ScriptManager.GetStateEventFlags(localID, itemID); 141 int eventFlags = m_scriptEngine.m_ScriptManager.GetStateEventFlags(localID, itemID);
141 m_host.SetScriptEvents(itemID, eventFlags); 142 m_host.SetScriptEvents(itemID, eventFlags);
142 m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", EventQueueManager.llDetectNull, new object[] { }); 143 m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new DetectParams[0], new object[] { });
143 if (postOnRez) 144 if (postOnRez)
144 { 145 {
145 m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(startParam) }); 146 m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez", new DetectParams[0], new object[] { new LSL_Types.LSLInteger(startParam) });
146 } 147 }
147 } 148 }
148 catch (Exception e) // LEGIT: User Scripting 149 catch (Exception e) // LEGIT: User Scripting
@@ -174,7 +175,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
174//#endif 175//#endif
175 176
176 // Stop long command on script 177 // Stop long command on script
177 m_scriptEngine.m_ASYNCLSLCommandManager.RemoveScript(localID, itemID); 178 AsyncCommandManager.RemoveScript(m_scriptEngine, localID, itemID);
178 179
179 IScript LSLBC = GetScript(localID, itemID); 180 IScript LSLBC = GetScript(localID, itemID);
180 if (LSLBC == null) 181 if (LSLBC == null)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index 020e64a..91ca298 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -54,47 +54,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
54 public IEventReceiver m_ScriptEngine; 54 public IEventReceiver m_ScriptEngine;
55 private IScene m_Scene; 55 private IScene m_Scene;
56 56
57 private static Dictionary<IScene, Dataserver> m_Dataserver = 57 private static Dictionary<IEventReceiver, Dataserver> m_Dataserver =
58 new Dictionary<IScene, Dataserver>(); 58 new Dictionary<IEventReceiver, Dataserver>();
59 private static Dictionary<IScene, Timer> m_Timer = 59 private static Dictionary<IEventReceiver, Timer> m_Timer =
60 new Dictionary<IScene, Timer>(); 60 new Dictionary<IEventReceiver, Timer>();
61 private static Dictionary<IScene, Listener> m_Listener = 61 private static Dictionary<IEventReceiver, Listener> m_Listener =
62 new Dictionary<IScene, Listener>(); 62 new Dictionary<IEventReceiver, Listener>();
63 private static Dictionary<IScene, HttpRequest> m_HttpRequest = 63 private static Dictionary<IEventReceiver, HttpRequest> m_HttpRequest =
64 new Dictionary<IScene, HttpRequest>(); 64 new Dictionary<IEventReceiver, HttpRequest>();
65 private static Dictionary<IScene, SensorRepeat> m_SensorRepeat = 65 private static Dictionary<IEventReceiver, SensorRepeat> m_SensorRepeat =
66 new Dictionary<IScene, SensorRepeat>(); 66 new Dictionary<IEventReceiver, SensorRepeat>();
67 private static Dictionary<IScene, XmlRequest> m_XmlRequest = 67 private static Dictionary<IEventReceiver, XmlRequest> m_XmlRequest =
68 new Dictionary<IScene, XmlRequest>(); 68 new Dictionary<IEventReceiver, XmlRequest>();
69 69
70 public Dataserver DataserverPlugin 70 public Dataserver DataserverPlugin
71 { 71 {
72 get { return m_Dataserver[m_Scene]; } 72 get { return m_Dataserver[m_ScriptEngine]; }
73 } 73 }
74 74
75 public Timer TimerPlugin 75 public Timer TimerPlugin
76 { 76 {
77 get { return m_Timer[m_Scene]; } 77 get { return m_Timer[m_ScriptEngine]; }
78 } 78 }
79 79
80 public HttpRequest HttpRequestPlugin 80 public HttpRequest HttpRequestPlugin
81 { 81 {
82 get { return m_HttpRequest[m_Scene]; } 82 get { return m_HttpRequest[m_ScriptEngine]; }
83 } 83 }
84 84
85 public Listener ListenerPlugin 85 public Listener ListenerPlugin
86 { 86 {
87 get { return m_Listener[m_Scene]; } 87 get { return m_Listener[m_ScriptEngine]; }
88 } 88 }
89 89
90 public SensorRepeat SensorRepeatPlugin 90 public SensorRepeat SensorRepeatPlugin
91 { 91 {
92 get { return m_SensorRepeat[m_Scene]; } 92 get { return m_SensorRepeat[m_ScriptEngine]; }
93 } 93 }
94 94
95 public XmlRequest XmlRequestPlugin 95 public XmlRequest XmlRequestPlugin
96 { 96 {
97 get { return m_XmlRequest[m_Scene]; } 97 get { return m_XmlRequest[m_ScriptEngine]; }
98 } 98 }
99 99
100 public IEventReceiver[] ScriptEngines 100 public IEventReceiver[] ScriptEngines
@@ -107,26 +107,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
107 m_ScriptEngine = _ScriptEngine; 107 m_ScriptEngine = _ScriptEngine;
108 m_Scene = m_ScriptEngine.World; 108 m_Scene = m_ScriptEngine.World;
109 109
110 if (m_Scenes.Count == 0)
111 ReadConfig();
112
110 if (!m_Scenes.Contains(m_Scene)) 113 if (!m_Scenes.Contains(m_Scene))
111 m_Scenes.Add(m_Scene); 114 m_Scenes.Add(m_Scene);
112 if (!m_ScriptEngines.Contains(m_ScriptEngine)) 115 if (!m_ScriptEngines.Contains(m_ScriptEngine))
113 m_ScriptEngines.Add(m_ScriptEngine); 116 m_ScriptEngines.Add(m_ScriptEngine);
114 117
115 ReadConfig();
116
117 // Create instances of all plugins 118 // Create instances of all plugins
118 if (!m_Dataserver.ContainsKey(m_Scene)) 119 if (!m_Dataserver.ContainsKey(m_ScriptEngine))
119 m_Dataserver[m_Scene] = new Dataserver(this); 120 m_Dataserver[m_ScriptEngine] = new Dataserver(this);
120 if (!m_Timer.ContainsKey(m_Scene)) 121 if (!m_Timer.ContainsKey(m_ScriptEngine))
121 m_Timer[m_Scene] = new Timer(this); 122 m_Timer[m_ScriptEngine] = new Timer(this);
122 if (!m_HttpRequest.ContainsKey(m_Scene)) 123 if (!m_HttpRequest.ContainsKey(m_ScriptEngine))
123 m_HttpRequest[m_Scene] = new HttpRequest(this); 124 m_HttpRequest[m_ScriptEngine] = new HttpRequest(this);
124 if (!m_Listener.ContainsKey(m_Scene)) 125 if (!m_Listener.ContainsKey(m_ScriptEngine))
125 m_Listener[m_Scene] = new Listener(this); 126 m_Listener[m_ScriptEngine] = new Listener(this);
126 if (!m_SensorRepeat.ContainsKey(m_Scene)) 127 if (!m_SensorRepeat.ContainsKey(m_ScriptEngine))
127 m_SensorRepeat[m_Scene] = new SensorRepeat(this); 128 m_SensorRepeat[m_ScriptEngine] = new SensorRepeat(this);
128 if (!m_XmlRequest.ContainsKey(m_Scene)) 129 if (!m_XmlRequest.ContainsKey(m_ScriptEngine))
129 m_XmlRequest[m_Scene] = new XmlRequest(this); 130 m_XmlRequest[m_ScriptEngine] = new XmlRequest(this);
130 131
131 StartThread(); 132 StartThread();
132 } 133 }
@@ -145,7 +146,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
145 } 146 }
146 } 147 }
147 148
148 public void ReadConfig() 149 private void ReadConfig()
149 { 150 {
150// cmdHandlerThreadCycleSleepms = m_ScriptEngine.Config.GetInt("AsyncLLCommandLoopms", 100); 151// cmdHandlerThreadCycleSleepms = m_ScriptEngine.Config.GetInt("AsyncLLCommandLoopms", 100);
151 // TODO: Make this sane again 152 // TODO: Make this sane again
@@ -195,18 +196,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
195 196
196 private static void DoOneCmdHandlerPass() 197 private static void DoOneCmdHandlerPass()
197 { 198 {
198 foreach (IScene s in m_Scenes) 199 // Check Listeners
200 m_Listener[m_ScriptEngines[0]].CheckListeners();
201
202 // Check HttpRequests
203 m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests();
204
205 // Check XMLRPCRequests
206 m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests();
207
208 foreach (IEventReceiver s in m_ScriptEngines)
199 { 209 {
200 // Check timers 210 // Check timers
201 m_Timer[s].CheckTimerEvents(); 211 m_Timer[s].CheckTimerEvents();
202 // Check HttpRequests 212
203 m_HttpRequest[s].CheckHttpRequests();
204 // Check XMLRPCRequests
205 m_XmlRequest[s].CheckXMLRPCRequests();
206 // Check Listeners
207 m_Listener[s].CheckListeners();
208 // Check Sensors 213 // Check Sensors
209 m_SensorRepeat[s].CheckSenseRepeaterEvents(); 214 m_SensorRepeat[s].CheckSenseRepeaterEvents();
215
210 // Check dataserver 216 // Check dataserver
211 m_Dataserver[s].ExpireRequests(); 217 m_Dataserver[s].ExpireRequests();
212 } 218 }
@@ -217,38 +223,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
217 /// </summary> 223 /// </summary>
218 /// <param name="localID"></param> 224 /// <param name="localID"></param>
219 /// <param name="itemID"></param> 225 /// <param name="itemID"></param>
220 public static void RemoveScript(IScene scene, uint localID, UUID itemID) 226 public static void RemoveScript(IEventReceiver engine, uint localID, UUID itemID)
221 { 227 {
222 // Remove a specific script 228 // Remove a specific script
223 229
224 // Remove dataserver events 230 // Remove dataserver events
225 m_Dataserver[scene].RemoveEvents(localID, itemID); 231 m_Dataserver[engine].RemoveEvents(localID, itemID);
226 232
227 // Remove from: Timers 233 // Remove from: Timers
228 m_Timer[scene].UnSetTimerEvents(localID, itemID); 234 m_Timer[engine].UnSetTimerEvents(localID, itemID);
229 235
230 // Remove from: HttpRequest 236 // Remove from: HttpRequest
231 IHttpRequests iHttpReq = 237 IHttpRequests iHttpReq =
232 scene.RequestModuleInterface<IHttpRequests>(); 238 engine.World.RequestModuleInterface<IHttpRequests>();
233 iHttpReq.StopHttpRequest(localID, itemID); 239 iHttpReq.StopHttpRequest(localID, itemID);
234 240
235 IWorldComm comms = scene.RequestModuleInterface<IWorldComm>(); 241 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>();
236 comms.DeleteListener(itemID); 242 comms.DeleteListener(itemID);
237 243
238 IXMLRPC xmlrpc = scene.RequestModuleInterface<IXMLRPC>(); 244 IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>();
239 xmlrpc.DeleteChannels(itemID); 245 xmlrpc.DeleteChannels(itemID);
240 xmlrpc.CancelSRDRequests(itemID); 246 xmlrpc.CancelSRDRequests(itemID);
241 247
242 // Remove Sensors 248 // Remove Sensors
243 m_SensorRepeat[scene].UnSetSenseRepeaterEvents(localID, itemID); 249 m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID);
244 250
245 } 251 }
246 252
247 public static Object[] GetSerializationData(IScene scene, UUID itemID) 253 public static Object[] GetSerializationData(IEventReceiver engine, UUID itemID)
248 { 254 {
249 List<Object> data = new List<Object>(); 255 List<Object> data = new List<Object>();
250 256
251 Object[] listeners=m_Listener[scene].GetSerializationData(itemID); 257 Object[] listeners=m_Listener[engine].GetSerializationData(itemID);
252 if (listeners.Length > 0) 258 if (listeners.Length > 0)
253 { 259 {
254 data.Add("listener"); 260 data.Add("listener");
@@ -256,7 +262,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
256 data.AddRange(listeners); 262 data.AddRange(listeners);
257 } 263 }
258 264
259 Object[] timers=m_Timer[scene].GetSerializationData(itemID); 265 Object[] timers=m_Timer[engine].GetSerializationData(itemID);
260 if (timers.Length > 0) 266 if (timers.Length > 0)
261 { 267 {
262 data.Add("timer"); 268 data.Add("timer");
@@ -264,7 +270,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
264 data.AddRange(timers); 270 data.AddRange(timers);
265 } 271 }
266 272
267 Object[] sensors=m_SensorRepeat[scene].GetSerializationData(itemID); 273 Object[] sensors=m_SensorRepeat[engine].GetSerializationData(itemID);
268 if (sensors.Length > 0) 274 if (sensors.Length > 0)
269 { 275 {
270 data.Add("sensor"); 276 data.Add("sensor");
@@ -275,7 +281,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
275 return data.ToArray(); 281 return data.ToArray();
276 } 282 }
277 283
278 public static void CreateFromData(IScene scene, uint localID, 284 public static void CreateFromData(IEventReceiver engine, uint localID,
279 UUID itemID, UUID hostID, Object[] data) 285 UUID itemID, UUID hostID, Object[] data)
280 { 286 {
281 int idx = 0; 287 int idx = 0;
@@ -297,15 +303,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
297 switch (type) 303 switch (type)
298 { 304 {
299 case "listener": 305 case "listener":
300 m_Listener[scene].CreateFromData(localID, itemID, 306 m_Listener[engine].CreateFromData(localID, itemID,
301 hostID, item); 307 hostID, item);
302 break; 308 break;
303 case "timer": 309 case "timer":
304 m_Timer[scene].CreateFromData(localID, itemID, 310 m_Timer[engine].CreateFromData(localID, itemID,
305 hostID, item); 311 hostID, item);
306 break; 312 break;
307 case "sensor": 313 case "sensor":
308 m_SensorRepeat[scene].CreateFromData(localID, 314 m_SensorRepeat[engine].CreateFromData(localID,
309 itemID, hostID, item); 315 itemID, hostID, item);
310 break; 316 break;
311 } 317 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs
index 3d3fb05..0c77a9d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
58 58
59 while (httpInfo != null) 59 while (httpInfo != null)
60 { 60 {
61 //m_ScriptEngine.Log.Info("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status); 61 //System.Console.WriteLine("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status);
62 62
63 // Deliver data to prim's remote_data handler 63 // Deliver data to prim's remote_data handler
64 // 64 //
@@ -77,7 +77,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
77 new LSL_Types.LSLString(httpInfo.response_body) 77 new LSL_Types.LSLString(httpInfo.response_body)
78 }; 78 };
79 79
80 foreach (IScriptEngine e in m_CmdManager.ScriptEngines) 80 foreach (IEventReceiver e in m_CmdManager.ScriptEngines)
81 { 81 {
82 if (e.PostObjectEvent(httpInfo.localID, 82 if (e.PostObjectEvent(httpInfo.localID,
83 new EventParams("http_response", 83 new EventParams("http_response",
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
index b353cba..59d5060 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
@@ -29,6 +29,7 @@ using System;
29using OpenMetaverse; 29using OpenMetaverse;
30using OpenSim.Region.Environment.Interfaces; 30using OpenSim.Region.Environment.Interfaces;
31using OpenSim.Region.Environment.Modules.Scripting.WorldComm; 31using OpenSim.Region.Environment.Modules.Scripting.WorldComm;
32using OpenSim.Region.ScriptEngine.Interfaces;
32using OpenSim.Region.ScriptEngine.Shared; 33using OpenSim.Region.ScriptEngine.Shared;
33using OpenSim.Region.ScriptEngine.Shared.Api; 34using OpenSim.Region.ScriptEngine.Shared.Api;
34 35
@@ -66,10 +67,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
66 new LSL_Types.LSLString(lInfo.GetMessage()) 67 new LSL_Types.LSLString(lInfo.GetMessage())
67 }; 68 };
68 69
69 m_CmdManager.m_ScriptEngine.PostScriptEvent( 70 foreach (IEventReceiver e in m_CmdManager.ScriptEngines)
70 lInfo.GetItemID(), new EventParams( 71 {
71 "listen", resobj, 72 e.PostScriptEvent(
72 new DetectParams[0])); 73 lInfo.GetItemID(), new EventParams(
74 "listen", resobj,
75 new DetectParams[0]));
76 }
73 } 77 }
74 } 78 }
75 } 79 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index d1e3921..9b0bc5b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -156,28 +156,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
156 SensorSweep(ts); 156 SensorSweep(ts);
157 } 157 }
158 158
159 public LSL_Types.list GetSensorList(uint m_localID, UUID m_itemID)
160 {
161 lock (SenseLock)
162 {
163 Dictionary<UUID, LSL_Types.list> Obj = null;
164 if (!SenseEvents.TryGetValue(m_localID, out Obj))
165 {
166 return null;
167 }
168 lock (Obj)
169 {
170 // Get script
171 LSL_Types.list SenseList = null;
172 if (!Obj.TryGetValue(m_itemID, out SenseList))
173 {
174 return null;
175 }
176 return SenseList;
177 }
178 }
179 }
180
181 private void SensorSweep(SenseRepeatClass ts) 159 private void SensorSweep(SenseRepeatClass ts)
182 { 160 {
183 SceneObjectPart SensePoint = ts.host; 161 SceneObjectPart SensePoint = ts.host;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
index ec7cd35..91cef9b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
@@ -108,7 +108,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
108 // Time has passed? 108 // Time has passed?
109 if (ts.next < DateTime.Now.Ticks) 109 if (ts.next < DateTime.Now.Ticks)
110 { 110 {
111 // Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); 111 //Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
112 // Add it to queue 112 // Add it to queue
113 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, 113 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
114 new EventParams("timer", new Object[0], 114 new EventParams("timer", new Object[0],
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs
index a7699a1..1c1ea0b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs
@@ -71,7 +71,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
71 new LSL_Types.LSLString(rInfo.GetStrVal()) 71 new LSL_Types.LSLString(rInfo.GetStrVal())
72 }; 72 };
73 73
74 foreach (IScriptEngine e in m_CmdManager.ScriptEngines) 74 foreach (IEventReceiver e in m_CmdManager.ScriptEngines)
75 { 75 {
76 if (e.PostScriptEvent( 76 if (e.PostScriptEvent(
77 rInfo.GetItemID(), new EventParams( 77 rInfo.GetItemID(), new EventParams(
@@ -100,7 +100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
100 new LSL_Types.LSLString(srdInfo.sdata) 100 new LSL_Types.LSLString(srdInfo.sdata)
101 }; 101 };
102 102
103 foreach (IScriptEngine e in m_CmdManager.ScriptEngines) 103 foreach (IEventReceiver e in m_CmdManager.ScriptEngines)
104 { 104 {
105 if (e.PostScriptEvent( 105 if (e.PostScriptEvent(
106 srdInfo.m_itemID, new EventParams( 106 srdInfo.m_itemID, new EventParams(
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 14ac256..28a3b11 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -246,7 +246,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
246 246
247 ScriptSerializer.Deserialize(xml, this); 247 ScriptSerializer.Deserialize(xml, this);
248 248
249 AsyncCommandManager.CreateFromData(m_Engine.World, 249 AsyncCommandManager.CreateFromData(m_Engine,
250 m_LocalID, m_ItemID, m_ObjectID, 250 m_LocalID, m_ItemID, m_ObjectID,
251 PluginData); 251 PluginData);
252 252
@@ -336,7 +336,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
336 public void DestroyScriptInstance() 336 public void DestroyScriptInstance()
337 { 337 {
338 ReleaseControls(); 338 ReleaseControls();
339 AsyncCommandManager.RemoveScript(m_Engine.World, m_LocalID, m_ItemID); 339 AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID);
340 } 340 }
341 341
342 public void RemoveState() 342 public void RemoveState()
@@ -554,7 +554,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
554 // m_Engine.Log.DebugFormat("[Script] Script {0}.{1} state set to {2}", 554 // m_Engine.Log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
555 // m_PrimName, m_ScriptName, data.Params[0].ToString()); 555 // m_PrimName, m_ScriptName, data.Params[0].ToString());
556 m_State=data.Params[0].ToString(); 556 m_State=data.Params[0].ToString();
557 AsyncCommandManager.RemoveScript(m_Engine.World, 557 AsyncCommandManager.RemoveScript(m_Engine,
558 m_LocalID, m_ItemID); 558 m_LocalID, m_ItemID);
559 559
560 SceneObjectPart part = m_Engine.World.GetSceneObjectPart( 560 SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
@@ -690,7 +690,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
690 SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); 690 SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID);
691 part.GetInventoryItem(m_ItemID).PermsMask = 0; 691 part.GetInventoryItem(m_ItemID).PermsMask = 0;
692 part.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero; 692 part.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero;
693 AsyncCommandManager.RemoveScript(m_Engine.World, m_LocalID, m_ItemID); 693 AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID);
694 m_EventQueue.Clear(); 694 m_EventQueue.Clear();
695 m_Script.ResetVars(); 695 m_Script.ResetVars();
696 m_State = "default"; 696 m_State = "default";
@@ -715,7 +715,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
715 SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); 715 SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID);
716 part.GetInventoryItem(m_ItemID).PermsMask = 0; 716 part.GetInventoryItem(m_ItemID).PermsMask = 0;
717 part.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero; 717 part.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero;
718 AsyncCommandManager.RemoveScript(m_Engine.World, m_LocalID, m_ItemID); 718 AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID);
719 719
720 m_EventQueue.Clear(); 720 m_EventQueue.Clear();
721 m_Script.ResetVars(); 721 m_Script.ResetVars();
@@ -772,7 +772,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
772 return; 772 return;
773 } 773 }
774 774
775 PluginData = AsyncCommandManager.GetSerializationData(m_Engine.World, m_ItemID); 775 PluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID);
776 776
777 string xml = ScriptSerializer.Serialize(this); 777 string xml = ScriptSerializer.Serialize(this);
778 778
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index f4cfef0..701ad60 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -50,7 +50,7 @@ using OpenSim.Region.ScriptEngine.Interfaces;
50 50
51namespace OpenSim.Region.ScriptEngine.XEngine 51namespace OpenSim.Region.ScriptEngine.XEngine
52{ 52{
53 public class XEngine : IScriptModule, IScriptEngine 53 public class XEngine : IRegionModule, IScriptEngine
54 { 54 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 56
@@ -75,7 +75,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
75#pragma warning restore 414 75#pragma warning restore 414
76 private int m_EventLimit; 76 private int m_EventLimit;
77 private bool m_KillTimedOutScripts; 77 private bool m_KillTimedOutScripts;
78 bool m_firstStart = true; 78// bool m_firstStart = true;
79 79
80 private static List<XEngine> m_ScriptEngines = 80 private static List<XEngine> m_ScriptEngines =
81 new List<XEngine>(); 81 new List<XEngine>();
@@ -205,8 +205,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
205 m_ScriptEngines.Add(this); 205 m_ScriptEngines.Add(this);
206 } 206 }
207 207
208 scene.RegisterModuleInterface<IScriptModule>(this);
209
210 // Needs to be here so we can queue the scripts that need starting 208 // Needs to be here so we can queue the scripts that need starting
211 // 209 //
212 m_Scene.EventManager.OnRezScript += OnRezScript; 210 m_Scene.EventManager.OnRezScript += OnRezScript;
@@ -230,6 +228,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
230 m_Scene.EventManager.OnScriptReset += OnScriptReset; 228 m_Scene.EventManager.OnScriptReset += OnScriptReset;
231 m_Scene.EventManager.OnStartScript += OnStartScript; 229 m_Scene.EventManager.OnStartScript += OnStartScript;
232 m_Scene.EventManager.OnStopScript += OnStopScript; 230 m_Scene.EventManager.OnStopScript += OnStopScript;
231 m_Scene.EventManager.OnGetScriptRunning += OnGetScriptRunning;
233 m_Scene.EventManager.OnShutdown += OnShutdown; 232 m_Scene.EventManager.OnShutdown += OnShutdown;
234 233
235 if (m_SleepTime > 0) 234 if (m_SleepTime > 0)
@@ -357,14 +356,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
357 356
358 if (m_CurrentCompile == null) 357 if (m_CurrentCompile == null)
359 { 358 {
360 if (m_firstStart) 359// if (m_firstStart)
361 { 360// {
362 m_firstStart = false; 361// m_firstStart = false;
363 m_CurrentCompile = m_ThreadPool.QueueWorkItem( 362// m_CurrentCompile = m_ThreadPool.QueueWorkItem(
364 new WorkItemCallback(this.DoScriptWait), 363// new WorkItemCallback(this.DoScriptWait),
365 new Object[0]); 364// new Object[0]);
366 return; 365// return;
367 } 366// }
368 367
369 m_CurrentCompile = m_ThreadPool.QueueWorkItem( 368 m_CurrentCompile = m_ThreadPool.QueueWorkItem(
370 new WorkItemCallback(this.DoOnRezScriptQueue), 369 new WorkItemCallback(this.DoOnRezScriptQueue),
@@ -375,7 +374,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
375 374
376 public Object DoScriptWait(Object dummy) 375 public Object DoScriptWait(Object dummy)
377 { 376 {
378 Thread.Sleep(30000); 377 Thread.Sleep(10000);
379 378
380 lock (m_CompileQueue) 379 lock (m_CompileQueue)
381 { 380 {
@@ -884,11 +883,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
884 return instance.StartParam; 883 return instance.StartParam;
885 } 884 }
886 885
887 public bool GetScriptRunning(UUID objectID, UUID itemID)
888 {
889 return GetScriptState(itemID);
890 }
891
892 public void OnShutdown() 886 public void OnShutdown()
893 { 887 {
894 List<IScriptInstance> instances = new List<IScriptInstance>(); 888 List<IScriptInstance> instances = new List<IScriptInstance>();
@@ -922,5 +916,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
922 return null; 916 return null;
923 return instance.GetApi(name); 917 return instance.GetApi(name);
924 } 918 }
919
920 public void OnGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
921 {
922 IScriptInstance instance = GetInstance(itemID);
923 if (instance == null)
924 return;
925 controllingClient.SendScriptRunningReply(objectID, itemID,
926 GetScriptState(itemID));
927 }
925 } 928 }
926} 929}
diff --git a/prebuild.xml b/prebuild.xml
index 5c58391..bd6994c 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1952,6 +1952,7 @@
1952 <Reference name="OpenSim.Region.Physics.Manager" /> 1952 <Reference name="OpenSim.Region.Physics.Manager" />
1953 <Reference name="OpenSim.Framework.Console"/> 1953 <Reference name="OpenSim.Framework.Console"/>
1954 <Reference name="OpenSim.Region.ScriptEngine.Shared"/> 1954 <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
1955 <Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/>
1955 <Reference name="Nini.dll" /> 1956 <Reference name="Nini.dll" />
1956 <Reference name="RAIL.dll"/> 1957 <Reference name="RAIL.dll"/>
1957 <Reference name="OpenSim.Framework.Console"/> 1958 <Reference name="OpenSim.Framework.Console"/>
@@ -1990,6 +1991,7 @@
1990 <Reference name="OpenSim.Region.Environment" /> 1991 <Reference name="OpenSim.Region.Environment" />
1991 <Reference name="OpenSim.Region.ScriptEngine.Common"/> 1992 <Reference name="OpenSim.Region.ScriptEngine.Common"/>
1992 <Reference name="OpenSim.Region.ScriptEngine.Shared"/> 1993 <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
1994 <Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/>
1993 <Reference name="Microsoft.JScript"/> 1995 <Reference name="Microsoft.JScript"/>
1994 <Reference name="Nini.dll" /> 1996 <Reference name="Nini.dll" />
1995 <Reference name="log4net.dll"/> 1997 <Reference name="log4net.dll"/>