diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 439 |
1 files changed, 333 insertions, 106 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 0dc2aa2..29d0342 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -126,13 +126,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
126 | [Serializable] | 126 | [Serializable] |
127 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi | 127 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi |
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 | |||
131 | public const string GridInfoServiceConfigSectionName = "GridInfoService"; | ||
130 | 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 | ||
@@ -880,13 +883,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
880 | if (World.Entities.ContainsKey((UUID)agent) && World.Entities[avatarID] is ScenePresence) | 883 | if (World.Entities.ContainsKey((UUID)agent) && World.Entities[avatarID] is ScenePresence) |
881 | { | 884 | { |
882 | ScenePresence target = (ScenePresence)World.Entities[avatarID]; | 885 | ScenePresence target = (ScenePresence)World.Entities[avatarID]; |
883 | EndPoint ep = target.ControllingClient.GetClientEP(); | 886 | return target.ControllingClient.RemoteEndPoint.Address.ToString(); |
884 | if (ep is IPEndPoint) | ||
885 | { | ||
886 | IPEndPoint ip = (IPEndPoint)ep; | ||
887 | return ip.Address.ToString(); | ||
888 | } | ||
889 | } | 887 | } |
888 | |||
890 | // fall through case, just return nothing | 889 | // fall through case, just return nothing |
891 | return ""; | 890 | return ""; |
892 | } | 891 | } |
@@ -957,21 +956,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
957 | UUID avatarID = (UUID)avatar; | 956 | UUID avatarID = (UUID)avatar; |
958 | 957 | ||
959 | m_host.AddScriptLPS(1); | 958 | m_host.AddScriptLPS(1); |
959 | |||
960 | // FIXME: What we really want to do here is factor out the similar code in llStopAnimation() to a common | ||
961 | // method (though see that doesn't do the is animation check, which is probably a bug) and have both | ||
962 | // these functions call that common code. However, this does mean navigating the brain-dead requirement | ||
963 | // of calling InitLSL() | ||
960 | if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence) | 964 | if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence) |
961 | { | 965 | { |
962 | ScenePresence target = (ScenePresence)World.Entities[avatarID]; | 966 | ScenePresence target = (ScenePresence)World.Entities[avatarID]; |
963 | if (target != null) | 967 | if (target != null) |
964 | { | 968 | { |
965 | UUID animID = UUID.Zero; | 969 | UUID animID; |
966 | m_host.TaskInventory.LockItemsForRead(true); | 970 | |
967 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 971 | if (!UUID.TryParse(animation, out animID)) |
968 | { | 972 | { |
969 | if (inv.Value.Name == animation) | 973 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation); |
970 | { | 974 | if (item != null && item.Type == (int)AssetType.Animation) |
971 | if (inv.Value.Type == (int)AssetType.Animation) | 975 | animID = item.AssetID; |
972 | animID = inv.Value.AssetID; | 976 | else |
973 | continue; | 977 | animID = UUID.Zero; |
974 | } | ||
975 | } | 978 | } |
976 | m_host.TaskInventory.LockItemsForRead(false); | 979 | m_host.TaskInventory.LockItemsForRead(false); |
977 | 980 | ||
@@ -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 | ||
@@ -1681,9 +1673,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1681 | CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); | 1673 | CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); |
1682 | m_host.AddScriptLPS(1); | 1674 | m_host.AddScriptLPS(1); |
1683 | 1675 | ||
1676 | UUID objUUID; | ||
1677 | if (!UUID.TryParse(objectUUID, out objUUID)) // prior to patching, a thrown exception regarding invalid GUID format would be shouted instead. | ||
1678 | { | ||
1679 | OSSLShoutError("osMessageObject() cannot send messages to objects with invalid UUIDs"); | ||
1680 | return; | ||
1681 | } | ||
1682 | |||
1684 | object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) }; | 1683 | object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) }; |
1685 | 1684 | ||
1686 | SceneObjectPart sceneOP = World.GetSceneObjectPart(new UUID(objectUUID)); | 1685 | SceneObjectPart sceneOP = World.GetSceneObjectPart(objUUID); |
1686 | |||
1687 | if (sceneOP == null) // prior to patching, PostObjectEvent() would cause a throw exception to be shouted instead. | ||
1688 | { | ||
1689 | OSSLShoutError("osMessageObject() cannot send message to " + objUUID.ToString() + ", object was not found in scene."); | ||
1690 | return; | ||
1691 | } | ||
1687 | 1692 | ||
1688 | m_ScriptEngine.PostObjectEvent( | 1693 | m_ScriptEngine.PostObjectEvent( |
1689 | sceneOP.LocalId, new EventParams( | 1694 | sceneOP.LocalId, new EventParams( |
@@ -1826,8 +1831,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1826 | if (a == null) | 1831 | if (a == null) |
1827 | return UUID.Zero; | 1832 | return UUID.Zero; |
1828 | 1833 | ||
1829 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | 1834 | string data = Encoding.UTF8.GetString(a.Data); |
1830 | string data = enc.GetString(a.Data); | ||
1831 | NotecardCache.Cache(assetID, data); | 1835 | NotecardCache.Cache(assetID, data); |
1832 | }; | 1836 | }; |
1833 | 1837 | ||
@@ -1980,7 +1984,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1980 | { | 1984 | { |
1981 | string retval = String.Empty; | 1985 | string retval = String.Empty; |
1982 | IConfigSource config = m_ScriptEngine.ConfigSource; | 1986 | IConfigSource config = m_ScriptEngine.ConfigSource; |
1983 | string url = config.Configs["GridInfo"].GetString("GridInfoURI", String.Empty); | 1987 | string url = null; |
1988 | |||
1989 | IConfig gridInfoConfig = config.Configs["GridInfo"]; | ||
1990 | |||
1991 | if (gridInfoConfig != null) | ||
1992 | url = gridInfoConfig.GetString("GridInfoURI", String.Empty); | ||
1984 | 1993 | ||
1985 | if (String.IsNullOrEmpty(url)) | 1994 | if (String.IsNullOrEmpty(url)) |
1986 | return "Configuration Error!"; | 1995 | return "Configuration Error!"; |
@@ -2042,8 +2051,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2042 | string nick = String.Empty; | 2051 | string nick = String.Empty; |
2043 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2052 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2044 | 2053 | ||
2045 | if (config.Configs["GridInfo"] != null) | 2054 | if (config.Configs[GridInfoServiceConfigSectionName] != null) |
2046 | nick = config.Configs["GridInfo"].GetString("gridnick", nick); | 2055 | nick = config.Configs[GridInfoServiceConfigSectionName].GetString("gridnick", nick); |
2047 | 2056 | ||
2048 | if (String.IsNullOrEmpty(nick)) | 2057 | if (String.IsNullOrEmpty(nick)) |
2049 | nick = GridUserInfo(InfoType.Nick); | 2058 | nick = GridUserInfo(InfoType.Nick); |
@@ -2059,8 +2068,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2059 | string name = String.Empty; | 2068 | string name = String.Empty; |
2060 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2069 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2061 | 2070 | ||
2062 | if (config.Configs["GridInfo"] != null) | 2071 | if (config.Configs[GridInfoServiceConfigSectionName] != null) |
2063 | name = config.Configs["GridInfo"].GetString("gridname", name); | 2072 | name = config.Configs[GridInfoServiceConfigSectionName].GetString("gridname", name); |
2064 | 2073 | ||
2065 | if (String.IsNullOrEmpty(name)) | 2074 | if (String.IsNullOrEmpty(name)) |
2066 | name = GridUserInfo(InfoType.Name); | 2075 | name = GridUserInfo(InfoType.Name); |
@@ -2076,8 +2085,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2076 | string loginURI = String.Empty; | 2085 | string loginURI = String.Empty; |
2077 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2086 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2078 | 2087 | ||
2079 | if (config.Configs["GridInfo"] != null) | 2088 | if (config.Configs[GridInfoServiceConfigSectionName] != null) |
2080 | loginURI = config.Configs["GridInfo"].GetString("login", loginURI); | 2089 | loginURI = config.Configs[GridInfoServiceConfigSectionName].GetString("login", loginURI); |
2081 | 2090 | ||
2082 | if (String.IsNullOrEmpty(loginURI)) | 2091 | if (String.IsNullOrEmpty(loginURI)) |
2083 | loginURI = GridUserInfo(InfoType.Login); | 2092 | loginURI = GridUserInfo(InfoType.Login); |
@@ -2124,8 +2133,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2124 | string retval = String.Empty; | 2133 | string retval = String.Empty; |
2125 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2134 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2126 | 2135 | ||
2127 | if (config.Configs["GridInfo"] != null) | 2136 | if (config.Configs[GridInfoServiceConfigSectionName] != null) |
2128 | retval = config.Configs["GridInfo"].GetString(key, retval); | 2137 | retval = config.Configs[GridInfoServiceConfigSectionName].GetString(key, retval); |
2129 | 2138 | ||
2130 | if (String.IsNullOrEmpty(retval)) | 2139 | if (String.IsNullOrEmpty(retval)) |
2131 | retval = GridUserInfo(InfoType.Custom, key); | 2140 | retval = GridUserInfo(InfoType.Custom, key); |
@@ -2135,7 +2144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2135 | 2144 | ||
2136 | public LSL_String osFormatString(string str, LSL_List strings) | 2145 | public LSL_String osFormatString(string str, LSL_List strings) |
2137 | { | 2146 | { |
2138 | CheckThreatLevel(ThreatLevel.Low, "osFormatString"); | 2147 | CheckThreatLevel(ThreatLevel.VeryLow, "osFormatString"); |
2139 | m_host.AddScriptLPS(1); | 2148 | m_host.AddScriptLPS(1); |
2140 | 2149 | ||
2141 | return String.Format(str, strings.Data); | 2150 | return String.Format(str, strings.Data); |
@@ -2143,7 +2152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2143 | 2152 | ||
2144 | public LSL_List osMatchString(string src, string pattern, int start) | 2153 | public LSL_List osMatchString(string src, string pattern, int start) |
2145 | { | 2154 | { |
2146 | CheckThreatLevel(ThreatLevel.High, "osMatchString"); | 2155 | CheckThreatLevel(ThreatLevel.VeryLow, "osMatchString"); |
2147 | m_host.AddScriptLPS(1); | 2156 | m_host.AddScriptLPS(1); |
2148 | 2157 | ||
2149 | LSL_List result = new LSL_List(); | 2158 | LSL_List result = new LSL_List(); |
@@ -2185,7 +2194,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2185 | 2194 | ||
2186 | public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start) | 2195 | public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start) |
2187 | { | 2196 | { |
2188 | CheckThreatLevel(ThreatLevel.High, "osReplaceString"); | 2197 | CheckThreatLevel(ThreatLevel.VeryLow, "osReplaceString"); |
2189 | m_host.AddScriptLPS(1); | 2198 | m_host.AddScriptLPS(1); |
2190 | 2199 | ||
2191 | // Normalize indices (if negative). | 2200 | // Normalize indices (if negative). |
@@ -2480,7 +2489,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2480 | return; | 2489 | return; |
2481 | 2490 | ||
2482 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); | 2491 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); |
2483 | module.MoveToTarget(npcId, World, pos, false, true); | 2492 | module.MoveToTarget(npcId, World, pos, false, true, false); |
2484 | } | 2493 | } |
2485 | } | 2494 | } |
2486 | 2495 | ||
@@ -2505,7 +2514,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2505 | World, | 2514 | World, |
2506 | pos, | 2515 | pos, |
2507 | (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, | 2516 | (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, |
2508 | (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0); | 2517 | (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0, |
2518 | (options & ScriptBaseClass.OS_NPC_RUNNING) != 0); | ||
2509 | } | 2519 | } |
2510 | } | 2520 | } |
2511 | 2521 | ||
@@ -2555,7 +2565,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2555 | 2565 | ||
2556 | public void osNpcStopMoveToTarget(LSL_Key npc) | 2566 | public void osNpcStopMoveToTarget(LSL_Key npc) |
2557 | { | 2567 | { |
2558 | CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); | 2568 | CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget"); |
2559 | m_host.AddScriptLPS(1); | 2569 | m_host.AddScriptLPS(1); |
2560 | 2570 | ||
2561 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2571 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
@@ -2572,6 +2582,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2572 | 2582 | ||
2573 | public void osNpcSay(LSL_Key npc, string message) | 2583 | public void osNpcSay(LSL_Key npc, string message) |
2574 | { | 2584 | { |
2585 | osNpcSay(npc, 0, message); | ||
2586 | } | ||
2587 | |||
2588 | public void osNpcSay(LSL_Key npc, int channel, string message) | ||
2589 | { | ||
2575 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); | 2590 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); |
2576 | m_host.AddScriptLPS(1); | 2591 | m_host.AddScriptLPS(1); |
2577 | 2592 | ||
@@ -2583,7 +2598,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2583 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | 2598 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) |
2584 | return; | 2599 | return; |
2585 | 2600 | ||
2586 | module.Say(npcId, World, message); | 2601 | module.Say(npcId, World, message, channel); |
2602 | } | ||
2603 | } | ||
2604 | |||
2605 | public void osNpcShout(LSL_Key npc, int channel, string message) | ||
2606 | { | ||
2607 | CheckThreatLevel(ThreatLevel.High, "osNpcShout"); | ||
2608 | m_host.AddScriptLPS(1); | ||
2609 | |||
2610 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2611 | if (module != null) | ||
2612 | { | ||
2613 | UUID npcId = new UUID(npc.m_string); | ||
2614 | |||
2615 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2616 | return; | ||
2617 | |||
2618 | module.Shout(npcId, World, message, channel); | ||
2587 | } | 2619 | } |
2588 | } | 2620 | } |
2589 | 2621 | ||
@@ -2684,6 +2716,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2684 | } | 2716 | } |
2685 | } | 2717 | } |
2686 | 2718 | ||
2719 | public void osNpcWhisper(LSL_Key npc, int channel, string message) | ||
2720 | { | ||
2721 | CheckThreatLevel(ThreatLevel.High, "osNpcWhisper"); | ||
2722 | m_host.AddScriptLPS(1); | ||
2723 | |||
2724 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2725 | if (module != null) | ||
2726 | { | ||
2727 | UUID npcId = new UUID(npc.m_string); | ||
2728 | |||
2729 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2730 | return; | ||
2731 | |||
2732 | module.Whisper(npcId, World, message, channel); | ||
2733 | } | ||
2734 | } | ||
2735 | |||
2736 | public void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num) | ||
2737 | { | ||
2738 | CheckThreatLevel(ThreatLevel.High, "osNpcTouch"); | ||
2739 | m_host.AddScriptLPS(1); | ||
2740 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2741 | int linkNum = link_num.value; | ||
2742 | if (module != null || (linkNum < 0 && linkNum != ScriptBaseClass.LINK_THIS)) | ||
2743 | { | ||
2744 | UUID npcId; | ||
2745 | if (!UUID.TryParse(npcLSL_Key, out npcId) || !module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2746 | return; | ||
2747 | SceneObjectPart part = null; | ||
2748 | UUID objectId; | ||
2749 | if (UUID.TryParse(LSL_String.ToString(object_key), out objectId)) | ||
2750 | part = World.GetSceneObjectPart(objectId); | ||
2751 | if (part == null) | ||
2752 | return; | ||
2753 | if (linkNum != ScriptBaseClass.LINK_THIS) | ||
2754 | { | ||
2755 | if (linkNum == 0 || linkNum == ScriptBaseClass.LINK_ROOT) | ||
2756 | { // 0 and 1 are treated as root, find the root if the current part isnt it | ||
2757 | if (!part.IsRoot) | ||
2758 | part = part.ParentGroup.RootPart; | ||
2759 | } | ||
2760 | else | ||
2761 | { // Find the prim with the given link number if not found then fail silently | ||
2762 | part = part.ParentGroup.GetLinkNumPart(linkNum); | ||
2763 | if (part == null) | ||
2764 | return; | ||
2765 | } | ||
2766 | } | ||
2767 | module.Touch(npcId, part.UUID); | ||
2768 | } | ||
2769 | } | ||
2770 | |||
2687 | /// <summary> | 2771 | /// <summary> |
2688 | /// Save the current appearance of the script owner permanently to the named notecard. | 2772 | /// Save the current appearance of the script owner permanently to the named notecard. |
2689 | /// </summary> | 2773 | /// </summary> |
@@ -2835,21 +2919,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2835 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); | 2919 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); |
2836 | m_host.AddScriptLPS(1); | 2920 | m_host.AddScriptLPS(1); |
2837 | 2921 | ||
2838 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) | 2922 | World.ForEachRootScenePresence(delegate(ScenePresence sp) |
2839 | { | 2923 | { |
2840 | World.ForEachRootScenePresence(delegate(ScenePresence sp) | 2924 | if (sp.Firstname == FirstName && sp.Lastname == SurName) |
2841 | { | 2925 | { |
2842 | if (sp.Firstname == FirstName && sp.Lastname == SurName) | 2926 | // kick client... |
2843 | { | 2927 | if (alert != null) |
2844 | // kick client... | 2928 | sp.ControllingClient.Kick(alert); |
2845 | if (alert != null) | ||
2846 | sp.ControllingClient.Kick(alert); | ||
2847 | 2929 | ||
2848 | // ...and close on our side | 2930 | // ...and close on our side |
2849 | sp.Scene.IncomingCloseAgent(sp.UUID); | 2931 | sp.Scene.IncomingCloseAgent(sp.UUID); |
2850 | } | 2932 | } |
2851 | }); | 2933 | }); |
2852 | } | ||
2853 | } | 2934 | } |
2854 | 2935 | ||
2855 | public void osCauseDamage(string avatar, double damage) | 2936 | public void osCauseDamage(string avatar, double damage) |
@@ -3095,5 +3176,151 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3095 | 3176 | ||
3096 | return ScriptBaseClass.TRUE; | 3177 | return ScriptBaseClass.TRUE; |
3097 | } | 3178 | } |
3179 | |||
3180 | /// <summary> | ||
3181 | /// Sets terrain estate texture | ||
3182 | /// </summary> | ||
3183 | /// <param name="level"></param> | ||
3184 | /// <param name="texture"></param> | ||
3185 | /// <returns></returns> | ||
3186 | public void osSetTerrainTexture(int level, LSL_Key texture) | ||
3187 | { | ||
3188 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture"); | ||
3189 | |||
3190 | m_host.AddScriptLPS(1); | ||
3191 | //Check to make sure that the script's owner is the estate manager/master | ||
3192 | //World.Permissions.GenericEstatePermission( | ||
3193 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
3194 | { | ||
3195 | if (level < 0 || level > 3) | ||
3196 | return; | ||
3197 | |||
3198 | UUID textureID = new UUID(); | ||
3199 | if (!UUID.TryParse(texture, out textureID)) | ||
3200 | return; | ||
3201 | |||
3202 | // estate module is required | ||
3203 | IEstateModule estate = World.RequestModuleInterface<IEstateModule>(); | ||
3204 | if (estate != null) | ||
3205 | estate.setEstateTerrainBaseTexture(level, textureID); | ||
3206 | } | ||
3207 | } | ||
3208 | |||
3209 | /// <summary> | ||
3210 | /// Sets terrain heights of estate | ||
3211 | /// </summary> | ||
3212 | /// <param name="corner"></param> | ||
3213 | /// <param name="low"></param> | ||
3214 | /// <param name="high"></param> | ||
3215 | /// <returns></returns> | ||
3216 | public void osSetTerrainTextureHeight(int corner, double low, double high) | ||
3217 | { | ||
3218 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight"); | ||
3219 | |||
3220 | m_host.AddScriptLPS(1); | ||
3221 | //Check to make sure that the script's owner is the estate manager/master | ||
3222 | //World.Permissions.GenericEstatePermission( | ||
3223 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
3224 | { | ||
3225 | if (corner < 0 || corner > 3) | ||
3226 | return; | ||
3227 | |||
3228 | // estate module is required | ||
3229 | IEstateModule estate = World.RequestModuleInterface<IEstateModule>(); | ||
3230 | if (estate != null) | ||
3231 | estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high); | ||
3232 | } | ||
3233 | } | ||
3234 | |||
3235 | public void osForceAttachToAvatar(int attachmentPoint) | ||
3236 | { | ||
3237 | CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); | ||
3238 | |||
3239 | m_host.AddScriptLPS(1); | ||
3240 | |||
3241 | InitLSL(); | ||
3242 | ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); | ||
3243 | } | ||
3244 | |||
3245 | public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint) | ||
3246 | { | ||
3247 | CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory"); | ||
3248 | |||
3249 | m_host.AddScriptLPS(1); | ||
3250 | |||
3251 | ForceAttachToAvatarFromInventory(m_host.OwnerID, itemName, attachmentPoint); | ||
3252 | } | ||
3253 | |||
3254 | public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint) | ||
3255 | { | ||
3256 | CheckThreatLevel(ThreatLevel.Severe, "osForceAttachToOtherAvatarFromInventory"); | ||
3257 | |||
3258 | m_host.AddScriptLPS(1); | ||
3259 | |||
3260 | UUID avatarId; | ||
3261 | |||
3262 | if (!UUID.TryParse(rawAvatarId, out avatarId)) | ||
3263 | return; | ||
3264 | |||
3265 | ForceAttachToAvatarFromInventory(avatarId, itemName, attachmentPoint); | ||
3266 | } | ||
3267 | |||
3268 | public void ForceAttachToAvatarFromInventory(UUID avatarId, string itemName, int attachmentPoint) | ||
3269 | { | ||
3270 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | ||
3271 | |||
3272 | if (attachmentsModule == null) | ||
3273 | return; | ||
3274 | |||
3275 | InitLSL(); | ||
3276 | |||
3277 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); | ||
3278 | |||
3279 | if (item == null) | ||
3280 | { | ||
3281 | ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Could not find object '{0}'", itemName)); | ||
3282 | throw new Exception(String.Format("The inventory item '{0}' could not be found", itemName)); | ||
3283 | } | ||
3284 | |||
3285 | if (item.InvType != (int)InventoryType.Object) | ||
3286 | { | ||
3287 | // FIXME: Temporary null check for regression tests since they dont' have the infrastructure to set | ||
3288 | // up the api reference. | ||
3289 | if (m_LSL_Api != null) | ||
3290 | ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName)); | ||
3291 | |||
3292 | throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName)); | ||
3293 | |||
3294 | return; | ||
3295 | } | ||
3296 | |||
3297 | ScenePresence sp = World.GetScenePresence(avatarId); | ||
3298 | |||
3299 | if (sp == null) | ||
3300 | return; | ||
3301 | |||
3302 | InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID); | ||
3303 | |||
3304 | if (newItem == null) | ||
3305 | { | ||
3306 | m_log.ErrorFormat( | ||
3307 | "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}", | ||
3308 | itemName, m_host.Name, attachmentPoint, World.Name); | ||
3309 | |||
3310 | return; | ||
3311 | } | ||
3312 | |||
3313 | attachmentsModule.RezSingleAttachmentFromInventory(sp, newItem.ID, (uint)attachmentPoint); | ||
3314 | } | ||
3315 | |||
3316 | public void osForceDetachFromAvatar() | ||
3317 | { | ||
3318 | CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); | ||
3319 | |||
3320 | m_host.AddScriptLPS(1); | ||
3321 | |||
3322 | InitLSL(); | ||
3323 | ((LSL_Api)m_LSL_Api).DetachFromAvatar(); | ||
3324 | } | ||
3098 | } | 3325 | } |
3099 | } | 3326 | } |