diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
21 files changed, 815 insertions, 641 deletions
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs index bb5bacc..2027ca6 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs | |||
@@ -27,17 +27,22 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenMetaverse; | 29 | using OpenMetaverse; |
30 | using OpenSim.Framework; | ||
30 | using OpenSim.Region.Framework.Scenes; | 31 | using OpenSim.Region.Framework.Scenes; |
31 | 32 | ||
32 | |||
33 | namespace OpenSim.Region.ScriptEngine.Interfaces | 33 | namespace OpenSim.Region.ScriptEngine.Interfaces |
34 | { | 34 | { |
35 | public interface IScriptApi | 35 | public interface IScriptApi |
36 | { | 36 | { |
37 | // | 37 | /// <summary> |
38 | // Each API has an identifier, which is used to load the | 38 | /// Initialize the API |
39 | // proper runtime assembly at load time. | 39 | /// </summary> |
40 | // | 40 | /// <remarks> |
41 | void Initialize(IScriptEngine engine, SceneObjectPart part, uint localID, UUID item); | 41 | /// Each API has an identifier, which is used to load the |
42 | /// proper runtime assembly at load time. | ||
43 | /// <param name='engine'>/param> | ||
44 | /// <param name='part'></param> | ||
45 | /// <param name='item'></param> | ||
46 | void Initialize(IScriptEngine engine, SceneObjectPart part, TaskInventoryItem item); | ||
42 | } | 47 | } |
43 | } | 48 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs index 47ed6ba..684138f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs | |||
@@ -29,42 +29,43 @@ using System; | |||
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | ||
32 | using OpenSim.Region.ScriptEngine.Interfaces; | 33 | using OpenSim.Region.ScriptEngine.Interfaces; |
33 | 34 | ||
34 | namespace OpenSim.Region.ScriptEngine.Shared.Api | 35 | namespace OpenSim.Region.ScriptEngine.Shared.Api |
35 | { | 36 | { |
36 | public class ApiManager | 37 | public class ApiManager |
37 | { | 38 | { |
39 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
40 | |||
38 | private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>(); | 41 | private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>(); |
39 | 42 | ||
40 | public string[] GetApis() | 43 | public string[] GetApis() |
41 | { | 44 | { |
42 | if (m_Apis.Count > 0) | 45 | if (m_Apis.Count <= 0) |
43 | { | 46 | { |
44 | List<string> l = new List<string>(m_Apis.Keys); | 47 | Assembly a = Assembly.GetExecutingAssembly(); |
45 | return l.ToArray(); | ||
46 | } | ||
47 | 48 | ||
48 | Assembly a = Assembly.GetExecutingAssembly(); | 49 | Type[] types = a.GetExportedTypes(); |
49 | 50 | ||
50 | Type[] types = a.GetExportedTypes(); | 51 | foreach (Type t in types) |
51 | |||
52 | foreach (Type t in types) | ||
53 | { | ||
54 | string name = t.ToString(); | ||
55 | int idx = name.LastIndexOf('.'); | ||
56 | if (idx != -1) | ||
57 | name = name.Substring(idx+1); | ||
58 | |||
59 | if (name.EndsWith("_Api")) | ||
60 | { | 52 | { |
61 | name = name.Substring(0, name.Length - 4); | 53 | string name = t.ToString(); |
62 | m_Apis[name] = t; | 54 | int idx = name.LastIndexOf('.'); |
55 | if (idx != -1) | ||
56 | name = name.Substring(idx+1); | ||
57 | |||
58 | if (name.EndsWith("_Api")) | ||
59 | { | ||
60 | name = name.Substring(0, name.Length - 4); | ||
61 | m_Apis[name] = t; | ||
62 | } | ||
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | List<string> ret = new List<string>(m_Apis.Keys); | 66 | // m_log.DebugFormat("[API MANAGER]: Found {0} apis", m_Apis.Keys.Count); |
67 | return ret.ToArray(); | 67 | |
68 | return new List<string>(m_Apis.Keys).ToArray(); | ||
68 | } | 69 | } |
69 | 70 | ||
70 | public IScriptApi CreateApi(string api) | 71 | public IScriptApi CreateApi(string api) |
@@ -76,4 +77,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
76 | return ret; | 77 | return ret; |
77 | } | 78 | } |
78 | } | 79 | } |
79 | } | 80 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs index 489c1c6..b5fa6de 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -59,16 +59,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
59 | { | 59 | { |
60 | internal IScriptEngine m_ScriptEngine; | 60 | internal IScriptEngine m_ScriptEngine; |
61 | internal SceneObjectPart m_host; | 61 | internal SceneObjectPart m_host; |
62 | internal uint m_localID; | 62 | internal TaskInventoryItem m_item; |
63 | internal UUID m_itemID; | ||
64 | internal bool m_CMFunctionsEnabled = false; | 63 | internal bool m_CMFunctionsEnabled = false; |
65 | 64 | ||
66 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | 65 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) |
67 | { | 66 | { |
68 | m_ScriptEngine = ScriptEngine; | 67 | m_ScriptEngine = ScriptEngine; |
69 | m_host = host; | 68 | m_host = host; |
70 | m_localID = localID; | 69 | m_item = item; |
71 | m_itemID = itemID; | ||
72 | 70 | ||
73 | if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) | 71 | if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) |
74 | m_CMFunctionsEnabled = true; | 72 | m_CMFunctionsEnabled = true; |
@@ -95,7 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
95 | public string cmDetectedCountry(int number) | 93 | public string cmDetectedCountry(int number) |
96 | { | 94 | { |
97 | m_host.AddScriptLPS(1); | 95 | m_host.AddScriptLPS(1); |
98 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 96 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
99 | if (detectedParams == null) | 97 | if (detectedParams == null) |
100 | return String.Empty; | 98 | return String.Empty; |
101 | return detectedParams.Country; | 99 | return detectedParams.Country; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6523c2d..5bd781c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -88,8 +88,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
88 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 88 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
89 | protected IScriptEngine m_ScriptEngine; | 89 | protected IScriptEngine m_ScriptEngine; |
90 | protected SceneObjectPart m_host; | 90 | protected SceneObjectPart m_host; |
91 | protected uint m_localID; | 91 | |
92 | protected UUID m_itemID; | 92 | /// <summary> |
93 | /// The item that hosts this script | ||
94 | /// </summary> | ||
95 | protected TaskInventoryItem m_item; | ||
96 | |||
93 | protected bool throwErrorOnNotImplemented = true; | 97 | protected bool throwErrorOnNotImplemented = true; |
94 | protected AsyncCommandManager AsyncCommands = null; | 98 | protected AsyncCommandManager AsyncCommands = null; |
95 | protected float m_ScriptDelayFactor = 1.0f; | 99 | protected float m_ScriptDelayFactor = 1.0f; |
@@ -111,7 +115,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
111 | protected Timer m_ShoutSayTimer; | 115 | protected Timer m_ShoutSayTimer; |
112 | protected int m_SayShoutCount = 0; | 116 | protected int m_SayShoutCount = 0; |
113 | 117 | ||
114 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | 118 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) |
115 | { | 119 | { |
116 | m_ShoutSayTimer = new Timer(1000); | 120 | m_ShoutSayTimer = new Timer(1000); |
117 | m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed; | 121 | m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed; |
@@ -120,8 +124,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
120 | 124 | ||
121 | m_ScriptEngine = ScriptEngine; | 125 | m_ScriptEngine = ScriptEngine; |
122 | m_host = host; | 126 | m_host = host; |
123 | m_localID = localID; | 127 | m_item = item; |
124 | m_itemID = itemID; | ||
125 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | 128 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); |
126 | 129 | ||
127 | m_ScriptDelayFactor = | 130 | m_ScriptDelayFactor = |
@@ -173,7 +176,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
173 | [DebuggerNonUserCode] | 176 | [DebuggerNonUserCode] |
174 | public void state(string newState) | 177 | public void state(string newState) |
175 | { | 178 | { |
176 | m_ScriptEngine.SetState(m_itemID, newState); | 179 | m_ScriptEngine.SetState(m_item.ItemID, newState); |
177 | } | 180 | } |
178 | 181 | ||
179 | /// <summary> | 182 | /// <summary> |
@@ -184,7 +187,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
184 | public void llResetScript() | 187 | public void llResetScript() |
185 | { | 188 | { |
186 | m_host.AddScriptLPS(1); | 189 | m_host.AddScriptLPS(1); |
187 | m_ScriptEngine.ApiResetScript(m_itemID); | 190 | m_ScriptEngine.ApiResetScript(m_item.ItemID); |
188 | } | 191 | } |
189 | 192 | ||
190 | public void llResetOtherScript(string name) | 193 | public void llResetOtherScript(string name) |
@@ -336,30 +339,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
336 | } | 339 | } |
337 | } | 340 | } |
338 | 341 | ||
339 | protected UUID InventorySelf() | ||
340 | { | ||
341 | UUID invItemID = new UUID(); | ||
342 | bool unlock = false; | ||
343 | if (!m_host.TaskInventory.IsReadLockedByMe()) | ||
344 | { | ||
345 | m_host.TaskInventory.LockItemsForRead(true); | ||
346 | unlock = true; | ||
347 | } | ||
348 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
349 | { | ||
350 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | ||
351 | { | ||
352 | invItemID = inv.Key; | ||
353 | break; | ||
354 | } | ||
355 | } | ||
356 | if (unlock) | ||
357 | { | ||
358 | m_host.TaskInventory.LockItemsForRead(false); | ||
359 | } | ||
360 | return invItemID; | ||
361 | } | ||
362 | |||
363 | protected UUID InventoryKey(string name, int type) | 342 | protected UUID InventoryKey(string name, int type) |
364 | { | 343 | { |
365 | m_host.AddScriptLPS(1); | 344 | m_host.AddScriptLPS(1); |
@@ -941,20 +920,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
941 | 920 | ||
942 | public void llRegionSayTo(string target, int channel, string msg) | 921 | public void llRegionSayTo(string target, int channel, string msg) |
943 | { | 922 | { |
944 | string error = String.Empty; | ||
945 | |||
946 | if (msg.Length > 1023) | 923 | if (msg.Length > 1023) |
947 | msg = msg.Substring(0, 1023); | 924 | msg = msg.Substring(0, 1023); |
948 | 925 | ||
949 | m_host.AddScriptLPS(1); | 926 | m_host.AddScriptLPS(1); |
950 | 927 | ||
928 | if (channel == ScriptBaseClass.DEBUG_CHANNEL) | ||
929 | { | ||
930 | return; | ||
931 | } | ||
932 | |||
951 | UUID TargetID; | 933 | UUID TargetID; |
952 | UUID.TryParse(target, out TargetID); | 934 | UUID.TryParse(target, out TargetID); |
953 | 935 | ||
954 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 936 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
955 | if (wComm != null) | 937 | if (wComm != null) |
956 | if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) | 938 | wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg); |
957 | LSLError(error); | ||
958 | } | 939 | } |
959 | 940 | ||
960 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) | 941 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) |
@@ -964,7 +945,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
964 | UUID.TryParse(ID, out keyID); | 945 | UUID.TryParse(ID, out keyID); |
965 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 946 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
966 | if (wComm != null) | 947 | if (wComm != null) |
967 | return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg); | 948 | return wComm.Listen(m_host.LocalId, m_item.ItemID, m_host.UUID, channelID, name, keyID, msg); |
968 | else | 949 | else |
969 | return -1; | 950 | return -1; |
970 | } | 951 | } |
@@ -974,7 +955,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
974 | m_host.AddScriptLPS(1); | 955 | m_host.AddScriptLPS(1); |
975 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 956 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
976 | if (wComm != null) | 957 | if (wComm != null) |
977 | wComm.ListenControl(m_itemID, number, active); | 958 | wComm.ListenControl(m_item.ItemID, number, active); |
978 | } | 959 | } |
979 | 960 | ||
980 | public void llListenRemove(int number) | 961 | public void llListenRemove(int number) |
@@ -982,7 +963,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
982 | m_host.AddScriptLPS(1); | 963 | m_host.AddScriptLPS(1); |
983 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 964 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
984 | if (wComm != null) | 965 | if (wComm != null) |
985 | wComm.ListenRemove(m_itemID, number); | 966 | wComm.ListenRemove(m_item.ItemID, number); |
986 | } | 967 | } |
987 | 968 | ||
988 | public void llSensor(string name, string id, int type, double range, double arc) | 969 | public void llSensor(string name, string id, int type, double range, double arc) |
@@ -991,7 +972,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
991 | UUID keyID = UUID.Zero; | 972 | UUID keyID = UUID.Zero; |
992 | UUID.TryParse(id, out keyID); | 973 | UUID.TryParse(id, out keyID); |
993 | 974 | ||
994 | AsyncCommands.SensorRepeatPlugin.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); | 975 | AsyncCommands.SensorRepeatPlugin.SenseOnce(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, m_host); |
995 | } | 976 | } |
996 | 977 | ||
997 | public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) | 978 | public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) |
@@ -1000,13 +981,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1000 | UUID keyID = UUID.Zero; | 981 | UUID keyID = UUID.Zero; |
1001 | UUID.TryParse(id, out keyID); | 982 | UUID.TryParse(id, out keyID); |
1002 | 983 | ||
1003 | AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); | 984 | AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, rate, m_host); |
1004 | } | 985 | } |
1005 | 986 | ||
1006 | public void llSensorRemove() | 987 | public void llSensorRemove() |
1007 | { | 988 | { |
1008 | m_host.AddScriptLPS(1); | 989 | m_host.AddScriptLPS(1); |
1009 | AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_localID, m_itemID); | 990 | AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_host.LocalId, m_item.ItemID); |
1010 | } | 991 | } |
1011 | 992 | ||
1012 | public string resolveName(UUID objecUUID) | 993 | public string resolveName(UUID objecUUID) |
@@ -1047,7 +1028,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1047 | public LSL_String llDetectedName(int number) | 1028 | public LSL_String llDetectedName(int number) |
1048 | { | 1029 | { |
1049 | m_host.AddScriptLPS(1); | 1030 | m_host.AddScriptLPS(1); |
1050 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1031 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1051 | if (detectedParams == null) | 1032 | if (detectedParams == null) |
1052 | return String.Empty; | 1033 | return String.Empty; |
1053 | return detectedParams.Name; | 1034 | return detectedParams.Name; |
@@ -1056,7 +1037,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1056 | public LSL_String llDetectedKey(int number) | 1037 | public LSL_String llDetectedKey(int number) |
1057 | { | 1038 | { |
1058 | m_host.AddScriptLPS(1); | 1039 | m_host.AddScriptLPS(1); |
1059 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1040 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1060 | if (detectedParams == null) | 1041 | if (detectedParams == null) |
1061 | return String.Empty; | 1042 | return String.Empty; |
1062 | return detectedParams.Key.ToString(); | 1043 | return detectedParams.Key.ToString(); |
@@ -1065,7 +1046,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1065 | public LSL_String llDetectedOwner(int number) | 1046 | public LSL_String llDetectedOwner(int number) |
1066 | { | 1047 | { |
1067 | m_host.AddScriptLPS(1); | 1048 | m_host.AddScriptLPS(1); |
1068 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1049 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1069 | if (detectedParams == null) | 1050 | if (detectedParams == null) |
1070 | return String.Empty; | 1051 | return String.Empty; |
1071 | return detectedParams.Owner.ToString(); | 1052 | return detectedParams.Owner.ToString(); |
@@ -1074,7 +1055,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1074 | public LSL_Integer llDetectedType(int number) | 1055 | public LSL_Integer llDetectedType(int number) |
1075 | { | 1056 | { |
1076 | m_host.AddScriptLPS(1); | 1057 | m_host.AddScriptLPS(1); |
1077 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1058 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1078 | if (detectedParams == null) | 1059 | if (detectedParams == null) |
1079 | return 0; | 1060 | return 0; |
1080 | return new LSL_Integer(detectedParams.Type); | 1061 | return new LSL_Integer(detectedParams.Type); |
@@ -1083,7 +1064,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1083 | public LSL_Vector llDetectedPos(int number) | 1064 | public LSL_Vector llDetectedPos(int number) |
1084 | { | 1065 | { |
1085 | m_host.AddScriptLPS(1); | 1066 | m_host.AddScriptLPS(1); |
1086 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1067 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1087 | if (detectedParams == null) | 1068 | if (detectedParams == null) |
1088 | return new LSL_Vector(); | 1069 | return new LSL_Vector(); |
1089 | return detectedParams.Position; | 1070 | return detectedParams.Position; |
@@ -1092,7 +1073,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1092 | public LSL_Vector llDetectedVel(int number) | 1073 | public LSL_Vector llDetectedVel(int number) |
1093 | { | 1074 | { |
1094 | m_host.AddScriptLPS(1); | 1075 | m_host.AddScriptLPS(1); |
1095 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1076 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1096 | if (detectedParams == null) | 1077 | if (detectedParams == null) |
1097 | return new LSL_Vector(); | 1078 | return new LSL_Vector(); |
1098 | return detectedParams.Velocity; | 1079 | return detectedParams.Velocity; |
@@ -1101,7 +1082,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1101 | public LSL_Vector llDetectedGrab(int number) | 1082 | public LSL_Vector llDetectedGrab(int number) |
1102 | { | 1083 | { |
1103 | m_host.AddScriptLPS(1); | 1084 | m_host.AddScriptLPS(1); |
1104 | DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1085 | DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1105 | if (parms == null) | 1086 | if (parms == null) |
1106 | return new LSL_Vector(0, 0, 0); | 1087 | return new LSL_Vector(0, 0, 0); |
1107 | 1088 | ||
@@ -1111,7 +1092,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1111 | public LSL_Rotation llDetectedRot(int number) | 1092 | public LSL_Rotation llDetectedRot(int number) |
1112 | { | 1093 | { |
1113 | m_host.AddScriptLPS(1); | 1094 | m_host.AddScriptLPS(1); |
1114 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1095 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1115 | if (detectedParams == null) | 1096 | if (detectedParams == null) |
1116 | return new LSL_Rotation(); | 1097 | return new LSL_Rotation(); |
1117 | return detectedParams.Rotation; | 1098 | return detectedParams.Rotation; |
@@ -1120,7 +1101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1120 | public LSL_Integer llDetectedGroup(int number) | 1101 | public LSL_Integer llDetectedGroup(int number) |
1121 | { | 1102 | { |
1122 | m_host.AddScriptLPS(1); | 1103 | m_host.AddScriptLPS(1); |
1123 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1104 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1124 | if (detectedParams == null) | 1105 | if (detectedParams == null) |
1125 | return new LSL_Integer(0); | 1106 | return new LSL_Integer(0); |
1126 | if (m_host.GroupID == detectedParams.Group) | 1107 | if (m_host.GroupID == detectedParams.Group) |
@@ -1131,7 +1112,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1131 | public LSL_Integer llDetectedLinkNumber(int number) | 1112 | public LSL_Integer llDetectedLinkNumber(int number) |
1132 | { | 1113 | { |
1133 | m_host.AddScriptLPS(1); | 1114 | m_host.AddScriptLPS(1); |
1134 | DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1115 | DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1135 | if (parms == null) | 1116 | if (parms == null) |
1136 | return new LSL_Integer(0); | 1117 | return new LSL_Integer(0); |
1137 | 1118 | ||
@@ -1144,7 +1125,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1144 | public LSL_Vector llDetectedTouchBinormal(int index) | 1125 | public LSL_Vector llDetectedTouchBinormal(int index) |
1145 | { | 1126 | { |
1146 | m_host.AddScriptLPS(1); | 1127 | m_host.AddScriptLPS(1); |
1147 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); | 1128 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); |
1148 | if (detectedParams == null) | 1129 | if (detectedParams == null) |
1149 | return new LSL_Vector(); | 1130 | return new LSL_Vector(); |
1150 | return detectedParams.TouchBinormal; | 1131 | return detectedParams.TouchBinormal; |
@@ -1156,7 +1137,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1156 | public LSL_Integer llDetectedTouchFace(int index) | 1137 | public LSL_Integer llDetectedTouchFace(int index) |
1157 | { | 1138 | { |
1158 | m_host.AddScriptLPS(1); | 1139 | m_host.AddScriptLPS(1); |
1159 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); | 1140 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); |
1160 | if (detectedParams == null) | 1141 | if (detectedParams == null) |
1161 | return new LSL_Integer(-1); | 1142 | return new LSL_Integer(-1); |
1162 | return new LSL_Integer(detectedParams.TouchFace); | 1143 | return new LSL_Integer(detectedParams.TouchFace); |
@@ -1168,7 +1149,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1168 | public LSL_Vector llDetectedTouchNormal(int index) | 1149 | public LSL_Vector llDetectedTouchNormal(int index) |
1169 | { | 1150 | { |
1170 | m_host.AddScriptLPS(1); | 1151 | m_host.AddScriptLPS(1); |
1171 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); | 1152 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); |
1172 | if (detectedParams == null) | 1153 | if (detectedParams == null) |
1173 | return new LSL_Vector(); | 1154 | return new LSL_Vector(); |
1174 | return detectedParams.TouchNormal; | 1155 | return detectedParams.TouchNormal; |
@@ -1180,7 +1161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1180 | public LSL_Vector llDetectedTouchPos(int index) | 1161 | public LSL_Vector llDetectedTouchPos(int index) |
1181 | { | 1162 | { |
1182 | m_host.AddScriptLPS(1); | 1163 | m_host.AddScriptLPS(1); |
1183 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); | 1164 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); |
1184 | if (detectedParams == null) | 1165 | if (detectedParams == null) |
1185 | return new LSL_Vector(); | 1166 | return new LSL_Vector(); |
1186 | return detectedParams.TouchPos; | 1167 | return detectedParams.TouchPos; |
@@ -1192,7 +1173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1192 | public LSL_Vector llDetectedTouchST(int index) | 1173 | public LSL_Vector llDetectedTouchST(int index) |
1193 | { | 1174 | { |
1194 | m_host.AddScriptLPS(1); | 1175 | m_host.AddScriptLPS(1); |
1195 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); | 1176 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); |
1196 | if (detectedParams == null) | 1177 | if (detectedParams == null) |
1197 | return new LSL_Vector(-1.0, -1.0, 0.0); | 1178 | return new LSL_Vector(-1.0, -1.0, 0.0); |
1198 | return detectedParams.TouchST; | 1179 | return detectedParams.TouchST; |
@@ -1204,7 +1185,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1204 | public LSL_Vector llDetectedTouchUV(int index) | 1185 | public LSL_Vector llDetectedTouchUV(int index) |
1205 | { | 1186 | { |
1206 | m_host.AddScriptLPS(1); | 1187 | m_host.AddScriptLPS(1); |
1207 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); | 1188 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); |
1208 | if (detectedParams == null) | 1189 | if (detectedParams == null) |
1209 | return new LSL_Vector(-1.0, -1.0, 0.0); | 1190 | return new LSL_Vector(-1.0, -1.0, 0.0); |
1210 | return detectedParams.TouchUV; | 1191 | return detectedParams.TouchUV; |
@@ -1910,6 +1891,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1910 | rgb.y = texcolor.G; | 1891 | rgb.y = texcolor.G; |
1911 | rgb.z = texcolor.B; | 1892 | rgb.z = texcolor.B; |
1912 | return rgb; | 1893 | return rgb; |
1894 | |||
1913 | } | 1895 | } |
1914 | else | 1896 | else |
1915 | { | 1897 | { |
@@ -2948,20 +2930,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2948 | 2930 | ||
2949 | public LSL_Integer llGiveMoney(string destination, int amount) | 2931 | public LSL_Integer llGiveMoney(string destination, int amount) |
2950 | { | 2932 | { |
2951 | UUID invItemID=InventorySelf(); | ||
2952 | if (invItemID == UUID.Zero) | ||
2953 | return 0; | ||
2954 | |||
2955 | m_host.AddScriptLPS(1); | 2933 | m_host.AddScriptLPS(1); |
2956 | 2934 | ||
2957 | m_host.TaskInventory.LockItemsForRead(true); | 2935 | if (m_item.PermsGranter == UUID.Zero) |
2958 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | ||
2959 | m_host.TaskInventory.LockItemsForRead(false); | ||
2960 | |||
2961 | if (item.PermsGranter == UUID.Zero) | ||
2962 | return 0; | 2936 | return 0; |
2963 | 2937 | ||
2964 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) | 2938 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) |
2965 | { | 2939 | { |
2966 | LSLError("No permissions to give money"); | 2940 | LSLError("No permissions to give money"); |
2967 | return 0; | 2941 | return 0; |
@@ -3148,7 +3122,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3148 | sec = m_MinTimerInterval; | 3122 | sec = m_MinTimerInterval; |
3149 | m_host.AddScriptLPS(1); | 3123 | m_host.AddScriptLPS(1); |
3150 | // Setting timer repeat | 3124 | // Setting timer repeat |
3151 | AsyncCommands.TimerPlugin.SetTimerEvent(m_localID, m_itemID, sec); | 3125 | AsyncCommands.TimerPlugin.SetTimerEvent(m_host.LocalId, m_item.ItemID, sec); |
3152 | } | 3126 | } |
3153 | 3127 | ||
3154 | public virtual void llSleep(double sec) | 3128 | public virtual void llSleep(double sec) |
@@ -3210,29 +3184,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3210 | 3184 | ||
3211 | public void llTakeControls(int controls, int accept, int pass_on) | 3185 | public void llTakeControls(int controls, int accept, int pass_on) |
3212 | { | 3186 | { |
3213 | TaskInventoryItem item; | 3187 | if (m_item.PermsGranter != UUID.Zero) |
3214 | |||
3215 | m_host.TaskInventory.LockItemsForRead(true); | ||
3216 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3217 | { | 3188 | { |
3218 | m_host.TaskInventory.LockItemsForRead(false); | 3189 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); |
3219 | return; | ||
3220 | } | ||
3221 | else | ||
3222 | { | ||
3223 | item = m_host.TaskInventory[InventorySelf()]; | ||
3224 | } | ||
3225 | m_host.TaskInventory.LockItemsForRead(false); | ||
3226 | |||
3227 | if (item.PermsGranter != UUID.Zero) | ||
3228 | { | ||
3229 | ScenePresence presence = World.GetScenePresence(item.PermsGranter); | ||
3230 | 3190 | ||
3231 | if (presence != null) | 3191 | if (presence != null) |
3232 | { | 3192 | { |
3233 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 3193 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
3234 | { | 3194 | { |
3235 | presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID); | 3195 | presence.RegisterControlEventsToScript(controls, accept, pass_on, m_host.LocalId, m_item.ItemID); |
3236 | } | 3196 | } |
3237 | } | 3197 | } |
3238 | } | 3198 | } |
@@ -3242,38 +3202,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3242 | 3202 | ||
3243 | public void llReleaseControls() | 3203 | public void llReleaseControls() |
3244 | { | 3204 | { |
3245 | TaskInventoryItem item; | ||
3246 | |||
3247 | m_host.TaskInventory.LockItemsForRead(true); | ||
3248 | lock (m_host.TaskInventory) | ||
3249 | { | ||
3250 | |||
3251 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3252 | { | ||
3253 | m_host.TaskInventory.LockItemsForRead(false); | ||
3254 | return; | ||
3255 | } | ||
3256 | else | ||
3257 | { | ||
3258 | item = m_host.TaskInventory[InventorySelf()]; | ||
3259 | } | ||
3260 | } | ||
3261 | m_host.TaskInventory.LockItemsForRead(false); | ||
3262 | |||
3263 | m_host.AddScriptLPS(1); | 3205 | m_host.AddScriptLPS(1); |
3264 | 3206 | ||
3265 | if (item.PermsGranter != UUID.Zero) | 3207 | if (m_item.PermsGranter != UUID.Zero) |
3266 | { | 3208 | { |
3267 | ScenePresence presence = World.GetScenePresence(item.PermsGranter); | 3209 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); |
3268 | 3210 | ||
3269 | if (presence != null) | 3211 | if (presence != null) |
3270 | { | 3212 | { |
3271 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 3213 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
3272 | { | 3214 | { |
3273 | // Unregister controls from Presence | 3215 | // Unregister controls from Presence |
3274 | presence.UnRegisterControlEventsToScript(m_localID, m_itemID); | 3216 | presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID); |
3275 | // Remove Take Control permission. | 3217 | // Remove Take Control permission. |
3276 | item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; | 3218 | m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; |
3277 | } | 3219 | } |
3278 | } | 3220 | } |
3279 | } | 3221 | } |
@@ -3286,86 +3228,71 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3286 | m_UrlModule.ReleaseURL(url); | 3228 | m_UrlModule.ReleaseURL(url); |
3287 | } | 3229 | } |
3288 | 3230 | ||
3289 | public void llAttachToAvatar(int attachment) | 3231 | /// <summary> |
3232 | /// Attach the object containing this script to the avatar that owns it. | ||
3233 | /// </summary> | ||
3234 | /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param> | ||
3235 | /// <returns>true if the attach suceeded, false if it did not</returns> | ||
3236 | public bool AttachToAvatar(int attachmentPoint) | ||
3290 | { | 3237 | { |
3291 | m_host.AddScriptLPS(1); | 3238 | SceneObjectGroup grp = m_host.ParentGroup; |
3292 | 3239 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | |
3293 | TaskInventoryItem item; | ||
3294 | 3240 | ||
3295 | m_host.TaskInventory.LockItemsForRead(true); | 3241 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3296 | 3242 | ||
3297 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3243 | if (attachmentsModule != null) |
3298 | { | 3244 | return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false); |
3299 | m_host.TaskInventory.LockItemsForRead(false); | ||
3300 | return; | ||
3301 | } | ||
3302 | else | 3245 | else |
3303 | { | 3246 | return false; |
3304 | item = m_host.TaskInventory[InventorySelf()]; | 3247 | } |
3305 | } | ||
3306 | |||
3307 | m_host.TaskInventory.LockItemsForRead(false); | ||
3308 | 3248 | ||
3309 | if (item.PermsGranter != m_host.OwnerID) | 3249 | /// <summary> |
3310 | return; | 3250 | /// Detach the object containing this script from the avatar it is attached to. |
3251 | /// </summary> | ||
3252 | /// <remarks> | ||
3253 | /// Nothing happens if the object is not attached. | ||
3254 | /// </remarks> | ||
3255 | public void DetachFromAvatar() | ||
3256 | { | ||
3257 | Util.FireAndForget(DetachWrapper, m_host); | ||
3258 | } | ||
3311 | 3259 | ||
3312 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) | 3260 | private void DetachWrapper(object o) |
3313 | { | 3261 | { |
3314 | SceneObjectGroup grp = m_host.ParentGroup; | 3262 | SceneObjectPart host = (SceneObjectPart)o; |
3315 | 3263 | ||
3316 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 3264 | SceneObjectGroup grp = host.ParentGroup; |
3265 | UUID itemID = grp.FromItemID; | ||
3266 | ScenePresence presence = World.GetScenePresence(host.OwnerID); | ||
3317 | 3267 | ||
3318 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3268 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3319 | if (attachmentsModule != null) | 3269 | if (attachmentsModule != null) |
3320 | attachmentsModule.AttachObject(presence, grp, (uint)attachment, false); | 3270 | attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); |
3321 | } | ||
3322 | } | 3271 | } |
3323 | 3272 | ||
3324 | public void llDetachFromAvatar() | 3273 | public void llAttachToAvatar(int attachmentPoint) |
3325 | { | 3274 | { |
3326 | m_host.AddScriptLPS(1); | 3275 | m_host.AddScriptLPS(1); |
3327 | 3276 | ||
3328 | if (m_host.ParentGroup.AttachmentPoint == 0) | 3277 | if (m_item.PermsGranter != m_host.OwnerID) |
3329 | return; | 3278 | return; |
3330 | 3279 | ||
3331 | TaskInventoryItem item; | 3280 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) |
3281 | AttachToAvatar(attachmentPoint); | ||
3282 | } | ||
3332 | 3283 | ||
3333 | m_host.TaskInventory.LockItemsForRead(true); | 3284 | public void llDetachFromAvatar() |
3285 | { | ||
3286 | m_host.AddScriptLPS(1); | ||
3334 | 3287 | ||
3335 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3288 | if (m_host.ParentGroup.AttachmentPoint == 0) |
3336 | { | ||
3337 | m_host.TaskInventory.LockItemsForRead(false); | ||
3338 | return; | 3289 | return; |
3339 | } | ||
3340 | else | ||
3341 | { | ||
3342 | item = m_host.TaskInventory[InventorySelf()]; | ||
3343 | } | ||
3344 | m_host.TaskInventory.LockItemsForRead(false); | ||
3345 | |||
3346 | 3290 | ||
3347 | if (item.PermsGranter != m_host.OwnerID) | 3291 | if (m_item.PermsGranter != m_host.OwnerID) |
3348 | return; | 3292 | return; |
3349 | 3293 | ||
3350 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) | 3294 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) |
3351 | { | 3295 | DetachFromAvatar(); |
3352 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | ||
3353 | if (attachmentsModule != null) | ||
3354 | Util.FireAndForget(DetachWrapper, m_host); | ||
3355 | } | ||
3356 | } | ||
3357 | |||
3358 | private void DetachWrapper(object o) | ||
3359 | { | ||
3360 | SceneObjectPart host = (SceneObjectPart)o; | ||
3361 | |||
3362 | SceneObjectGroup grp = host.ParentGroup; | ||
3363 | UUID itemID = grp.FromItemID; | ||
3364 | ScenePresence presence = World.GetScenePresence(host.OwnerID); | ||
3365 | |||
3366 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | ||
3367 | if (attachmentsModule != null) | ||
3368 | attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); | ||
3369 | } | 3296 | } |
3370 | 3297 | ||
3371 | public void llTakeCamera(string avatar) | 3298 | public void llTakeCamera(string avatar) |
@@ -3523,6 +3450,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3523 | return m_host.UUID.ToString(); | 3450 | return m_host.UUID.ToString(); |
3524 | } | 3451 | } |
3525 | 3452 | ||
3453 | public LSL_Key llGenerateKey() | ||
3454 | { | ||
3455 | m_host.AddScriptLPS(1); | ||
3456 | return UUID.Random().ToString(); | ||
3457 | } | ||
3458 | |||
3526 | public void llSetBuoyancy(double buoyancy) | 3459 | public void llSetBuoyancy(double buoyancy) |
3527 | { | 3460 | { |
3528 | m_host.AddScriptLPS(1); | 3461 | m_host.AddScriptLPS(1); |
@@ -3569,7 +3502,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3569 | m_host.AddScriptLPS(1); | 3502 | m_host.AddScriptLPS(1); |
3570 | try | 3503 | try |
3571 | { | 3504 | { |
3572 | m_ScriptEngine.SetMinEventDelay(m_itemID, delay); | 3505 | m_ScriptEngine.SetMinEventDelay(m_item.ItemID, delay); |
3573 | } | 3506 | } |
3574 | catch (NotImplementedException) | 3507 | catch (NotImplementedException) |
3575 | { | 3508 | { |
@@ -3622,29 +3555,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3622 | { | 3555 | { |
3623 | m_host.AddScriptLPS(1); | 3556 | m_host.AddScriptLPS(1); |
3624 | 3557 | ||
3625 | UUID invItemID = InventorySelf(); | 3558 | if (m_item.PermsGranter == UUID.Zero) |
3626 | if (invItemID == UUID.Zero) | ||
3627 | return; | 3559 | return; |
3628 | 3560 | ||
3629 | TaskInventoryItem item; | 3561 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) |
3630 | |||
3631 | m_host.TaskInventory.LockItemsForRead(true); | ||
3632 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3633 | { | 3562 | { |
3634 | m_host.TaskInventory.LockItemsForRead(false); | 3563 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); |
3635 | return; | ||
3636 | } | ||
3637 | else | ||
3638 | { | ||
3639 | item = m_host.TaskInventory[InventorySelf()]; | ||
3640 | } | ||
3641 | m_host.TaskInventory.LockItemsForRead(false); | ||
3642 | if (item.PermsGranter == UUID.Zero) | ||
3643 | return; | ||
3644 | |||
3645 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) | ||
3646 | { | ||
3647 | ScenePresence presence = World.GetScenePresence(item.PermsGranter); | ||
3648 | 3564 | ||
3649 | if (presence != null) | 3565 | if (presence != null) |
3650 | { | 3566 | { |
@@ -3662,38 +3578,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3662 | { | 3578 | { |
3663 | m_host.AddScriptLPS(1); | 3579 | m_host.AddScriptLPS(1); |
3664 | 3580 | ||
3665 | UUID invItemID=InventorySelf(); | 3581 | if (m_item.PermsGranter == UUID.Zero) |
3666 | if (invItemID == UUID.Zero) | ||
3667 | return; | ||
3668 | |||
3669 | TaskInventoryItem item; | ||
3670 | |||
3671 | m_host.TaskInventory.LockItemsForRead(true); | ||
3672 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3673 | { | ||
3674 | m_host.TaskInventory.LockItemsForRead(false); | ||
3675 | return; | ||
3676 | } | ||
3677 | else | ||
3678 | { | ||
3679 | item = m_host.TaskInventory[InventorySelf()]; | ||
3680 | } | ||
3681 | m_host.TaskInventory.LockItemsForRead(false); | ||
3682 | |||
3683 | |||
3684 | if (item.PermsGranter == UUID.Zero) | ||
3685 | return; | 3582 | return; |
3686 | 3583 | ||
3687 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) | 3584 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) |
3688 | { | 3585 | { |
3689 | UUID animID = new UUID(); | 3586 | UUID animID = new UUID(); |
3690 | 3587 | ||
3691 | if (!UUID.TryParse(anim, out animID)) | 3588 | if (!UUID.TryParse(anim, out animID)) |
3692 | { | 3589 | { |
3693 | animID=InventoryKey(anim); | 3590 | animID = InventoryKey(anim); |
3694 | } | 3591 | } |
3695 | 3592 | ||
3696 | ScenePresence presence = World.GetScenePresence(item.PermsGranter); | 3593 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); |
3697 | 3594 | ||
3698 | if (presence != null) | 3595 | if (presence != null) |
3699 | { | 3596 | { |
@@ -3729,44 +3626,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3729 | public LSL_Integer llGetStartParameter() | 3626 | public LSL_Integer llGetStartParameter() |
3730 | { | 3627 | { |
3731 | m_host.AddScriptLPS(1); | 3628 | m_host.AddScriptLPS(1); |
3732 | return m_ScriptEngine.GetStartParameter(m_itemID); | 3629 | return m_ScriptEngine.GetStartParameter(m_item.ItemID); |
3733 | } | 3630 | } |
3734 | 3631 | ||
3735 | public void llRequestPermissions(string agent, int perm) | 3632 | public void llRequestPermissions(string agent, int perm) |
3736 | { | 3633 | { |
3737 | UUID agentID = new UUID(); | 3634 | UUID agentID; |
3738 | 3635 | ||
3739 | if (!UUID.TryParse(agent, out agentID)) | 3636 | if (!UUID.TryParse(agent, out agentID)) |
3740 | return; | 3637 | return; |
3741 | 3638 | ||
3742 | UUID invItemID = InventorySelf(); | ||
3743 | |||
3744 | if (invItemID == UUID.Zero) | ||
3745 | return; // Not in a prim? How?? | ||
3746 | |||
3747 | TaskInventoryItem item; | ||
3748 | |||
3749 | |||
3750 | m_host.TaskInventory.LockItemsForRead(true); | ||
3751 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3752 | { | ||
3753 | m_host.TaskInventory.LockItemsForRead(false); | ||
3754 | return; | ||
3755 | } | ||
3756 | else | ||
3757 | { | ||
3758 | item = m_host.TaskInventory[invItemID]; | ||
3759 | } | ||
3760 | m_host.TaskInventory.LockItemsForRead(false); | ||
3761 | |||
3762 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3639 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3763 | { | 3640 | { |
3764 | llReleaseControls(); | 3641 | llReleaseControls(); |
3765 | 3642 | ||
3766 | item.PermsGranter = UUID.Zero; | 3643 | m_item.PermsGranter = UUID.Zero; |
3767 | item.PermsMask = 0; | 3644 | m_item.PermsMask = 0; |
3768 | 3645 | ||
3769 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3646 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3770 | "run_time_permissions", new Object[] { | 3647 | "run_time_permissions", new Object[] { |
3771 | new LSL_Integer(0) }, | 3648 | new LSL_Integer(0) }, |
3772 | new DetectParams[0])); | 3649 | new DetectParams[0])); |
@@ -3774,7 +3651,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3774 | return; | 3651 | return; |
3775 | } | 3652 | } |
3776 | 3653 | ||
3777 | if (item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3654 | if (m_item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3778 | llReleaseControls(); | 3655 | llReleaseControls(); |
3779 | 3656 | ||
3780 | m_host.AddScriptLPS(1); | 3657 | m_host.AddScriptLPS(1); |
@@ -3791,11 +3668,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3791 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3668 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3792 | { | 3669 | { |
3793 | m_host.TaskInventory.LockItemsForWrite(true); | 3670 | m_host.TaskInventory.LockItemsForWrite(true); |
3794 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3671 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3795 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3672 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; |
3796 | m_host.TaskInventory.LockItemsForWrite(false); | 3673 | m_host.TaskInventory.LockItemsForWrite(false); |
3797 | 3674 | ||
3798 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3675 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3799 | "run_time_permissions", new Object[] { | 3676 | "run_time_permissions", new Object[] { |
3800 | new LSL_Integer(perm) }, | 3677 | new LSL_Integer(perm) }, |
3801 | new DetectParams[0])); | 3678 | new DetectParams[0])); |
@@ -3830,11 +3707,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3830 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3707 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3831 | { | 3708 | { |
3832 | m_host.TaskInventory.LockItemsForWrite(true); | 3709 | m_host.TaskInventory.LockItemsForWrite(true); |
3833 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3710 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3834 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3711 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; |
3835 | m_host.TaskInventory.LockItemsForWrite(false); | 3712 | m_host.TaskInventory.LockItemsForWrite(false); |
3836 | 3713 | ||
3837 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3714 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3838 | "run_time_permissions", new Object[] { | 3715 | "run_time_permissions", new Object[] { |
3839 | new LSL_Integer(perm) }, | 3716 | new LSL_Integer(perm) }, |
3840 | new DetectParams[0])); | 3717 | new DetectParams[0])); |
@@ -3855,8 +3732,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3855 | if (!m_waitingForScriptAnswer) | 3732 | if (!m_waitingForScriptAnswer) |
3856 | { | 3733 | { |
3857 | m_host.TaskInventory.LockItemsForWrite(true); | 3734 | m_host.TaskInventory.LockItemsForWrite(true); |
3858 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3735 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3859 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3736 | m_host.TaskInventory[m_item.ItemID].PermsMask = 0; |
3860 | m_host.TaskInventory.LockItemsForWrite(false); | 3737 | m_host.TaskInventory.LockItemsForWrite(false); |
3861 | 3738 | ||
3862 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3739 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
@@ -3864,13 +3741,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3864 | } | 3741 | } |
3865 | 3742 | ||
3866 | presence.ControllingClient.SendScriptQuestion( | 3743 | presence.ControllingClient.SendScriptQuestion( |
3867 | m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); | 3744 | m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_item.ItemID, perm); |
3868 | 3745 | ||
3869 | return; | 3746 | return; |
3870 | } | 3747 | } |
3871 | 3748 | ||
3872 | // Requested agent is not in range, refuse perms | 3749 | // Requested agent is not in range, refuse perms |
3873 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3750 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3874 | "run_time_permissions", new Object[] { | 3751 | "run_time_permissions", new Object[] { |
3875 | new LSL_Integer(0) }, | 3752 | new LSL_Integer(0) }, |
3876 | new DetectParams[0])); | 3753 | new DetectParams[0])); |
@@ -3881,24 +3758,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3881 | if (taskID != m_host.UUID) | 3758 | if (taskID != m_host.UUID) |
3882 | return; | 3759 | return; |
3883 | 3760 | ||
3884 | UUID invItemID = InventorySelf(); | 3761 | client.OnScriptAnswer -= handleScriptAnswer; |
3885 | 3762 | m_waitingForScriptAnswer = false; | |
3886 | if (invItemID == UUID.Zero) | ||
3887 | return; | ||
3888 | |||
3889 | client.OnScriptAnswer-=handleScriptAnswer; | ||
3890 | m_waitingForScriptAnswer=false; | ||
3891 | 3763 | ||
3892 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3764 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3893 | llReleaseControls(); | 3765 | llReleaseControls(); |
3894 | 3766 | ||
3895 | |||
3896 | m_host.TaskInventory.LockItemsForWrite(true); | 3767 | m_host.TaskInventory.LockItemsForWrite(true); |
3897 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3768 | m_host.TaskInventory[m_item.ItemID].PermsMask = answer; |
3898 | m_host.TaskInventory.LockItemsForWrite(false); | 3769 | m_host.TaskInventory.LockItemsForWrite(false); |
3899 | 3770 | ||
3900 | 3771 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | |
3901 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | ||
3902 | "run_time_permissions", new Object[] { | 3772 | "run_time_permissions", new Object[] { |
3903 | new LSL_Integer(answer) }, | 3773 | new LSL_Integer(answer) }, |
3904 | new DetectParams[0])); | 3774 | new DetectParams[0])); |
@@ -3908,41 +3778,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3908 | { | 3778 | { |
3909 | m_host.AddScriptLPS(1); | 3779 | m_host.AddScriptLPS(1); |
3910 | 3780 | ||
3911 | m_host.TaskInventory.LockItemsForRead(true); | 3781 | return m_item.PermsGranter.ToString(); |
3912 | |||
3913 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3914 | { | ||
3915 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
3916 | { | ||
3917 | m_host.TaskInventory.LockItemsForRead(false); | ||
3918 | return item.PermsGranter.ToString(); | ||
3919 | } | ||
3920 | } | ||
3921 | m_host.TaskInventory.LockItemsForRead(false); | ||
3922 | |||
3923 | return UUID.Zero.ToString(); | ||
3924 | } | 3782 | } |
3925 | 3783 | ||
3926 | public LSL_Integer llGetPermissions() | 3784 | public LSL_Integer llGetPermissions() |
3927 | { | 3785 | { |
3928 | m_host.AddScriptLPS(1); | 3786 | m_host.AddScriptLPS(1); |
3929 | 3787 | ||
3930 | m_host.TaskInventory.LockItemsForRead(true); | 3788 | int perms = m_item.PermsMask; |
3931 | 3789 | ||
3932 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3790 | if (m_automaticLinkPermission) |
3933 | { | 3791 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3934 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
3935 | { | ||
3936 | int perms = item.PermsMask; | ||
3937 | if (m_automaticLinkPermission) | ||
3938 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | ||
3939 | m_host.TaskInventory.LockItemsForRead(false); | ||
3940 | return perms; | ||
3941 | } | ||
3942 | } | ||
3943 | m_host.TaskInventory.LockItemsForRead(false); | ||
3944 | 3792 | ||
3945 | return 0; | 3793 | return perms; |
3946 | } | 3794 | } |
3947 | 3795 | ||
3948 | public LSL_Integer llGetLinkNumber() | 3796 | public LSL_Integer llGetLinkNumber() |
@@ -3980,18 +3828,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3980 | public void llCreateLink(string target, int parent) | 3828 | public void llCreateLink(string target, int parent) |
3981 | { | 3829 | { |
3982 | m_host.AddScriptLPS(1); | 3830 | m_host.AddScriptLPS(1); |
3983 | UUID invItemID = InventorySelf(); | 3831 | |
3984 | UUID targetID; | 3832 | UUID targetID; |
3985 | 3833 | ||
3986 | if (!UUID.TryParse(target, out targetID)) | 3834 | if (!UUID.TryParse(target, out targetID)) |
3987 | return; | 3835 | return; |
3988 | 3836 | ||
3989 | TaskInventoryItem item; | 3837 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3990 | m_host.TaskInventory.LockItemsForRead(true); | ||
3991 | item = m_host.TaskInventory[invItemID]; | ||
3992 | m_host.TaskInventory.LockItemsForRead(false); | ||
3993 | |||
3994 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | ||
3995 | && !m_automaticLinkPermission) | 3838 | && !m_automaticLinkPermission) |
3996 | { | 3839 | { |
3997 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3840 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
@@ -3999,7 +3842,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3999 | } | 3842 | } |
4000 | 3843 | ||
4001 | IClientAPI client = null; | 3844 | IClientAPI client = null; |
4002 | ScenePresence sp = World.GetScenePresence(item.PermsGranter); | 3845 | ScenePresence sp = World.GetScenePresence(m_item.PermsGranter); |
4003 | if (sp != null) | 3846 | if (sp != null) |
4004 | client = sp.ControllingClient; | 3847 | client = sp.ControllingClient; |
4005 | 3848 | ||
@@ -4045,18 +3888,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4045 | public void llBreakLink(int linknum) | 3888 | public void llBreakLink(int linknum) |
4046 | { | 3889 | { |
4047 | m_host.AddScriptLPS(1); | 3890 | m_host.AddScriptLPS(1); |
4048 | UUID invItemID = InventorySelf(); | ||
4049 | 3891 | ||
4050 | m_host.TaskInventory.LockItemsForRead(true); | 3892 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
4051 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3893 | && !m_automaticLinkPermission) |
4052 | && !m_automaticLinkPermission) | 3894 | { |
4053 | { | 3895 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
4054 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3896 | return; |
4055 | m_host.TaskInventory.LockItemsForRead(false); | 3897 | } |
4056 | return; | 3898 | |
4057 | } | ||
4058 | m_host.TaskInventory.LockItemsForRead(false); | ||
4059 | |||
4060 | if (linknum < ScriptBaseClass.LINK_THIS) | 3899 | if (linknum < ScriptBaseClass.LINK_THIS) |
4061 | return; | 3900 | return; |
4062 | 3901 | ||
@@ -4155,12 +3994,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4155 | { | 3994 | { |
4156 | m_host.AddScriptLPS(1); | 3995 | m_host.AddScriptLPS(1); |
4157 | 3996 | ||
4158 | UUID invItemID = InventorySelf(); | 3997 | TaskInventoryItem item = m_item; |
4159 | |||
4160 | TaskInventoryItem item; | ||
4161 | m_host.TaskInventory.LockItemsForRead(true); | ||
4162 | item = m_host.TaskInventory[invItemID]; | ||
4163 | m_host.TaskInventory.LockItemsForRead(false); | ||
4164 | 3998 | ||
4165 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3999 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
4166 | && !m_automaticLinkPermission) | 4000 | && !m_automaticLinkPermission) |
@@ -4471,7 +4305,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4471 | { | 4305 | { |
4472 | if (item.Name == name) | 4306 | if (item.Name == name) |
4473 | { | 4307 | { |
4474 | if (item.ItemID == m_itemID) | 4308 | if (item.ItemID == m_item.ItemID) |
4475 | throw new ScriptDeleteException(); | 4309 | throw new ScriptDeleteException(); |
4476 | else | 4310 | else |
4477 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 4311 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
@@ -4605,8 +4439,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4605 | UUID rq = UUID.Random(); | 4439 | UUID rq = UUID.Random(); |
4606 | 4440 | ||
4607 | UUID tid = AsyncCommands. | 4441 | UUID tid = AsyncCommands. |
4608 | DataserverPlugin.RegisterRequest(m_localID, | 4442 | DataserverPlugin.RegisterRequest(m_host.LocalId, |
4609 | m_itemID, rq.ToString()); | 4443 | m_item.ItemID, rq.ToString()); |
4610 | 4444 | ||
4611 | AsyncCommands. | 4445 | AsyncCommands. |
4612 | DataserverPlugin.DataserverReply(rq.ToString(), reply); | 4446 | DataserverPlugin.DataserverReply(rq.ToString(), reply); |
@@ -4633,8 +4467,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4633 | if (item.Type == 3 && item.Name == name) | 4467 | if (item.Type == 3 && item.Name == name) |
4634 | { | 4468 | { |
4635 | UUID tid = AsyncCommands. | 4469 | UUID tid = AsyncCommands. |
4636 | DataserverPlugin.RegisterRequest(m_localID, | 4470 | DataserverPlugin.RegisterRequest(m_host.LocalId, |
4637 | m_itemID, item.AssetID.ToString()); | 4471 | m_item.ItemID, item.AssetID.ToString()); |
4638 | 4472 | ||
4639 | Vector3 region = new Vector3( | 4473 | Vector3 region = new Vector3( |
4640 | World.RegionInfo.RegionLocX * Constants.RegionSize, | 4474 | World.RegionInfo.RegionLocX * Constants.RegionSize, |
@@ -5033,22 +4867,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5033 | 4867 | ||
5034 | public LSL_String llGetScriptName() | 4868 | public LSL_String llGetScriptName() |
5035 | { | 4869 | { |
5036 | string result = String.Empty; | ||
5037 | |||
5038 | m_host.AddScriptLPS(1); | 4870 | m_host.AddScriptLPS(1); |
5039 | 4871 | ||
5040 | m_host.TaskInventory.LockItemsForRead(true); | 4872 | return m_item.Name != null ? m_item.Name : String.Empty; |
5041 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
5042 | { | ||
5043 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
5044 | { | ||
5045 | result = item.Name!=null?item.Name:String.Empty; | ||
5046 | break; | ||
5047 | } | ||
5048 | } | ||
5049 | m_host.TaskInventory.LockItemsForRead(false); | ||
5050 | |||
5051 | return result; | ||
5052 | } | 4873 | } |
5053 | 4874 | ||
5054 | public LSL_Integer llGetLinkNumberOfSides(int link) | 4875 | public LSL_Integer llGetLinkNumberOfSides(int link) |
@@ -6333,7 +6154,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6333 | if (m_host.OwnerID == land.LandData.OwnerID) | 6154 | if (m_host.OwnerID == land.LandData.OwnerID) |
6334 | { | 6155 | { |
6335 | Vector3 pos = World.GetNearestAllowedPosition(presence, land); | 6156 | Vector3 pos = World.GetNearestAllowedPosition(presence, land); |
6336 | presence.TeleportWithMomentum(pos); | 6157 | presence.TeleportWithMomentum(pos, null); |
6337 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); | 6158 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); |
6338 | } | 6159 | } |
6339 | } | 6160 | } |
@@ -7280,14 +7101,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7280 | IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); | 7101 | IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); |
7281 | if (xmlrpcMod.IsEnabled()) | 7102 | if (xmlrpcMod.IsEnabled()) |
7282 | { | 7103 | { |
7283 | UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, UUID.Zero); | 7104 | UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_host.LocalId, m_item.ItemID, UUID.Zero); |
7284 | IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>(); | 7105 | IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>(); |
7285 | if (xmlRpcRouter != null) | 7106 | if (xmlRpcRouter != null) |
7286 | { | 7107 | { |
7287 | string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName; | 7108 | string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName; |
7288 | 7109 | ||
7289 | xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID, | 7110 | xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID, |
7290 | m_itemID, String.Format("http://{0}:{1}/", ExternalHostName, | 7111 | m_item.ItemID, String.Format("http://{0}:{1}/", ExternalHostName, |
7291 | xmlrpcMod.Port.ToString())); | 7112 | xmlrpcMod.Port.ToString())); |
7292 | } | 7113 | } |
7293 | object[] resobj = new object[] | 7114 | object[] resobj = new object[] |
@@ -7299,7 +7120,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7299 | new LSL_Integer(0), | 7120 | new LSL_Integer(0), |
7300 | new LSL_String(String.Empty) | 7121 | new LSL_String(String.Empty) |
7301 | }; | 7122 | }; |
7302 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams("remote_data", resobj, | 7123 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams("remote_data", resobj, |
7303 | new DetectParams[0])); | 7124 | new DetectParams[0])); |
7304 | } | 7125 | } |
7305 | ScriptSleep(1000); | 7126 | ScriptSleep(1000); |
@@ -7310,7 +7131,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7310 | m_host.AddScriptLPS(1); | 7131 | m_host.AddScriptLPS(1); |
7311 | IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); | 7132 | IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); |
7312 | ScriptSleep(3000); | 7133 | ScriptSleep(3000); |
7313 | return (xmlrpcMod.SendRemoteData(m_localID, m_itemID, channel, dest, idata, sdata)).ToString(); | 7134 | return (xmlrpcMod.SendRemoteData(m_host.LocalId, m_item.ItemID, channel, dest, idata, sdata)).ToString(); |
7314 | } | 7135 | } |
7315 | 7136 | ||
7316 | public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) | 7137 | public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) |
@@ -8149,7 +7970,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8149 | return; | 7970 | return; |
8150 | face = (int)rules.GetLSLIntegerItem(idx++); | 7971 | face = (int)rules.GetLSLIntegerItem(idx++); |
8151 | int shiny = (int)rules.GetLSLIntegerItem(idx++); | 7972 | int shiny = (int)rules.GetLSLIntegerItem(idx++); |
8152 | Bumpiness bump = (Bumpiness)Convert.ToByte((int)rules.GetLSLIntegerItem(idx++)); | 7973 | Bumpiness bump = (Bumpiness)(int)rules.GetLSLIntegerItem(idx++); |
8153 | 7974 | ||
8154 | SetShiny(part, face, shiny, bump); | 7975 | SetShiny(part, face, shiny, bump); |
8155 | 7976 | ||
@@ -9953,13 +9774,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9953 | { | 9774 | { |
9954 | m_host.AddScriptLPS(1); | 9775 | m_host.AddScriptLPS(1); |
9955 | if (m_UrlModule != null) | 9776 | if (m_UrlModule != null) |
9956 | return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); | 9777 | return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString(); |
9957 | return UUID.Zero.ToString(); | 9778 | return UUID.Zero.ToString(); |
9958 | } | 9779 | } |
9959 | 9780 | ||
9960 | public LSL_String llRequestSimulatorData(string simulator, int data) | 9781 | public LSL_String llRequestSimulatorData(string simulator, int data) |
9961 | { | 9782 | { |
9962 | IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_itemID, "OSSL"); | 9783 | IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL"); |
9963 | 9784 | ||
9964 | try | 9785 | try |
9965 | { | 9786 | { |
@@ -10021,7 +9842,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10021 | UUID rq = UUID.Random(); | 9842 | UUID rq = UUID.Random(); |
10022 | 9843 | ||
10023 | UUID tid = AsyncCommands. | 9844 | UUID tid = AsyncCommands. |
10024 | DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); | 9845 | DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString()); |
10025 | 9846 | ||
10026 | AsyncCommands. | 9847 | AsyncCommands. |
10027 | DataserverPlugin.DataserverReply(rq.ToString(), reply); | 9848 | DataserverPlugin.DataserverReply(rq.ToString(), reply); |
@@ -10040,7 +9861,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10040 | m_host.AddScriptLPS(1); | 9861 | m_host.AddScriptLPS(1); |
10041 | 9862 | ||
10042 | if (m_UrlModule != null) | 9863 | if (m_UrlModule != null) |
10043 | return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); | 9864 | return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString(); |
10044 | return UUID.Zero.ToString(); | 9865 | return UUID.Zero.ToString(); |
10045 | } | 9866 | } |
10046 | 9867 | ||
@@ -10076,7 +9897,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10076 | // child agents have a mass of 1.0 | 9897 | // child agents have a mass of 1.0 |
10077 | return 1; | 9898 | return 1; |
10078 | else | 9899 | else |
10079 | return avatar.GetMass(); | 9900 | return (double)avatar.GetMass(); |
10080 | } | 9901 | } |
10081 | catch (KeyNotFoundException) | 9902 | catch (KeyNotFoundException) |
10082 | { | 9903 | { |
@@ -10519,22 +10340,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10519 | public LSL_Vector llGetCameraPos() | 10340 | public LSL_Vector llGetCameraPos() |
10520 | { | 10341 | { |
10521 | m_host.AddScriptLPS(1); | 10342 | m_host.AddScriptLPS(1); |
10522 | UUID invItemID = InventorySelf(); | ||
10523 | 10343 | ||
10524 | if (invItemID == UUID.Zero) | 10344 | if (m_item.PermsGranter == UUID.Zero) |
10525 | return new LSL_Vector(); | 10345 | return new LSL_Vector(); |
10526 | 10346 | ||
10527 | m_host.TaskInventory.LockItemsForRead(true); | 10347 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
10528 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
10529 | { | ||
10530 | m_host.TaskInventory.LockItemsForRead(false); | ||
10531 | return new LSL_Vector(); | ||
10532 | } | ||
10533 | |||
10534 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
10535 | { | 10348 | { |
10536 | ShoutError("No permissions to track the camera"); | 10349 | ShoutError("No permissions to track the camera"); |
10537 | m_host.TaskInventory.LockItemsForRead(false); | ||
10538 | return new LSL_Vector(); | 10350 | return new LSL_Vector(); |
10539 | } | 10351 | } |
10540 | m_host.TaskInventory.LockItemsForRead(false); | 10352 | m_host.TaskInventory.LockItemsForRead(false); |
@@ -10551,20 +10363,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10551 | public LSL_Rotation llGetCameraRot() | 10363 | public LSL_Rotation llGetCameraRot() |
10552 | { | 10364 | { |
10553 | m_host.AddScriptLPS(1); | 10365 | m_host.AddScriptLPS(1); |
10554 | UUID invItemID = InventorySelf(); | ||
10555 | if (invItemID == UUID.Zero) | ||
10556 | return new LSL_Rotation(); | ||
10557 | 10366 | ||
10558 | m_host.TaskInventory.LockItemsForRead(true); | 10367 | if (m_item.PermsGranter == UUID.Zero) |
10559 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 10368 | return new LSL_Rotation(); |
10560 | { | 10369 | |
10561 | m_host.TaskInventory.LockItemsForRead(false); | 10370 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
10562 | return new LSL_Rotation(); | ||
10563 | } | ||
10564 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
10565 | { | 10371 | { |
10566 | ShoutError("No permissions to track the camera"); | 10372 | ShoutError("No permissions to track the camera"); |
10567 | m_host.TaskInventory.LockItemsForRead(false); | ||
10568 | return new LSL_Rotation(); | 10373 | return new LSL_Rotation(); |
10569 | } | 10374 | } |
10570 | m_host.TaskInventory.LockItemsForRead(false); | 10375 | m_host.TaskInventory.LockItemsForRead(false); |
@@ -10628,7 +10433,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10628 | public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt) | 10433 | public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt) |
10629 | { | 10434 | { |
10630 | m_host.AddScriptLPS(1); | 10435 | m_host.AddScriptLPS(1); |
10631 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); | 10436 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); |
10632 | if (detectedParams == null) | 10437 | if (detectedParams == null) |
10633 | { | 10438 | { |
10634 | if (m_host.ParentGroup.IsAttachment == true) | 10439 | if (m_host.ParentGroup.IsAttachment == true) |
@@ -10752,30 +10557,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10752 | { | 10557 | { |
10753 | m_host.AddScriptLPS(1); | 10558 | m_host.AddScriptLPS(1); |
10754 | 10559 | ||
10755 | // our key in the object we are in | ||
10756 | UUID invItemID = InventorySelf(); | ||
10757 | if (invItemID == UUID.Zero) return; | ||
10758 | |||
10759 | // the object we are in | 10560 | // the object we are in |
10760 | UUID objectID = m_host.ParentUUID; | 10561 | UUID objectID = m_host.ParentUUID; |
10761 | if (objectID == UUID.Zero) return; | 10562 | if (objectID == UUID.Zero) |
10563 | return; | ||
10762 | 10564 | ||
10763 | UUID agentID; | ||
10764 | m_host.TaskInventory.LockItemsForRead(true); | ||
10765 | // we need the permission first, to know which avatar we want to set the camera for | 10565 | // we need the permission first, to know which avatar we want to set the camera for |
10766 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 10566 | UUID agentID = m_item.PermsGranter; |
10767 | 10567 | ||
10768 | if (agentID == UUID.Zero) | 10568 | if (agentID == UUID.Zero) |
10769 | { | ||
10770 | m_host.TaskInventory.LockItemsForRead(false); | ||
10771 | return; | 10569 | return; |
10772 | } | 10570 | |
10773 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | 10571 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) |
10774 | { | ||
10775 | m_host.TaskInventory.LockItemsForRead(false); | ||
10776 | return; | 10572 | return; |
10777 | } | ||
10778 | m_host.TaskInventory.LockItemsForRead(false); | ||
10779 | 10573 | ||
10780 | ScenePresence presence = World.GetScenePresence(agentID); | 10574 | ScenePresence presence = World.GetScenePresence(agentID); |
10781 | 10575 | ||
@@ -10817,34 +10611,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10817 | { | 10611 | { |
10818 | m_host.AddScriptLPS(1); | 10612 | m_host.AddScriptLPS(1); |
10819 | 10613 | ||
10820 | // our key in the object we are in | ||
10821 | UUID invItemID=InventorySelf(); | ||
10822 | if (invItemID == UUID.Zero) return; | ||
10823 | |||
10824 | // the object we are in | 10614 | // the object we are in |
10825 | UUID objectID = m_host.ParentUUID; | 10615 | UUID objectID = m_host.ParentUUID; |
10826 | if (objectID == UUID.Zero) return; | 10616 | if (objectID == UUID.Zero) |
10617 | return; | ||
10827 | 10618 | ||
10828 | // we need the permission first, to know which avatar we want to clear the camera for | 10619 | // we need the permission first, to know which avatar we want to clear the camera for |
10829 | UUID agentID; | 10620 | UUID agentID = m_item.PermsGranter; |
10830 | m_host.TaskInventory.LockItemsForRead(true); | 10621 | |
10831 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
10832 | if (agentID == UUID.Zero) | 10622 | if (agentID == UUID.Zero) |
10833 | { | ||
10834 | m_host.TaskInventory.LockItemsForRead(false); | ||
10835 | return; | 10623 | return; |
10836 | } | 10624 | |
10837 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | 10625 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) |
10838 | { | ||
10839 | m_host.TaskInventory.LockItemsForRead(false); | ||
10840 | return; | 10626 | return; |
10841 | } | ||
10842 | m_host.TaskInventory.LockItemsForRead(false); | ||
10843 | 10627 | ||
10844 | ScenePresence presence = World.GetScenePresence(agentID); | 10628 | ScenePresence presence = World.GetScenePresence(agentID); |
10845 | 10629 | ||
10846 | // we are not interested in child-agents | 10630 | // we are not interested in child-agents |
10847 | if (presence.IsChildAgent) return; | 10631 | if (presence.IsChildAgent) |
10632 | return; | ||
10848 | 10633 | ||
10849 | presence.ControllingClient.SendClearFollowCamProperties(objectID); | 10634 | presence.ControllingClient.SendClearFollowCamProperties(objectID); |
10850 | } | 10635 | } |
@@ -11035,8 +10820,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11035 | } | 10820 | } |
11036 | } | 10821 | } |
11037 | 10822 | ||
11038 | UUID reqID = httpScriptMod. | 10823 | UUID reqID |
11039 | StartHttpRequest(m_localID, m_itemID, url, param, httpHeaders, body); | 10824 | = httpScriptMod.StartHttpRequest(m_host.LocalId, m_item.ItemID, url, param, httpHeaders, body); |
11040 | 10825 | ||
11041 | if (reqID != UUID.Zero) | 10826 | if (reqID != UUID.Zero) |
11042 | return reqID.ToString(); | 10827 | return reqID.ToString(); |
@@ -11268,19 +11053,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11268 | break; | 11053 | break; |
11269 | // For the following 8 see the Object version below | 11054 | // For the following 8 see the Object version below |
11270 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: | 11055 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: |
11271 | ret.Add(new LSL_Integer(0)); | 11056 | ret.Add(new LSL_Integer(av.RunningScriptCount())); |
11272 | break; | 11057 | break; |
11273 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: | 11058 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: |
11274 | ret.Add(new LSL_Integer(0)); | 11059 | ret.Add(new LSL_Integer(av.ScriptCount())); |
11275 | break; | 11060 | break; |
11276 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: | 11061 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: |
11277 | ret.Add(new LSL_Integer(0)); | 11062 | ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384)); |
11278 | break; | 11063 | break; |
11279 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: | 11064 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: |
11280 | ret.Add(new LSL_Float(0)); | 11065 | ret.Add(new LSL_Float(av.ScriptExecutionTime() / 1000.0f)); |
11281 | break; | 11066 | break; |
11282 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: | 11067 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: |
11283 | ret.Add(new LSL_Integer(0)); | 11068 | ret.Add(new LSL_Integer(1)); |
11284 | break; | 11069 | break; |
11285 | case ScriptBaseClass.OBJECT_SERVER_COST: | 11070 | case ScriptBaseClass.OBJECT_SERVER_COST: |
11286 | ret.Add(new LSL_Float(0)); | 11071 | ret.Add(new LSL_Float(0)); |
@@ -11332,43 +11117,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11332 | case ScriptBaseClass.OBJECT_CREATOR: | 11117 | case ScriptBaseClass.OBJECT_CREATOR: |
11333 | ret.Add(new LSL_String(obj.CreatorID.ToString())); | 11118 | ret.Add(new LSL_String(obj.CreatorID.ToString())); |
11334 | break; | 11119 | break; |
11335 | // The following 8 I have intentionaly coded to return zero. They are part of | ||
11336 | // "Land Impact" calculations. These calculations are probably not applicable | ||
11337 | // to OpenSim, required figures (cpu/memory usage) are not currently tracked | ||
11338 | // I have intentionally left these all at zero rather than return possibly | ||
11339 | // missleading numbers | ||
11340 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: | 11120 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: |
11341 | // in SL this currently includes crashed scripts | 11121 | ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount())); |
11342 | ret.Add(new LSL_Integer(0)); | ||
11343 | break; | 11122 | break; |
11344 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: | 11123 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: |
11345 | ret.Add(new LSL_Integer(0)); | 11124 | ret.Add(new LSL_Integer(obj.ParentGroup.ScriptCount())); |
11346 | break; | 11125 | break; |
11347 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: | 11126 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: |
11348 | // The value returned in SL for mono scripts is 65536 * number of active scripts | 11127 | // The value returned in SL for mono scripts is 65536 * number of active scripts |
11349 | ret.Add(new LSL_Integer(0)); | 11128 | // and 16384 * number of active scripts for LSO. since llGetFreememory |
11129 | // is coded to give the LSO value use it here | ||
11130 | ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384)); | ||
11350 | break; | 11131 | break; |
11351 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: | 11132 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: |
11352 | // Average cpu time per simulator frame expended on all scripts in the objetc | 11133 | // Average cpu time in seconds per simulator frame expended on all scripts in the object |
11353 | ret.Add(new LSL_Float(0)); | 11134 | ret.Add(new LSL_Float(obj.ParentGroup.ScriptExecutionTime() / 1000.0f)); |
11354 | break; | 11135 | break; |
11355 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: | 11136 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: |
11356 | // according to the SL wiki A prim or linkset will have prim | 11137 | // according to the SL wiki A prim or linkset will have prim |
11357 | // equivalent of the number of prims in a linkset if it does not | 11138 | // equivalent of the number of prims in a linkset if it does not |
11358 | // contain a mesh anywhere in the link set or is not a normal prim | 11139 | // contain a mesh anywhere in the link set or is not a normal prim |
11359 | // The value returned in SL for normal prims is prim count | 11140 | // The value returned in SL for normal prims is prim count |
11360 | ret.Add(new LSL_Integer(0)); | 11141 | ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); |
11361 | break; | 11142 | break; |
11143 | // The following 3 costs I have intentionaly coded to return zero. They are part of | ||
11144 | // "Land Impact" calculations. These calculations are probably not applicable | ||
11145 | // to OpenSim and are not yet complete in SL | ||
11362 | case ScriptBaseClass.OBJECT_SERVER_COST: | 11146 | case ScriptBaseClass.OBJECT_SERVER_COST: |
11363 | // The value returned in SL for normal prims is prim count | 11147 | // The linden calculation is here |
11148 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight | ||
11149 | // The value returned in SL for normal prims looks like the prim count | ||
11364 | ret.Add(new LSL_Float(0)); | 11150 | ret.Add(new LSL_Float(0)); |
11365 | break; | 11151 | break; |
11366 | case ScriptBaseClass.OBJECT_STREAMING_COST: | 11152 | case ScriptBaseClass.OBJECT_STREAMING_COST: |
11367 | // The value returned in SL for normal prims is prim count * 0.06 | 11153 | // The linden calculation is here |
11154 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost | ||
11155 | // The value returned in SL for normal prims looks like the prim count * 0.06 | ||
11368 | ret.Add(new LSL_Float(0)); | 11156 | ret.Add(new LSL_Float(0)); |
11369 | break; | 11157 | break; |
11370 | case ScriptBaseClass.OBJECT_PHYSICS_COST: | 11158 | case ScriptBaseClass.OBJECT_PHYSICS_COST: |
11371 | // The value returned in SL for normal prims is prim count | 11159 | // The linden calculation is here |
11160 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics | ||
11161 | // The value returned in SL for normal prims looks like the prim count | ||
11372 | ret.Add(new LSL_Float(0)); | 11162 | ret.Add(new LSL_Float(0)); |
11373 | break; | 11163 | break; |
11374 | default: | 11164 | default: |
@@ -11466,7 +11256,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11466 | } | 11256 | } |
11467 | 11257 | ||
11468 | // was: UUID tid = tid = AsyncCommands. | 11258 | // was: UUID tid = tid = AsyncCommands. |
11469 | UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); | 11259 | UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString()); |
11470 | 11260 | ||
11471 | if (NotecardCache.IsCached(assetID)) | 11261 | if (NotecardCache.IsCached(assetID)) |
11472 | { | 11262 | { |
@@ -11529,7 +11319,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11529 | } | 11319 | } |
11530 | 11320 | ||
11531 | // was: UUID tid = tid = AsyncCommands. | 11321 | // was: UUID tid = tid = AsyncCommands. |
11532 | UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); | 11322 | UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString()); |
11533 | 11323 | ||
11534 | if (NotecardCache.IsCached(assetID)) | 11324 | if (NotecardCache.IsCached(assetID)) |
11535 | { | 11325 | { |
@@ -11613,7 +11403,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11613 | { | 11403 | { |
11614 | UUID rq = UUID.Random(); | 11404 | UUID rq = UUID.Random(); |
11615 | 11405 | ||
11616 | AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); | 11406 | AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString()); |
11617 | 11407 | ||
11618 | AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); | 11408 | AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); |
11619 | 11409 | ||
@@ -11629,7 +11419,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11629 | { | 11419 | { |
11630 | UUID rq = UUID.Random(); | 11420 | UUID rq = UUID.Random(); |
11631 | 11421 | ||
11632 | AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); | 11422 | AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString()); |
11633 | 11423 | ||
11634 | AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); | 11424 | AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); |
11635 | 11425 | ||
@@ -12123,7 +11913,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12123 | bool isAccount = false; | 11913 | bool isAccount = false; |
12124 | bool isGroup = false; | 11914 | bool isGroup = false; |
12125 | 11915 | ||
12126 | if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManager(m_host.OwnerID)) | 11916 | if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID)) |
12127 | return 0; | 11917 | return 0; |
12128 | 11918 | ||
12129 | UUID id = new UUID(); | 11919 | UUID id = new UUID(); |
@@ -12185,35 +11975,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12185 | return 1; | 11975 | return 1; |
12186 | } | 11976 | } |
12187 | 11977 | ||
12188 | #region Not Implemented | 11978 | public LSL_Integer llGetMemoryLimit() |
12189 | // | 11979 | { |
12190 | // Listing the unimplemented lsl functions here, please move | 11980 | m_host.AddScriptLPS(1); |
12191 | // them from this region as they are completed | 11981 | // The value returned for LSO scripts in SL |
12192 | // | 11982 | return 16384; |
11983 | } | ||
12193 | 11984 | ||
12194 | public void llGetEnv(LSL_String name) | 11985 | public LSL_Integer llSetMemoryLimit(LSL_Integer limit) |
12195 | { | 11986 | { |
12196 | m_host.AddScriptLPS(1); | 11987 | m_host.AddScriptLPS(1); |
12197 | NotImplemented("llGetEnv"); | 11988 | // Treat as an LSO script |
11989 | return ScriptBaseClass.FALSE; | ||
12198 | } | 11990 | } |
12199 | 11991 | ||
12200 | public void llGetSPMaxMemory() | 11992 | public LSL_Integer llGetSPMaxMemory() |
12201 | { | 11993 | { |
12202 | m_host.AddScriptLPS(1); | 11994 | m_host.AddScriptLPS(1); |
12203 | NotImplemented("llGetSPMaxMemory"); | 11995 | // The value returned for LSO scripts in SL |
11996 | return 16384; | ||
12204 | } | 11997 | } |
12205 | 11998 | ||
12206 | public virtual LSL_Integer llGetUsedMemory() | 11999 | public virtual LSL_Integer llGetUsedMemory() |
12207 | { | 12000 | { |
12208 | m_host.AddScriptLPS(1); | 12001 | m_host.AddScriptLPS(1); |
12209 | NotImplemented("llGetUsedMemory"); | 12002 | // The value returned for LSO scripts in SL |
12210 | return 0; | 12003 | return 16384; |
12211 | } | 12004 | } |
12212 | 12005 | ||
12213 | public void llScriptProfiler(LSL_Integer flags) | 12006 | public void llScriptProfiler(LSL_Integer flags) |
12214 | { | 12007 | { |
12215 | m_host.AddScriptLPS(1); | 12008 | m_host.AddScriptLPS(1); |
12216 | //NotImplemented("llScriptProfiler"); | 12009 | // This does nothing for LSO scripts in SL |
12010 | } | ||
12011 | |||
12012 | #region Not Implemented | ||
12013 | // | ||
12014 | // Listing the unimplemented lsl functions here, please move | ||
12015 | // them from this region as they are completed | ||
12016 | // | ||
12017 | |||
12018 | public void llGetEnv(LSL_String name) | ||
12019 | { | ||
12020 | m_host.AddScriptLPS(1); | ||
12021 | NotImplemented("llGetEnv"); | ||
12217 | } | 12022 | } |
12218 | 12023 | ||
12219 | public void llSetSoundQueueing(int queue) | 12024 | public void llSetSoundQueueing(int queue) |
@@ -12293,8 +12098,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12293 | 12098 | ||
12294 | try | 12099 | try |
12295 | { | 12100 | { |
12296 | UUID invItemID=InventorySelf(); | 12101 | TaskInventoryItem item = m_item; |
12297 | if (invItemID == UUID.Zero) | 12102 | if (item == null) |
12298 | { | 12103 | { |
12299 | replydata = "SERVICE_ERROR"; | 12104 | replydata = "SERVICE_ERROR"; |
12300 | return; | 12105 | return; |
@@ -12302,10 +12107,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12302 | 12107 | ||
12303 | m_host.AddScriptLPS(1); | 12108 | m_host.AddScriptLPS(1); |
12304 | 12109 | ||
12305 | m_host.TaskInventory.LockItemsForRead(true); | ||
12306 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | ||
12307 | m_host.TaskInventory.LockItemsForRead(false); | ||
12308 | |||
12309 | if (item.PermsGranter == UUID.Zero) | 12110 | if (item.PermsGranter == UUID.Zero) |
12310 | { | 12111 | { |
12311 | replydata = "MISSING_PERMISSION_DEBIT"; | 12112 | replydata = "MISSING_PERMISSION_DEBIT"; |
@@ -12347,7 +12148,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12347 | } | 12148 | } |
12348 | finally | 12149 | finally |
12349 | { | 12150 | { |
12350 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 12151 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
12351 | "transaction_result", new Object[] { | 12152 | "transaction_result", new Object[] { |
12352 | new LSL_String(txn.ToString()), | 12153 | new LSL_String(txn.ToString()), |
12353 | new LSL_Integer(replycode), | 12154 | new LSL_Integer(replycode), |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index 77a784d..795de80 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | |||
@@ -58,17 +58,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
58 | { | 58 | { |
59 | internal IScriptEngine m_ScriptEngine; | 59 | internal IScriptEngine m_ScriptEngine; |
60 | internal SceneObjectPart m_host; | 60 | internal SceneObjectPart m_host; |
61 | internal uint m_localID; | ||
62 | internal UUID m_itemID; | ||
63 | internal bool m_LSFunctionsEnabled = false; | 61 | internal bool m_LSFunctionsEnabled = false; |
64 | internal IScriptModuleComms m_comms = null; | 62 | internal IScriptModuleComms m_comms = null; |
65 | 63 | ||
66 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | 64 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) |
67 | { | 65 | { |
68 | m_ScriptEngine = ScriptEngine; | 66 | m_ScriptEngine = ScriptEngine; |
69 | m_host = host; | 67 | m_host = host; |
70 | m_localID = localID; | ||
71 | m_itemID = itemID; | ||
72 | 68 | ||
73 | if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) | 69 | if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) |
74 | m_LSFunctionsEnabled = true; | 70 | m_LSFunctionsEnabled = true; |
@@ -449,7 +445,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
449 | LSShoutError("LightShare functions are not enabled."); | 445 | LSShoutError("LightShare functions are not enabled."); |
450 | return 0; | 446 | return 0; |
451 | } | 447 | } |
452 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 448 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
453 | { | 449 | { |
454 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | 450 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); |
455 | return 0; | 451 | return 0; |
@@ -477,7 +473,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
477 | LSShoutError("LightShare functions are not enabled."); | 473 | LSShoutError("LightShare functions are not enabled."); |
478 | return; | 474 | return; |
479 | } | 475 | } |
480 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 476 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
481 | { | 477 | { |
482 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | 478 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); |
483 | return; | 479 | return; |
@@ -500,7 +496,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
500 | LSShoutError("LightShare functions are not enabled."); | 496 | LSShoutError("LightShare functions are not enabled."); |
501 | return 0; | 497 | return 0; |
502 | } | 498 | } |
503 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 499 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
504 | { | 500 | { |
505 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); | 501 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); |
506 | return 0; | 502 | return 0; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 7c07e15..4bd3dff 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -57,17 +57,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
57 | { | 57 | { |
58 | internal IScriptEngine m_ScriptEngine; | 58 | internal IScriptEngine m_ScriptEngine; |
59 | internal SceneObjectPart m_host; | 59 | internal SceneObjectPart m_host; |
60 | internal uint m_localID; | 60 | internal TaskInventoryItem m_item; |
61 | internal UUID m_itemID; | ||
62 | internal bool m_MODFunctionsEnabled = false; | 61 | internal bool m_MODFunctionsEnabled = false; |
63 | internal IScriptModuleComms m_comms = null; | 62 | internal IScriptModuleComms m_comms = null; |
64 | 63 | ||
65 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | 64 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) |
66 | { | 65 | { |
67 | m_ScriptEngine = ScriptEngine; | 66 | m_ScriptEngine = ScriptEngine; |
68 | m_host = host; | 67 | m_host = host; |
69 | m_localID = localID; | 68 | m_item = item; |
70 | m_itemID = itemID; | ||
71 | 69 | ||
72 | if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) | 70 | if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) |
73 | m_MODFunctionsEnabled = true; | 71 | m_MODFunctionsEnabled = true; |
@@ -252,7 +250,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
252 | // non-null but don't trust it completely | 250 | // non-null but don't trust it completely |
253 | try | 251 | try |
254 | { | 252 | { |
255 | object result = m_comms.InvokeOperation(m_host.UUID, m_itemID, fname, convertedParms); | 253 | object result = m_comms.InvokeOperation(m_host.UUID, m_item.ItemID, fname, convertedParms); |
256 | if (result != null) | 254 | if (result != null) |
257 | return result; | 255 | return result; |
258 | 256 | ||
@@ -279,7 +277,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
279 | 277 | ||
280 | UUID req = UUID.Random(); | 278 | UUID req = UUID.Random(); |
281 | 279 | ||
282 | m_comms.RaiseEvent(m_itemID, req.ToString(), module, command, k); | 280 | m_comms.RaiseEvent(m_item.ItemID, req.ToString(), module, command, k); |
283 | 281 | ||
284 | return req.ToString(); | 282 | return req.ToString(); |
285 | } | 283 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 0dc2aa2..51ace1a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -128,11 +128,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
128 | { | 128 | { |
129 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 129 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
130 | 130 | ||
131 | public const string GridInfoServiceConfigSectionName = "GridInfoService"; | ||
132 | |||
131 | internal IScriptEngine m_ScriptEngine; | 133 | internal IScriptEngine m_ScriptEngine; |
132 | internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there | 134 | internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there |
133 | internal SceneObjectPart m_host; | 135 | internal SceneObjectPart m_host; |
134 | internal uint m_localID; | 136 | internal TaskInventoryItem m_item; |
135 | internal UUID m_itemID; | ||
136 | internal bool m_OSFunctionsEnabled = false; | 137 | internal bool m_OSFunctionsEnabled = false; |
137 | internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; | 138 | internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; |
138 | internal float m_ScriptDelayFactor = 1.0f; | 139 | internal float m_ScriptDelayFactor = 1.0f; |
@@ -140,12 +141,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
140 | internal bool m_debuggerSafe = false; | 141 | internal bool m_debuggerSafe = false; |
141 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); | 142 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); |
142 | 143 | ||
143 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | 144 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) |
144 | { | 145 | { |
145 | m_ScriptEngine = ScriptEngine; | 146 | m_ScriptEngine = ScriptEngine; |
146 | m_host = host; | 147 | m_host = host; |
147 | m_localID = localID; | 148 | m_item = item; |
148 | m_itemID = itemID; | ||
149 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | 149 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); |
150 | 150 | ||
151 | if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | 151 | if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) |
@@ -218,12 +218,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | /// <summary> | ||
222 | /// Initialize the LSL interface. | ||
223 | /// </summary> | ||
224 | /// <remarks> | ||
225 | /// FIXME: This is an abomination. We should be able to set this up earlier but currently we have no | ||
226 | /// guarantee the interface is present on Initialize(). There needs to be another post initialize call from | ||
227 | /// ScriptInstance. | ||
228 | /// </remarks> | ||
221 | private void InitLSL() | 229 | private void InitLSL() |
222 | { | 230 | { |
223 | if (m_LSL_Api != null) | 231 | if (m_LSL_Api != null) |
224 | return; | 232 | return; |
225 | 233 | ||
226 | m_LSL_Api = (ILSL_Api)m_ScriptEngine.GetApi(m_itemID, "LSL"); | 234 | m_LSL_Api = (ILSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "LSL"); |
227 | } | 235 | } |
228 | 236 | ||
229 | // | 237 | // |
@@ -342,22 +350,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
342 | return; | 350 | return; |
343 | } | 351 | } |
344 | 352 | ||
345 | TaskInventoryItem ti = m_host.Inventory.GetInventoryItem(m_itemID); | 353 | UUID ownerID = m_item.OwnerID; |
346 | if (ti == null) | ||
347 | { | ||
348 | OSSLError( | ||
349 | String.Format("{0} permission error. Can't find script in prim inventory.", | ||
350 | function)); | ||
351 | } | ||
352 | |||
353 | UUID ownerID = ti.OwnerID; | ||
354 | 354 | ||
355 | //OSSL only may be used if objet is in the same group as the parcel | 355 | //OSSL only may be used if object is in the same group as the parcel |
356 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) | 356 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) |
357 | { | 357 | { |
358 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); | 358 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); |
359 | 359 | ||
360 | if (land.LandData.GroupID == ti.GroupID && land.LandData.GroupID != UUID.Zero) | 360 | if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero) |
361 | { | 361 | { |
362 | return; | 362 | return; |
363 | } | 363 | } |
@@ -378,7 +378,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
378 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) | 378 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) |
379 | { | 379 | { |
380 | //Only Estate Managers may use the function | 380 | //Only Estate Managers may use the function |
381 | if (World.RegionInfo.EstateSettings.IsEstateManager(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) | 381 | if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) |
382 | { | 382 | { |
383 | return; | 383 | return; |
384 | } | 384 | } |
@@ -393,13 +393,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
393 | } | 393 | } |
394 | } | 394 | } |
395 | 395 | ||
396 | if (!m_FunctionPerms[function].AllowedCreators.Contains(ti.CreatorID)) | 396 | if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID)) |
397 | OSSLError( | 397 | OSSLError( |
398 | String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", | 398 | String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", |
399 | function)); | 399 | function)); |
400 | if (ti.CreatorID != ownerID) | 400 | |
401 | if (m_item.CreatorID != ownerID) | ||
401 | { | 402 | { |
402 | if ((ti.CurrentPermissions & (uint)PermissionMask.Modify) != 0) | 403 | if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0) |
403 | OSSLError( | 404 | OSSLError( |
404 | String.Format("{0} permission denied. Script permissions error.", | 405 | String.Format("{0} permission denied. Script permissions error.", |
405 | function)); | 406 | function)); |
@@ -730,11 +731,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
730 | 731 | ||
731 | m_host.AddScriptLPS(1); | 732 | m_host.AddScriptLPS(1); |
732 | 733 | ||
734 | // For safety, we add another permission check here, and don't rely only on the standard OSSL permissions | ||
733 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) | 735 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) |
734 | { | 736 | { |
735 | MainConsole.Instance.RunCommand(command); | 737 | MainConsole.Instance.RunCommand(command); |
736 | return true; | 738 | return true; |
737 | } | 739 | } |
740 | |||
738 | return false; | 741 | return false; |
739 | } | 742 | } |
740 | 743 | ||
@@ -1178,7 +1181,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1178 | CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); | 1181 | CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); |
1179 | m_host.AddScriptLPS(1); | 1182 | m_host.AddScriptLPS(1); |
1180 | 1183 | ||
1181 | m_host.SetScriptEvents(m_itemID, events); | 1184 | m_host.SetScriptEvents(m_item.ItemID, events); |
1182 | } | 1185 | } |
1183 | 1186 | ||
1184 | public void osSetRegionWaterHeight(double height) | 1187 | public void osSetRegionWaterHeight(double height) |
@@ -1186,12 +1189,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1186 | CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); | 1189 | CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); |
1187 | 1190 | ||
1188 | m_host.AddScriptLPS(1); | 1191 | m_host.AddScriptLPS(1); |
1189 | //Check to make sure that the script's owner is the estate manager/master | 1192 | |
1190 | //World.Permissions.GenericEstatePermission( | 1193 | World.EventManager.TriggerRequestChangeWaterHeight((float)height); |
1191 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
1192 | { | ||
1193 | World.EventManager.TriggerRequestChangeWaterHeight((float)height); | ||
1194 | } | ||
1195 | } | 1194 | } |
1196 | 1195 | ||
1197 | /// <summary> | 1196 | /// <summary> |
@@ -1202,27 +1201,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1202 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> | 1201 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> |
1203 | public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) | 1202 | public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) |
1204 | { | 1203 | { |
1205 | CheckThreatLevel(ThreatLevel.Nuisance, "osSetRegionSunSettings"); | 1204 | CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings"); |
1206 | 1205 | ||
1207 | m_host.AddScriptLPS(1); | 1206 | m_host.AddScriptLPS(1); |
1208 | //Check to make sure that the script's owner is the estate manager/master | ||
1209 | //World.Permissions.GenericEstatePermission( | ||
1210 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
1211 | { | ||
1212 | while (sunHour > 24.0) | ||
1213 | sunHour -= 24.0; | ||
1214 | 1207 | ||
1215 | while (sunHour < 0) | 1208 | while (sunHour > 24.0) |
1216 | sunHour += 24.0; | 1209 | sunHour -= 24.0; |
1217 | 1210 | ||
1211 | while (sunHour < 0) | ||
1212 | sunHour += 24.0; | ||
1218 | 1213 | ||
1219 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; | 1214 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; |
1220 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 | 1215 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 |
1221 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; | 1216 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; |
1222 | World.RegionInfo.RegionSettings.Save(); | 1217 | World.RegionInfo.RegionSettings.Save(); |
1223 | 1218 | ||
1224 | World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); | 1219 | World.EventManager.TriggerEstateToolsSunUpdate( |
1225 | } | 1220 | World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); |
1226 | } | 1221 | } |
1227 | 1222 | ||
1228 | /// <summary> | 1223 | /// <summary> |
@@ -1232,26 +1227,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1232 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> | 1227 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> |
1233 | public void osSetEstateSunSettings(bool sunFixed, double sunHour) | 1228 | public void osSetEstateSunSettings(bool sunFixed, double sunHour) |
1234 | { | 1229 | { |
1235 | CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings"); | 1230 | CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings"); |
1236 | 1231 | ||
1237 | m_host.AddScriptLPS(1); | 1232 | m_host.AddScriptLPS(1); |
1238 | //Check to make sure that the script's owner is the estate manager/master | ||
1239 | //World.Permissions.GenericEstatePermission( | ||
1240 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
1241 | { | ||
1242 | while (sunHour > 24.0) | ||
1243 | sunHour -= 24.0; | ||
1244 | 1233 | ||
1245 | while (sunHour < 0) | 1234 | while (sunHour > 24.0) |
1246 | sunHour += 24.0; | 1235 | sunHour -= 24.0; |
1247 | 1236 | ||
1248 | World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; | 1237 | while (sunHour < 0) |
1249 | World.RegionInfo.EstateSettings.SunPosition = sunHour; | 1238 | sunHour += 24.0; |
1250 | World.RegionInfo.EstateSettings.FixedSun = sunFixed; | ||
1251 | World.RegionInfo.EstateSettings.Save(); | ||
1252 | 1239 | ||
1253 | World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); | 1240 | World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; |
1254 | } | 1241 | World.RegionInfo.EstateSettings.SunPosition = sunHour; |
1242 | World.RegionInfo.EstateSettings.FixedSun = sunFixed; | ||
1243 | World.RegionInfo.EstateSettings.Save(); | ||
1244 | |||
1245 | World.EventManager.TriggerEstateToolsSunUpdate( | ||
1246 | World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); | ||
1255 | } | 1247 | } |
1256 | 1248 | ||
1257 | /// <summary> | 1249 | /// <summary> |
@@ -1627,7 +1619,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1627 | 1619 | ||
1628 | public Object osParseJSONNew(string JSON) | 1620 | public Object osParseJSONNew(string JSON) |
1629 | { | 1621 | { |
1630 | CheckThreatLevel(ThreatLevel.None, "osParseJSON"); | 1622 | CheckThreatLevel(ThreatLevel.None, "osParseJSONNew"); |
1631 | 1623 | ||
1632 | m_host.AddScriptLPS(1); | 1624 | m_host.AddScriptLPS(1); |
1633 | 1625 | ||
@@ -2042,8 +2034,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2042 | string nick = String.Empty; | 2034 | string nick = String.Empty; |
2043 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2035 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2044 | 2036 | ||
2045 | if (config.Configs["GridInfo"] != null) | 2037 | if (config.Configs[GridInfoServiceConfigSectionName] != null) |
2046 | nick = config.Configs["GridInfo"].GetString("gridnick", nick); | 2038 | nick = config.Configs[GridInfoServiceConfigSectionName].GetString("gridnick", nick); |
2047 | 2039 | ||
2048 | if (String.IsNullOrEmpty(nick)) | 2040 | if (String.IsNullOrEmpty(nick)) |
2049 | nick = GridUserInfo(InfoType.Nick); | 2041 | nick = GridUserInfo(InfoType.Nick); |
@@ -2059,8 +2051,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2059 | string name = String.Empty; | 2051 | string name = String.Empty; |
2060 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2052 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2061 | 2053 | ||
2062 | if (config.Configs["GridInfo"] != null) | 2054 | if (config.Configs[GridInfoServiceConfigSectionName] != null) |
2063 | name = config.Configs["GridInfo"].GetString("gridname", name); | 2055 | name = config.Configs[GridInfoServiceConfigSectionName].GetString("gridname", name); |
2064 | 2056 | ||
2065 | if (String.IsNullOrEmpty(name)) | 2057 | if (String.IsNullOrEmpty(name)) |
2066 | name = GridUserInfo(InfoType.Name); | 2058 | name = GridUserInfo(InfoType.Name); |
@@ -2076,8 +2068,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2076 | string loginURI = String.Empty; | 2068 | string loginURI = String.Empty; |
2077 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2069 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2078 | 2070 | ||
2079 | if (config.Configs["GridInfo"] != null) | 2071 | if (config.Configs[GridInfoServiceConfigSectionName] != null) |
2080 | loginURI = config.Configs["GridInfo"].GetString("login", loginURI); | 2072 | loginURI = config.Configs[GridInfoServiceConfigSectionName].GetString("login", loginURI); |
2081 | 2073 | ||
2082 | if (String.IsNullOrEmpty(loginURI)) | 2074 | if (String.IsNullOrEmpty(loginURI)) |
2083 | loginURI = GridUserInfo(InfoType.Login); | 2075 | loginURI = GridUserInfo(InfoType.Login); |
@@ -2124,8 +2116,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2124 | string retval = String.Empty; | 2116 | string retval = String.Empty; |
2125 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2117 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2126 | 2118 | ||
2127 | if (config.Configs["GridInfo"] != null) | 2119 | if (config.Configs[GridInfoServiceConfigSectionName] != null) |
2128 | retval = config.Configs["GridInfo"].GetString(key, retval); | 2120 | retval = config.Configs[GridInfoServiceConfigSectionName].GetString(key, retval); |
2129 | 2121 | ||
2130 | if (String.IsNullOrEmpty(retval)) | 2122 | if (String.IsNullOrEmpty(retval)) |
2131 | retval = GridUserInfo(InfoType.Custom, key); | 2123 | retval = GridUserInfo(InfoType.Custom, key); |
@@ -2480,7 +2472,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2480 | return; | 2472 | return; |
2481 | 2473 | ||
2482 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); | 2474 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); |
2483 | module.MoveToTarget(npcId, World, pos, false, true); | 2475 | module.MoveToTarget(npcId, World, pos, false, true, false); |
2484 | } | 2476 | } |
2485 | } | 2477 | } |
2486 | 2478 | ||
@@ -2505,7 +2497,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2505 | World, | 2497 | World, |
2506 | pos, | 2498 | pos, |
2507 | (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, | 2499 | (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, |
2508 | (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0); | 2500 | (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0, |
2501 | (options & ScriptBaseClass.OS_NPC_RUNNING) != 0); | ||
2509 | } | 2502 | } |
2510 | } | 2503 | } |
2511 | 2504 | ||
@@ -2555,7 +2548,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2555 | 2548 | ||
2556 | public void osNpcStopMoveToTarget(LSL_Key npc) | 2549 | public void osNpcStopMoveToTarget(LSL_Key npc) |
2557 | { | 2550 | { |
2558 | CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); | 2551 | CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget"); |
2559 | m_host.AddScriptLPS(1); | 2552 | m_host.AddScriptLPS(1); |
2560 | 2553 | ||
2561 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2554 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
@@ -2572,6 +2565,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2572 | 2565 | ||
2573 | public void osNpcSay(LSL_Key npc, string message) | 2566 | public void osNpcSay(LSL_Key npc, string message) |
2574 | { | 2567 | { |
2568 | osNpcSay(npc, 0, message); | ||
2569 | } | ||
2570 | |||
2571 | public void osNpcSay(LSL_Key npc, int channel, string message) | ||
2572 | { | ||
2575 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); | 2573 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); |
2576 | m_host.AddScriptLPS(1); | 2574 | m_host.AddScriptLPS(1); |
2577 | 2575 | ||
@@ -2583,7 +2581,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2583 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | 2581 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) |
2584 | return; | 2582 | return; |
2585 | 2583 | ||
2586 | module.Say(npcId, World, message); | 2584 | module.Say(npcId, World, message, channel); |
2585 | } | ||
2586 | } | ||
2587 | |||
2588 | public void osNpcShout(LSL_Key npc, int channel, string message) | ||
2589 | { | ||
2590 | CheckThreatLevel(ThreatLevel.High, "osNpcShout"); | ||
2591 | m_host.AddScriptLPS(1); | ||
2592 | |||
2593 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2594 | if (module != null) | ||
2595 | { | ||
2596 | UUID npcId = new UUID(npc.m_string); | ||
2597 | |||
2598 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2599 | return; | ||
2600 | |||
2601 | module.Shout(npcId, World, message, channel); | ||
2587 | } | 2602 | } |
2588 | } | 2603 | } |
2589 | 2604 | ||
@@ -2684,6 +2699,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2684 | } | 2699 | } |
2685 | } | 2700 | } |
2686 | 2701 | ||
2702 | public void osNpcWhisper(LSL_Key npc, int channel, string message) | ||
2703 | { | ||
2704 | CheckThreatLevel(ThreatLevel.High, "osNpcWhisper"); | ||
2705 | m_host.AddScriptLPS(1); | ||
2706 | |||
2707 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2708 | if (module != null) | ||
2709 | { | ||
2710 | UUID npcId = new UUID(npc.m_string); | ||
2711 | |||
2712 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2713 | return; | ||
2714 | |||
2715 | module.Whisper(npcId, World, message, channel); | ||
2716 | } | ||
2717 | } | ||
2718 | |||
2687 | /// <summary> | 2719 | /// <summary> |
2688 | /// Save the current appearance of the script owner permanently to the named notecard. | 2720 | /// Save the current appearance of the script owner permanently to the named notecard. |
2689 | /// </summary> | 2721 | /// </summary> |
@@ -2835,21 +2867,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2835 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); | 2867 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); |
2836 | m_host.AddScriptLPS(1); | 2868 | m_host.AddScriptLPS(1); |
2837 | 2869 | ||
2838 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) | 2870 | World.ForEachRootScenePresence(delegate(ScenePresence sp) |
2839 | { | 2871 | { |
2840 | World.ForEachRootScenePresence(delegate(ScenePresence sp) | 2872 | if (sp.Firstname == FirstName && sp.Lastname == SurName) |
2841 | { | 2873 | { |
2842 | if (sp.Firstname == FirstName && sp.Lastname == SurName) | 2874 | // kick client... |
2843 | { | 2875 | if (alert != null) |
2844 | // kick client... | 2876 | sp.ControllingClient.Kick(alert); |
2845 | if (alert != null) | ||
2846 | sp.ControllingClient.Kick(alert); | ||
2847 | 2877 | ||
2848 | // ...and close on our side | 2878 | // ...and close on our side |
2849 | sp.Scene.IncomingCloseAgent(sp.UUID); | 2879 | sp.Scene.IncomingCloseAgent(sp.UUID); |
2850 | } | 2880 | } |
2851 | }); | 2881 | }); |
2852 | } | ||
2853 | } | 2882 | } |
2854 | 2883 | ||
2855 | public void osCauseDamage(string avatar, double damage) | 2884 | public void osCauseDamage(string avatar, double damage) |
@@ -3095,5 +3124,80 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3095 | 3124 | ||
3096 | return ScriptBaseClass.TRUE; | 3125 | return ScriptBaseClass.TRUE; |
3097 | } | 3126 | } |
3127 | |||
3128 | /// <summary> | ||
3129 | /// Sets terrain estate texture | ||
3130 | /// </summary> | ||
3131 | /// <param name="level"></param> | ||
3132 | /// <param name="texture"></param> | ||
3133 | /// <returns></returns> | ||
3134 | public void osSetTerrainTexture(int level, LSL_Key texture) | ||
3135 | { | ||
3136 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture"); | ||
3137 | |||
3138 | m_host.AddScriptLPS(1); | ||
3139 | //Check to make sure that the script's owner is the estate manager/master | ||
3140 | //World.Permissions.GenericEstatePermission( | ||
3141 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
3142 | { | ||
3143 | if (level < 0 || level > 3) | ||
3144 | return; | ||
3145 | |||
3146 | UUID textureID = new UUID(); | ||
3147 | if (!UUID.TryParse(texture, out textureID)) | ||
3148 | return; | ||
3149 | |||
3150 | // estate module is required | ||
3151 | IEstateModule estate = World.RequestModuleInterface<IEstateModule>(); | ||
3152 | if (estate != null) | ||
3153 | estate.setEstateTerrainBaseTexture(level, textureID); | ||
3154 | } | ||
3155 | } | ||
3156 | |||
3157 | /// <summary> | ||
3158 | /// Sets terrain heights of estate | ||
3159 | /// </summary> | ||
3160 | /// <param name="corner"></param> | ||
3161 | /// <param name="low"></param> | ||
3162 | /// <param name="high"></param> | ||
3163 | /// <returns></returns> | ||
3164 | public void osSetTerrainTextureHeight(int corner, double low, double high) | ||
3165 | { | ||
3166 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight"); | ||
3167 | |||
3168 | m_host.AddScriptLPS(1); | ||
3169 | //Check to make sure that the script's owner is the estate manager/master | ||
3170 | //World.Permissions.GenericEstatePermission( | ||
3171 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
3172 | { | ||
3173 | if (corner < 0 || corner > 3) | ||
3174 | return; | ||
3175 | |||
3176 | // estate module is required | ||
3177 | IEstateModule estate = World.RequestModuleInterface<IEstateModule>(); | ||
3178 | if (estate != null) | ||
3179 | estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high); | ||
3180 | } | ||
3181 | } | ||
3182 | |||
3183 | public void osForceAttachToAvatar(int attachmentPoint) | ||
3184 | { | ||
3185 | CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); | ||
3186 | |||
3187 | m_host.AddScriptLPS(1); | ||
3188 | |||
3189 | InitLSL(); | ||
3190 | ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); | ||
3191 | } | ||
3192 | |||
3193 | public void osForceDetachFromAvatar() | ||
3194 | { | ||
3195 | CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); | ||
3196 | |||
3197 | m_host.AddScriptLPS(1); | ||
3198 | |||
3199 | InitLSL(); | ||
3200 | ((LSL_Api)m_LSL_Api).DetachFromAvatar(); | ||
3201 | } | ||
3098 | } | 3202 | } |
3099 | } | 3203 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 1373971..19f3ce1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -308,7 +308,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
308 | } | 308 | } |
309 | SceneObjectPart SensePoint = ts.host; | 309 | SceneObjectPart SensePoint = ts.host; |
310 | 310 | ||
311 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; | 311 | Vector3 fromRegionPos = SensePoint.GetWorldPosition(); |
312 | 312 | ||
313 | // pre define some things to avoid repeated definitions in the loop body | 313 | // pre define some things to avoid repeated definitions in the loop body |
314 | Vector3 toRegionPos; | 314 | Vector3 toRegionPos; |
@@ -323,13 +323,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
323 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! | 323 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! |
324 | if (SensePoint.ParentGroup.IsAttachment) | 324 | if (SensePoint.ParentGroup.IsAttachment) |
325 | { | 325 | { |
326 | // In attachments, the sensor cone always orients with the | 326 | // In attachments, rotate the sensor cone with the |
327 | // avatar rotation. This may include a nonzero elevation if | 327 | // avatar rotation. This may include a nonzero elevation if |
328 | // in mouselook. | 328 | // in mouselook. |
329 | // This will not include the rotation and position of the | ||
330 | // attachment point (e.g. your head when a sensor is in your | ||
331 | // hair attached to your scull. Your hair will turn with | ||
332 | // your head but the sensor will stay with your (global) | ||
333 | // avatar rotation and position. | ||
334 | // Position of a sensor in a child prim attached to an avatar | ||
335 | // will be still wrong. | ||
329 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | 336 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
330 | fromRegionPos = avatar.AbsolutePosition; | 337 | fromRegionPos = avatar.AbsolutePosition; |
331 | q = avatar.Rotation; | 338 | q = avatar.Rotation; |
332 | } | 339 | } |
340 | |||
333 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 341 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
334 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | 342 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
335 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 343 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
@@ -441,14 +449,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
441 | return sensedEntities; | 449 | return sensedEntities; |
442 | 450 | ||
443 | SceneObjectPart SensePoint = ts.host; | 451 | SceneObjectPart SensePoint = ts.host; |
444 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; | 452 | Vector3 fromRegionPos = SensePoint.GetWorldPosition(); |
445 | 453 | ||
446 | Quaternion q = SensePoint.RotationOffset; | 454 | Quaternion q = SensePoint.GetWorldRotation(); |
447 | if (SensePoint.ParentGroup.IsAttachment) | 455 | if (SensePoint.ParentGroup.IsAttachment) |
448 | { | 456 | { |
449 | // In attachments, the sensor cone always orients with the | 457 | // In attachments, rotate the sensor cone with the |
450 | // avatar rotation. This may include a nonzero elevation if | 458 | // avatar rotation. This may include a nonzero elevation if |
451 | // in mouselook. | 459 | // in mouselook. |
460 | // This will not include the rotation and position of the | ||
461 | // attachment point (e.g. your head when a sensor is in your | ||
462 | // hair attached to your scull. Your hair will turn with | ||
463 | // your head but the sensor will stay with your (global) | ||
464 | // avatar rotation and position. | ||
465 | // Position of a sensor in a child prim attached to an avatar | ||
466 | // will be still wrong. | ||
452 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | 467 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
453 | if (avatar == null) | 468 | if (avatar == null) |
454 | return sensedEntities; | 469 | return sensedEntities; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index be5740e..048124d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -105,6 +105,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
105 | LSL_Integer llFloor(double f); | 105 | LSL_Integer llFloor(double f); |
106 | void llForceMouselook(int mouselook); | 106 | void llForceMouselook(int mouselook); |
107 | LSL_Float llFrand(double mag); | 107 | LSL_Float llFrand(double mag); |
108 | LSL_Key llGenerateKey(); | ||
108 | LSL_Vector llGetAccel(); | 109 | LSL_Vector llGetAccel(); |
109 | LSL_Integer llGetAgentInfo(string id); | 110 | LSL_Integer llGetAgentInfo(string id); |
110 | LSL_String llGetAgentLanguage(string id); | 111 | LSL_String llGetAgentLanguage(string id); |
@@ -150,7 +151,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
150 | LSL_Rotation llGetLocalRot(); | 151 | LSL_Rotation llGetLocalRot(); |
151 | LSL_Float llGetMass(); | 152 | LSL_Float llGetMass(); |
152 | LSL_Float llGetMassMKS(); | 153 | LSL_Float llGetMassMKS(); |
153 | void llGetNextEmail(string address, string subject); | 154 | LSL_Integer llGetMemoryLimit(); |
155 | void llGetNextEmail(string address, string subject); | ||
154 | LSL_String llGetNotecardLine(string name, int line); | 156 | LSL_String llGetNotecardLine(string name, int line); |
155 | LSL_Key llGetNumberOfNotecardLines(string name); | 157 | LSL_Key llGetNumberOfNotecardLines(string name); |
156 | LSL_Integer llGetNumberOfPrims(); | 158 | LSL_Integer llGetNumberOfPrims(); |
@@ -188,6 +190,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
188 | LSL_String llGetScriptName(); | 190 | LSL_String llGetScriptName(); |
189 | LSL_Integer llGetScriptState(string name); | 191 | LSL_Integer llGetScriptState(string name); |
190 | LSL_String llGetSimulatorHostname(); | 192 | LSL_String llGetSimulatorHostname(); |
193 | LSL_Integer llGetSPMaxMemory(); | ||
191 | LSL_Integer llGetStartParameter(); | 194 | LSL_Integer llGetStartParameter(); |
192 | LSL_Integer llGetStatus(int status); | 195 | LSL_Integer llGetStatus(int status); |
193 | LSL_String llGetSubString(string src, int start, int end); | 196 | LSL_String llGetSubString(string src, int start, int end); |
@@ -323,6 +326,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
323 | void llSay(int channelID, string text); | 326 | void llSay(int channelID, string text); |
324 | void llScaleTexture(double u, double v, int face); | 327 | void llScaleTexture(double u, double v, int face); |
325 | LSL_Integer llScriptDanger(LSL_Vector pos); | 328 | LSL_Integer llScriptDanger(LSL_Vector pos); |
329 | void llScriptProfiler(LSL_Integer flag); | ||
326 | LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata); | 330 | LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata); |
327 | void llSensor(string name, string id, int type, double range, double arc); | 331 | void llSensor(string name, string id, int type, double range, double arc); |
328 | void llSensorRemove(); | 332 | void llSensorRemove(); |
@@ -346,6 +350,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
346 | void llSetLinkTexture(int linknumber, string texture, int face); | 350 | void llSetLinkTexture(int linknumber, string texture, int face); |
347 | void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate); | 351 | void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate); |
348 | void llSetLocalRot(LSL_Rotation rot); | 352 | void llSetLocalRot(LSL_Rotation rot); |
353 | LSL_Integer llSetMemoryLimit(LSL_Integer limit); | ||
349 | void llSetObjectDesc(string desc); | 354 | void llSetObjectDesc(string desc); |
350 | void llSetObjectName(string name); | 355 | void llSetObjectName(string name); |
351 | void llSetObjectPermMask(int mask, int value); | 356 | void llSetObjectPermMask(int mask, int value); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 444a681..7382495 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -98,6 +98,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
98 | void osAvatarPlayAnimation(string avatar, string animation); | 98 | void osAvatarPlayAnimation(string avatar, string animation); |
99 | void osAvatarStopAnimation(string avatar, string animation); | 99 | void osAvatarStopAnimation(string avatar, string animation); |
100 | 100 | ||
101 | // Attachment commands | ||
102 | |||
103 | /// <summary> | ||
104 | /// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH | ||
105 | /// </summary> | ||
106 | /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param> | ||
107 | void osForceAttachToAvatar(int attachment); | ||
108 | |||
109 | /// <summary> | ||
110 | /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH | ||
111 | /// </summary> | ||
112 | /// <remarks>Nothing happens if the object is not attached.</remarks> | ||
113 | void osForceDetachFromAvatar(); | ||
114 | |||
101 | //texture draw functions | 115 | //texture draw functions |
102 | string osMovePen(string drawList, int x, int y); | 116 | string osMovePen(string drawList, int x, int y); |
103 | string osDrawLine(string drawList, int startX, int startY, int endX, int endY); | 117 | string osDrawLine(string drawList, int startX, int startY, int endX, int endY); |
@@ -203,11 +217,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
203 | void osNpcSetRot(LSL_Key npc, rotation rot); | 217 | void osNpcSetRot(LSL_Key npc, rotation rot); |
204 | void osNpcStopMoveToTarget(LSL_Key npc); | 218 | void osNpcStopMoveToTarget(LSL_Key npc); |
205 | void osNpcSay(key npc, string message); | 219 | void osNpcSay(key npc, string message); |
220 | void osNpcSay(key npc, int channel, string message); | ||
221 | void osNpcShout(key npc, int channel, string message); | ||
206 | void osNpcSit(key npc, key target, int options); | 222 | void osNpcSit(key npc, key target, int options); |
207 | void osNpcStand(LSL_Key npc); | 223 | void osNpcStand(LSL_Key npc); |
208 | void osNpcRemove(key npc); | 224 | void osNpcRemove(key npc); |
209 | void osNpcPlayAnimation(LSL_Key npc, string animation); | 225 | void osNpcPlayAnimation(LSL_Key npc, string animation); |
210 | void osNpcStopAnimation(LSL_Key npc, string animation); | 226 | void osNpcStopAnimation(LSL_Key npc, string animation); |
227 | void osNpcWhisper(key npc, int channel, string message); | ||
211 | 228 | ||
212 | LSL_Key osOwnerSaveAppearance(string notecard); | 229 | LSL_Key osOwnerSaveAppearance(string notecard); |
213 | LSL_Key osAgentSaveAppearance(key agentId, string notecard); | 230 | LSL_Key osAgentSaveAppearance(key agentId, string notecard); |
@@ -234,5 +251,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
234 | 251 | ||
235 | LSL_Integer osInviteToGroup(LSL_Key agentId); | 252 | LSL_Integer osInviteToGroup(LSL_Key agentId); |
236 | LSL_Integer osEjectFromGroup(LSL_Key agentId); | 253 | LSL_Integer osEjectFromGroup(LSL_Key agentId); |
254 | |||
255 | void osSetTerrainTexture(int level, LSL_Key texture); | ||
256 | void osSetTerrainTextureHeight(int corner, double low, double high); | ||
237 | } | 257 | } |
238 | } | 258 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 278f74e..5c6ad8a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -383,6 +383,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
383 | public const int PRIM_SCULPT_FLAG_INVERT = 64; | 383 | public const int PRIM_SCULPT_FLAG_INVERT = 64; |
384 | public const int PRIM_SCULPT_FLAG_MIRROR = 128; | 384 | public const int PRIM_SCULPT_FLAG_MIRROR = 128; |
385 | 385 | ||
386 | public const int PROFILE_NONE = 0; | ||
387 | public const int PROFILE_SCRIPT_MEMORY = 1; | ||
388 | |||
386 | public const int MASK_BASE = 0; | 389 | public const int MASK_BASE = 0; |
387 | public const int MASK_OWNER = 1; | 390 | public const int MASK_OWNER = 1; |
388 | public const int MASK_GROUP = 2; | 391 | public const int MASK_GROUP = 2; |
@@ -641,6 +644,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
641 | public const int OS_NPC_FLY = 0; | 644 | public const int OS_NPC_FLY = 0; |
642 | public const int OS_NPC_NO_FLY = 1; | 645 | public const int OS_NPC_NO_FLY = 1; |
643 | public const int OS_NPC_LAND_AT_TARGET = 2; | 646 | public const int OS_NPC_LAND_AT_TARGET = 2; |
647 | public const int OS_NPC_RUNNING = 4; | ||
644 | 648 | ||
645 | public const int OS_NPC_SIT_NOW = 0; | 649 | public const int OS_NPC_SIT_NOW = 0; |
646 | 650 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 9ba9561..2d23d30 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -376,6 +376,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
376 | return m_LSL_Functions.llFrand(mag); | 376 | return m_LSL_Functions.llFrand(mag); |
377 | } | 377 | } |
378 | 378 | ||
379 | public LSL_Key llGenerateKey() | ||
380 | { | ||
381 | return m_LSL_Functions.llGenerateKey(); | ||
382 | } | ||
383 | |||
379 | public LSL_Vector llGetAccel() | 384 | public LSL_Vector llGetAccel() |
380 | { | 385 | { |
381 | return m_LSL_Functions.llGetAccel(); | 386 | return m_LSL_Functions.llGetAccel(); |
@@ -591,6 +596,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
591 | return m_LSL_Functions.llGetMassMKS(); | 596 | return m_LSL_Functions.llGetMassMKS(); |
592 | } | 597 | } |
593 | 598 | ||
599 | public LSL_Integer llGetMemoryLimit() | ||
600 | { | ||
601 | return m_LSL_Functions.llGetMemoryLimit(); | ||
602 | } | ||
603 | |||
594 | public void llGetNextEmail(string address, string subject) | 604 | public void llGetNextEmail(string address, string subject) |
595 | { | 605 | { |
596 | m_LSL_Functions.llGetNextEmail(address, subject); | 606 | m_LSL_Functions.llGetNextEmail(address, subject); |
@@ -781,6 +791,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
781 | return m_LSL_Functions.llGetSimulatorHostname(); | 791 | return m_LSL_Functions.llGetSimulatorHostname(); |
782 | } | 792 | } |
783 | 793 | ||
794 | public LSL_Integer llGetSPMaxMemory() | ||
795 | { | ||
796 | return m_LSL_Functions.llGetSPMaxMemory(); | ||
797 | } | ||
798 | |||
784 | public LSL_Integer llGetStartParameter() | 799 | public LSL_Integer llGetStartParameter() |
785 | { | 800 | { |
786 | return m_LSL_Functions.llGetStartParameter(); | 801 | return m_LSL_Functions.llGetStartParameter(); |
@@ -1450,6 +1465,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1450 | return m_LSL_Functions.llScriptDanger(pos); | 1465 | return m_LSL_Functions.llScriptDanger(pos); |
1451 | } | 1466 | } |
1452 | 1467 | ||
1468 | public void llScriptProfiler(LSL_Integer flags) | ||
1469 | { | ||
1470 | m_LSL_Functions.llScriptProfiler(flags); | ||
1471 | } | ||
1472 | |||
1453 | public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata) | 1473 | public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata) |
1454 | { | 1474 | { |
1455 | return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); | 1475 | return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); |
@@ -1560,6 +1580,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1560 | m_LSL_Functions.llSetLocalRot(rot); | 1580 | m_LSL_Functions.llSetLocalRot(rot); |
1561 | } | 1581 | } |
1562 | 1582 | ||
1583 | public LSL_Integer llSetMemoryLimit(LSL_Integer limit) | ||
1584 | { | ||
1585 | return m_LSL_Functions.llSetMemoryLimit(limit); | ||
1586 | } | ||
1587 | |||
1563 | public void llSetObjectDesc(string desc) | 1588 | public void llSetObjectDesc(string desc) |
1564 | { | 1589 | { |
1565 | m_LSL_Functions.llSetObjectDesc(desc); | 1590 | m_LSL_Functions.llSetObjectDesc(desc); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 680cefb4..d230662 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -289,8 +289,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
289 | m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); | 289 | m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); |
290 | } | 290 | } |
291 | 291 | ||
292 | // Avatar functions | ||
292 | 293 | ||
293 | //Texture Draw functions | 294 | public void osForceAttachToAvatar(int attachmentPoint) |
295 | { | ||
296 | m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint); | ||
297 | } | ||
298 | |||
299 | public void osForceDetachFromAvatar() | ||
300 | { | ||
301 | m_OSSL_Functions.osForceDetachFromAvatar(); | ||
302 | } | ||
303 | |||
304 | // Texture Draw functions | ||
294 | 305 | ||
295 | public string osMovePen(string drawList, int x, int y) | 306 | public string osMovePen(string drawList, int x, int y) |
296 | { | 307 | { |
@@ -569,6 +580,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
569 | m_OSSL_Functions.osNpcSay(npc, message); | 580 | m_OSSL_Functions.osNpcSay(npc, message); |
570 | } | 581 | } |
571 | 582 | ||
583 | public void osNpcSay(key npc, int channel, string message) | ||
584 | { | ||
585 | m_OSSL_Functions.osNpcSay(npc, channel, message); | ||
586 | } | ||
587 | |||
588 | |||
589 | public void osNpcShout(key npc, int channel, string message) | ||
590 | { | ||
591 | m_OSSL_Functions.osNpcShout(npc, channel, message); | ||
592 | } | ||
593 | |||
572 | public void osNpcSit(LSL_Key npc, LSL_Key target, int options) | 594 | public void osNpcSit(LSL_Key npc, LSL_Key target, int options) |
573 | { | 595 | { |
574 | m_OSSL_Functions.osNpcSit(npc, target, options); | 596 | m_OSSL_Functions.osNpcSit(npc, target, options); |
@@ -594,6 +616,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
594 | m_OSSL_Functions.osNpcStopAnimation(npc, animation); | 616 | m_OSSL_Functions.osNpcStopAnimation(npc, animation); |
595 | } | 617 | } |
596 | 618 | ||
619 | public void osNpcWhisper(key npc, int channel, string message) | ||
620 | { | ||
621 | m_OSSL_Functions.osNpcWhisper(npc, channel, message); | ||
622 | } | ||
623 | |||
597 | public LSL_Key osOwnerSaveAppearance(string notecard) | 624 | public LSL_Key osOwnerSaveAppearance(string notecard) |
598 | { | 625 | { |
599 | return m_OSSL_Functions.osOwnerSaveAppearance(notecard); | 626 | return m_OSSL_Functions.osOwnerSaveAppearance(notecard); |
@@ -878,5 +905,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
878 | { | 905 | { |
879 | return m_OSSL_Functions.osEjectFromGroup(agentId); | 906 | return m_OSSL_Functions.osEjectFromGroup(agentId); |
880 | } | 907 | } |
908 | |||
909 | public void osSetTerrainTexture(int level, LSL_Key texture) | ||
910 | { | ||
911 | m_OSSL_Functions.osSetTerrainTexture(level, texture); | ||
912 | } | ||
913 | |||
914 | public void osSetTerrainTextureHeight(int corner, double low, double high) | ||
915 | { | ||
916 | m_OSSL_Functions.osSetTerrainTextureHeight(corner, low, high); | ||
917 | } | ||
881 | } | 918 | } |
882 | } | 919 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index ff1f277..5cad883 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -232,7 +232,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
232 | foreach (string api in am.GetApis()) | 232 | foreach (string api in am.GetApis()) |
233 | { | 233 | { |
234 | m_Apis[api] = am.CreateApi(api); | 234 | m_Apis[api] = am.CreateApi(api); |
235 | m_Apis[api].Initialize(engine, part, LocalID, itemID); | 235 | m_Apis[api].Initialize(engine, part, ScriptTask); |
236 | } | 236 | } |
237 | 237 | ||
238 | try | 238 | try |
@@ -964,7 +964,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
964 | public IScriptApi GetApi(string name) | 964 | public IScriptApi GetApi(string name) |
965 | { | 965 | { |
966 | if (m_Apis.ContainsKey(name)) | 966 | if (m_Apis.ContainsKey(name)) |
967 | { | ||
968 | // m_log.DebugFormat("[SCRIPT INSTANCE]: Found api {0} in {1}@{2}", name, ScriptName, PrimName); | ||
969 | |||
967 | return m_Apis[name]; | 970 | return m_Apis[name]; |
971 | } | ||
972 | |||
973 | // m_log.DebugFormat("[SCRIPT INSTANCE]: Did not find api {0} in {1}@{2}", name, ScriptName, PrimName); | ||
974 | |||
968 | return null; | 975 | return null; |
969 | } | 976 | } |
970 | 977 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs index e2d0db2..c73e22f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs | |||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
63 | IConfig config = initConfigSource.AddConfig("XEngine"); | 63 | IConfig config = initConfigSource.AddConfig("XEngine"); |
64 | config.Set("Enabled", "true"); | 64 | config.Set("Enabled", "true"); |
65 | 65 | ||
66 | m_scene = SceneHelpers.SetupScene(); | 66 | m_scene = new SceneHelpers().SetupScene(); |
67 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); | 67 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); |
68 | 68 | ||
69 | m_engine = new XEngine.XEngine(); | 69 | m_engine = new XEngine.XEngine(); |
@@ -91,7 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
91 | TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, userId); | 91 | TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, userId); |
92 | 92 | ||
93 | LSL_Api api = new LSL_Api(); | 93 | LSL_Api api = new LSL_Api(); |
94 | api.Initialize(m_engine, so1.RootPart, so1.RootPart.LocalId, so1.RootPart.UUID); | 94 | api.Initialize(m_engine, so1.RootPart, null); |
95 | 95 | ||
96 | // Create a second object | 96 | // Create a second object |
97 | SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, userId, "so2", 0x100); | 97 | SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, userId, "so2", 0x100); |
@@ -124,7 +124,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
124 | SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); | 124 | SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); |
125 | m_scene.AddSceneObject(so1); | 125 | m_scene.AddSceneObject(so1); |
126 | LSL_Api api = new LSL_Api(); | 126 | LSL_Api api = new LSL_Api(); |
127 | api.Initialize(m_engine, so1.RootPart, so1.RootPart.LocalId, so1.RootPart.UUID); | 127 | api.Initialize(m_engine, so1.RootPart, null); |
128 | 128 | ||
129 | // Create an object embedded inside the first | 129 | // Create an object embedded inside the first |
130 | UUID itemId = TestHelpers.ParseTail(0x20); | 130 | UUID itemId = TestHelpers.ParseTail(0x20); |
@@ -134,7 +134,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
134 | SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); | 134 | SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); |
135 | m_scene.AddSceneObject(so2); | 135 | m_scene.AddSceneObject(so2); |
136 | LSL_Api api2 = new LSL_Api(); | 136 | LSL_Api api2 = new LSL_Api(); |
137 | api2.Initialize(m_engine, so2.RootPart, so2.RootPart.LocalId, so2.RootPart.UUID); | 137 | api2.Initialize(m_engine, so2.RootPart, null); |
138 | 138 | ||
139 | // *** Firstly, we test where llAllowInventoryDrop() has not been called. *** | 139 | // *** Firstly, we test where llAllowInventoryDrop() has not been called. *** |
140 | api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); | 140 | api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs new file mode 100644 index 0000000..bc3b790 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs | |||
@@ -0,0 +1,139 @@ | |||
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 OpenSimulator 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.Assets; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | ||
40 | using OpenSim.Region.OptionalModules.World.NPC; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using OpenSim.Region.ScriptEngine.Shared; | ||
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
44 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using OpenSim.Tests.Common; | ||
47 | using OpenSim.Tests.Common.Mock; | ||
48 | |||
49 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | ||
50 | { | ||
51 | /// <summary> | ||
52 | /// Tests for linking functions in LSL | ||
53 | /// </summary> | ||
54 | /// <remarks> | ||
55 | /// This relates to LSL. Actual linking functionality should be tested in the main | ||
56 | /// OpenSim.Region.Framework.Scenes.Tests.SceneObjectLinkingTests. | ||
57 | /// </remarks> | ||
58 | [TestFixture] | ||
59 | public class LSL_ApiLinkingTests | ||
60 | { | ||
61 | protected Scene m_scene; | ||
62 | protected XEngine.XEngine m_engine; | ||
63 | |||
64 | [SetUp] | ||
65 | public void SetUp() | ||
66 | { | ||
67 | IConfigSource initConfigSource = new IniConfigSource(); | ||
68 | IConfig config = initConfigSource.AddConfig("XEngine"); | ||
69 | config.Set("Enabled", "true"); | ||
70 | |||
71 | m_scene = new SceneHelpers().SetupScene(); | ||
72 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); | ||
73 | |||
74 | m_engine = new XEngine.XEngine(); | ||
75 | m_engine.Initialise(initConfigSource); | ||
76 | m_engine.AddRegion(m_scene); | ||
77 | } | ||
78 | |||
79 | [Test] | ||
80 | public void TestllCreateLink() | ||
81 | { | ||
82 | TestHelpers.InMethod(); | ||
83 | |||
84 | UUID ownerId = TestHelpers.ParseTail(0x1); | ||
85 | |||
86 | SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); | ||
87 | grp1.AbsolutePosition = new Vector3(10, 10, 10); | ||
88 | m_scene.AddSceneObject(grp1); | ||
89 | |||
90 | // FIXME: This should really be a script item (with accompanying script) | ||
91 | TaskInventoryItem grp1Item | ||
92 | = TaskInventoryHelpers.AddNotecard(m_scene, grp1.RootPart); | ||
93 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | ||
94 | |||
95 | SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); | ||
96 | grp2.AbsolutePosition = new Vector3(20, 20, 20); | ||
97 | |||
98 | // <180,0,0> | ||
99 | grp2.UpdateGroupRotationR(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); | ||
100 | |||
101 | m_scene.AddSceneObject(grp2); | ||
102 | |||
103 | LSL_Api apiGrp1 = new LSL_Api(); | ||
104 | apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item); | ||
105 | |||
106 | apiGrp1.llCreateLink(grp2.UUID.ToString(), ScriptBaseClass.TRUE); | ||
107 | |||
108 | Assert.That(grp1.Parts.Length, Is.EqualTo(4)); | ||
109 | Assert.That(grp2.IsDeleted, Is.True); | ||
110 | } | ||
111 | |||
112 | [Test] | ||
113 | public void TestllBreakLink() | ||
114 | { | ||
115 | TestHelpers.InMethod(); | ||
116 | |||
117 | UUID ownerId = TestHelpers.ParseTail(0x1); | ||
118 | |||
119 | SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); | ||
120 | grp1.AbsolutePosition = new Vector3(10, 10, 10); | ||
121 | m_scene.AddSceneObject(grp1); | ||
122 | |||
123 | // FIXME: This should really be a script item (with accompanying script) | ||
124 | TaskInventoryItem grp1Item | ||
125 | = TaskInventoryHelpers.AddNotecard(m_scene, grp1.RootPart); | ||
126 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | ||
127 | |||
128 | LSL_Api apiGrp1 = new LSL_Api(); | ||
129 | apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item); | ||
130 | |||
131 | apiGrp1.llBreakLink(2); | ||
132 | |||
133 | Assert.That(grp1.Parts.Length, Is.EqualTo(1)); | ||
134 | |||
135 | SceneObjectGroup grp2 = m_scene.GetSceneObjectGroup("grp1-Part1"); | ||
136 | Assert.That(grp2, Is.Not.Null); | ||
137 | } | ||
138 | } | ||
139 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 9cf9258..f96a156 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
58 | IConfig config = initConfigSource.AddConfig("XEngine"); | 58 | IConfig config = initConfigSource.AddConfig("XEngine"); |
59 | config.Set("Enabled", "true"); | 59 | config.Set("Enabled", "true"); |
60 | 60 | ||
61 | Scene scene = SceneHelpers.SetupScene(); | 61 | Scene scene = new SceneHelpers().SetupScene(); |
62 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); | 62 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); |
63 | 63 | ||
64 | XEngine.XEngine engine = new XEngine.XEngine(); | 64 | XEngine.XEngine engine = new XEngine.XEngine(); |
@@ -66,8 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
66 | engine.AddRegion(scene); | 66 | engine.AddRegion(scene); |
67 | 67 | ||
68 | m_lslApi = new LSL_Api(); | 68 | m_lslApi = new LSL_Api(); |
69 | m_lslApi.Initialize(engine, part, part.LocalId, part.UUID); | 69 | m_lslApi.Initialize(engine, part, null); |
70 | |||
71 | } | 70 | } |
72 | 71 | ||
73 | [Test] | 72 | [Test] |
@@ -261,7 +260,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
261 | TestHelpers.InMethod(); | 260 | TestHelpers.InMethod(); |
262 | 261 | ||
263 | // Create Prim1. | 262 | // Create Prim1. |
264 | Scene scene = SceneHelpers.SetupScene(); | 263 | Scene scene = new SceneHelpers().SetupScene(); |
265 | string obj1Name = "Prim1"; | 264 | string obj1Name = "Prim1"; |
266 | UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); | 265 | UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); |
267 | SceneObjectPart part1 = | 266 | SceneObjectPart part1 = |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs index 7573dff..3965734 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs | |||
@@ -67,7 +67,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
67 | config = initConfigSource.AddConfig("NPC"); | 67 | config = initConfigSource.AddConfig("NPC"); |
68 | config.Set("Enabled", "true"); | 68 | config.Set("Enabled", "true"); |
69 | 69 | ||
70 | m_scene = SceneHelpers.SetupScene(); | 70 | m_scene = new SceneHelpers().SetupScene(); |
71 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); | 71 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); |
72 | 72 | ||
73 | m_engine = new XEngine.XEngine(); | 73 | m_engine = new XEngine.XEngine(); |
@@ -95,7 +95,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
95 | m_scene.AddSceneObject(so); | 95 | m_scene.AddSceneObject(so); |
96 | 96 | ||
97 | OSSL_Api osslApi = new OSSL_Api(); | 97 | OSSL_Api osslApi = new OSSL_Api(); |
98 | osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); | 98 | osslApi.Initialize(m_engine, part, null); |
99 | 99 | ||
100 | string notecardName = "appearanceNc"; | 100 | string notecardName = "appearanceNc"; |
101 | osslApi.osOwnerSaveAppearance(notecardName); | 101 | osslApi.osOwnerSaveAppearance(notecardName); |
@@ -130,7 +130,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
130 | m_scene.AddSceneObject(so); | 130 | m_scene.AddSceneObject(so); |
131 | 131 | ||
132 | OSSL_Api osslApi = new OSSL_Api(); | 132 | OSSL_Api osslApi = new OSSL_Api(); |
133 | osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); | 133 | osslApi.Initialize(m_engine, part, null); |
134 | 134 | ||
135 | string notecardName = "appearanceNc"; | 135 | string notecardName = "appearanceNc"; |
136 | osslApi.osOwnerSaveAppearance(notecardName); | 136 | osslApi.osOwnerSaveAppearance(notecardName); |
@@ -161,7 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
161 | m_scene.AddSceneObject(so); | 161 | m_scene.AddSceneObject(so); |
162 | 162 | ||
163 | OSSL_Api osslApi = new OSSL_Api(); | 163 | OSSL_Api osslApi = new OSSL_Api(); |
164 | osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); | 164 | osslApi.Initialize(m_engine, part, null); |
165 | 165 | ||
166 | string notecardName = "appearanceNc"; | 166 | string notecardName = "appearanceNc"; |
167 | 167 | ||
@@ -202,7 +202,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
202 | m_scene.AddSceneObject(so); | 202 | m_scene.AddSceneObject(so); |
203 | 203 | ||
204 | OSSL_Api osslApi = new OSSL_Api(); | 204 | OSSL_Api osslApi = new OSSL_Api(); |
205 | osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); | 205 | osslApi.Initialize(m_engine, part, null); |
206 | 206 | ||
207 | string notecardName = "appearanceNc"; | 207 | string notecardName = "appearanceNc"; |
208 | 208 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs index 9d9fc51..0ccd889 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | |||
@@ -68,7 +68,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
68 | config = initConfigSource.AddConfig("NPC"); | 68 | config = initConfigSource.AddConfig("NPC"); |
69 | config.Set("Enabled", "true"); | 69 | config.Set("Enabled", "true"); |
70 | 70 | ||
71 | m_scene = SceneHelpers.SetupScene(); | 71 | m_scene = new SceneHelpers().SetupScene(); |
72 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); | 72 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); |
73 | 73 | ||
74 | m_engine = new XEngine.XEngine(); | 74 | m_engine = new XEngine.XEngine(); |
@@ -104,10 +104,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
104 | m_scene.AddSceneObject(otherSo); | 104 | m_scene.AddSceneObject(otherSo); |
105 | 105 | ||
106 | OSSL_Api osslApi = new OSSL_Api(); | 106 | OSSL_Api osslApi = new OSSL_Api(); |
107 | osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); | 107 | osslApi.Initialize(m_engine, part, null); |
108 | 108 | ||
109 | OSSL_Api otherOsslApi = new OSSL_Api(); | 109 | OSSL_Api otherOsslApi = new OSSL_Api(); |
110 | otherOsslApi.Initialize(m_engine, otherPart, otherPart.LocalId, otherPart.UUID); | 110 | otherOsslApi.Initialize(m_engine, otherPart, null); |
111 | 111 | ||
112 | string notecardName = "appearanceNc"; | 112 | string notecardName = "appearanceNc"; |
113 | osslApi.osOwnerSaveAppearance(notecardName); | 113 | osslApi.osOwnerSaveAppearance(notecardName); |
@@ -151,7 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
151 | m_scene.AddSceneObject(so); | 151 | m_scene.AddSceneObject(so); |
152 | 152 | ||
153 | OSSL_Api osslApi = new OSSL_Api(); | 153 | OSSL_Api osslApi = new OSSL_Api(); |
154 | osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); | 154 | osslApi.Initialize(m_engine, part, null); |
155 | 155 | ||
156 | string notecardName = "appearanceNc"; | 156 | string notecardName = "appearanceNc"; |
157 | osslApi.osOwnerSaveAppearance(notecardName); | 157 | osslApi.osOwnerSaveAppearance(notecardName); |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs index 7d7bd82..a3f848c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs | |||
@@ -73,7 +73,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests | |||
73 | // to AssemblyResolver.OnAssemblyResolve fails. | 73 | // to AssemblyResolver.OnAssemblyResolve fails. |
74 | xEngineConfig.Set("AppDomainLoading", "false"); | 74 | xEngineConfig.Set("AppDomainLoading", "false"); |
75 | 75 | ||
76 | m_scene = SceneHelpers.SetupScene("My Test", UUID.Random(), 1000, 1000, null, configSource); | 76 | m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource); |
77 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); | 77 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); |
78 | m_scene.StartScripts(); | 78 | m_scene.StartScripts(); |
79 | } | 79 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 1e0f01f..eeb125e 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1089,11 +1089,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1089 | 1089 | ||
1090 | AppDomain sandbox; | 1090 | AppDomain sandbox; |
1091 | if (m_AppDomainLoading) | 1091 | if (m_AppDomainLoading) |
1092 | { | ||
1092 | sandbox = AppDomain.CreateDomain( | 1093 | sandbox = AppDomain.CreateDomain( |
1093 | m_Scene.RegionInfo.RegionID.ToString(), | 1094 | m_Scene.RegionInfo.RegionID.ToString(), |
1094 | evidence, appSetup); | 1095 | evidence, appSetup); |
1096 | m_AppDomains[appDomain].AssemblyResolve += | ||
1097 | new ResolveEventHandler( | ||
1098 | AssemblyResolver.OnAssemblyResolve); | ||
1099 | } | ||
1095 | else | 1100 | else |
1101 | { | ||
1096 | sandbox = AppDomain.CurrentDomain; | 1102 | sandbox = AppDomain.CurrentDomain; |
1103 | } | ||
1097 | 1104 | ||
1098 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | 1105 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); |
1099 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | 1106 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); |
@@ -1105,9 +1112,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1105 | 1112 | ||
1106 | m_AppDomains[appDomain] = sandbox; | 1113 | m_AppDomains[appDomain] = sandbox; |
1107 | 1114 | ||
1108 | m_AppDomains[appDomain].AssemblyResolve += | ||
1109 | new ResolveEventHandler( | ||
1110 | AssemblyResolver.OnAssemblyResolve); | ||
1111 | m_DomainScripts[appDomain] = new List<UUID>(); | 1115 | m_DomainScripts[appDomain] = new List<UUID>(); |
1112 | } | 1116 | } |
1113 | catch (Exception e) | 1117 | catch (Exception e) |
@@ -1898,9 +1902,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1898 | // if there already exists a file at that location, it may be locked. | 1902 | // if there already exists a file at that location, it may be locked. |
1899 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); | 1903 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); |
1900 | } | 1904 | } |
1905 | |||
1906 | string textpath = path + ".text"; | ||
1901 | try | 1907 | try |
1902 | { | 1908 | { |
1903 | using (FileStream fs = File.Create(path + ".text")) | 1909 | using (FileStream fs = File.Create(textpath)) |
1904 | { | 1910 | { |
1905 | using (StreamWriter sw = new StreamWriter(fs)) | 1911 | using (StreamWriter sw = new StreamWriter(fs)) |
1906 | { | 1912 | { |
@@ -1913,7 +1919,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1913 | catch (IOException ex) | 1919 | catch (IOException ex) |
1914 | { | 1920 | { |
1915 | // if there already exists a file at that location, it may be locked. | 1921 | // if there already exists a file at that location, it may be locked. |
1916 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); | 1922 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", textpath, ex.Message); |
1917 | } | 1923 | } |
1918 | } | 1924 | } |
1919 | } | 1925 | } |
@@ -1962,7 +1968,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1962 | catch (IOException ex) | 1968 | catch (IOException ex) |
1963 | { | 1969 | { |
1964 | // if there already exists a file at that location, it may be locked. | 1970 | // if there already exists a file at that location, it may be locked. |
1965 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); | 1971 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", mappath, ex.Message); |
1966 | } | 1972 | } |
1967 | } | 1973 | } |
1968 | 1974 | ||
@@ -1997,45 +2003,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1997 | if (!topScripts.ContainsKey(si.LocalID)) | 2003 | if (!topScripts.ContainsKey(si.LocalID)) |
1998 | topScripts[si.RootLocalID] = 0; | 2004 | topScripts[si.RootLocalID] = 0; |
1999 | 2005 | ||
2000 | // long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | 2006 | topScripts[si.RootLocalID] += CalculateAdjustedExectionTime(si, tickNow); |
2001 | // float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond); | 2007 | } |
2002 | 2008 | } | |
2003 | // Execution time of the script adjusted by it's measurement period to make scripts started at | ||
2004 | // different times comparable. | ||
2005 | // float adjustedExecutionTime | ||
2006 | // = (float)si.MeasurementPeriodExecutionTime | ||
2007 | // / ((float)(tickNow - si.MeasurementPeriodTickStart) / ScriptInstance.MaxMeasurementPeriod) | ||
2008 | // / TimeSpan.TicksPerMillisecond; | ||
2009 | |||
2010 | long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | ||
2011 | |||
2012 | // Avoid divide by zerp | ||
2013 | if (ticksElapsed == 0) | ||
2014 | ticksElapsed = 1; | ||
2015 | 2009 | ||
2016 | // Scale execution time to the ideal 55 fps frame time for these reasons. | 2010 | return topScripts; |
2017 | // | 2011 | } |
2018 | // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no | ||
2019 | // 'script execution time per frame', which is the original purpose of this value. | ||
2020 | // | ||
2021 | // 2) Giving the raw execution times is misleading since scripts start at different times, making | ||
2022 | // it impossible to compare scripts. | ||
2023 | // | ||
2024 | // 3) Scaling the raw execution time to the time that the script has been running is better but | ||
2025 | // is still misleading since a script that has just been rezzed may appear to have been running | ||
2026 | // for much longer. | ||
2027 | // | ||
2028 | // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect | ||
2029 | // since the figure does not represent actual execution time and very hard running scripts will | ||
2030 | // never exceed 18ms (though this is a very high number for script execution so is a warning sign). | ||
2031 | float adjustedExecutionTime | ||
2032 | = ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f; | ||
2033 | 2012 | ||
2034 | topScripts[si.RootLocalID] += adjustedExecutionTime; | 2013 | public float GetScriptExecutionTime(List<UUID> itemIDs) |
2014 | { | ||
2015 | if (itemIDs == null|| itemIDs.Count == 0) | ||
2016 | { | ||
2017 | return 0.0f; | ||
2018 | } | ||
2019 | float time = 0.0f; | ||
2020 | long tickNow = Util.EnvironmentTickCount(); | ||
2021 | IScriptInstance si; | ||
2022 | // Calculate the time for all scripts that this engine is executing | ||
2023 | // Ignore any others | ||
2024 | foreach (UUID id in itemIDs) | ||
2025 | { | ||
2026 | si = GetInstance(id); | ||
2027 | if (si != null && si.Running) | ||
2028 | { | ||
2029 | time += CalculateAdjustedExectionTime(si, tickNow); | ||
2035 | } | 2030 | } |
2036 | } | 2031 | } |
2032 | return time; | ||
2033 | } | ||
2037 | 2034 | ||
2038 | return topScripts; | 2035 | private float CalculateAdjustedExectionTime(IScriptInstance si, long tickNow) |
2036 | { | ||
2037 | long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | ||
2038 | |||
2039 | // Avoid divide by zero | ||
2040 | if (ticksElapsed == 0) | ||
2041 | ticksElapsed = 1; | ||
2042 | |||
2043 | // Scale execution time to the ideal 55 fps frame time for these reasons. | ||
2044 | // | ||
2045 | // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no | ||
2046 | // 'script execution time per frame', which is the original purpose of this value. | ||
2047 | // | ||
2048 | // 2) Giving the raw execution times is misleading since scripts start at different times, making | ||
2049 | // it impossible to compare scripts. | ||
2050 | // | ||
2051 | // 3) Scaling the raw execution time to the time that the script has been running is better but | ||
2052 | // is still misleading since a script that has just been rezzed may appear to have been running | ||
2053 | // for much longer. | ||
2054 | // | ||
2055 | // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect | ||
2056 | // since the figure does not represent actual execution time and very hard running scripts will | ||
2057 | // never exceed 18ms (though this is a very high number for script execution so is a warning sign). | ||
2058 | return ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f; | ||
2039 | } | 2059 | } |
2040 | 2060 | ||
2041 | public void SuspendScript(UUID itemID) | 2061 | public void SuspendScript(UUID itemID) |