diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs index 5a55b02f8e..0316944072 100644 --- a/OpenSim/Framework/ILandObject.cs +++ b/OpenSim/Framework/ILandObject.cs @@ -35,8 +35,8 @@ namespace OpenSim.Framework public interface ILandObject { - int GetParcelMaxPrimCount(ILandObject thisObject); - int GetSimulatorMaxPrimCount(ILandObject thisObject); + int GetParcelMaxPrimCount(); + int GetSimulatorMaxPrimCount(); int GetPrimsFree(); LandData LandData { get; set; } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 82bef48c8c..64616365f4 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -347,12 +347,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver landData.Add(parcel); } - - if (!m_merge) - m_scene.LandChannel.Clear(false); + + if (!m_merge) + { + bool setupDefaultParcel = (landData.Count == 0); + m_scene.LandChannel.Clear(setupDefaultParcel); + } m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData); - m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count); + m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count); } /// diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 2307c8e585..729e9f78bd 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -313,6 +313,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null"); Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match"); + Assert.Greater(m_scene.LandChannel.AllParcels().Count, 0, "incorrect number of parcels"); + // Temporary Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod()); } diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index bfab7b88e4..63dec1516f 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -520,8 +520,12 @@ namespace OpenSim.Region.CoreModules.World.Land } } + /// + /// Like handleEventManagerOnSignificantClientMovement, but called with an AgentUpdate regardless of distance. + /// + /// public void EventManagerOnClientMovement(ScenePresence avatar) - //Like handleEventManagerOnSignificantClientMovement, but called with an AgentUpdate regardless of distance. + // { ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); if (over != null) @@ -534,7 +538,6 @@ namespace OpenSim.Region.CoreModules.World.Land } } - public void ClientOnParcelAccessListRequest(UUID agentID, UUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client) { @@ -668,14 +671,14 @@ namespace OpenSim.Region.CoreModules.World.Land //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); } - + m_landList.Clear(); + + ResetSimLandObjects(); + + if (setupDefaultParcel) + CreateDefaultParcel(); } - - ResetSimLandObjects(); - - if (setupDefaultParcel) - CreateDefaultParcel(); } private void performFinalLandJoin(ILandObject master, ILandObject slave) @@ -1391,8 +1394,11 @@ namespace OpenSim.Region.CoreModules.World.Land public void EventManagerOnNoLandDataFromStorage() { - ResetSimLandObjects(); - CreateDefaultParcel(); + lock (m_landList) + { + ResetSimLandObjects(); + CreateDefaultParcel(); + } } #endregion diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index c2f104e370..560b862625 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -67,7 +67,7 @@ namespace OpenSim.Region.CoreModules.World.Land public int GetPrimsFree() { m_scene.EventManager.TriggerParcelPrimCountUpdate(); - int free = GetSimulatorMaxPrimCount(this) - m_landData.SimwidePrims; + int free = GetSimulatorMaxPrimCount() - m_landData.SimwidePrims; return free; } @@ -181,11 +181,11 @@ namespace OpenSim.Region.CoreModules.World.Land overrideSimulatorMaxPrimCount = overrideDel; } - public int GetParcelMaxPrimCount(ILandObject thisObject) + public int GetParcelMaxPrimCount() { if (overrideParcelMaxPrimCount != null) { - return overrideParcelMaxPrimCount(thisObject); + return overrideParcelMaxPrimCount(this); } else { @@ -197,11 +197,12 @@ namespace OpenSim.Region.CoreModules.World.Land return parcelMax; } } - public int GetSimulatorMaxPrimCount(ILandObject thisObject) + + public int GetSimulatorMaxPrimCount() { if (overrideSimulatorMaxPrimCount != null) { - return overrideSimulatorMaxPrimCount(thisObject); + return overrideSimulatorMaxPrimCount(this); } else { @@ -244,8 +245,8 @@ namespace OpenSim.Region.CoreModules.World.Land remote_client.SendLandProperties(seq_id, snap_selection, request_result, this, (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, - GetParcelMaxPrimCount(this), - GetSimulatorMaxPrimCount(this), regionFlags); + GetParcelMaxPrimCount(), + GetSimulatorMaxPrimCount(), regionFlags); } public void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client) diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs index e983239b4a..0f37dddc86 100644 --- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs +++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs @@ -70,14 +70,14 @@ namespace OpenSim.Region.CoreModules.World.Region false, "region restart bluebox", "region restart bluebox +", "Schedule a region restart", - "Schedule a region restart after a given number of seconds. If one delta is given then the region is restarted in delta seconds time. A time to restart is sent to users in the region as a transient notice. If multiple deltas are given then a notice is sent when we reach each delta.", + "Schedule a region restart after a given number of seconds. If one delta is given then the region is restarted in delta seconds time. A time to restart is sent to users in the region as a dismissable bluebox notice. If multiple deltas are given then a notice is sent when we reach each delta.", HandleRegionRestart); MainConsole.Instance.Commands.AddCommand("RestartModule", false, "region restart notice", "region restart notice +", "Schedule a region restart", - "Schedule a region restart after a given number of seconds. If one delta is given then the region is restarted in delta seconds time. A time to restart is sent to users in the region as a dismissable bluebox notice. If multiple deltas are given then a notice is sent when we reach each delta.", + "Schedule a region restart after a given number of seconds. If one delta is given then the region is restarted in delta seconds time. A time to restart is sent to users in the region as a transient notice. If multiple deltas are given then a notice is sent when we reach each delta.", HandleRegionRestart); MainConsole.Instance.Commands.AddCommand("RestartModule", diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 3bf2c2b61e..e242010120 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -924,9 +924,9 @@ namespace OpenSim.Region.Framework.Scenes uint callbackID, string description, string name, sbyte invType, sbyte type, UUID olditemID) { - m_log.DebugFormat( - "[AGENT INVENTORY]: Received request from {0} to create inventory item link {1} in folder {2} pointing to {3}", - remoteClient.Name, name, folderID, olditemID); +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Received request from {0} to create inventory item link {1} in folder {2} pointing to {3}", +// remoteClient.Name, name, folderID, olditemID); if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) return; @@ -934,20 +934,25 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence presence; if (TryGetScenePresence(remoteClient.AgentId, out presence)) { - bool linkAlreadyExists = false; - List existingItems = InventoryService.GetFolderItems(remoteClient.AgentId, folderID); - foreach (InventoryItemBase item in existingItems) - if (item.AssetID == olditemID) - linkAlreadyExists = true; - - if (linkAlreadyExists) - { - m_log.WarnFormat( - "[AGENT INVENTORY]: Ignoring request from {0} to create item link {1} in folder {2} pointing to {3} since a link already exists", - remoteClient.Name, name, folderID, olditemID); - - return; - } + // Disabled the check for duplicate links. + // + // When outfits are being adjusted, the viewer rapidly sends delete link messages followed by + // create links. However, since these are handled asynchronously, the deletes do not complete before + // the creates are handled. Therefore, we cannot enforce a duplicate link check. +// InventoryItemBase existingLink = null; +// List existingItems = InventoryService.GetFolderItems(remoteClient.AgentId, folderID); +// foreach (InventoryItemBase item in existingItems) +// if (item.AssetID == olditemID) +// existingLink = item; +// +// if (existingLink != null) +// { +// m_log.WarnFormat( +// "[AGENT INVENTORY]: Ignoring request from {0} to create item link {1} in folder {2} pointing to {3} since a link named {4} with id {5} already exists", +// remoteClient.Name, name, folderID, olditemID, existingLink.Name, existingLink.ID); +// +// return; +// } AssetBase asset = new AssetBase(); asset.FullID = olditemID; @@ -975,7 +980,11 @@ namespace OpenSim.Region.Framework.Scenes /// private void RemoveInventoryItem(IClientAPI remoteClient, List itemIDs) { - //m_log.Debug("[SCENE INVENTORY]: user " + remoteClient.AgentId); +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Removing inventory items {0} for {1}", +// string.Join(",", itemIDs.ConvertAll(uuid => uuid.ToString()).ToArray()), +// remoteClient.Name); + InventoryService.DeleteItems(remoteClient.AgentId, itemIDs); } diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs index 471b90f0e1..c1957e2cb8 100644 --- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs +++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs @@ -76,22 +76,24 @@ namespace OpenSim.Region.OptionalModules public void AddRegion(Scene scene) { - if(!m_enabled) + if (!m_enabled) { return; } scene.Permissions.OnRezObject += CanRezObject; scene.Permissions.OnObjectEntry += CanObjectEnter; scene.Permissions.OnDuplicateObject += CanDuplicateObject; + m_log.DebugFormat("[PRIM LIMITS]: Region {0} added", scene.RegionInfo.RegionName); } public void RemoveRegion(Scene scene) { - if(m_enabled) + if (m_enabled) { return; } + scene.Permissions.OnRezObject -= CanRezObject; scene.Permissions.OnObjectEntry -= CanObjectEnter; scene.Permissions.OnDuplicateObject -= CanDuplicateObject; @@ -104,13 +106,11 @@ namespace OpenSim.Region.OptionalModules private bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene) { - // This may be a little long winded and can probably be optomized - int usedPrims = scene.LandChannel.GetLandObject(objectPosition.X,objectPosition.Y).PrimCounts.Total; - LandData landData = scene.LandChannel.GetLandObject(objectPosition.X,objectPosition.Y).LandData; - int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * - (float)scene.RegionInfo.ObjectCapacity * (float)scene.RegionInfo.RegionSettings.ObjectBonus); + ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); + int usedPrims = lo.PrimCounts.Total; + int simulatorCapacity = lo.GetSimulatorMaxPrimCount(); - if(objectCount + usedPrims > simulatorCapacity) + if (objectCount + usedPrims > simulatorCapacity) { m_dialogModule.SendAlertToUser(owner, "Unable to rez object because the parcel is too full"); return false; @@ -118,7 +118,7 @@ namespace OpenSim.Region.OptionalModules return true; } - //OnMoveObject + private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) { SceneObjectPart obj = scene.GetSceneObjectPart(objectID); @@ -126,11 +126,9 @@ namespace OpenSim.Region.OptionalModules int objectCount = obj.ParentGroup.PrimCount; ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y); ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y); - - int usedPrims=newParcel.PrimCounts.Total; - LandData landData = newParcel.LandData; - int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * - (float)scene.RegionInfo.ObjectCapacity * (float)scene.RegionInfo.RegionSettings.ObjectBonus); + + int usedPrims = newParcel.PrimCounts.Total; + int simulatorCapacity = newParcel.GetSimulatorMaxPrimCount(); // The prim hasn't crossed a region boundry so we don't need to worry // about prim counts here @@ -138,36 +136,39 @@ namespace OpenSim.Region.OptionalModules { return true; } + // Prim counts are determined by the location of the root prim. if we're // moving a child prim, just let it pass if(!obj.IsRoot) { return true; } - // Add Special Case here for temporary prims + + // TODO: Add Special Case here for temporary prims if(objectCount + usedPrims > simulatorCapacity) { m_dialogModule.SendAlertToUser(obj.OwnerID, "Unable to move object because the destination parcel is too full"); return false; } + return true; } + //OnDuplicateObject private bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition) { - // This may be a little long winded and can probably be optomized - int usedPrims = scene.LandChannel.GetLandObject(objectPosition.X,objectPosition.Y).PrimCounts.Total; - LandData landData = scene.LandChannel.GetLandObject(objectPosition.X,objectPosition.Y).LandData; - int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * - (float)scene.RegionInfo.ObjectCapacity * (float)scene.RegionInfo.RegionSettings.ObjectBonus); + ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); + int usedPrims = lo.PrimCounts.Total; + int simulatorCapacity = lo.GetSimulatorMaxPrimCount(); if(objectCount + usedPrims > simulatorCapacity) { m_dialogModule.SendAlertToUser(owner, "Unable to duplicate object because the parcel is too full"); return false; } + return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index aa28fa0ca2..02402271c1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -9908,31 +9908,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetParcelMaxPrims(LSL_Vector pos, int sim_wide) { m_host.AddScriptLPS(1); - // Alondria: This currently just is utilizing the normal grid's 0.22 prims/m2 calculation - // Which probably will be irrelevent in OpenSim.... - LandData land = World.GetLandData((float)pos.x, (float)pos.y); - float bonusfactor = (float)World.RegionInfo.RegionSettings.ObjectBonus; + ILandObject lo = World.LandChannel.GetLandObject((float)pos.x, (float)pos.y); - if (land == null) - { + if (lo == null) return 0; - } if (sim_wide != 0) - { - decimal v = land.SimwideArea * (decimal)(0.22) * (decimal)bonusfactor; - - return (int)v; - } - + return lo.GetSimulatorMaxPrimCount(); else - { - decimal v = land.Area * (decimal)(0.22) * (decimal)bonusfactor; - - return (int)v; - } - + return lo.GetParcelMaxPrimCount(); } public LSL_List llGetParcelDetails(LSL_Vector pos, LSL_List param) diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index cdab49ed6b..0da9fc112a 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs @@ -30,6 +30,7 @@ using System.Collections; using System.IO; using System.Net; using System.Reflection; +using System.Security; using System.Text; using log4net; using Nini.Config; @@ -143,7 +144,7 @@ namespace OpenSim.Server.Handlers.Grid sb.Append("\n"); foreach (string k in _info.Keys) { - sb.AppendFormat("<{0}>{1}\n", k, _info[k]); + sb.AppendFormat("<{0}>{1}\n", k, SecurityElement.Escape(_info[k].ToString())); } sb.Append("\n"); diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs index c3134b3bc1..0e4dfb9eee 100644 --- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs +++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs @@ -40,10 +40,12 @@ namespace OpenSim.Tests.Common.Mock public class TestLandChannel : ILandChannel { private Scene m_scene; + private List m_parcels; public TestLandChannel(Scene scene) { m_scene = scene; + m_parcels = new List(); } public List ParcelsNearPoint(Vector3 position) @@ -53,12 +55,19 @@ namespace OpenSim.Tests.Common.Mock public List AllParcels() { - return new List(); + return m_parcels; } public void Clear(bool setupDefaultParcel) { - // Intentionally blank since we don't save any parcel data in the test channel + m_parcels.Clear(); + + if (setupDefaultParcel) + { + ILandObject obj = new LandObject(UUID.Zero, false, m_scene); + obj.LandData.Name = "Your Parcel"; + m_parcels.Add(obj); + } } protected ILandObject GetNoLand()