From 7494d7726afd9f8b9762d78aead918ba7a90efa3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 11 Oct 2016 01:14:53 +0100 Subject: [PATCH] change math on GetParcelMaxPrimCount and GetSimulatorMaxPrimCount to reduce round errors, limit both to region max prims. consider ObjectBonus on last one also. Change a variable name in PrimLimitsModule to make it more clear --- .../CoreModules/World/Land/LandObject.cs | 25 +++++++++++++------ .../PrimLimitsModule/PrimLimitsModule.cs | 4 +-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 69a34550a9..4cbc8b81af 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -341,10 +341,16 @@ namespace OpenSim.Region.CoreModules.World.Land else { // Normal Calculations - int parcelMax = (int)( (long)LandData.Area - * (long)m_scene.RegionInfo.ObjectCapacity - * (long)m_scene.RegionInfo.RegionSettings.ObjectBonus - / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY) ); + 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) + + 0.5 ); + + if(parcelMax > m_scene.RegionInfo.ObjectCapacity) + parcelMax = m_scene.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); return parcelMax; } @@ -359,9 +365,14 @@ namespace OpenSim.Region.CoreModules.World.Land else { //Normal Calculations - int simMax = (int)( (long)LandData.SimwideArea - * (long)m_scene.RegionInfo.ObjectCapacity - / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY) ); + 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) + +0.5 ); + + if(simMax > m_scene.RegionInfo.ObjectCapacity) + simMax = m_scene.RegionInfo.ObjectCapacity; //m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}, SimWidePrims {3}", // LandData.SimwideArea, m_scene.RegionInfo.ObjectCapacity, simMax, LandData.SimwidePrims); return simMax; diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs index 50a5fae06d..4ffb03bd75 100644 --- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs +++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs @@ -186,8 +186,8 @@ namespace OpenSim.Region.OptionalModules { string response = null; - int simulatorCapacity = lo.GetSimulatorMaxPrimCount(); - if ((objectCount + lo.PrimCounts.Total) > simulatorCapacity) + int OwnedParcelsCapacity = lo.GetSimulatorMaxPrimCount(); + if ((objectCount + lo.PrimCounts.Total) > OwnedParcelsCapacity) { response = "Unable to rez object because the parcel is too full"; }