From d2dfa4cfe7aadfed0611fb31414d9c8fff420b24 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 31 Jan 2012 03:09:44 +0000 Subject: [PATCH 1/4] Make parcel sale overlays work. No auction support. --- OpenSim/Region/Application/OpenSimBase.cs | 6 +- .../World/WorldMap/WorldMapModule.cs | 88 ++++++++++++++++++- 2 files changed, 87 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index a680a59cba..f482d8f93c 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -383,6 +383,9 @@ namespace OpenSim // TODO : Try setting resource for region xstats here on scene MainServer.Instance.AddStreamHandler(new Region.Framework.Scenes.RegionStatsHandler(regionInfo)); + scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID); + scene.EventManager.TriggerParcelPrimCountUpdate(); + try { scene.RegisterRegionWithGrid(); @@ -398,9 +401,6 @@ namespace OpenSim Environment.Exit(1); } - scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID); - scene.EventManager.TriggerParcelPrimCountUpdate(); - // We need to do this after we've initialized the // scripting engines. scene.CreateScriptInstances(); diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index e42c946807..6c6aa373a2 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -213,7 +213,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap UUID agentID, Caps caps) { //try - //{ + // //m_log.DebugFormat("[MAPLAYER]: path: {0}, param: {1}, agent:{2}", // path, param, agentID.ToString()); @@ -1345,10 +1345,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap if (data == null) return; + byte[] overlay = GenerateOverlay(); + m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE"); UUID terrainImageID = UUID.Random(); - UUID parcelImageID = UUID.Zero; // UUID.Random(); + UUID parcelImageID = UUID.Zero; AssetBase asset = new AssetBase( terrainImageID, @@ -1364,9 +1366,26 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_log.DebugFormat("[WORLDMAP]: Storing map tile {0}", asset.ID); m_scene.AssetService.Store(asset); + if (overlay != null) + { + parcelImageID = UUID.Random(); + + AssetBase parcels = new AssetBase( + parcelImageID, + "parcelImage_" + m_scene.RegionInfo.RegionID.ToString(), + (sbyte)AssetType.Texture, + m_scene.RegionInfo.RegionID.ToString()); + parcels.Data = overlay; + parcels.Description = m_scene.RegionInfo.RegionName; + parcels.Temporary = false; + parcels.Flags = AssetFlags.Maptile; + + m_scene.AssetService.Store(parcels); + } + // Switch to the new one UUID lastTerrainImageID = m_scene.RegionInfo.RegionSettings.TerrainImageID; - UUID lastParcelImageID = m_scene.RegionInfo.RegionSettings.TerrainImageID; + UUID lastParcelImageID = m_scene.RegionInfo.RegionSettings.ParcelImageID; m_scene.RegionInfo.RegionSettings.TerrainImageID = terrainImageID; m_scene.RegionInfo.RegionSettings.ParcelImageID = parcelImageID; m_scene.RegionInfo.RegionSettings.Save(); @@ -1374,7 +1393,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // Delete the old one // m_log.DebugFormat("[WORLDMAP]: Deleting old map tile {0}", lastTerrainImageID); m_scene.AssetService.Delete(lastTerrainImageID.ToString()); - m_scene.AssetService.Delete(lastParcelImageID.ToString()); + if (lastParcelImageID != UUID.Zero) + m_scene.AssetService.Delete(lastParcelImageID.ToString()); } private void MakeRootAgent(ScenePresence avatar) @@ -1420,6 +1440,66 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } } + private Byte[] GenerateOverlay() + { + Bitmap overlay = new Bitmap(256, 256); + + bool[,] saleBitmap = new bool[64, 64]; + for (int x = 0 ; x < 64 ; x++) + { + for (int y = 0 ; y < 64 ; y++) + saleBitmap[x, y] = false; + } + + bool landForSale = false; + + List parcels = m_scene.LandChannel.AllParcels(); + + Color background = Color.FromArgb(0, 0, 0, 0); + SolidBrush transparent = new SolidBrush(background); + Graphics g = Graphics.FromImage(overlay); + g.FillRectangle(transparent, 0, 0, 256, 256); + + SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); + + foreach (ILandObject land in parcels) + { + // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags); + if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) + { + landForSale = true; + + saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap()); + } + } + + if (!landForSale) + { + m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not geenrating overlay", m_scene.RegionInfo.RegionName); + return null; + } + + m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, genrating overlay", m_scene.RegionInfo.RegionName); + + for (int x = 0 ; x < 64 ; x++) + { + for (int y = 0 ; y < 64 ; y++) + { + if (saleBitmap[x, y]) + g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); + } + } + + try + { + return OpenJPEG.EncodeFromImage(overlay, true); + } + catch (Exception e) + { + m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString()); + } + return null; + } } public struct MapRequestState From a98a146c50964c9d55d9cf512fa48df015fa8aaf Mon Sep 17 00:00:00 2001 From: PixelTomsen Date: Tue, 31 Jan 2012 17:44:39 +0100 Subject: [PATCH 2/4] Fix:llSetText - limited text to a maximum of 254 chars mantis: http://opensimulator.org/mantis/view.php?id=5867 Signed-off-by: nebadon --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 50fe218285..67dee021c8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4039,9 +4039,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f), Util.Clip((float)color.y, 0.0f, 1.0f), Util.Clip((float)color.z, 0.0f, 1.0f)); - m_host.SetText(text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); - m_host.ParentGroup.HasGroupChanged = true; - m_host.ParentGroup.ScheduleGroupForFullUpdate(); + m_host.SetText(text.Length > 254 ? text.Remove(255) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); + //m_host.ParentGroup.HasGroupChanged = true; + //m_host.ParentGroup.ScheduleGroupForFullUpdate(); } public LSL_Float llWater(LSL_Vector offset) From f3780b9eaeae8834c49f6e2f6045ef922916924d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 31 Jan 2012 19:56:37 +0000 Subject: [PATCH 3/4] Add torture tests to test adding 10,000, 100,000 and 200,000 single prim scene objects. These can be run using the "nant torture" target. They are not part of "nant test" due to their long-run future nature. Such tests are designed to do some testing of extreme situations and give some feedback on memory usage, etc. However, data can be inconsistent due to different machine circumstances and virtual machine actions. This area is under development. --- .nant/local.include | 11 ++ OpenSim/Region/Framework/Scenes/Scene.cs | 2 + OpenSim/Region/Framework/Scenes/SceneGraph.cs | 6 + OpenSim/Tests/Torture/ObjectTortureTests.cs | 126 ++++++++++++++++++ bin/OpenSim.Tests.Torture.dll.config | 33 +++++ prebuild.xml | 34 ++++- 6 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Tests/Torture/ObjectTortureTests.cs create mode 100644 bin/OpenSim.Tests.Torture.dll.config diff --git a/.nant/local.include b/.nant/local.include index 0c23e50eed..4fa3e4df4b 100644 --- a/.nant/local.include +++ b/.nant/local.include @@ -111,6 +111,17 @@ + + + + + + + + + + + diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 984058c902..975d769947 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1943,6 +1943,7 @@ namespace OpenSim.Region.Framework.Scenes /// If true, the object is made persistent into the scene. /// If false, the object will not persist over server restarts /// + /// true if the object was added. false if not public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) { return AddNewSceneObject(sceneObject, attachToBackup, true); @@ -1960,6 +1961,7 @@ namespace OpenSim.Region.Framework.Scenes /// If true, updates for the new scene object are sent to all viewers in range. /// If false, it is left to the caller to schedule the update /// + /// true if the object was added. false if not public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) { if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates)) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 36a454eb75..006f9c62a7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -357,7 +357,13 @@ namespace OpenSim.Region.Framework.Scenes return false; if (Entities.ContainsKey(sceneObject.UUID)) + { +// m_log.DebugFormat( +// "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()", +// m_parentScene.RegionInfo.RegionName, sceneObject.UUID); + return false; + } // m_log.DebugFormat( // "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}", diff --git a/OpenSim/Tests/Torture/ObjectTortureTests.cs b/OpenSim/Tests/Torture/ObjectTortureTests.cs new file mode 100644 index 0000000000..cdbaa66c63 --- /dev/null +++ b/OpenSim/Tests/Torture/ObjectTortureTests.cs @@ -0,0 +1,126 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Diagnostics; +using System.Reflection; +using log4net; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Tests.Torture +{ + /// + /// Object torture tests + /// + /// + /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached, + /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller + /// earlier tests. + /// + [TestFixture] + public class ObjectTortureTests + { +// [Test] +// public void Test0000Clean() +// { +// TestHelpers.InMethod(); +//// log4net.Config.XmlConfigurator.Configure(); +// +// TestAddObjects(200000); +// } + + [Test] + public void Test0001TenThousandObjects() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + TestAddObjects(10000); + } + + [Test] + public void Test0002OneHundredThousandObjects() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + TestAddObjects(100000); + } + + [Test] + public void Test0003TwoHundredThousandObjects() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + TestAddObjects(200000); + } + + private void TestAddObjects(int objectsToAdd) + { + UUID ownerId = new UUID("F0000000-0000-0000-0000-000000000000"); + + TestScene scene = SceneHelpers.SetupScene(); + + Process process = Process.GetCurrentProcess(); +// long startProcessMemory = process.PrivateMemorySize64; + long startGcMemory = GC.GetTotalMemory(true); + DateTime start = DateTime.Now; + + for (int i = 1; i <= objectsToAdd; i++) + { + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId, "part_", i); + Assert.That(scene.AddNewSceneObject(so, false), Is.True, string.Format("Object {0} was not created", i)); + } + + TimeSpan elapsed = DateTime.Now - start; +// long processMemoryAlloc = process.PrivateMemorySize64 - startProcessMemory; + long processGcAlloc = GC.GetTotalMemory(false) - startGcMemory; + + for (int i = 1; i <= objectsToAdd; i++) + { + Assert.That( + scene.GetSceneObjectGroup(TestHelpers.ParseTail(i)), + Is.Not.Null, + string.Format("Object {0} could not be retrieved", i)); + } + +// Console.WriteLine( +// "Took {0}ms, {1}MB to create {2} single prim scene objects", +// elapsed.Milliseconds, processGcAlloc / 1024 / 1024, objectsToAdd); + + Console.WriteLine( + "Took {0}MB to create {1} single prim scene objects", + processGcAlloc / 1024 / 1024, objectsToAdd); + } + } +} \ No newline at end of file diff --git a/bin/OpenSim.Tests.Torture.dll.config b/bin/OpenSim.Tests.Torture.dll.config new file mode 100644 index 0000000000..a3f681d89e --- /dev/null +++ b/bin/OpenSim.Tests.Torture.dll.config @@ -0,0 +1,33 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/prebuild.xml b/prebuild.xml index eebb9f92a5..65383ee18f 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -2822,7 +2822,6 @@ - @@ -3259,6 +3258,39 @@ + + + + ../../../bin/ + + + + + ../../../bin/ + + + + ../../../bin/ + + + + + + + + + + + + + + + + + + + + From 10b9348071094122d5e2dd636f7cce9c0b25f0a9 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 31 Jan 2012 20:30:30 +0000 Subject: [PATCH 4/4] Remove scene object null check on SceneGraph.AddSceneObject(). Complain explicitly if there's an attempt to add any object with a zero UUID. Callers themselves need to check that they're not attempting to add a null scene object. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 006f9c62a7..06de72f181 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -353,8 +353,14 @@ namespace OpenSim.Region.Framework.Scenes /// protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) { - if (sceneObject == null || sceneObject.RootPart.UUID == UUID.Zero) + if (sceneObject.UUID == UUID.Zero) + { + m_log.ErrorFormat( + "[SCENEGRAPH]: Tried to add scene object {0} to {1} with illegal UUID of {2}", + sceneObject.Name, m_parentScene.RegionInfo.RegionName, UUID.Zero); + return false; + } if (Entities.ContainsKey(sceneObject.UUID)) {