diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs index e8dbc40cdd..a67add4891 100644 --- a/OpenSim/Framework/Constants.cs +++ b/OpenSim/Framework/Constants.cs @@ -47,6 +47,8 @@ namespace OpenSim.Framework public const int MinRegionSize = 256; public const int TerrainPatchSize = 16; + public const int LandUnit = 4; // parcels only have sizes multiple of this + public const float MinSimulationHeight = -100f; public const float MaxSimulationHeight = 50000f; public const float MinTerrainHeightmap = -100f; diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 1186edb8cc..5c4fcce0b2 100755 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -38,14 +38,11 @@ using OpenMetaverse.StructuredData; using OpenMetaverse.Messages.Linden; using Mono.Addins; using OpenSim.Framework; -using OpenSim.Framework.Capabilities; using OpenSim.Framework.Console; -using OpenSim.Framework.Servers; using OpenSim.Framework.Monitoring; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Services.Interfaces; using Caps = OpenSim.Framework.Capabilities.Caps; using GridRegion = OpenSim.Services.Interfaces.GridRegion; @@ -72,8 +69,6 @@ namespace OpenSim.Region.CoreModules.World.Land /// Minimum land unit size in region co-ordinates. /// - public const int LandUnit = 4; - private Scene m_scene; //private LandChannel m_landChannel; @@ -166,7 +161,7 @@ namespace OpenSim.Region.CoreModules.World.Land m_regionHandler = m_scene.RegionInfo.RegionHandle; m_regionSizeX = (int)m_scene.RegionInfo.RegionSizeX; m_regionSizeY = (int)m_scene.RegionInfo.RegionSizeY; - m_landIDList = new int[m_regionSizeX / LandUnit, m_regionSizeY / LandUnit]; + m_landIDList = new int[m_regionSizeX / Constants.LandUnit, m_regionSizeY / Constants.LandUnit]; m_scene.LandChannel = this; @@ -309,7 +304,7 @@ namespace OpenSim.Region.CoreModules.World.Land m_landFakeIDs.Clear(); m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; - m_landIDList = new int[m_regionSizeX / LandUnit, m_regionSizeY / LandUnit]; + m_landIDList = new int[m_regionSizeX / Constants.LandUnit, m_regionSizeY / Constants.LandUnit]; } } @@ -997,7 +992,7 @@ namespace OpenSim.Region.CoreModules.World.Land { try { - return m_landList[m_landIDList[avx / LandUnit, avy / LandUnit]]; + return m_landList[m_landIDList[avx / Constants.LandUnit, avy / Constants.LandUnit]]; } catch (IndexOutOfRangeException) { @@ -1032,7 +1027,7 @@ namespace OpenSim.Region.CoreModules.World.Land { try { - return m_landList[m_landIDList[x / LandUnit, y / LandUnit]]; + return m_landList[m_landIDList[x / Constants.LandUnit, y / Constants.LandUnit]]; } catch (IndexOutOfRangeException) { @@ -1404,12 +1399,12 @@ namespace OpenSim.Region.CoreModules.World.Land int byteArrayCount = 0; int sequenceID = 0; - int sx = m_regionSizeX / LandUnit; + int sx = m_regionSizeX / Constants.LandUnit; byte curByte; byte tmpByte; // Layer data is in LandUnit (4m) chunks - for (int y = 0; y < m_regionSizeY / LandUnit; ++y) + for (int y = 0; y < m_regionSizeY / Constants.LandUnit; ++y) { for (int x = 0; x < sx;) { @@ -1546,8 +1541,8 @@ namespace OpenSim.Region.CoreModules.World.Land if (start_x >= m_regionSizeX || start_y >= m_regionSizeX || end_x > m_regionSizeX || end_y > m_regionSizeY) return; - if (end_x - start_x <= LandUnit && - end_y - start_y <= LandUnit) + if (end_x - start_x <= Constants.LandUnit && + end_y - start_y <= Constants.LandUnit) { ILandObject parcel = GetLandObject(start_x, start_y); if(parcel != null) @@ -1555,10 +1550,10 @@ namespace OpenSim.Region.CoreModules.World.Land return; } - start_x /= LandUnit; - start_y /= LandUnit; - end_x /= LandUnit; - end_y /= LandUnit; + start_x /= Constants.LandUnit; + start_y /= Constants.LandUnit; + end_x /= Constants.LandUnit; + end_y /= Constants.LandUnit; //Get the land objects within the bounds Dictionary temp = new Dictionary(); @@ -1840,9 +1835,9 @@ namespace OpenSim.Region.CoreModules.World.Land IncomingLandObjectFromStorage(data[i]); // Layer data is in LandUnit (4m) chunks - for (int y = 0; y < m_regionSizeY / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); y++) + for (int y = 0; y < m_regionSizeY / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / Constants.LandUnit); y++) { - for (int x = 0; x < m_regionSizeX / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); x++) + for (int x = 0; x < m_regionSizeX / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / Constants.LandUnit); x++) { if (m_landIDList[x, y] == 0) { diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 72b883dbff..afb42311d5 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -28,6 +28,8 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Runtime.CompilerServices; + using log4net; using OpenMetaverse; using OpenSim.Framework; @@ -49,17 +51,22 @@ namespace OpenSim.Region.CoreModules.World.Land protected const int GROUPMEMBERCACHETIMEOUT = 30000; // cache invalidation after 30s - private readonly int landUnit = 4; - - private int m_lastSeqId = 0; + private int m_lastSeqId = 0; private int m_expiryCounter = 0; - protected Scene m_scene; + protected readonly Scene m_scene; + protected readonly int m_regionSizeX; + protected readonly int m_regionSizeY; + protected readonly RegionInfo m_regionInfo; + protected readonly RegionSettings m_regionSettings; + protected readonly ScenePermissions m_scenePermissions; + protected readonly EstateSettings m_estateSettings; + protected readonly List primsOverMe = new List(); - private readonly Dictionary m_listTransactions = new Dictionary(); + private readonly ExpiringCacheOS m_listTransactions = new ExpiringCacheOS(30000); private readonly object m_listTransactionsLock = new object(); - protected readonly ExpiringCacheOS m_groupMemberCache = new ExpiringCacheOS(); + protected readonly ExpiringCacheOS m_groupMemberCache = new ExpiringCacheOS(30000); IDwellModule m_dwellModule; private bool[,] m_landBitmap; @@ -130,7 +137,7 @@ namespace OpenSim.Region.CoreModules.World.Land public UUID RegionUUID { - get { return m_scene.RegionInfo.RegionID; } + get { return m_regionInfo.RegionID; } } private Vector2 m_startPoint = Vector2.Zero; @@ -164,11 +171,13 @@ namespace OpenSim.Region.CoreModules.World.Land } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public ISceneObject[] GetSceneObjectGroups() { return primsOverMe.ToArray(); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public Vector2? GetNearestPoint(Vector3 pos) { Vector3 direction = new Vector3(m_centerPoint.X - pos.X, m_centerPoint.Y - pos.Y, 0f ); @@ -180,8 +189,8 @@ namespace OpenSim.Region.CoreModules.World.Land Vector2 testpos; Vector2 direction; - testpos.X = pos.X / landUnit; - testpos.Y = pos.Y / landUnit; + testpos.X = pos.X / Constants.LandUnit; + testpos.Y = pos.Y / Constants.LandUnit; if(LandBitmap[(int)testpos.X, (int)testpos.Y]) return new Vector2(pos.X, pos.Y); // we are already here @@ -194,8 +203,8 @@ namespace OpenSim.Region.CoreModules.World.Land direction.Normalize(); - int minx = (int)(m_AABBmin.X / landUnit); - int maxx = (int)(m_AABBmax.X / landUnit); + int minx = (int)(m_AABBmin.X / Constants.LandUnit); + int maxx = (int)(m_AABBmax.X / Constants.LandUnit); // check against AABB if(direction.X > 0f) @@ -220,8 +229,8 @@ namespace OpenSim.Region.CoreModules.World.Land return null; // will never get there } - int miny = (int)(m_AABBmin.Y / landUnit); - int maxy = (int)(m_AABBmax.Y / landUnit); + int miny = (int)(m_AABBmin.Y / Constants.LandUnit); + int maxy = (int)(m_AABBmax.Y / Constants.LandUnit); if(direction.Y > 0f) { @@ -259,13 +268,13 @@ namespace OpenSim.Region.CoreModules.World.Land return null; } - testpos *= landUnit; + testpos *= Constants.LandUnit; float ftmp; if(Math.Abs(direction.X) > Math.Abs(direction.Y)) { if(direction.X < 0) - testpos.X += landUnit - 0.5f; + testpos.X += Constants.LandUnit - 0.5f; else testpos.X += 0.5f; ftmp = testpos.X - pos.X; @@ -278,7 +287,7 @@ namespace OpenSim.Region.CoreModules.World.Land ftmp = testpos.Y + .5f; else { - testpos.Y += landUnit - 0.5f; + testpos.Y += Constants.LandUnit - 0.5f; if(ftmp > testpos.Y) ftmp = testpos.Y; } @@ -287,7 +296,7 @@ namespace OpenSim.Region.CoreModules.World.Land else { if(direction.Y < 0) - testpos.Y += landUnit - 0.5f; + testpos.Y += Constants.LandUnit - 0.5f; else testpos.Y += 0.5f; ftmp = testpos.Y - pos.Y; @@ -300,7 +309,7 @@ namespace OpenSim.Region.CoreModules.World.Land ftmp = testpos.X + .5f; else { - testpos.X += landUnit - 0.5f; + testpos.X += Constants.LandUnit - 0.5f; if(ftmp > testpos.X) ftmp = testpos.X; } @@ -316,6 +325,14 @@ namespace OpenSim.Region.CoreModules.World.Land { LandData = landData.Copy(); m_scene = scene; + m_scenePermissions = scene.Permissions; + + m_regionInfo = scene.RegionInfo; + m_regionSettings = scene.RegionInfo.RegionSettings; + m_estateSettings = m_regionInfo.EstateSettings; + + m_regionSizeX = (int)m_regionInfo.RegionSizeX; + m_regionSizeY = (int)m_regionInfo.RegionSizeY; m_scene.EventManager.OnFrame += OnFrame; m_dwellModule = m_scene.RequestModuleInterface(); } @@ -324,10 +341,21 @@ namespace OpenSim.Region.CoreModules.World.Land { m_scene = scene; if (m_scene == null) - LandBitmap = new bool[Constants.RegionSize / landUnit, Constants.RegionSize / landUnit]; + { + m_regionSizeX = (int)Constants.RegionSize; + m_regionSizeY = (int)Constants.RegionSize; + LandBitmap = new bool[Constants.RegionSize / Constants.LandUnit, Constants.RegionSize / Constants.LandUnit]; + } else { - LandBitmap = new bool[m_scene.RegionInfo.RegionSizeX / landUnit, m_scene.RegionInfo.RegionSizeY / landUnit]; + m_scenePermissions = scene.Permissions; + m_regionInfo = scene.RegionInfo; + m_regionSettings = scene.RegionInfo.RegionSettings; + m_estateSettings = m_regionInfo.EstateSettings; + + m_regionSizeX = (int)m_regionInfo.RegionSizeX; + m_regionSizeY = (int)m_regionInfo.RegionSizeY; + LandBitmap = new bool[m_regionSizeX / Constants.LandUnit, m_regionSizeY / Constants.LandUnit]; m_dwellModule = m_scene.RequestModuleInterface(); } @@ -368,11 +396,12 @@ namespace OpenSim.Region.CoreModules.World.Land /// /// /// Returns true if the piece of land contains the specified point + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool ContainsPoint(int x, int y) { - if (x >= 0 && y >= 0 && x < m_scene.RegionInfo.RegionSizeX && y < m_scene.RegionInfo.RegionSizeY) + if (x >= 0 && y >= 0 && x < m_regionSizeX && y < m_regionSizeY) { - return LandBitmap[x / landUnit, y / landUnit]; + return LandBitmap[x / Constants.LandUnit, y / Constants.LandUnit]; } else { @@ -380,6 +409,7 @@ namespace OpenSim.Region.CoreModules.World.Land } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public ILandObject Copy() { ILandObject newLand = new LandObject(LandData, m_scene); @@ -390,15 +420,19 @@ namespace OpenSim.Region.CoreModules.World.Land static overrideParcelMaxPrimCountDelegate overrideParcelMaxPrimCount; static overrideSimulatorMaxPrimCountDelegate overrideSimulatorMaxPrimCount; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel) { overrideParcelMaxPrimCount = overrideDel; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel) { overrideSimulatorMaxPrimCount = overrideDel; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public int GetParcelMaxPrimCount() { if (overrideParcelMaxPrimCount != null) @@ -410,20 +444,21 @@ namespace OpenSim.Region.CoreModules.World.Land // Normal Calculations int parcelMax = (int)( (double)LandData.Area - * (double)m_scene.RegionInfo.ObjectCapacity - * (double)m_scene.RegionInfo.RegionSettings.ObjectBonus - / (double)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY) + * (double)m_regionInfo.ObjectCapacity + * (double)m_regionSettings.ObjectBonus + / (double)(m_regionSizeX * m_regionSizeY) + 0.5 ); - if(parcelMax > m_scene.RegionInfo.ObjectCapacity) - parcelMax = m_scene.RegionInfo.ObjectCapacity; + if(parcelMax > m_regionInfo.ObjectCapacity) + parcelMax = m_regionInfo.ObjectCapacity; - //m_log.DebugFormat("Area: {0}, Capacity {1}, Bonus {2}, Parcel {3}", LandData.Area, m_scene.RegionInfo.ObjectCapacity, m_scene.RegionInfo.RegionSettings.ObjectBonus, parcelMax); + //m_log.DebugFormat("Area: {0}, Capacity {1}, Bonus {2}, Parcel {3}", LandData.Area, m_regionInfo.ObjectCapacity, m_regionInfo.RegionSettings.ObjectBonus, parcelMax); return parcelMax; } } // the total prims a parcel owner can have on a region + [MethodImpl(MethodImplOptions.AggressiveInlining)] public int GetSimulatorMaxPrimCount() { if (overrideSimulatorMaxPrimCount != null) @@ -434,15 +469,15 @@ namespace OpenSim.Region.CoreModules.World.Land { //Normal Calculations int simMax = (int)( (double)LandData.SimwideArea - * (double)m_scene.RegionInfo.ObjectCapacity - * (double)m_scene.RegionInfo.RegionSettings.ObjectBonus - / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY) + * (double)m_regionInfo.ObjectCapacity + * (double)m_regionSettings.ObjectBonus + / (long)(m_regionSizeX * m_regionSizeY) +0.5 ); // sanity check - if(simMax > m_scene.RegionInfo.ObjectCapacity) - simMax = m_scene.RegionInfo.ObjectCapacity; + if(simMax > m_regionInfo.ObjectCapacity) + simMax = m_regionInfo.ObjectCapacity; //m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}, SimWidePrims {3}", - // LandData.SimwideArea, m_scene.RegionInfo.ObjectCapacity, simMax, LandData.SimwidePrims); + // LandData.SimwideArea, m_regionInfo.ObjectCapacity, simMax, LandData.SimwidePrims); return simMax; } } @@ -453,7 +488,7 @@ namespace OpenSim.Region.CoreModules.World.Land public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client) { - if(m_scene.RegionInfo.RegionSettings.AllowDamage) + if(m_regionSettings.AllowDamage) remote_client.SceneAgent.Invulnerable = false; else remote_client.SceneAgent.Invulnerable = (m_landData.Flags & (uint)ParcelFlags.AllowDamage) == 0; @@ -484,7 +519,7 @@ namespace OpenSim.Region.CoreModules.World.Land remote_client.SendLandProperties(seq_id, snap_selection, request_result, this, - (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, + (float)m_regionSettings.ObjectBonus, GetParcelMaxPrimCount(), GetSimulatorMaxPrimCount(), regionFlags); } @@ -502,7 +537,7 @@ namespace OpenSim.Region.CoreModules.World.Land // ParcelFlags.ForSaleObjects // ParcelFlags.LindenHome - if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions, false)) + if (m_scenePermissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions, false)) { allowedDelta |= (uint)(ParcelFlags.AllowLandmark | ParcelFlags.AllowTerraform | @@ -520,7 +555,7 @@ namespace OpenSim.Region.CoreModules.World.Land newData.GroupAVSounds = args.GroupAVSounds; } - if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandSetSale, true)) + if (m_scenePermissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandSetSale, true)) { if (args.AuthBuyerID != newData.AuthBuyerID || args.SalePrice != newData.SalePrice) @@ -545,7 +580,7 @@ namespace OpenSim.Region.CoreModules.World.Land allowedDelta |= (uint)ParcelFlags.ForSale; } - if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.FindPlaces, false)) + if (m_scenePermissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.FindPlaces, false)) { newData.Category = args.Category; @@ -554,21 +589,21 @@ namespace OpenSim.Region.CoreModules.World.Land ParcelFlags.MaturePublish) | (uint)(1 << 23); } - if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity, false)) + if (m_scenePermissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity, false)) { newData.Description = args.Desc; newData.Name = args.Name; newData.SnapshotID = args.SnapshotID; } - if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.SetLandingPoint, false)) + if (m_scenePermissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.SetLandingPoint, false)) { newData.LandingType = args.LandingType; newData.UserLocation = args.UserLocation; newData.UserLookAt = args.UserLookAt; } - if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.ChangeMedia, false)) + if (m_scenePermissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.ChangeMedia, false)) { newData.MediaAutoScale = args.MediaAutoScale; newData.MediaID = args.MediaID; @@ -589,10 +624,10 @@ namespace OpenSim.Region.CoreModules.World.Land ParcelFlags.UseEstateVoiceChan); } - if(!m_scene.RegionInfo.EstateSettings.TaxFree) + if(!m_estateSettings.TaxFree) { // don't allow passes on group owned until we can give money to groups - if (!newData.IsGroupOwned && m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandManagePasses, false)) + if (!newData.IsGroupOwned && m_scenePermissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandManagePasses, false)) { newData.PassHours = args.PassHours; newData.PassPrice = args.PassPrice; @@ -600,13 +635,13 @@ namespace OpenSim.Region.CoreModules.World.Land allowedDelta |= (uint)ParcelFlags.UsePassList; } - if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManageAllowed, false)) + if (m_scenePermissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManageAllowed, false)) { allowedDelta |= (uint)(ParcelFlags.UseAccessGroup | ParcelFlags.UseAccessList); } - if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManageBanned, false)) + if (m_scenePermissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManageBanned, false)) { allowedDelta |= (uint)(ParcelFlags.UseBanList | ParcelFlags.DenyAnonymous | @@ -615,13 +650,13 @@ namespace OpenSim.Region.CoreModules.World.Land } // enforce estate age and payinfo limitations - if (m_scene.RegionInfo.EstateSettings.DenyMinors) + if (m_estateSettings.DenyMinors) { args.ParcelFlags |= (uint)ParcelFlags.DenyAgeUnverified; allowedDelta |= (uint)ParcelFlags.DenyAgeUnverified; } - if (m_scene.RegionInfo.EstateSettings.DenyAnonymous) + if (m_estateSettings.DenyAnonymous) { args.ParcelFlags |= (uint)ParcelFlags.DenyAnonymous; allowedDelta |= (uint)ParcelFlags.DenyAnonymous; @@ -683,7 +718,7 @@ namespace OpenSim.Region.CoreModules.World.Land public bool IsEitherBannedOrRestricted(UUID avatar) { - if (m_scene.RegionInfo.EstateSettings.TaxFree) // region access control only + if (m_estateSettings.TaxFree) // region access control only return false; if (IsBannedFromLand(avatar)) @@ -699,7 +734,7 @@ namespace OpenSim.Region.CoreModules.World.Land public bool CanBeOnThisLand(UUID avatar, float posHeight) { - if (m_scene.RegionInfo.EstateSettings.TaxFree) // region access control only + if (m_estateSettings.TaxFree) // region access control only return true; if (posHeight < m_scene.LandChannel.BanLineSafeHeight && IsBannedFromLand(avatar)) @@ -758,13 +793,13 @@ namespace OpenSim.Region.CoreModules.World.Land { ExpireAccessList(); - if (m_scene.RegionInfo.EstateSettings.TaxFree) // region access control only + if (m_estateSettings.TaxFree) // region access control only return false; - if (m_scene.Permissions.IsAdministrator(avatar)) + if (m_scenePermissions.IsAdministrator(avatar)) return false; - if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar)) + if (m_estateSettings.IsEstateManagerOrOwner(avatar)) return false; if (avatar.Equals(LandData.OwnerID)) @@ -788,15 +823,15 @@ namespace OpenSim.Region.CoreModules.World.Land public bool IsRestrictedFromLand(UUID avatar) { - if (m_scene.RegionInfo.EstateSettings.TaxFree) // estate access only + if (m_estateSettings.TaxFree) // estate access only return false; if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) == 0) { - bool adults = m_scene.RegionInfo.EstateSettings.DoDenyMinors && - (m_scene.RegionInfo.EstateSettings.DenyMinors || ((LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0)); - bool anonymous = m_scene.RegionInfo.EstateSettings.DoDenyAnonymous && - (m_scene.RegionInfo.EstateSettings.DenyAnonymous || ((LandData.Flags & (uint)ParcelFlags.DenyAnonymous) != 0)); + bool adults = m_estateSettings.DoDenyMinors && + (m_estateSettings.DenyMinors || ((LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0)); + bool anonymous = m_estateSettings.DoDenyAnonymous && + (m_estateSettings.DenyAnonymous || ((LandData.Flags & (uint)ParcelFlags.DenyAnonymous) != 0)); if(adults || anonymous) { int userflags; @@ -817,10 +852,10 @@ namespace OpenSim.Region.CoreModules.World.Land return false; } - if (m_scene.Permissions.IsAdministrator(avatar)) + if (m_scenePermissions.IsAdministrator(avatar)) return false; - if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar)) + if (m_estateSettings.IsEstateManagerOrOwner(avatar)) return false; if (avatar.Equals(LandData.OwnerID)) @@ -872,17 +907,20 @@ namespace OpenSim.Region.CoreModules.World.Land return true; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SendLandUpdateToClient(IClientAPI remote_client) { SendLandProperties(0, false, 0, remote_client); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client) { m_scene.EventManager.TriggerParcelPrimCountUpdate(); SendLandProperties(0, snap_selection, 0, remote_client); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SendLandUpdateToAvatarsOverMe() { SendLandUpdateToAvatarsOverMe(false); @@ -896,9 +934,9 @@ namespace OpenSim.Region.CoreModules.World.Land if (avatar.IsNPC) return; - if(ContainsPoint((int)Math.Round(avatar.AbsolutePosition.X), (int)Math.Round(avatar.AbsolutePosition.Y))) + if(ContainsPoint((int)avatar.AbsolutePosition.X, (int)avatar.AbsolutePosition.Y)) { - if(m_scene.RegionInfo.RegionSettings.AllowDamage) + if(m_regionSettings.AllowDamage) avatar.Invulnerable = false; else avatar.Invulnerable = (LandData.Flags & (uint)ParcelFlags.AllowDamage) == 0; @@ -921,9 +959,9 @@ namespace OpenSim.Region.CoreModules.World.Land SendLandProperties(-10000, false, LandChannel.LAND_RESULT_SINGLE, avatar.ControllingClient); return; } - if (ContainsPoint((int)Math.Round(avatar.AbsolutePosition.X), (int)Math.Round(avatar.AbsolutePosition.Y))) + if (ContainsPoint((int)avatar.AbsolutePosition.X, (int)avatar.AbsolutePosition.Y)) { - if (m_scene.RegionInfo.RegionSettings.AllowDamage) + if (m_regionSettings.AllowDamage) avatar.Invulnerable = false; else avatar.Invulnerable = (LandData.Flags & (uint)ParcelFlags.AllowDamage) == 0; @@ -982,10 +1020,10 @@ namespace OpenSim.Region.CoreModules.World.Land public void UpdateAccessList(uint flags, UUID transactionID, List entries) { - if((flags & 0x03) == 0) + flags &= 0x03; + if (flags == 0) return; // we only have access and ban - flags &=0x03 ; // get a work copy of lists List parcelAccessList = new List(LandData.ParcelAccessList); @@ -993,10 +1031,10 @@ namespace OpenSim.Region.CoreModules.World.Land // we need to this way because viewer protocol does not seem reliable lock (m_listTransactionsLock) { - if ((!m_listTransactions.ContainsKey(flags)) || - m_listTransactions[flags] != transactionID) + if ((!m_listTransactions.TryGetValue(flags, out UUID flagsID)) || flagsID.NotEqual(transactionID)) { - m_listTransactions[flags] = transactionID; + m_listTransactions.Add(flags, transactionID); + List toRemove = new List(); foreach (LandAccessEntry entry in parcelAccessList) { @@ -1041,6 +1079,7 @@ namespace OpenSim.Region.CoreModules.World.Land #region Update Functions + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void UpdateLandBitmapByteArray() { LandData.Bitmap = ConvertLandBitmapToBytes(); @@ -1049,12 +1088,14 @@ namespace OpenSim.Region.CoreModules.World.Land /// /// Update all settings in land such as area, bitmap byte array, etc /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void ForceUpdateLandInfo() { UpdateGeometryValues(); UpdateLandBitmapByteArray(); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetLandBitmapFromByteArray() { LandBitmap = ConvertBytesToLandBitmap(); @@ -1098,8 +1139,8 @@ namespace OpenSim.Region.CoreModules.World.Land { avgx = x; avgy = y; - m_startPoint.X = x * landUnit; - m_startPoint.Y = y * landUnit; + m_startPoint.X = x * Constants.LandUnit; + m_startPoint.Y = y * Constants.LandUnit; needFirst = false; } else @@ -1130,45 +1171,38 @@ namespace OpenSim.Region.CoreModules.World.Land if (m_scene != null) { - RegionInfo ri = m_scene.RegionInfo; //create a fake ID - LandData.FakeID = Util.BuildFakeParcelID(ri.RegionHandle, 0, 0); + LandData.FakeID = Util.BuildFakeParcelID(m_regionInfo.RegionHandle, 0, 0); } return; } - int halfunit = landUnit/2; + const int halfunit = Constants.LandUnit / 2; + m_centerPoint.X = avgx * Constants.LandUnit + halfunit; + m_centerPoint.Y = avgy * Constants.LandUnit + halfunit; - m_centerPoint.X = avgx * landUnit + halfunit; - m_centerPoint.Y = avgy * landUnit + halfunit; - - m_endPoint.X = lastX * landUnit + landUnit; - m_endPoint.Y = lastY * landUnit + landUnit; + m_endPoint.X = lastX * Constants.LandUnit + Constants.LandUnit; + m_endPoint.Y = lastY * Constants.LandUnit + Constants.LandUnit; // next tests should not be needed // if they fail, something is wrong - int regionSizeX = (int)Constants.RegionSize; - int regionSizeY = (int)Constants.RegionSize; ulong regionHandle; if(m_scene != null) { - RegionInfo ri = m_scene.RegionInfo; - regionSizeX = (int)ri.RegionSizeX; - regionSizeY = (int)ri.RegionSizeY; - regionHandle = ri.RegionHandle; + regionHandle = m_regionInfo.RegionHandle; //create a fake ID - LandData.FakeID = Util.BuildFakeParcelID(regionHandle, (uint)(lastX * landUnit), (uint)(lastY * landUnit)); + LandData.FakeID = Util.BuildFakeParcelID(regionHandle, (uint)(lastX * Constants.LandUnit), (uint)(lastY * Constants.LandUnit)); } - int tx = min_x * landUnit; - if (tx >= regionSizeX) - tx = regionSizeX - 1; + int tx = min_x * Constants.LandUnit; + if (tx >= m_regionSizeX) + tx = m_regionSizeX - 1; - int ty = min_y * landUnit; - if (ty >= regionSizeY) - ty = regionSizeY - 1; + int ty = min_y * Constants.LandUnit; + if (ty >= m_regionSizeY) + ty = m_regionSizeY - 1; m_AABBmin.X = tx; m_AABBmin.Y = ty; @@ -1179,14 +1213,14 @@ namespace OpenSim.Region.CoreModules.World.Land LandData.AABBMin = new Vector3(tx, ty, (float)m_scene.Heightmap[tx, ty]); max_x++; - tx = max_x * landUnit; - if (tx > regionSizeX) - tx = regionSizeX; + tx = max_x * Constants.LandUnit; + if (tx > m_regionSizeX) + tx = m_regionSizeX; max_y++; - ty = max_y * landUnit; - if (ty > regionSizeY) - ty = regionSizeY; + ty = max_y * Constants.LandUnit; + if (ty > m_regionSizeY) + ty = m_regionSizeY; m_AABBmax.X = tx; m_AABBmax.Y = ty; @@ -1196,7 +1230,7 @@ namespace OpenSim.Region.CoreModules.World.Land else LandData.AABBMax = new Vector3(tx, ty, (float)m_scene.Heightmap[tx - 1, ty - 1]); - tempArea *= landUnit * landUnit; + tempArea *= Constants.LandUnit * Constants.LandUnit; LandData.Area = tempArea; } @@ -1208,6 +1242,7 @@ namespace OpenSim.Region.CoreModules.World.Land /// Sets the land's bitmap manually /// /// block representing where this land is on a map mapped in a 4x4 meter grid + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetLandBitmap(bool[,] bitmap) { LandBitmap = bitmap; @@ -1218,16 +1253,19 @@ namespace OpenSim.Region.CoreModules.World.Land /// Gets the land's bitmap manually /// /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool[,] GetLandBitmap() { return LandBitmap; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool[,] BasicFullRegionLandBitmap() { - return GetSquareLandBitmap(0, 0, (int)m_scene.RegionInfo.RegionSizeX, (int) m_scene.RegionInfo.RegionSizeY, true); + return GetSquareLandBitmap(0, 0, m_regionSizeX, m_regionSizeY, true); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y, bool set_value = true) { bool[,] tempBitmap = ModifyLandBitmapSquare(null, start_x, start_y, end_x, end_y, set_value); @@ -1249,15 +1287,15 @@ namespace OpenSim.Region.CoreModules.World.Land { if(land_bitmap == null) { - land_bitmap = new bool[m_scene.RegionInfo.RegionSizeX / landUnit, m_scene.RegionInfo.RegionSizeY / landUnit]; + land_bitmap = new bool[m_regionSizeX / Constants.LandUnit, m_regionSizeY / Constants.LandUnit]; if(!set_value) return land_bitmap; } - start_x /= landUnit; - end_x /= landUnit; - start_y /= landUnit; - end_y /= landUnit; + start_x /= Constants.LandUnit; + end_x /= Constants.LandUnit; + start_y /= Constants.LandUnit; + end_y /= Constants.LandUnit; for (int x = start_x; x < end_x; ++x) { @@ -1308,12 +1346,12 @@ namespace OpenSim.Region.CoreModules.World.Land /// <x,y,?> /// <x,y,?> /// <x,y,?> - /// <x,y,?> + /// <x,y,?> /// out: This is set if the resultant bitmap is now empty /// out: parcel.AABBMin <x,y,0> /// out: parcel.AABBMax <x,y,0> /// New parcel bitmap - public bool[,] RemapLandBitmap(bool[,] bitmap_base, Vector2 displacement, float rotationDegrees, Vector2 boundingOrigin, Vector2 boundingSize, Vector2 regionSize, out bool isEmptyNow) + public bool[,] RemapLandBitmap(bool[,] bitmap_base, Vector2 displacement, float rotationDegrees, Vector2 boundingOrigin, Vector2 boundingSize, Vector2 newRegionSize, out bool isEmptyNow) { // get the size of the incoming bitmap int baseX = bitmap_base.GetLength(0); @@ -1386,25 +1424,25 @@ namespace OpenSim.Region.CoreModules.World.Land // So... our output land bitmap must be the size of the current region but rememeber, parcel landbitmaps are landUnit metres (4x4 metres) per point, // and region sizes, boundaries and displacements are in metres so we need to scale down - int newX = (int)(regionSize.X / landUnit); - int newY = (int)(regionSize.Y / landUnit); + int newX = (int)(newRegionSize.X / Constants.LandUnit); + int newY = (int)(newRegionSize.Y / Constants.LandUnit); bool[,] bitmap_new = new bool[newX, newY]; // displacement is relative to <0,0> in the destination region and defines where the origin of the data selected by the bounding-rectangle is placed - int dispX = (int)Math.Floor(displacement.X / landUnit); - int dispY = (int)Math.Floor(displacement.Y / landUnit); + int dispX = (int)Math.Floor(displacement.X / Constants.LandUnit); + int dispY = (int)Math.Floor(displacement.Y / Constants.LandUnit); // startX/Y and endX/Y are coordinates in bitmap_tmp - int startX = (int)Math.Floor(boundingOrigin.X / landUnit) + offsetX; + int startX = (int)Math.Floor(boundingOrigin.X / Constants.LandUnit) + offsetX; if (startX > tmpX) startX = tmpX; if (startX < 0) startX = 0; - int startY = (int)Math.Floor(boundingOrigin.Y / landUnit) + offsetY; + int startY = (int)Math.Floor(boundingOrigin.Y / Constants.LandUnit) + offsetY; if (startY > tmpY) startY = tmpY; if (startY < 0) startY = 0; - int endX = (int)Math.Floor((boundingOrigin.X + boundingSize.X) / landUnit) + offsetX; + int endX = (int)Math.Floor((boundingOrigin.X + boundingSize.X) / Constants.LandUnit) + offsetX; if (endX > tmpX) endX = tmpX; if (endX < 0) endX = 0; - int endY = (int)Math.Floor((boundingOrigin.Y + boundingSize.Y) / landUnit) + offsetY; + int endY = (int)Math.Floor((boundingOrigin.Y + boundingSize.Y) / Constants.LandUnit) + offsetY; if (endY > tmpY) endY = tmpY; if (endY < 0) endY = 0; @@ -1534,16 +1572,16 @@ namespace OpenSim.Region.CoreModules.World.Land } else { - tempConvertMap = new bool[m_scene.RegionInfo.RegionSizeX / landUnit, m_scene.RegionInfo.RegionSizeY / landUnit]; + tempConvertMap = new bool[m_regionSizeX / Constants.LandUnit, m_regionSizeY / Constants.LandUnit]; tempConvertMap.Initialize(); // Math.Min overcomes an old bug that might have made it into the database. Only use the bytes that fit into convertMap. bitmapLen = Math.Min(LandData.Bitmap.Length, tempConvertMap.GetLength(0) * tempConvertMap.GetLength(1) / 8); - xLen = (int)(m_scene.RegionInfo.RegionSizeX / landUnit); + xLen = (m_regionSizeX / Constants.LandUnit); if (bitmapLen == 512) { // Legacy bitmap being passed in. Use the legacy region size // and only set the lower area of the larger region. - xLen = (int)(Constants.RegionSize / landUnit); + xLen = (int)(Constants.RegionSize / Constants.LandUnit); } } // m_log.DebugFormat("{0} ConvertBytesToLandBitmap: bitmapLen={1}, xLen={2}", LogHeader, bitmapLen, xLen); @@ -1608,7 +1646,7 @@ namespace OpenSim.Region.CoreModules.World.Land public void SendForceObjectSelect(int local_id, int request_type, List returnIDs, IClientAPI remote_client) { - if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions, true)) + if (m_scenePermissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions, true)) { List resultLocalIDs = new List(); try @@ -1657,7 +1695,7 @@ namespace OpenSim.Region.CoreModules.World.Land /// public void SendLandObjectOwners(IClientAPI remote_client) { - if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions, true)) + if (m_scenePermissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions, true)) { Dictionary primCount = new Dictionary(); List groups = new List(); @@ -1762,7 +1800,7 @@ namespace OpenSim.Region.CoreModules.World.Land { foreach (SceneObjectGroup obj in primsOverMe) { - if(m_scene.Permissions.CanSellObject(previousOwner,obj, (byte)SaleType.Original)) + if(m_scenePermissions.CanSellObject(previousOwner,obj, (byte)SaleType.Original)) m_BuySellModule.BuyObject(sp.ControllingClient, UUID.Zero, obj.LocalId, (byte)SaleType.Original, 0); } } @@ -1772,6 +1810,7 @@ namespace OpenSim.Region.CoreModules.World.Land #region Object Returning + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void ReturnObject(SceneObjectGroup obj) { SceneObjectGroup[] objs = new SceneObjectGroup[1]; @@ -1846,7 +1885,7 @@ namespace OpenSim.Region.CoreModules.World.Land foreach (List ol in returns.Values) { - if (m_scene.Permissions.CanReturnObjects(this, remote_client, ol)) + if (m_scenePermissions.CanReturnObjects(this, remote_client, ol)) m_scene.returnObjects(ol.ToArray(), remote_client); } } @@ -1855,12 +1894,14 @@ namespace OpenSim.Region.CoreModules.World.Land #region Object Adding/Removing from Parcel + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void ResetOverMeRecord() { lock (primsOverMe) primsOverMe.Clear(); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddPrimOverMe(SceneObjectGroup obj) { // m_log.DebugFormat("[LAND OBJECT]: Adding scene object {0} {1} over {2}", obj.Name, obj.LocalId, LandData.Name); @@ -1869,10 +1910,10 @@ namespace OpenSim.Region.CoreModules.World.Land primsOverMe.Add(obj); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RemovePrimFromOverMe(SceneObjectGroup obj) { -// m_log.DebugFormat("[LAND OBJECT]: Removing scene object {0} {1} from over {2}", obj.Name, obj.LocalId, LandData.Name); - + //m_log.DebugFormat("[LAND OBJECT]: Removing scene object {0} {1} from over {2}", obj.Name, obj.LocalId, LandData.Name); lock (primsOverMe) primsOverMe.Remove(obj); } @@ -1933,6 +1974,7 @@ namespace OpenSim.Region.CoreModules.World.Land /// Get the music url for this land parcel /// /// The music url. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public string GetMusicUrl() { return LandData.MusicURL; diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs index d6a3dede75..c512eac3e8 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs @@ -248,7 +248,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); lo = lmm.AddLandObject(lo); - lmm.Subdivide(0, 0, LandManagementModule.LandUnit, LandManagementModule.LandUnit, userId); + lmm.Subdivide(0, 0, Constants.LandUnit, Constants.LandUnit, userId); { ILandObject loAtCoord = lmm.GetLandObject(0, 0); @@ -257,7 +257,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests } { - ILandObject loAtCoord = lmm.GetLandObject(LandManagementModule.LandUnit, LandManagementModule.LandUnit); + ILandObject loAtCoord = lmm.GetLandObject(Constants.LandUnit, Constants.LandUnit); Assert.That(loAtCoord.LandData.LocalID, Is.EqualTo(lo.LandData.LocalID)); Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(lo.LandData.GlobalID)); } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/HGWorldMapModule.cs index 00463af326..96d88f5347 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/HGWorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/HGWorldMapModule.cs @@ -176,9 +176,11 @@ namespace OpenSim.Region.CoreModules.Hypergrid { if (m_UserManagement != null && !string.IsNullOrEmpty(m_MapImageServerURL) && !m_UserManagement.IsLocalGridUser(agentID)) { - OSD extras; - if (!features.TryGetValue("OpenSimExtras", out extras)) + if (!features.TryGetValue("OpenSimExtras", out OSD extras)) + { extras = new OSDMap(); + features["OpenSimExtras"] = extras; + } ((OSDMap)extras)["map-server-url"] = m_MapImageServerURL; diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 7097310970..1fc4434981 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1709,7 +1709,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap private Byte[] GenerateOverlay() { - int landTileSize = LandManagementModule.LandUnit; + const int landTileSize = Constants.LandUnit; // These need to be ints for bitmap generation int regionSizeX = (int)m_scene.RegionInfo.RegionSizeX;