mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
cosmetics
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -139,7 +139,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
// shared things
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static object m_OSSLLock = new object();
|
||||
private static readonly object m_OSSLLock = new object();
|
||||
private static bool m_doneSharedInit = false;
|
||||
internal static bool m_OSFunctionsEnabled = false;
|
||||
internal static TimeZoneInfo PSTTimeZone = null;
|
||||
@@ -342,8 +342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
// or a string explaining why this function can't be used.
|
||||
private string CheckThreatLevelTest(ThreatLevel level, string function)
|
||||
{
|
||||
FunctionPerms perms;
|
||||
if (!m_FunctionPerms.TryGetValue(function, out perms))
|
||||
if (!m_FunctionPerms.TryGetValue(function, out FunctionPerms perms))
|
||||
{
|
||||
perms = new FunctionPerms();
|
||||
|
||||
@@ -744,12 +743,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
if (dm == null)
|
||||
return;
|
||||
|
||||
UUID avatarID;
|
||||
if (!UUID.TryParse(agentID, out avatarID))
|
||||
if (!UUID.TryParse(agentID, out UUID avatarID))
|
||||
return;
|
||||
|
||||
ScenePresence sp = null;
|
||||
if (!World.TryGetScenePresence(avatarID, out sp))
|
||||
if (!World.TryGetScenePresence(avatarID, out ScenePresence sp))
|
||||
return;
|
||||
|
||||
if (sp == null || sp.IsChildAgent || sp.IsDeleted || sp.IsInTransit || sp.IsNPC)
|
||||
@@ -767,8 +764,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
if (World.Entities.ContainsKey(target))
|
||||
{
|
||||
EntityBase entity;
|
||||
if (World.Entities.TryGetValue(target, out entity))
|
||||
if (World.Entities.TryGetValue(target, out EntityBase entity))
|
||||
{
|
||||
if (entity is SceneObjectGroup)
|
||||
((SceneObjectGroup)entity).UpdateGroupRotationR(rotation);
|
||||
@@ -1001,8 +997,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
// Teleport functions
|
||||
public void osLocalTeleportAgent(LSL_Key agent, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, LSL_Types.Vector3 lookat, LSL_Integer flags)
|
||||
{
|
||||
UUID agentId;
|
||||
if (!UUID.TryParse(agent, out agentId))
|
||||
if (!UUID.TryParse(agent, out UUID agentId))
|
||||
return;
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(agentId);
|
||||
@@ -1031,21 +1026,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
if(String.IsNullOrEmpty(regionName))
|
||||
regionName = World.RegionInfo.RegionName;
|
||||
|
||||
UUID agentId;
|
||||
if (UUID.TryParse(agent, out agentId))
|
||||
if (UUID.TryParse(agent, out UUID agentId))
|
||||
{
|
||||
ScenePresence presence = World.GetScenePresence(agentId);
|
||||
if (presence == null || presence.IsDeleted || presence.IsInTransit)
|
||||
return;
|
||||
|
||||
Vector3 pos = presence.AbsolutePosition;
|
||||
if(!checkAllowAgentTPbyLandOwner(agentId, pos))
|
||||
if (!checkAllowAgentTPbyLandOwner(agentId, pos))
|
||||
{
|
||||
ScriptSleep(500);
|
||||
return;
|
||||
}
|
||||
|
||||
if(regionName == World.RegionInfo.RegionName)
|
||||
if (regionName == World.RegionInfo.RegionName)
|
||||
{
|
||||
// should be faster than going to threadpool
|
||||
World.RequestTeleportLocation(presence.ControllingClient, regionName, position,
|
||||
@@ -1054,14 +1048,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
}
|
||||
else
|
||||
{
|
||||
// We will launch the teleport on a new thread so that when the script threads are terminated
|
||||
// before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
|
||||
Util.FireAndForget(
|
||||
o => World.RequestTeleportLocation(
|
||||
presence.ControllingClient, regionName, position,
|
||||
lookat, (uint)TPFlags.ViaLocation),
|
||||
null, "OSSL_Api.TeleportAgentByRegionCoords");
|
||||
ScriptSleep(5000);
|
||||
// We will launch the teleport on a new thread so that when the script threads are terminated
|
||||
// before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
|
||||
Util.FireAndForget(
|
||||
o => World.RequestTeleportLocation(
|
||||
presence.ControllingClient, regionName, position,
|
||||
lookat, (uint)TPFlags.ViaLocation),
|
||||
null, "OSSL_Api.TeleportAgentByRegionCoords");
|
||||
ScriptSleep(5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1080,15 +1074,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
ulong regionHandle = Util.RegionGridLocToHandle((uint)regionGridX, (uint)regionGridY);
|
||||
|
||||
UUID agentId;
|
||||
if (UUID.TryParse(agent, out agentId))
|
||||
if (UUID.TryParse(agent, out UUID agentId))
|
||||
{
|
||||
ScenePresence presence = World.GetScenePresence(agentId);
|
||||
if (presence == null || presence.IsDeleted || presence.IsInTransit)
|
||||
return;
|
||||
|
||||
Vector3 pos = presence.AbsolutePosition;
|
||||
if(!checkAllowAgentTPbyLandOwner(agentId, pos))
|
||||
if (!checkAllowAgentTPbyLandOwner(agentId, pos))
|
||||
{
|
||||
ScriptSleep(500);
|
||||
return;
|
||||
@@ -1106,15 +1099,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
|
||||
{
|
||||
UUID agentId;
|
||||
if (UUID.TryParse(agent, out agentId))
|
||||
if (UUID.TryParse(agent, out UUID agentId))
|
||||
{
|
||||
ScenePresence presence = World.GetScenePresence(agentId);
|
||||
if (presence == null || presence.IsDeleted || presence.IsInTransit)
|
||||
return;
|
||||
|
||||
Vector3 pos = presence.AbsolutePosition;
|
||||
if(!checkAllowAgentTPbyLandOwner(agentId, pos))
|
||||
if (!checkAllowAgentTPbyLandOwner(agentId, pos))
|
||||
{
|
||||
ScriptSleep(500);
|
||||
return;
|
||||
@@ -1179,9 +1171,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public void ForceSit(string avatar, UUID targetID)
|
||||
{
|
||||
UUID agentID;
|
||||
|
||||
if (!UUID.TryParse(avatar, out agentID))
|
||||
if (!UUID.TryParse(avatar, out UUID agentID))
|
||||
return;
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(agentID);
|
||||
@@ -1235,8 +1225,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarPlayAnimation");
|
||||
|
||||
UUID avatarID;
|
||||
if(!UUID.TryParse(avatar, out avatarID))
|
||||
if (!UUID.TryParse(avatar, out UUID avatarID))
|
||||
return;
|
||||
|
||||
ScenePresence target = World.GetScenePresence(avatarID);
|
||||
@@ -1268,16 +1257,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarStopAnimation");
|
||||
|
||||
UUID avatarID;
|
||||
if(!UUID.TryParse(avatar, out avatarID))
|
||||
if (!UUID.TryParse(avatar, out UUID avatarID))
|
||||
return;
|
||||
|
||||
ScenePresence target = World.GetScenePresence(avatarID);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
UUID animID;
|
||||
if (!UUID.TryParse(animation, out animID))
|
||||
if (!UUID.TryParse(animation, out UUID animID))
|
||||
{
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation);
|
||||
if (item != null && item.Type == (int)AssetType.Animation)
|
||||
@@ -1490,9 +1477,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
|
||||
if (textureManager != null)
|
||||
{
|
||||
double xSize, ySize;
|
||||
textureManager.GetDrawStringSize(contentType, text, fontName, fontSize,
|
||||
out xSize, out ySize);
|
||||
out double xSize, out double ySize);
|
||||
vec.x = xSize;
|
||||
vec.y = ySize;
|
||||
}
|
||||
@@ -2134,8 +2120,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Low, "osMessageObject");
|
||||
|
||||
UUID objUUID;
|
||||
if (!UUID.TryParse(objectUUID, out objUUID)) // prior to patching, a thrown exception regarding invalid GUID format would be shouted instead.
|
||||
if (!UUID.TryParse(objectUUID, out UUID objUUID)) // prior to patching, a thrown exception regarding invalid GUID format would be shouted instead.
|
||||
{
|
||||
OSSLShoutError("osMessageObject() cannot send messages to objects with invalid UUIDs");
|
||||
return;
|
||||
@@ -2174,8 +2159,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
CheckThreatLevel(ThreatLevel.Low, "osDie");
|
||||
|
||||
UUID objUUID;
|
||||
if (!UUID.TryParse(objectUUID, out objUUID))
|
||||
if (!UUID.TryParse(objectUUID, out UUID objUUID))
|
||||
{
|
||||
OSSLShoutError("osDie() cannot delete objects with invalid UUIDs");
|
||||
return;
|
||||
@@ -2249,8 +2233,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
protected TaskInventoryItem SaveNotecard(string name, string description, string data, bool forceSameName)
|
||||
{
|
||||
// Create new asset
|
||||
AssetBase asset = new AssetBase(UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString());
|
||||
asset.Description = description;
|
||||
AssetBase asset = new AssetBase(UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString())
|
||||
{
|
||||
Description = description
|
||||
};
|
||||
byte[] a;
|
||||
byte[] b;
|
||||
byte[] c;
|
||||
@@ -2496,10 +2482,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return userID.ToString();
|
||||
|
||||
// HG ?
|
||||
string realFirstName;
|
||||
string realLastName;
|
||||
string serverURI;
|
||||
if (Util.ParseForeignAvatarName(firstname, lastname, out realFirstName, out realLastName, out serverURI))
|
||||
if (Util.ParseForeignAvatarName(firstname, lastname, out string realFirstName, out string realLastName, out string serverURI))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2542,9 +2525,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
if (uInfo != null)
|
||||
{
|
||||
UUID userUUID; String gridURL; String firstName; String lastName; String tmp;
|
||||
|
||||
if (Util.ParseUniversalUserIdentifier(uInfo.UserID, out userUUID, out gridURL, out firstName, out lastName, out tmp))
|
||||
if (Util.ParseUniversalUserIdentifier(uInfo.UserID, out UUID userUUID,
|
||||
out string gridURL, out string firstName,
|
||||
out string lastName, out string tmp))
|
||||
{
|
||||
string grid = new Uri(gridURL).Authority;
|
||||
return firstName + "." + lastName + " @" + grid;
|
||||
@@ -2934,8 +2918,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||
if (module != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (UUID.TryParse(npc.m_string, out npcId))
|
||||
if (UUID.TryParse(npc.m_string, out UUID npcId))
|
||||
if (module.IsNPC(npcId, World))
|
||||
return ScriptBaseClass.TRUE;
|
||||
}
|
||||
@@ -3038,8 +3021,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
if((createFlags & NPCOptionsFlags.AllowCloneOtherAvatars) != 0)
|
||||
{
|
||||
UUID id;
|
||||
if (UUID.TryParse(notecard, out id))
|
||||
if (UUID.TryParse(notecard, out UUID id))
|
||||
{
|
||||
ScenePresence clonePresence = World.GetScenePresence(id);
|
||||
if (clonePresence != null)
|
||||
@@ -3086,8 +3068,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
World,
|
||||
appearance);
|
||||
|
||||
ScenePresence sp;
|
||||
if (World.TryGetScenePresence(x, out sp))
|
||||
if (World.TryGetScenePresence(x, out ScenePresence sp))
|
||||
{
|
||||
sp.SendAvatarDataToAllAgents();
|
||||
}
|
||||
@@ -3139,8 +3120,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
if (npcModule != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
if (!UUID.TryParse(npc.m_string, out UUID npcId))
|
||||
return;
|
||||
|
||||
if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
|
||||
@@ -3169,8 +3149,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
|
||||
if (npcModule != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (UUID.TryParse(npc.m_string, out npcId))
|
||||
if (UUID.TryParse(npc.m_string, out UUID npcId))
|
||||
{
|
||||
UUID owner = npcModule.GetOwner(npcId);
|
||||
if (owner != UUID.Zero)
|
||||
@@ -3190,8 +3169,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
|
||||
if (npcModule != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
if (!UUID.TryParse(npc.m_string, out UUID npcId))
|
||||
return new LSL_Vector(0, 0, 0);
|
||||
|
||||
if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
|
||||
@@ -3213,8 +3191,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||
if (module != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
if (!UUID.TryParse(npc.m_string, out UUID npcId))
|
||||
return;
|
||||
|
||||
if (!module.CheckPermissions(npcId, m_host.OwnerID))
|
||||
@@ -3231,8 +3208,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||
if (module != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
if (!UUID.TryParse(npc.m_string, out UUID npcId))
|
||||
return;
|
||||
|
||||
if (!module.CheckPermissions(npcId, m_host.OwnerID))
|
||||
@@ -3255,8 +3231,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
|
||||
if (npcModule != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
if (!UUID.TryParse(npc.m_string, out UUID npcId))
|
||||
return new LSL_Rotation(Quaternion.Identity);
|
||||
|
||||
if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
|
||||
@@ -3278,8 +3253,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
|
||||
if (npcModule != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
if (!UUID.TryParse(npc.m_string, out UUID npcId))
|
||||
return;
|
||||
|
||||
if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
|
||||
@@ -3383,12 +3357,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
if (module == null)
|
||||
return;
|
||||
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npc.m_string, out npcId))
|
||||
if (!UUID.TryParse(npc.m_string, out UUID npcId))
|
||||
return;
|
||||
|
||||
UUID TargetID;
|
||||
if (!UUID.TryParse(target.m_string, out TargetID))
|
||||
if (!UUID.TryParse(target.m_string, out UUID TargetID))
|
||||
return;
|
||||
|
||||
if (!module.CheckPermissions(npcId, m_host.OwnerID))
|
||||
@@ -3482,8 +3454,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
if (module == null)
|
||||
return;
|
||||
|
||||
UUID npcID;
|
||||
if(!UUID.TryParse(npc.m_string, out npcID))
|
||||
if (!UUID.TryParse(npc.m_string, out UUID npcID))
|
||||
return;
|
||||
|
||||
ScenePresence target = World.GetScenePresence(npcID);
|
||||
@@ -3522,8 +3493,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
if (module == null)
|
||||
return;
|
||||
|
||||
UUID npcID;
|
||||
if (!UUID.TryParse(npc.m_string, out npcID))
|
||||
if (!UUID.TryParse(npc.m_string, out UUID npcID))
|
||||
return;
|
||||
|
||||
ScenePresence target = World.GetScenePresence(npcID);
|
||||
@@ -3533,8 +3503,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
if (!module.CheckPermissions(npcID, m_host.OwnerID))
|
||||
return;
|
||||
|
||||
UUID animID;
|
||||
if (!UUID.TryParse(animation, out animID))
|
||||
if (!UUID.TryParse(animation, out UUID animID))
|
||||
{
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation);
|
||||
if (item != null && item.Type == (int)AssetType.Animation)
|
||||
@@ -3573,13 +3542,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
int linkNum = link_num.value;
|
||||
if (module != null || (linkNum < 0 && linkNum != ScriptBaseClass.LINK_THIS))
|
||||
{
|
||||
UUID npcId;
|
||||
if (!UUID.TryParse(npcLSL_Key, out npcId) || !module.CheckPermissions(npcId, m_host.OwnerID))
|
||||
if (!UUID.TryParse(npcLSL_Key, out UUID npcId) || !module.CheckPermissions(npcId, m_host.OwnerID))
|
||||
return;
|
||||
|
||||
SceneObjectPart part = null;
|
||||
UUID objectId;
|
||||
if (UUID.TryParse(LSL_String.ToString(object_key), out objectId))
|
||||
if (UUID.TryParse(LSL_String.ToString(object_key), out UUID objectId))
|
||||
part = World.GetSceneObjectPart(objectId);
|
||||
|
||||
if (part == null)
|
||||
@@ -3681,8 +3648,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.None, "osGetGender");
|
||||
|
||||
UUID avatarId;
|
||||
if (!UUID.TryParse(rawAvatarId, out avatarId))
|
||||
if (!UUID.TryParse(rawAvatarId, out UUID avatarId))
|
||||
return new LSL_String("unknown");
|
||||
|
||||
ScenePresence sp = World.GetScenePresence(avatarId);
|
||||
@@ -3826,8 +3792,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Moderate, "osSetSpeed");
|
||||
|
||||
UUID avid;
|
||||
if(!UUID.TryParse(ID, out avid))
|
||||
if (!UUID.TryParse(ID, out UUID avid))
|
||||
return;
|
||||
|
||||
ScenePresence avatar = World.GetScenePresence(avid);
|
||||
@@ -3869,8 +3834,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar");
|
||||
|
||||
UUID id;
|
||||
if (!UUID.TryParse(agentKey, out id) || id == UUID.Zero)
|
||||
if (!UUID.TryParse(agentKey, out UUID id) || id == UUID.Zero)
|
||||
return;
|
||||
|
||||
ScenePresence sp = World.GetScenePresence(id);
|
||||
@@ -3891,8 +3855,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
LSL_Float health = new LSL_Float(-1);
|
||||
|
||||
UUID id;
|
||||
if (!UUID.TryParse(agentKey, out id) || id == UUID.Zero)
|
||||
if (!UUID.TryParse(agentKey, out UUID id) || id == UUID.Zero)
|
||||
return health;
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(id);
|
||||
@@ -3905,8 +3868,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osCauseDamage");
|
||||
|
||||
UUID avatarId;
|
||||
if (!UUID.TryParse(avatar, out avatarId))
|
||||
if (!UUID.TryParse(avatar, out UUID avatarId))
|
||||
return;
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(avatarId);
|
||||
@@ -3934,8 +3896,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osCauseHealing");
|
||||
|
||||
UUID avatarId;
|
||||
if (!UUID.TryParse(avatar, out avatarId))
|
||||
if (!UUID.TryParse(avatar, out UUID avatarId))
|
||||
return;
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(avatarId);
|
||||
@@ -3973,8 +3934,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osSetHealRate");
|
||||
|
||||
UUID avatarId;
|
||||
if (!UUID.TryParse(avatar, out avatarId))
|
||||
if (!UUID.TryParse(avatar, out UUID avatarId))
|
||||
return;
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(avatarId);
|
||||
@@ -3990,8 +3950,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
LSL_Float rate = new LSL_Float(0);
|
||||
|
||||
UUID avatarId;
|
||||
if (!UUID.TryParse(avatar, out avatarId))
|
||||
if (!UUID.TryParse(avatar, out UUID avatarId))
|
||||
return rate;
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(avatarId);
|
||||
@@ -4282,9 +4241,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.VeryHigh, "osForceAttachToOtherAvatarFromInventory");
|
||||
|
||||
UUID avatarId;
|
||||
|
||||
if (!UUID.TryParse(rawAvatarId, out avatarId))
|
||||
if (!UUID.TryParse(rawAvatarId, out UUID avatarId))
|
||||
return;
|
||||
|
||||
ForceAttachToAvatarFromInventory(avatarId, itemName, attachmentPoint);
|
||||
@@ -4322,8 +4279,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
if (sp == null)
|
||||
return;
|
||||
|
||||
string message;
|
||||
InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID, out message);
|
||||
InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID, out string message);
|
||||
|
||||
if (newItem == null)
|
||||
{
|
||||
@@ -4349,11 +4305,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Moderate, "osGetNumberOfAttachments");
|
||||
|
||||
UUID targetUUID;
|
||||
ScenePresence target;
|
||||
LSL_List resp = new LSL_List();
|
||||
|
||||
if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
|
||||
if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out UUID targetUUID) && World.TryGetScenePresence(targetUUID, out ScenePresence target))
|
||||
{
|
||||
foreach (object point in attachmentPoints.Data)
|
||||
{
|
||||
@@ -4383,18 +4337,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments");
|
||||
|
||||
UUID targetUUID;
|
||||
if(!UUID.TryParse(avatar.ToString(), out targetUUID))
|
||||
if (!UUID.TryParse(avatar.ToString(), out UUID targetUUID))
|
||||
return;
|
||||
|
||||
if(targetUUID == UUID.Zero)
|
||||
if (targetUUID == UUID.Zero)
|
||||
return;
|
||||
|
||||
ScenePresence target;
|
||||
if(!World.TryGetScenePresence(targetUUID, out target))
|
||||
return;
|
||||
if (!World.TryGetScenePresence(targetUUID, out ScenePresence target))
|
||||
return;
|
||||
|
||||
if(target.IsDeleted || target.IsInTransit)
|
||||
if (target.IsDeleted || target.IsInTransit)
|
||||
return;
|
||||
|
||||
List<int> aps = new List<int>();
|
||||
@@ -4402,8 +4354,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
foreach (object point in attachmentPoints.Data)
|
||||
{
|
||||
int ipoint;
|
||||
if (int.TryParse(point.ToString(), out ipoint))
|
||||
if (int.TryParse(point.ToString(), out int ipoint))
|
||||
{
|
||||
aps.Add(ipoint);
|
||||
}
|
||||
@@ -4492,8 +4443,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel();
|
||||
|
||||
UUID test;
|
||||
return UUID.TryParse(thing, out test) ? 1 : 0;
|
||||
return UUID.TryParse(thing, out UUID test) ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -4629,8 +4579,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Low, "osListenRegex");
|
||||
|
||||
UUID keyID;
|
||||
UUID.TryParse(ID, out keyID);
|
||||
UUID.TryParse(ID, out UUID keyID);
|
||||
|
||||
// if we want the name to be used as a regular expression, ensure it is valid first.
|
||||
if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_NAME) == ScriptBaseClass.OS_LISTEN_REGEX_NAME)
|
||||
@@ -4781,16 +4730,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
CheckThreatLevel();
|
||||
|
||||
LSL_List result = new LSL_List();
|
||||
float TotalMass;
|
||||
Vector3 CenterOfMass;
|
||||
Vector3 Inertia;
|
||||
Vector4 aux;
|
||||
|
||||
SceneObjectGroup sog = m_host.ParentGroup;
|
||||
if(sog== null || sog.IsDeleted)
|
||||
if (sog== null || sog.IsDeleted)
|
||||
return result;
|
||||
|
||||
sog.GetInertiaData(out TotalMass, out CenterOfMass, out Inertia, out aux );
|
||||
sog.GetInertiaData(out float TotalMass, out Vector3 CenterOfMass, out Vector3 Inertia, out Vector4 aux );
|
||||
if(TotalMass > 0)
|
||||
{
|
||||
float t = 1.0f/TotalMass;
|
||||
@@ -5041,8 +4986,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Severe, "osTeleportObject");
|
||||
|
||||
UUID objUUID;
|
||||
if (!UUID.TryParse(objectUUID, out objUUID))
|
||||
if (!UUID.TryParse(objectUUID, out UUID objUUID))
|
||||
{
|
||||
OSSLShoutError("osTeleportObject() invalid object Key");
|
||||
return -1;
|
||||
@@ -5343,8 +5287,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
if (World.UserAccountService == null)
|
||||
return String.Empty;
|
||||
|
||||
UUID key;
|
||||
if (!UUID.TryParse(id, out key))
|
||||
if (!UUID.TryParse(id, out UUID key))
|
||||
return String.Empty;
|
||||
if (key == UUID.Zero)
|
||||
return String.Empty;
|
||||
@@ -5638,8 +5581,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
TaskInventoryItem item = null;
|
||||
UUID itemID;
|
||||
if (UUID.TryParse(itemNameorid, out itemID))
|
||||
if (UUID.TryParse(itemNameorid, out UUID itemID))
|
||||
item = m_host.Inventory.GetInventoryItem(itemID);
|
||||
else
|
||||
item = m_host.Inventory.GetInventoryItem(itemNameorid);
|
||||
@@ -5677,8 +5619,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
TaskInventoryItem item = null;
|
||||
UUID itemID;
|
||||
if (UUID.TryParse(itemId, out itemID))
|
||||
if (UUID.TryParse(itemId, out UUID itemID))
|
||||
item = m_host.Inventory.GetInventoryItem(itemID);
|
||||
|
||||
if (item == null)
|
||||
@@ -5692,8 +5633,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
TaskInventoryItem item = null;
|
||||
UUID itemID;
|
||||
if (UUID.TryParse(itemNameorid, out itemID))
|
||||
if (UUID.TryParse(itemNameorid, out UUID itemID))
|
||||
item = m_host.Inventory.GetInventoryItem(itemID);
|
||||
else
|
||||
item = m_host.Inventory.GetInventoryItem(itemNameorid);
|
||||
@@ -6100,4 +6040,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
|
||||
private INPCModule m_npcModule;
|
||||
|
||||
private Object SenseLock = new Object();
|
||||
private readonly object SenseLock = new object();
|
||||
|
||||
private const int AGENT = 1;
|
||||
private const int AGENT_BY_USERNAME = 0x10;
|
||||
@@ -133,7 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
/// Always lock SenseRepeatListLock when updating this list.
|
||||
/// </remarks>
|
||||
private List<SensorInfo> SenseRepeaters = new List<SensorInfo>();
|
||||
private object SenseRepeatListLock = new object();
|
||||
private readonly object SenseRepeatListLock = new object();
|
||||
|
||||
public void SetSenseRepeatEvent(uint m_localID, UUID m_itemID,
|
||||
string name, UUID keyID, int type, double range,
|
||||
@@ -146,13 +146,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
return;
|
||||
|
||||
// Add to timer
|
||||
SensorInfo ts = new SensorInfo();
|
||||
ts.localID = m_localID;
|
||||
ts.itemID = m_itemID;
|
||||
ts.interval = sec;
|
||||
ts.name = name;
|
||||
ts.keyID = keyID;
|
||||
ts.type = type;
|
||||
SensorInfo ts = new SensorInfo
|
||||
{
|
||||
localID = m_localID,
|
||||
itemID = m_itemID,
|
||||
interval = sec,
|
||||
name = name,
|
||||
keyID = keyID,
|
||||
type = type
|
||||
};
|
||||
if (range > maximumRange)
|
||||
ts.range = maximumRange;
|
||||
else
|
||||
@@ -169,8 +171,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
{
|
||||
lock (SenseRepeatListLock)
|
||||
{
|
||||
List<SensorInfo> newSenseRepeaters = new List<SensorInfo>(SenseRepeaters);
|
||||
newSenseRepeaters.Add(senseRepeater);
|
||||
List<SensorInfo> newSenseRepeaters = new List<SensorInfo>(SenseRepeaters)
|
||||
{
|
||||
senseRepeater
|
||||
};
|
||||
SenseRepeaters = newSenseRepeaters;
|
||||
}
|
||||
}
|
||||
@@ -219,13 +223,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
double range, double arc, SceneObjectPart host)
|
||||
{
|
||||
// Add to timer
|
||||
SensorInfo ts = new SensorInfo();
|
||||
ts.localID = m_localID;
|
||||
ts.itemID = m_itemID;
|
||||
ts.interval = 0;
|
||||
ts.name = name;
|
||||
ts.keyID = keyID;
|
||||
ts.type = type;
|
||||
SensorInfo ts = new SensorInfo
|
||||
{
|
||||
localID = m_localID,
|
||||
itemID = m_itemID,
|
||||
interval = 0,
|
||||
name = name,
|
||||
keyID = keyID,
|
||||
type = type
|
||||
};
|
||||
if (range > maximumRange)
|
||||
ts.range = maximumRange;
|
||||
else
|
||||
@@ -277,8 +283,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
{
|
||||
try
|
||||
{
|
||||
DetectParams detect = new DetectParams();
|
||||
detect.Key = sensedEntities[idx].itemID;
|
||||
DetectParams detect = new DetectParams
|
||||
{
|
||||
Key = sensedEntities[idx].itemID
|
||||
};
|
||||
detect.Populate(m_CmdManager.m_ScriptEngine.World);
|
||||
detected.Add(detect);
|
||||
}
|
||||
@@ -320,12 +328,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
// rather than getting a list to scan through
|
||||
if (ts.keyID != UUID.Zero)
|
||||
{
|
||||
EntityBase e = null;
|
||||
m_CmdManager.m_ScriptEngine.World.Entities.TryGetValue(ts.keyID, out e);
|
||||
m_CmdManager.m_ScriptEngine.World.Entities.TryGetValue(ts.keyID, out EntityBase e);
|
||||
if (e == null)
|
||||
return sensedEntities;
|
||||
Entities = new List<EntityBase>();
|
||||
Entities.Add(e);
|
||||
Entities = new List<EntityBase>
|
||||
{
|
||||
e
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -617,17 +626,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
// rather than getting a list to scan through
|
||||
if (ts.keyID != UUID.Zero)
|
||||
{
|
||||
ScenePresence sp;
|
||||
// Try direct lookup by UUID
|
||||
if (!m_CmdManager.m_ScriptEngine.World.TryGetScenePresence(ts.keyID, out sp))
|
||||
if (!m_CmdManager.m_ScriptEngine.World.TryGetScenePresence(ts.keyID, out ScenePresence sp))
|
||||
return sensedEntities;
|
||||
senseEntity(sp);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(ts.name))
|
||||
{
|
||||
ScenePresence sp;
|
||||
// Try lookup by name will return if/when found
|
||||
if (((ts.type & AGENT) != 0) && m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp))
|
||||
if (((ts.type & AGENT) != 0) && m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out ScenePresence sp))
|
||||
senseEntity(sp);
|
||||
if ((ts.type & AGENT_BY_USERNAME) != 0)
|
||||
{
|
||||
@@ -689,18 +696,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
|
||||
while (idx < data.Length)
|
||||
{
|
||||
SensorInfo ts = new SensorInfo();
|
||||
SensorInfo ts = new SensorInfo
|
||||
{
|
||||
localID = localID,
|
||||
itemID = itemID,
|
||||
|
||||
ts.localID = localID;
|
||||
ts.itemID = itemID;
|
||||
|
||||
ts.interval = (double)data[idx];
|
||||
ts.name = (string)data[idx+1];
|
||||
ts.keyID = (UUID)data[idx+2];
|
||||
ts.type = (int)data[idx+3];
|
||||
ts.range = (double)data[idx+4];
|
||||
ts.arc = (double)data[idx+5];
|
||||
ts.host = part;
|
||||
interval = (double)data[idx],
|
||||
name = (string)data[idx + 1],
|
||||
keyID = (UUID)data[idx + 2],
|
||||
type = (int)data[idx + 3],
|
||||
range = (double)data[idx + 4],
|
||||
arc = (double)data[idx + 5],
|
||||
host = part
|
||||
};
|
||||
|
||||
ts.next =
|
||||
DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
|
||||
|
||||
Reference in New Issue
Block a user