diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 488 |
1 files changed, 393 insertions, 95 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index dcc85c4..e799714 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -62,6 +62,8 @@ using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | |||
62 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | 62 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; |
63 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 63 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
64 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | 64 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; |
65 | using PermissionMask = OpenSim.Framework.PermissionMask; | ||
66 | using OpenSim.Services.Connectors.Hypergrid; | ||
65 | 67 | ||
66 | namespace OpenSim.Region.ScriptEngine.Shared.Api | 68 | namespace OpenSim.Region.ScriptEngine.Shared.Api |
67 | { | 69 | { |
@@ -142,16 +144,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
142 | 144 | ||
143 | protected IUrlModule m_UrlModule = null; | 145 | protected IUrlModule m_UrlModule = null; |
144 | 146 | ||
145 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 147 | public void Initialize( |
148 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item) | ||
146 | { | 149 | { |
147 | m_ScriptEngine = ScriptEngine; | 150 | m_ScriptEngine = scriptEngine; |
148 | m_host = host; | 151 | m_host = host; |
149 | m_item = item; | 152 | m_item = item; |
150 | 153 | ||
151 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | 154 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); |
152 | 155 | ||
153 | if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | 156 | if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) |
157 | { | ||
154 | m_OSFunctionsEnabled = true; | 158 | m_OSFunctionsEnabled = true; |
159 | // m_log.Warn("[OSSL] OSSL FUNCTIONS ENABLED"); | ||
160 | } | ||
155 | 161 | ||
156 | m_ScriptDelayFactor = | 162 | m_ScriptDelayFactor = |
157 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); | 163 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); |
@@ -245,11 +251,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
245 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | 251 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); |
246 | } | 252 | } |
247 | 253 | ||
254 | // Returns of the function is allowed. Throws a script exception if not allowed. | ||
248 | public void CheckThreatLevel(ThreatLevel level, string function) | 255 | public void CheckThreatLevel(ThreatLevel level, string function) |
249 | { | 256 | { |
250 | if (!m_OSFunctionsEnabled) | 257 | if (!m_OSFunctionsEnabled) |
251 | OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws | 258 | OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws |
252 | 259 | ||
260 | string reasonWhyNot = CheckThreatLevelTest(level, function); | ||
261 | if (!String.IsNullOrEmpty(reasonWhyNot)) | ||
262 | { | ||
263 | OSSLError(reasonWhyNot); | ||
264 | } | ||
265 | } | ||
266 | |||
267 | // Check to see if function is allowed. Returns an empty string if function permitted | ||
268 | // or a string explaining why this function can't be used. | ||
269 | private string CheckThreatLevelTest(ThreatLevel level, string function) | ||
270 | { | ||
253 | if (!m_FunctionPerms.ContainsKey(function)) | 271 | if (!m_FunctionPerms.ContainsKey(function)) |
254 | { | 272 | { |
255 | FunctionPerms perms = new FunctionPerms(); | 273 | FunctionPerms perms = new FunctionPerms(); |
@@ -329,10 +347,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
329 | { | 347 | { |
330 | // Allow / disallow by threat level | 348 | // Allow / disallow by threat level |
331 | if (level > m_MaxThreatLevel) | 349 | if (level > m_MaxThreatLevel) |
332 | OSSLError( | 350 | return |
333 | String.Format( | 351 | String.Format( |
334 | "{0} permission denied. Allowed threat level is {1} but function threat level is {2}.", | 352 | "{0} permission denied. Allowed threat level is {1} but function threat level is {2}.", |
335 | function, m_MaxThreatLevel, level)); | 353 | function, m_MaxThreatLevel, level); |
336 | } | 354 | } |
337 | else | 355 | else |
338 | { | 356 | { |
@@ -342,7 +360,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
342 | if (m_FunctionPerms[function].AllowedOwners.Contains(m_host.OwnerID)) | 360 | if (m_FunctionPerms[function].AllowedOwners.Contains(m_host.OwnerID)) |
343 | { | 361 | { |
344 | // prim owner is in the list of allowed owners | 362 | // prim owner is in the list of allowed owners |
345 | return; | 363 | return String.Empty; |
346 | } | 364 | } |
347 | 365 | ||
348 | UUID ownerID = m_item.OwnerID; | 366 | UUID ownerID = m_item.OwnerID; |
@@ -350,22 +368,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
350 | //OSSL only may be used if object is in the same group as the parcel | 368 | //OSSL only may be used if object is in the same group as the parcel |
351 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) | 369 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) |
352 | { | 370 | { |
353 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); | 371 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); |
354 | 372 | ||
355 | if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero) | 373 | if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero) |
356 | { | 374 | { |
357 | return; | 375 | return String.Empty; |
358 | } | 376 | } |
359 | } | 377 | } |
360 | 378 | ||
361 | //Only Parcelowners may use the function | 379 | //Only Parcelowners may use the function |
362 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_OWNER")) | 380 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_OWNER")) |
363 | { | 381 | { |
364 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); | 382 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); |
365 | 383 | ||
366 | if (land.LandData.OwnerID == ownerID) | 384 | if (land.LandData.OwnerID == ownerID) |
367 | { | 385 | { |
368 | return; | 386 | return String.Empty; |
369 | } | 387 | } |
370 | } | 388 | } |
371 | 389 | ||
@@ -375,7 +393,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
375 | //Only Estate Managers may use the function | 393 | //Only Estate Managers may use the function |
376 | if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) | 394 | if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) |
377 | { | 395 | { |
378 | return; | 396 | return String.Empty; |
379 | } | 397 | } |
380 | } | 398 | } |
381 | 399 | ||
@@ -384,25 +402,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
384 | { | 402 | { |
385 | if (World.RegionInfo.EstateSettings.EstateOwner == ownerID) | 403 | if (World.RegionInfo.EstateSettings.EstateOwner == ownerID) |
386 | { | 404 | { |
387 | return; | 405 | return String.Empty; |
388 | } | 406 | } |
389 | } | 407 | } |
390 | 408 | ||
391 | if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID)) | 409 | if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID)) |
392 | OSSLError( | 410 | return( |
393 | 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.", | 411 | 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.", |
394 | function)); | 412 | function)); |
395 | 413 | ||
396 | if (m_item.CreatorID != ownerID) | 414 | if (m_item.CreatorID != ownerID) |
397 | { | 415 | { |
398 | if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0) | 416 | if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0) |
399 | OSSLError( | 417 | return String.Format("{0} permission denied. Script permissions error.", function); |
400 | String.Format("{0} permission denied. Script permissions error.", | ||
401 | function)); | ||
402 | 418 | ||
403 | } | 419 | } |
404 | } | 420 | } |
405 | } | 421 | } |
422 | return String.Empty; | ||
406 | } | 423 | } |
407 | 424 | ||
408 | internal void OSSLDeprecated(string function, string replacement) | 425 | internal void OSSLDeprecated(string function, string replacement) |
@@ -437,7 +454,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
437 | { | 454 | { |
438 | m_host.AddScriptLPS(1); | 455 | m_host.AddScriptLPS(1); |
439 | 456 | ||
440 | if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0) | 457 | if (x > (World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0) |
441 | OSSLError("osSetTerrainHeight: Coordinate out of bounds"); | 458 | OSSLError("osSetTerrainHeight: Coordinate out of bounds"); |
442 | 459 | ||
443 | if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0))) | 460 | if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0))) |
@@ -467,7 +484,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
467 | private LSL_Float GetTerrainHeight(int x, int y) | 484 | private LSL_Float GetTerrainHeight(int x, int y) |
468 | { | 485 | { |
469 | m_host.AddScriptLPS(1); | 486 | m_host.AddScriptLPS(1); |
470 | if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0) | 487 | if (x > (World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0) |
471 | OSSLError("osGetTerrainHeight: Coordinate out of bounds"); | 488 | OSSLError("osGetTerrainHeight: Coordinate out of bounds"); |
472 | 489 | ||
473 | return World.Heightmap[x, y]; | 490 | return World.Heightmap[x, y]; |
@@ -777,9 +794,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
777 | 794 | ||
778 | // We will launch the teleport on a new thread so that when the script threads are terminated | 795 | // We will launch the teleport on a new thread so that when the script threads are terminated |
779 | // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. | 796 | // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. |
780 | Util.FireAndForget(o => World.RequestTeleportLocation( | 797 | Util.FireAndForget( |
781 | presence.ControllingClient, regionName, position, | 798 | o => World.RequestTeleportLocation( |
782 | lookat, (uint)TPFlags.ViaLocation)); | 799 | presence.ControllingClient, regionName, position, |
800 | lookat, (uint)TPFlags.ViaLocation), | ||
801 | null, "OSSL_Api.TeleportAgentByRegionCoords"); | ||
783 | 802 | ||
784 | ScriptSleep(5000); | 803 | ScriptSleep(5000); |
785 | 804 | ||
@@ -801,7 +820,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
801 | private void TeleportAgent(string agent, int regionX, int regionY, | 820 | private void TeleportAgent(string agent, int regionX, int regionY, |
802 | LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) | 821 | LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) |
803 | { | 822 | { |
804 | ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); | 823 | // ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); |
824 | ulong regionHandle = Util.RegionLocToHandle((uint)regionX, (uint)regionY); | ||
805 | 825 | ||
806 | m_host.AddScriptLPS(1); | 826 | m_host.AddScriptLPS(1); |
807 | UUID agentId = new UUID(); | 827 | UUID agentId = new UUID(); |
@@ -822,9 +842,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
822 | 842 | ||
823 | // We will launch the teleport on a new thread so that when the script threads are terminated | 843 | // We will launch the teleport on a new thread so that when the script threads are terminated |
824 | // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. | 844 | // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. |
825 | Util.FireAndForget(o => World.RequestTeleportLocation( | 845 | Util.FireAndForget( |
826 | presence.ControllingClient, regionHandle, | 846 | o => World.RequestTeleportLocation( |
827 | position, lookat, (uint)TPFlags.ViaLocation)); | 847 | presence.ControllingClient, regionHandle, |
848 | position, lookat, (uint)TPFlags.ViaLocation), | ||
849 | null, "OSSL_Api.TeleportAgentByRegionName"); | ||
828 | 850 | ||
829 | ScriptSleep(5000); | 851 | ScriptSleep(5000); |
830 | 852 | ||
@@ -859,6 +881,59 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
859 | TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat, true); | 881 | TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat, true); |
860 | } | 882 | } |
861 | 883 | ||
884 | ///<summary> | ||
885 | /// Allows a script IN the target prim to force an avatar to sit on it using normal methods | ||
886 | /// as if called by the client. | ||
887 | /// Silent fail if agent (or target if overloaded) not found. | ||
888 | /// Does work if passed key (or keys if overloaded). | ||
889 | /// </summary> | ||
890 | /// <param name="avatar"></param> | ||
891 | public void osForceOtherSit(string avatar) | ||
892 | { | ||
893 | CheckThreatLevel(ThreatLevel.VeryHigh, "osForceOtherSit"); | ||
894 | |||
895 | m_host.AddScriptLPS(1); | ||
896 | |||
897 | ForceSit(avatar, m_host.UUID); | ||
898 | } | ||
899 | |||
900 | /// <summary> | ||
901 | /// Overload method of osForceOtherSit(string avatar) to allow a script NOT in the target prim to force | ||
902 | /// an avatar to sit on the target prim using normal methods as if called by the client. | ||
903 | /// </summary> | ||
904 | /// <param name="avatar"></param> | ||
905 | /// <param name="target"></param> | ||
906 | public void osForceOtherSit(string avatar, string target) | ||
907 | { | ||
908 | CheckThreatLevel(ThreatLevel.VeryHigh, "osForceOtherSit"); | ||
909 | |||
910 | m_host.AddScriptLPS(1); | ||
911 | |||
912 | UUID targetID = new UUID(target); | ||
913 | |||
914 | ForceSit(avatar, targetID); | ||
915 | } | ||
916 | |||
917 | public void ForceSit(string avatar, UUID targetID) | ||
918 | { | ||
919 | UUID agentID; | ||
920 | |||
921 | if (!UUID.TryParse(avatar, out agentID)) | ||
922 | return; | ||
923 | |||
924 | ScenePresence presence = World.GetScenePresence(agentID); | ||
925 | |||
926 | SceneObjectPart part = World.GetSceneObjectPart(targetID); | ||
927 | |||
928 | if (presence != null && | ||
929 | part != null && | ||
930 | part.SitTargetAvatar == UUID.Zero) | ||
931 | presence.HandleAgentRequestSit(presence.ControllingClient, | ||
932 | agentID, | ||
933 | targetID, | ||
934 | part.SitTargetPosition); | ||
935 | } | ||
936 | |||
862 | // Functions that get information from the agent itself. | 937 | // Functions that get information from the agent itself. |
863 | // | 938 | // |
864 | // osGetAgentIP - this is used to determine the IP address of | 939 | // osGetAgentIP - this is used to determine the IP address of |
@@ -1205,12 +1280,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1205 | sunHour += 24.0; | 1280 | sunHour += 24.0; |
1206 | 1281 | ||
1207 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; | 1282 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; |
1208 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 | 1283 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 |
1209 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; | 1284 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; |
1210 | World.RegionInfo.RegionSettings.Save(); | 1285 | World.RegionInfo.RegionSettings.Save(); |
1211 | 1286 | ||
1212 | World.EventManager.TriggerEstateToolsSunUpdate( | 1287 | World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle); |
1213 | World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); | ||
1214 | } | 1288 | } |
1215 | 1289 | ||
1216 | /// <summary> | 1290 | /// <summary> |
@@ -1233,10 +1307,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1233 | World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; | 1307 | World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; |
1234 | World.RegionInfo.EstateSettings.SunPosition = sunHour; | 1308 | World.RegionInfo.EstateSettings.SunPosition = sunHour; |
1235 | World.RegionInfo.EstateSettings.FixedSun = sunFixed; | 1309 | World.RegionInfo.EstateSettings.FixedSun = sunFixed; |
1236 | World.RegionInfo.EstateSettings.Save(); | 1310 | World.EstateDataService.StoreEstateSettings(World.RegionInfo.EstateSettings); |
1237 | 1311 | ||
1238 | World.EventManager.TriggerEstateToolsSunUpdate( | 1312 | World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle); |
1239 | World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); | ||
1240 | } | 1313 | } |
1241 | 1314 | ||
1242 | /// <summary> | 1315 | /// <summary> |
@@ -1492,8 +1565,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1492 | 1565 | ||
1493 | m_host.AddScriptLPS(1); | 1566 | m_host.AddScriptLPS(1); |
1494 | 1567 | ||
1495 | ILandObject land | 1568 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); |
1496 | = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); | ||
1497 | 1569 | ||
1498 | if (land.LandData.OwnerID != m_host.OwnerID) | 1570 | if (land.LandData.OwnerID != m_host.OwnerID) |
1499 | return; | 1571 | return; |
@@ -1509,8 +1581,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1509 | 1581 | ||
1510 | m_host.AddScriptLPS(1); | 1582 | m_host.AddScriptLPS(1); |
1511 | 1583 | ||
1512 | ILandObject land | 1584 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); |
1513 | = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); | ||
1514 | 1585 | ||
1515 | if (land.LandData.OwnerID != m_host.OwnerID) | 1586 | if (land.LandData.OwnerID != m_host.OwnerID) |
1516 | { | 1587 | { |
@@ -1560,6 +1631,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1560 | } | 1631 | } |
1561 | } | 1632 | } |
1562 | 1633 | ||
1634 | public LSL_Integer osCheckODE() | ||
1635 | { | ||
1636 | m_host.AddScriptLPS(1); | ||
1637 | LSL_Integer ret = 0; // false | ||
1638 | if (m_ScriptEngine.World.PhysicsScene != null) | ||
1639 | { | ||
1640 | string physEngine = m_ScriptEngine.World.PhysicsScene.EngineType; | ||
1641 | if (physEngine == "OpenDynamicsEngine") | ||
1642 | { | ||
1643 | ret = 1; // true | ||
1644 | } | ||
1645 | } | ||
1646 | return ret; | ||
1647 | } | ||
1648 | |||
1649 | public string osGetPhysicsEngineType() | ||
1650 | { | ||
1651 | // High because it can be used to target attacks to known weaknesses | ||
1652 | // This would allow a new class of griefer scripts that don't even | ||
1653 | // require their user to know what they are doing (see script | ||
1654 | // kiddie) | ||
1655 | // Because it would be nice if scripts didn't blow up if the information | ||
1656 | // about the physics engine, this function returns an empty string if | ||
1657 | // the user does not have permission to see it. This as opposed to | ||
1658 | // throwing an exception. | ||
1659 | m_host.AddScriptLPS(1); | ||
1660 | string ret = String.Empty; | ||
1661 | if (String.IsNullOrEmpty(CheckThreatLevelTest(ThreatLevel.High, "osGetPhysicsEngineType"))) | ||
1662 | { | ||
1663 | if (m_ScriptEngine.World.PhysicsScene != null) | ||
1664 | { | ||
1665 | ret = m_ScriptEngine.World.PhysicsScene.EngineType; | ||
1666 | // An old physics engine might have an uninitialized engine type | ||
1667 | if (ret == null) | ||
1668 | ret = "unknown"; | ||
1669 | } | ||
1670 | } | ||
1671 | |||
1672 | return ret; | ||
1673 | } | ||
1674 | |||
1563 | public string osGetSimulatorVersion() | 1675 | public string osGetSimulatorVersion() |
1564 | { | 1676 | { |
1565 | // High because it can be used to target attacks to known weaknesses | 1677 | // High because it can be used to target attacks to known weaknesses |
@@ -1732,13 +1844,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1732 | // Create new asset | 1844 | // Create new asset |
1733 | AssetBase asset = new AssetBase(UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); | 1845 | AssetBase asset = new AssetBase(UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); |
1734 | asset.Description = description; | 1846 | asset.Description = description; |
1847 | byte[] a; | ||
1848 | byte[] b; | ||
1849 | byte[] c; | ||
1850 | |||
1851 | b = Util.UTF8.GetBytes(data); | ||
1735 | 1852 | ||
1736 | int textLength = data.Length; | 1853 | a = Util.UTF8.GetBytes( |
1737 | data | 1854 | "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " + b.Length.ToString() + "\n"); |
1738 | = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " | ||
1739 | + textLength.ToString() + "\n" + data + "}\n"; | ||
1740 | 1855 | ||
1741 | asset.Data = Util.UTF8.GetBytes(data); | 1856 | c = Util.UTF8.GetBytes("}"); |
1857 | |||
1858 | byte[] d = new byte[a.Length + b.Length + c.Length]; | ||
1859 | Buffer.BlockCopy(a, 0, d, 0, a.Length); | ||
1860 | Buffer.BlockCopy(b, 0, d, a.Length, b.Length); | ||
1861 | Buffer.BlockCopy(c, 0, d, a.Length + b.Length, c.Length); | ||
1862 | |||
1863 | asset.Data = d; | ||
1742 | World.AssetService.Store(asset); | 1864 | World.AssetService.Store(asset); |
1743 | 1865 | ||
1744 | // Create Task Entry | 1866 | // Create Task Entry |
@@ -1753,8 +1875,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1753 | taskItem.InvType = (int)InventoryType.Notecard; | 1875 | taskItem.InvType = (int)InventoryType.Notecard; |
1754 | taskItem.OwnerID = m_host.OwnerID; | 1876 | taskItem.OwnerID = m_host.OwnerID; |
1755 | taskItem.CreatorID = m_host.OwnerID; | 1877 | taskItem.CreatorID = m_host.OwnerID; |
1756 | taskItem.BasePermissions = (uint)PermissionMask.All; | 1878 | taskItem.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export; |
1757 | taskItem.CurrentPermissions = (uint)PermissionMask.All; | 1879 | taskItem.CurrentPermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export; |
1758 | taskItem.EveryonePermissions = 0; | 1880 | taskItem.EveryonePermissions = 0; |
1759 | taskItem.NextPermissions = (uint)PermissionMask.All; | 1881 | taskItem.NextPermissions = (uint)PermissionMask.All; |
1760 | taskItem.GroupID = m_host.GroupID; | 1882 | taskItem.GroupID = m_host.GroupID; |
@@ -1833,8 +1955,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1833 | if (a == null) | 1955 | if (a == null) |
1834 | return UUID.Zero; | 1956 | return UUID.Zero; |
1835 | 1957 | ||
1836 | string data = Encoding.UTF8.GetString(a.Data); | 1958 | NotecardCache.Cache(assetID, a.Data); |
1837 | NotecardCache.Cache(assetID, data); | ||
1838 | }; | 1959 | }; |
1839 | 1960 | ||
1840 | return assetID; | 1961 | return assetID; |
@@ -1932,15 +2053,51 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1932 | CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); | 2053 | CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); |
1933 | m_host.AddScriptLPS(1); | 2054 | m_host.AddScriptLPS(1); |
1934 | 2055 | ||
1935 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname); | 2056 | IUserManagement userManager = World.RequestModuleInterface<IUserManagement>(); |
1936 | if (null == account) | 2057 | if (userManager == null) |
1937 | { | 2058 | { |
1938 | return UUID.Zero.ToString(); | 2059 | OSSLShoutError("osAvatarName2Key: UserManagement module not available"); |
2060 | return string.Empty; | ||
2061 | } | ||
2062 | |||
2063 | // Check if the user is already cached | ||
2064 | |||
2065 | UUID userID = userManager.GetUserIdByName(firstname, lastname); | ||
2066 | if (userID != UUID.Zero) | ||
2067 | return userID.ToString(); | ||
2068 | |||
2069 | // Query for the user | ||
2070 | |||
2071 | String realFirstName; String realLastName; String serverURI; | ||
2072 | if (Util.ParseForeignAvatarName(firstname, lastname, out realFirstName, out realLastName, out serverURI)) | ||
2073 | { | ||
2074 | try | ||
2075 | { | ||
2076 | UserAgentServiceConnector userConnection = new UserAgentServiceConnector(serverURI, true); | ||
2077 | |||
2078 | if (userConnection != null) | ||
2079 | { | ||
2080 | userID = userConnection.GetUUID(realFirstName, realLastName); | ||
2081 | if (userID != UUID.Zero) | ||
2082 | { | ||
2083 | userManager.AddUser(userID, realFirstName, realLastName, serverURI); | ||
2084 | return userID.ToString(); | ||
2085 | } | ||
2086 | } | ||
2087 | } | ||
2088 | catch (Exception /*e*/) | ||
2089 | { | ||
2090 | // m_log.Warn("[osAvatarName2Key] UserAgentServiceConnector - Unable to connect to destination grid ", e); | ||
2091 | } | ||
1939 | } | 2092 | } |
1940 | else | 2093 | else |
1941 | { | 2094 | { |
1942 | return account.PrincipalID.ToString(); | 2095 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname); |
2096 | if (account != null) | ||
2097 | return account.PrincipalID.ToString(); | ||
1943 | } | 2098 | } |
2099 | |||
2100 | return UUID.Zero.ToString(); | ||
1944 | } | 2101 | } |
1945 | 2102 | ||
1946 | public string osKey2Name(string id) | 2103 | public string osKey2Name(string id) |
@@ -1953,19 +2110,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1953 | if (UUID.TryParse(id, out key)) | 2110 | if (UUID.TryParse(id, out key)) |
1954 | { | 2111 | { |
1955 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, key); | 2112 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, key); |
1956 | if (null == account) | 2113 | if (account != null) |
1957 | { | ||
1958 | return ""; | ||
1959 | } | ||
1960 | else | ||
1961 | { | ||
1962 | return account.Name; | 2114 | return account.Name; |
2115 | |||
2116 | if (m_ScriptEngine.World.GridUserService != null) | ||
2117 | { | ||
2118 | GridUserInfo uInfo = m_ScriptEngine.World.GridUserService.GetGridUserInfo(key.ToString()); | ||
2119 | |||
2120 | if (uInfo != null) | ||
2121 | { | ||
2122 | UUID userUUID; String gridURL; String firstName; String lastName; String tmp; | ||
2123 | |||
2124 | if (Util.ParseUniversalUserIdentifier(uInfo.UserID, out userUUID, out gridURL, out firstName, out lastName, out tmp)) | ||
2125 | { | ||
2126 | string grid = new Uri(gridURL).Authority; | ||
2127 | return firstName + "." + lastName + " @" + grid; | ||
2128 | } | ||
2129 | } | ||
1963 | } | 2130 | } |
1964 | } | 2131 | } |
1965 | else | 2132 | |
1966 | { | 2133 | return ""; |
1967 | return ""; | ||
1968 | } | ||
1969 | } | 2134 | } |
1970 | 2135 | ||
1971 | private enum InfoType | 2136 | private enum InfoType |
@@ -2101,9 +2266,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2101 | CheckThreatLevel(ThreatLevel.Moderate, "osGetGridHomeURI"); | 2266 | CheckThreatLevel(ThreatLevel.Moderate, "osGetGridHomeURI"); |
2102 | m_host.AddScriptLPS(1); | 2267 | m_host.AddScriptLPS(1); |
2103 | 2268 | ||
2104 | string HomeURI = String.Empty; | ||
2105 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2269 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2270 | string HomeURI = Util.GetConfigVarFromSections<string>(config, "HomeURI", | ||
2271 | new string[] { "Startup", "Hypergrid" }, String.Empty); | ||
2106 | 2272 | ||
2273 | if (!string.IsNullOrEmpty(HomeURI)) | ||
2274 | return HomeURI; | ||
2275 | |||
2276 | // Legacy. Remove soon! | ||
2107 | if (config.Configs["LoginService"] != null) | 2277 | if (config.Configs["LoginService"] != null) |
2108 | HomeURI = config.Configs["LoginService"].GetString("SRV_HomeURI", HomeURI); | 2278 | HomeURI = config.Configs["LoginService"].GetString("SRV_HomeURI", HomeURI); |
2109 | 2279 | ||
@@ -2118,9 +2288,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2118 | CheckThreatLevel(ThreatLevel.Moderate, "osGetGridGatekeeperURI"); | 2288 | CheckThreatLevel(ThreatLevel.Moderate, "osGetGridGatekeeperURI"); |
2119 | m_host.AddScriptLPS(1); | 2289 | m_host.AddScriptLPS(1); |
2120 | 2290 | ||
2121 | string gatekeeperURI = String.Empty; | ||
2122 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2291 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2292 | string gatekeeperURI = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", | ||
2293 | new string[] { "Startup", "Hypergrid" }, String.Empty); | ||
2294 | |||
2295 | if (!string.IsNullOrEmpty(gatekeeperURI)) | ||
2296 | return gatekeeperURI; | ||
2123 | 2297 | ||
2298 | // Legacy. Remove soon! | ||
2124 | if (config.Configs["GridService"] != null) | 2299 | if (config.Configs["GridService"] != null) |
2125 | gatekeeperURI = config.Configs["GridService"].GetString("Gatekeeper", gatekeeperURI); | 2300 | gatekeeperURI = config.Configs["GridService"].GetString("Gatekeeper", gatekeeperURI); |
2126 | 2301 | ||
@@ -2144,6 +2319,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2144 | return retval; | 2319 | return retval; |
2145 | } | 2320 | } |
2146 | 2321 | ||
2322 | public string osGetAvatarHomeURI(string uuid) | ||
2323 | { | ||
2324 | CheckThreatLevel(ThreatLevel.Low, "osGetAvatarHomeURI"); | ||
2325 | m_host.AddScriptLPS(1); | ||
2326 | |||
2327 | IUserManagement userManager = m_ScriptEngine.World.RequestModuleInterface<IUserManagement>(); | ||
2328 | string returnValue = ""; | ||
2329 | |||
2330 | if (userManager != null) | ||
2331 | { | ||
2332 | returnValue = userManager.GetUserServerURL(new UUID(uuid), "HomeURI"); | ||
2333 | } | ||
2334 | |||
2335 | if (returnValue == "") | ||
2336 | { | ||
2337 | IConfigSource config = m_ScriptEngine.ConfigSource; | ||
2338 | returnValue = Util.GetConfigVarFromSections<string>(config, "HomeURI", | ||
2339 | new string[] { "Startup", "Hypergrid" }, String.Empty); | ||
2340 | |||
2341 | if (!string.IsNullOrEmpty(returnValue)) | ||
2342 | return returnValue; | ||
2343 | |||
2344 | // Legacy. Remove soon! | ||
2345 | if (config.Configs["LoginService"] != null) | ||
2346 | returnValue = config.Configs["LoginService"].GetString("SRV_HomeURI", returnValue); | ||
2347 | |||
2348 | if (String.IsNullOrEmpty(returnValue)) | ||
2349 | returnValue = GridUserInfo(InfoType.Home); | ||
2350 | } | ||
2351 | |||
2352 | return returnValue; | ||
2353 | } | ||
2354 | |||
2147 | public LSL_String osFormatString(string str, LSL_List strings) | 2355 | public LSL_String osFormatString(string str, LSL_List strings) |
2148 | { | 2356 | { |
2149 | CheckThreatLevel(ThreatLevel.VeryLow, "osFormatString"); | 2357 | CheckThreatLevel(ThreatLevel.VeryLow, "osFormatString"); |
@@ -2265,14 +2473,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2265 | // on the ILSL_Api interface. | 2473 | // on the ILSL_Api interface. |
2266 | LSL_Api LSL_Api = (LSL_Api)m_LSL_Api; | 2474 | LSL_Api LSL_Api = (LSL_Api)m_LSL_Api; |
2267 | LSL_List retVal = new LSL_List(); | 2475 | LSL_List retVal = new LSL_List(); |
2268 | LSL_List remaining = null; | 2476 | LSL_List remaining = new LSL_List(); |
2269 | List<SceneObjectPart> parts = LSL_Api.GetLinkParts(linknumber); | 2477 | List<SceneObjectPart> parts = LSL_Api.GetLinkParts(linknumber); |
2270 | foreach (SceneObjectPart part in parts) | 2478 | foreach (SceneObjectPart part in parts) |
2271 | { | 2479 | { |
2272 | remaining = LSL_Api.GetPrimParams(part, rules, ref retVal); | 2480 | remaining = LSL_Api.GetPrimParams(part, rules, ref retVal); |
2273 | } | 2481 | } |
2274 | 2482 | ||
2275 | while (remaining != null && remaining.Length > 2) | 2483 | while (remaining.Length > 2) |
2276 | { | 2484 | { |
2277 | linknumber = remaining.GetLSLIntegerItem(0); | 2485 | linknumber = remaining.GetLSLIntegerItem(0); |
2278 | rules = remaining.GetSublist(1, -1); | 2486 | rules = remaining.GetSublist(1, -1); |
@@ -2284,6 +2492,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2284 | return retVal; | 2492 | return retVal; |
2285 | } | 2493 | } |
2286 | 2494 | ||
2495 | public void osForceCreateLink(string target, int parent) | ||
2496 | { | ||
2497 | CheckThreatLevel(ThreatLevel.VeryLow, "osForceCreateLink"); | ||
2498 | |||
2499 | m_host.AddScriptLPS(1); | ||
2500 | |||
2501 | InitLSL(); | ||
2502 | ((LSL_Api)m_LSL_Api).CreateLink(target, parent); | ||
2503 | } | ||
2504 | |||
2505 | public void osForceBreakLink(int linknum) | ||
2506 | { | ||
2507 | CheckThreatLevel(ThreatLevel.VeryLow, "osForceBreakLink"); | ||
2508 | |||
2509 | m_host.AddScriptLPS(1); | ||
2510 | |||
2511 | InitLSL(); | ||
2512 | ((LSL_Api)m_LSL_Api).BreakLink(linknum); | ||
2513 | } | ||
2514 | |||
2515 | public void osForceBreakAllLinks() | ||
2516 | { | ||
2517 | CheckThreatLevel(ThreatLevel.VeryLow, "osForceBreakAllLinks"); | ||
2518 | |||
2519 | m_host.AddScriptLPS(1); | ||
2520 | |||
2521 | InitLSL(); | ||
2522 | ((LSL_Api)m_LSL_Api).BreakAllLinks(); | ||
2523 | } | ||
2524 | |||
2287 | public LSL_Integer osIsNpc(LSL_Key npc) | 2525 | public LSL_Integer osIsNpc(LSL_Key npc) |
2288 | { | 2526 | { |
2289 | CheckThreatLevel(ThreatLevel.None, "osIsNpc"); | 2527 | CheckThreatLevel(ThreatLevel.None, "osIsNpc"); |
@@ -2469,13 +2707,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2469 | ScenePresence sp = World.GetScenePresence(npcId); | 2707 | ScenePresence sp = World.GetScenePresence(npcId); |
2470 | 2708 | ||
2471 | if (sp != null) | 2709 | if (sp != null) |
2472 | { | 2710 | return new LSL_Vector(sp.AbsolutePosition); |
2473 | Vector3 pos = sp.AbsolutePosition; | ||
2474 | return new LSL_Vector(pos.X, pos.Y, pos.Z); | ||
2475 | } | ||
2476 | } | 2711 | } |
2477 | 2712 | ||
2478 | return new LSL_Vector(0, 0, 0); | 2713 | return Vector3.Zero; |
2479 | } | 2714 | } |
2480 | 2715 | ||
2481 | public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos) | 2716 | public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos) |
@@ -2532,21 +2767,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2532 | { | 2767 | { |
2533 | UUID npcId; | 2768 | UUID npcId; |
2534 | if (!UUID.TryParse(npc.m_string, out npcId)) | 2769 | if (!UUID.TryParse(npc.m_string, out npcId)) |
2535 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | 2770 | return new LSL_Rotation(Quaternion.Identity); |
2536 | 2771 | ||
2537 | if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) | 2772 | if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) |
2538 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | 2773 | return new LSL_Rotation(Quaternion.Identity); |
2539 | 2774 | ||
2540 | ScenePresence sp = World.GetScenePresence(npcId); | 2775 | ScenePresence sp = World.GetScenePresence(npcId); |
2541 | 2776 | ||
2542 | if (sp != null) | 2777 | if (sp != null) |
2543 | { | 2778 | return new LSL_Rotation(sp.GetWorldRotation()); |
2544 | Quaternion rot = sp.Rotation; | ||
2545 | return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | ||
2546 | } | ||
2547 | } | 2779 | } |
2548 | 2780 | ||
2549 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | 2781 | return Quaternion.Identity; |
2550 | } | 2782 | } |
2551 | 2783 | ||
2552 | public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation) | 2784 | public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation) |
@@ -2824,6 +3056,51 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2824 | 3056 | ||
2825 | return SaveAppearanceToNotecard(avatarId, notecard); | 3057 | return SaveAppearanceToNotecard(avatarId, notecard); |
2826 | } | 3058 | } |
3059 | |||
3060 | /// <summary> | ||
3061 | /// Get the gender as specified in avatar appearance for a given avatar key | ||
3062 | /// </summary> | ||
3063 | /// <param name="rawAvatarId"></param> | ||
3064 | /// <returns>"male" or "female" or "unknown"</returns> | ||
3065 | public LSL_String osGetGender(LSL_Key rawAvatarId) | ||
3066 | { | ||
3067 | CheckThreatLevel(ThreatLevel.None, "osGetGender"); | ||
3068 | m_host.AddScriptLPS(1); | ||
3069 | |||
3070 | UUID avatarId; | ||
3071 | if (!UUID.TryParse(rawAvatarId, out avatarId)) | ||
3072 | return new LSL_String("unknown"); | ||
3073 | |||
3074 | ScenePresence sp = World.GetScenePresence(avatarId); | ||
3075 | |||
3076 | if (sp == null || sp.IsChildAgent || sp.Appearance == null || sp.Appearance.VisualParams == null) | ||
3077 | return new LSL_String("unknown"); | ||
3078 | |||
3079 | // find the index of "shape" parameter "male" | ||
3080 | int vpShapeMaleIndex = 0; | ||
3081 | bool indexFound = false; | ||
3082 | VisualParam param = new VisualParam(); | ||
3083 | foreach(var vpEntry in VisualParams.Params) | ||
3084 | { | ||
3085 | param = vpEntry.Value; | ||
3086 | if (param.Name == "male" && param.Wearable == "shape") | ||
3087 | { | ||
3088 | indexFound = true; | ||
3089 | break; | ||
3090 | } | ||
3091 | |||
3092 | if (param.Group == 0) | ||
3093 | vpShapeMaleIndex++; | ||
3094 | } | ||
3095 | |||
3096 | if (!indexFound) | ||
3097 | return new LSL_String("unknown"); | ||
3098 | |||
3099 | float vpShapeMale = Utils.ByteToFloat(sp.Appearance.VisualParams[vpShapeMaleIndex], param.MinValue, param.MaxValue); | ||
3100 | |||
3101 | bool isMale = vpShapeMale > 0.5f; | ||
3102 | return new LSL_String(isMale ? "male" : "female"); | ||
3103 | } | ||
2827 | 3104 | ||
2828 | /// <summary> | 3105 | /// <summary> |
2829 | /// Get current region's map texture UUID | 3106 | /// Get current region's map texture UUID |
@@ -2887,6 +3164,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2887 | return ret; | 3164 | return ret; |
2888 | } | 3165 | } |
2889 | 3166 | ||
3167 | public LSL_Vector osGetRegionSize() | ||
3168 | { | ||
3169 | CheckThreatLevel(ThreatLevel.None, "osGetRegionSize"); | ||
3170 | m_host.AddScriptLPS(1); | ||
3171 | |||
3172 | bool isMegaregion; | ||
3173 | IRegionCombinerModule rcMod = World.RequestModuleInterface<IRegionCombinerModule>(); | ||
3174 | if (rcMod != null) | ||
3175 | isMegaregion = rcMod.IsRootForMegaregion(World.RegionInfo.RegionID); | ||
3176 | else | ||
3177 | isMegaregion = false; | ||
3178 | |||
3179 | if (isMegaregion) | ||
3180 | { | ||
3181 | Vector2 size = rcMod.GetSizeOfMegaregion(World.RegionInfo.RegionID); | ||
3182 | return new LSL_Vector(size.X, size.Y, Constants.RegionHeight); | ||
3183 | } | ||
3184 | else | ||
3185 | { | ||
3186 | Scene scene = m_ScriptEngine.World; | ||
3187 | GridRegion region = scene.GridService.GetRegionByUUID(UUID.Zero, World.RegionInfo.RegionID); | ||
3188 | return new LSL_Vector((float)region.RegionSizeX, (float)region.RegionSizeX, Constants.RegionHeight); | ||
3189 | } | ||
3190 | } | ||
3191 | |||
2890 | public int osGetSimulatorMemory() | 3192 | public int osGetSimulatorMemory() |
2891 | { | 3193 | { |
2892 | CheckThreatLevel(ThreatLevel.Moderate, "osGetSimulatorMemory"); | 3194 | CheckThreatLevel(ThreatLevel.Moderate, "osGetSimulatorMemory"); |
@@ -2925,7 +3227,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2925 | sp.ControllingClient.Kick(alert); | 3227 | sp.ControllingClient.Kick(alert); |
2926 | 3228 | ||
2927 | // ...and close on our side | 3229 | // ...and close on our side |
2928 | sp.Scene.IncomingCloseAgent(sp.UUID, false); | 3230 | sp.Scene.CloseAgent(sp.UUID, false); |
2929 | } | 3231 | } |
2930 | }); | 3232 | }); |
2931 | } | 3233 | } |
@@ -2976,20 +3278,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2976 | 3278 | ||
2977 | UUID avatarId = new UUID(avatar); | 3279 | UUID avatarId = new UUID(avatar); |
2978 | ScenePresence presence = World.GetScenePresence(avatarId); | 3280 | ScenePresence presence = World.GetScenePresence(avatarId); |
2979 | Vector3 pos = m_host.GetWorldPosition(); | 3281 | |
2980 | bool result = World.ScriptDanger(m_host.LocalId, new Vector3((float)pos.X, (float)pos.Y, (float)pos.Z)); | 3282 | if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) |
2981 | if (result) | ||
2982 | { | 3283 | { |
2983 | if (presence != null) | 3284 | float health = presence.Health; |
2984 | { | 3285 | health += (float)healing; |
2985 | float health = presence.Health; | 3286 | |
2986 | health += (float)healing; | 3287 | if (health >= 100) |
2987 | if (health >= 100) | 3288 | health = 100; |
2988 | { | 3289 | |
2989 | health = 100; | 3290 | presence.setHealthWithUpdate(health); |
2990 | } | ||
2991 | presence.setHealthWithUpdate(health); | ||
2992 | } | ||
2993 | } | 3291 | } |
2994 | } | 3292 | } |
2995 | 3293 | ||
@@ -3066,8 +3364,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3066 | if (avatar != null && avatar.UUID != m_host.OwnerID) | 3364 | if (avatar != null && avatar.UUID != m_host.OwnerID) |
3067 | { | 3365 | { |
3068 | result.Add(new LSL_String(avatar.UUID.ToString())); | 3366 | result.Add(new LSL_String(avatar.UUID.ToString())); |
3069 | OpenMetaverse.Vector3 ap = avatar.AbsolutePosition; | 3367 | result.Add(new LSL_Vector(avatar.AbsolutePosition)); |
3070 | result.Add(new LSL_Vector(ap.X, ap.Y, ap.Z)); | ||
3071 | result.Add(new LSL_String(avatar.Name)); | 3368 | result.Add(new LSL_String(avatar.Name)); |
3072 | } | 3369 | } |
3073 | }); | 3370 | }); |
@@ -3263,7 +3560,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3263 | 3560 | ||
3264 | public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint) | 3561 | public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint) |
3265 | { | 3562 | { |
3266 | CheckThreatLevel(ThreatLevel.Severe, "osForceAttachToOtherAvatarFromInventory"); | 3563 | CheckThreatLevel(ThreatLevel.VeryHigh, "osForceAttachToOtherAvatarFromInventory"); |
3267 | 3564 | ||
3268 | m_host.AddScriptLPS(1); | 3565 | m_host.AddScriptLPS(1); |
3269 | 3566 | ||
@@ -3307,14 +3604,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3307 | if (sp == null) | 3604 | if (sp == null) |
3308 | return; | 3605 | return; |
3309 | 3606 | ||
3310 | InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID); | 3607 | string message; |
3608 | InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID, out message); | ||
3311 | 3609 | ||
3312 | if (newItem == null) | 3610 | if (newItem == null) |
3313 | { | 3611 | { |
3314 | m_log.ErrorFormat( | 3612 | m_log.ErrorFormat( |
3315 | "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}", | 3613 | "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}: {4}", |
3316 | itemName, m_host.Name, attachmentPoint, World.Name); | 3614 | itemName, m_host.Name, attachmentPoint, World.Name, message); |
3317 | 3615 | ((LSL_Api)m_LSL_Api).llSay(0, message); | |
3318 | return; | 3616 | return; |
3319 | } | 3617 | } |
3320 | 3618 | ||