From be20f41637b6c06ce3ab16bc25851b6e43468e12 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 30 Apr 2008 21:43:47 +0000 Subject: * Cruft removal step #1. Cleaning Modules directory. --- .../Environment/Modules/World/Land/LandChannel.cs | 364 ++++++++++----------- .../Modules/World/Land/LandManagementModule.cs | 11 +- .../Environment/Modules/World/Land/LandObject.cs | 227 ++++++------- 3 files changed, 286 insertions(+), 316 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/World/Land') diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs index cbea07a..efc5234 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs @@ -43,61 +43,45 @@ namespace OpenSim.Region.Environment.Modules.World.Land //Land types set with flags in ParcelOverlay. //Only one of these can be used. - public const byte LAND_TYPE_PUBLIC = (byte)0; //Equals 00000000 - public const byte LAND_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001 - public const byte LAND_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010 - public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011 - public const byte LAND_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100 - public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101 - - //Flags that when set, a border on the given side will be placed - //NOTE: North and East is assumable by the west and south sides (if land to east has a west border, then I have an east border; etc) - //This took forever to figure out -- jeesh. /blame LL for even having to send these - public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000 - public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000 + public const float BAN_LINE_SAFETY_HIEGHT = 100; + public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte) 128; //Equals 10000000 + public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte) 64; //Equals 01000000 //RequestResults (I think these are right, they seem to work): - public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land + public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land //ParcelSelectObjects - public const int LAND_SELECT_OBJECTS_OWNER = 2; public const int LAND_SELECT_OBJECTS_GROUP = 4; public const int LAND_SELECT_OBJECTS_OTHER = 8; + public const int LAND_SELECT_OBJECTS_OWNER = 2; + public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101 + public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100 + public const byte LAND_TYPE_OWNED_BY_GROUP = (byte) 2; //Equals 00000010 + public const byte LAND_TYPE_OWNED_BY_OTHER = (byte) 1; //Equals 00000001 + public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte) 3; //Equals 00000011 + public const byte LAND_TYPE_PUBLIC = (byte) 0; //Equals 00000000 //These are other constants. Yay! public const int START_LAND_LOCAL_ID = 1; - public const float BAN_LINE_SAFETY_HIEGHT = 100; - #endregion - private Scene m_scene; - + private int[,] landIDList = new int[64,64]; private Dictionary landList = new Dictionary(); - private int lastLandLocalID = START_LAND_LOCAL_ID - 1; - private int[,] landIDList = new int[64, 64]; private bool landPrimCountTainted = false; + private int lastLandLocalID = START_LAND_LOCAL_ID - 1; private bool m_allowedForcefulBans = true; - public bool allowedForcefulBans - { - get - { - return m_allowedForcefulBans; - } - set - { - m_allowedForcefulBans = value; - } - } + private Scene m_scene; public LandChannel(Scene scene) { m_scene = scene; landIDList.Initialize(); } + #region Land Object From Storage Functions public void IncomingLandObjectsFromStorage(List data) @@ -133,10 +117,64 @@ namespace OpenSim.Region.Environment.Modules.World.Land resetSimLandObjects(); } - #endregion + #endregion #region Parcel Add/Remove/Get/Create + public void updateLandObject(int local_id, LandData newData) + { + if (landList.ContainsKey(local_id)) + { + landList[local_id].landData = newData.Copy(); + m_scene.EventManager.TriggerLandObjectUpdated((uint) local_id, landList[local_id]); + } + } + + /// + /// Get the land object at the specified point + /// + /// Value between 0 - 256 on the x axis of the point + /// Value between 0 - 256 on the y axis of the point + /// Land object at the point supplied + public ILandObject getLandObject(float x_float, float y_float) + { + int x; + int y; + + try + { + x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0))); + y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0))); + } + catch (OverflowException) + { + return null; + } + + if (x >= 64 || y >= 64 || x < 0 || y < 0) + { + return null; + } + else + { + return landList[landIDList[x, y]]; + } + } + + public ILandObject getLandObject(int x, int y) + { + if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || 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); + } + else + { + return landList[landIDList[x / 4, y / 4]]; + } + } + /// /// Creates a basic Parcel object without an owner (a zeroed key) /// @@ -154,7 +192,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land { lastLandLocalID++; new_land.landData.localID = lastLandLocalID; - landList.Add(lastLandLocalID, (LandObject)new_land.Copy()); + landList.Add(lastLandLocalID, (LandObject) new_land.Copy()); bool[,] landBitmap = new_land.getLandBitmap(); @@ -197,15 +235,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land landList.Remove(local_id); } - public void updateLandObject(int local_id, LandData newData) - { - if (landList.ContainsKey(local_id)) - { - landList[local_id].landData = newData.Copy(); - m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]); - } - } - private void performFinalLandJoin(ILandObject master, ILandObject slave) { int x, y; @@ -225,66 +254,113 @@ namespace OpenSim.Region.Environment.Modules.World.Land updateLandObject(master.landData.localID, master.landData); } - /// - /// Get the land object at the specified point - /// - /// Value between 0 - 256 on the x axis of the point - /// Value between 0 - 256 on the y axis of the point - /// Land object at the point supplied - public ILandObject getLandObject(float x_float, float y_float) + public ILandObject getLandObject(int parcelLocalID) { - int x; - int y; - - try + lock (landList) { - x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0))); - y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0))); + if (landList.ContainsKey(parcelLocalID)) + { + return landList[parcelLocalID]; + } } - catch (OverflowException) + return null; + } + + #endregion + + #region Parcel Modification + + public void resetAllLandPrimCounts() + { + foreach (LandObject p in landList.Values) { - return null; + p.resetLandPrimCounts(); } + } - if (x >= 64 || y >= 64 || x < 0 || y < 0) + public void setPrimsTainted() + { + landPrimCountTainted = true; + } + + public bool isLandPrimCountTainted() + { + return landPrimCountTainted; + } + + public void addPrimToLandPrimCounts(SceneObjectGroup obj) + { + LLVector3 position = obj.AbsolutePosition; + ILandObject landUnderPrim = getLandObject(position.X, position.Y); + if (landUnderPrim != null) { - return null; + landUnderPrim.addPrimToCount(obj); } - else + } + + public void removePrimFromLandPrimCounts(SceneObjectGroup obj) + { + foreach (LandObject p in landList.Values) { - return landList[landIDList[x, y]]; + p.removePrimFromCount(obj); } } - public ILandObject getLandObject(int parcelLocalID) + public void finalizeLandPrimCountUpdate() { - lock (landList) + //Get Simwide prim count for owner + Dictionary> landOwnersAndParcels = new Dictionary>(); + foreach (LandObject p in landList.Values) { - if (landList.ContainsKey(parcelLocalID)) + if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID)) { - return landList[parcelLocalID]; + List tempList = new List(); + tempList.Add(p); + landOwnersAndParcels.Add(p.landData.ownerID, tempList); + } + else + { + landOwnersAndParcels[p.landData.ownerID].Add(p); } } - return null; - } - public ILandObject getLandObject(int x, int y) - { - if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0) + foreach (LLUUID owner in landOwnersAndParcels.Keys) { - // 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); + int simArea = 0; + int simPrims = 0; + foreach (LandObject p in landOwnersAndParcels[owner]) + { + simArea += p.landData.area; + simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims + + p.landData.selectedPrims; + } + + foreach (LandObject p in landOwnersAndParcels[owner]) + { + p.landData.simwideArea = simArea; + p.landData.simwidePrims = simPrims; + } } - else + } + + public void updateLandPrimCounts() + { + foreach (EntityBase obj in m_scene.Entities.Values) { - return landList[landIDList[x / 4, y / 4]]; + if (obj is SceneObjectGroup) + { + m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj); + } } } - #endregion - - #region Parcel Modification + public void performParcelPrimCountUpdate() + { + resetAllLandPrimCounts(); + m_scene.EventManager.TriggerParcelPrimCountUpdate(); + finalizeLandPrimCountUpdate(); + landPrimCountTainted = false; + } /// /// Subdivides a piece of land @@ -435,97 +511,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land return true; } - public void resetAllLandPrimCounts() - { - foreach (LandObject p in landList.Values) - { - p.resetLandPrimCounts(); - } - } - - public void setPrimsTainted() - { - landPrimCountTainted = true; - } - - public bool isLandPrimCountTainted() - { - return landPrimCountTainted; - } - - public void addPrimToLandPrimCounts(SceneObjectGroup obj) - { - LLVector3 position = obj.AbsolutePosition; - ILandObject landUnderPrim = getLandObject(position.X, position.Y); - if (landUnderPrim != null) - { - landUnderPrim.addPrimToCount(obj); - } - } - - public void removePrimFromLandPrimCounts(SceneObjectGroup obj) - { - foreach (LandObject p in landList.Values) - { - p.removePrimFromCount(obj); - } - } - - public void finalizeLandPrimCountUpdate() - { - //Get Simwide prim count for owner - Dictionary> landOwnersAndParcels = new Dictionary>(); - foreach (LandObject p in landList.Values) - { - if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID)) - { - List tempList = new List(); - tempList.Add(p); - landOwnersAndParcels.Add(p.landData.ownerID, tempList); - } - else - { - landOwnersAndParcels[p.landData.ownerID].Add(p); - } - } - - foreach (LLUUID owner in landOwnersAndParcels.Keys) - { - int simArea = 0; - int simPrims = 0; - foreach (LandObject p in landOwnersAndParcels[owner]) - { - simArea += p.landData.area; - simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims + - p.landData.selectedPrims; - } - - foreach (LandObject p in landOwnersAndParcels[owner]) - { - p.landData.simwideArea = simArea; - p.landData.simwidePrims = simPrims; - } - } - } - - public void updateLandPrimCounts() - { - foreach (EntityBase obj in m_scene.Entities.Values) - { - if (obj is SceneObjectGroup) - { - m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj); - } - } - } - - public void performParcelPrimCountUpdate() - { - resetAllLandPrimCounts(); - m_scene.EventManager.TriggerParcelPrimCountUpdate(); - finalizeLandPrimCountUpdate(); - landPrimCountTainted = false; - } #endregion #region Parcel Updating @@ -547,7 +532,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land { for (x = 0; x < 64; x++) { - byte tempByte = (byte)0; //This represents the byte for the current 4x4 + byte tempByte = (byte) 0; //This represents the byte for the current 4x4 ILandObject currentParcelBlock = null; try @@ -623,10 +608,10 @@ namespace OpenSim.Region.Environment.Modules.World.Land if (byteArrayCount >= LAND_BLOCKS_PER_PACKET) { byteArrayCount = 0; - packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay); + packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay); packet.ParcelData.Data = byteArray; packet.ParcelData.SequenceID = sequenceID; - remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task); + remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task); sequenceID++; byteArray = new byte[LAND_BLOCKS_PER_PACKET]; } @@ -652,7 +637,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land { for (y = 0; y < inc_y; y++) { - ILandObject currentParcel = null; try { @@ -693,7 +677,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land if (landList.ContainsKey(packet.ParcelData.LocalID)) { landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client); - } } @@ -719,6 +702,14 @@ namespace OpenSim.Region.Environment.Modules.World.Land #endregion + #region ILandChannel Members + + public bool allowedForcefulBans + { + get { return m_allowedForcefulBans; } + set { m_allowedForcefulBans = value; } + } + /// /// Resets the sim to the default land object (full sim piece of land owned by the default user) /// @@ -731,7 +722,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene); - fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); + fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize)); fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; addLandObject(fullSimParcel); @@ -816,18 +807,17 @@ namespace OpenSim.Region.Environment.Modules.World.Land { if (presence.UUID == avatar.AgentId) { - List checkLandParcels = parcelsNearPoint(presence.AbsolutePosition); foreach (ILandObject checkBan in checkLandParcels) { if (checkBan.isBannedFromLand(avatar.AgentId)) { - checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar); + checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar); return; //Only send one } else if (checkBan.isRestrictedFromLand(avatar.AgentId)) { - checkBan.sendLandProperties(-40000, false, (int)ParcelManager.ParcelResult.Single, avatar); + checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar); return; //Only send one } } @@ -841,8 +831,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land ILandObject over = null; try { - over = getLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), - (int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); + over = getLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), + (int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); } catch (Exception) { @@ -873,11 +863,12 @@ namespace OpenSim.Region.Environment.Modules.World.Land } } } + public void sendLandUpdate(ScenePresence avatar) { sendLandUpdate(avatar, false); - } + public void handleSignificantClientMovement(IClientAPI remote_client) { ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId); @@ -949,6 +940,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land } } + #endregion + // If the economy has been validated by the economy module, // and land has been validated as well, this method transfers // the land ownership @@ -961,7 +954,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land { if (landList.ContainsKey(e.parcelLocalID)) { - landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint)e.transactionID, e.parcelPrice, e.parcelArea); + landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint) e.transactionID, e.parcelPrice, e.parcelArea); return; } } @@ -989,17 +982,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land LLUUID AuthorizedID = lob.landData.authBuyerID; int saleprice = lob.landData.salePrice; LLUUID pOwnerID = lob.landData.ownerID; - - bool landforsale = ((lob.landData.landFlags & (uint)(Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0); + + bool landforsale = ((lob.landData.landFlags & + (uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0); if ((AuthorizedID == LLUUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale) { lock (e) { e.parcelOwnerID = pOwnerID; e.landValidated = true; - } - } } } diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs index c5ffdca..3f09bd5 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs @@ -27,7 +27,6 @@ using Nini.Config; using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Modules.World.Land; using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Modules.World.Land @@ -43,7 +42,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land { m_scene = scene; landChannel = new LandChannel(scene); - + m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts; m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts; m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel); @@ -53,18 +52,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land lock (m_scene) { - m_scene.LandChannel = (ILandChannel)landChannel; + m_scene.LandChannel = (ILandChannel) landChannel; } } public void PostInitialise() { - } public void Close() { - } public string Name @@ -77,10 +74,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land get { return false; } } - - - - #endregion } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs index 693c55d..368e113 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs @@ -33,7 +33,6 @@ using libsecondlife.Packets; using log4net; using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Modules.World.Land; using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Modules.World.Land @@ -46,23 +45,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land #region Member Variables private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private bool[,] m_landBitmap = new bool[64,64]; protected LandData m_landData = new LandData(); - protected List primsOverMe = new List(); protected Scene m_scene; - - private bool[,] m_landBitmap = new bool[64,64]; + protected List primsOverMe = new List(); public bool[,] landBitmap { - get - { - return m_landBitmap; - } - set - { - m_landBitmap = value; - } + get { return m_landBitmap; } + set { m_landBitmap = value; } } #endregion @@ -71,25 +63,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land public LandData landData { - get - { - return m_landData; - } + get { return m_landData; } - set - { - m_landData = value; - } + set { m_landData = value; } } - public LLUUID regionUUID + public LLUUID regionUUID { get { return m_scene.RegionInfo.RegionID; } } - #endregion - - #region Constructors public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene) @@ -115,7 +98,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land { if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) { - return (landBitmap[x/4, y/4] == true); + return (landBitmap[x / 4, y / 4] == true); } else { @@ -149,7 +132,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land { ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties); // TODO: don't create new blocks if recycling an old packet - + updatePacket.ParcelData.AABBMax = landData.AABBMax; updatePacket.ParcelData.AABBMin = landData.AABBMin; updatePacket.ParcelData.Area = landData.area; @@ -171,7 +154,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land { updatePacket.ParcelData.MaxPrims = Convert.ToInt32( - Math.Round((Convert.ToDecimal(landData.area)/Convert.ToDecimal(65536))*m_scene.objectCapacity* + Math.Round((Convert.ToDecimal(landData.area) / Convert.ToDecimal(65536)) * m_scene.objectCapacity * Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor))); } else @@ -193,7 +176,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land updatePacket.ParcelData.PassHours = landData.passHours; updatePacket.ParcelData.PassPrice = landData.passPrice; updatePacket.ParcelData.PublicCount = 0; //unemplemented - + uint regionFlags = (uint) m_scene.RegionInfo.EstateSettings.regionFlags; updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) > 0); @@ -255,12 +238,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land newData.snapshotID = packet.ParcelData.SnapshotID; newData.userLocation = packet.ParcelData.UserLocation; newData.userLookAt = packet.ParcelData.UserLookAt; - + m_scene.LandChannel.updateLandObject(landData.localID, newData); sendLandUpdateToAvatarsOverMe(); } } + public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area) { LandData newData = landData.Copy(); @@ -272,7 +256,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land newData.claimPrice = claimprice; newData.salePrice = 0; newData.authBuyerID = LLUUID.Zero; - newData.landFlags &= ~(uint)(Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects); + newData.landFlags &= ~(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects); m_scene.LandChannel.updateLandObject(landData.localID, newData); sendLandUpdateToAvatarsOverMe(); @@ -339,12 +323,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land try { over = - m_scene.LandChannel.getLandObject((int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.X))), - (int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.Y)))); + m_scene.LandChannel.getLandObject((int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.X))), + (int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.Y)))); } catch (Exception) { - m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + Math.Round(avatars[i].AbsolutePosition.Y)); + m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + + Math.Round(avatars[i].AbsolutePosition.Y)); } if (over != null) @@ -463,6 +448,25 @@ namespace OpenSim.Region.Environment.Modules.World.Land #region Update Functions + public void updateLandBitmapByteArray() + { + landData.landBitmapByteArray = convertLandBitmapToBytes(); + } + + /// + /// Update all settings in land such as area, bitmap byte array, etc + /// + public void forceUpdateLandInfo() + { + updateAABBAndAreaValues(); + updateLandBitmapByteArray(); + } + + public void setLandBitmapFromByteArray() + { + landBitmap = convertBytesToLandBitmap(); + } + /// /// Updates the AABBMin and AABBMax values after area/shape modification of the land object /// @@ -495,8 +499,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land if (ty > 255) ty = 255; landData.AABBMin = - new LLVector3((float)(min_x * 4), (float)(min_y * 4), - (float)m_scene.Heightmap[tx, ty]); + new LLVector3((float) (min_x * 4), (float) (min_y * 4), + (float) m_scene.Heightmap[tx, ty]); tx = max_x * 4; if (tx > 255) @@ -505,30 +509,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land if (ty > 255) ty = 255; landData.AABBMax = - new LLVector3((float)(max_x * 4), (float)(max_y * 4), - (float)m_scene.Heightmap[tx, ty]); + new LLVector3((float) (max_x * 4), (float) (max_y * 4), + (float) m_scene.Heightmap[tx, ty]); landData.area = tempArea; } - public void updateLandBitmapByteArray() - { - landData.landBitmapByteArray = convertLandBitmapToBytes(); - } - - /// - /// Update all settings in land such as area, bitmap byte array, etc - /// - public void forceUpdateLandInfo() - { - updateAABBAndAreaValues(); - updateLandBitmapByteArray(); - } - - public void setLandBitmapFromByteArray() - { - landBitmap = convertBytesToLandBitmap(); - } - #endregion #region Land Bitmap Functions @@ -562,63 +547,12 @@ namespace OpenSim.Region.Environment.Modules.World.Land } /// - /// Converts the land bitmap to a packet friendly byte array - /// - /// - private byte[] convertLandBitmapToBytes() - { - byte[] tempConvertArr = new byte[512]; - byte tempByte = 0; - int x, y, i, byteNum = 0; - i = 0; - for (y = 0; y < 64; y++) - { - for (x = 0; x < 64; x++) - { - tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++%8)); - if (i%8 == 0) - { - tempConvertArr[byteNum] = tempByte; - tempByte = (byte) 0; - i = 0; - byteNum++; - } - } - } - return tempConvertArr; - } - - private bool[,] convertBytesToLandBitmap() - { - bool[,] tempConvertMap = new bool[64,64]; - tempConvertMap.Initialize(); - byte tempByte = 0; - int x = 0, y = 0, i = 0, bitNum = 0; - for (i = 0; i < 512; i++) - { - tempByte = landData.landBitmapByteArray[i]; - for (bitNum = 0; bitNum < 8; bitNum++) - { - bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1); - tempConvertMap[x, y] = bit; - x++; - if (x > 63) - { - x = 0; - y++; - } - } - } - return tempConvertMap; - } - - /// /// Full sim land object creation /// /// public bool[,] basicFullRegionLandBitmap() { - return getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize); + return getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize); } /// @@ -662,8 +596,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land { for (x = 0; x < 64; x++) { - if (x >= start_x/4 && x < end_x/4 - && y >= start_y/4 && y < end_y/4) + if (x >= start_x / 4 && x < end_x / 4 + && y >= start_y / 4 && y < end_y / 4) { land_bitmap[x, y] = set_value; } @@ -705,6 +639,57 @@ namespace OpenSim.Region.Environment.Modules.World.Land return bitmap_base; } + /// + /// Converts the land bitmap to a packet friendly byte array + /// + /// + private byte[] convertLandBitmapToBytes() + { + byte[] tempConvertArr = new byte[512]; + byte tempByte = 0; + int x, y, i, byteNum = 0; + i = 0; + for (y = 0; y < 64; y++) + { + for (x = 0; x < 64; x++) + { + tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++ % 8)); + if (i % 8 == 0) + { + tempConvertArr[byteNum] = tempByte; + tempByte = (byte) 0; + i = 0; + byteNum++; + } + } + } + return tempConvertArr; + } + + private bool[,] convertBytesToLandBitmap() + { + bool[,] tempConvertMap = new bool[64,64]; + tempConvertMap.Initialize(); + byte tempByte = 0; + int x = 0, y = 0, i = 0, bitNum = 0; + for (i = 0; i < 512; i++) + { + tempByte = landData.landBitmapByteArray[i]; + for (bitNum = 0; bitNum < 8; bitNum++) + { + bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1); + tempConvertMap[x, y] = bit; + x++; + if (x > 63) + { + x = 0; + y++; + } + } + } + return tempConvertMap; + } + #endregion #region Object Select and Object Owner Listing @@ -781,7 +766,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land public void sendLandObjectOwners(IClientAPI remote_client) { Dictionary primCount = new Dictionary(); - ParcelObjectOwnersReplyPacket pack + ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply); // TODO: don't create new blocks if recycling an old packet @@ -807,21 +792,21 @@ namespace OpenSim.Region.Environment.Modules.World.Land m_log.Error("[LAND]: Unable to match a prim with it's owner."); } } - + int notifyCount = primCount.Count; - + if (notifyCount > 0) { if (notifyCount > 32) { m_log.InfoFormat( "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}" - + " - a developer might want to investigate whether this is a hard limit", 32); - + + " - a developer might want to investigate whether this is a hard limit", 32); + notifyCount = 32; } - - ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock + + ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount]; int num = 0; @@ -834,16 +819,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land dataBlock[num].OwnerID = owner; num++; - + if (num >= notifyCount) { break; } } - + pack.Data = dataBlock; } - + remote_client.OutPacket(pack, ThrottleOutPacketType.Task); } @@ -937,7 +922,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land #endregion #endregion - + #endregion } } \ No newline at end of file -- cgit v1.1