aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs41
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs717
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs270
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs25
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs20
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs25
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs39
12 files changed, 600 insertions, 582 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;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using log4net;
32using OpenSim.Region.ScriptEngine.Interfaces; 33using OpenSim.Region.ScriptEngine.Interfaces;
33 34
34namespace OpenSim.Region.ScriptEngine.Shared.Api 35namespace 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 edabc2e..8072e72 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,11 +111,12 @@ 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;
113 118
114 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 119 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
115 { 120 {
116 m_ShoutSayTimer = new Timer(1000); 121 m_ShoutSayTimer = new Timer(1000);
117 m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed; 122 m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed;
@@ -120,10 +125,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
120 125
121 m_ScriptEngine = ScriptEngine; 126 m_ScriptEngine = ScriptEngine;
122 m_host = host; 127 m_host = host;
123 m_localID = localID; 128 m_item = item;
124 m_itemID = itemID;
125 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); 129 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
126 130
131 LoadLimits(); // read script limits from config.
132
133 m_TransferModule =
134 m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>();
135 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
136
137 AsyncCommands = new AsyncCommandManager(ScriptEngine);
138 }
139
140 /* load configuration items that affect script, object and run-time behavior. */
141 private void LoadLimits()
142 {
127 m_ScriptDelayFactor = 143 m_ScriptDelayFactor =
128 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); 144 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
129 m_ScriptDistanceFactor = 145 m_ScriptDistanceFactor =
@@ -136,12 +152,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
136 m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255); 152 m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255);
137 if (m_notecardLineReadCharsMax > 65535) 153 if (m_notecardLineReadCharsMax > 65535)
138 m_notecardLineReadCharsMax = 65535; 154 m_notecardLineReadCharsMax = 65535;
139 155 // load limits for particular subsystems.
140 m_TransferModule = 156 IConfig SMTPConfig;
141 m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); 157 if ((SMTPConfig = m_ScriptEngine.ConfigSource.Configs["SMTP"]) != null) {
142 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); 158 // there's an smtp config, so load in the snooze time.
143 159 EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME);
144 AsyncCommands = new AsyncCommandManager(ScriptEngine); 160 }
145 } 161 }
146 162
147 public override Object InitializeLifetimeService() 163 public override Object InitializeLifetimeService()
@@ -173,7 +189,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
173 [DebuggerNonUserCode] 189 [DebuggerNonUserCode]
174 public void state(string newState) 190 public void state(string newState)
175 { 191 {
176 m_ScriptEngine.SetState(m_itemID, newState); 192 m_ScriptEngine.SetState(m_item.ItemID, newState);
177 } 193 }
178 194
179 /// <summary> 195 /// <summary>
@@ -184,7 +200,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
184 public void llResetScript() 200 public void llResetScript()
185 { 201 {
186 m_host.AddScriptLPS(1); 202 m_host.AddScriptLPS(1);
187 m_ScriptEngine.ApiResetScript(m_itemID); 203 m_ScriptEngine.ApiResetScript(m_item.ItemID);
188 } 204 }
189 205
190 public void llResetOtherScript(string name) 206 public void llResetOtherScript(string name)
@@ -336,30 +352,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
336 } 352 }
337 } 353 }
338 354
339 protected UUID InventorySelf()
340 {
341 UUID invItemID = new UUID();
342 bool unlock = false;
343 if (!m_host.TaskInventory.IsReadLockedByMe())
344 {
345 m_host.TaskInventory.LockItemsForRead(true);
346 unlock = true;
347 }
348 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
349 {
350 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
351 {
352 invItemID = inv.Key;
353 break;
354 }
355 }
356 if (unlock)
357 {
358 m_host.TaskInventory.LockItemsForRead(false);
359 }
360 return invItemID;
361 }
362
363 protected UUID InventoryKey(string name, int type) 355 protected UUID InventoryKey(string name, int type)
364 { 356 {
365 m_host.AddScriptLPS(1); 357 m_host.AddScriptLPS(1);
@@ -941,20 +933,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
941 933
942 public void llRegionSayTo(string target, int channel, string msg) 934 public void llRegionSayTo(string target, int channel, string msg)
943 { 935 {
944 string error = String.Empty;
945
946 if (msg.Length > 1023) 936 if (msg.Length > 1023)
947 msg = msg.Substring(0, 1023); 937 msg = msg.Substring(0, 1023);
948 938
949 m_host.AddScriptLPS(1); 939 m_host.AddScriptLPS(1);
950 940
941 if (channel == ScriptBaseClass.DEBUG_CHANNEL)
942 {
943 return;
944 }
945
951 UUID TargetID; 946 UUID TargetID;
952 UUID.TryParse(target, out TargetID); 947 UUID.TryParse(target, out TargetID);
953 948
954 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 949 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
955 if (wComm != null) 950 if (wComm != null)
956 if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) 951 wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg);
957 LSLError(error);
958 } 952 }
959 953
960 public LSL_Integer llListen(int channelID, string name, string ID, string msg) 954 public LSL_Integer llListen(int channelID, string name, string ID, string msg)
@@ -964,7 +958,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
964 UUID.TryParse(ID, out keyID); 958 UUID.TryParse(ID, out keyID);
965 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 959 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
966 if (wComm != null) 960 if (wComm != null)
967 return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg); 961 return wComm.Listen(m_host.LocalId, m_item.ItemID, m_host.UUID, channelID, name, keyID, msg);
968 else 962 else
969 return -1; 963 return -1;
970 } 964 }
@@ -974,7 +968,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
974 m_host.AddScriptLPS(1); 968 m_host.AddScriptLPS(1);
975 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 969 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
976 if (wComm != null) 970 if (wComm != null)
977 wComm.ListenControl(m_itemID, number, active); 971 wComm.ListenControl(m_item.ItemID, number, active);
978 } 972 }
979 973
980 public void llListenRemove(int number) 974 public void llListenRemove(int number)
@@ -982,7 +976,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
982 m_host.AddScriptLPS(1); 976 m_host.AddScriptLPS(1);
983 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 977 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
984 if (wComm != null) 978 if (wComm != null)
985 wComm.ListenRemove(m_itemID, number); 979 wComm.ListenRemove(m_item.ItemID, number);
986 } 980 }
987 981
988 public void llSensor(string name, string id, int type, double range, double arc) 982 public void llSensor(string name, string id, int type, double range, double arc)
@@ -991,7 +985,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
991 UUID keyID = UUID.Zero; 985 UUID keyID = UUID.Zero;
992 UUID.TryParse(id, out keyID); 986 UUID.TryParse(id, out keyID);
993 987
994 AsyncCommands.SensorRepeatPlugin.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); 988 AsyncCommands.SensorRepeatPlugin.SenseOnce(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, m_host);
995 } 989 }
996 990
997 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) 991 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
@@ -1000,13 +994,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1000 UUID keyID = UUID.Zero; 994 UUID keyID = UUID.Zero;
1001 UUID.TryParse(id, out keyID); 995 UUID.TryParse(id, out keyID);
1002 996
1003 AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); 997 AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, rate, m_host);
1004 } 998 }
1005 999
1006 public void llSensorRemove() 1000 public void llSensorRemove()
1007 { 1001 {
1008 m_host.AddScriptLPS(1); 1002 m_host.AddScriptLPS(1);
1009 AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_localID, m_itemID); 1003 AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_host.LocalId, m_item.ItemID);
1010 } 1004 }
1011 1005
1012 public string resolveName(UUID objecUUID) 1006 public string resolveName(UUID objecUUID)
@@ -1047,7 +1041,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1047 public LSL_String llDetectedName(int number) 1041 public LSL_String llDetectedName(int number)
1048 { 1042 {
1049 m_host.AddScriptLPS(1); 1043 m_host.AddScriptLPS(1);
1050 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1044 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1051 if (detectedParams == null) 1045 if (detectedParams == null)
1052 return String.Empty; 1046 return String.Empty;
1053 return detectedParams.Name; 1047 return detectedParams.Name;
@@ -1056,7 +1050,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1056 public LSL_String llDetectedKey(int number) 1050 public LSL_String llDetectedKey(int number)
1057 { 1051 {
1058 m_host.AddScriptLPS(1); 1052 m_host.AddScriptLPS(1);
1059 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1053 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1060 if (detectedParams == null) 1054 if (detectedParams == null)
1061 return String.Empty; 1055 return String.Empty;
1062 return detectedParams.Key.ToString(); 1056 return detectedParams.Key.ToString();
@@ -1065,7 +1059,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1065 public LSL_String llDetectedOwner(int number) 1059 public LSL_String llDetectedOwner(int number)
1066 { 1060 {
1067 m_host.AddScriptLPS(1); 1061 m_host.AddScriptLPS(1);
1068 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1062 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1069 if (detectedParams == null) 1063 if (detectedParams == null)
1070 return String.Empty; 1064 return String.Empty;
1071 return detectedParams.Owner.ToString(); 1065 return detectedParams.Owner.ToString();
@@ -1074,7 +1068,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1074 public LSL_Integer llDetectedType(int number) 1068 public LSL_Integer llDetectedType(int number)
1075 { 1069 {
1076 m_host.AddScriptLPS(1); 1070 m_host.AddScriptLPS(1);
1077 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1071 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1078 if (detectedParams == null) 1072 if (detectedParams == null)
1079 return 0; 1073 return 0;
1080 return new LSL_Integer(detectedParams.Type); 1074 return new LSL_Integer(detectedParams.Type);
@@ -1083,7 +1077,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1083 public LSL_Vector llDetectedPos(int number) 1077 public LSL_Vector llDetectedPos(int number)
1084 { 1078 {
1085 m_host.AddScriptLPS(1); 1079 m_host.AddScriptLPS(1);
1086 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1080 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1087 if (detectedParams == null) 1081 if (detectedParams == null)
1088 return new LSL_Vector(); 1082 return new LSL_Vector();
1089 return detectedParams.Position; 1083 return detectedParams.Position;
@@ -1092,7 +1086,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1092 public LSL_Vector llDetectedVel(int number) 1086 public LSL_Vector llDetectedVel(int number)
1093 { 1087 {
1094 m_host.AddScriptLPS(1); 1088 m_host.AddScriptLPS(1);
1095 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1089 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1096 if (detectedParams == null) 1090 if (detectedParams == null)
1097 return new LSL_Vector(); 1091 return new LSL_Vector();
1098 return detectedParams.Velocity; 1092 return detectedParams.Velocity;
@@ -1101,7 +1095,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1101 public LSL_Vector llDetectedGrab(int number) 1095 public LSL_Vector llDetectedGrab(int number)
1102 { 1096 {
1103 m_host.AddScriptLPS(1); 1097 m_host.AddScriptLPS(1);
1104 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 1098 DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1105 if (parms == null) 1099 if (parms == null)
1106 return new LSL_Vector(0, 0, 0); 1100 return new LSL_Vector(0, 0, 0);
1107 1101
@@ -1111,7 +1105,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1111 public LSL_Rotation llDetectedRot(int number) 1105 public LSL_Rotation llDetectedRot(int number)
1112 { 1106 {
1113 m_host.AddScriptLPS(1); 1107 m_host.AddScriptLPS(1);
1114 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1108 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1115 if (detectedParams == null) 1109 if (detectedParams == null)
1116 return new LSL_Rotation(); 1110 return new LSL_Rotation();
1117 return detectedParams.Rotation; 1111 return detectedParams.Rotation;
@@ -1120,7 +1114,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1120 public LSL_Integer llDetectedGroup(int number) 1114 public LSL_Integer llDetectedGroup(int number)
1121 { 1115 {
1122 m_host.AddScriptLPS(1); 1116 m_host.AddScriptLPS(1);
1123 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1117 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1124 if (detectedParams == null) 1118 if (detectedParams == null)
1125 return new LSL_Integer(0); 1119 return new LSL_Integer(0);
1126 if (m_host.GroupID == detectedParams.Group) 1120 if (m_host.GroupID == detectedParams.Group)
@@ -1131,7 +1125,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1131 public LSL_Integer llDetectedLinkNumber(int number) 1125 public LSL_Integer llDetectedLinkNumber(int number)
1132 { 1126 {
1133 m_host.AddScriptLPS(1); 1127 m_host.AddScriptLPS(1);
1134 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 1128 DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1135 if (parms == null) 1129 if (parms == null)
1136 return new LSL_Integer(0); 1130 return new LSL_Integer(0);
1137 1131
@@ -1144,7 +1138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1144 public LSL_Vector llDetectedTouchBinormal(int index) 1138 public LSL_Vector llDetectedTouchBinormal(int index)
1145 { 1139 {
1146 m_host.AddScriptLPS(1); 1140 m_host.AddScriptLPS(1);
1147 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1141 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1148 if (detectedParams == null) 1142 if (detectedParams == null)
1149 return new LSL_Vector(); 1143 return new LSL_Vector();
1150 return detectedParams.TouchBinormal; 1144 return detectedParams.TouchBinormal;
@@ -1156,7 +1150,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1156 public LSL_Integer llDetectedTouchFace(int index) 1150 public LSL_Integer llDetectedTouchFace(int index)
1157 { 1151 {
1158 m_host.AddScriptLPS(1); 1152 m_host.AddScriptLPS(1);
1159 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1153 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1160 if (detectedParams == null) 1154 if (detectedParams == null)
1161 return new LSL_Integer(-1); 1155 return new LSL_Integer(-1);
1162 return new LSL_Integer(detectedParams.TouchFace); 1156 return new LSL_Integer(detectedParams.TouchFace);
@@ -1168,7 +1162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1168 public LSL_Vector llDetectedTouchNormal(int index) 1162 public LSL_Vector llDetectedTouchNormal(int index)
1169 { 1163 {
1170 m_host.AddScriptLPS(1); 1164 m_host.AddScriptLPS(1);
1171 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1165 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1172 if (detectedParams == null) 1166 if (detectedParams == null)
1173 return new LSL_Vector(); 1167 return new LSL_Vector();
1174 return detectedParams.TouchNormal; 1168 return detectedParams.TouchNormal;
@@ -1180,7 +1174,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1180 public LSL_Vector llDetectedTouchPos(int index) 1174 public LSL_Vector llDetectedTouchPos(int index)
1181 { 1175 {
1182 m_host.AddScriptLPS(1); 1176 m_host.AddScriptLPS(1);
1183 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1177 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1184 if (detectedParams == null) 1178 if (detectedParams == null)
1185 return new LSL_Vector(); 1179 return new LSL_Vector();
1186 return detectedParams.TouchPos; 1180 return detectedParams.TouchPos;
@@ -1192,7 +1186,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1192 public LSL_Vector llDetectedTouchST(int index) 1186 public LSL_Vector llDetectedTouchST(int index)
1193 { 1187 {
1194 m_host.AddScriptLPS(1); 1188 m_host.AddScriptLPS(1);
1195 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1189 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1196 if (detectedParams == null) 1190 if (detectedParams == null)
1197 return new LSL_Vector(-1.0, -1.0, 0.0); 1191 return new LSL_Vector(-1.0, -1.0, 0.0);
1198 return detectedParams.TouchST; 1192 return detectedParams.TouchST;
@@ -1204,7 +1198,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1204 public LSL_Vector llDetectedTouchUV(int index) 1198 public LSL_Vector llDetectedTouchUV(int index)
1205 { 1199 {
1206 m_host.AddScriptLPS(1); 1200 m_host.AddScriptLPS(1);
1207 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1201 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1208 if (detectedParams == null) 1202 if (detectedParams == null)
1209 return new LSL_Vector(-1.0, -1.0, 0.0); 1203 return new LSL_Vector(-1.0, -1.0, 0.0);
1210 return detectedParams.TouchUV; 1204 return detectedParams.TouchUV;
@@ -1910,6 +1904,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1910 rgb.y = texcolor.G; 1904 rgb.y = texcolor.G;
1911 rgb.z = texcolor.B; 1905 rgb.z = texcolor.B;
1912 return rgb; 1906 return rgb;
1907
1913 } 1908 }
1914 else 1909 else
1915 { 1910 {
@@ -2948,20 +2943,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2948 2943
2949 public LSL_Integer llGiveMoney(string destination, int amount) 2944 public LSL_Integer llGiveMoney(string destination, int amount)
2950 { 2945 {
2951 UUID invItemID=InventorySelf();
2952 if (invItemID == UUID.Zero)
2953 return 0;
2954
2955 m_host.AddScriptLPS(1); 2946 m_host.AddScriptLPS(1);
2956 2947
2957 m_host.TaskInventory.LockItemsForRead(true); 2948 if (m_item.PermsGranter == UUID.Zero)
2958 TaskInventoryItem item = m_host.TaskInventory[invItemID];
2959 m_host.TaskInventory.LockItemsForRead(false);
2960
2961 if (item.PermsGranter == UUID.Zero)
2962 return 0; 2949 return 0;
2963 2950
2964 if ((item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) 2951 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0)
2965 { 2952 {
2966 LSLError("No permissions to give money"); 2953 LSLError("No permissions to give money");
2967 return 0; 2954 return 0;
@@ -3148,11 +3135,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3148 sec = m_MinTimerInterval; 3135 sec = m_MinTimerInterval;
3149 m_host.AddScriptLPS(1); 3136 m_host.AddScriptLPS(1);
3150 // Setting timer repeat 3137 // Setting timer repeat
3151 AsyncCommands.TimerPlugin.SetTimerEvent(m_localID, m_itemID, sec); 3138 AsyncCommands.TimerPlugin.SetTimerEvent(m_host.LocalId, m_item.ItemID, sec);
3152 } 3139 }
3153 3140
3154 public virtual void llSleep(double sec) 3141 public virtual void llSleep(double sec)
3155 { 3142 {
3143// m_log.Info("llSleep snoozing " + sec + "s.");
3156 m_host.AddScriptLPS(1); 3144 m_host.AddScriptLPS(1);
3157 Thread.Sleep((int)(sec * 1000)); 3145 Thread.Sleep((int)(sec * 1000));
3158 } 3146 }
@@ -3211,29 +3199,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3211 3199
3212 public void llTakeControls(int controls, int accept, int pass_on) 3200 public void llTakeControls(int controls, int accept, int pass_on)
3213 { 3201 {
3214 TaskInventoryItem item; 3202 if (m_item.PermsGranter != UUID.Zero)
3215
3216 m_host.TaskInventory.LockItemsForRead(true);
3217 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3218 {
3219 m_host.TaskInventory.LockItemsForRead(false);
3220 return;
3221 }
3222 else
3223 {
3224 item = m_host.TaskInventory[InventorySelf()];
3225 }
3226 m_host.TaskInventory.LockItemsForRead(false);
3227
3228 if (item.PermsGranter != UUID.Zero)
3229 { 3203 {
3230 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3204 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3231 3205
3232 if (presence != null) 3206 if (presence != null)
3233 { 3207 {
3234 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 3208 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
3235 { 3209 {
3236 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID); 3210 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_host.LocalId, m_item.ItemID);
3237 } 3211 }
3238 } 3212 }
3239 } 3213 }
@@ -3243,38 +3217,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3243 3217
3244 public void llReleaseControls() 3218 public void llReleaseControls()
3245 { 3219 {
3246 TaskInventoryItem item;
3247
3248 m_host.TaskInventory.LockItemsForRead(true);
3249 lock (m_host.TaskInventory)
3250 {
3251
3252 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3253 {
3254 m_host.TaskInventory.LockItemsForRead(false);
3255 return;
3256 }
3257 else
3258 {
3259 item = m_host.TaskInventory[InventorySelf()];
3260 }
3261 }
3262 m_host.TaskInventory.LockItemsForRead(false);
3263
3264 m_host.AddScriptLPS(1); 3220 m_host.AddScriptLPS(1);
3265 3221
3266 if (item.PermsGranter != UUID.Zero) 3222 if (m_item.PermsGranter != UUID.Zero)
3267 { 3223 {
3268 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3224 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3269 3225
3270 if (presence != null) 3226 if (presence != null)
3271 { 3227 {
3272 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 3228 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
3273 { 3229 {
3274 // Unregister controls from Presence 3230 // Unregister controls from Presence
3275 presence.UnRegisterControlEventsToScript(m_localID, m_itemID); 3231 presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID);
3276 // Remove Take Control permission. 3232 // Remove Take Control permission.
3277 item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; 3233 m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS;
3278 } 3234 }
3279 } 3235 }
3280 } 3236 }
@@ -3287,86 +3243,71 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3287 m_UrlModule.ReleaseURL(url); 3243 m_UrlModule.ReleaseURL(url);
3288 } 3244 }
3289 3245
3290 public void llAttachToAvatar(int attachment) 3246 /// <summary>
3247 /// Attach the object containing this script to the avatar that owns it.
3248 /// </summary>
3249 /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param>
3250 /// <returns>true if the attach suceeded, false if it did not</returns>
3251 public bool AttachToAvatar(int attachmentPoint)
3291 { 3252 {
3292 m_host.AddScriptLPS(1); 3253 SceneObjectGroup grp = m_host.ParentGroup;
3293 3254 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3294 TaskInventoryItem item;
3295 3255
3296 m_host.TaskInventory.LockItemsForRead(true); 3256 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3297 3257
3298 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3258 if (attachmentsModule != null)
3299 { 3259 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false);
3300 m_host.TaskInventory.LockItemsForRead(false);
3301 return;
3302 }
3303 else 3260 else
3304 { 3261 return false;
3305 item = m_host.TaskInventory[InventorySelf()]; 3262 }
3306 }
3307
3308 m_host.TaskInventory.LockItemsForRead(false);
3309 3263
3310 if (item.PermsGranter != m_host.OwnerID) 3264 /// <summary>
3311 return; 3265 /// Detach the object containing this script from the avatar it is attached to.
3266 /// </summary>
3267 /// <remarks>
3268 /// Nothing happens if the object is not attached.
3269 /// </remarks>
3270 public void DetachFromAvatar()
3271 {
3272 Util.FireAndForget(DetachWrapper, m_host);
3273 }
3312 3274
3313 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3275 private void DetachWrapper(object o)
3314 { 3276 {
3315 SceneObjectGroup grp = m_host.ParentGroup; 3277 SceneObjectPart host = (SceneObjectPart)o;
3316 3278
3317 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 3279 SceneObjectGroup grp = host.ParentGroup;
3280 UUID itemID = grp.FromItemID;
3281 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3318 3282
3319 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 3283 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3320 if (attachmentsModule != null) 3284 if (attachmentsModule != null)
3321 attachmentsModule.AttachObject(presence, grp, (uint)attachment, false); 3285 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3322 }
3323 } 3286 }
3324 3287
3325 public void llDetachFromAvatar() 3288 public void llAttachToAvatar(int attachmentPoint)
3326 { 3289 {
3327 m_host.AddScriptLPS(1); 3290 m_host.AddScriptLPS(1);
3328 3291
3329 if (m_host.ParentGroup.AttachmentPoint == 0) 3292 if (m_item.PermsGranter != m_host.OwnerID)
3330 return; 3293 return;
3331 3294
3332 TaskInventoryItem item; 3295 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3296 AttachToAvatar(attachmentPoint);
3297 }
3333 3298
3334 m_host.TaskInventory.LockItemsForRead(true); 3299 public void llDetachFromAvatar()
3300 {
3301 m_host.AddScriptLPS(1);
3335 3302
3336 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3303 if (m_host.ParentGroup.AttachmentPoint == 0)
3337 {
3338 m_host.TaskInventory.LockItemsForRead(false);
3339 return; 3304 return;
3340 }
3341 else
3342 {
3343 item = m_host.TaskInventory[InventorySelf()];
3344 }
3345 m_host.TaskInventory.LockItemsForRead(false);
3346 3305
3347 3306 if (m_item.PermsGranter != m_host.OwnerID)
3348 if (item.PermsGranter != m_host.OwnerID)
3349 return; 3307 return;
3350 3308
3351 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3309 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3352 { 3310 DetachFromAvatar();
3353 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3354 if (attachmentsModule != null)
3355 Util.FireAndForget(DetachWrapper, m_host);
3356 }
3357 }
3358
3359 private void DetachWrapper(object o)
3360 {
3361 SceneObjectPart host = (SceneObjectPart)o;
3362
3363 SceneObjectGroup grp = host.ParentGroup;
3364 UUID itemID = grp.FromItemID;
3365 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3366
3367 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3368 if (attachmentsModule != null)
3369 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3370 } 3311 }
3371 3312
3372 public void llTakeCamera(string avatar) 3313 public void llTakeCamera(string avatar)
@@ -3487,7 +3428,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3487 } 3428 }
3488 3429
3489 emailModule.SendEmail(m_host.UUID, address, subject, message); 3430 emailModule.SendEmail(m_host.UUID, address, subject, message);
3490 ScriptSleep(15000); 3431 ScriptSleep(EMAIL_PAUSE_TIME * 1000);
3491 } 3432 }
3492 3433
3493 public void llGetNextEmail(string address, string subject) 3434 public void llGetNextEmail(string address, string subject)
@@ -3524,6 +3465,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3524 return m_host.UUID.ToString(); 3465 return m_host.UUID.ToString();
3525 } 3466 }
3526 3467
3468 public LSL_Key llGenerateKey()
3469 {
3470 m_host.AddScriptLPS(1);
3471 return UUID.Random().ToString();
3472 }
3473
3527 public void llSetBuoyancy(double buoyancy) 3474 public void llSetBuoyancy(double buoyancy)
3528 { 3475 {
3529 m_host.AddScriptLPS(1); 3476 m_host.AddScriptLPS(1);
@@ -3570,7 +3517,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3570 m_host.AddScriptLPS(1); 3517 m_host.AddScriptLPS(1);
3571 try 3518 try
3572 { 3519 {
3573 m_ScriptEngine.SetMinEventDelay(m_itemID, delay); 3520 m_ScriptEngine.SetMinEventDelay(m_item.ItemID, delay);
3574 } 3521 }
3575 catch (NotImplementedException) 3522 catch (NotImplementedException)
3576 { 3523 {
@@ -3623,29 +3570,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3623 { 3570 {
3624 m_host.AddScriptLPS(1); 3571 m_host.AddScriptLPS(1);
3625 3572
3626 UUID invItemID = InventorySelf(); 3573 if (m_item.PermsGranter == UUID.Zero)
3627 if (invItemID == UUID.Zero)
3628 return; 3574 return;
3629 3575
3630 TaskInventoryItem item; 3576 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3631
3632 m_host.TaskInventory.LockItemsForRead(true);
3633 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3634 {
3635 m_host.TaskInventory.LockItemsForRead(false);
3636 return;
3637 }
3638 else
3639 { 3577 {
3640 item = m_host.TaskInventory[InventorySelf()]; 3578 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3641 }
3642 m_host.TaskInventory.LockItemsForRead(false);
3643 if (item.PermsGranter == UUID.Zero)
3644 return;
3645
3646 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3647 {
3648 ScenePresence presence = World.GetScenePresence(item.PermsGranter);
3649 3579
3650 if (presence != null) 3580 if (presence != null)
3651 { 3581 {
@@ -3663,38 +3593,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3663 { 3593 {
3664 m_host.AddScriptLPS(1); 3594 m_host.AddScriptLPS(1);
3665 3595
3666 UUID invItemID=InventorySelf(); 3596 if (m_item.PermsGranter == UUID.Zero)
3667 if (invItemID == UUID.Zero)
3668 return; 3597 return;
3669 3598
3670 TaskInventoryItem item; 3599 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3671
3672 m_host.TaskInventory.LockItemsForRead(true);
3673 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3674 {
3675 m_host.TaskInventory.LockItemsForRead(false);
3676 return;
3677 }
3678 else
3679 {
3680 item = m_host.TaskInventory[InventorySelf()];
3681 }
3682 m_host.TaskInventory.LockItemsForRead(false);
3683
3684
3685 if (item.PermsGranter == UUID.Zero)
3686 return;
3687
3688 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3689 { 3600 {
3690 UUID animID = new UUID(); 3601 UUID animID = new UUID();
3691 3602
3692 if (!UUID.TryParse(anim, out animID)) 3603 if (!UUID.TryParse(anim, out animID))
3693 { 3604 {
3694 animID=InventoryKey(anim); 3605 animID = InventoryKey(anim);
3695 } 3606 }
3696 3607
3697 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3608 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3698 3609
3699 if (presence != null) 3610 if (presence != null)
3700 { 3611 {
@@ -3730,44 +3641,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3730 public LSL_Integer llGetStartParameter() 3641 public LSL_Integer llGetStartParameter()
3731 { 3642 {
3732 m_host.AddScriptLPS(1); 3643 m_host.AddScriptLPS(1);
3733 return m_ScriptEngine.GetStartParameter(m_itemID); 3644 return m_ScriptEngine.GetStartParameter(m_item.ItemID);
3734 } 3645 }
3735 3646
3736 public void llRequestPermissions(string agent, int perm) 3647 public void llRequestPermissions(string agent, int perm)
3737 { 3648 {
3738 UUID agentID = new UUID(); 3649 UUID agentID;
3739 3650
3740 if (!UUID.TryParse(agent, out agentID)) 3651 if (!UUID.TryParse(agent, out agentID))
3741 return; 3652 return;
3742 3653
3743 UUID invItemID = InventorySelf();
3744
3745 if (invItemID == UUID.Zero)
3746 return; // Not in a prim? How??
3747
3748 TaskInventoryItem item;
3749
3750
3751 m_host.TaskInventory.LockItemsForRead(true);
3752 if (!m_host.TaskInventory.ContainsKey(invItemID))
3753 {
3754 m_host.TaskInventory.LockItemsForRead(false);
3755 return;
3756 }
3757 else
3758 {
3759 item = m_host.TaskInventory[invItemID];
3760 }
3761 m_host.TaskInventory.LockItemsForRead(false);
3762
3763 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3654 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3764 { 3655 {
3765 llReleaseControls(); 3656 llReleaseControls();
3766 3657
3767 item.PermsGranter = UUID.Zero; 3658 m_item.PermsGranter = UUID.Zero;
3768 item.PermsMask = 0; 3659 m_item.PermsMask = 0;
3769 3660
3770 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3661 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3771 "run_time_permissions", new Object[] { 3662 "run_time_permissions", new Object[] {
3772 new LSL_Integer(0) }, 3663 new LSL_Integer(0) },
3773 new DetectParams[0])); 3664 new DetectParams[0]));
@@ -3775,7 +3666,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3775 return; 3666 return;
3776 } 3667 }
3777 3668
3778 if (item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3669 if (m_item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3779 llReleaseControls(); 3670 llReleaseControls();
3780 3671
3781 m_host.AddScriptLPS(1); 3672 m_host.AddScriptLPS(1);
@@ -3792,11 +3683,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3792 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3683 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3793 { 3684 {
3794 m_host.TaskInventory.LockItemsForWrite(true); 3685 m_host.TaskInventory.LockItemsForWrite(true);
3795 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3686 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3796 m_host.TaskInventory[invItemID].PermsMask = perm; 3687 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3797 m_host.TaskInventory.LockItemsForWrite(false); 3688 m_host.TaskInventory.LockItemsForWrite(false);
3798 3689
3799 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3690 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3800 "run_time_permissions", new Object[] { 3691 "run_time_permissions", new Object[] {
3801 new LSL_Integer(perm) }, 3692 new LSL_Integer(perm) },
3802 new DetectParams[0])); 3693 new DetectParams[0]));
@@ -3831,11 +3722,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3831 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3722 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3832 { 3723 {
3833 m_host.TaskInventory.LockItemsForWrite(true); 3724 m_host.TaskInventory.LockItemsForWrite(true);
3834 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3725 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3835 m_host.TaskInventory[invItemID].PermsMask = perm; 3726 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3836 m_host.TaskInventory.LockItemsForWrite(false); 3727 m_host.TaskInventory.LockItemsForWrite(false);
3837 3728
3838 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3729 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3839 "run_time_permissions", new Object[] { 3730 "run_time_permissions", new Object[] {
3840 new LSL_Integer(perm) }, 3731 new LSL_Integer(perm) },
3841 new DetectParams[0])); 3732 new DetectParams[0]));
@@ -3856,8 +3747,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3856 if (!m_waitingForScriptAnswer) 3747 if (!m_waitingForScriptAnswer)
3857 { 3748 {
3858 m_host.TaskInventory.LockItemsForWrite(true); 3749 m_host.TaskInventory.LockItemsForWrite(true);
3859 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3750 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3860 m_host.TaskInventory[invItemID].PermsMask = 0; 3751 m_host.TaskInventory[m_item.ItemID].PermsMask = 0;
3861 m_host.TaskInventory.LockItemsForWrite(false); 3752 m_host.TaskInventory.LockItemsForWrite(false);
3862 3753
3863 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3754 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
@@ -3865,13 +3756,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3865 } 3756 }
3866 3757
3867 presence.ControllingClient.SendScriptQuestion( 3758 presence.ControllingClient.SendScriptQuestion(
3868 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); 3759 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_item.ItemID, perm);
3869 3760
3870 return; 3761 return;
3871 } 3762 }
3872 3763
3873 // Requested agent is not in range, refuse perms 3764 // Requested agent is not in range, refuse perms
3874 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3765 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3875 "run_time_permissions", new Object[] { 3766 "run_time_permissions", new Object[] {
3876 new LSL_Integer(0) }, 3767 new LSL_Integer(0) },
3877 new DetectParams[0])); 3768 new DetectParams[0]));
@@ -3882,24 +3773,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3882 if (taskID != m_host.UUID) 3773 if (taskID != m_host.UUID)
3883 return; 3774 return;
3884 3775
3885 UUID invItemID = InventorySelf(); 3776 client.OnScriptAnswer -= handleScriptAnswer;
3886 3777 m_waitingForScriptAnswer = false;
3887 if (invItemID == UUID.Zero)
3888 return;
3889
3890 client.OnScriptAnswer-=handleScriptAnswer;
3891 m_waitingForScriptAnswer=false;
3892 3778
3893 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3779 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3894 llReleaseControls(); 3780 llReleaseControls();
3895 3781
3896
3897 m_host.TaskInventory.LockItemsForWrite(true); 3782 m_host.TaskInventory.LockItemsForWrite(true);
3898 m_host.TaskInventory[invItemID].PermsMask = answer; 3783 m_host.TaskInventory[m_item.ItemID].PermsMask = answer;
3899 m_host.TaskInventory.LockItemsForWrite(false); 3784 m_host.TaskInventory.LockItemsForWrite(false);
3900 3785
3901 3786 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3902 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3903 "run_time_permissions", new Object[] { 3787 "run_time_permissions", new Object[] {
3904 new LSL_Integer(answer) }, 3788 new LSL_Integer(answer) },
3905 new DetectParams[0])); 3789 new DetectParams[0]));
@@ -3909,41 +3793,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3909 { 3793 {
3910 m_host.AddScriptLPS(1); 3794 m_host.AddScriptLPS(1);
3911 3795
3912 m_host.TaskInventory.LockItemsForRead(true); 3796 return m_item.PermsGranter.ToString();
3913
3914 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3915 {
3916 if (item.Type == 10 && item.ItemID == m_itemID)
3917 {
3918 m_host.TaskInventory.LockItemsForRead(false);
3919 return item.PermsGranter.ToString();
3920 }
3921 }
3922 m_host.TaskInventory.LockItemsForRead(false);
3923
3924 return UUID.Zero.ToString();
3925 } 3797 }
3926 3798
3927 public LSL_Integer llGetPermissions() 3799 public LSL_Integer llGetPermissions()
3928 { 3800 {
3929 m_host.AddScriptLPS(1); 3801 m_host.AddScriptLPS(1);
3930 3802
3931 m_host.TaskInventory.LockItemsForRead(true); 3803 int perms = m_item.PermsMask;
3932 3804
3933 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3805 if (m_automaticLinkPermission)
3934 { 3806 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3935 if (item.Type == 10 && item.ItemID == m_itemID)
3936 {
3937 int perms = item.PermsMask;
3938 if (m_automaticLinkPermission)
3939 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3940 m_host.TaskInventory.LockItemsForRead(false);
3941 return perms;
3942 }
3943 }
3944 m_host.TaskInventory.LockItemsForRead(false);
3945 3807
3946 return 0; 3808 return perms;
3947 } 3809 }
3948 3810
3949 public LSL_Integer llGetLinkNumber() 3811 public LSL_Integer llGetLinkNumber()
@@ -3981,18 +3843,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3981 public void llCreateLink(string target, int parent) 3843 public void llCreateLink(string target, int parent)
3982 { 3844 {
3983 m_host.AddScriptLPS(1); 3845 m_host.AddScriptLPS(1);
3984 UUID invItemID = InventorySelf(); 3846
3985 UUID targetID; 3847 UUID targetID;
3986 3848
3987 if (!UUID.TryParse(target, out targetID)) 3849 if (!UUID.TryParse(target, out targetID))
3988 return; 3850 return;
3989 3851
3990 TaskInventoryItem item; 3852 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3991 m_host.TaskInventory.LockItemsForRead(true);
3992 item = m_host.TaskInventory[invItemID];
3993 m_host.TaskInventory.LockItemsForRead(false);
3994
3995 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3996 && !m_automaticLinkPermission) 3853 && !m_automaticLinkPermission)
3997 { 3854 {
3998 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3855 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
@@ -4000,7 +3857,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4000 } 3857 }
4001 3858
4002 IClientAPI client = null; 3859 IClientAPI client = null;
4003 ScenePresence sp = World.GetScenePresence(item.PermsGranter); 3860 ScenePresence sp = World.GetScenePresence(m_item.PermsGranter);
4004 if (sp != null) 3861 if (sp != null)
4005 client = sp.ControllingClient; 3862 client = sp.ControllingClient;
4006 3863
@@ -4046,18 +3903,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4046 public void llBreakLink(int linknum) 3903 public void llBreakLink(int linknum)
4047 { 3904 {
4048 m_host.AddScriptLPS(1); 3905 m_host.AddScriptLPS(1);
4049 UUID invItemID = InventorySelf();
4050 3906
4051 m_host.TaskInventory.LockItemsForRead(true); 3907 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4052 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3908 && !m_automaticLinkPermission)
4053 && !m_automaticLinkPermission) 3909 {
4054 { 3910 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
4055 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3911 return;
4056 m_host.TaskInventory.LockItemsForRead(false); 3912 }
4057 return; 3913
4058 }
4059 m_host.TaskInventory.LockItemsForRead(false);
4060
4061 if (linknum < ScriptBaseClass.LINK_THIS) 3914 if (linknum < ScriptBaseClass.LINK_THIS)
4062 return; 3915 return;
4063 3916
@@ -4156,12 +4009,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4156 { 4009 {
4157 m_host.AddScriptLPS(1); 4010 m_host.AddScriptLPS(1);
4158 4011
4159 UUID invItemID = InventorySelf(); 4012 TaskInventoryItem item = m_item;
4160
4161 TaskInventoryItem item;
4162 m_host.TaskInventory.LockItemsForRead(true);
4163 item = m_host.TaskInventory[invItemID];
4164 m_host.TaskInventory.LockItemsForRead(false);
4165 4013
4166 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 4014 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4167 && !m_automaticLinkPermission) 4015 && !m_automaticLinkPermission)
@@ -4472,7 +4320,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4472 { 4320 {
4473 if (item.Name == name) 4321 if (item.Name == name)
4474 { 4322 {
4475 if (item.ItemID == m_itemID) 4323 if (item.ItemID == m_item.ItemID)
4476 throw new ScriptDeleteException(); 4324 throw new ScriptDeleteException();
4477 else 4325 else
4478 m_host.Inventory.RemoveInventoryItem(item.ItemID); 4326 m_host.Inventory.RemoveInventoryItem(item.ItemID);
@@ -4606,8 +4454,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4606 UUID rq = UUID.Random(); 4454 UUID rq = UUID.Random();
4607 4455
4608 UUID tid = AsyncCommands. 4456 UUID tid = AsyncCommands.
4609 DataserverPlugin.RegisterRequest(m_localID, 4457 DataserverPlugin.RegisterRequest(m_host.LocalId,
4610 m_itemID, rq.ToString()); 4458 m_item.ItemID, rq.ToString());
4611 4459
4612 AsyncCommands. 4460 AsyncCommands.
4613 DataserverPlugin.DataserverReply(rq.ToString(), reply); 4461 DataserverPlugin.DataserverReply(rq.ToString(), reply);
@@ -4634,8 +4482,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4634 if (item.Type == 3 && item.Name == name) 4482 if (item.Type == 3 && item.Name == name)
4635 { 4483 {
4636 UUID tid = AsyncCommands. 4484 UUID tid = AsyncCommands.
4637 DataserverPlugin.RegisterRequest(m_localID, 4485 DataserverPlugin.RegisterRequest(m_host.LocalId,
4638 m_itemID, item.AssetID.ToString()); 4486 m_item.ItemID, item.AssetID.ToString());
4639 4487
4640 Vector3 region = new Vector3( 4488 Vector3 region = new Vector3(
4641 World.RegionInfo.RegionLocX * Constants.RegionSize, 4489 World.RegionInfo.RegionLocX * Constants.RegionSize,
@@ -5034,22 +4882,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5034 4882
5035 public LSL_String llGetScriptName() 4883 public LSL_String llGetScriptName()
5036 { 4884 {
5037 string result = String.Empty;
5038
5039 m_host.AddScriptLPS(1); 4885 m_host.AddScriptLPS(1);
5040 4886
5041 m_host.TaskInventory.LockItemsForRead(true); 4887 return m_item.Name != null ? m_item.Name : String.Empty;
5042 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
5043 {
5044 if (item.Type == 10 && item.ItemID == m_itemID)
5045 {
5046 result = item.Name!=null?item.Name:String.Empty;
5047 break;
5048 }
5049 }
5050 m_host.TaskInventory.LockItemsForRead(false);
5051
5052 return result;
5053 } 4888 }
5054 4889
5055 public LSL_Integer llGetLinkNumberOfSides(int link) 4890 public LSL_Integer llGetLinkNumberOfSides(int link)
@@ -6334,7 +6169,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6334 if (m_host.OwnerID == land.LandData.OwnerID) 6169 if (m_host.OwnerID == land.LandData.OwnerID)
6335 { 6170 {
6336 Vector3 pos = World.GetNearestAllowedPosition(presence, land); 6171 Vector3 pos = World.GetNearestAllowedPosition(presence, land);
6337 presence.TeleportWithMomentum(pos); 6172 presence.TeleportWithMomentum(pos, null);
6338 presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); 6173 presence.ControllingClient.SendAlertMessage("You have been ejected from this land");
6339 } 6174 }
6340 } 6175 }
@@ -7281,14 +7116,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7281 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 7116 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
7282 if (xmlrpcMod.IsEnabled()) 7117 if (xmlrpcMod.IsEnabled())
7283 { 7118 {
7284 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, UUID.Zero); 7119 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_host.LocalId, m_item.ItemID, UUID.Zero);
7285 IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>(); 7120 IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>();
7286 if (xmlRpcRouter != null) 7121 if (xmlRpcRouter != null)
7287 { 7122 {
7288 string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName; 7123 string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName;
7289 7124
7290 xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID, 7125 xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID,
7291 m_itemID, String.Format("http://{0}:{1}/", ExternalHostName, 7126 m_item.ItemID, String.Format("http://{0}:{1}/", ExternalHostName,
7292 xmlrpcMod.Port.ToString())); 7127 xmlrpcMod.Port.ToString()));
7293 } 7128 }
7294 object[] resobj = new object[] 7129 object[] resobj = new object[]
@@ -7300,7 +7135,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7300 new LSL_Integer(0), 7135 new LSL_Integer(0),
7301 new LSL_String(String.Empty) 7136 new LSL_String(String.Empty)
7302 }; 7137 };
7303 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams("remote_data", resobj, 7138 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams("remote_data", resobj,
7304 new DetectParams[0])); 7139 new DetectParams[0]));
7305 } 7140 }
7306 ScriptSleep(1000); 7141 ScriptSleep(1000);
@@ -7311,7 +7146,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7311 m_host.AddScriptLPS(1); 7146 m_host.AddScriptLPS(1);
7312 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 7147 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
7313 ScriptSleep(3000); 7148 ScriptSleep(3000);
7314 return (xmlrpcMod.SendRemoteData(m_localID, m_itemID, channel, dest, idata, sdata)).ToString(); 7149 return (xmlrpcMod.SendRemoteData(m_host.LocalId, m_item.ItemID, channel, dest, idata, sdata)).ToString();
7315 } 7150 }
7316 7151
7317 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) 7152 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata)
@@ -8150,7 +7985,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8150 return; 7985 return;
8151 face = (int)rules.GetLSLIntegerItem(idx++); 7986 face = (int)rules.GetLSLIntegerItem(idx++);
8152 int shiny = (int)rules.GetLSLIntegerItem(idx++); 7987 int shiny = (int)rules.GetLSLIntegerItem(idx++);
8153 Bumpiness bump = (Bumpiness)Convert.ToByte((int)rules.GetLSLIntegerItem(idx++)); 7988 Bumpiness bump = (Bumpiness)(int)rules.GetLSLIntegerItem(idx++);
8154 7989
8155 SetShiny(part, face, shiny, bump); 7990 SetShiny(part, face, shiny, bump);
8156 7991
@@ -9954,13 +9789,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9954 { 9789 {
9955 m_host.AddScriptLPS(1); 9790 m_host.AddScriptLPS(1);
9956 if (m_UrlModule != null) 9791 if (m_UrlModule != null)
9957 return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); 9792 return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString();
9958 return UUID.Zero.ToString(); 9793 return UUID.Zero.ToString();
9959 } 9794 }
9960 9795
9961 public LSL_String llRequestSimulatorData(string simulator, int data) 9796 public LSL_String llRequestSimulatorData(string simulator, int data)
9962 { 9797 {
9963 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_itemID, "OSSL"); 9798 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL");
9964 9799
9965 try 9800 try
9966 { 9801 {
@@ -10022,7 +9857,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10022 UUID rq = UUID.Random(); 9857 UUID rq = UUID.Random();
10023 9858
10024 UUID tid = AsyncCommands. 9859 UUID tid = AsyncCommands.
10025 DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 9860 DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
10026 9861
10027 AsyncCommands. 9862 AsyncCommands.
10028 DataserverPlugin.DataserverReply(rq.ToString(), reply); 9863 DataserverPlugin.DataserverReply(rq.ToString(), reply);
@@ -10041,7 +9876,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10041 m_host.AddScriptLPS(1); 9876 m_host.AddScriptLPS(1);
10042 9877
10043 if (m_UrlModule != null) 9878 if (m_UrlModule != null)
10044 return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); 9879 return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString();
10045 return UUID.Zero.ToString(); 9880 return UUID.Zero.ToString();
10046 } 9881 }
10047 9882
@@ -10077,7 +9912,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10077 // child agents have a mass of 1.0 9912 // child agents have a mass of 1.0
10078 return 1; 9913 return 1;
10079 else 9914 else
10080 return avatar.GetMass(); 9915 return (double)avatar.GetMass();
10081 } 9916 }
10082 catch (KeyNotFoundException) 9917 catch (KeyNotFoundException)
10083 { 9918 {
@@ -10520,22 +10355,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10520 public LSL_Vector llGetCameraPos() 10355 public LSL_Vector llGetCameraPos()
10521 { 10356 {
10522 m_host.AddScriptLPS(1); 10357 m_host.AddScriptLPS(1);
10523 UUID invItemID = InventorySelf();
10524
10525 if (invItemID == UUID.Zero)
10526 return new LSL_Vector();
10527 10358
10528 m_host.TaskInventory.LockItemsForRead(true); 10359 if (m_item.PermsGranter == UUID.Zero)
10529 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 10360 return new LSL_Vector();
10530 {
10531 m_host.TaskInventory.LockItemsForRead(false);
10532 return new LSL_Vector();
10533 }
10534 10361
10535 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 10362 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
10536 { 10363 {
10537 ShoutError("No permissions to track the camera"); 10364 ShoutError("No permissions to track the camera");
10538 m_host.TaskInventory.LockItemsForRead(false);
10539 return new LSL_Vector(); 10365 return new LSL_Vector();
10540 } 10366 }
10541 m_host.TaskInventory.LockItemsForRead(false); 10367 m_host.TaskInventory.LockItemsForRead(false);
@@ -10552,20 +10378,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10552 public LSL_Rotation llGetCameraRot() 10378 public LSL_Rotation llGetCameraRot()
10553 { 10379 {
10554 m_host.AddScriptLPS(1); 10380 m_host.AddScriptLPS(1);
10555 UUID invItemID = InventorySelf();
10556 if (invItemID == UUID.Zero)
10557 return new LSL_Rotation();
10558 10381
10559 m_host.TaskInventory.LockItemsForRead(true); 10382 if (m_item.PermsGranter == UUID.Zero)
10560 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 10383 return new LSL_Rotation();
10561 { 10384
10562 m_host.TaskInventory.LockItemsForRead(false); 10385 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
10563 return new LSL_Rotation();
10564 }
10565 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
10566 { 10386 {
10567 ShoutError("No permissions to track the camera"); 10387 ShoutError("No permissions to track the camera");
10568 m_host.TaskInventory.LockItemsForRead(false);
10569 return new LSL_Rotation(); 10388 return new LSL_Rotation();
10570 } 10389 }
10571 m_host.TaskInventory.LockItemsForRead(false); 10390 m_host.TaskInventory.LockItemsForRead(false);
@@ -10629,7 +10448,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10629 public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt) 10448 public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt)
10630 { 10449 {
10631 m_host.AddScriptLPS(1); 10450 m_host.AddScriptLPS(1);
10632 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); 10451 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0);
10633 if (detectedParams == null) 10452 if (detectedParams == null)
10634 { 10453 {
10635 if (m_host.ParentGroup.IsAttachment == true) 10454 if (m_host.ParentGroup.IsAttachment == true)
@@ -10753,30 +10572,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10753 { 10572 {
10754 m_host.AddScriptLPS(1); 10573 m_host.AddScriptLPS(1);
10755 10574
10756 // our key in the object we are in
10757 UUID invItemID = InventorySelf();
10758 if (invItemID == UUID.Zero) return;
10759
10760 // the object we are in 10575 // the object we are in
10761 UUID objectID = m_host.ParentUUID; 10576 UUID objectID = m_host.ParentUUID;
10762 if (objectID == UUID.Zero) return; 10577 if (objectID == UUID.Zero)
10578 return;
10763 10579
10764 UUID agentID;
10765 m_host.TaskInventory.LockItemsForRead(true);
10766 // we need the permission first, to know which avatar we want to set the camera for 10580 // we need the permission first, to know which avatar we want to set the camera for
10767 agentID = m_host.TaskInventory[invItemID].PermsGranter; 10581 UUID agentID = m_item.PermsGranter;
10768 10582
10769 if (agentID == UUID.Zero) 10583 if (agentID == UUID.Zero)
10770 {
10771 m_host.TaskInventory.LockItemsForRead(false);
10772 return; 10584 return;
10773 } 10585
10774 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) 10586 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
10775 {
10776 m_host.TaskInventory.LockItemsForRead(false);
10777 return; 10587 return;
10778 }
10779 m_host.TaskInventory.LockItemsForRead(false);
10780 10588
10781 ScenePresence presence = World.GetScenePresence(agentID); 10589 ScenePresence presence = World.GetScenePresence(agentID);
10782 10590
@@ -10818,34 +10626,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10818 { 10626 {
10819 m_host.AddScriptLPS(1); 10627 m_host.AddScriptLPS(1);
10820 10628
10821 // our key in the object we are in
10822 UUID invItemID=InventorySelf();
10823 if (invItemID == UUID.Zero) return;
10824
10825 // the object we are in 10629 // the object we are in
10826 UUID objectID = m_host.ParentUUID; 10630 UUID objectID = m_host.ParentUUID;
10827 if (objectID == UUID.Zero) return; 10631 if (objectID == UUID.Zero)
10632 return;
10828 10633
10829 // we need the permission first, to know which avatar we want to clear the camera for 10634 // we need the permission first, to know which avatar we want to clear the camera for
10830 UUID agentID; 10635 UUID agentID = m_item.PermsGranter;
10831 m_host.TaskInventory.LockItemsForRead(true); 10636
10832 agentID = m_host.TaskInventory[invItemID].PermsGranter;
10833 if (agentID == UUID.Zero) 10637 if (agentID == UUID.Zero)
10834 {
10835 m_host.TaskInventory.LockItemsForRead(false);
10836 return; 10638 return;
10837 } 10639
10838 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) 10640 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
10839 {
10840 m_host.TaskInventory.LockItemsForRead(false);
10841 return; 10641 return;
10842 }
10843 m_host.TaskInventory.LockItemsForRead(false);
10844 10642
10845 ScenePresence presence = World.GetScenePresence(agentID); 10643 ScenePresence presence = World.GetScenePresence(agentID);
10846 10644
10847 // we are not interested in child-agents 10645 // we are not interested in child-agents
10848 if (presence.IsChildAgent) return; 10646 if (presence.IsChildAgent)
10647 return;
10849 10648
10850 presence.ControllingClient.SendClearFollowCamProperties(objectID); 10649 presence.ControllingClient.SendClearFollowCamProperties(objectID);
10851 } 10650 }
@@ -11036,8 +10835,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11036 } 10835 }
11037 } 10836 }
11038 10837
11039 UUID reqID = httpScriptMod. 10838 UUID reqID
11040 StartHttpRequest(m_localID, m_itemID, url, param, httpHeaders, body); 10839 = httpScriptMod.StartHttpRequest(m_host.LocalId, m_item.ItemID, url, param, httpHeaders, body);
11041 10840
11042 if (reqID != UUID.Zero) 10841 if (reqID != UUID.Zero)
11043 return reqID.ToString(); 10842 return reqID.ToString();
@@ -11269,19 +11068,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11269 break; 11068 break;
11270 // For the following 8 see the Object version below 11069 // For the following 8 see the Object version below
11271 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: 11070 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT:
11272 ret.Add(new LSL_Integer(0)); 11071 ret.Add(new LSL_Integer(av.RunningScriptCount()));
11273 break; 11072 break;
11274 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: 11073 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT:
11275 ret.Add(new LSL_Integer(0)); 11074 ret.Add(new LSL_Integer(av.ScriptCount()));
11276 break; 11075 break;
11277 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: 11076 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY:
11278 ret.Add(new LSL_Integer(0)); 11077 ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384));
11279 break; 11078 break;
11280 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 11079 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
11281 ret.Add(new LSL_Float(0)); 11080 ret.Add(new LSL_Float(av.ScriptExecutionTime() / 1000.0f));
11282 break; 11081 break;
11283 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 11082 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
11284 ret.Add(new LSL_Integer(0)); 11083 ret.Add(new LSL_Integer(1));
11285 break; 11084 break;
11286 case ScriptBaseClass.OBJECT_SERVER_COST: 11085 case ScriptBaseClass.OBJECT_SERVER_COST:
11287 ret.Add(new LSL_Float(0)); 11086 ret.Add(new LSL_Float(0));
@@ -11333,43 +11132,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11333 case ScriptBaseClass.OBJECT_CREATOR: 11132 case ScriptBaseClass.OBJECT_CREATOR:
11334 ret.Add(new LSL_String(obj.CreatorID.ToString())); 11133 ret.Add(new LSL_String(obj.CreatorID.ToString()));
11335 break; 11134 break;
11336 // The following 8 I have intentionaly coded to return zero. They are part of
11337 // "Land Impact" calculations. These calculations are probably not applicable
11338 // to OpenSim, required figures (cpu/memory usage) are not currently tracked
11339 // I have intentionally left these all at zero rather than return possibly
11340 // missleading numbers
11341 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: 11135 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT:
11342 // in SL this currently includes crashed scripts 11136 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount()));
11343 ret.Add(new LSL_Integer(0));
11344 break; 11137 break;
11345 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: 11138 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT:
11346 ret.Add(new LSL_Integer(0)); 11139 ret.Add(new LSL_Integer(obj.ParentGroup.ScriptCount()));
11347 break; 11140 break;
11348 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: 11141 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY:
11349 // The value returned in SL for mono scripts is 65536 * number of active scripts 11142 // The value returned in SL for mono scripts is 65536 * number of active scripts
11350 ret.Add(new LSL_Integer(0)); 11143 // and 16384 * number of active scripts for LSO. since llGetFreememory
11144 // is coded to give the LSO value use it here
11145 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384));
11351 break; 11146 break;
11352 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 11147 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
11353 // Average cpu time per simulator frame expended on all scripts in the objetc 11148 // Average cpu time in seconds per simulator frame expended on all scripts in the object
11354 ret.Add(new LSL_Float(0)); 11149 ret.Add(new LSL_Float(obj.ParentGroup.ScriptExecutionTime() / 1000.0f));
11355 break; 11150 break;
11356 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 11151 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
11357 // according to the SL wiki A prim or linkset will have prim 11152 // according to the SL wiki A prim or linkset will have prim
11358 // equivalent of the number of prims in a linkset if it does not 11153 // equivalent of the number of prims in a linkset if it does not
11359 // contain a mesh anywhere in the link set or is not a normal prim 11154 // contain a mesh anywhere in the link set or is not a normal prim
11360 // The value returned in SL for normal prims is prim count 11155 // The value returned in SL for normal prims is prim count
11361 ret.Add(new LSL_Integer(0)); 11156 ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount));
11362 break; 11157 break;
11158 // The following 3 costs I have intentionaly coded to return zero. They are part of
11159 // "Land Impact" calculations. These calculations are probably not applicable
11160 // to OpenSim and are not yet complete in SL
11363 case ScriptBaseClass.OBJECT_SERVER_COST: 11161 case ScriptBaseClass.OBJECT_SERVER_COST:
11364 // The value returned in SL for normal prims is prim count 11162 // The linden calculation is here
11163 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight
11164 // The value returned in SL for normal prims looks like the prim count
11365 ret.Add(new LSL_Float(0)); 11165 ret.Add(new LSL_Float(0));
11366 break; 11166 break;
11367 case ScriptBaseClass.OBJECT_STREAMING_COST: 11167 case ScriptBaseClass.OBJECT_STREAMING_COST:
11368 // The value returned in SL for normal prims is prim count * 0.06 11168 // The linden calculation is here
11169 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost
11170 // The value returned in SL for normal prims looks like the prim count * 0.06
11369 ret.Add(new LSL_Float(0)); 11171 ret.Add(new LSL_Float(0));
11370 break; 11172 break;
11371 case ScriptBaseClass.OBJECT_PHYSICS_COST: 11173 case ScriptBaseClass.OBJECT_PHYSICS_COST:
11372 // The value returned in SL for normal prims is prim count 11174 // The linden calculation is here
11175 // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics
11176 // The value returned in SL for normal prims looks like the prim count
11373 ret.Add(new LSL_Float(0)); 11177 ret.Add(new LSL_Float(0));
11374 break; 11178 break;
11375 default: 11179 default:
@@ -11467,7 +11271,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11467 } 11271 }
11468 11272
11469 // was: UUID tid = tid = AsyncCommands. 11273 // was: UUID tid = tid = AsyncCommands.
11470 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); 11274 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString());
11471 11275
11472 if (NotecardCache.IsCached(assetID)) 11276 if (NotecardCache.IsCached(assetID))
11473 { 11277 {
@@ -11530,7 +11334,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11530 } 11334 }
11531 11335
11532 // was: UUID tid = tid = AsyncCommands. 11336 // was: UUID tid = tid = AsyncCommands.
11533 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); 11337 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString());
11534 11338
11535 if (NotecardCache.IsCached(assetID)) 11339 if (NotecardCache.IsCached(assetID))
11536 { 11340 {
@@ -11614,7 +11418,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11614 { 11418 {
11615 UUID rq = UUID.Random(); 11419 UUID rq = UUID.Random();
11616 11420
11617 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 11421 AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
11618 11422
11619 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); 11423 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id)));
11620 11424
@@ -11630,7 +11434,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11630 { 11434 {
11631 UUID rq = UUID.Random(); 11435 UUID rq = UUID.Random();
11632 11436
11633 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 11437 AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
11634 11438
11635 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); 11439 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id));
11636 11440
@@ -12124,7 +11928,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12124 bool isAccount = false; 11928 bool isAccount = false;
12125 bool isGroup = false; 11929 bool isGroup = false;
12126 11930
12127 if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManager(m_host.OwnerID)) 11931 if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID))
12128 return 0; 11932 return 0;
12129 11933
12130 UUID id = new UUID(); 11934 UUID id = new UUID();
@@ -12186,35 +11990,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12186 return 1; 11990 return 1;
12187 } 11991 }
12188 11992
12189 #region Not Implemented 11993 public LSL_Integer llGetMemoryLimit()
12190 // 11994 {
12191 // Listing the unimplemented lsl functions here, please move 11995 m_host.AddScriptLPS(1);
12192 // them from this region as they are completed 11996 // The value returned for LSO scripts in SL
12193 // 11997 return 16384;
11998 }
12194 11999
12195 public void llGetEnv(LSL_String name) 12000 public LSL_Integer llSetMemoryLimit(LSL_Integer limit)
12196 { 12001 {
12197 m_host.AddScriptLPS(1); 12002 m_host.AddScriptLPS(1);
12198 NotImplemented("llGetEnv"); 12003 // Treat as an LSO script
12004 return ScriptBaseClass.FALSE;
12199 } 12005 }
12200 12006
12201 public void llGetSPMaxMemory() 12007 public LSL_Integer llGetSPMaxMemory()
12202 { 12008 {
12203 m_host.AddScriptLPS(1); 12009 m_host.AddScriptLPS(1);
12204 NotImplemented("llGetSPMaxMemory"); 12010 // The value returned for LSO scripts in SL
12011 return 16384;
12205 } 12012 }
12206 12013
12207 public virtual LSL_Integer llGetUsedMemory() 12014 public virtual LSL_Integer llGetUsedMemory()
12208 { 12015 {
12209 m_host.AddScriptLPS(1); 12016 m_host.AddScriptLPS(1);
12210 NotImplemented("llGetUsedMemory"); 12017 // The value returned for LSO scripts in SL
12211 return 0; 12018 return 16384;
12212 } 12019 }
12213 12020
12214 public void llScriptProfiler(LSL_Integer flags) 12021 public void llScriptProfiler(LSL_Integer flags)
12215 { 12022 {
12216 m_host.AddScriptLPS(1); 12023 m_host.AddScriptLPS(1);
12217 //NotImplemented("llScriptProfiler"); 12024 // This does nothing for LSO scripts in SL
12025 }
12026
12027 #region Not Implemented
12028 //
12029 // Listing the unimplemented lsl functions here, please move
12030 // them from this region as they are completed
12031 //
12032
12033 public void llGetEnv(LSL_String name)
12034 {
12035 m_host.AddScriptLPS(1);
12036 NotImplemented("llGetEnv");
12218 } 12037 }
12219 12038
12220 public void llSetSoundQueueing(int queue) 12039 public void llSetSoundQueueing(int queue)
@@ -12294,8 +12113,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12294 12113
12295 try 12114 try
12296 { 12115 {
12297 UUID invItemID=InventorySelf(); 12116 TaskInventoryItem item = m_item;
12298 if (invItemID == UUID.Zero) 12117 if (item == null)
12299 { 12118 {
12300 replydata = "SERVICE_ERROR"; 12119 replydata = "SERVICE_ERROR";
12301 return; 12120 return;
@@ -12303,10 +12122,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12303 12122
12304 m_host.AddScriptLPS(1); 12123 m_host.AddScriptLPS(1);
12305 12124
12306 m_host.TaskInventory.LockItemsForRead(true);
12307 TaskInventoryItem item = m_host.TaskInventory[invItemID];
12308 m_host.TaskInventory.LockItemsForRead(false);
12309
12310 if (item.PermsGranter == UUID.Zero) 12125 if (item.PermsGranter == UUID.Zero)
12311 { 12126 {
12312 replydata = "MISSING_PERMISSION_DEBIT"; 12127 replydata = "MISSING_PERMISSION_DEBIT";
@@ -12348,7 +12163,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12348 } 12163 }
12349 finally 12164 finally
12350 { 12165 {
12351 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 12166 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
12352 "transaction_result", new Object[] { 12167 "transaction_result", new Object[] {
12353 new LSL_String(txn.ToString()), 12168 new LSL_String(txn.ToString()),
12354 new LSL_Integer(replycode), 12169 new LSL_Integer(replycode),
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index 77a784d..795de80 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -58,17 +58,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
58 { 58 {
59 internal IScriptEngine m_ScriptEngine; 59 internal IScriptEngine m_ScriptEngine;
60 internal SceneObjectPart m_host; 60 internal SceneObjectPart m_host;
61 internal uint m_localID;
62 internal UUID m_itemID;
63 internal bool m_LSFunctionsEnabled = false; 61 internal bool m_LSFunctionsEnabled = false;
64 internal IScriptModuleComms m_comms = null; 62 internal IScriptModuleComms m_comms = null;
65 63
66 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 64 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
67 { 65 {
68 m_ScriptEngine = ScriptEngine; 66 m_ScriptEngine = ScriptEngine;
69 m_host = host; 67 m_host = host;
70 m_localID = localID;
71 m_itemID = itemID;
72 68
73 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) 69 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false))
74 m_LSFunctionsEnabled = true; 70 m_LSFunctionsEnabled = true;
@@ -449,7 +445,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
449 LSShoutError("LightShare functions are not enabled."); 445 LSShoutError("LightShare functions are not enabled.");
450 return 0; 446 return 0;
451 } 447 }
452 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 448 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
453 { 449 {
454 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); 450 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
455 return 0; 451 return 0;
@@ -477,7 +473,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
477 LSShoutError("LightShare functions are not enabled."); 473 LSShoutError("LightShare functions are not enabled.");
478 return; 474 return;
479 } 475 }
480 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 476 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
481 { 477 {
482 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); 478 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
483 return; 479 return;
@@ -500,7 +496,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
500 LSShoutError("LightShare functions are not enabled."); 496 LSShoutError("LightShare functions are not enabled.");
501 return 0; 497 return 0;
502 } 498 }
503 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 499 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
504 { 500 {
505 LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); 501 LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
506 return 0; 502 return 0;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 7c07e15..4bd3dff 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -57,17 +57,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
57 { 57 {
58 internal IScriptEngine m_ScriptEngine; 58 internal IScriptEngine m_ScriptEngine;
59 internal SceneObjectPart m_host; 59 internal SceneObjectPart m_host;
60 internal uint m_localID; 60 internal TaskInventoryItem m_item;
61 internal UUID m_itemID;
62 internal bool m_MODFunctionsEnabled = false; 61 internal bool m_MODFunctionsEnabled = false;
63 internal IScriptModuleComms m_comms = null; 62 internal IScriptModuleComms m_comms = null;
64 63
65 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 64 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
66 { 65 {
67 m_ScriptEngine = ScriptEngine; 66 m_ScriptEngine = ScriptEngine;
68 m_host = host; 67 m_host = host;
69 m_localID = localID; 68 m_item = item;
70 m_itemID = itemID;
71 69
72 if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) 70 if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false))
73 m_MODFunctionsEnabled = true; 71 m_MODFunctionsEnabled = true;
@@ -252,7 +250,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
252 // non-null but don't trust it completely 250 // non-null but don't trust it completely
253 try 251 try
254 { 252 {
255 object result = m_comms.InvokeOperation(m_host.UUID, m_itemID, fname, convertedParms); 253 object result = m_comms.InvokeOperation(m_host.UUID, m_item.ItemID, fname, convertedParms);
256 if (result != null) 254 if (result != null)
257 return result; 255 return result;
258 256
@@ -279,7 +277,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
279 277
280 UUID req = UUID.Random(); 278 UUID req = UUID.Random();
281 279
282 m_comms.RaiseEvent(m_itemID, req.ToString(), module, command, k); 280 m_comms.RaiseEvent(m_item.ItemID, req.ToString(), module, command, k);
283 281
284 return req.ToString(); 282 return req.ToString();
285 } 283 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 0dc2aa2..51ace1a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -128,11 +128,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
128 { 128 {
129// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 129// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
130 130
131 public const string GridInfoServiceConfigSectionName = "GridInfoService";
132
131 internal IScriptEngine m_ScriptEngine; 133 internal IScriptEngine m_ScriptEngine;
132 internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there 134 internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there
133 internal SceneObjectPart m_host; 135 internal SceneObjectPart m_host;
134 internal uint m_localID; 136 internal TaskInventoryItem m_item;
135 internal UUID m_itemID;
136 internal bool m_OSFunctionsEnabled = false; 137 internal bool m_OSFunctionsEnabled = false;
137 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; 138 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
138 internal float m_ScriptDelayFactor = 1.0f; 139 internal float m_ScriptDelayFactor = 1.0f;
@@ -140,12 +141,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
140 internal bool m_debuggerSafe = false; 141 internal bool m_debuggerSafe = false;
141 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); 142 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
142 143
143 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 144 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
144 { 145 {
145 m_ScriptEngine = ScriptEngine; 146 m_ScriptEngine = ScriptEngine;
146 m_host = host; 147 m_host = host;
147 m_localID = localID; 148 m_item = item;
148 m_itemID = itemID;
149 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); 149 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
150 150
151 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 151 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
@@ -218,12 +218,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
218 } 218 }
219 } 219 }
220 220
221 /// <summary>
222 /// Initialize the LSL interface.
223 /// </summary>
224 /// <remarks>
225 /// FIXME: This is an abomination. We should be able to set this up earlier but currently we have no
226 /// guarantee the interface is present on Initialize(). There needs to be another post initialize call from
227 /// ScriptInstance.
228 /// </remarks>
221 private void InitLSL() 229 private void InitLSL()
222 { 230 {
223 if (m_LSL_Api != null) 231 if (m_LSL_Api != null)
224 return; 232 return;
225 233
226 m_LSL_Api = (ILSL_Api)m_ScriptEngine.GetApi(m_itemID, "LSL"); 234 m_LSL_Api = (ILSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "LSL");
227 } 235 }
228 236
229 // 237 //
@@ -342,22 +350,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
342 return; 350 return;
343 } 351 }
344 352
345 TaskInventoryItem ti = m_host.Inventory.GetInventoryItem(m_itemID); 353 UUID ownerID = m_item.OwnerID;
346 if (ti == null)
347 {
348 OSSLError(
349 String.Format("{0} permission error. Can't find script in prim inventory.",
350 function));
351 }
352
353 UUID ownerID = ti.OwnerID;
354 354
355 //OSSL only may be used if objet is in the same group as the parcel 355 //OSSL only may be used if object is in the same group as the parcel
356 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) 356 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER"))
357 { 357 {
358 ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); 358 ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
359 359
360 if (land.LandData.GroupID == ti.GroupID && land.LandData.GroupID != UUID.Zero) 360 if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero)
361 { 361 {
362 return; 362 return;
363 } 363 }
@@ -378,7 +378,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
378 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) 378 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER"))
379 { 379 {
380 //Only Estate Managers may use the function 380 //Only Estate Managers may use the function
381 if (World.RegionInfo.EstateSettings.IsEstateManager(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) 381 if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID)
382 { 382 {
383 return; 383 return;
384 } 384 }
@@ -393,13 +393,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
393 } 393 }
394 } 394 }
395 395
396 if (!m_FunctionPerms[function].AllowedCreators.Contains(ti.CreatorID)) 396 if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID))
397 OSSLError( 397 OSSLError(
398 String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", 398 String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.",
399 function)); 399 function));
400 if (ti.CreatorID != ownerID) 400
401 if (m_item.CreatorID != ownerID)
401 { 402 {
402 if ((ti.CurrentPermissions & (uint)PermissionMask.Modify) != 0) 403 if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0)
403 OSSLError( 404 OSSLError(
404 String.Format("{0} permission denied. Script permissions error.", 405 String.Format("{0} permission denied. Script permissions error.",
405 function)); 406 function));
@@ -730,11 +731,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
730 731
731 m_host.AddScriptLPS(1); 732 m_host.AddScriptLPS(1);
732 733
734 // For safety, we add another permission check here, and don't rely only on the standard OSSL permissions
733 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) 735 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
734 { 736 {
735 MainConsole.Instance.RunCommand(command); 737 MainConsole.Instance.RunCommand(command);
736 return true; 738 return true;
737 } 739 }
740
738 return false; 741 return false;
739 } 742 }
740 743
@@ -1178,7 +1181,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1178 CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); 1181 CheckThreatLevel(ThreatLevel.High, "osSetStateEvents");
1179 m_host.AddScriptLPS(1); 1182 m_host.AddScriptLPS(1);
1180 1183
1181 m_host.SetScriptEvents(m_itemID, events); 1184 m_host.SetScriptEvents(m_item.ItemID, events);
1182 } 1185 }
1183 1186
1184 public void osSetRegionWaterHeight(double height) 1187 public void osSetRegionWaterHeight(double height)
@@ -1186,12 +1189,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1186 CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); 1189 CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight");
1187 1190
1188 m_host.AddScriptLPS(1); 1191 m_host.AddScriptLPS(1);
1189 //Check to make sure that the script's owner is the estate manager/master 1192
1190 //World.Permissions.GenericEstatePermission( 1193 World.EventManager.TriggerRequestChangeWaterHeight((float)height);
1191 if (World.Permissions.IsGod(m_host.OwnerID))
1192 {
1193 World.EventManager.TriggerRequestChangeWaterHeight((float)height);
1194 }
1195 } 1194 }
1196 1195
1197 /// <summary> 1196 /// <summary>
@@ -1202,27 +1201,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1202 /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> 1201 /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param>
1203 public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) 1202 public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour)
1204 { 1203 {
1205 CheckThreatLevel(ThreatLevel.Nuisance, "osSetRegionSunSettings"); 1204 CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings");
1206 1205
1207 m_host.AddScriptLPS(1); 1206 m_host.AddScriptLPS(1);
1208 //Check to make sure that the script's owner is the estate manager/master
1209 //World.Permissions.GenericEstatePermission(
1210 if (World.Permissions.IsGod(m_host.OwnerID))
1211 {
1212 while (sunHour > 24.0)
1213 sunHour -= 24.0;
1214 1207
1215 while (sunHour < 0) 1208 while (sunHour > 24.0)
1216 sunHour += 24.0; 1209 sunHour -= 24.0;
1217 1210
1211 while (sunHour < 0)
1212 sunHour += 24.0;
1218 1213
1219 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; 1214 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun;
1220 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 1215 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30
1221 World.RegionInfo.RegionSettings.FixedSun = sunFixed; 1216 World.RegionInfo.RegionSettings.FixedSun = sunFixed;
1222 World.RegionInfo.RegionSettings.Save(); 1217 World.RegionInfo.RegionSettings.Save();
1223 1218
1224 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); 1219 World.EventManager.TriggerEstateToolsSunUpdate(
1225 } 1220 World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour);
1226 } 1221 }
1227 1222
1228 /// <summary> 1223 /// <summary>
@@ -1232,26 +1227,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1232 /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> 1227 /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param>
1233 public void osSetEstateSunSettings(bool sunFixed, double sunHour) 1228 public void osSetEstateSunSettings(bool sunFixed, double sunHour)
1234 { 1229 {
1235 CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings"); 1230 CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings");
1236 1231
1237 m_host.AddScriptLPS(1); 1232 m_host.AddScriptLPS(1);
1238 //Check to make sure that the script's owner is the estate manager/master
1239 //World.Permissions.GenericEstatePermission(
1240 if (World.Permissions.IsGod(m_host.OwnerID))
1241 {
1242 while (sunHour > 24.0)
1243 sunHour -= 24.0;
1244 1233
1245 while (sunHour < 0) 1234 while (sunHour > 24.0)
1246 sunHour += 24.0; 1235 sunHour -= 24.0;
1247 1236
1248 World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; 1237 while (sunHour < 0)
1249 World.RegionInfo.EstateSettings.SunPosition = sunHour; 1238 sunHour += 24.0;
1250 World.RegionInfo.EstateSettings.FixedSun = sunFixed;
1251 World.RegionInfo.EstateSettings.Save();
1252 1239
1253 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); 1240 World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed;
1254 } 1241 World.RegionInfo.EstateSettings.SunPosition = sunHour;
1242 World.RegionInfo.EstateSettings.FixedSun = sunFixed;
1243 World.RegionInfo.EstateSettings.Save();
1244
1245 World.EventManager.TriggerEstateToolsSunUpdate(
1246 World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour);
1255 } 1247 }
1256 1248
1257 /// <summary> 1249 /// <summary>
@@ -1627,7 +1619,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1627 1619
1628 public Object osParseJSONNew(string JSON) 1620 public Object osParseJSONNew(string JSON)
1629 { 1621 {
1630 CheckThreatLevel(ThreatLevel.None, "osParseJSON"); 1622 CheckThreatLevel(ThreatLevel.None, "osParseJSONNew");
1631 1623
1632 m_host.AddScriptLPS(1); 1624 m_host.AddScriptLPS(1);
1633 1625
@@ -2042,8 +2034,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2042 string nick = String.Empty; 2034 string nick = String.Empty;
2043 IConfigSource config = m_ScriptEngine.ConfigSource; 2035 IConfigSource config = m_ScriptEngine.ConfigSource;
2044 2036
2045 if (config.Configs["GridInfo"] != null) 2037 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2046 nick = config.Configs["GridInfo"].GetString("gridnick", nick); 2038 nick = config.Configs[GridInfoServiceConfigSectionName].GetString("gridnick", nick);
2047 2039
2048 if (String.IsNullOrEmpty(nick)) 2040 if (String.IsNullOrEmpty(nick))
2049 nick = GridUserInfo(InfoType.Nick); 2041 nick = GridUserInfo(InfoType.Nick);
@@ -2059,8 +2051,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2059 string name = String.Empty; 2051 string name = String.Empty;
2060 IConfigSource config = m_ScriptEngine.ConfigSource; 2052 IConfigSource config = m_ScriptEngine.ConfigSource;
2061 2053
2062 if (config.Configs["GridInfo"] != null) 2054 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2063 name = config.Configs["GridInfo"].GetString("gridname", name); 2055 name = config.Configs[GridInfoServiceConfigSectionName].GetString("gridname", name);
2064 2056
2065 if (String.IsNullOrEmpty(name)) 2057 if (String.IsNullOrEmpty(name))
2066 name = GridUserInfo(InfoType.Name); 2058 name = GridUserInfo(InfoType.Name);
@@ -2076,8 +2068,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2076 string loginURI = String.Empty; 2068 string loginURI = String.Empty;
2077 IConfigSource config = m_ScriptEngine.ConfigSource; 2069 IConfigSource config = m_ScriptEngine.ConfigSource;
2078 2070
2079 if (config.Configs["GridInfo"] != null) 2071 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2080 loginURI = config.Configs["GridInfo"].GetString("login", loginURI); 2072 loginURI = config.Configs[GridInfoServiceConfigSectionName].GetString("login", loginURI);
2081 2073
2082 if (String.IsNullOrEmpty(loginURI)) 2074 if (String.IsNullOrEmpty(loginURI))
2083 loginURI = GridUserInfo(InfoType.Login); 2075 loginURI = GridUserInfo(InfoType.Login);
@@ -2124,8 +2116,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2124 string retval = String.Empty; 2116 string retval = String.Empty;
2125 IConfigSource config = m_ScriptEngine.ConfigSource; 2117 IConfigSource config = m_ScriptEngine.ConfigSource;
2126 2118
2127 if (config.Configs["GridInfo"] != null) 2119 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2128 retval = config.Configs["GridInfo"].GetString(key, retval); 2120 retval = config.Configs[GridInfoServiceConfigSectionName].GetString(key, retval);
2129 2121
2130 if (String.IsNullOrEmpty(retval)) 2122 if (String.IsNullOrEmpty(retval))
2131 retval = GridUserInfo(InfoType.Custom, key); 2123 retval = GridUserInfo(InfoType.Custom, key);
@@ -2480,7 +2472,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2480 return; 2472 return;
2481 2473
2482 Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); 2474 Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
2483 module.MoveToTarget(npcId, World, pos, false, true); 2475 module.MoveToTarget(npcId, World, pos, false, true, false);
2484 } 2476 }
2485 } 2477 }
2486 2478
@@ -2505,7 +2497,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2505 World, 2497 World,
2506 pos, 2498 pos,
2507 (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, 2499 (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
2508 (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0); 2500 (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0,
2501 (options & ScriptBaseClass.OS_NPC_RUNNING) != 0);
2509 } 2502 }
2510 } 2503 }
2511 2504
@@ -2555,7 +2548,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2555 2548
2556 public void osNpcStopMoveToTarget(LSL_Key npc) 2549 public void osNpcStopMoveToTarget(LSL_Key npc)
2557 { 2550 {
2558 CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); 2551 CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget");
2559 m_host.AddScriptLPS(1); 2552 m_host.AddScriptLPS(1);
2560 2553
2561 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2554 INPCModule module = World.RequestModuleInterface<INPCModule>();
@@ -2572,6 +2565,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2572 2565
2573 public void osNpcSay(LSL_Key npc, string message) 2566 public void osNpcSay(LSL_Key npc, string message)
2574 { 2567 {
2568 osNpcSay(npc, 0, message);
2569 }
2570
2571 public void osNpcSay(LSL_Key npc, int channel, string message)
2572 {
2575 CheckThreatLevel(ThreatLevel.High, "osNpcSay"); 2573 CheckThreatLevel(ThreatLevel.High, "osNpcSay");
2576 m_host.AddScriptLPS(1); 2574 m_host.AddScriptLPS(1);
2577 2575
@@ -2583,7 +2581,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2583 if (!module.CheckPermissions(npcId, m_host.OwnerID)) 2581 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2584 return; 2582 return;
2585 2583
2586 module.Say(npcId, World, message); 2584 module.Say(npcId, World, message, channel);
2585 }
2586 }
2587
2588 public void osNpcShout(LSL_Key npc, int channel, string message)
2589 {
2590 CheckThreatLevel(ThreatLevel.High, "osNpcShout");
2591 m_host.AddScriptLPS(1);
2592
2593 INPCModule module = World.RequestModuleInterface<INPCModule>();
2594 if (module != null)
2595 {
2596 UUID npcId = new UUID(npc.m_string);
2597
2598 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2599 return;
2600
2601 module.Shout(npcId, World, message, channel);
2587 } 2602 }
2588 } 2603 }
2589 2604
@@ -2684,6 +2699,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2684 } 2699 }
2685 } 2700 }
2686 2701
2702 public void osNpcWhisper(LSL_Key npc, int channel, string message)
2703 {
2704 CheckThreatLevel(ThreatLevel.High, "osNpcWhisper");
2705 m_host.AddScriptLPS(1);
2706
2707 INPCModule module = World.RequestModuleInterface<INPCModule>();
2708 if (module != null)
2709 {
2710 UUID npcId = new UUID(npc.m_string);
2711
2712 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2713 return;
2714
2715 module.Whisper(npcId, World, message, channel);
2716 }
2717 }
2718
2687 /// <summary> 2719 /// <summary>
2688 /// Save the current appearance of the script owner permanently to the named notecard. 2720 /// Save the current appearance of the script owner permanently to the named notecard.
2689 /// </summary> 2721 /// </summary>
@@ -2835,21 +2867,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2835 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); 2867 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar");
2836 m_host.AddScriptLPS(1); 2868 m_host.AddScriptLPS(1);
2837 2869
2838 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) 2870 World.ForEachRootScenePresence(delegate(ScenePresence sp)
2839 { 2871 {
2840 World.ForEachRootScenePresence(delegate(ScenePresence sp) 2872 if (sp.Firstname == FirstName && sp.Lastname == SurName)
2841 { 2873 {
2842 if (sp.Firstname == FirstName && sp.Lastname == SurName) 2874 // kick client...
2843 { 2875 if (alert != null)
2844 // kick client... 2876 sp.ControllingClient.Kick(alert);
2845 if (alert != null)
2846 sp.ControllingClient.Kick(alert);
2847 2877
2848 // ...and close on our side 2878 // ...and close on our side
2849 sp.Scene.IncomingCloseAgent(sp.UUID); 2879 sp.Scene.IncomingCloseAgent(sp.UUID);
2850 } 2880 }
2851 }); 2881 });
2852 }
2853 } 2882 }
2854 2883
2855 public void osCauseDamage(string avatar, double damage) 2884 public void osCauseDamage(string avatar, double damage)
@@ -3095,5 +3124,80 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3095 3124
3096 return ScriptBaseClass.TRUE; 3125 return ScriptBaseClass.TRUE;
3097 } 3126 }
3127
3128 /// <summary>
3129 /// Sets terrain estate texture
3130 /// </summary>
3131 /// <param name="level"></param>
3132 /// <param name="texture"></param>
3133 /// <returns></returns>
3134 public void osSetTerrainTexture(int level, LSL_Key texture)
3135 {
3136 CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture");
3137
3138 m_host.AddScriptLPS(1);
3139 //Check to make sure that the script's owner is the estate manager/master
3140 //World.Permissions.GenericEstatePermission(
3141 if (World.Permissions.IsGod(m_host.OwnerID))
3142 {
3143 if (level < 0 || level > 3)
3144 return;
3145
3146 UUID textureID = new UUID();
3147 if (!UUID.TryParse(texture, out textureID))
3148 return;
3149
3150 // estate module is required
3151 IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
3152 if (estate != null)
3153 estate.setEstateTerrainBaseTexture(level, textureID);
3154 }
3155 }
3156
3157 /// <summary>
3158 /// Sets terrain heights of estate
3159 /// </summary>
3160 /// <param name="corner"></param>
3161 /// <param name="low"></param>
3162 /// <param name="high"></param>
3163 /// <returns></returns>
3164 public void osSetTerrainTextureHeight(int corner, double low, double high)
3165 {
3166 CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight");
3167
3168 m_host.AddScriptLPS(1);
3169 //Check to make sure that the script's owner is the estate manager/master
3170 //World.Permissions.GenericEstatePermission(
3171 if (World.Permissions.IsGod(m_host.OwnerID))
3172 {
3173 if (corner < 0 || corner > 3)
3174 return;
3175
3176 // estate module is required
3177 IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
3178 if (estate != null)
3179 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
3180 }
3181 }
3182
3183 public void osForceAttachToAvatar(int attachmentPoint)
3184 {
3185 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
3186
3187 m_host.AddScriptLPS(1);
3188
3189 InitLSL();
3190 ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
3191 }
3192
3193 public void osForceDetachFromAvatar()
3194 {
3195 CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
3196
3197 m_host.AddScriptLPS(1);
3198
3199 InitLSL();
3200 ((LSL_Api)m_LSL_Api).DetachFromAvatar();
3201 }
3098 } 3202 }
3099} 3203}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 1373971..19f3ce1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -308,7 +308,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
308 } 308 }
309 SceneObjectPart SensePoint = ts.host; 309 SceneObjectPart SensePoint = ts.host;
310 310
311 Vector3 fromRegionPos = SensePoint.AbsolutePosition; 311 Vector3 fromRegionPos = SensePoint.GetWorldPosition();
312 312
313 // pre define some things to avoid repeated definitions in the loop body 313 // pre define some things to avoid repeated definitions in the loop body
314 Vector3 toRegionPos; 314 Vector3 toRegionPos;
@@ -323,13 +323,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
323 Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! 323 Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation!
324 if (SensePoint.ParentGroup.IsAttachment) 324 if (SensePoint.ParentGroup.IsAttachment)
325 { 325 {
326 // In attachments, the sensor cone always orients with the 326 // In attachments, rotate the sensor cone with the
327 // avatar rotation. This may include a nonzero elevation if 327 // avatar rotation. This may include a nonzero elevation if
328 // in mouselook. 328 // in mouselook.
329 // This will not include the rotation and position of the
330 // attachment point (e.g. your head when a sensor is in your
331 // hair attached to your scull. Your hair will turn with
332 // your head but the sensor will stay with your (global)
333 // avatar rotation and position.
334 // Position of a sensor in a child prim attached to an avatar
335 // will be still wrong.
329 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); 336 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
330 fromRegionPos = avatar.AbsolutePosition; 337 fromRegionPos = avatar.AbsolutePosition;
331 q = avatar.Rotation; 338 q = avatar.Rotation;
332 } 339 }
340
333 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 341 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
334 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); 342 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
335 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 343 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
@@ -441,14 +449,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
441 return sensedEntities; 449 return sensedEntities;
442 450
443 SceneObjectPart SensePoint = ts.host; 451 SceneObjectPart SensePoint = ts.host;
444 Vector3 fromRegionPos = SensePoint.AbsolutePosition; 452 Vector3 fromRegionPos = SensePoint.GetWorldPosition();
445 453
446 Quaternion q = SensePoint.RotationOffset; 454 Quaternion q = SensePoint.GetWorldRotation();
447 if (SensePoint.ParentGroup.IsAttachment) 455 if (SensePoint.ParentGroup.IsAttachment)
448 { 456 {
449 // In attachments, the sensor cone always orients with the 457 // In attachments, rotate the sensor cone with the
450 // avatar rotation. This may include a nonzero elevation if 458 // avatar rotation. This may include a nonzero elevation if
451 // in mouselook. 459 // in mouselook.
460 // This will not include the rotation and position of the
461 // attachment point (e.g. your head when a sensor is in your
462 // hair attached to your scull. Your hair will turn with
463 // your head but the sensor will stay with your (global)
464 // avatar rotation and position.
465 // Position of a sensor in a child prim attached to an avatar
466 // will be still wrong.
452 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); 467 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
453 if (avatar == null) 468 if (avatar == null)
454 return sensedEntities; 469 return sensedEntities;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index be5740e..048124d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -105,6 +105,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
105 LSL_Integer llFloor(double f); 105 LSL_Integer llFloor(double f);
106 void llForceMouselook(int mouselook); 106 void llForceMouselook(int mouselook);
107 LSL_Float llFrand(double mag); 107 LSL_Float llFrand(double mag);
108 LSL_Key llGenerateKey();
108 LSL_Vector llGetAccel(); 109 LSL_Vector llGetAccel();
109 LSL_Integer llGetAgentInfo(string id); 110 LSL_Integer llGetAgentInfo(string id);
110 LSL_String llGetAgentLanguage(string id); 111 LSL_String llGetAgentLanguage(string id);
@@ -150,7 +151,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
150 LSL_Rotation llGetLocalRot(); 151 LSL_Rotation llGetLocalRot();
151 LSL_Float llGetMass(); 152 LSL_Float llGetMass();
152 LSL_Float llGetMassMKS(); 153 LSL_Float llGetMassMKS();
153 void llGetNextEmail(string address, string subject); 154 LSL_Integer llGetMemoryLimit();
155 void llGetNextEmail(string address, string subject);
154 LSL_String llGetNotecardLine(string name, int line); 156 LSL_String llGetNotecardLine(string name, int line);
155 LSL_Key llGetNumberOfNotecardLines(string name); 157 LSL_Key llGetNumberOfNotecardLines(string name);
156 LSL_Integer llGetNumberOfPrims(); 158 LSL_Integer llGetNumberOfPrims();
@@ -188,6 +190,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
188 LSL_String llGetScriptName(); 190 LSL_String llGetScriptName();
189 LSL_Integer llGetScriptState(string name); 191 LSL_Integer llGetScriptState(string name);
190 LSL_String llGetSimulatorHostname(); 192 LSL_String llGetSimulatorHostname();
193 LSL_Integer llGetSPMaxMemory();
191 LSL_Integer llGetStartParameter(); 194 LSL_Integer llGetStartParameter();
192 LSL_Integer llGetStatus(int status); 195 LSL_Integer llGetStatus(int status);
193 LSL_String llGetSubString(string src, int start, int end); 196 LSL_String llGetSubString(string src, int start, int end);
@@ -323,6 +326,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
323 void llSay(int channelID, string text); 326 void llSay(int channelID, string text);
324 void llScaleTexture(double u, double v, int face); 327 void llScaleTexture(double u, double v, int face);
325 LSL_Integer llScriptDanger(LSL_Vector pos); 328 LSL_Integer llScriptDanger(LSL_Vector pos);
329 void llScriptProfiler(LSL_Integer flag);
326 LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata); 330 LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata);
327 void llSensor(string name, string id, int type, double range, double arc); 331 void llSensor(string name, string id, int type, double range, double arc);
328 void llSensorRemove(); 332 void llSensorRemove();
@@ -346,6 +350,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
346 void llSetLinkTexture(int linknumber, string texture, int face); 350 void llSetLinkTexture(int linknumber, string texture, int face);
347 void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate); 351 void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate);
348 void llSetLocalRot(LSL_Rotation rot); 352 void llSetLocalRot(LSL_Rotation rot);
353 LSL_Integer llSetMemoryLimit(LSL_Integer limit);
349 void llSetObjectDesc(string desc); 354 void llSetObjectDesc(string desc);
350 void llSetObjectName(string name); 355 void llSetObjectName(string name);
351 void llSetObjectPermMask(int mask, int value); 356 void llSetObjectPermMask(int mask, int value);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 444a681..7382495 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -98,6 +98,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
98 void osAvatarPlayAnimation(string avatar, string animation); 98 void osAvatarPlayAnimation(string avatar, string animation);
99 void osAvatarStopAnimation(string avatar, string animation); 99 void osAvatarStopAnimation(string avatar, string animation);
100 100
101 // Attachment commands
102
103 /// <summary>
104 /// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH
105 /// </summary>
106 /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
107 void osForceAttachToAvatar(int attachment);
108
109 /// <summary>
110 /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH
111 /// </summary>
112 /// <remarks>Nothing happens if the object is not attached.</remarks>
113 void osForceDetachFromAvatar();
114
101 //texture draw functions 115 //texture draw functions
102 string osMovePen(string drawList, int x, int y); 116 string osMovePen(string drawList, int x, int y);
103 string osDrawLine(string drawList, int startX, int startY, int endX, int endY); 117 string osDrawLine(string drawList, int startX, int startY, int endX, int endY);
@@ -203,11 +217,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
203 void osNpcSetRot(LSL_Key npc, rotation rot); 217 void osNpcSetRot(LSL_Key npc, rotation rot);
204 void osNpcStopMoveToTarget(LSL_Key npc); 218 void osNpcStopMoveToTarget(LSL_Key npc);
205 void osNpcSay(key npc, string message); 219 void osNpcSay(key npc, string message);
220 void osNpcSay(key npc, int channel, string message);
221 void osNpcShout(key npc, int channel, string message);
206 void osNpcSit(key npc, key target, int options); 222 void osNpcSit(key npc, key target, int options);
207 void osNpcStand(LSL_Key npc); 223 void osNpcStand(LSL_Key npc);
208 void osNpcRemove(key npc); 224 void osNpcRemove(key npc);
209 void osNpcPlayAnimation(LSL_Key npc, string animation); 225 void osNpcPlayAnimation(LSL_Key npc, string animation);
210 void osNpcStopAnimation(LSL_Key npc, string animation); 226 void osNpcStopAnimation(LSL_Key npc, string animation);
227 void osNpcWhisper(key npc, int channel, string message);
211 228
212 LSL_Key osOwnerSaveAppearance(string notecard); 229 LSL_Key osOwnerSaveAppearance(string notecard);
213 LSL_Key osAgentSaveAppearance(key agentId, string notecard); 230 LSL_Key osAgentSaveAppearance(key agentId, string notecard);
@@ -234,5 +251,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
234 251
235 LSL_Integer osInviteToGroup(LSL_Key agentId); 252 LSL_Integer osInviteToGroup(LSL_Key agentId);
236 LSL_Integer osEjectFromGroup(LSL_Key agentId); 253 LSL_Integer osEjectFromGroup(LSL_Key agentId);
254
255 void osSetTerrainTexture(int level, LSL_Key texture);
256 void osSetTerrainTextureHeight(int corner, double low, double high);
237 } 257 }
238} 258}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 278f74e..5c6ad8a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -383,6 +383,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
383 public const int PRIM_SCULPT_FLAG_INVERT = 64; 383 public const int PRIM_SCULPT_FLAG_INVERT = 64;
384 public const int PRIM_SCULPT_FLAG_MIRROR = 128; 384 public const int PRIM_SCULPT_FLAG_MIRROR = 128;
385 385
386 public const int PROFILE_NONE = 0;
387 public const int PROFILE_SCRIPT_MEMORY = 1;
388
386 public const int MASK_BASE = 0; 389 public const int MASK_BASE = 0;
387 public const int MASK_OWNER = 1; 390 public const int MASK_OWNER = 1;
388 public const int MASK_GROUP = 2; 391 public const int MASK_GROUP = 2;
@@ -641,6 +644,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
641 public const int OS_NPC_FLY = 0; 644 public const int OS_NPC_FLY = 0;
642 public const int OS_NPC_NO_FLY = 1; 645 public const int OS_NPC_NO_FLY = 1;
643 public const int OS_NPC_LAND_AT_TARGET = 2; 646 public const int OS_NPC_LAND_AT_TARGET = 2;
647 public const int OS_NPC_RUNNING = 4;
644 648
645 public const int OS_NPC_SIT_NOW = 0; 649 public const int OS_NPC_SIT_NOW = 0;
646 650
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 9ba9561..2d23d30 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -376,6 +376,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
376 return m_LSL_Functions.llFrand(mag); 376 return m_LSL_Functions.llFrand(mag);
377 } 377 }
378 378
379 public LSL_Key llGenerateKey()
380 {
381 return m_LSL_Functions.llGenerateKey();
382 }
383
379 public LSL_Vector llGetAccel() 384 public LSL_Vector llGetAccel()
380 { 385 {
381 return m_LSL_Functions.llGetAccel(); 386 return m_LSL_Functions.llGetAccel();
@@ -591,6 +596,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
591 return m_LSL_Functions.llGetMassMKS(); 596 return m_LSL_Functions.llGetMassMKS();
592 } 597 }
593 598
599 public LSL_Integer llGetMemoryLimit()
600 {
601 return m_LSL_Functions.llGetMemoryLimit();
602 }
603
594 public void llGetNextEmail(string address, string subject) 604 public void llGetNextEmail(string address, string subject)
595 { 605 {
596 m_LSL_Functions.llGetNextEmail(address, subject); 606 m_LSL_Functions.llGetNextEmail(address, subject);
@@ -781,6 +791,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
781 return m_LSL_Functions.llGetSimulatorHostname(); 791 return m_LSL_Functions.llGetSimulatorHostname();
782 } 792 }
783 793
794 public LSL_Integer llGetSPMaxMemory()
795 {
796 return m_LSL_Functions.llGetSPMaxMemory();
797 }
798
784 public LSL_Integer llGetStartParameter() 799 public LSL_Integer llGetStartParameter()
785 { 800 {
786 return m_LSL_Functions.llGetStartParameter(); 801 return m_LSL_Functions.llGetStartParameter();
@@ -1450,6 +1465,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1450 return m_LSL_Functions.llScriptDanger(pos); 1465 return m_LSL_Functions.llScriptDanger(pos);
1451 } 1466 }
1452 1467
1468 public void llScriptProfiler(LSL_Integer flags)
1469 {
1470 m_LSL_Functions.llScriptProfiler(flags);
1471 }
1472
1453 public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata) 1473 public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata)
1454 { 1474 {
1455 return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); 1475 return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata);
@@ -1560,6 +1580,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1560 m_LSL_Functions.llSetLocalRot(rot); 1580 m_LSL_Functions.llSetLocalRot(rot);
1561 } 1581 }
1562 1582
1583 public LSL_Integer llSetMemoryLimit(LSL_Integer limit)
1584 {
1585 return m_LSL_Functions.llSetMemoryLimit(limit);
1586 }
1587
1563 public void llSetObjectDesc(string desc) 1588 public void llSetObjectDesc(string desc)
1564 { 1589 {
1565 m_LSL_Functions.llSetObjectDesc(desc); 1590 m_LSL_Functions.llSetObjectDesc(desc);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 680cefb4..d230662 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -289,8 +289,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); 289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
290 } 290 }
291 291
292 // Avatar functions
292 293
293 //Texture Draw functions 294 public void osForceAttachToAvatar(int attachmentPoint)
295 {
296 m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint);
297 }
298
299 public void osForceDetachFromAvatar()
300 {
301 m_OSSL_Functions.osForceDetachFromAvatar();
302 }
303
304 // Texture Draw functions
294 305
295 public string osMovePen(string drawList, int x, int y) 306 public string osMovePen(string drawList, int x, int y)
296 { 307 {
@@ -569,6 +580,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
569 m_OSSL_Functions.osNpcSay(npc, message); 580 m_OSSL_Functions.osNpcSay(npc, message);
570 } 581 }
571 582
583 public void osNpcSay(key npc, int channel, string message)
584 {
585 m_OSSL_Functions.osNpcSay(npc, channel, message);
586 }
587
588
589 public void osNpcShout(key npc, int channel, string message)
590 {
591 m_OSSL_Functions.osNpcShout(npc, channel, message);
592 }
593
572 public void osNpcSit(LSL_Key npc, LSL_Key target, int options) 594 public void osNpcSit(LSL_Key npc, LSL_Key target, int options)
573 { 595 {
574 m_OSSL_Functions.osNpcSit(npc, target, options); 596 m_OSSL_Functions.osNpcSit(npc, target, options);
@@ -594,6 +616,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
594 m_OSSL_Functions.osNpcStopAnimation(npc, animation); 616 m_OSSL_Functions.osNpcStopAnimation(npc, animation);
595 } 617 }
596 618
619 public void osNpcWhisper(key npc, int channel, string message)
620 {
621 m_OSSL_Functions.osNpcWhisper(npc, channel, message);
622 }
623
597 public LSL_Key osOwnerSaveAppearance(string notecard) 624 public LSL_Key osOwnerSaveAppearance(string notecard)
598 { 625 {
599 return m_OSSL_Functions.osOwnerSaveAppearance(notecard); 626 return m_OSSL_Functions.osOwnerSaveAppearance(notecard);
@@ -878,5 +905,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
878 { 905 {
879 return m_OSSL_Functions.osEjectFromGroup(agentId); 906 return m_OSSL_Functions.osEjectFromGroup(agentId);
880 } 907 }
908
909 public void osSetTerrainTexture(int level, LSL_Key texture)
910 {
911 m_OSSL_Functions.osSetTerrainTexture(level, texture);
912 }
913
914 public void osSetTerrainTextureHeight(int corner, double low, double high)
915 {
916 m_OSSL_Functions.osSetTerrainTextureHeight(corner, low, high);
917 }
881 } 918 }
882} 919}