From 06f2ec0097c380cf1a88be0cb09297b429ee6e06 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 18 Jun 2022 18:01:50 +0100 Subject: [PATCH] several changes on lslapi like add uuid zero checks, etc --- .../Shared/Api/Implementation/LSL_Api.cs | 422 ++++++++---------- 1 file changed, 191 insertions(+), 231 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c081413fe4..3a12302ebb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1335,12 +1335,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llListen(int channelID, string name, string ID, string msg) { - UUID.TryParse(ID, out UUID keyID); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); - if (wComm != null) - return wComm.Listen(m_host.LocalId, m_item.ItemID, m_host.UUID, channelID, name, keyID, msg); - else + if (wComm == null) return -1; + + UUID.TryParse(ID, out UUID keyID); + return wComm.Listen(m_host.LocalId, m_item.ItemID, m_host.UUID, channelID, name, keyID, msg); } public void llListenControl(int number, int active) @@ -1359,17 +1359,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSensor(string name, string id, int type, double range, double arc) { - UUID keyID = UUID.Zero; - UUID.TryParse(id, out keyID); - + UUID.TryParse(id, out UUID keyID); m_AsyncCommands.SensorRepeatPlugin.SenseOnce(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, m_host); } public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) { - UUID keyID = UUID.Zero; - UUID.TryParse(id, out keyID); - + UUID.TryParse(id, out UUID keyID); m_AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, rate, m_host); } @@ -1930,7 +1926,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_UrlModule == null) return; - if(!UUID.TryParse(reqid, out UUID id)) + if(!UUID.TryParse(reqid, out UUID id) || id.IsZero()) return; // Make sure the content type is text/plain to start with @@ -1970,31 +1966,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api switch (type) { case ScriptBaseClass.CONTENT_TYPE_HTML: - m_UrlModule.HttpContentType(new UUID(id), "text/html"); + m_UrlModule.HttpContentType(id, "text/html"); break; case ScriptBaseClass.CONTENT_TYPE_XML: - m_UrlModule.HttpContentType(new UUID(id), "application/xml"); + m_UrlModule.HttpContentType(id, "application/xml"); break; case ScriptBaseClass.CONTENT_TYPE_XHTML: - m_UrlModule.HttpContentType(new UUID(id), "application/xhtml+xml"); + m_UrlModule.HttpContentType(id, "application/xhtml+xml"); break; case ScriptBaseClass.CONTENT_TYPE_ATOM: - m_UrlModule.HttpContentType(new UUID(id), "application/atom+xml"); + m_UrlModule.HttpContentType(id, "application/atom+xml"); break; case ScriptBaseClass.CONTENT_TYPE_JSON: - m_UrlModule.HttpContentType(new UUID(id), "application/json"); + m_UrlModule.HttpContentType(id, "application/json"); break; case ScriptBaseClass.CONTENT_TYPE_LLSD: - m_UrlModule.HttpContentType(new UUID(id), "application/llsd+xml"); + m_UrlModule.HttpContentType(id, "application/llsd+xml"); break; case ScriptBaseClass.CONTENT_TYPE_FORM: - m_UrlModule.HttpContentType(new UUID(id), "application/x-www-form-urlencoded"); + m_UrlModule.HttpContentType(id, "application/x-www-form-urlencoded"); break; case ScriptBaseClass.CONTENT_TYPE_RSS: - m_UrlModule.HttpContentType(new UUID(id), "application/rss+xml"); + m_UrlModule.HttpContentType(id, "application/rss+xml"); break; default: - m_UrlModule.HttpContentType(new UUID(id), "text/plain"); + m_UrlModule.HttpContentType(id, "text/plain"); break; } } @@ -2465,12 +2461,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; - UUID textureID = new UUID(); - - textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture); + UUID textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture); if (textureID.IsZero()) { - if (!UUID.TryParse(texture, out textureID)) + if (!UUID.TryParse(texture, out textureID) || textureID.IsZero()) return; } @@ -3492,9 +3486,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return 0; } - UUID toID = new UUID(); - - if (!UUID.TryParse(destination, out toID)) + if (!UUID.TryParse(destination, out UUID toID)) { Error("llGiveMoney", "Bad key in llGiveMoney"); return 0; @@ -4247,7 +4239,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRequestPermissions(string agent, int perm) { - if (!UUID.TryParse(agent, out UUID agentID)) + if (!UUID.TryParse(agent, out UUID agentID) || agentID.IsZero()) return; if (agentID == UUID.Zero || perm == 0) // Releasing permissions @@ -4440,7 +4432,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llCreateLink(LSL_Key target, LSL_Integer parent) { - if (!UUID.TryParse(target, out UUID targetID)) + if (!UUID.TryParse(target, out UUID targetID) || targetID.IsZero()) return; if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 @@ -4450,14 +4442,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - CreateLink(target, parent); + CreateLink(targetID, parent); } public void CreateLink(string target, int parent) { - if (!UUID.TryParse(target, out UUID targetID)) + if (!UUID.TryParse(target, out UUID targetID) || targetID.IsZero()) return; + CreateLink(targetID, parent); + } + + public void CreateLink(UUID targetID, int parent) + { SceneObjectPart targetPart = World.GetSceneObjectPart(targetID); if (targetPart == null) return; @@ -4465,7 +4462,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (targetPart.ParentGroup.AttachmentPoint != 0) return; // Fail silently if attached - if (targetPart.ParentGroup.RootPart.OwnerID != m_host.ParentGroup.RootPart.OwnerID) + if (targetPart.ParentGroup.RootPart.OwnerID.NotEqual(m_host.ParentGroup.RootPart.OwnerID)) return; SceneObjectGroup parentPrim = null, childPrim = null; @@ -4763,7 +4760,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llGiveInventory(LSL_Key destination, LSL_String inventory) { - if (!UUID.TryParse(destination, out UUID destId)) + if (!UUID.TryParse(destination, out UUID destId) || destId.IsZero()) { Error("llGiveInventory", "Can't parse destination key '" + destination + "'"); return; @@ -4869,7 +4866,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key llRequestAgentData(string id, int data) { - if (UUID.TryParse(id, out UUID uuid) && !uuid.IsZero()) + if (UUID.TryParse(id, out UUID uuid) && uuid.IsNotZero()) { //pre process fast local avatars switch(data) @@ -5048,7 +5045,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.ParentGroup.FromItemID.IsZero()) return; - if (UUID.TryParse(agent, out UUID agentId)) + if (UUID.TryParse(agent, out UUID agentId) && agentId.IsNotZero()) { ScenePresence presence = World.GetScenePresence(agentId); if (presence == null || presence.IsDeleted || presence.IsChildAgent || presence.IsNPC || presence.IsSatOnObject || presence.IsInTransit) @@ -5091,10 +5088,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.ParentGroup.FromItemID.IsZero()) return; - if (UUID.TryParse(agent, out UUID agentId)) + if (UUID.TryParse(agent, out UUID agentId) && agentId.IsNotZero()) { // This function is owner only! - if (m_host.OwnerID != agentId) + if (m_host.OwnerID.NotEqual(agentId)) return; ScenePresence presence = World.GetScenePresence(agentId); @@ -5146,10 +5143,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (dm == null) return; - UUID av = new UUID(); - if (!UUID.TryParse(agent,out av)) + if (!UUID.TryParse(agent, out UUID av) || av.IsZero()) { - Error("llTextBox", "First parameter must be a key"); + Error("llTextBox", "First parameter must be a valid agent key"); return; } @@ -5260,9 +5256,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api bool pushAllowed = false; bool pusheeIsAvatar = false; - UUID targetID = UUID.Zero; - if (!UUID.TryParse(target,out targetID)) + if (!UUID.TryParse(target, out UUID targetID) || targetID.IsZero()) return; ScenePresence pusheeav = null; @@ -5667,21 +5662,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key llGetOwnerKey(string id) { - UUID key = new UUID(); - if (UUID.TryParse(id, out key)) + if (UUID.TryParse(id, out UUID key)) { - try - { - SceneObjectPart obj = World.GetSceneObjectPart(key); - if (obj == null) - return id; // the key is for an agent so just return the key - else - return obj.OwnerID.ToString(); - } - catch (KeyNotFoundException) - { - return id; // The Object/Agent not in the region so just return the key - } + if(key.IsZero()) + return id; + + SceneObjectPart obj = World.GetSceneObjectPart(key); + return (obj == null) ? id : obj.OwnerID.ToString(); } else { @@ -6436,13 +6423,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetAgentInfo(LSL_Key id) { - if (!UUID.TryParse(id, out UUID key)) + if (!UUID.TryParse(id, out UUID key) || key.IsZero()) { return 0; } - int flags = 0; - ScenePresence agent = World.GetScenePresence(key); if (agent == null) { @@ -6452,6 +6437,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (agent.IsChildAgent || agent.IsDeleted) return 0; // Fail if they are not in the same region + int flags = 0; try { // note: in OpenSim, sitting seems to cancel AGENT_ALWAYS_RUN, unlike SL @@ -6514,7 +6500,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // there be some minimum non-collision threshold time before claiming the avatar is in-air? if ((flags & ScriptBaseClass.AGENT_WALKING) == 0 && !agent.IsColliding ) { - flags |= ScriptBaseClass.AGENT_IN_AIR; + flags |= ScriptBaseClass.AGENT_IN_AIR; } if (agent.ParentPart != null) @@ -6523,8 +6509,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api flags |= ScriptBaseClass.AGENT_SITTING; } - if (agent.Animator.Animations.ImplicitDefaultAnimation.AnimID - == DefaultAvatarAnimations.AnimsUUIDbyName["SIT_GROUND_CONSTRAINED"]) + if (agent.Animator.Animations.ImplicitDefaultAnimation.AnimID.Equals(DefaultAvatarAnimations.AnimsUUIDbyName["SIT_GROUND_CONSTRAINED"])) { flags |= ScriptBaseClass.AGENT_SITTING; } @@ -6551,8 +6536,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else { - UUID key = new UUID(); - if (UUID.TryParse(id, out key)) + if (UUID.TryParse(id, out UUID key) && key.IsNotZero()) { return new LSL_String(World.AgentPreferencesService.GetLang(key)); } @@ -6664,20 +6648,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llKey2Name(LSL_Key id) { - UUID key = new UUID(); - if (UUID.TryParse(id,out key)) + if (UUID.TryParse(id, out UUID key) && key.IsNotZero()) { ScenePresence presence = World.GetScenePresence(key); - if (presence != null) { return presence.Name; - //return presence.Name; } - - if (World.GetSceneObjectPart(key) != null) + SceneObjectPart sop = World.GetSceneObjectPart(key); + if (sop != null) { - return World.GetSceneObjectPart(key).Name; + return sop.Name; } } return String.Empty; @@ -6860,8 +6841,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llEjectFromLand(LSL_Key pest) { - UUID agentID = new UUID(); - if (UUID.TryParse(pest, out agentID)) + if (UUID.TryParse(pest, out UUID agentID) && agentID.IsNotZero()) { ScenePresence presence = World.GetScenePresence(agentID); if (presence != null) @@ -6889,8 +6869,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llOverMyLand(string id) { - UUID key = new UUID(); - if (UUID.TryParse(id, out key)) + if (UUID.TryParse(id, out UUID key) && key.IsNotZero()) { try { @@ -6931,22 +6910,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetAgentSize(LSL_Key id) { - if(!UUID.TryParse(id, out UUID avID)) + if(!UUID.TryParse(id, out UUID avID) || avID.IsZero()) return ScriptBaseClass.ZERO_VECTOR; ScenePresence avatar = World.GetScenePresence(avID); if (avatar == null || avatar.IsChildAgent) // Fail if not in the same region return ScriptBaseClass.ZERO_VECTOR; -// agentSize = new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight); - Vector3 s = avatar.Appearance.AvatarSize; - return new LSL_Vector(s.X, s.Y, s.Z); + return new LSL_Vector(avatar.Appearance.AvatarSize); } public LSL_Integer llSameGroup(string id) { - UUID uuid; - if (!UUID.TryParse(id, out uuid)) + if (!UUID.TryParse(id, out UUID uuid) || uuid.IsZero()) return 0; // Check if it's a group key @@ -6990,40 +6966,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llUnSit(string id) { + if (!UUID.TryParse(id, out UUID key) || key.IsZero()) + return; - UUID key = new UUID(); - if (UUID.TryParse(id, out key)) + ScenePresence av = World.GetScenePresence(key); + if(av == null) + return; + + List sittingAvatars = m_host.ParentGroup.GetSittingAvatars(); + + if (sittingAvatars.Contains(av)) { - ScenePresence av = World.GetScenePresence(key); - List sittingAvatars = m_host.ParentGroup.GetSittingAvatars(); - - if (av != null) + av.StandUp(); + } + else + { + // If the object owner also owns the parcel + // or + // if the land is group owned and the object is group owned by the same group + // or + // if the object is owned by a person with estate access. + ILandObject parcel = World.LandChannel.GetLandObject(av.AbsolutePosition); + if (parcel != null) { - if (sittingAvatars.Contains(av)) + if (m_host.OwnerID.Equals(parcel.LandData.OwnerID) || + (m_host.OwnerID.Equals(m_host.GroupID) && m_host.GroupID.Equals(parcel.LandData.GroupID) + && parcel.LandData.IsGroupOwned) || World.Permissions.IsGod(m_host.OwnerID)) { - // if the avatar is sitting on this object, then - // we can unsit them. We don't want random scripts unsitting random people - // Lets avoid the popcorn avatar scenario. av.StandUp(); } - else - { - // If the object owner also owns the parcel - // or - // if the land is group owned and the object is group owned by the same group - // or - // if the object is owned by a person with estate access. - ILandObject parcel = World.LandChannel.GetLandObject(av.AbsolutePosition); - if (parcel != null) - { - if (m_host.OwnerID.Equals(parcel.LandData.OwnerID) || - (m_host.OwnerID.Equals(m_host.GroupID) && m_host.GroupID.Equals(parcel.LandData.GroupID) - && parcel.LandData.IsGroupOwned) || World.Permissions.IsGod(m_host.OwnerID)) - { - av.StandUp(); - } - } - } } } } @@ -7113,7 +7084,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetAttachedList(LSL_Key id) { - if(!UUID.TryParse(id, out UUID avID)) + if(!UUID.TryParse(id, out UUID avID) || avID.IsZero()) return new LSL_List("NOT_FOUND"); ScenePresence av = World.GetScenePresence(avID); @@ -7598,8 +7569,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case ScriptBaseClass.PSYS_SRC_TARGET_KEY: - UUID key = UUID.Zero; - if (UUID.TryParse(rules.Data[i + 1].ToString(), out key)) + if (UUID.TryParse(rules.Data[i + 1].ToString(), out UUID key)) { prules.Target = key; } @@ -7698,7 +7668,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (inventory.Length == 0) return; - if (!UUID.TryParse(destination, out UUID destID)) + + if (!UUID.TryParse(destination, out UUID destID) || destID.IsZero()) return; bool isNotOwner = true; @@ -7712,7 +7683,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScriptSleep(100); return; } - isNotOwner = sp.UUID != m_host.OwnerID; + isNotOwner = sp.UUID.NotEqual(m_host.OwnerID); } List itemList = new List(inventory.Length); @@ -7907,41 +7878,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llAddToLandPassList(LSL_Key avatar, LSL_Float hours) { + if(!UUID.TryParse(avatar, out UUID key) || key.IsZero()) + return; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManagePasses, false)) { - int expires = 0; - if (hours != 0) - expires = Util.UnixTimeSinceEpoch() + (int)(3600.0 * hours); + LandAccessEntry entry; - if (UUID.TryParse(avatar, out UUID key)) + int expires = (hours != 0) ? Util.UnixTimeSinceEpoch() + (int)(3600.0 * hours) : 0; + int idx = land.LandData.ParcelAccessList.FindIndex( + delegate(LandAccessEntry e) + { + if (e.Flags == AccessList.Access && e.AgentID.Equals(key)) + return true; + return false; + }); + + if (idx != -1) { - int idx = land.LandData.ParcelAccessList.FindIndex( - delegate(LandAccessEntry e) - { - if (e.Flags == AccessList.Access && e.AgentID.Equals(key)) - return true; - return false; - }); - - if (idx != -1 && (land.LandData.ParcelAccessList[idx].Expires == 0 || (expires != 0 && expires < land.LandData.ParcelAccessList[idx].Expires))) + entry = land.LandData.ParcelAccessList[idx]; + if (entry.Expires == 0) + return; + if (expires != 0 && expires < entry.Expires) return; - if (idx != -1) - land.LandData.ParcelAccessList.RemoveAt(idx); - - LandAccessEntry entry = new LandAccessEntry - { - AgentID = key, - Flags = AccessList.Access, - Expires = expires - }; - - land.LandData.ParcelAccessList.Add(entry); - - World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); + entry.Expires = expires; + return; } + + entry = new LandAccessEntry + { + AgentID = key, + Flags = AccessList.Access, + Expires = expires + }; + + land.LandData.ParcelAccessList.Add(entry); + + World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); } ScriptSleep(m_sleepMsOnAddToLandPassList); } @@ -8034,10 +8009,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (dm == null) return; - UUID av = new UUID(); - if (!UUID.TryParse(avatar,out av)) + if (!UUID.TryParse(avatar,out UUID av) || av.IsZero()) { - Error("llDialog", "First parameter must be a key"); + Error("llDialog", "First parameter must be a valid key"); return; } @@ -8107,12 +8081,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) { - - UUID destId = UUID.Zero; - - if (!UUID.TryParse(target, out destId)) + if (!UUID.TryParse(target, out UUID destId) || destId.IsZero()) { - Error("llRemoteLoadScriptPin", "Can't parse key '" + target + "'"); + Error("llRemoteLoadScriptPin", "invalid key '" + target + "'"); return; } @@ -10927,7 +10898,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetAnimationList(LSL_Key id) { - if(!UUID.TryParse(id, out UUID avID)) + if(!UUID.TryParse(id, out UUID avID) || avID.IsZero()) return new LSL_List(); ScenePresence av = World.GetScenePresence(avID); @@ -11038,11 +11009,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_List llGetBoundingBox(string obj) { - UUID objID = UUID.Zero; LSL_List result = new LSL_List(); // If the ID is not valid, return null result - if (!UUID.TryParse(obj, out objID)) + if (!UUID.TryParse(obj, out UUID objID) || objID.IsZero()) { result.Add(new LSL_Vector()); result.Add(new LSL_Vector()); @@ -12911,8 +12881,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llGetObjectMass(LSL_Key id) { - UUID key = new UUID(); - if (!UUID.TryParse(id, out key)) + if (!UUID.TryParse(id, out UUID key) || key.IsZero()) return 0; // return total object mass @@ -13098,7 +13067,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (commandList.Data[i + 1] is LSL_String) { - if (UUID.TryParse((LSL_String)commandList.Data[i + 1], out UUID agentID)) + if (UUID.TryParse((LSL_String)commandList.Data[i + 1], out UUID agentID) && agentID.IsNotZero()) { presence = World.GetScenePresence(agentID); if(presence == null || presence.IsNPC) @@ -13527,66 +13496,69 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llAddToLandBanList(LSL_Key avatar, LSL_Float hours) { + if (!UUID.TryParse(avatar, out UUID key) || key.IsZero()) + return; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned, false)) { - int expires = 0; - if (hours != 0) - expires = Util.UnixTimeSinceEpoch() + (int)(3600.0 * hours); + LandAccessEntry entry; + int expires = (hours != 0) ? Util.UnixTimeSinceEpoch() + (int)(3600.0 * hours) : 0; - if (UUID.TryParse(avatar, out UUID key)) + int idx = land.LandData.ParcelAccessList.FindIndex( + delegate(LandAccessEntry e) + { + if (e.Flags == AccessList.Ban && e.AgentID.Equals(key)) + return true; + return false; + }); + + if (idx != -1) { - int idx = land.LandData.ParcelAccessList.FindIndex( - delegate(LandAccessEntry e) - { - if (e.Flags == AccessList.Ban && e.AgentID.Equals(key)) - return true; - return false; - }); - - if (idx != -1 && (land.LandData.ParcelAccessList[idx].Expires == 0 || (expires != 0 && expires < land.LandData.ParcelAccessList[idx].Expires))) + entry = land.LandData.ParcelAccessList[idx]; + if (entry.Expires == 0) + return; + if (expires != 0 && expires < entry.Expires) return; - if (idx != -1) - land.LandData.ParcelAccessList.RemoveAt(idx); - - LandAccessEntry entry = new LandAccessEntry - { - AgentID = key, - Flags = AccessList.Ban, - Expires = expires - }; - - land.LandData.ParcelAccessList.Add(entry); - - World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); + entry.Expires = expires; + return; } + + entry = new LandAccessEntry + { + AgentID = key, + Flags = AccessList.Ban, + Expires = expires + }; + + land.LandData.ParcelAccessList.Add(entry); + + World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); } ScriptSleep(m_sleepMsOnAddToLandBanList); } public void llRemoveFromLandPassList(string avatar) { + if (!UUID.TryParse(avatar, out UUID key) || key.IsZero()) + return; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManagePasses, false)) { - if (UUID.TryParse(avatar, out UUID key)) - { - int idx = land.LandData.ParcelAccessList.FindIndex( - delegate(LandAccessEntry e) - { - if (e.Flags == AccessList.Access && e.AgentID.Equals(key)) - return true; - return false; - }); + int idx = land.LandData.ParcelAccessList.FindIndex( + delegate(LandAccessEntry e) + { + if (e.Flags == AccessList.Access && e.AgentID.Equals(key)) + return true; + return false; + }); - if (idx != -1) - { - land.LandData.ParcelAccessList.RemoveAt(idx); - World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); - } + if (idx != -1) + { + land.LandData.ParcelAccessList.RemoveAt(idx); + World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); } } ScriptSleep(m_sleepMsOnRemoveFromLandPassList); @@ -13594,25 +13566,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRemoveFromLandBanList(string avatar) { + if (!UUID.TryParse(avatar, out UUID key) || key.IsZero()) + return; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned, false)) { - if (UUID.TryParse(avatar, out UUID key)) - { - int idx = land.LandData.ParcelAccessList.FindIndex( - delegate(LandAccessEntry e) - { - if (e.Flags == AccessList.Ban && e.AgentID.Equals(key)) - return true; - return false; - }); + int idx = land.LandData.ParcelAccessList.FindIndex( + delegate(LandAccessEntry e) + { + if (e.Flags == AccessList.Ban && e.AgentID.Equals(key)) + return true; + return false; + }); - if (idx != -1) - { - land.LandData.ParcelAccessList.RemoveAt(idx); - World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); - } + if (idx != -1) + { + land.LandData.ParcelAccessList.RemoveAt(idx); + World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); } } ScriptSleep(m_sleepMsOnRemoveFromLandBanList); @@ -14353,7 +14324,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetObjectPrimCount(LSL_Key object_id) { - if(!UUID.TryParse(object_id, out UUID id)) + if(!UUID.TryParse(object_id, out UUID id) || id.IsZero()) return 0; SceneObjectPart part = World.GetSceneObjectPart(id); @@ -14463,8 +14434,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetObjectDetails(LSL_Key id, LSL_List args) { LSL_List ret = new LSL_List(); - UUID key = new UUID(); - if (!UUID.TryParse(id, out key)) + if (!UUID.TryParse(id, out UUID key) || key.IsZero()) return ret; int count = 0; @@ -15015,18 +14985,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api World.AssetService.Get(assetID.ToString(), this, delegate(string i, object sender, AssetBase a) { - UUID uuid = UUID.Zero; - UUID.TryParse(i, out uuid); + UUID.TryParse(i, out UUID uuid); cb(uuid, a); }); } public LSL_Key llGetNumberOfNotecardLines(string name) { - - UUID assetID = UUID.Zero; - - if (!UUID.TryParse(name, out assetID)) + if (!UUID.TryParse(name, out UUID assetID)) { TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); @@ -15074,10 +15040,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key llGetNotecardLine(string name, int line) { - - UUID assetID = UUID.Zero; - - if (!UUID.TryParse(name, out assetID)) + if (!UUID.TryParse(name, out UUID assetID)) { TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); @@ -15128,7 +15091,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc) { - if (!UUID.TryParse(prim, out UUID id)) + if (!UUID.TryParse(prim, out UUID id) || id.IsZero()) return; SceneObjectPart obj = World.GetSceneObjectPart(id); @@ -15305,7 +15268,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetDisplayName(LSL_Key id) { - if (UUID.TryParse(id, out UUID key) && !key.IsZero()) + if (UUID.TryParse(id, out UUID key) && key.IsNotZero()) { ScenePresence presence = World.GetScenePresence(key); if (presence != null) @@ -16745,19 +16708,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llManageEstateAccess(int action, string avatar) { - EstateSettings estate = World.RegionInfo.EstateSettings; - bool isAccount = false; - bool isGroup = false; + if (!UUID.TryParse(avatar, out UUID id) || id.IsZero()) + return 0; + EstateSettings estate = World.RegionInfo.EstateSettings; if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID)) return 0; - UUID id = new UUID(); - if (!UUID.TryParse(avatar, out id)) - return 0; - UserAccount account = m_userAccountService.GetUserAccount(RegionScopeID, id); - isAccount = account != null ? true : false; + bool isAccount = account != null ? true : false; + bool isGroup = false; if (!isAccount) { IGroupsModule groups = World.RequestModuleInterface();