From 37ea05088610db79ad3c6c99d1dfa818e98ccc26 Mon Sep 17 00:00:00 2001 From: mingchen Date: Fri, 21 Dec 2007 00:35:55 +0000 Subject: *Removed some exceptions that were thrown in Land that is no longer needed. --- OpenSim/Region/Environment/LandManagement/Land.cs | 20 ++- .../Environment/LandManagement/LandManager.cs | 168 ++++++++++++--------- OpenSim/Region/Environment/PermissionManager.cs | 17 ++- .../ExtensionsScriptModule/ScriptInterpretedAPI.cs | 5 +- 4 files changed, 126 insertions(+), 84 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index da17a69..11ff0ee 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -227,6 +227,19 @@ namespace OpenSim.Region.Environment.LandManagement } } + public bool isEitherBannedOrRestricted(LLUUID avatar) + { + if (isBannedFromLand(avatar)) + { + return true; + } + else if (isRestrictedFromLand(avatar)) + { + return true; + } + return false; + } + public bool isBannedFromLand(LLUUID avatar) { if ((this.landData.landFlags & (uint)Parcel.ParcelFlags.UseBanList) > 0) @@ -274,9 +287,12 @@ namespace OpenSim.Region.Environment.LandManagement Land over = m_scene.LandManager.getLandObject((int) Math.Round(avatars[i].AbsolutePosition.X), (int) Math.Round(avatars[i].AbsolutePosition.Y)); - if (over.landData.localID == landData.localID) + if (over != null) { - sendLandUpdateToClient(avatars[i].ControllingClient); + if (over.landData.localID == landData.localID) + { + sendLandUpdateToClient(avatars[i].ControllingClient); + } } } } diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index f984d58..c360f7f 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -192,7 +192,8 @@ namespace OpenSim.Region.Environment.LandManagement { if (landIDList[x, y] == local_id) { - throw new Exception("Could not remove land object. Still being used at " + x + ", " + y); + return; + //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y); } } } @@ -210,7 +211,7 @@ namespace OpenSim.Region.Environment.LandManagement } else { - throw new Exception("Could not update land object. Local ID '" + local_id + "' does not exist"); + //throw new Exception("Could not update land object. Local ID '" + local_id + "' does not exist"); } } @@ -246,10 +247,7 @@ namespace OpenSim.Region.Environment.LandManagement if (x >= 64 || y >= 64 || x < 0 || y < 0) { - // These exceptions here will cause a lot of complaints from the users specifically because - // they happen every time at border crossings - - throw new Exception("Error: Parcel not found at point " + x + ", " + y); + return null; } else { @@ -366,9 +364,12 @@ namespace OpenSim.Region.Environment.LandManagement for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4) { Land p = getLandObject(stepXSelected, stepYSelected); - if (!selectedLandObjects.Contains(p)) + if (p != null) { - selectedLandObjects.Add(p); + if (!selectedLandObjects.Contains(p)) + { + selectedLandObjects.Add(p); + } } } } @@ -429,61 +430,66 @@ namespace OpenSim.Region.Environment.LandManagement { byte tempByte = (byte) 0; //This represents the byte for the current 4x4 Land currentParcelBlock = getLandObject(x*4, y*4); - - if (currentParcelBlock.landData.ownerID == remote_client.AgentId) + if (currentParcelBlock != null) { - //Owner Flag - tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_REQUESTER); - } - else if (currentParcelBlock.landData.salePrice > 0 && - (currentParcelBlock.landData.authBuyerID == LLUUID.Zero || - currentParcelBlock.landData.authBuyerID == remote_client.AgentId)) - { - //Sale Flag - tempByte = Convert.ToByte(tempByte | LAND_TYPE_IS_FOR_SALE); - } - else if (currentParcelBlock.landData.ownerID == LLUUID.Zero) - { - //Public Flag - tempByte = Convert.ToByte(tempByte | LAND_TYPE_PUBLIC); - } - else - { - //Other Flag - tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_OTHER); - } + if (currentParcelBlock.landData.ownerID == remote_client.AgentId) + { + //Owner Flag + tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_REQUESTER); + } + else if (currentParcelBlock.landData.salePrice > 0 && + (currentParcelBlock.landData.authBuyerID == LLUUID.Zero || + currentParcelBlock.landData.authBuyerID == remote_client.AgentId)) + { + //Sale Flag + tempByte = Convert.ToByte(tempByte | LAND_TYPE_IS_FOR_SALE); + } + else if (currentParcelBlock.landData.ownerID == LLUUID.Zero) + { + //Public Flag + tempByte = Convert.ToByte(tempByte | LAND_TYPE_PUBLIC); + } + else + { + //Other Flag + tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_OTHER); + } - //Now for border control - if (x == 0) - { - tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST); - } - else if (getLandObject((x - 1)*4, y*4) != currentParcelBlock) - { - tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST); - } + //Now for border control - if (y == 0) - { - tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH); - } - else if (getLandObject(x*4, (y - 1)*4) != currentParcelBlock) - { - tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH); - } + Land westParcel = getLandObject((x - 1) * 4, y * 4); + Land southParcel = getLandObject(x * 4, (y - 1) * 4); + if (x == 0) + { + tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST); + } + else if (westParcel != null && westParcel != currentParcelBlock) + { + tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST); + } - byteArray[byteArrayCount] = tempByte; - byteArrayCount++; - if (byteArrayCount >= LAND_BLOCKS_PER_PACKET) - { - byteArrayCount = 0; - packet = new ParcelOverlayPacket(); - packet.ParcelData.Data = byteArray; - packet.ParcelData.SequenceID = sequenceID; - remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task); - sequenceID++; - byteArray = new byte[LAND_BLOCKS_PER_PACKET]; + if (y == 0) + { + tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH); + } + else if (southParcel != null && southParcel != currentParcelBlock) + { + tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH); + } + + byteArray[byteArrayCount] = tempByte; + byteArrayCount++; + if (byteArrayCount >= LAND_BLOCKS_PER_PACKET) + { + byteArrayCount = 0; + packet = new ParcelOverlayPacket(); + packet.ParcelData.Data = byteArray; + packet.ParcelData.SequenceID = sequenceID; + remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task); + sequenceID++; + byteArray = new byte[LAND_BLOCKS_PER_PACKET]; + } } } } @@ -502,10 +508,13 @@ namespace OpenSim.Region.Environment.LandManagement for (y = 0; y < inc_y; y++) { Land currentParcel = getLandObject(start_x + x, start_y + y); - if (!temp.Contains(currentParcel)) + if (currentParcel != null) { - currentParcel.forceUpdateLandInfo(); - temp.Add(currentParcel); + if (!temp.Contains(currentParcel)) + { + currentParcel.forceUpdateLandInfo(); + temp.Add(currentParcel); + } } } } @@ -583,9 +592,12 @@ namespace OpenSim.Region.Environment.LandManagement for (y = -4; y <= 4; y += 4) { Land check = getLandObject(position.X + x, position.Y + y); - if (!parcelsNear.Contains(check)) + if (check != null) { - parcelsNear.Add(check); + if (!parcelsNear.Contains(check)) + { + parcelsNear.Add(check); + } } } } @@ -693,18 +705,21 @@ namespace OpenSim.Region.Environment.LandManagement sendLandUpdate(clientAvatar); sendOutNearestBanLine(remote_client); Land parcel = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); - if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) + if (parcel != null) { - - handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID); //They are going below the safety line! - if (!parcel.isBannedFromLand(clientAvatar.UUID)) + if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) { - clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; + + handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID); //They are going below the safety line! + if (!parcel.isBannedFromLand(clientAvatar.UUID)) + { + clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; + } + } + else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && parcel.isBannedFromLand(clientAvatar.UUID)) + { + sendYouAreBannedNotice(clientAvatar); } - } - else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && parcel.isBannedFromLand(clientAvatar.UUID)) - { - sendYouAreBannedNotice(clientAvatar); } } } @@ -712,11 +727,14 @@ namespace OpenSim.Region.Environment.LandManagement public void handleAnyClientMovement(ScenePresence avatar) //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance. { Land over = getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); - if (!over.isBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= BAN_LINE_SAFETY_HIEGHT) + if (over != null) { - avatar.lastKnownAllowedPosition = new Axiom.Math.Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); - + if (!over.isBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= BAN_LINE_SAFETY_HIEGHT) + { + avatar.lastKnownAllowedPosition = new Axiom.Math.Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); + + } } } diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index 37df180..53fa08a 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -110,6 +110,8 @@ namespace OpenSim.Region.Environment string reason = "Insufficient permission"; Land land = this.m_scene.LandManager.getLandObject(position.X, position.Y); + if (land == null) return false; + if ((land.landData.landFlags & ((int)Parcel.ParcelFlags.CreateObjects)) == (int)Parcel.ParcelFlags.CreateObjects) permission = true; @@ -176,8 +178,8 @@ namespace OpenSim.Region.Environment return OwnerMask; // Users should be able to edit what is over their land. - if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID == - user) + Land parcel = m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y); + if (parcel != null && parcel.landData.ownerID == user) return OwnerMask; // Estate users should be able to edit anything in the sim @@ -235,8 +237,8 @@ namespace OpenSim.Region.Environment permission = true; // Users should be able to edit what is over their land. - if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID == - user) + Land parcel = m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y); + if (parcel != null && parcel.landData.ownerID == user) permission = true; // Estate users should be able to edit anything in the sim @@ -399,7 +401,8 @@ namespace OpenSim.Region.Environment Y = 0; // Land owner can terraform too - if (GenericParcelPermission(user, m_scene.LandManager.getLandObject(X, Y))) + Land parcel = m_scene.LandManager.getLandObject(X, Y); + if (parcel != null && GenericParcelPermission(user, parcel)) permission = true; if (!permission) @@ -466,7 +469,9 @@ namespace OpenSim.Region.Environment protected virtual bool GenericParcelPermission(LLUUID user, LLVector3 pos) { - return GenericParcelPermission(user, m_scene.LandManager.getLandObject(pos.X, pos.Y)); + Land parcel = m_scene.LandManager.getLandObject(pos.X, pos.Y); + if (parcel == null) return false; + return GenericParcelPermission(user, parcel); } public virtual bool CanEditParcel(LLUUID user, Land parcel) diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs index 2895c4e..d6613e9 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs @@ -103,7 +103,10 @@ namespace OpenSim.Region.ExtensionsScriptModule { Vector myPosition = Task.AbsolutePosition; Land myParcel = Scene.LandManager.getLandObject(myPosition.X, myPosition.Y); - + if (myParcel == null) + { + //Dont do anything! + } MainLog.Instance.Warn("script", "Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); return; -- cgit v1.1