aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-25 05:13:44 +0000
committerMelanie Thielker2008-09-25 05:13:44 +0000
commitf3c8963c86dbc969541ede80ae37eb59d26b7809 (patch)
treeff1e5cea74e9d5c2b73c476320a7bddf11d93766 /OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
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 'OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs233
1 files changed, 37 insertions, 196 deletions
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)