From 19e4473a9732bfb1ebbace4bcbfbe15a0d833941 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 27 Jan 2011 20:57:59 +0000 Subject: Put confirmation on "land clear" command to avoid nasty accidents --- .../CoreModules/World/Land/LandManagementModule.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index a46be13..5243be8 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -1653,9 +1653,21 @@ namespace OpenSim.Region.CoreModules.World.Land protected void ClearCommand(Object[] args) { - Clear(true); + string response = MainConsole.Instance.CmdPrompt( + string.Format( + "Are you sure that you want to clear all land parcels from {0} (y or n)", + m_scene.RegionInfo.RegionName), + "n"); - MainConsole.Instance.OutputFormat("Cleared all parcels from {0}", m_scene.RegionInfo.RegionName); + if (response.ToLower() == "y") + { + Clear(true); + MainConsole.Instance.OutputFormat("Cleared all parcels from {0}", m_scene.RegionInfo.RegionName); + } + else + { + MainConsole.Instance.OutputFormat("Aborting clear of all parcels from {0}", m_scene.RegionInfo.RegionName); + } } protected void ShowParcelsCommand(Object[] args) -- cgit v1.1 From f9ea5e69c5f99ff19fc018a60f0a45c06cd93594 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 27 Jan 2011 21:07:21 +0000 Subject: Refactor: Break out LoadObjects() and LoadParcels() from a longer method --- .../World/Archiver/ArchiveReadRequest.cs | 72 +++++++++++++--------- 1 file changed, 44 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 44fd994..fd8f546 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -217,31 +217,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_scene.DeleteAllSceneObjects(); } - // Try to retain the original creator/owner/lastowner if their uuid is present on this grid - // otherwise, use the master avatar uuid instead + LoadParcels(serialisedParcels); + LoadObjects(serialisedSceneObjects); - // Reload serialized parcels - m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count); - List landData = new List(); - foreach (string serialisedParcel in serialisedParcels) - { - LandData parcel = LandDataSerializer.Deserialize(serialisedParcel); - if (!ResolveUserUuid(parcel.OwnerID)) - parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; - -// m_log.DebugFormat( -// "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}", -// parcel.Name, parcel.LocalID, parcel.Area); - - landData.Add(parcel); - } - - if (!m_merge) - m_scene.LandChannel.Clear(false); - - m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData); - m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count); + m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); + m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage); + } + + /// + /// Load serialized scene objects. + /// + /// + protected void LoadObjects(List serialisedSceneObjects) + { // Reload serialized prims m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); @@ -271,6 +260,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver // to the same scene (when this is possible). sceneObject.ResetIDs(); + // Try to retain the original creator/owner/lastowner if their uuid is present on this grid + // or creator data is present. Otherwise, use the estate owner instead. foreach (SceneObjectPart part in sceneObject.Parts) { if (part.CreatorData == null || part.CreatorData == string.Empty) @@ -327,11 +318,36 @@ namespace OpenSim.Region.CoreModules.World.Archiver int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount; if (ignoredObjects > 0) - m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects); - - m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); - - m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage); + m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects); + } + + /// + /// Load serialized parcels. + /// + /// + protected void LoadParcels(List serialisedParcels) + { + // Reload serialized parcels + m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count); + List landData = new List(); + foreach (string serialisedParcel in serialisedParcels) + { + LandData parcel = LandDataSerializer.Deserialize(serialisedParcel); + if (!ResolveUserUuid(parcel.OwnerID)) + parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; + +// m_log.DebugFormat( +// "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}", +// parcel.Name, parcel.LocalID, parcel.Area); + + landData.Add(parcel); + } + + if (!m_merge) + m_scene.LandChannel.Clear(false); + + m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData); + m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count); } /// -- cgit v1.1 From 5a0cb7d37e2491e508e6e37f0c9ee2e8ce6e7957 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 28 Jan 2011 02:34:07 +0000 Subject: Thank you, Goetz, for a patch to fix prim count display in cut regions. --- .../CoreModules/World/Land/LandManagementModule.cs | 8 ++++---- .../Region/CoreModules/World/Land/LandObject.cs | 24 +++++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index a46be13..893e35c 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -709,7 +709,7 @@ namespace OpenSim.Region.CoreModules.World.Land int x; int y; - if (x_float > Constants.RegionSize || x_float <= 0 || y_float > Constants.RegionSize || y_float <= 0) + if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) return null; try @@ -751,10 +751,10 @@ namespace OpenSim.Region.CoreModules.World.Land { try { - if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4])) + //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4])) return m_landList[m_landIDList[x / 4, y / 4]]; - else - return null; + //else + // return null; } catch (IndexOutOfRangeException) { diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index b90e307..46c15ed 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -66,6 +66,13 @@ namespace OpenSim.Region.CoreModules.World.Land #region ILandObject Members + public int GetPrimsFree() + { + m_scene.EventManager.TriggerParcelPrimCountUpdate(); + int free = GetSimulatorMaxPrimCount(this) - m_landData.SimwidePrims; + return free; + } + public LandData LandData { get { return m_landData; } @@ -141,7 +148,7 @@ namespace OpenSim.Region.CoreModules.World.Land /// Returns true if the piece of land contains the specified point public bool ContainsPoint(int x, int y) { - if (x >= 0 && y >= 0 && x <= Constants.RegionSize && y <= Constants.RegionSize) + if (x >= 0 && y >= 0 && x < Constants.RegionSize && y < Constants.RegionSize) { return (LandBitmap[x / 4, y / 4] == true); } @@ -183,7 +190,11 @@ namespace OpenSim.Region.CoreModules.World.Land else { // Normal Calculations - return (int)Math.Round(((float)LandData.Area / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); + int parcelMax = (int)(((float)LandData.Area / 65536.0f) + * (float)m_scene.RegionInfo.ObjectCapacity + * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); + // TODO: The calculation of ObjectBonus should be refactored. It does still not work in the same manner as SL! + return parcelMax; } } public int GetSimulatorMaxPrimCount(ILandObject thisObject) @@ -195,7 +206,9 @@ namespace OpenSim.Region.CoreModules.World.Land else { //Normal Calculations - return m_scene.RegionInfo.ObjectCapacity; + int simMax = (int)(((float)LandData.SimwideArea / 65536.0f) + * (float)m_scene.RegionInfo.ObjectCapacity); + return simMax; } } #endregion @@ -369,7 +382,7 @@ namespace OpenSim.Region.CoreModules.World.Land newData.AuthBuyerID = UUID.Zero; newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory); m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); - + m_scene.EventManager.TriggerParcelPrimCountUpdate(); SendLandUpdateToAvatarsOverMe(true); } @@ -384,7 +397,7 @@ namespace OpenSim.Region.CoreModules.World.Land newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory); m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); - + m_scene.EventManager.TriggerParcelPrimCountUpdate(); SendLandUpdateToAvatarsOverMe(true); } @@ -450,6 +463,7 @@ namespace OpenSim.Region.CoreModules.World.Land public void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client) { + m_scene.EventManager.TriggerParcelPrimCountUpdate(); SendLandProperties(0, snap_selection, 0, remote_client); } -- cgit v1.1