diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
18 files changed, 844 insertions, 687 deletions
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 667aa93..6af3c1e 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; |
@@ -107,6 +111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
107 | protected IUrlModule m_UrlModule = null; | 111 | protected IUrlModule m_UrlModule = null; |
108 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = | 112 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = |
109 | new Dictionary<UUID, UserInfoCacheEntry>(); | 113 | new Dictionary<UUID, UserInfoCacheEntry>(); |
114 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. | ||
110 | 115 | ||
111 | protected Timer m_ShoutSayTimer; | 116 | protected Timer m_ShoutSayTimer; |
112 | protected int m_SayShoutCount = 0; | 117 | protected int m_SayShoutCount = 0; |
@@ -133,7 +138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
133 | {"TURNRIGHT", "Turning Right"} | 138 | {"TURNRIGHT", "Turning Right"} |
134 | }; | 139 | }; |
135 | 140 | ||
136 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | 141 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) |
137 | { | 142 | { |
138 | m_ShoutSayTimer = new Timer(1000); | 143 | m_ShoutSayTimer = new Timer(1000); |
139 | m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed; | 144 | m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed; |
@@ -142,10 +147,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
142 | 147 | ||
143 | m_ScriptEngine = ScriptEngine; | 148 | m_ScriptEngine = ScriptEngine; |
144 | m_host = host; | 149 | m_host = host; |
145 | m_localID = localID; | 150 | m_item = item; |
146 | m_itemID = itemID; | ||
147 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | 151 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); |
148 | 152 | ||
153 | LoadLimits(); // read script limits from config. | ||
154 | |||
155 | m_TransferModule = | ||
156 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); | ||
157 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | ||
158 | |||
159 | AsyncCommands = new AsyncCommandManager(ScriptEngine); | ||
160 | } | ||
161 | |||
162 | /* load configuration items that affect script, object and run-time behavior. */ | ||
163 | private void LoadLimits() | ||
164 | { | ||
149 | m_ScriptDelayFactor = | 165 | m_ScriptDelayFactor = |
150 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); | 166 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); |
151 | m_ScriptDistanceFactor = | 167 | m_ScriptDistanceFactor = |
@@ -158,12 +174,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
158 | m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255); | 174 | m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255); |
159 | if (m_notecardLineReadCharsMax > 65535) | 175 | if (m_notecardLineReadCharsMax > 65535) |
160 | m_notecardLineReadCharsMax = 65535; | 176 | m_notecardLineReadCharsMax = 65535; |
161 | 177 | // load limits for particular subsystems. | |
162 | m_TransferModule = | 178 | IConfig SMTPConfig; |
163 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); | 179 | if ((SMTPConfig = m_ScriptEngine.ConfigSource.Configs["SMTP"]) != null) { |
164 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | 180 | // there's an smtp config, so load in the snooze time. |
165 | 181 | EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME); | |
166 | AsyncCommands = new AsyncCommandManager(ScriptEngine); | 182 | } |
167 | } | 183 | } |
168 | 184 | ||
169 | public override Object InitializeLifetimeService() | 185 | public override Object InitializeLifetimeService() |
@@ -195,7 +211,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
195 | [DebuggerNonUserCode] | 211 | [DebuggerNonUserCode] |
196 | public void state(string newState) | 212 | public void state(string newState) |
197 | { | 213 | { |
198 | m_ScriptEngine.SetState(m_itemID, newState); | 214 | m_ScriptEngine.SetState(m_item.ItemID, newState); |
199 | } | 215 | } |
200 | 216 | ||
201 | /// <summary> | 217 | /// <summary> |
@@ -206,7 +222,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
206 | public void llResetScript() | 222 | public void llResetScript() |
207 | { | 223 | { |
208 | m_host.AddScriptLPS(1); | 224 | m_host.AddScriptLPS(1); |
209 | m_ScriptEngine.ApiResetScript(m_itemID); | 225 | m_ScriptEngine.ApiResetScript(m_item.ItemID); |
210 | } | 226 | } |
211 | 227 | ||
212 | public void llResetOtherScript(string name) | 228 | public void llResetOtherScript(string name) |
@@ -358,77 +374,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
358 | } | 374 | } |
359 | } | 375 | } |
360 | 376 | ||
361 | protected UUID InventorySelf() | ||
362 | { | ||
363 | UUID invItemID = new UUID(); | ||
364 | bool unlock = false; | ||
365 | if (!m_host.TaskInventory.IsReadLockedByMe()) | ||
366 | { | ||
367 | m_host.TaskInventory.LockItemsForRead(true); | ||
368 | unlock = true; | ||
369 | } | ||
370 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
371 | { | ||
372 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | ||
373 | { | ||
374 | invItemID = inv.Key; | ||
375 | break; | ||
376 | } | ||
377 | } | ||
378 | if (unlock) | ||
379 | { | ||
380 | m_host.TaskInventory.LockItemsForRead(false); | ||
381 | } | ||
382 | return invItemID; | ||
383 | } | ||
384 | |||
385 | protected UUID InventoryKey(string name, int type) | 377 | protected UUID InventoryKey(string name, int type) |
386 | { | 378 | { |
387 | m_host.AddScriptLPS(1); | 379 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); |
388 | m_host.TaskInventory.LockItemsForRead(true); | ||
389 | |||
390 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
391 | { | ||
392 | if (inv.Value.Name == name) | ||
393 | { | ||
394 | m_host.TaskInventory.LockItemsForRead(false); | ||
395 | |||
396 | if (inv.Value.Type != type) | ||
397 | { | ||
398 | return UUID.Zero; | ||
399 | } | ||
400 | |||
401 | return inv.Value.AssetID; | ||
402 | } | ||
403 | } | ||
404 | |||
405 | m_host.TaskInventory.LockItemsForRead(false); | ||
406 | return UUID.Zero; | ||
407 | } | ||
408 | |||
409 | protected UUID InventoryKey(string name) | ||
410 | { | ||
411 | m_host.AddScriptLPS(1); | ||
412 | 380 | ||
413 | 381 | if (item != null && item.Type == type) | |
414 | m_host.TaskInventory.LockItemsForRead(true); | 382 | return item.AssetID; |
415 | 383 | else | |
416 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 384 | return UUID.Zero; |
417 | { | ||
418 | if (inv.Value.Name == name) | ||
419 | { | ||
420 | m_host.TaskInventory.LockItemsForRead(false); | ||
421 | return inv.Value.AssetID; | ||
422 | } | ||
423 | } | ||
424 | |||
425 | m_host.TaskInventory.LockItemsForRead(false); | ||
426 | |||
427 | |||
428 | return UUID.Zero; | ||
429 | } | 385 | } |
430 | 386 | ||
431 | |||
432 | /// <summary> | 387 | /// <summary> |
433 | /// accepts a valid UUID, -or- a name of an inventory item. | 388 | /// accepts a valid UUID, -or- a name of an inventory item. |
434 | /// Returns a valid UUID or UUID.Zero if key invalid and item not found | 389 | /// Returns a valid UUID or UUID.Zero if key invalid and item not found |
@@ -438,19 +393,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
438 | /// <returns></returns> | 393 | /// <returns></returns> |
439 | protected UUID KeyOrName(string k) | 394 | protected UUID KeyOrName(string k) |
440 | { | 395 | { |
441 | UUID key = UUID.Zero; | 396 | UUID key; |
442 | 397 | ||
443 | // if we can parse the string as a key, use it. | 398 | // if we can parse the string as a key, use it. |
444 | if (UUID.TryParse(k, out key)) | ||
445 | { | ||
446 | return key; | ||
447 | } | ||
448 | // else try to locate the name in inventory of object. found returns key, | 399 | // else try to locate the name in inventory of object. found returns key, |
449 | // not found returns UUID.Zero which will translate to the default particle texture | 400 | // not found returns UUID.Zero |
450 | else | 401 | if (!UUID.TryParse(k, out key)) |
451 | { | 402 | { |
452 | return InventoryKey(k); | 403 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k); |
404 | |||
405 | if (item != null) | ||
406 | key = item.AssetID; | ||
407 | else | ||
408 | key = UUID.Zero; | ||
453 | } | 409 | } |
410 | |||
411 | return key; | ||
454 | } | 412 | } |
455 | 413 | ||
456 | // convert a LSL_Rotation to a Quaternion | 414 | // convert a LSL_Rotation to a Quaternion |
@@ -963,20 +921,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
963 | 921 | ||
964 | public void llRegionSayTo(string target, int channel, string msg) | 922 | public void llRegionSayTo(string target, int channel, string msg) |
965 | { | 923 | { |
966 | string error = String.Empty; | ||
967 | |||
968 | if (msg.Length > 1023) | 924 | if (msg.Length > 1023) |
969 | msg = msg.Substring(0, 1023); | 925 | msg = msg.Substring(0, 1023); |
970 | 926 | ||
971 | m_host.AddScriptLPS(1); | 927 | m_host.AddScriptLPS(1); |
972 | 928 | ||
929 | if (channel == ScriptBaseClass.DEBUG_CHANNEL) | ||
930 | { | ||
931 | return; | ||
932 | } | ||
933 | |||
973 | UUID TargetID; | 934 | UUID TargetID; |
974 | UUID.TryParse(target, out TargetID); | 935 | UUID.TryParse(target, out TargetID); |
975 | 936 | ||
976 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 937 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
977 | if (wComm != null) | 938 | if (wComm != null) |
978 | if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) | 939 | wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg); |
979 | LSLError(error); | ||
980 | } | 940 | } |
981 | 941 | ||
982 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) | 942 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) |
@@ -986,7 +946,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
986 | UUID.TryParse(ID, out keyID); | 946 | UUID.TryParse(ID, out keyID); |
987 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 947 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
988 | if (wComm != null) | 948 | if (wComm != null) |
989 | return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg); | 949 | return wComm.Listen(m_host.LocalId, m_item.ItemID, m_host.UUID, channelID, name, keyID, msg); |
990 | else | 950 | else |
991 | return -1; | 951 | return -1; |
992 | } | 952 | } |
@@ -996,7 +956,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
996 | m_host.AddScriptLPS(1); | 956 | m_host.AddScriptLPS(1); |
997 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 957 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
998 | if (wComm != null) | 958 | if (wComm != null) |
999 | wComm.ListenControl(m_itemID, number, active); | 959 | wComm.ListenControl(m_item.ItemID, number, active); |
1000 | } | 960 | } |
1001 | 961 | ||
1002 | public void llListenRemove(int number) | 962 | public void llListenRemove(int number) |
@@ -1004,7 +964,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1004 | m_host.AddScriptLPS(1); | 964 | m_host.AddScriptLPS(1); |
1005 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 965 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
1006 | if (wComm != null) | 966 | if (wComm != null) |
1007 | wComm.ListenRemove(m_itemID, number); | 967 | wComm.ListenRemove(m_item.ItemID, number); |
1008 | } | 968 | } |
1009 | 969 | ||
1010 | public void llSensor(string name, string id, int type, double range, double arc) | 970 | public void llSensor(string name, string id, int type, double range, double arc) |
@@ -1013,7 +973,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1013 | UUID keyID = UUID.Zero; | 973 | UUID keyID = UUID.Zero; |
1014 | UUID.TryParse(id, out keyID); | 974 | UUID.TryParse(id, out keyID); |
1015 | 975 | ||
1016 | AsyncCommands.SensorRepeatPlugin.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); | 976 | AsyncCommands.SensorRepeatPlugin.SenseOnce(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, m_host); |
1017 | } | 977 | } |
1018 | 978 | ||
1019 | public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) | 979 | public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) |
@@ -1022,13 +982,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1022 | UUID keyID = UUID.Zero; | 982 | UUID keyID = UUID.Zero; |
1023 | UUID.TryParse(id, out keyID); | 983 | UUID.TryParse(id, out keyID); |
1024 | 984 | ||
1025 | AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); | 985 | AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, rate, m_host); |
1026 | } | 986 | } |
1027 | 987 | ||
1028 | public void llSensorRemove() | 988 | public void llSensorRemove() |
1029 | { | 989 | { |
1030 | m_host.AddScriptLPS(1); | 990 | m_host.AddScriptLPS(1); |
1031 | AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_localID, m_itemID); | 991 | AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_host.LocalId, m_item.ItemID); |
1032 | } | 992 | } |
1033 | 993 | ||
1034 | public string resolveName(UUID objecUUID) | 994 | public string resolveName(UUID objecUUID) |
@@ -1069,7 +1029,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1069 | public LSL_String llDetectedName(int number) | 1029 | public LSL_String llDetectedName(int number) |
1070 | { | 1030 | { |
1071 | m_host.AddScriptLPS(1); | 1031 | m_host.AddScriptLPS(1); |
1072 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1032 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1073 | if (detectedParams == null) | 1033 | if (detectedParams == null) |
1074 | return String.Empty; | 1034 | return String.Empty; |
1075 | return detectedParams.Name; | 1035 | return detectedParams.Name; |
@@ -1078,7 +1038,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1078 | public LSL_String llDetectedKey(int number) | 1038 | public LSL_String llDetectedKey(int number) |
1079 | { | 1039 | { |
1080 | m_host.AddScriptLPS(1); | 1040 | m_host.AddScriptLPS(1); |
1081 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1041 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1082 | if (detectedParams == null) | 1042 | if (detectedParams == null) |
1083 | return String.Empty; | 1043 | return String.Empty; |
1084 | return detectedParams.Key.ToString(); | 1044 | return detectedParams.Key.ToString(); |
@@ -1087,7 +1047,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1087 | public LSL_String llDetectedOwner(int number) | 1047 | public LSL_String llDetectedOwner(int number) |
1088 | { | 1048 | { |
1089 | m_host.AddScriptLPS(1); | 1049 | m_host.AddScriptLPS(1); |
1090 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1050 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1091 | if (detectedParams == null) | 1051 | if (detectedParams == null) |
1092 | return String.Empty; | 1052 | return String.Empty; |
1093 | return detectedParams.Owner.ToString(); | 1053 | return detectedParams.Owner.ToString(); |
@@ -1096,7 +1056,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1096 | public LSL_Integer llDetectedType(int number) | 1056 | public LSL_Integer llDetectedType(int number) |
1097 | { | 1057 | { |
1098 | m_host.AddScriptLPS(1); | 1058 | m_host.AddScriptLPS(1); |
1099 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1059 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1100 | if (detectedParams == null) | 1060 | if (detectedParams == null) |
1101 | return 0; | 1061 | return 0; |
1102 | return new LSL_Integer(detectedParams.Type); | 1062 | return new LSL_Integer(detectedParams.Type); |
@@ -1105,7 +1065,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1105 | public LSL_Vector llDetectedPos(int number) | 1065 | public LSL_Vector llDetectedPos(int number) |
1106 | { | 1066 | { |
1107 | m_host.AddScriptLPS(1); | 1067 | m_host.AddScriptLPS(1); |
1108 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1068 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1109 | if (detectedParams == null) | 1069 | if (detectedParams == null) |
1110 | return new LSL_Vector(); | 1070 | return new LSL_Vector(); |
1111 | return detectedParams.Position; | 1071 | return detectedParams.Position; |
@@ -1114,7 +1074,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1114 | public LSL_Vector llDetectedVel(int number) | 1074 | public LSL_Vector llDetectedVel(int number) |
1115 | { | 1075 | { |
1116 | m_host.AddScriptLPS(1); | 1076 | m_host.AddScriptLPS(1); |
1117 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1077 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1118 | if (detectedParams == null) | 1078 | if (detectedParams == null) |
1119 | return new LSL_Vector(); | 1079 | return new LSL_Vector(); |
1120 | return detectedParams.Velocity; | 1080 | return detectedParams.Velocity; |
@@ -1123,7 +1083,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1123 | public LSL_Vector llDetectedGrab(int number) | 1083 | public LSL_Vector llDetectedGrab(int number) |
1124 | { | 1084 | { |
1125 | m_host.AddScriptLPS(1); | 1085 | m_host.AddScriptLPS(1); |
1126 | DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1086 | DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1127 | if (parms == null) | 1087 | if (parms == null) |
1128 | return new LSL_Vector(0, 0, 0); | 1088 | return new LSL_Vector(0, 0, 0); |
1129 | 1089 | ||
@@ -1133,7 +1093,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1133 | public LSL_Rotation llDetectedRot(int number) | 1093 | public LSL_Rotation llDetectedRot(int number) |
1134 | { | 1094 | { |
1135 | m_host.AddScriptLPS(1); | 1095 | m_host.AddScriptLPS(1); |
1136 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1096 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1137 | if (detectedParams == null) | 1097 | if (detectedParams == null) |
1138 | return new LSL_Rotation(); | 1098 | return new LSL_Rotation(); |
1139 | return detectedParams.Rotation; | 1099 | return detectedParams.Rotation; |
@@ -1142,7 +1102,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1142 | public LSL_Integer llDetectedGroup(int number) | 1102 | public LSL_Integer llDetectedGroup(int number) |
1143 | { | 1103 | { |
1144 | m_host.AddScriptLPS(1); | 1104 | m_host.AddScriptLPS(1); |
1145 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1105 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1146 | if (detectedParams == null) | 1106 | if (detectedParams == null) |
1147 | return new LSL_Integer(0); | 1107 | return new LSL_Integer(0); |
1148 | if (m_host.GroupID == detectedParams.Group) | 1108 | if (m_host.GroupID == detectedParams.Group) |
@@ -1153,7 +1113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1153 | public LSL_Integer llDetectedLinkNumber(int number) | 1113 | public LSL_Integer llDetectedLinkNumber(int number) |
1154 | { | 1114 | { |
1155 | m_host.AddScriptLPS(1); | 1115 | m_host.AddScriptLPS(1); |
1156 | DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); | 1116 | DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); |
1157 | if (parms == null) | 1117 | if (parms == null) |
1158 | return new LSL_Integer(0); | 1118 | return new LSL_Integer(0); |
1159 | 1119 | ||
@@ -1166,7 +1126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1166 | public LSL_Vector llDetectedTouchBinormal(int index) | 1126 | public LSL_Vector llDetectedTouchBinormal(int index) |
1167 | { | 1127 | { |
1168 | m_host.AddScriptLPS(1); | 1128 | m_host.AddScriptLPS(1); |
1169 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); | 1129 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); |
1170 | if (detectedParams == null) | 1130 | if (detectedParams == null) |
1171 | return new LSL_Vector(); | 1131 | return new LSL_Vector(); |
1172 | return detectedParams.TouchBinormal; | 1132 | return detectedParams.TouchBinormal; |
@@ -1178,7 +1138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1178 | public LSL_Integer llDetectedTouchFace(int index) | 1138 | public LSL_Integer llDetectedTouchFace(int index) |
1179 | { | 1139 | { |
1180 | m_host.AddScriptLPS(1); | 1140 | m_host.AddScriptLPS(1); |
1181 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); | 1141 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); |
1182 | if (detectedParams == null) | 1142 | if (detectedParams == null) |
1183 | return new LSL_Integer(-1); | 1143 | return new LSL_Integer(-1); |
1184 | return new LSL_Integer(detectedParams.TouchFace); | 1144 | return new LSL_Integer(detectedParams.TouchFace); |
@@ -1190,7 +1150,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1190 | public LSL_Vector llDetectedTouchNormal(int index) | 1150 | public LSL_Vector llDetectedTouchNormal(int index) |
1191 | { | 1151 | { |
1192 | m_host.AddScriptLPS(1); | 1152 | m_host.AddScriptLPS(1); |
1193 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); | 1153 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); |
1194 | if (detectedParams == null) | 1154 | if (detectedParams == null) |
1195 | return new LSL_Vector(); | 1155 | return new LSL_Vector(); |
1196 | return detectedParams.TouchNormal; | 1156 | return detectedParams.TouchNormal; |
@@ -1202,7 +1162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1202 | public LSL_Vector llDetectedTouchPos(int index) | 1162 | public LSL_Vector llDetectedTouchPos(int index) |
1203 | { | 1163 | { |
1204 | m_host.AddScriptLPS(1); | 1164 | m_host.AddScriptLPS(1); |
1205 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); | 1165 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); |
1206 | if (detectedParams == null) | 1166 | if (detectedParams == null) |
1207 | return new LSL_Vector(); | 1167 | return new LSL_Vector(); |
1208 | return detectedParams.TouchPos; | 1168 | return detectedParams.TouchPos; |
@@ -1214,7 +1174,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1214 | public LSL_Vector llDetectedTouchST(int index) | 1174 | public LSL_Vector llDetectedTouchST(int index) |
1215 | { | 1175 | { |
1216 | m_host.AddScriptLPS(1); | 1176 | m_host.AddScriptLPS(1); |
1217 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); | 1177 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); |
1218 | if (detectedParams == null) | 1178 | if (detectedParams == null) |
1219 | return new LSL_Vector(-1.0, -1.0, 0.0); | 1179 | return new LSL_Vector(-1.0, -1.0, 0.0); |
1220 | return detectedParams.TouchST; | 1180 | return detectedParams.TouchST; |
@@ -1226,7 +1186,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1226 | public LSL_Vector llDetectedTouchUV(int index) | 1186 | public LSL_Vector llDetectedTouchUV(int index) |
1227 | { | 1187 | { |
1228 | m_host.AddScriptLPS(1); | 1188 | m_host.AddScriptLPS(1); |
1229 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); | 1189 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); |
1230 | if (detectedParams == null) | 1190 | if (detectedParams == null) |
1231 | return new LSL_Vector(-1.0, -1.0, 0.0); | 1191 | return new LSL_Vector(-1.0, -1.0, 0.0); |
1232 | return detectedParams.TouchUV; | 1192 | return detectedParams.TouchUV; |
@@ -1929,12 +1889,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1929 | 1889 | ||
1930 | return rgb; | 1890 | return rgb; |
1931 | } | 1891 | } |
1892 | |||
1932 | if (face >= 0 && face < GetNumberOfSides(part)) | 1893 | if (face >= 0 && face < GetNumberOfSides(part)) |
1933 | { | 1894 | { |
1934 | texcolor = tex.GetFace((uint)face).RGBA; | 1895 | texcolor = tex.GetFace((uint)face).RGBA; |
1935 | rgb.x = texcolor.R; | 1896 | rgb.x = texcolor.R; |
1936 | rgb.y = texcolor.G; | 1897 | rgb.y = texcolor.G; |
1937 | rgb.z = texcolor.B; | 1898 | rgb.z = texcolor.B; |
1899 | |||
1938 | return rgb; | 1900 | return rgb; |
1939 | } | 1901 | } |
1940 | else | 1902 | else |
@@ -2975,20 +2937,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2975 | 2937 | ||
2976 | public LSL_Integer llGiveMoney(string destination, int amount) | 2938 | public LSL_Integer llGiveMoney(string destination, int amount) |
2977 | { | 2939 | { |
2978 | UUID invItemID=InventorySelf(); | ||
2979 | if (invItemID == UUID.Zero) | ||
2980 | return 0; | ||
2981 | |||
2982 | m_host.AddScriptLPS(1); | 2940 | m_host.AddScriptLPS(1); |
2983 | 2941 | ||
2984 | m_host.TaskInventory.LockItemsForRead(true); | 2942 | if (m_item.PermsGranter == UUID.Zero) |
2985 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | ||
2986 | m_host.TaskInventory.LockItemsForRead(false); | ||
2987 | |||
2988 | if (item.PermsGranter == UUID.Zero) | ||
2989 | return 0; | 2943 | return 0; |
2990 | 2944 | ||
2991 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) | 2945 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) |
2992 | { | 2946 | { |
2993 | LSLError("No permissions to give money"); | 2947 | LSLError("No permissions to give money"); |
2994 | return 0; | 2948 | return 0; |
@@ -3176,11 +3130,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3176 | sec = m_MinTimerInterval; | 3130 | sec = m_MinTimerInterval; |
3177 | m_host.AddScriptLPS(1); | 3131 | m_host.AddScriptLPS(1); |
3178 | // Setting timer repeat | 3132 | // Setting timer repeat |
3179 | AsyncCommands.TimerPlugin.SetTimerEvent(m_localID, m_itemID, sec); | 3133 | AsyncCommands.TimerPlugin.SetTimerEvent(m_host.LocalId, m_item.ItemID, sec); |
3180 | } | 3134 | } |
3181 | 3135 | ||
3182 | public virtual void llSleep(double sec) | 3136 | public virtual void llSleep(double sec) |
3183 | { | 3137 | { |
3138 | // m_log.Info("llSleep snoozing " + sec + "s."); | ||
3184 | m_host.AddScriptLPS(1); | 3139 | m_host.AddScriptLPS(1); |
3185 | Thread.Sleep((int)(sec * 1000)); | 3140 | Thread.Sleep((int)(sec * 1000)); |
3186 | } | 3141 | } |
@@ -3239,29 +3194,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3239 | 3194 | ||
3240 | public void llTakeControls(int controls, int accept, int pass_on) | 3195 | public void llTakeControls(int controls, int accept, int pass_on) |
3241 | { | 3196 | { |
3242 | TaskInventoryItem item; | 3197 | if (m_item.PermsGranter != UUID.Zero) |
3243 | |||
3244 | m_host.TaskInventory.LockItemsForRead(true); | ||
3245 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3246 | { | ||
3247 | m_host.TaskInventory.LockItemsForRead(false); | ||
3248 | return; | ||
3249 | } | ||
3250 | else | ||
3251 | { | 3198 | { |
3252 | item = m_host.TaskInventory[InventorySelf()]; | 3199 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); |
3253 | } | ||
3254 | m_host.TaskInventory.LockItemsForRead(false); | ||
3255 | |||
3256 | if (item.PermsGranter != UUID.Zero) | ||
3257 | { | ||
3258 | ScenePresence presence = World.GetScenePresence(item.PermsGranter); | ||
3259 | 3200 | ||
3260 | if (presence != null) | 3201 | if (presence != null) |
3261 | { | 3202 | { |
3262 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 3203 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
3263 | { | 3204 | { |
3264 | presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID); | 3205 | presence.RegisterControlEventsToScript(controls, accept, pass_on, m_host.LocalId, m_item.ItemID); |
3265 | } | 3206 | } |
3266 | } | 3207 | } |
3267 | } | 3208 | } |
@@ -3271,38 +3212,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3271 | 3212 | ||
3272 | public void llReleaseControls() | 3213 | public void llReleaseControls() |
3273 | { | 3214 | { |
3274 | TaskInventoryItem item; | ||
3275 | |||
3276 | m_host.TaskInventory.LockItemsForRead(true); | ||
3277 | lock (m_host.TaskInventory) | ||
3278 | { | ||
3279 | |||
3280 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3281 | { | ||
3282 | m_host.TaskInventory.LockItemsForRead(false); | ||
3283 | return; | ||
3284 | } | ||
3285 | else | ||
3286 | { | ||
3287 | item = m_host.TaskInventory[InventorySelf()]; | ||
3288 | } | ||
3289 | } | ||
3290 | m_host.TaskInventory.LockItemsForRead(false); | ||
3291 | |||
3292 | m_host.AddScriptLPS(1); | 3215 | m_host.AddScriptLPS(1); |
3293 | 3216 | ||
3294 | if (item.PermsGranter != UUID.Zero) | 3217 | if (m_item.PermsGranter != UUID.Zero) |
3295 | { | 3218 | { |
3296 | ScenePresence presence = World.GetScenePresence(item.PermsGranter); | 3219 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); |
3297 | 3220 | ||
3298 | if (presence != null) | 3221 | if (presence != null) |
3299 | { | 3222 | { |
3300 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 3223 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
3301 | { | 3224 | { |
3302 | // Unregister controls from Presence | 3225 | // Unregister controls from Presence |
3303 | presence.UnRegisterControlEventsToScript(m_localID, m_itemID); | 3226 | presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID); |
3304 | // Remove Take Control permission. | 3227 | // Remove Take Control permission. |
3305 | item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; | 3228 | m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; |
3306 | } | 3229 | } |
3307 | } | 3230 | } |
3308 | } | 3231 | } |
@@ -3315,86 +3238,71 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3315 | m_UrlModule.ReleaseURL(url); | 3238 | m_UrlModule.ReleaseURL(url); |
3316 | } | 3239 | } |
3317 | 3240 | ||
3318 | public void llAttachToAvatar(int attachment) | 3241 | /// <summary> |
3242 | /// Attach the object containing this script to the avatar that owns it. | ||
3243 | /// </summary> | ||
3244 | /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param> | ||
3245 | /// <returns>true if the attach suceeded, false if it did not</returns> | ||
3246 | public bool AttachToAvatar(int attachmentPoint) | ||
3319 | { | 3247 | { |
3320 | m_host.AddScriptLPS(1); | 3248 | SceneObjectGroup grp = m_host.ParentGroup; |
3249 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | ||
3321 | 3250 | ||
3322 | TaskInventoryItem item; | 3251 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3323 | |||
3324 | m_host.TaskInventory.LockItemsForRead(true); | ||
3325 | 3252 | ||
3326 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3253 | if (attachmentsModule != null) |
3327 | { | 3254 | return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, true); |
3328 | m_host.TaskInventory.LockItemsForRead(false); | ||
3329 | return; | ||
3330 | } | ||
3331 | else | 3255 | else |
3332 | { | 3256 | return false; |
3333 | item = m_host.TaskInventory[InventorySelf()]; | 3257 | } |
3334 | } | ||
3335 | |||
3336 | m_host.TaskInventory.LockItemsForRead(false); | ||
3337 | 3258 | ||
3338 | if (item.PermsGranter != m_host.OwnerID) | 3259 | /// <summary> |
3339 | return; | 3260 | /// Detach the object containing this script from the avatar it is attached to. |
3261 | /// </summary> | ||
3262 | /// <remarks> | ||
3263 | /// Nothing happens if the object is not attached. | ||
3264 | /// </remarks> | ||
3265 | public void DetachFromAvatar() | ||
3266 | { | ||
3267 | Util.FireAndForget(DetachWrapper, m_host); | ||
3268 | } | ||
3340 | 3269 | ||
3341 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) | 3270 | private void DetachWrapper(object o) |
3342 | { | 3271 | { |
3343 | SceneObjectGroup grp = m_host.ParentGroup; | 3272 | SceneObjectPart host = (SceneObjectPart)o; |
3344 | 3273 | ||
3345 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 3274 | SceneObjectGroup grp = host.ParentGroup; |
3275 | UUID itemID = grp.FromItemID; | ||
3276 | ScenePresence presence = World.GetScenePresence(host.OwnerID); | ||
3346 | 3277 | ||
3347 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3278 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3348 | if (attachmentsModule != null) | 3279 | if (attachmentsModule != null) |
3349 | attachmentsModule.AttachObject(presence, grp, (uint)attachment, false, true); | 3280 | attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); |
3350 | } | ||
3351 | } | 3281 | } |
3352 | 3282 | ||
3353 | public void llDetachFromAvatar() | 3283 | public void llAttachToAvatar(int attachmentPoint) |
3354 | { | 3284 | { |
3355 | m_host.AddScriptLPS(1); | 3285 | m_host.AddScriptLPS(1); |
3356 | 3286 | ||
3357 | if (m_host.ParentGroup.AttachmentPoint == 0) | 3287 | if (m_item.PermsGranter != m_host.OwnerID) |
3358 | return; | 3288 | return; |
3359 | 3289 | ||
3360 | TaskInventoryItem item; | 3290 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) |
3291 | AttachToAvatar(attachmentPoint); | ||
3292 | } | ||
3361 | 3293 | ||
3362 | m_host.TaskInventory.LockItemsForRead(true); | 3294 | public void llDetachFromAvatar() |
3295 | { | ||
3296 | m_host.AddScriptLPS(1); | ||
3363 | 3297 | ||
3364 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3298 | if (m_host.ParentGroup.AttachmentPoint == 0) |
3365 | { | ||
3366 | m_host.TaskInventory.LockItemsForRead(false); | ||
3367 | return; | 3299 | return; |
3368 | } | ||
3369 | else | ||
3370 | { | ||
3371 | item = m_host.TaskInventory[InventorySelf()]; | ||
3372 | } | ||
3373 | m_host.TaskInventory.LockItemsForRead(false); | ||
3374 | |||
3375 | 3300 | ||
3376 | if (item.PermsGranter != m_host.OwnerID) | 3301 | if (m_item.PermsGranter != m_host.OwnerID) |
3377 | return; | 3302 | return; |
3378 | 3303 | ||
3379 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) | 3304 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) |
3380 | { | 3305 | DetachFromAvatar(); |
3381 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | ||
3382 | if (attachmentsModule != null) | ||
3383 | Util.FireAndForget(DetachWrapper, m_host); | ||
3384 | } | ||
3385 | } | ||
3386 | |||
3387 | private void DetachWrapper(object o) | ||
3388 | { | ||
3389 | SceneObjectPart host = (SceneObjectPart)o; | ||
3390 | |||
3391 | SceneObjectGroup grp = host.ParentGroup; | ||
3392 | UUID itemID = grp.FromItemID; | ||
3393 | ScenePresence presence = World.GetScenePresence(host.OwnerID); | ||
3394 | |||
3395 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | ||
3396 | if (attachmentsModule != null) | ||
3397 | attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); | ||
3398 | } | 3306 | } |
3399 | 3307 | ||
3400 | public void llTakeCamera(string avatar) | 3308 | public void llTakeCamera(string avatar) |
@@ -3515,7 +3423,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3515 | } | 3423 | } |
3516 | 3424 | ||
3517 | emailModule.SendEmail(m_host.UUID, address, subject, message); | 3425 | emailModule.SendEmail(m_host.UUID, address, subject, message); |
3518 | ScriptSleep(15000); | 3426 | ScriptSleep(EMAIL_PAUSE_TIME * 1000); |
3519 | } | 3427 | } |
3520 | 3428 | ||
3521 | public void llGetNextEmail(string address, string subject) | 3429 | public void llGetNextEmail(string address, string subject) |
@@ -3552,6 +3460,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3552 | return m_host.UUID.ToString(); | 3460 | return m_host.UUID.ToString(); |
3553 | } | 3461 | } |
3554 | 3462 | ||
3463 | public LSL_Key llGenerateKey() | ||
3464 | { | ||
3465 | m_host.AddScriptLPS(1); | ||
3466 | return UUID.Random().ToString(); | ||
3467 | } | ||
3468 | |||
3555 | public void llSetBuoyancy(double buoyancy) | 3469 | public void llSetBuoyancy(double buoyancy) |
3556 | { | 3470 | { |
3557 | m_host.AddScriptLPS(1); | 3471 | m_host.AddScriptLPS(1); |
@@ -3598,7 +3512,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3598 | m_host.AddScriptLPS(1); | 3512 | m_host.AddScriptLPS(1); |
3599 | try | 3513 | try |
3600 | { | 3514 | { |
3601 | m_ScriptEngine.SetMinEventDelay(m_itemID, delay); | 3515 | m_ScriptEngine.SetMinEventDelay(m_item.ItemID, delay); |
3602 | } | 3516 | } |
3603 | catch (NotImplementedException) | 3517 | catch (NotImplementedException) |
3604 | { | 3518 | { |
@@ -3651,29 +3565,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3651 | { | 3565 | { |
3652 | m_host.AddScriptLPS(1); | 3566 | m_host.AddScriptLPS(1); |
3653 | 3567 | ||
3654 | UUID invItemID = InventorySelf(); | 3568 | if (m_item.PermsGranter == UUID.Zero) |
3655 | if (invItemID == UUID.Zero) | ||
3656 | return; | ||
3657 | |||
3658 | TaskInventoryItem item; | ||
3659 | |||
3660 | m_host.TaskInventory.LockItemsForRead(true); | ||
3661 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3662 | { | ||
3663 | m_host.TaskInventory.LockItemsForRead(false); | ||
3664 | return; | ||
3665 | } | ||
3666 | else | ||
3667 | { | ||
3668 | item = m_host.TaskInventory[InventorySelf()]; | ||
3669 | } | ||
3670 | m_host.TaskInventory.LockItemsForRead(false); | ||
3671 | if (item.PermsGranter == UUID.Zero) | ||
3672 | return; | 3569 | return; |
3673 | 3570 | ||
3674 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) | 3571 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) |
3675 | { | 3572 | { |
3676 | ScenePresence presence = World.GetScenePresence(item.PermsGranter); | 3573 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); |
3677 | 3574 | ||
3678 | if (presence != null) | 3575 | if (presence != null) |
3679 | { | 3576 | { |
@@ -3691,41 +3588,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3691 | { | 3588 | { |
3692 | m_host.AddScriptLPS(1); | 3589 | m_host.AddScriptLPS(1); |
3693 | 3590 | ||
3694 | UUID invItemID=InventorySelf(); | 3591 | if (m_item.PermsGranter == UUID.Zero) |
3695 | if (invItemID == UUID.Zero) | ||
3696 | return; | 3592 | return; |
3697 | 3593 | ||
3698 | TaskInventoryItem item; | 3594 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) |
3699 | |||
3700 | m_host.TaskInventory.LockItemsForRead(true); | ||
3701 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3702 | { | ||
3703 | m_host.TaskInventory.LockItemsForRead(false); | ||
3704 | return; | ||
3705 | } | ||
3706 | else | ||
3707 | { | 3595 | { |
3708 | item = m_host.TaskInventory[InventorySelf()]; | 3596 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); |
3709 | } | ||
3710 | m_host.TaskInventory.LockItemsForRead(false); | ||
3711 | |||
3712 | |||
3713 | if (item.PermsGranter == UUID.Zero) | ||
3714 | return; | ||
3715 | |||
3716 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) | ||
3717 | { | ||
3718 | UUID animID = new UUID(); | ||
3719 | |||
3720 | if (!UUID.TryParse(anim, out animID)) | ||
3721 | { | ||
3722 | animID=InventoryKey(anim); | ||
3723 | } | ||
3724 | |||
3725 | ScenePresence presence = World.GetScenePresence(item.PermsGranter); | ||
3726 | 3597 | ||
3727 | if (presence != null) | 3598 | if (presence != null) |
3728 | { | 3599 | { |
3600 | UUID animID = KeyOrName(anim); | ||
3601 | |||
3729 | if (animID == UUID.Zero) | 3602 | if (animID == UUID.Zero) |
3730 | presence.Animator.RemoveAnimation(anim); | 3603 | presence.Animator.RemoveAnimation(anim); |
3731 | else | 3604 | else |
@@ -3758,44 +3631,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3758 | public LSL_Integer llGetStartParameter() | 3631 | public LSL_Integer llGetStartParameter() |
3759 | { | 3632 | { |
3760 | m_host.AddScriptLPS(1); | 3633 | m_host.AddScriptLPS(1); |
3761 | return m_ScriptEngine.GetStartParameter(m_itemID); | 3634 | return m_ScriptEngine.GetStartParameter(m_item.ItemID); |
3762 | } | 3635 | } |
3763 | 3636 | ||
3764 | public void llRequestPermissions(string agent, int perm) | 3637 | public void llRequestPermissions(string agent, int perm) |
3765 | { | 3638 | { |
3766 | UUID agentID = new UUID(); | 3639 | UUID agentID; |
3767 | 3640 | ||
3768 | if (!UUID.TryParse(agent, out agentID)) | 3641 | if (!UUID.TryParse(agent, out agentID)) |
3769 | return; | 3642 | return; |
3770 | 3643 | ||
3771 | UUID invItemID = InventorySelf(); | ||
3772 | |||
3773 | if (invItemID == UUID.Zero) | ||
3774 | return; // Not in a prim? How?? | ||
3775 | |||
3776 | TaskInventoryItem item; | ||
3777 | |||
3778 | |||
3779 | m_host.TaskInventory.LockItemsForRead(true); | ||
3780 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3781 | { | ||
3782 | m_host.TaskInventory.LockItemsForRead(false); | ||
3783 | return; | ||
3784 | } | ||
3785 | else | ||
3786 | { | ||
3787 | item = m_host.TaskInventory[invItemID]; | ||
3788 | } | ||
3789 | m_host.TaskInventory.LockItemsForRead(false); | ||
3790 | |||
3791 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3644 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3792 | { | 3645 | { |
3793 | llReleaseControls(); | 3646 | llReleaseControls(); |
3794 | 3647 | ||
3795 | item.PermsGranter = UUID.Zero; | 3648 | m_item.PermsGranter = UUID.Zero; |
3796 | item.PermsMask = 0; | 3649 | m_item.PermsMask = 0; |
3797 | 3650 | ||
3798 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3651 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3799 | "run_time_permissions", new Object[] { | 3652 | "run_time_permissions", new Object[] { |
3800 | new LSL_Integer(0) }, | 3653 | new LSL_Integer(0) }, |
3801 | new DetectParams[0])); | 3654 | new DetectParams[0])); |
@@ -3803,7 +3656,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3803 | return; | 3656 | return; |
3804 | } | 3657 | } |
3805 | 3658 | ||
3806 | if (item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3659 | if (m_item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3807 | llReleaseControls(); | 3660 | llReleaseControls(); |
3808 | 3661 | ||
3809 | m_host.AddScriptLPS(1); | 3662 | m_host.AddScriptLPS(1); |
@@ -3820,11 +3673,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3820 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3673 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3821 | { | 3674 | { |
3822 | m_host.TaskInventory.LockItemsForWrite(true); | 3675 | m_host.TaskInventory.LockItemsForWrite(true); |
3823 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3676 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3824 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3677 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; |
3825 | m_host.TaskInventory.LockItemsForWrite(false); | 3678 | m_host.TaskInventory.LockItemsForWrite(false); |
3826 | 3679 | ||
3827 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3680 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3828 | "run_time_permissions", new Object[] { | 3681 | "run_time_permissions", new Object[] { |
3829 | new LSL_Integer(perm) }, | 3682 | new LSL_Integer(perm) }, |
3830 | new DetectParams[0])); | 3683 | new DetectParams[0])); |
@@ -3859,11 +3712,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3859 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3712 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3860 | { | 3713 | { |
3861 | m_host.TaskInventory.LockItemsForWrite(true); | 3714 | m_host.TaskInventory.LockItemsForWrite(true); |
3862 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3715 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3863 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3716 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; |
3864 | m_host.TaskInventory.LockItemsForWrite(false); | 3717 | m_host.TaskInventory.LockItemsForWrite(false); |
3865 | 3718 | ||
3866 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3719 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3867 | "run_time_permissions", new Object[] { | 3720 | "run_time_permissions", new Object[] { |
3868 | new LSL_Integer(perm) }, | 3721 | new LSL_Integer(perm) }, |
3869 | new DetectParams[0])); | 3722 | new DetectParams[0])); |
@@ -3874,9 +3727,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3874 | } | 3727 | } |
3875 | 3728 | ||
3876 | ScenePresence presence = World.GetScenePresence(agentID); | 3729 | ScenePresence presence = World.GetScenePresence(agentID); |
3877 | |||
3878 | if (presence != null) | 3730 | if (presence != null) |
3879 | { | 3731 | { |
3732 | // If permissions are being requested from an NPC and were not implicitly granted above then | ||
3733 | // auto grant all reuqested permissions if the script is owned by the NPC or the NPCs owner | ||
3734 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
3735 | if (npcModule != null && npcModule.IsNPC(agentID, World)) | ||
3736 | { | ||
3737 | if (agentID == m_host.ParentGroup.OwnerID || npcModule.GetOwner(agentID) == m_host.ParentGroup.OwnerID) | ||
3738 | { | ||
3739 | lock (m_host.TaskInventory) | ||
3740 | { | ||
3741 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; | ||
3742 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; | ||
3743 | } | ||
3744 | |||
3745 | m_ScriptEngine.PostScriptEvent( | ||
3746 | m_item.ItemID, | ||
3747 | new EventParams( | ||
3748 | "run_time_permissions", new Object[] { new LSL_Integer(perm) }, new DetectParams[0])); | ||
3749 | } | ||
3750 | |||
3751 | // it is an NPC, exit even if the permissions werent granted above, they are not going to answer | ||
3752 | // the question! | ||
3753 | return; | ||
3754 | } | ||
3755 | |||
3880 | string ownerName = resolveName(m_host.ParentGroup.RootPart.OwnerID); | 3756 | string ownerName = resolveName(m_host.ParentGroup.RootPart.OwnerID); |
3881 | if (ownerName == String.Empty) | 3757 | if (ownerName == String.Empty) |
3882 | ownerName = "(hippos)"; | 3758 | ownerName = "(hippos)"; |
@@ -3884,8 +3760,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3884 | if (!m_waitingForScriptAnswer) | 3760 | if (!m_waitingForScriptAnswer) |
3885 | { | 3761 | { |
3886 | m_host.TaskInventory.LockItemsForWrite(true); | 3762 | m_host.TaskInventory.LockItemsForWrite(true); |
3887 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3763 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3888 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3764 | m_host.TaskInventory[m_item.ItemID].PermsMask = 0; |
3889 | m_host.TaskInventory.LockItemsForWrite(false); | 3765 | m_host.TaskInventory.LockItemsForWrite(false); |
3890 | 3766 | ||
3891 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3767 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
@@ -3893,16 +3769,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3893 | } | 3769 | } |
3894 | 3770 | ||
3895 | presence.ControllingClient.SendScriptQuestion( | 3771 | presence.ControllingClient.SendScriptQuestion( |
3896 | m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); | 3772 | m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_item.ItemID, perm); |
3897 | 3773 | ||
3898 | return; | 3774 | return; |
3899 | } | 3775 | } |
3900 | 3776 | ||
3901 | // Requested agent is not in range, refuse perms | 3777 | // Requested agent is not in range, refuse perms |
3902 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3778 | m_ScriptEngine.PostScriptEvent( |
3903 | "run_time_permissions", new Object[] { | 3779 | m_item.ItemID, |
3904 | new LSL_Integer(0) }, | 3780 | new EventParams("run_time_permissions", new Object[] { new LSL_Integer(0) }, new DetectParams[0])); |
3905 | new DetectParams[0])); | ||
3906 | } | 3781 | } |
3907 | 3782 | ||
3908 | void handleScriptAnswer(IClientAPI client, UUID taskID, UUID itemID, int answer) | 3783 | void handleScriptAnswer(IClientAPI client, UUID taskID, UUID itemID, int answer) |
@@ -3910,24 +3785,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3910 | if (taskID != m_host.UUID) | 3785 | if (taskID != m_host.UUID) |
3911 | return; | 3786 | return; |
3912 | 3787 | ||
3913 | UUID invItemID = InventorySelf(); | 3788 | client.OnScriptAnswer -= handleScriptAnswer; |
3914 | 3789 | m_waitingForScriptAnswer = false; | |
3915 | if (invItemID == UUID.Zero) | ||
3916 | return; | ||
3917 | |||
3918 | client.OnScriptAnswer-=handleScriptAnswer; | ||
3919 | m_waitingForScriptAnswer=false; | ||
3920 | 3790 | ||
3921 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3791 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3922 | llReleaseControls(); | 3792 | llReleaseControls(); |
3923 | 3793 | ||
3924 | |||
3925 | m_host.TaskInventory.LockItemsForWrite(true); | 3794 | m_host.TaskInventory.LockItemsForWrite(true); |
3926 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3795 | m_host.TaskInventory[m_item.ItemID].PermsMask = answer; |
3927 | m_host.TaskInventory.LockItemsForWrite(false); | 3796 | m_host.TaskInventory.LockItemsForWrite(false); |
3928 | 3797 | ||
3929 | 3798 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | |
3930 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | ||
3931 | "run_time_permissions", new Object[] { | 3799 | "run_time_permissions", new Object[] { |
3932 | new LSL_Integer(answer) }, | 3800 | new LSL_Integer(answer) }, |
3933 | new DetectParams[0])); | 3801 | new DetectParams[0])); |
@@ -3937,41 +3805,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3937 | { | 3805 | { |
3938 | m_host.AddScriptLPS(1); | 3806 | m_host.AddScriptLPS(1); |
3939 | 3807 | ||
3940 | m_host.TaskInventory.LockItemsForRead(true); | 3808 | return m_item.PermsGranter.ToString(); |
3941 | |||
3942 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3943 | { | ||
3944 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
3945 | { | ||
3946 | m_host.TaskInventory.LockItemsForRead(false); | ||
3947 | return item.PermsGranter.ToString(); | ||
3948 | } | ||
3949 | } | ||
3950 | m_host.TaskInventory.LockItemsForRead(false); | ||
3951 | |||
3952 | return UUID.Zero.ToString(); | ||
3953 | } | 3809 | } |
3954 | 3810 | ||
3955 | public LSL_Integer llGetPermissions() | 3811 | public LSL_Integer llGetPermissions() |
3956 | { | 3812 | { |
3957 | m_host.AddScriptLPS(1); | 3813 | m_host.AddScriptLPS(1); |
3958 | 3814 | ||
3959 | m_host.TaskInventory.LockItemsForRead(true); | 3815 | int perms = m_item.PermsMask; |
3960 | 3816 | ||
3961 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3817 | if (m_automaticLinkPermission) |
3962 | { | 3818 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3963 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
3964 | { | ||
3965 | int perms = item.PermsMask; | ||
3966 | if (m_automaticLinkPermission) | ||
3967 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | ||
3968 | m_host.TaskInventory.LockItemsForRead(false); | ||
3969 | return perms; | ||
3970 | } | ||
3971 | } | ||
3972 | m_host.TaskInventory.LockItemsForRead(false); | ||
3973 | 3819 | ||
3974 | return 0; | 3820 | return perms; |
3975 | } | 3821 | } |
3976 | 3822 | ||
3977 | public LSL_Integer llGetLinkNumber() | 3823 | public LSL_Integer llGetLinkNumber() |
@@ -4009,18 +3855,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4009 | public void llCreateLink(string target, int parent) | 3855 | public void llCreateLink(string target, int parent) |
4010 | { | 3856 | { |
4011 | m_host.AddScriptLPS(1); | 3857 | m_host.AddScriptLPS(1); |
4012 | UUID invItemID = InventorySelf(); | 3858 | |
4013 | UUID targetID; | 3859 | UUID targetID; |
4014 | 3860 | ||
4015 | if (!UUID.TryParse(target, out targetID)) | 3861 | if (!UUID.TryParse(target, out targetID)) |
4016 | return; | 3862 | return; |
4017 | 3863 | ||
4018 | TaskInventoryItem item; | 3864 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
4019 | m_host.TaskInventory.LockItemsForRead(true); | ||
4020 | item = m_host.TaskInventory[invItemID]; | ||
4021 | m_host.TaskInventory.LockItemsForRead(false); | ||
4022 | |||
4023 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | ||
4024 | && !m_automaticLinkPermission) | 3865 | && !m_automaticLinkPermission) |
4025 | { | 3866 | { |
4026 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3867 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
@@ -4028,7 +3869,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4028 | } | 3869 | } |
4029 | 3870 | ||
4030 | IClientAPI client = null; | 3871 | IClientAPI client = null; |
4031 | ScenePresence sp = World.GetScenePresence(item.PermsGranter); | 3872 | ScenePresence sp = World.GetScenePresence(m_item.PermsGranter); |
4032 | if (sp != null) | 3873 | if (sp != null) |
4033 | client = sp.ControllingClient; | 3874 | client = sp.ControllingClient; |
4034 | 3875 | ||
@@ -4074,18 +3915,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4074 | public void llBreakLink(int linknum) | 3915 | public void llBreakLink(int linknum) |
4075 | { | 3916 | { |
4076 | m_host.AddScriptLPS(1); | 3917 | m_host.AddScriptLPS(1); |
4077 | UUID invItemID = InventorySelf(); | ||
4078 | 3918 | ||
4079 | m_host.TaskInventory.LockItemsForRead(true); | 3919 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
4080 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3920 | && !m_automaticLinkPermission) |
4081 | && !m_automaticLinkPermission) | 3921 | { |
4082 | { | 3922 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
4083 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3923 | return; |
4084 | m_host.TaskInventory.LockItemsForRead(false); | 3924 | } |
4085 | return; | 3925 | |
4086 | } | ||
4087 | m_host.TaskInventory.LockItemsForRead(false); | ||
4088 | |||
4089 | if (linknum < ScriptBaseClass.LINK_THIS) | 3926 | if (linknum < ScriptBaseClass.LINK_THIS) |
4090 | return; | 3927 | return; |
4091 | 3928 | ||
@@ -4184,12 +4021,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4184 | { | 4021 | { |
4185 | m_host.AddScriptLPS(1); | 4022 | m_host.AddScriptLPS(1); |
4186 | 4023 | ||
4187 | UUID invItemID = InventorySelf(); | 4024 | TaskInventoryItem item = m_item; |
4188 | |||
4189 | TaskInventoryItem item; | ||
4190 | m_host.TaskInventory.LockItemsForRead(true); | ||
4191 | item = m_host.TaskInventory[invItemID]; | ||
4192 | m_host.TaskInventory.LockItemsForRead(false); | ||
4193 | 4025 | ||
4194 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 4026 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
4195 | && !m_automaticLinkPermission) | 4027 | && !m_automaticLinkPermission) |
@@ -4500,7 +4332,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4500 | { | 4332 | { |
4501 | if (item.Name == name) | 4333 | if (item.Name == name) |
4502 | { | 4334 | { |
4503 | if (item.ItemID == m_itemID) | 4335 | if (item.ItemID == m_item.ItemID) |
4504 | throw new ScriptDeleteException(); | 4336 | throw new ScriptDeleteException(); |
4505 | else | 4337 | else |
4506 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 4338 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
@@ -4634,8 +4466,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4634 | UUID rq = UUID.Random(); | 4466 | UUID rq = UUID.Random(); |
4635 | 4467 | ||
4636 | UUID tid = AsyncCommands. | 4468 | UUID tid = AsyncCommands. |
4637 | DataserverPlugin.RegisterRequest(m_localID, | 4469 | DataserverPlugin.RegisterRequest(m_host.LocalId, |
4638 | m_itemID, rq.ToString()); | 4470 | m_item.ItemID, rq.ToString()); |
4639 | 4471 | ||
4640 | AsyncCommands. | 4472 | AsyncCommands. |
4641 | DataserverPlugin.DataserverReply(rq.ToString(), reply); | 4473 | DataserverPlugin.DataserverReply(rq.ToString(), reply); |
@@ -4662,8 +4494,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4662 | if (item.Type == 3 && item.Name == name) | 4494 | if (item.Type == 3 && item.Name == name) |
4663 | { | 4495 | { |
4664 | UUID tid = AsyncCommands. | 4496 | UUID tid = AsyncCommands. |
4665 | DataserverPlugin.RegisterRequest(m_localID, | 4497 | DataserverPlugin.RegisterRequest(m_host.LocalId, |
4666 | m_itemID, item.AssetID.ToString()); | 4498 | m_item.ItemID, item.AssetID.ToString()); |
4667 | 4499 | ||
4668 | Vector3 region = new Vector3( | 4500 | Vector3 region = new Vector3( |
4669 | World.RegionInfo.RegionLocX * Constants.RegionSize, | 4501 | World.RegionInfo.RegionLocX * Constants.RegionSize, |
@@ -5074,22 +4906,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5074 | 4906 | ||
5075 | public LSL_String llGetScriptName() | 4907 | public LSL_String llGetScriptName() |
5076 | { | 4908 | { |
5077 | string result = String.Empty; | ||
5078 | |||
5079 | m_host.AddScriptLPS(1); | 4909 | m_host.AddScriptLPS(1); |
5080 | 4910 | ||
5081 | m_host.TaskInventory.LockItemsForRead(true); | 4911 | return m_item.Name != null ? m_item.Name : String.Empty; |
5082 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
5083 | { | ||
5084 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
5085 | { | ||
5086 | result = item.Name!=null?item.Name:String.Empty; | ||
5087 | break; | ||
5088 | } | ||
5089 | } | ||
5090 | m_host.TaskInventory.LockItemsForRead(false); | ||
5091 | |||
5092 | return result; | ||
5093 | } | 4912 | } |
5094 | 4913 | ||
5095 | public LSL_Integer llGetLinkNumberOfSides(int link) | 4914 | public LSL_Integer llGetLinkNumberOfSides(int link) |
@@ -6223,7 +6042,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6223 | } | 6042 | } |
6224 | } | 6043 | } |
6225 | } | 6044 | } |
6226 | List<UUID> presenceIds = new List<UUID>(); | ||
6227 | 6045 | ||
6228 | World.ForEachRootScenePresence( | 6046 | World.ForEachRootScenePresence( |
6229 | delegate (ScenePresence ssp) | 6047 | delegate (ScenePresence ssp) |
@@ -6374,7 +6192,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6374 | if (m_host.OwnerID == land.LandData.OwnerID) | 6192 | if (m_host.OwnerID == land.LandData.OwnerID) |
6375 | { | 6193 | { |
6376 | Vector3 pos = World.GetNearestAllowedPosition(presence, land); | 6194 | Vector3 pos = World.GetNearestAllowedPosition(presence, land); |
6377 | presence.TeleportWithMomentum(pos); | 6195 | presence.TeleportWithMomentum(pos, null); |
6378 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); | 6196 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); |
6379 | } | 6197 | } |
6380 | } | 6198 | } |
@@ -7321,14 +7139,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7321 | IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); | 7139 | IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); |
7322 | if (xmlrpcMod.IsEnabled()) | 7140 | if (xmlrpcMod.IsEnabled()) |
7323 | { | 7141 | { |
7324 | UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, UUID.Zero); | 7142 | UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_host.LocalId, m_item.ItemID, UUID.Zero); |
7325 | IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>(); | 7143 | IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>(); |
7326 | if (xmlRpcRouter != null) | 7144 | if (xmlRpcRouter != null) |
7327 | { | 7145 | { |
7328 | string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName; | 7146 | string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName; |
7329 | 7147 | ||
7330 | xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID, | 7148 | xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID, |
7331 | m_itemID, String.Format("http://{0}:{1}/", ExternalHostName, | 7149 | m_item.ItemID, String.Format("http://{0}:{1}/", ExternalHostName, |
7332 | xmlrpcMod.Port.ToString())); | 7150 | xmlrpcMod.Port.ToString())); |
7333 | } | 7151 | } |
7334 | object[] resobj = new object[] | 7152 | object[] resobj = new object[] |
@@ -7340,7 +7158,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7340 | new LSL_Integer(0), | 7158 | new LSL_Integer(0), |
7341 | new LSL_String(String.Empty) | 7159 | new LSL_String(String.Empty) |
7342 | }; | 7160 | }; |
7343 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams("remote_data", resobj, | 7161 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams("remote_data", resobj, |
7344 | new DetectParams[0])); | 7162 | new DetectParams[0])); |
7345 | } | 7163 | } |
7346 | ScriptSleep(1000); | 7164 | ScriptSleep(1000); |
@@ -7351,7 +7169,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7351 | m_host.AddScriptLPS(1); | 7169 | m_host.AddScriptLPS(1); |
7352 | IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); | 7170 | IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); |
7353 | ScriptSleep(3000); | 7171 | ScriptSleep(3000); |
7354 | return (xmlrpcMod.SendRemoteData(m_localID, m_itemID, channel, dest, idata, sdata)).ToString(); | 7172 | return (xmlrpcMod.SendRemoteData(m_host.LocalId, m_item.ItemID, channel, dest, idata, sdata)).ToString(); |
7355 | } | 7173 | } |
7356 | 7174 | ||
7357 | public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) | 7175 | public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) |
@@ -8190,7 +8008,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8190 | return; | 8008 | return; |
8191 | face = (int)rules.GetLSLIntegerItem(idx++); | 8009 | face = (int)rules.GetLSLIntegerItem(idx++); |
8192 | int shiny = (int)rules.GetLSLIntegerItem(idx++); | 8010 | int shiny = (int)rules.GetLSLIntegerItem(idx++); |
8193 | Bumpiness bump = (Bumpiness)Convert.ToByte((int)rules.GetLSLIntegerItem(idx++)); | 8011 | Bumpiness bump = (Bumpiness)(int)rules.GetLSLIntegerItem(idx++); |
8194 | 8012 | ||
8195 | SetShiny(part, face, shiny, bump); | 8013 | SetShiny(part, face, shiny, bump); |
8196 | 8014 | ||
@@ -9655,7 +9473,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9655 | public LSL_String llGetSimulatorHostname() | 9473 | public LSL_String llGetSimulatorHostname() |
9656 | { | 9474 | { |
9657 | m_host.AddScriptLPS(1); | 9475 | m_host.AddScriptLPS(1); |
9658 | return System.Environment.MachineName; | 9476 | IUrlModule UrlModule = World.RequestModuleInterface<IUrlModule>(); |
9477 | return UrlModule.ExternalHostNameForLSL; | ||
9659 | } | 9478 | } |
9660 | 9479 | ||
9661 | // <summary> | 9480 | // <summary> |
@@ -9994,13 +9813,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9994 | { | 9813 | { |
9995 | m_host.AddScriptLPS(1); | 9814 | m_host.AddScriptLPS(1); |
9996 | if (m_UrlModule != null) | 9815 | if (m_UrlModule != null) |
9997 | return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); | 9816 | return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString(); |
9998 | return UUID.Zero.ToString(); | 9817 | return UUID.Zero.ToString(); |
9999 | } | 9818 | } |
10000 | 9819 | ||
10001 | public LSL_String llRequestSimulatorData(string simulator, int data) | 9820 | public LSL_String llRequestSimulatorData(string simulator, int data) |
10002 | { | 9821 | { |
10003 | IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_itemID, "OSSL"); | 9822 | IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL"); |
10004 | 9823 | ||
10005 | try | 9824 | try |
10006 | { | 9825 | { |
@@ -10010,7 +9829,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10010 | 9829 | ||
10011 | GridRegion info; | 9830 | GridRegion info; |
10012 | 9831 | ||
10013 | if (m_ScriptEngine.World.RegionInfo.RegionName == simulator) | 9832 | if (m_ScriptEngine.World.RegionInfo.RegionName == simulator) //Det data for this simulator? |
9833 | |||
10014 | info = new GridRegion(m_ScriptEngine.World.RegionInfo); | 9834 | info = new GridRegion(m_ScriptEngine.World.RegionInfo); |
10015 | else | 9835 | else |
10016 | info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator); | 9836 | info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator); |
@@ -10023,10 +9843,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10023 | ScriptSleep(1000); | 9843 | ScriptSleep(1000); |
10024 | return UUID.Zero.ToString(); | 9844 | return UUID.Zero.ToString(); |
10025 | } | 9845 | } |
10026 | reply = new LSL_Vector( | 9846 | if (m_ScriptEngine.World.RegionInfo.RegionName != simulator) |
10027 | info.RegionLocX, | 9847 | { |
10028 | info.RegionLocY, | 9848 | //Hypergrid Region co-ordinates |
10029 | 0).ToString(); | 9849 | uint rx = 0, ry = 0; |
9850 | Utils.LongToUInts(Convert.ToUInt64(info.RegionSecret), out rx, out ry); | ||
9851 | |||
9852 | reply = new LSL_Vector( | ||
9853 | rx, | ||
9854 | ry, | ||
9855 | 0).ToString(); | ||
9856 | } | ||
9857 | else | ||
9858 | { | ||
9859 | //Local-cooridnates | ||
9860 | reply = new LSL_Vector( | ||
9861 | info.RegionLocX, | ||
9862 | info.RegionLocY, | ||
9863 | 0).ToString(); | ||
9864 | } | ||
10030 | break; | 9865 | break; |
10031 | case ScriptBaseClass.DATA_SIM_STATUS: | 9866 | case ScriptBaseClass.DATA_SIM_STATUS: |
10032 | if (info != null) | 9867 | if (info != null) |
@@ -10062,7 +9897,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10062 | UUID rq = UUID.Random(); | 9897 | UUID rq = UUID.Random(); |
10063 | 9898 | ||
10064 | UUID tid = AsyncCommands. | 9899 | UUID tid = AsyncCommands. |
10065 | DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); | 9900 | DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString()); |
10066 | 9901 | ||
10067 | AsyncCommands. | 9902 | AsyncCommands. |
10068 | DataserverPlugin.DataserverReply(rq.ToString(), reply); | 9903 | DataserverPlugin.DataserverReply(rq.ToString(), reply); |
@@ -10081,7 +9916,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10081 | m_host.AddScriptLPS(1); | 9916 | m_host.AddScriptLPS(1); |
10082 | 9917 | ||
10083 | if (m_UrlModule != null) | 9918 | if (m_UrlModule != null) |
10084 | return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); | 9919 | return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString(); |
10085 | return UUID.Zero.ToString(); | 9920 | return UUID.Zero.ToString(); |
10086 | } | 9921 | } |
10087 | 9922 | ||
@@ -10117,7 +9952,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10117 | // child agents have a mass of 1.0 | 9952 | // child agents have a mass of 1.0 |
10118 | return 1; | 9953 | return 1; |
10119 | else | 9954 | else |
10120 | return avatar.GetMass(); | 9955 | return (double)avatar.GetMass(); |
10121 | } | 9956 | } |
10122 | catch (KeyNotFoundException) | 9957 | catch (KeyNotFoundException) |
10123 | { | 9958 | { |
@@ -10560,32 +10395,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10560 | public LSL_Vector llGetCameraPos() | 10395 | public LSL_Vector llGetCameraPos() |
10561 | { | 10396 | { |
10562 | m_host.AddScriptLPS(1); | 10397 | m_host.AddScriptLPS(1); |
10563 | UUID invItemID = InventorySelf(); | ||
10564 | 10398 | ||
10565 | if (invItemID == UUID.Zero) | 10399 | if (m_item.PermsGranter == UUID.Zero) |
10566 | return new LSL_Vector(); | 10400 | return new LSL_Vector(); |
10567 | |||
10568 | m_host.TaskInventory.LockItemsForRead(true); | ||
10569 | |||
10570 | UUID agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
10571 | |||
10572 | // if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
10573 | if (agentID == UUID.Zero) | ||
10574 | { | ||
10575 | m_host.TaskInventory.LockItemsForRead(false); | ||
10576 | return new LSL_Vector(); | ||
10577 | } | ||
10578 | 10401 | ||
10579 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 10402 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
10580 | { | 10403 | { |
10581 | ShoutError("No permissions to track the camera"); | 10404 | ShoutError("No permissions to track the camera"); |
10582 | m_host.TaskInventory.LockItemsForRead(false); | ||
10583 | return new LSL_Vector(); | 10405 | return new LSL_Vector(); |
10584 | } | 10406 | } |
10585 | m_host.TaskInventory.LockItemsForRead(false); | ||
10586 | 10407 | ||
10587 | // ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 10408 | // ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
10588 | ScenePresence presence = World.GetScenePresence(agentID); | 10409 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); |
10589 | if (presence != null) | 10410 | if (presence != null) |
10590 | { | 10411 | { |
10591 | LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); | 10412 | LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); |
@@ -10597,30 +10418,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10597 | public LSL_Rotation llGetCameraRot() | 10418 | public LSL_Rotation llGetCameraRot() |
10598 | { | 10419 | { |
10599 | m_host.AddScriptLPS(1); | 10420 | m_host.AddScriptLPS(1); |
10600 | UUID invItemID = InventorySelf(); | ||
10601 | if (invItemID == UUID.Zero) | ||
10602 | return new LSL_Rotation(); | ||
10603 | |||
10604 | m_host.TaskInventory.LockItemsForRead(true); | ||
10605 | 10421 | ||
10606 | UUID agentID = m_host.TaskInventory[invItemID].PermsGranter; | 10422 | if (m_item.PermsGranter == UUID.Zero) |
10423 | return new LSL_Rotation(); | ||
10607 | 10424 | ||
10608 | // if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 10425 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
10609 | if (agentID == UUID.Zero) | ||
10610 | { | ||
10611 | m_host.TaskInventory.LockItemsForRead(false); | ||
10612 | return new LSL_Rotation(); | ||
10613 | } | ||
10614 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
10615 | { | 10426 | { |
10616 | ShoutError("No permissions to track the camera"); | 10427 | ShoutError("No permissions to track the camera"); |
10617 | m_host.TaskInventory.LockItemsForRead(false); | ||
10618 | return new LSL_Rotation(); | 10428 | return new LSL_Rotation(); |
10619 | } | 10429 | } |
10620 | m_host.TaskInventory.LockItemsForRead(false); | ||
10621 | 10430 | ||
10622 | // ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 10431 | // ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
10623 | ScenePresence presence = World.GetScenePresence(agentID); | 10432 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); |
10624 | if (presence != null) | 10433 | if (presence != null) |
10625 | { | 10434 | { |
10626 | return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); | 10435 | return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); |
@@ -10679,7 +10488,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10679 | public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt) | 10488 | public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt) |
10680 | { | 10489 | { |
10681 | m_host.AddScriptLPS(1); | 10490 | m_host.AddScriptLPS(1); |
10682 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); | 10491 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); |
10683 | if (detectedParams == null) | 10492 | if (detectedParams == null) |
10684 | { | 10493 | { |
10685 | if (m_host.ParentGroup.IsAttachment == true) | 10494 | if (m_host.ParentGroup.IsAttachment == true) |
@@ -10803,30 +10612,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10803 | { | 10612 | { |
10804 | m_host.AddScriptLPS(1); | 10613 | m_host.AddScriptLPS(1); |
10805 | 10614 | ||
10806 | // our key in the object we are in | ||
10807 | UUID invItemID = InventorySelf(); | ||
10808 | if (invItemID == UUID.Zero) return; | ||
10809 | |||
10810 | // the object we are in | 10615 | // the object we are in |
10811 | UUID objectID = m_host.ParentUUID; | 10616 | UUID objectID = m_host.ParentUUID; |
10812 | if (objectID == UUID.Zero) return; | 10617 | if (objectID == UUID.Zero) |
10618 | return; | ||
10813 | 10619 | ||
10814 | UUID agentID; | ||
10815 | m_host.TaskInventory.LockItemsForRead(true); | ||
10816 | // we need the permission first, to know which avatar we want to set the camera for | 10620 | // we need the permission first, to know which avatar we want to set the camera for |
10817 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 10621 | UUID agentID = m_item.PermsGranter; |
10818 | 10622 | ||
10819 | if (agentID == UUID.Zero) | 10623 | if (agentID == UUID.Zero) |
10820 | { | ||
10821 | m_host.TaskInventory.LockItemsForRead(false); | ||
10822 | return; | 10624 | return; |
10823 | } | 10625 | |
10824 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | 10626 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) |
10825 | { | ||
10826 | m_host.TaskInventory.LockItemsForRead(false); | ||
10827 | return; | 10627 | return; |
10828 | } | ||
10829 | m_host.TaskInventory.LockItemsForRead(false); | ||
10830 | 10628 | ||
10831 | ScenePresence presence = World.GetScenePresence(agentID); | 10629 | ScenePresence presence = World.GetScenePresence(agentID); |
10832 | 10630 | ||
@@ -10868,34 +10666,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10868 | { | 10666 | { |
10869 | m_host.AddScriptLPS(1); | 10667 | m_host.AddScriptLPS(1); |
10870 | 10668 | ||
10871 | // our key in the object we are in | ||
10872 | UUID invItemID=InventorySelf(); | ||
10873 | if (invItemID == UUID.Zero) return; | ||
10874 | |||
10875 | // the object we are in | 10669 | // the object we are in |
10876 | UUID objectID = m_host.ParentUUID; | 10670 | UUID objectID = m_host.ParentUUID; |
10877 | if (objectID == UUID.Zero) return; | 10671 | if (objectID == UUID.Zero) |
10672 | return; | ||
10878 | 10673 | ||
10879 | // we need the permission first, to know which avatar we want to clear the camera for | 10674 | // we need the permission first, to know which avatar we want to clear the camera for |
10880 | UUID agentID; | 10675 | UUID agentID = m_item.PermsGranter; |
10881 | m_host.TaskInventory.LockItemsForRead(true); | 10676 | |
10882 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
10883 | if (agentID == UUID.Zero) | 10677 | if (agentID == UUID.Zero) |
10884 | { | ||
10885 | m_host.TaskInventory.LockItemsForRead(false); | ||
10886 | return; | 10678 | return; |
10887 | } | 10679 | |
10888 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | 10680 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) |
10889 | { | ||
10890 | m_host.TaskInventory.LockItemsForRead(false); | ||
10891 | return; | 10681 | return; |
10892 | } | ||
10893 | m_host.TaskInventory.LockItemsForRead(false); | ||
10894 | 10682 | ||
10895 | ScenePresence presence = World.GetScenePresence(agentID); | 10683 | ScenePresence presence = World.GetScenePresence(agentID); |
10896 | 10684 | ||
10897 | // we are not interested in child-agents | 10685 | // we are not interested in child-agents |
10898 | if (presence.IsChildAgent) return; | 10686 | if (presence.IsChildAgent) |
10687 | return; | ||
10899 | 10688 | ||
10900 | presence.ControllingClient.SendClearFollowCamProperties(objectID); | 10689 | presence.ControllingClient.SendClearFollowCamProperties(objectID); |
10901 | } | 10690 | } |
@@ -11086,8 +10875,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11086 | } | 10875 | } |
11087 | } | 10876 | } |
11088 | 10877 | ||
11089 | UUID reqID = httpScriptMod. | 10878 | UUID reqID |
11090 | StartHttpRequest(m_localID, m_itemID, url, param, httpHeaders, body); | 10879 | = httpScriptMod.StartHttpRequest(m_host.LocalId, m_item.ItemID, url, param, httpHeaders, body); |
11091 | 10880 | ||
11092 | if (reqID != UUID.Zero) | 10881 | if (reqID != UUID.Zero) |
11093 | return reqID.ToString(); | 10882 | return reqID.ToString(); |
@@ -11319,19 +11108,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11319 | break; | 11108 | break; |
11320 | // For the following 8 see the Object version below | 11109 | // For the following 8 see the Object version below |
11321 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: | 11110 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: |
11322 | ret.Add(new LSL_Integer(0)); | 11111 | ret.Add(new LSL_Integer(av.RunningScriptCount())); |
11323 | break; | 11112 | break; |
11324 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: | 11113 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: |
11325 | ret.Add(new LSL_Integer(0)); | 11114 | ret.Add(new LSL_Integer(av.ScriptCount())); |
11326 | break; | 11115 | break; |
11327 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: | 11116 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: |
11328 | ret.Add(new LSL_Integer(0)); | 11117 | ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384)); |
11329 | break; | 11118 | break; |
11330 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: | 11119 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: |
11331 | ret.Add(new LSL_Float(0)); | 11120 | ret.Add(new LSL_Float(av.ScriptExecutionTime() / 1000.0f)); |
11332 | break; | 11121 | break; |
11333 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: | 11122 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: |
11334 | ret.Add(new LSL_Integer(0)); | 11123 | ret.Add(new LSL_Integer(1)); |
11335 | break; | 11124 | break; |
11336 | case ScriptBaseClass.OBJECT_SERVER_COST: | 11125 | case ScriptBaseClass.OBJECT_SERVER_COST: |
11337 | ret.Add(new LSL_Float(0)); | 11126 | ret.Add(new LSL_Float(0)); |
@@ -11383,43 +11172,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11383 | case ScriptBaseClass.OBJECT_CREATOR: | 11172 | case ScriptBaseClass.OBJECT_CREATOR: |
11384 | ret.Add(new LSL_String(obj.CreatorID.ToString())); | 11173 | ret.Add(new LSL_String(obj.CreatorID.ToString())); |
11385 | break; | 11174 | break; |
11386 | // The following 8 I have intentionaly coded to return zero. They are part of | ||
11387 | // "Land Impact" calculations. These calculations are probably not applicable | ||
11388 | // to OpenSim, required figures (cpu/memory usage) are not currently tracked | ||
11389 | // I have intentionally left these all at zero rather than return possibly | ||
11390 | // missleading numbers | ||
11391 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: | 11175 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: |
11392 | // in SL this currently includes crashed scripts | 11176 | ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount())); |
11393 | ret.Add(new LSL_Integer(0)); | ||
11394 | break; | 11177 | break; |
11395 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: | 11178 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: |
11396 | ret.Add(new LSL_Integer(0)); | 11179 | ret.Add(new LSL_Integer(obj.ParentGroup.ScriptCount())); |
11397 | break; | 11180 | break; |
11398 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: | 11181 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: |
11399 | // The value returned in SL for mono scripts is 65536 * number of active scripts | 11182 | // The value returned in SL for mono scripts is 65536 * number of active scripts |
11400 | ret.Add(new LSL_Integer(0)); | 11183 | // and 16384 * number of active scripts for LSO. since llGetFreememory |
11184 | // is coded to give the LSO value use it here | ||
11185 | ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384)); | ||
11401 | break; | 11186 | break; |
11402 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: | 11187 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: |
11403 | // Average cpu time per simulator frame expended on all scripts in the objetc | 11188 | // Average cpu time in seconds per simulator frame expended on all scripts in the object |
11404 | ret.Add(new LSL_Float(0)); | 11189 | ret.Add(new LSL_Float(obj.ParentGroup.ScriptExecutionTime() / 1000.0f)); |
11405 | break; | 11190 | break; |
11406 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: | 11191 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: |
11407 | // according to the SL wiki A prim or linkset will have prim | 11192 | // according to the SL wiki A prim or linkset will have prim |
11408 | // equivalent of the number of prims in a linkset if it does not | 11193 | // equivalent of the number of prims in a linkset if it does not |
11409 | // contain a mesh anywhere in the link set or is not a normal prim | 11194 | // contain a mesh anywhere in the link set or is not a normal prim |
11410 | // The value returned in SL for normal prims is prim count | 11195 | // The value returned in SL for normal prims is prim count |
11411 | ret.Add(new LSL_Integer(0)); | 11196 | ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); |
11412 | break; | 11197 | break; |
11198 | // The following 3 costs I have intentionaly coded to return zero. They are part of | ||
11199 | // "Land Impact" calculations. These calculations are probably not applicable | ||
11200 | // to OpenSim and are not yet complete in SL | ||
11413 | case ScriptBaseClass.OBJECT_SERVER_COST: | 11201 | case ScriptBaseClass.OBJECT_SERVER_COST: |
11414 | // The value returned in SL for normal prims is prim count | 11202 | // The linden calculation is here |
11203 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight | ||
11204 | // The value returned in SL for normal prims looks like the prim count | ||
11415 | ret.Add(new LSL_Float(0)); | 11205 | ret.Add(new LSL_Float(0)); |
11416 | break; | 11206 | break; |
11417 | case ScriptBaseClass.OBJECT_STREAMING_COST: | 11207 | case ScriptBaseClass.OBJECT_STREAMING_COST: |
11418 | // The value returned in SL for normal prims is prim count * 0.06 | 11208 | // The linden calculation is here |
11209 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost | ||
11210 | // The value returned in SL for normal prims looks like the prim count * 0.06 | ||
11419 | ret.Add(new LSL_Float(0)); | 11211 | ret.Add(new LSL_Float(0)); |
11420 | break; | 11212 | break; |
11421 | case ScriptBaseClass.OBJECT_PHYSICS_COST: | 11213 | case ScriptBaseClass.OBJECT_PHYSICS_COST: |
11422 | // The value returned in SL for normal prims is prim count | 11214 | // The linden calculation is here |
11215 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics | ||
11216 | // The value returned in SL for normal prims looks like the prim count | ||
11423 | ret.Add(new LSL_Float(0)); | 11217 | ret.Add(new LSL_Float(0)); |
11424 | break; | 11218 | break; |
11425 | default: | 11219 | default: |
@@ -11517,7 +11311,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11517 | } | 11311 | } |
11518 | 11312 | ||
11519 | // was: UUID tid = tid = AsyncCommands. | 11313 | // was: UUID tid = tid = AsyncCommands. |
11520 | UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); | 11314 | UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString()); |
11521 | 11315 | ||
11522 | if (NotecardCache.IsCached(assetID)) | 11316 | if (NotecardCache.IsCached(assetID)) |
11523 | { | 11317 | { |
@@ -11580,7 +11374,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11580 | } | 11374 | } |
11581 | 11375 | ||
11582 | // was: UUID tid = tid = AsyncCommands. | 11376 | // was: UUID tid = tid = AsyncCommands. |
11583 | UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); | 11377 | UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString()); |
11584 | 11378 | ||
11585 | if (NotecardCache.IsCached(assetID)) | 11379 | if (NotecardCache.IsCached(assetID)) |
11586 | { | 11380 | { |
@@ -11664,7 +11458,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11664 | { | 11458 | { |
11665 | UUID rq = UUID.Random(); | 11459 | UUID rq = UUID.Random(); |
11666 | 11460 | ||
11667 | AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); | 11461 | AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString()); |
11668 | 11462 | ||
11669 | AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); | 11463 | AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); |
11670 | 11464 | ||
@@ -11680,7 +11474,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11680 | { | 11474 | { |
11681 | UUID rq = UUID.Random(); | 11475 | UUID rq = UUID.Random(); |
11682 | 11476 | ||
11683 | AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); | 11477 | AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString()); |
11684 | 11478 | ||
11685 | AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); | 11479 | AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); |
11686 | 11480 | ||
@@ -12174,7 +11968,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12174 | bool isAccount = false; | 11968 | bool isAccount = false; |
12175 | bool isGroup = false; | 11969 | bool isGroup = false; |
12176 | 11970 | ||
12177 | if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManager(m_host.OwnerID)) | 11971 | if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID)) |
12178 | return 0; | 11972 | return 0; |
12179 | 11973 | ||
12180 | UUID id = new UUID(); | 11974 | UUID id = new UUID(); |
@@ -12236,35 +12030,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12236 | return 1; | 12030 | return 1; |
12237 | } | 12031 | } |
12238 | 12032 | ||
12239 | #region Not Implemented | 12033 | public LSL_Integer llGetMemoryLimit() |
12240 | // | 12034 | { |
12241 | // Listing the unimplemented lsl functions here, please move | 12035 | m_host.AddScriptLPS(1); |
12242 | // them from this region as they are completed | 12036 | // The value returned for LSO scripts in SL |
12243 | // | 12037 | return 16384; |
12038 | } | ||
12244 | 12039 | ||
12245 | public void llGetEnv(LSL_String name) | 12040 | public LSL_Integer llSetMemoryLimit(LSL_Integer limit) |
12246 | { | 12041 | { |
12247 | m_host.AddScriptLPS(1); | 12042 | m_host.AddScriptLPS(1); |
12248 | NotImplemented("llGetEnv"); | 12043 | // Treat as an LSO script |
12044 | return ScriptBaseClass.FALSE; | ||
12249 | } | 12045 | } |
12250 | 12046 | ||
12251 | public void llGetSPMaxMemory() | 12047 | public LSL_Integer llGetSPMaxMemory() |
12252 | { | 12048 | { |
12253 | m_host.AddScriptLPS(1); | 12049 | m_host.AddScriptLPS(1); |
12254 | NotImplemented("llGetSPMaxMemory"); | 12050 | // The value returned for LSO scripts in SL |
12051 | return 16384; | ||
12255 | } | 12052 | } |
12256 | 12053 | ||
12257 | public virtual LSL_Integer llGetUsedMemory() | 12054 | public virtual LSL_Integer llGetUsedMemory() |
12258 | { | 12055 | { |
12259 | m_host.AddScriptLPS(1); | 12056 | m_host.AddScriptLPS(1); |
12260 | NotImplemented("llGetUsedMemory"); | 12057 | // The value returned for LSO scripts in SL |
12261 | return 0; | 12058 | return 16384; |
12262 | } | 12059 | } |
12263 | 12060 | ||
12264 | public void llScriptProfiler(LSL_Integer flags) | 12061 | public void llScriptProfiler(LSL_Integer flags) |
12265 | { | 12062 | { |
12266 | m_host.AddScriptLPS(1); | 12063 | m_host.AddScriptLPS(1); |
12267 | //NotImplemented("llScriptProfiler"); | 12064 | // This does nothing for LSO scripts in SL |
12065 | } | ||
12066 | |||
12067 | #region Not Implemented | ||
12068 | // | ||
12069 | // Listing the unimplemented lsl functions here, please move | ||
12070 | // them from this region as they are completed | ||
12071 | // | ||
12072 | |||
12073 | public void llGetEnv(LSL_String name) | ||
12074 | { | ||
12075 | m_host.AddScriptLPS(1); | ||
12076 | NotImplemented("llGetEnv"); | ||
12268 | } | 12077 | } |
12269 | 12078 | ||
12270 | public void llSetSoundQueueing(int queue) | 12079 | public void llSetSoundQueueing(int queue) |
@@ -12344,8 +12153,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12344 | 12153 | ||
12345 | try | 12154 | try |
12346 | { | 12155 | { |
12347 | UUID invItemID=InventorySelf(); | 12156 | TaskInventoryItem item = m_item; |
12348 | if (invItemID == UUID.Zero) | 12157 | if (item == null) |
12349 | { | 12158 | { |
12350 | replydata = "SERVICE_ERROR"; | 12159 | replydata = "SERVICE_ERROR"; |
12351 | return; | 12160 | return; |
@@ -12353,10 +12162,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12353 | 12162 | ||
12354 | m_host.AddScriptLPS(1); | 12163 | m_host.AddScriptLPS(1); |
12355 | 12164 | ||
12356 | m_host.TaskInventory.LockItemsForRead(true); | ||
12357 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | ||
12358 | m_host.TaskInventory.LockItemsForRead(false); | ||
12359 | |||
12360 | if (item.PermsGranter == UUID.Zero) | 12165 | if (item.PermsGranter == UUID.Zero) |
12361 | { | 12166 | { |
12362 | replydata = "MISSING_PERMISSION_DEBIT"; | 12167 | replydata = "MISSING_PERMISSION_DEBIT"; |
@@ -12398,7 +12203,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12398 | } | 12203 | } |
12399 | finally | 12204 | finally |
12400 | { | 12205 | { |
12401 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 12206 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
12402 | "transaction_result", new Object[] { | 12207 | "transaction_result", new Object[] { |
12403 | new LSL_String(txn.ToString()), | 12208 | new LSL_String(txn.ToString()), |
12404 | new LSL_Integer(replycode), | 12209 | 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..8237b60 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 | ||
@@ -957,21 +960,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
957 | UUID avatarID = (UUID)avatar; | 960 | UUID avatarID = (UUID)avatar; |
958 | 961 | ||
959 | m_host.AddScriptLPS(1); | 962 | m_host.AddScriptLPS(1); |
963 | |||
964 | // FIXME: What we really want to do here is factor out the similar code in llStopAnimation() to a common | ||
965 | // method (though see that doesn't do the is animation check, which is probably a bug) and have both | ||
966 | // these functions call that common code. However, this does mean navigating the brain-dead requirement | ||
967 | // of calling InitLSL() | ||
960 | if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence) | 968 | if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence) |
961 | { | 969 | { |
962 | ScenePresence target = (ScenePresence)World.Entities[avatarID]; | 970 | ScenePresence target = (ScenePresence)World.Entities[avatarID]; |
963 | if (target != null) | 971 | if (target != null) |
964 | { | 972 | { |
965 | UUID animID = UUID.Zero; | 973 | UUID animID; |
966 | m_host.TaskInventory.LockItemsForRead(true); | 974 | |
967 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 975 | if (!UUID.TryParse(animation, out animID)) |
968 | { | 976 | { |
969 | if (inv.Value.Name == animation) | 977 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation); |
970 | { | 978 | if (item != null && item.Type == (int)AssetType.Animation) |
971 | if (inv.Value.Type == (int)AssetType.Animation) | 979 | animID = item.AssetID; |
972 | animID = inv.Value.AssetID; | 980 | else |
973 | continue; | 981 | animID = UUID.Zero; |
974 | } | ||
975 | } | 982 | } |
976 | m_host.TaskInventory.LockItemsForRead(false); | 983 | m_host.TaskInventory.LockItemsForRead(false); |
977 | 984 | ||
@@ -1178,7 +1185,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1178 | CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); | 1185 | CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); |
1179 | m_host.AddScriptLPS(1); | 1186 | m_host.AddScriptLPS(1); |
1180 | 1187 | ||
1181 | m_host.SetScriptEvents(m_itemID, events); | 1188 | m_host.SetScriptEvents(m_item.ItemID, events); |
1182 | } | 1189 | } |
1183 | 1190 | ||
1184 | public void osSetRegionWaterHeight(double height) | 1191 | public void osSetRegionWaterHeight(double height) |
@@ -1186,12 +1193,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1186 | CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); | 1193 | CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); |
1187 | 1194 | ||
1188 | m_host.AddScriptLPS(1); | 1195 | m_host.AddScriptLPS(1); |
1189 | //Check to make sure that the script's owner is the estate manager/master | 1196 | |
1190 | //World.Permissions.GenericEstatePermission( | 1197 | World.EventManager.TriggerRequestChangeWaterHeight((float)height); |
1191 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
1192 | { | ||
1193 | World.EventManager.TriggerRequestChangeWaterHeight((float)height); | ||
1194 | } | ||
1195 | } | 1198 | } |
1196 | 1199 | ||
1197 | /// <summary> | 1200 | /// <summary> |
@@ -1202,27 +1205,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> | 1205 | /// <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) | 1206 | public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) |
1204 | { | 1207 | { |
1205 | CheckThreatLevel(ThreatLevel.Nuisance, "osSetRegionSunSettings"); | 1208 | CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings"); |
1206 | 1209 | ||
1207 | m_host.AddScriptLPS(1); | 1210 | 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 | 1211 | ||
1215 | while (sunHour < 0) | 1212 | while (sunHour > 24.0) |
1216 | sunHour += 24.0; | 1213 | sunHour -= 24.0; |
1217 | 1214 | ||
1215 | while (sunHour < 0) | ||
1216 | sunHour += 24.0; | ||
1218 | 1217 | ||
1219 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; | 1218 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; |
1220 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 | 1219 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 |
1221 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; | 1220 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; |
1222 | World.RegionInfo.RegionSettings.Save(); | 1221 | World.RegionInfo.RegionSettings.Save(); |
1223 | 1222 | ||
1224 | World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); | 1223 | World.EventManager.TriggerEstateToolsSunUpdate( |
1225 | } | 1224 | World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); |
1226 | } | 1225 | } |
1227 | 1226 | ||
1228 | /// <summary> | 1227 | /// <summary> |
@@ -1232,26 +1231,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> | 1231 | /// <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) | 1232 | public void osSetEstateSunSettings(bool sunFixed, double sunHour) |
1234 | { | 1233 | { |
1235 | CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings"); | 1234 | CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings"); |
1236 | 1235 | ||
1237 | m_host.AddScriptLPS(1); | 1236 | 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 | 1237 | ||
1245 | while (sunHour < 0) | 1238 | while (sunHour > 24.0) |
1246 | sunHour += 24.0; | 1239 | sunHour -= 24.0; |
1247 | 1240 | ||
1248 | World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; | 1241 | while (sunHour < 0) |
1249 | World.RegionInfo.EstateSettings.SunPosition = sunHour; | 1242 | sunHour += 24.0; |
1250 | World.RegionInfo.EstateSettings.FixedSun = sunFixed; | ||
1251 | World.RegionInfo.EstateSettings.Save(); | ||
1252 | 1243 | ||
1253 | World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); | 1244 | World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; |
1254 | } | 1245 | World.RegionInfo.EstateSettings.SunPosition = sunHour; |
1246 | World.RegionInfo.EstateSettings.FixedSun = sunFixed; | ||
1247 | World.RegionInfo.EstateSettings.Save(); | ||
1248 | |||
1249 | World.EventManager.TriggerEstateToolsSunUpdate( | ||
1250 | World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); | ||
1255 | } | 1251 | } |
1256 | 1252 | ||
1257 | /// <summary> | 1253 | /// <summary> |
@@ -1627,7 +1623,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1627 | 1623 | ||
1628 | public Object osParseJSONNew(string JSON) | 1624 | public Object osParseJSONNew(string JSON) |
1629 | { | 1625 | { |
1630 | CheckThreatLevel(ThreatLevel.None, "osParseJSON"); | 1626 | CheckThreatLevel(ThreatLevel.None, "osParseJSONNew"); |
1631 | 1627 | ||
1632 | m_host.AddScriptLPS(1); | 1628 | m_host.AddScriptLPS(1); |
1633 | 1629 | ||
@@ -2042,8 +2038,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2042 | string nick = String.Empty; | 2038 | string nick = String.Empty; |
2043 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2039 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2044 | 2040 | ||
2045 | if (config.Configs["GridInfo"] != null) | 2041 | if (config.Configs[GridInfoServiceConfigSectionName] != null) |
2046 | nick = config.Configs["GridInfo"].GetString("gridnick", nick); | 2042 | nick = config.Configs[GridInfoServiceConfigSectionName].GetString("gridnick", nick); |
2047 | 2043 | ||
2048 | if (String.IsNullOrEmpty(nick)) | 2044 | if (String.IsNullOrEmpty(nick)) |
2049 | nick = GridUserInfo(InfoType.Nick); | 2045 | nick = GridUserInfo(InfoType.Nick); |
@@ -2059,8 +2055,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2059 | string name = String.Empty; | 2055 | string name = String.Empty; |
2060 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2056 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2061 | 2057 | ||
2062 | if (config.Configs["GridInfo"] != null) | 2058 | if (config.Configs[GridInfoServiceConfigSectionName] != null) |
2063 | name = config.Configs["GridInfo"].GetString("gridname", name); | 2059 | name = config.Configs[GridInfoServiceConfigSectionName].GetString("gridname", name); |
2064 | 2060 | ||
2065 | if (String.IsNullOrEmpty(name)) | 2061 | if (String.IsNullOrEmpty(name)) |
2066 | name = GridUserInfo(InfoType.Name); | 2062 | name = GridUserInfo(InfoType.Name); |
@@ -2076,8 +2072,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2076 | string loginURI = String.Empty; | 2072 | string loginURI = String.Empty; |
2077 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2073 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2078 | 2074 | ||
2079 | if (config.Configs["GridInfo"] != null) | 2075 | if (config.Configs[GridInfoServiceConfigSectionName] != null) |
2080 | loginURI = config.Configs["GridInfo"].GetString("login", loginURI); | 2076 | loginURI = config.Configs[GridInfoServiceConfigSectionName].GetString("login", loginURI); |
2081 | 2077 | ||
2082 | if (String.IsNullOrEmpty(loginURI)) | 2078 | if (String.IsNullOrEmpty(loginURI)) |
2083 | loginURI = GridUserInfo(InfoType.Login); | 2079 | loginURI = GridUserInfo(InfoType.Login); |
@@ -2124,8 +2120,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2124 | string retval = String.Empty; | 2120 | string retval = String.Empty; |
2125 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2121 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2126 | 2122 | ||
2127 | if (config.Configs["GridInfo"] != null) | 2123 | if (config.Configs[GridInfoServiceConfigSectionName] != null) |
2128 | retval = config.Configs["GridInfo"].GetString(key, retval); | 2124 | retval = config.Configs[GridInfoServiceConfigSectionName].GetString(key, retval); |
2129 | 2125 | ||
2130 | if (String.IsNullOrEmpty(retval)) | 2126 | if (String.IsNullOrEmpty(retval)) |
2131 | retval = GridUserInfo(InfoType.Custom, key); | 2127 | retval = GridUserInfo(InfoType.Custom, key); |
@@ -2480,7 +2476,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2480 | return; | 2476 | return; |
2481 | 2477 | ||
2482 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); | 2478 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); |
2483 | module.MoveToTarget(npcId, World, pos, false, true); | 2479 | module.MoveToTarget(npcId, World, pos, false, true, false); |
2484 | } | 2480 | } |
2485 | } | 2481 | } |
2486 | 2482 | ||
@@ -2505,7 +2501,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2505 | World, | 2501 | World, |
2506 | pos, | 2502 | pos, |
2507 | (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, | 2503 | (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, |
2508 | (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0); | 2504 | (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0, |
2505 | (options & ScriptBaseClass.OS_NPC_RUNNING) != 0); | ||
2509 | } | 2506 | } |
2510 | } | 2507 | } |
2511 | 2508 | ||
@@ -2555,7 +2552,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2555 | 2552 | ||
2556 | public void osNpcStopMoveToTarget(LSL_Key npc) | 2553 | public void osNpcStopMoveToTarget(LSL_Key npc) |
2557 | { | 2554 | { |
2558 | CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); | 2555 | CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget"); |
2559 | m_host.AddScriptLPS(1); | 2556 | m_host.AddScriptLPS(1); |
2560 | 2557 | ||
2561 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2558 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
@@ -2572,6 +2569,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2572 | 2569 | ||
2573 | public void osNpcSay(LSL_Key npc, string message) | 2570 | public void osNpcSay(LSL_Key npc, string message) |
2574 | { | 2571 | { |
2572 | osNpcSay(npc, 0, message); | ||
2573 | } | ||
2574 | |||
2575 | public void osNpcSay(LSL_Key npc, int channel, string message) | ||
2576 | { | ||
2575 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); | 2577 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); |
2576 | m_host.AddScriptLPS(1); | 2578 | m_host.AddScriptLPS(1); |
2577 | 2579 | ||
@@ -2583,7 +2585,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2583 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | 2585 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) |
2584 | return; | 2586 | return; |
2585 | 2587 | ||
2586 | module.Say(npcId, World, message); | 2588 | module.Say(npcId, World, message, channel); |
2589 | } | ||
2590 | } | ||
2591 | |||
2592 | public void osNpcShout(LSL_Key npc, int channel, string message) | ||
2593 | { | ||
2594 | CheckThreatLevel(ThreatLevel.High, "osNpcShout"); | ||
2595 | m_host.AddScriptLPS(1); | ||
2596 | |||
2597 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2598 | if (module != null) | ||
2599 | { | ||
2600 | UUID npcId = new UUID(npc.m_string); | ||
2601 | |||
2602 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2603 | return; | ||
2604 | |||
2605 | module.Shout(npcId, World, message, channel); | ||
2587 | } | 2606 | } |
2588 | } | 2607 | } |
2589 | 2608 | ||
@@ -2684,6 +2703,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2684 | } | 2703 | } |
2685 | } | 2704 | } |
2686 | 2705 | ||
2706 | public void osNpcWhisper(LSL_Key npc, int channel, string message) | ||
2707 | { | ||
2708 | CheckThreatLevel(ThreatLevel.High, "osNpcWhisper"); | ||
2709 | m_host.AddScriptLPS(1); | ||
2710 | |||
2711 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2712 | if (module != null) | ||
2713 | { | ||
2714 | UUID npcId = new UUID(npc.m_string); | ||
2715 | |||
2716 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2717 | return; | ||
2718 | |||
2719 | module.Whisper(npcId, World, message, channel); | ||
2720 | } | ||
2721 | } | ||
2722 | |||
2687 | /// <summary> | 2723 | /// <summary> |
2688 | /// Save the current appearance of the script owner permanently to the named notecard. | 2724 | /// Save the current appearance of the script owner permanently to the named notecard. |
2689 | /// </summary> | 2725 | /// </summary> |
@@ -2835,21 +2871,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2835 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); | 2871 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); |
2836 | m_host.AddScriptLPS(1); | 2872 | m_host.AddScriptLPS(1); |
2837 | 2873 | ||
2838 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) | 2874 | World.ForEachRootScenePresence(delegate(ScenePresence sp) |
2839 | { | 2875 | { |
2840 | World.ForEachRootScenePresence(delegate(ScenePresence sp) | 2876 | if (sp.Firstname == FirstName && sp.Lastname == SurName) |
2841 | { | 2877 | { |
2842 | if (sp.Firstname == FirstName && sp.Lastname == SurName) | 2878 | // kick client... |
2843 | { | 2879 | if (alert != null) |
2844 | // kick client... | 2880 | sp.ControllingClient.Kick(alert); |
2845 | if (alert != null) | ||
2846 | sp.ControllingClient.Kick(alert); | ||
2847 | 2881 | ||
2848 | // ...and close on our side | 2882 | // ...and close on our side |
2849 | sp.Scene.IncomingCloseAgent(sp.UUID); | 2883 | sp.Scene.IncomingCloseAgent(sp.UUID); |
2850 | } | 2884 | } |
2851 | }); | 2885 | }); |
2852 | } | ||
2853 | } | 2886 | } |
2854 | 2887 | ||
2855 | public void osCauseDamage(string avatar, double damage) | 2888 | public void osCauseDamage(string avatar, double damage) |
@@ -3095,5 +3128,80 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3095 | 3128 | ||
3096 | return ScriptBaseClass.TRUE; | 3129 | return ScriptBaseClass.TRUE; |
3097 | } | 3130 | } |
3131 | |||
3132 | /// <summary> | ||
3133 | /// Sets terrain estate texture | ||
3134 | /// </summary> | ||
3135 | /// <param name="level"></param> | ||
3136 | /// <param name="texture"></param> | ||
3137 | /// <returns></returns> | ||
3138 | public void osSetTerrainTexture(int level, LSL_Key texture) | ||
3139 | { | ||
3140 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture"); | ||
3141 | |||
3142 | m_host.AddScriptLPS(1); | ||
3143 | //Check to make sure that the script's owner is the estate manager/master | ||
3144 | //World.Permissions.GenericEstatePermission( | ||
3145 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
3146 | { | ||
3147 | if (level < 0 || level > 3) | ||
3148 | return; | ||
3149 | |||
3150 | UUID textureID = new UUID(); | ||
3151 | if (!UUID.TryParse(texture, out textureID)) | ||
3152 | return; | ||
3153 | |||
3154 | // estate module is required | ||
3155 | IEstateModule estate = World.RequestModuleInterface<IEstateModule>(); | ||
3156 | if (estate != null) | ||
3157 | estate.setEstateTerrainBaseTexture(level, textureID); | ||
3158 | } | ||
3159 | } | ||
3160 | |||
3161 | /// <summary> | ||
3162 | /// Sets terrain heights of estate | ||
3163 | /// </summary> | ||
3164 | /// <param name="corner"></param> | ||
3165 | /// <param name="low"></param> | ||
3166 | /// <param name="high"></param> | ||
3167 | /// <returns></returns> | ||
3168 | public void osSetTerrainTextureHeight(int corner, double low, double high) | ||
3169 | { | ||
3170 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight"); | ||
3171 | |||
3172 | m_host.AddScriptLPS(1); | ||
3173 | //Check to make sure that the script's owner is the estate manager/master | ||
3174 | //World.Permissions.GenericEstatePermission( | ||
3175 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
3176 | { | ||
3177 | if (corner < 0 || corner > 3) | ||
3178 | return; | ||
3179 | |||
3180 | // estate module is required | ||
3181 | IEstateModule estate = World.RequestModuleInterface<IEstateModule>(); | ||
3182 | if (estate != null) | ||
3183 | estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high); | ||
3184 | } | ||
3185 | } | ||
3186 | |||
3187 | public void osForceAttachToAvatar(int attachmentPoint) | ||
3188 | { | ||
3189 | CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); | ||
3190 | |||
3191 | m_host.AddScriptLPS(1); | ||
3192 | |||
3193 | InitLSL(); | ||
3194 | ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); | ||
3195 | } | ||
3196 | |||
3197 | public void osForceDetachFromAvatar() | ||
3198 | { | ||
3199 | CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); | ||
3200 | |||
3201 | m_host.AddScriptLPS(1); | ||
3202 | |||
3203 | InitLSL(); | ||
3204 | ((LSL_Api)m_LSL_Api).DetachFromAvatar(); | ||
3205 | } | ||
3098 | } | 3206 | } |
3099 | } | 3207 | } |
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 5e68d69..1c59d45 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 |
@@ -966,7 +966,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
966 | public IScriptApi GetApi(string name) | 966 | public IScriptApi GetApi(string name) |
967 | { | 967 | { |
968 | if (m_Apis.ContainsKey(name)) | 968 | if (m_Apis.ContainsKey(name)) |
969 | { | ||
970 | // m_log.DebugFormat("[SCRIPT INSTANCE]: Found api {0} in {1}@{2}", name, ScriptName, PrimName); | ||
971 | |||
969 | return m_Apis[name]; | 972 | return m_Apis[name]; |
973 | } | ||
974 | |||
975 | // m_log.DebugFormat("[SCRIPT INSTANCE]: Did not find api {0} in {1}@{2}", name, ScriptName, PrimName); | ||
976 | |||
970 | return null; | 977 | return null; |
971 | } | 978 | } |
972 | 979 | ||
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); |