From f99b89990c9e4b136b77125c680c7a7c510a6ef2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 9 Jul 2011 02:21:56 +0100 Subject: Add scratch AvatarFactoryModuleTests with one test to do a partial check on AvatarFactoryModule.SetAppearance() Baked texture set not yet checked, nor persistence of data in avatar service This is a foundation for later npc related tests. --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 24 +++++--- .../Tests/AvatarFactoryModuleTests.cs | 72 ++++++++++++++++++++++ 2 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index d02a305..1955e5b 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -116,16 +116,20 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory #endregion /// - /// Check for the existence of the baked texture assets. Request a rebake - /// unless checkonly is true. + /// Check for the existence of the baked texture assets. /// /// - /// public bool ValidateBakedTextureCache(IClientAPI client) { return ValidateBakedTextureCache(client, true); } - + + /// + /// Check for the existence of the baked texture assets. Request a rebake + /// unless checkonly is true. + /// + /// + /// private bool ValidateBakedTextureCache(IClientAPI client, bool checkonly) { ScenePresence sp = m_scene.GetScenePresence(client.AgentId); @@ -156,13 +160,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory defonly = false; // found a non-default texture reference - if (! CheckBakedTextureAsset(client,face.TextureID,idx)) + if (!CheckBakedTextureAsset(client, face.TextureID, idx)) { // the asset didn't exist if we are only checking, then we found a bad // one and we're done otherwise, ask for a rebake - if (checkonly) return false; + if (checkonly) + return false; m_log.InfoFormat("[AVFACTORY]: missing baked texture {0}, requesting rebake", face.TextureID); + client.SendRebakeAvatarTextures(face.TextureID); } } @@ -183,7 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory ScenePresence sp = m_scene.GetScenePresence(client.AgentId); if (sp == null) { - m_log.WarnFormat("[AVFACTORY]: SetAppearance unable to find presence for {0}",client.AgentId); + m_log.WarnFormat("[AVFACTORY]: SetAppearance unable to find presence for {0}", client.AgentId); return; } @@ -211,7 +217,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; m_log.InfoFormat("[AVFACTORY]: received texture update for {0}", client.AgentId); - Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(client,false); }); + Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(client, false); }); // This appears to be set only in the final stage of the appearance // update transaction. In theory, we should be able to do an immediate @@ -220,9 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // save only if there were changes, send no matter what (doesn't hurt to send twice) if (changed) QueueAppearanceSave(client.AgentId); + QueueAppearanceSend(client.AgentId); } - } // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs new file mode 100644 index 0000000..cf4c331 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs @@ -0,0 +1,72 @@ +/* + * 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 NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory +{ + [TestFixture] + public class AvatarFactoryModuleTests + { + /// + /// Only partial right now since we don't yet test that it's ended up in the avatar appearance service. + /// + [Test] + public void TestSetAppearance() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID userId = TestHelper.ParseTail(0x1); + + AvatarFactoryModule afm = new AvatarFactoryModule(); + TestScene scene = SceneSetupHelpers.SetupScene(); + SceneSetupHelpers.SetupSceneModules(scene, afm); + + AgentCircuitData acd = new AgentCircuitData(); + acd.AgentID = userId; + TestClient tc = SceneSetupHelpers.AddRootAgent(scene, acd); + + byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT]; + for (byte i = 0; i < visualParams.Length; i++) + visualParams[i] = i; + + afm.SetAppearance(tc, new Primitive.TextureEntry(TestHelper.ParseTail(0x10)), visualParams); + + ScenePresence sp = scene.GetScenePresence(userId); + + // TODO: Check baked texture + Assert.AreEqual(visualParams, sp.Appearance.VisualParams); + } + } +} \ No newline at end of file -- cgit v1.1 From 59aedbc94b345a964fc404c22247afd0487b6f54 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 9 Jul 2011 02:25:40 +0100 Subject: Rename SceneSetupHelpers.AddRootAgent to AddClient() to better represent its effects and return object --- .../CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index cf4c331..736dd72 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = userId; - TestClient tc = SceneSetupHelpers.AddRootAgent(scene, acd); + TestClient tc = SceneSetupHelpers.AddClient(scene, acd); byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT]; for (byte i = 0; i < visualParams.Length; i++) -- cgit v1.1 From 457ba9d1a29daa203e326c6b9711c9e1ad99475d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 9 Jul 2011 02:27:47 +0100 Subject: refactor: slightly simplify test --- .../Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index 736dd72..07de908 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs @@ -52,10 +52,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory AvatarFactoryModule afm = new AvatarFactoryModule(); TestScene scene = SceneSetupHelpers.SetupScene(); SceneSetupHelpers.SetupSceneModules(scene, afm); - - AgentCircuitData acd = new AgentCircuitData(); - acd.AgentID = userId; - TestClient tc = SceneSetupHelpers.AddClient(scene, acd); + TestClient tc = SceneSetupHelpers.AddClient(scene, userId); byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT]; for (byte i = 0; i < visualParams.Length; i++) -- cgit v1.1 From bf1b8397bb6a8dad5eba89b44c46412bbb948edd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 12 Jul 2011 23:35:06 +0100 Subject: Add a warning to URI config in GridCommon.ini.example not to add a slash to the end. Tidy up GridCommon.ini.example --- OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index f15f8f6..b5cbcbb 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs @@ -68,7 +68,6 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring { m_scene = scene; - m_scene.AddCommand(this, "monitor report", "monitor report", "Returns a variety of statistics about the current region and/or simulator", -- cgit v1.1 From 08dc07dc7691ce8ee3c81528bb45b9fdfc603a68 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 13 Jul 2011 00:48:36 +0100 Subject: refactor: Move all callers of the obsoleted SychronousRestObjectPoster.BeginPostObject() to the identical SynchronousRestObjectRequester.MakeRequest() --- .../CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 321b38b..8d055d4 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs @@ -173,9 +173,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { if (m_RestURL != "") { - m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId); + m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); - List msglist = SynchronousRestObjectPoster.BeginPostObject>( + List msglist + = SynchronousRestObjectRequester.MakeRequest>( "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); if (msglist == null) @@ -203,7 +204,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if ((im.offline != 0) && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages))) { - bool success = SynchronousRestObjectPoster.BeginPostObject( + bool success = SynchronousRestObjectRequester.MakeRequest( "POST", m_RestURL+"/SaveMessage/", im); if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) -- cgit v1.1 From 3e5b2d52ff7e9fd0c968608c4a705740f51b9bc2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Jul 2011 22:58:29 +0100 Subject: minor: method doc for baked texture uploading --- OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 1955e5b..75dbeb8 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -180,8 +180,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory } /// - /// Set appearance data (textureentry and slider settings) received from the client + /// Set appearance data (texture asset IDs and slider settings) received from the client /// + /// /// /// public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) -- cgit v1.1 From 0ee7a5ee81437f7fb81814b1694c00cb5a206bda Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Jul 2011 23:36:32 +0100 Subject: If object is an attachment, make llGetVel() return the avatar's speed rather than the object's own zero speed. As per http://opensimulator.org/mantis/view.php?id=5575 --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 520d794..1e09610 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -566,7 +566,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) { - m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); -- cgit v1.1 From 2b339b7d2b1e860af2ea2a873797a70bc257bf6f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 16 Jul 2011 02:56:54 +0100 Subject: minor: remove mono compiler warnings --- OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs | 2 +- OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs | 2 +- .../CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs index c82cfd2..d687e6a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs @@ -196,7 +196,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure if (!(client.Scene is Scene)) return; - Scene scene = (Scene)(client.Scene); +// Scene scene = (Scene)(client.Scene); GridInstantMessage im = null; if (m_PendingLures.TryGetValue(lureID, out im)) diff --git a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs index 079e1b6..dee0ad4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs @@ -134,7 +134,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profile if (!(s is Scene)) return; - Scene scene = (Scene)s; +// Scene scene = (Scene)s; string profileUrl = String.Empty; string aboutText = String.Empty; diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 66fbcb9..b714f2b 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -810,18 +810,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) remoteClient.SendBulkUpdateInventory(item); + return null; } - for (int i = 0 ; i < objlist.Count ; i++ ) + for (int i = 0 ; i < objlist.Count; i++) { group = objlist[i]; - Vector3 storedPosition = group.AbsolutePosition; +// Vector3 storedPosition = group.AbsolutePosition; if (group.UUID == UUID.Zero) { m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3"); } + group.RootPart.FromFolderID = item.Folder; // If it's rezzed in world, select it. Much easier to @@ -833,6 +835,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess foreach (SceneObjectPart child in group.Parts) child.CreateSelected = true; } + group.ResetIDs(); if (attachment) -- cgit v1.1 From aec3b58a5775b70de278c950f300a0f7e6787ec2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 18 Jul 2011 02:06:06 +0100 Subject: use standard sdk stack in terrain model rather than OpenSim.Framework.UndoStack. remove OpenSim.Framework.UndoStack --- OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 9c7b2fa..c832520 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -84,7 +84,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain private ITerrainChannel m_revert; private Scene m_scene; private volatile bool m_tainted; - private readonly UndoStack m_undo = new UndoStack(5); + private readonly Stack m_undo = new Stack(5); #region ICommandableModule Members -- cgit v1.1 From f97278610c2ab9717b32b9c64bc5865b0b47dd41 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 4 Jul 2011 17:54:14 +0300 Subject: Fixed updating avatar appearance Signed-off-by: root --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 75dbeb8..9037c80 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory changed = sp.Appearance.SetVisualParams(visualParams); if (sp.Appearance.AvatarHeight > 0) sp.SetHeight(sp.Appearance.AvatarHeight); - } + } // Process the baked texture array if (textureEntry != null) @@ -387,11 +387,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}", client.AgentId); // we need to clean out the existing textures - sp.Appearance.ResetAppearance(); + sp.Appearance.ResetAppearance(); - // operate on a copy of the appearance so we don't have to lock anything + // operate on a copy of the appearance so we don't have to lock anything yet AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false); - + foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) { if (wear.Type < AvatarWearable.MAX_WEARABLES) @@ -403,12 +403,19 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // This could take awhile since it needs to pull inventory SetAppearanceAssets(sp.UUID, ref avatAppearance); - // could get fancier with the locks here, but in the spirit of "last write wins" - // this should work correctly, also, we don't need to send the appearance here - // since the "iswearing" will trigger a new set of visual param and baked texture changes - // when those complete, the new appearance will be sent - sp.Appearance = avatAppearance; - QueueAppearanceSave(client.AgentId); + lock (m_setAppearanceLock) + { + // Update only those fields that we have changed. This is important because the viewer + // often sends AvatarIsWearing and SetAppearance packets at once, and AvatarIsWearing + // shouldn't overwrite the changes made in SetAppearance. + sp.Appearance.Wearables = avatAppearance.Wearables; + sp.Appearance.Texture = avatAppearance.Texture; + + // We don't need to send the appearance here since the "iswearing" will trigger a new set + // of visual param and baked texture changes. When those complete, the new appearance will be sent + + QueueAppearanceSave(client.AgentId); + } } private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) -- cgit v1.1 From 56830bfe07234b0f4b48737a921cc6eae68d9a39 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 12 Jul 2011 12:56:34 +0300 Subject: When handling SetAppearance packet, always save the appearance; not only if the texture was changed --- .../CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 9037c80..995a552 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -224,12 +224,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // update transaction. In theory, we should be able to do an immediate // appearance send and save here. - // save only if there were changes, send no matter what (doesn't hurt to send twice) - if (changed) - QueueAppearanceSave(client.AgentId); - - QueueAppearanceSend(client.AgentId); } + // save only if there were changes, send no matter what (doesn't hurt to send twice) + if (changed) + QueueAppearanceSave(client.AgentId); + + QueueAppearanceSend(client.AgentId); } // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); -- cgit v1.1 From 02e54c57c4901167779f07ed3e89fb1d24ffc22a Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Fri, 22 Jul 2011 11:33:00 +0300 Subject: Generate the initial maptile asynchronously Signed-off-by: Melanie --- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 6e142bb..fac2dab 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1110,14 +1110,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap if (data == null) return; - UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID; - m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE"); - m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Random(); + UUID terrainImageID = UUID.Random(); AssetBase asset = new AssetBase( - m_scene.RegionInfo.RegionSettings.TerrainImageID, + terrainImageID, "terrainImage_" + m_scene.RegionInfo.RegionID.ToString(), (sbyte)AssetType.Texture, m_scene.RegionInfo.RegionID.ToString()); @@ -1129,6 +1127,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // Store the new one m_log.DebugFormat("[WORLDMAP]: Storing map tile {0}", asset.ID); m_scene.AssetService.Store(asset); + + // Switch to the new one + UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID; + m_scene.RegionInfo.RegionSettings.TerrainImageID = terrainImageID; m_scene.RegionInfo.RegionSettings.Save(); // Delete the old one -- cgit v1.1 From 667b54f5a2a04fa5a2859397868d270eab3913f1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Jul 2011 01:59:14 +0100 Subject: Don't load current/next/everyone/base permissions from the library item xml files - always use PermissionMask.All instead (which was the existing default). Library items always need the same permissions, so it doesn't make sense to load them from the xml files. This just opens the door to permissions mistakes. --- .../Framework/InventoryAccess/InventoryAccessModule.cs | 4 ++++ OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index b714f2b..4933147 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -984,11 +984,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess public virtual bool CanGetAgentInventoryItem(IClientAPI remoteClient, UUID itemID, UUID requestID) { InventoryItemBase assetRequestItem = GetItem(remoteClient.AgentId, itemID); + if (assetRequestItem == null) { ILibraryService lib = m_Scene.RequestModuleInterface(); + if (lib != null) assetRequestItem = lib.LibraryRootFolder.FindItem(itemID); + if (assetRequestItem == null) return false; } @@ -1019,6 +1022,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_log.WarnFormat( "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}", Name, requestID, itemID, assetRequestItem.AssetID); + return false; } diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index d570608..2ef4457 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs @@ -185,6 +185,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName, false); archread.Execute(); } + foreach (InventoryNodeBase node in nodes) FixPerms(node); } @@ -197,18 +198,23 @@ namespace OpenSim.Region.CoreModules.Framework.Library archread.Close(); } } - } private void FixPerms(InventoryNodeBase node) { + m_log.DebugFormat("[LIBRARY MODULE]: Fixing perms for {0} {1}", node.Name, node.ID); + if (node is InventoryItemBase) { InventoryItemBase item = (InventoryItemBase)node; +// item.BasePermissions = (uint)PermissionMask.All; item.BasePermissions = 0x7FFFFFFF; item.EveryOnePermissions = 0x7FFFFFFF; item.CurrentPermissions = 0x7FFFFFFF; item.NextPermissions = 0x7FFFFFFF; +// item.EveryOnePermissions = (uint)PermissionMask.Copy; +// item.CurrentPermissions = (uint)PermissionMask.None; +// item.NextPermissions = (uint)PermissionMask.All; } } -- cgit v1.1 From fcaa4f601231a6feb7fd5ea40e35fba6220c6235 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Jul 2011 02:05:51 +0100 Subject: Revert "Don't load current/next/everyone/base permissions from the library item xml files - always use PermissionMask.All instead (which was the existing default)." There actually are uses for this. I will correct the perms instead since some entries appear to be wrong. This reverts commit 667b54f5a2a04fa5a2859397868d270eab3913f1. --- .../Framework/InventoryAccess/InventoryAccessModule.cs | 4 ---- OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | 8 +------- 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 4933147..b714f2b 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -984,14 +984,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess public virtual bool CanGetAgentInventoryItem(IClientAPI remoteClient, UUID itemID, UUID requestID) { InventoryItemBase assetRequestItem = GetItem(remoteClient.AgentId, itemID); - if (assetRequestItem == null) { ILibraryService lib = m_Scene.RequestModuleInterface(); - if (lib != null) assetRequestItem = lib.LibraryRootFolder.FindItem(itemID); - if (assetRequestItem == null) return false; } @@ -1022,7 +1019,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_log.WarnFormat( "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}", Name, requestID, itemID, assetRequestItem.AssetID); - return false; } diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index 2ef4457..d570608 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs @@ -185,7 +185,6 @@ namespace OpenSim.Region.CoreModules.Framework.Library archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName, false); archread.Execute(); } - foreach (InventoryNodeBase node in nodes) FixPerms(node); } @@ -198,23 +197,18 @@ namespace OpenSim.Region.CoreModules.Framework.Library archread.Close(); } } + } private void FixPerms(InventoryNodeBase node) { - m_log.DebugFormat("[LIBRARY MODULE]: Fixing perms for {0} {1}", node.Name, node.ID); - if (node is InventoryItemBase) { InventoryItemBase item = (InventoryItemBase)node; -// item.BasePermissions = (uint)PermissionMask.All; item.BasePermissions = 0x7FFFFFFF; item.EveryOnePermissions = 0x7FFFFFFF; item.CurrentPermissions = 0x7FFFFFFF; item.NextPermissions = 0x7FFFFFFF; -// item.EveryOnePermissions = (uint)PermissionMask.Copy; -// item.CurrentPermissions = (uint)PermissionMask.None; -// item.NextPermissions = (uint)PermissionMask.All; } } -- cgit v1.1 From f0895028e96e39ca179cad8c103042397ad870e5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Jul 2011 02:13:11 +0100 Subject: Remove manually permissions settings on all current library items so that they use the defaults instead. Some items had completely wrong permissions - this is easier than correcting them all. The ability to set permissions in xml is retained since there are use cases for this (e.g. to create no-mod library scripts) --- .../Framework/InventoryAccess/InventoryAccessModule.cs | 4 ++++ OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index b714f2b..4933147 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -984,11 +984,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess public virtual bool CanGetAgentInventoryItem(IClientAPI remoteClient, UUID itemID, UUID requestID) { InventoryItemBase assetRequestItem = GetItem(remoteClient.AgentId, itemID); + if (assetRequestItem == null) { ILibraryService lib = m_Scene.RequestModuleInterface(); + if (lib != null) assetRequestItem = lib.LibraryRootFolder.FindItem(itemID); + if (assetRequestItem == null) return false; } @@ -1019,6 +1022,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_log.WarnFormat( "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}", Name, requestID, itemID, assetRequestItem.AssetID); + return false; } diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index d570608..2ef4457 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs @@ -185,6 +185,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName, false); archread.Execute(); } + foreach (InventoryNodeBase node in nodes) FixPerms(node); } @@ -197,18 +198,23 @@ namespace OpenSim.Region.CoreModules.Framework.Library archread.Close(); } } - } private void FixPerms(InventoryNodeBase node) { + m_log.DebugFormat("[LIBRARY MODULE]: Fixing perms for {0} {1}", node.Name, node.ID); + if (node is InventoryItemBase) { InventoryItemBase item = (InventoryItemBase)node; +// item.BasePermissions = (uint)PermissionMask.All; item.BasePermissions = 0x7FFFFFFF; item.EveryOnePermissions = 0x7FFFFFFF; item.CurrentPermissions = 0x7FFFFFFF; item.NextPermissions = 0x7FFFFFFF; +// item.EveryOnePermissions = (uint)PermissionMask.Copy; +// item.CurrentPermissions = (uint)PermissionMask.None; +// item.NextPermissions = (uint)PermissionMask.All; } } -- cgit v1.1 From be9b4ad23abcb2dec2291679c758f0dc0bc6096e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Jul 2011 02:18:23 +0100 Subject: For default everyone permissions on library items, make notecards and scripts non-modifiable (but still copyable, etc). Users should not be given the impression that they can modify these items. This still does not solve the issue where library items cannot be dragged into prims or user inventory any time after they are initially seen. Curiously, manually copying and pasting still appears to work. On the surface, this seems to have something to do with library item caching on the client, since deleting the cache allows drag to work again once Not sure what the exact problem is. --- .../Region/CoreModules/Framework/Library/LibraryModule.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index 2ef4457..3155ce7 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs @@ -207,14 +207,10 @@ namespace OpenSim.Region.CoreModules.Framework.Library if (node is InventoryItemBase) { InventoryItemBase item = (InventoryItemBase)node; -// item.BasePermissions = (uint)PermissionMask.All; - item.BasePermissions = 0x7FFFFFFF; - item.EveryOnePermissions = 0x7FFFFFFF; - item.CurrentPermissions = 0x7FFFFFFF; - item.NextPermissions = 0x7FFFFFFF; -// item.EveryOnePermissions = (uint)PermissionMask.Copy; -// item.CurrentPermissions = (uint)PermissionMask.None; -// item.NextPermissions = (uint)PermissionMask.All; + item.BasePermissions = (uint)PermissionMask.All; + item.EveryOnePermissions = (uint)PermissionMask.All - (uint)PermissionMask.Modify; + item.CurrentPermissions = (uint)PermissionMask.All; + item.NextPermissions = (uint)PermissionMask.All; } } -- cgit v1.1 From 4eaca4884eca26ca4cb73a6ce4c7edee38b789ac Mon Sep 17 00:00:00 2001 From: Makopoppo Date: Sun, 17 Jul 2011 11:22:29 +0900 Subject: Fixed serverside_object_permission default value confliction --- OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index a40517c..7cb3751 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -146,7 +146,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions = ParseUserSetConfigSetting(myConfig, "allowed_script_editors", m_allowedScriptEditors); if (m_bypassPermissions) - m_log.Info("[PERMISSIONS]: serviceside_object_permissions = false in ini file so disabling all region service permission checks"); + m_log.Info("[PERMISSIONS]: serverside_object_permissions = false in ini file so disabling all region service permission checks"); else m_log.Debug("[PERMISSIONS]: Enabling all region service permission checks"); -- cgit v1.1 From 504de8bc4792eda165d71a2c7481cb43cb92759a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Jul 2011 03:46:55 +0100 Subject: Pass the first name and last name from the agent circuit data to the authorization service rather than from the account. This is to accomodate situations where the authorization service is being used by the hypergrid, where visitors have no user account. See http://opensimulator.org/mantis/view.php?id=5517, this code is somewhat adapted/cleaned up from Michelle's patch I'm a little ambivalent about this since visitors could put anything in firstname/lastname so it's not much of an auth measure. It's up to the auth service to decide which data it actually uses. Possibly we should be passing through other info such as agent circuit ip --- .../LocalAuthorizationServiceConnector.cs | 17 ++++++++------- .../RemoteAuthorizationServiceConnector.cs | 24 ++++++++++++++-------- 2 files changed, 24 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs index 85a1ac3..18a7177 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs @@ -39,8 +39,7 @@ using OpenMetaverse; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization { - public class LocalAuthorizationServicesConnector : - ISharedRegionModule, IAuthorizationService + public class LocalAuthorizationServicesConnector : ISharedRegionModule, IAuthorizationService { private static readonly ILog m_log = LogManager.GetLogger( @@ -127,15 +126,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization if (!m_Enabled) return; - m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: Enabled local authorization for region {0}", scene.RegionInfo.RegionName); - - + m_log.InfoFormat( + "[AUTHORIZATION CONNECTOR]: Enabled local authorization for region {0}", + scene.RegionInfo.RegionName); } - public bool IsAuthorizedForRegion(string userID, string regionID, out string message) + public bool IsAuthorizedForRegion( + string userID, string firstName, string lastName, string regionID, out string message) { - return m_AuthorizationService.IsAuthorizedForRegion(userID, regionID, out message); + return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message); } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs index 66994fa..5fa27b8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs @@ -117,12 +117,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization } - public bool IsAuthorizedForRegion(string userID, string regionID, out string message) + public bool IsAuthorizedForRegion( + string userID, string firstName, string lastName, string regionID, out string message) { - m_log.InfoFormat("[REMOTE AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} for region {1}", userID, regionID); + m_log.InfoFormat( + "[REMOTE AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} for region {1}", userID, regionID); bool isAuthorized = true; message = String.Empty; + string mail = String.Empty; // get the scene this call is being made for Scene scene = null; @@ -140,17 +143,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization if (scene != null) { UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, new UUID(userID)); - isAuthorized = IsAuthorizedForRegion(userID, account.FirstName, account.LastName, - account.Email, scene.RegionInfo.RegionName, regionID, out message); + + if (account != null) + mail = account.Email; + + isAuthorized + = IsAuthorizedForRegion( + userID, firstName, lastName, account.Email, scene.RegionInfo.RegionName, regionID, out message); } else { - m_log.ErrorFormat("[REMOTE AUTHORIZATION CONNECTOR] IsAuthorizedForRegion, can't find scene to match region id of {0} ",regionID); + m_log.ErrorFormat( + "[REMOTE AUTHORIZATION CONNECTOR] IsAuthorizedForRegion, can't find scene to match region id of {0}", + regionID); } - return isAuthorized; - } } -} +} \ No newline at end of file -- cgit v1.1 From 4cdc8806fbc0d0d9b0ff878b30a4491b347cf2dc Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 23 Jul 2011 11:39:32 +0100 Subject: Fix LLTextBox to work with the updated libOMV --- OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 0db31eb..36fe040 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -141,10 +141,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog { UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid); string ownerFirstName, ownerLastName; + UUID ownerID = UUID.Zero; if (account != null) { ownerFirstName = account.FirstName; ownerLastName = account.LastName; + ownerID = account.PrincipalID; } else { @@ -155,7 +157,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog ScenePresence sp = m_scene.GetScenePresence(avatarid); if (sp != null) - sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerFirstName, ownerLastName, objectid); + sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerID, ownerFirstName, ownerLastName, objectid); } public void SendNotificationToUsersInRegion( -- cgit v1.1 From 84c68c61bd4c3f20640b7af2376c40ad5c38dc2c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 29 Jul 2011 22:27:04 +0100 Subject: When we start the appearance saving thread, make sure we set the culture to En_US so that a different culture doesn't save values with commas as decimal points, etc. This will hopefully stop giants stalking the grid. See http://opensimulator.org/mantis/view.php?id=5614 --- .../Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 995a552..20dff0c 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -305,6 +305,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory private void HandleAppearanceSave(UUID agentid) { + // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved + // in a culture where decimal points are commas and then reloaded in a culture which just treats them as + // number seperators. + Culture.SetCurrentCulture(); + ScenePresence sp = m_scene.GetScenePresence(agentid); if (sp == null) { -- cgit v1.1 From c4c6b457c3bbedd292e210cdd4dbc416d1361fcb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 30 Jul 2011 01:16:10 +0100 Subject: correct misleading "fcache status" text - deep scans are not performed when this command is invoked. --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 2b3f7f5..0b13dc5 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -765,7 +765,7 @@ namespace Flotsam.RegionModules.AssetCache foreach (string s in Directory.GetFiles(m_CacheDirectory, "*.fac")) { - m_log.Info("[FLOTSAM ASSET CACHE]: Deep Scans were performed on the following regions:"); + m_log.Info("[FLOTSAM ASSET CACHE]: Deep scans have previously been performed on the following regions:"); string RegionID = s.Remove(0,s.IndexOf("_")).Replace(".fac",""); DateTime RegionDeepScanTMStamp = File.GetLastWriteTime(s); -- cgit v1.1 From 7791c1fd1eff983a0f9824e52c5f90f1657c77a8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 30 Jul 2011 01:35:22 +0100 Subject: Replace the generic exception logging in flotsam asset cache with more specific stuff to return more information. --- .../Region/CoreModules/Asset/FlotsamAssetCache.cs | 50 +++++++++++----------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 0b13dc5..84fe506 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -301,7 +301,9 @@ namespace Flotsam.RegionModules.AssetCache } catch (Exception e) { - LogException(e); + m_log.ErrorFormat( + "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", + asset.ID, e.Message, e.StackTrace); } } @@ -361,7 +363,9 @@ namespace Flotsam.RegionModules.AssetCache } catch (System.Runtime.Serialization.SerializationException e) { - LogException(e); + m_log.ErrorFormat( + "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", + filename, id, e.Message, e.StackTrace); // If there was a problem deserializing the asset, the asset may // either be corrupted OR was serialized under an old format @@ -371,7 +375,9 @@ namespace Flotsam.RegionModules.AssetCache } catch (Exception e) { - LogException(e); + m_log.ErrorFormat( + "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", + filename, id, e.Message, e.StackTrace); } finally { @@ -380,7 +386,6 @@ namespace Flotsam.RegionModules.AssetCache } } - #if WAIT_ON_INPROGRESS_REQUESTS // Check if we're already downloading this asset. If so, try to wait for it to // download. @@ -403,7 +408,6 @@ namespace Flotsam.RegionModules.AssetCache m_RequestsForInprogress++; } #endif - return asset; } @@ -432,7 +436,6 @@ namespace Flotsam.RegionModules.AssetCache } m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0} unnessesary requests due to requests for assets that are currently downloading.", m_RequestsForInprogress); - } return asset; @@ -446,7 +449,7 @@ namespace Flotsam.RegionModules.AssetCache public void Expire(string id) { if (m_LogLevel >= 2) - m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Expiring Asset {0}.", id); + m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Expiring Asset {0}", id); try { @@ -464,7 +467,9 @@ namespace Flotsam.RegionModules.AssetCache } catch (Exception e) { - LogException(e); + m_log.ErrorFormat( + "[FLOTSAM ASSET CACHE]: Failed to expire cached file {0}. Exception {1} {2}", + id, e.Message, e.StackTrace); } } @@ -602,7 +607,9 @@ namespace Flotsam.RegionModules.AssetCache } catch (Exception e) { - LogException(e); + m_log.ErrorFormat( + "[FLOTSAM ASSET CACHE]: Failed to write asset {0} to cache. Directory {1}, tempname {2}, filename {3}. Exception {4} {5}.", + asset.ID, directory, tempname, filename, e.Message, e.StackTrace); } finally { @@ -632,15 +639,6 @@ namespace Flotsam.RegionModules.AssetCache } } - private static void LogException(Exception e) - { - string[] text = e.ToString().Split(new char[] { '\n' }); - foreach (string t in text) - { - m_log.ErrorFormat("[FLOTSAM ASSET CACHE]: {0} ", t); - } - } - /// /// Scan through the file cache, and return number of assets currently cached. /// @@ -693,8 +691,7 @@ namespace Flotsam.RegionModules.AssetCache s.ForEachSOG(delegate(SceneObjectGroup e) { gatherer.GatherAssetUuids(e, assets); - } - ); + }); } foreach (UUID assetID in assets.Keys) @@ -727,7 +724,9 @@ namespace Flotsam.RegionModules.AssetCache } catch (Exception e) { - LogException(e); + m_log.ErrorFormat( + "[FLOTSAM ASSET CACHE]: Couldn't clear asset cache directory {0} from {1}. Exception {2} {3}", + dir, m_CacheDirectory, e.Message, e.StackTrace); } } @@ -739,7 +738,9 @@ namespace Flotsam.RegionModules.AssetCache } catch (Exception e) { - LogException(e); + m_log.ErrorFormat( + "[FLOTSAM ASSET CACHE]: Couldn't clear asset cache file {0} from {1}. Exception {1} {2}", + file, m_CacheDirectory, e.Message, e.StackTrace); } } } @@ -836,7 +837,6 @@ namespace Flotsam.RegionModules.AssetCache Util.FireAndForget(delegate { int assetsCached = CacheScenes(); m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Completed Scene Caching, {0} assets found.", assetsCached); - }); break; @@ -891,7 +891,6 @@ namespace Flotsam.RegionModules.AssetCache #region IAssetService Members - public AssetMetadata GetMetadata(string id) { AssetBase asset = Get(id); @@ -921,7 +920,6 @@ namespace Flotsam.RegionModules.AssetCache Cache(asset); return asset.ID; - } public bool UpdateContent(string id, byte[] data) @@ -940,4 +938,4 @@ namespace Flotsam.RegionModules.AssetCache #endregion } -} +} \ No newline at end of file -- cgit v1.1 From 59f548cda82facef003fb7309180412254a234a1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 1 Aug 2011 23:41:29 +0100 Subject: Get osNpcCreate appearance working with avatars that are currently in the scene. Had to stop using AvatarService for now since it doesn't store baked texture IDs (which is why this was failing). Also failing because cloning appearance was also cloning the AvatarApperance.Owner field, which we weren't then changing. Extended TestCreate() to check this. --- .../Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 20dff0c..e3e3452 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -151,6 +151,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory if (face == null) continue; +// m_log.DebugFormat( +// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", +// face.TextureID, idx, client.Name, client.AgentId); + // if the texture is one of the "defaults" then skip it // this should probably be more intelligent (skirt texture doesnt matter // if the avatar isnt wearing a skirt) but if any of the main baked -- cgit v1.1 From 17e9d61f4383627434b7b8249cea1a487f001099 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 2 Aug 2011 00:52:48 +0100 Subject: Change GridService.GetRegionByName() to only return info if there is an exact region name match, unlike GetRegionsByName() This should fix the first part of http://opensimulator.org/mantis/view.php?id=5606, and maybe 5605. Thanks to Melanie for helping with this. --- .../ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index c044407..cd7d6bc 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs @@ -64,10 +64,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests } /// - /// Test saving a V0.2 OpenSim Region Archive. + /// Test region registration. /// [Test] - public void TestRegisterRegionV0_2() + public void TestRegisterRegion() { SetUp(); @@ -123,6 +123,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests m_LocalConnector.RegisterRegion(UUID.Zero, r1); GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test"); + Assert.IsNull(result, "Retrieved GetRegionByName \"Test\" is not null"); + + result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test Region 1"); Assert.IsNotNull(result, "Retrieved GetRegionByName is null"); Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match"); -- cgit v1.1 From d2220da2058b9fc7136a5dda588ebc39d77f8531 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 2 Aug 2011 00:58:08 +0100 Subject: remove ancient late 2008 cruft that handles the situation where the GetRegionsByName used to not be implemented/returned null. It's impossible that anybody is still running this since the infrastructure has changed massively since that time. --- OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 2e3b21f..3804017 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -96,16 +96,7 @@ m_log.DebugFormat("MAP NAME=({0})", mapName); // try to fetch from GridServer List regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); - if (regionInfos == null) - { - m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?"); - // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region - regionInfos = new List(); - GridRegion info = m_scene.GridService.GetRegionByName(m_scene.RegionInfo.ScopeID, mapName); - if (info != null) - regionInfos.Add(info); - } - else if (regionInfos.Count == 0) + if (regionInfos.Count == 0) remoteClient.SendAlertMessage("Hyperlink could not be established."); m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); -- cgit v1.1 From 74b23210a7780b2b1e3cb4a7ccf562fe2a8ec25e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 1 Aug 2011 23:14:20 -0700 Subject: Fix Flotsam cache so it will use the disk cache if the memory cache is enabled --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 84fe506..da39202 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -419,7 +419,7 @@ namespace Flotsam.RegionModules.AssetCache if (m_MemoryCacheEnabled) asset = GetFromMemoryCache(id); - else if (m_FileCacheEnabled) + if (asset == null && m_FileCacheEnabled) asset = GetFromFileCache(id); if (((m_LogLevel >= 1)) && (m_HitRateDisplay != 0) && (m_Requests % m_HitRateDisplay == 0)) @@ -938,4 +938,4 @@ namespace Flotsam.RegionModules.AssetCache #endregion } -} \ No newline at end of file +} -- cgit v1.1 From 6e4ec2972266ae250337867fe1ba1944131f212d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 04:19:19 +0100 Subject: Do a partial fix/implementation of OSSL osNpcMoveTo() Avatar moves and stops. However, will stop in mid stride. And if the move to position is in the air, avatar will continue to make vain and quite hilarious attempts to take off (but never doing so). Clearly more work is needed. --- .../CoreModules/World/Land/LandManagementModule.cs | 69 ++++++++++------------ 1 file changed, 32 insertions(+), 37 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 63dec15..7554e12 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -470,53 +470,48 @@ namespace OpenSim.Region.CoreModules.World.Land SendLandUpdate(avatar, false); } - public void EventManagerOnSignificantClientMovement(IClientAPI remote_client) + public void EventManagerOnSignificantClientMovement(ScenePresence clientAvatar) { - ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId); - - if (clientAvatar != null) + SendLandUpdate(clientAvatar); + SendOutNearestBanLine(clientAvatar.ControllingClient); + ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); + if (parcel != null) { - SendLandUpdate(clientAvatar); - SendOutNearestBanLine(remote_client); - ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); - if (parcel != null) + if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT && + clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) { - if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT && - clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) + EventManagerOnAvatarEnteringNewParcel(clientAvatar, parcel.LandData.LocalID, + m_scene.RegionInfo.RegionID); + //They are going under the safety line! + if (!parcel.IsBannedFromLand(clientAvatar.UUID)) { - EventManagerOnAvatarEnteringNewParcel(clientAvatar, parcel.LandData.LocalID, - m_scene.RegionInfo.RegionID); - //They are going under the safety line! - if (!parcel.IsBannedFromLand(clientAvatar.UUID)) - { - clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; - } + clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; } - else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT && - parcel.IsBannedFromLand(clientAvatar.UUID)) + } + else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT && + parcel.IsBannedFromLand(clientAvatar.UUID)) + { + //once we've sent the message once, keep going toward the target until we are done + if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId)) { - //once we've sent the message once, keep going toward the target until we are done - if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId)) - { - SendYouAreBannedNotice(clientAvatar); - ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar)); - } + SendYouAreBannedNotice(clientAvatar); + ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar)); } - else if (parcel.IsRestrictedFromLand(clientAvatar.UUID)) - { - //once we've sent the message once, keep going toward the target until we are done - if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId)) - { - SendYouAreRestrictedNotice(clientAvatar); - ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar)); - } - } - else + } + else if (parcel.IsRestrictedFromLand(clientAvatar.UUID)) + { + //once we've sent the message once, keep going toward the target until we are done + if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId)) { - //when we are finally in a safe place, lets release the forced position lock - forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); + SendYouAreRestrictedNotice(clientAvatar); + ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar)); } } + else + { + //when we are finally in a safe place, lets release the forced position lock + forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); + } } } -- cgit v1.1 From 1a2518d19bb447f4d3821cb71e32e712cc99d9c0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 5 Aug 2011 19:57:47 +0100 Subject: Instead of moving the file to its final place when FlotsamCache writes to disk, copy it instead. This is to eliminate IOException where two threads compete to cache the same file. --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index da39202..0c700e3 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -600,7 +600,13 @@ namespace Flotsam.RegionModules.AssetCache stream.Close(); // Now that it's written, rename it so that it can be found. - File.Move(tempname, filename); + // We're doing this as a file copy operation so that if two threads are competing to cache this asset, + // then both suceed instead of one failing when it tries to move the file to a final filename that + // already exists. + // This assumes that the file copy operation is atomic. Assuming this holds, then copying also works + // if another simulator is using the same cache directory. + File.Copy(tempname, filename, true); + File.Delete(tempname); if (m_LogLevel >= 2) m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Cache Stored :: {0}", asset.ID); @@ -635,7 +641,6 @@ namespace Flotsam.RegionModules.AssetCache } #endif } - } } -- cgit v1.1 From 7d35bf819374a323fa737f8342a4239e0759ce8f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 5 Aug 2011 22:45:42 +0100 Subject: refactor: remove a sliver of unnecessary code --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 0c700e3..7ef759c 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -635,10 +635,7 @@ namespace Flotsam.RegionModules.AssetCache waitEvent.Set(); } #else - if (m_CurrentlyWriting.Contains(filename)) - { - m_CurrentlyWriting.Remove(filename); - } + m_CurrentlyWriting.Remove(filename); #endif } } -- cgit v1.1 From bda1a4be4567181df6c18ce6e059ca8982bc5fa1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 6 Aug 2011 00:26:37 +0100 Subject: rename test SceneSetupHelpers -> SceneHelpers for consistency --- .../Asset/Tests/FlotsamAssetCacheTests.cs | 4 +-- .../Tests/AvatarFactoryModuleTests.cs | 6 ++-- .../Archiver/Tests/InventoryArchiveTestCase.cs | 10 +++---- .../Archiver/Tests/InventoryArchiverTests.cs | 8 +++--- .../Avatar/Inventory/Archiver/Tests/PathTests.cs | 22 +++++++-------- .../Tests/InventoryAccessModuleTests.cs | 10 +++---- .../World/Archiver/Tests/ArchiverTests.cs | 8 +++--- .../World/Land/Tests/PrimCountModuleTests.cs | 32 +++++++++++----------- .../World/Media/Moap/Tests/MoapTests.cs | 8 +++--- .../World/Serialiser/Tests/SerialiserTests.cs | 4 +-- 10 files changed, 56 insertions(+), 56 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs index 63b0c31..1662f19 100644 --- a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs +++ b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs @@ -65,8 +65,8 @@ namespace OpenSim.Region.CoreModules.Asset.Tests config.Configs["AssetCache"].Set("MemoryCacheEnabled", "true"); m_cache = new FlotsamAssetCache(); - m_scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(m_scene, config, m_cache); + m_scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(m_scene, config, m_cache); } [Test] diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index 07de908..c05f5ab 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs @@ -50,9 +50,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory UUID userId = TestHelper.ParseTail(0x1); AvatarFactoryModule afm = new AvatarFactoryModule(); - TestScene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, afm); - TestClient tc = SceneSetupHelpers.AddClient(scene, userId); + TestScene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, afm); + TestClient tc = SceneHelpers.AddClient(scene, userId); byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT]; for (byte i = 0; i < visualParams.Length; i++) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index aadeedb..19ef571 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs @@ -100,8 +100,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // log4net.Config.XmlConfigurator.Configure(); InventoryArchiverModule archiverModule = new InventoryArchiverModule(); - Scene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, archiverModule); + Scene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, archiverModule); UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); @@ -109,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // Create scene object asset UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); - SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50); + SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50); UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); @@ -127,10 +127,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests scene.AddInventoryItem(item1); // Create coalesced objects asset - SceneObjectGroup cobj1 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120); + SceneObjectGroup cobj1 = SceneHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120); cobj1.AbsolutePosition = new Vector3(15, 30, 45); - SceneObjectGroup cobj2 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140); + SceneObjectGroup cobj2 = SceneHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140); cobj2.AbsolutePosition = new Vector3(25, 50, 75); CoalescedSceneObjects coa = new CoalescedSceneObjects(m_uaLL1.PrincipalID, cobj1, cobj2); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index ae3ab21..3616ae2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -61,8 +61,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests SerialiserModule serialiserModule = new SerialiserModule(); m_archiverModule = new InventoryArchiverModule(); - m_scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); + m_scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); } [Test] @@ -141,7 +141,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // Create asset UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); - SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50); + SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50); UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); @@ -236,7 +236,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // Create asset UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); - SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50); + SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50); UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs index 127d5f8..1d3e5d0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs @@ -62,8 +62,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests InventoryArchiverModule archiverModule = new InventoryArchiverModule(); - Scene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, archiverModule); + Scene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, archiverModule); // Create user string userFirstName = "Jock"; @@ -179,9 +179,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests InventoryArchiverModule archiverModule = new InventoryArchiverModule(); // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene - Scene scene = SceneSetupHelpers.SetupScene(); + Scene scene = SceneHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); + SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "meowfood"); UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); @@ -222,8 +222,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests SerialiserModule serialiserModule = new SerialiserModule(); InventoryArchiverModule archiverModule = new InventoryArchiverModule(); - Scene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); + Scene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "password"); archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream); @@ -247,8 +247,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests InventoryArchiverModule archiverModule = new InventoryArchiverModule(); - Scene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, archiverModule); + Scene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, archiverModule); // Create user string userFirstName = "Jock"; @@ -326,7 +326,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - Scene scene = SceneSetupHelpers.SetupScene(); + Scene scene = SceneHelpers.SetupScene(); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); Dictionary foldersCreated = new Dictionary(); @@ -393,7 +393,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests TestHelper.InMethod(); //log4net.Config.XmlConfigurator.Configure(); - Scene scene = SceneSetupHelpers.SetupScene(); + Scene scene = SceneHelpers.SetupScene(); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); string folder1ExistingName = "a"; @@ -444,7 +444,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - Scene scene = SceneSetupHelpers.SetupScene(); + Scene scene = SceneHelpers.SetupScene(); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); string folder1ExistingName = "a"; diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs index 733ad25..90b6481 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs @@ -65,8 +65,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests config.AddConfig("Modules"); config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); - m_scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(m_scene, config, m_iam); + m_scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(m_scene, config, m_iam); // Create user string userFirstName = "Jock"; @@ -86,10 +86,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests // log4net.Config.XmlConfigurator.Configure(); // Create asset - SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20); + SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20); object1.AbsolutePosition = new Vector3(15, 30, 45); - SceneObjectGroup object2 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40); + SceneObjectGroup object2 = SceneHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40); object2.AbsolutePosition = new Vector3(25, 50, 75); CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2); @@ -142,7 +142,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests // log4net.Config.XmlConfigurator.Configure(); // Create asset - SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40); + SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40); UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 6ba3459..645113f 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -68,8 +68,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests SerialiserModule serialiserModule = new SerialiserModule(); TerrainModule terrainModule = new TerrainModule(); - m_scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); + m_scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); } private void LoadCompleted(Guid requestId, string errorMessage) @@ -524,8 +524,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests SerialiserModule serialiserModule = new SerialiserModule(); TerrainModule terrainModule = new TerrainModule(); - Scene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); + Scene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index a3aa38d..fecbf67 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -64,8 +64,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests { m_pcm = new PrimCountModule(); LandManagementModule lmm = new LandManagementModule(); - m_scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm); + m_scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(m_scene, lmm, m_pcm); int xParcelDivider = (int)Constants.RegionSize - 1; @@ -111,7 +111,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); + SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); m_scene.AddNewSceneObject(sog, false); Assert.That(pc.Owner, Is.EqualTo(3)); @@ -124,7 +124,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Simulator, Is.EqualTo(3)); // Add a second object and retest - SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10); + SceneObjectGroup sog2 = SceneHelpers.CreateSceneObject(2, m_userId, "b", 0x10); m_scene.AddNewSceneObject(sog2, false); Assert.That(pc.Owner, Is.EqualTo(5)); @@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); + SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); m_scene.AddNewSceneObject(sog, false); m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity); @@ -172,9 +172,9 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); + SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); m_scene.AddNewSceneObject(sog, false); - SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10); + SceneObjectGroup sog2 = SceneHelpers.CreateSceneObject(2, m_userId, "b", 0x10); m_scene.AddNewSceneObject(sog2, false); // Move the first scene object to the eastern strip parcel @@ -235,8 +235,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1), false); - SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10); + m_scene.AddNewSceneObject(SceneHelpers.CreateSceneObject(1, m_userId, "a", 0x1), false); + SceneObjectGroup sogToDelete = SceneHelpers.CreateSceneObject(3, m_userId, "b", 0x10); m_scene.AddNewSceneObject(sogToDelete, false); m_scene.DeleteSceneObject(sogToDelete, false); @@ -260,7 +260,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01); + SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01); sog.GroupID = m_groupId; m_scene.AddNewSceneObject(sog, false); @@ -291,11 +291,11 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sogToKeep = SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1); + SceneObjectGroup sogToKeep = SceneHelpers.CreateSceneObject(1, m_userId, "a", 0x1); sogToKeep.GroupID = m_groupId; m_scene.AddNewSceneObject(sogToKeep, false); - SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10); + SceneObjectGroup sogToDelete = SceneHelpers.CreateSceneObject(3, m_userId, "b", 0x10); m_scene.AddNewSceneObject(sogToDelete, false); m_scene.DeleteSceneObject(sogToDelete, false); @@ -318,7 +318,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01); + SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01); m_scene.AddNewSceneObject(sog, false); Assert.That(pc.Owner, Is.EqualTo(0)); @@ -339,8 +339,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_otherUserId, "a", 0x1), false); - SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "b", 0x10); + m_scene.AddNewSceneObject(SceneHelpers.CreateSceneObject(1, m_otherUserId, "a", 0x1), false); + SceneObjectGroup sogToDelete = SceneHelpers.CreateSceneObject(3, m_otherUserId, "b", 0x10); m_scene.AddNewSceneObject(sogToDelete, false); m_scene.DeleteSceneObject(sogToDelete, false); @@ -363,7 +363,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests TestHelper.InMethod(); IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); + SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); m_scene.AddNewSceneObject(sog, false); m_pcm.TaintPrimCount(); diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs index d5b7082..fe09739 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs @@ -53,8 +53,8 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests public void SetUp() { m_module = new MoapModule(); - m_scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(m_scene, m_module); + m_scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(m_scene, m_module); } [Test] @@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene); + SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); MediaEntry me = new MediaEntry(); m_module.SetMediaEntry(part, 1, me); @@ -88,7 +88,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests string homeUrl = "opensimulator.org"; - SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene); + SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); MediaEntry me = new MediaEntry() { HomeURL = homeUrl }; m_module.SetMediaEntry(part, 1, me); diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index 4f752ab..93e38f8 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs @@ -236,8 +236,8 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests public void Init() { m_serialiserModule = new SerialiserModule(); - m_scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(m_scene, m_serialiserModule); + m_scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(m_scene, m_serialiserModule); } [Test] -- cgit v1.1 From dad1d6df181151ae45fb998447b58d5589459627 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 6 Aug 2011 00:31:03 +0100 Subject: rename TestHelper => TestHelpers for consistency --- .../CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs | 12 ++++++------ .../AvatarFactory/Tests/AvatarFactoryModuleTests.cs | 6 +++--- .../Inventory/Archiver/Tests/InventoryArchiverTests.cs | 14 +++++++------- .../Avatar/Inventory/Archiver/Tests/PathTests.cs | 14 +++++++------- .../Tests/InventoryAccessModuleTests.cs | 4 ++-- .../CoreModules/World/Archiver/Tests/ArchiverTests.cs | 10 +++++----- .../World/Land/Tests/PrimCountModuleTests.cs | 18 +++++++++--------- .../CoreModules/World/Media/Moap/Tests/MoapTests.cs | 4 ++-- .../World/Serialiser/Tests/SerialiserTests.cs | 8 ++++---- 9 files changed, 45 insertions(+), 45 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs index 1662f19..2ff1920 100644 --- a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs +++ b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs @@ -72,11 +72,11 @@ namespace OpenSim.Region.CoreModules.Asset.Tests [Test] public void TestCacheAsset() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); AssetBase asset = AssetHelpers.CreateAsset(); - asset.ID = TestHelper.ParseTail(0x1).ToString(); + asset.ID = TestHelpers.ParseTail(0x1).ToString(); // Check we don't get anything before the asset is put in the cache AssetBase retrievedAsset = m_cache.Get(asset.ID.ToString()); @@ -93,11 +93,11 @@ namespace OpenSim.Region.CoreModules.Asset.Tests [Test] public void TestExpireAsset() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); AssetBase asset = AssetHelpers.CreateAsset(); - asset.ID = TestHelper.ParseTail(0x2).ToString(); + asset.ID = TestHelpers.ParseTail(0x2).ToString(); m_cache.Store(asset); @@ -110,11 +110,11 @@ namespace OpenSim.Region.CoreModules.Asset.Tests [Test] public void TestClearCache() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); AssetBase asset = AssetHelpers.CreateAsset(); - asset.ID = TestHelper.ParseTail(0x2).ToString(); + asset.ID = TestHelpers.ParseTail(0x2).ToString(); m_cache.Store(asset); diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index c05f5ab..4e83fa7 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs @@ -44,10 +44,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory [Test] public void TestSetAppearance() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UUID userId = TestHelper.ParseTail(0x1); + UUID userId = TestHelpers.ParseTail(0x1); AvatarFactoryModule afm = new AvatarFactoryModule(); TestScene scene = SceneHelpers.SetupScene(); @@ -58,7 +58,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory for (byte i = 0; i < visualParams.Length; i++) visualParams[i] = i; - afm.SetAppearance(tc, new Primitive.TextureEntry(TestHelper.ParseTail(0x10)), visualParams); + afm.SetAppearance(tc, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams); ScenePresence sp = scene.GetScenePresence(userId); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 3616ae2..e409c8e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestLoadCoalesecedItem() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password"); @@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestOrder() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); MemoryStream archiveReadStream = new MemoryStream(m_iarStreamBytes); @@ -129,7 +129,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestSaveItemToIar() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); // Create user @@ -224,7 +224,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestSaveItemToIarNoAssets() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); // Create user @@ -325,7 +325,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestLoadIarCreatorAccountPresent() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood"); @@ -357,7 +357,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestLoadIarV0_1SameNameCreator() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood"); @@ -390,7 +390,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestLoadIarV0_1AbsentCreator() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "password"); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs index 1d3e5d0..417c20c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs @@ -57,7 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestSavePathToIarV0_1() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); InventoryArchiverModule archiverModule = new InventoryArchiverModule(); @@ -172,7 +172,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestLoadIarToInventoryPaths() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); SerialiserModule serialiserModule = new SerialiserModule(); @@ -217,7 +217,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestLoadIarPathStartsWithSlash() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); SerialiserModule serialiserModule = new SerialiserModule(); @@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestLoadIarPathWithEscapedChars() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); string itemName = "You & you are a mean/man/"; @@ -323,7 +323,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestNewIarPath() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneHelpers.SetupScene(); @@ -390,7 +390,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestPartExistingIarPath() { - TestHelper.InMethod(); + TestHelpers.InMethod(); //log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneHelpers.SetupScene(); @@ -441,7 +441,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestMergeIarPath() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneHelpers.SetupScene(); diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs index 90b6481..e74310c 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs @@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests [Test] public void TestRezCoalescedObject() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); // Create asset @@ -138,7 +138,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests [Test] public void TestRezObject() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); // Create asset diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 645113f..b185d9b 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -125,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests [Test] public void TestSaveOar() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); SceneObjectPart part1 = CreateSceneObjectPart1(); @@ -217,7 +217,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests [Test] public void TestSaveOarNoAssets() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); SceneObjectPart part1 = CreateSceneObjectPart1(); @@ -300,7 +300,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests [Test] public void TestLoadOar() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); MemoryStream archiveWriteStream = new MemoryStream(); @@ -409,7 +409,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests [Test] public void TestLoadOarRegionSettings() { - TestHelper.InMethod(); + TestHelpers.InMethod(); //log4net.Config.XmlConfigurator.Configure(); MemoryStream archiveWriteStream = new MemoryStream(); @@ -505,7 +505,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests //[Test] public void TestMergeOar() { - TestHelper.InMethod(); + TestHelpers.InMethod(); //XmlConfigurator.Configure(); MemoryStream archiveWriteStream = new MemoryStream(); diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index fecbf67..e553ffa 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests [Test] public void TestAddOwnerObject() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); IPrimCounts pc = m_lo.PrimCounts; @@ -143,7 +143,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests [Test] public void TestCopyOwnerObject() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); IPrimCounts pc = m_lo.PrimCounts; @@ -169,7 +169,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests [Test] public void TestMoveOwnerObject() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); @@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests [Test] public void TestRemoveOwnerObject() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); IPrimCounts pc = m_lo.PrimCounts; @@ -253,7 +253,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests [Test] public void TestAddGroupObject() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); m_lo.DeedToGroup(m_groupId); @@ -284,7 +284,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests [Test] public void TestRemoveGroupObject() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); m_lo.DeedToGroup(m_groupId); @@ -313,7 +313,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests [Test] public void TestAddOthersObject() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); IPrimCounts pc = m_lo.PrimCounts; @@ -334,7 +334,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests [Test] public void TestRemoveOthersObject() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); IPrimCounts pc = m_lo.PrimCounts; @@ -360,7 +360,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests [Test] public void TestTaint() { - TestHelper.InMethod(); + TestHelpers.InMethod(); IPrimCounts pc = m_lo.PrimCounts; SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs index fe09739..4326606 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs @@ -60,7 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests [Test] public void TestClearMediaUrl() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); @@ -84,7 +84,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests [Test] public void TestSetMediaUrl() { - TestHelper.InMethod(); + TestHelpers.InMethod(); string homeUrl = "opensimulator.org"; diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index 93e38f8..d5b585a 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs @@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests [Test] public void TestDeserializeXml() { - TestHelper.InMethod(); + TestHelpers.InMethod(); //log4net.Config.XmlConfigurator.Configure(); SceneObjectGroup so = SceneObjectSerializer.FromOriginalXmlFormat(xml); @@ -259,7 +259,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests [Test] public void TestSerializeXml() { - TestHelper.InMethod(); + TestHelpers.InMethod(); //log4net.Config.XmlConfigurator.Configure(); string rpName = "My Little Donkey"; @@ -334,7 +334,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests [Test] public void TestDeserializeXml2() { - TestHelper.InMethod(); + TestHelpers.InMethod(); //log4net.Config.XmlConfigurator.Configure(); SceneObjectGroup so = m_serialiserModule.DeserializeGroupFromXml2(xml2); @@ -350,7 +350,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests [Test] public void TestSerializeXml2() { - TestHelper.InMethod(); + TestHelpers.InMethod(); //log4net.Config.XmlConfigurator.Configure(); string rpName = "My Little Pony"; -- cgit v1.1 From 85e07c78fbed9e85c142c0f565c27015ad95769d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 6 Aug 2011 02:17:41 +0100 Subject: refactor: Change SceneHelpers.AddClient() to AddScenePresence(). This seems to make more sense as we can get SP.ControllingClient --- .../CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index 4e83fa7..1bd3b6e 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs @@ -52,7 +52,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory AvatarFactoryModule afm = new AvatarFactoryModule(); TestScene scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, afm); - TestClient tc = SceneHelpers.AddClient(scene, userId); + IClientAPI tc = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT]; for (byte i = 0; i < visualParams.Length; i++) -- cgit v1.1 From e869eeb0bfc48c769f680970f99e4c67dd5a1a70 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Aug 2011 03:51:34 +0100 Subject: Implement first draft functions for saving and loading NPC appearance from storage. This works by serializing and deserializing NPC AvatarAppearance to a notecard in the prim inventory and making the required baked textures permanent. By using notecards, we avoid lots of awkward, technical and user-unfriendly issues concerning retaining asset references and creating a new asset type. Notecards also allow different appearances to be swapped and manipulated easily. This also allows stored NPC appearances to work transparently with OARs/IARs since the UUID scan will pick up and store the necessary references from the notecard text. This works in my basic test but is not at all ready for user use or bug reporting yet. --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 87 ++++++++++++++++------ .../Tests/AvatarFactoryModuleTests.cs | 2 +- 2 files changed, 65 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index e3e3452..75d8143 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public void NewClient(IClientAPI client) { client.OnRequestWearables += SendWearables; - client.OnSetAppearance += SetAppearance; + client.OnSetAppearance += SetAppearanceFromClient; client.OnAvatarNowWearing += AvatarIsWearing; } @@ -189,7 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory /// /// /// - public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) + public void SetAppearanceFromClient(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) { ScenePresence sp = m_scene.GetScenePresence(client.AgentId); if (sp == null) @@ -257,6 +257,47 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory return true; } + public bool SaveBakedTextures(UUID agentId) + { + ScenePresence sp = m_scene.GetScenePresence(agentId); + + if (sp == null || sp.IsChildAgent) + return false; + + AvatarAppearance appearance = sp.Appearance; + Primitive.TextureEntryFace[] faceTextures = appearance.Texture.FaceTextures; + + m_log.DebugFormat( + "[AV FACTORY]: Permanently saving baked textures for {0} in {1}", + sp.Name, m_scene.RegionInfo.RegionName); + + for (int i = 0; i < faceTextures.Length; i++) + { +// m_log.DebugFormat( +// "[AVFACTORY]: NPC avatar {0} has texture id {1} : {2}", +// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); + + if (faceTextures[i] == null) + continue; + + AssetBase asset = m_scene.AssetService.Get(faceTextures[i].TextureID.ToString()); + + if (asset != null) + { + asset.Temporary = false; + m_scene.AssetService.Store(asset); + } + else + { + m_log.WarnFormat( + "[AV FACTORY]: Baked texture {0} for {1} in {2} unexpectedly not found when trying to save permanently", + faceTextures[i].TextureID, sp.Name, m_scene.RegionInfo.RegionName); + } + } + + return true; + } + #region UpdateAppearanceTimer /// @@ -289,25 +330,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory } } - private void HandleAppearanceSend(UUID agentid) - { - ScenePresence sp = m_scene.GetScenePresence(agentid); - if (sp == null) - { - m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); - return; - } - - // m_log.WarnFormat("[AVFACTORY]: Handle appearance send for {0}", agentid); - - // Send the appearance to everyone in the scene - sp.SendAppearanceToAllOtherAgents(); - - // Send animations back to the avatar as well - sp.Animator.SendAnimPack(); - } - - private void HandleAppearanceSave(UUID agentid) + private void SaveAppearance(UUID agentid) { // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved // in a culture where decimal points are commas and then reloaded in a culture which just treats them as @@ -337,7 +360,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory { if (kvp.Value < now) { - Util.FireAndForget(delegate(object o) { HandleAppearanceSend(kvp.Key); }); + Util.FireAndForget(delegate(object o) { SendAppearance(kvp.Key); }); m_sendqueue.Remove(kvp.Key); } } @@ -350,7 +373,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory { if (kvp.Value < now) { - Util.FireAndForget(delegate(object o) { HandleAppearanceSave(kvp.Key); }); + Util.FireAndForget(delegate(object o) { SaveAppearance(kvp.Key); }); m_savequeue.Remove(kvp.Key); } } @@ -427,6 +450,24 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory } } + public bool SendAppearance(UUID agentId) + { + ScenePresence sp = m_scene.GetScenePresence(agentId); + if (sp == null) + { + m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); + return false; + } + + // Send the appearance to everyone in the scene + sp.SendAppearanceToAllOtherAgents(); + + // Send animations back to the avatar as well + sp.Animator.SendAnimPack(); + + return true; + } + private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) { IInventoryService invService = m_scene.InventoryService; diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index 1bd3b6e..b831b31 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs @@ -58,7 +58,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory for (byte i = 0; i < visualParams.Length; i++) visualParams[i] = i; - afm.SetAppearance(tc, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams); + afm.SetAppearanceFromClient(tc, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams); ScenePresence sp = scene.GetScenePresence(userId); -- cgit v1.1 From 92e96d394a1712ed16b0a7835dd2ccfde01f3fee Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Aug 2011 23:11:07 +0100 Subject: When an NPC is created, stop telling neighbouring regions to expect a child agent --- .../CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 457ee33..f5d49c5 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1065,10 +1065,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #endregion #region Enable Child Agent + /// /// This informs a single neighbouring region about agent "avatar". /// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// + /// + /// public void EnableChildAgent(ScenePresence sp, GridRegion region) { m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName); @@ -1126,6 +1129,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer /// This informs all neighbouring regions about agent "avatar". /// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// + /// public void EnableChildAgents(ScenePresence sp) { List neighbours = new List(); @@ -1312,7 +1316,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Utils.LongToUInts(reg.RegionHandle, out x, out y); x = x / Constants.RegionSize; y = y / Constants.RegionSize; - m_log.Debug("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")"); + m_log.Debug("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint + ")"); string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath); -- cgit v1.1 From 195c1dc9b8b8511980d9a607a242b24a5a91da17 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 00:26:38 +0100 Subject: implement osNpcStopMoveTo() to cancel any current move target --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 1e09610..ebb5bd2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -566,8 +566,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) { - m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name, - attachmentpoint, attachOffset, so.RootPart.AttachedPos); + m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", + so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); so.DetachFromBackup(); -- cgit v1.1 From cace6eaa8a82018fbb21ab83ce1bf95ea0a1e154 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 02:06:32 +0100 Subject: comment out some of the currently less useful debug log messages --- .../CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs | 3 ++- .../CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs index 6543845..d6063ad 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs @@ -93,7 +93,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser lookat = ((ScenePresence)sp).Lookat; } } - m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); + +// m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); m_GridUserService.LoggedOut(client.AgentId.ToString(), client.SessionId, client.Scene.RegionInfo.RegionID, position, lookat); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index fa5b873..59a407f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -94,7 +94,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence } } - m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); +// m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); m_PresenceService.LogoutAgent(client.SessionId); } -- cgit v1.1 From 3d4cc93a8e46847d4852eb3fd038ec48c284c18e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 03:07:41 +0100 Subject: minor: a little bit of log message correction/commenting out --- OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs index aa14054..1d2141e 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs @@ -173,7 +173,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap private Bitmap fetchTexture(UUID id) { AssetBase asset = m_scene.AssetService.Get(id.ToString()); - m_log.DebugFormat("Fetched texture {0}, found: {1}", id, asset != null); + m_log.DebugFormat("[TexturedMapTileRenderer]: Fetched texture {0}, found: {1}", id, asset != null); if (asset == null) return null; ManagedImage managedImage; -- cgit v1.1 From 2169cf04f92a6465fe9cd58a2bac0d1380a561bd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Aug 2011 01:24:15 +0100 Subject: When saving appearance, only save the baked textures, not the other face textures (which are already stored permanently) --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 48 +++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 75d8143..4627701 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -271,16 +271,30 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory "[AV FACTORY]: Permanently saving baked textures for {0} in {1}", sp.Name, m_scene.RegionInfo.RegionName); - for (int i = 0; i < faceTextures.Length; i++) + foreach (int i in Enum.GetValues(typeof(BakeType))) { + BakeType bakeType = (BakeType)i; + + if (bakeType == BakeType.Unknown) + continue; + // m_log.DebugFormat( // "[AVFACTORY]: NPC avatar {0} has texture id {1} : {2}", // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); - if (faceTextures[i] == null) + int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); + Primitive.TextureEntryFace bakedTextureFace = faceTextures[ftIndex]; + + if (bakedTextureFace == null) + { + m_log.WarnFormat( + "[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently", + bakeType, sp.Name, m_scene.RegionInfo.RegionName); + continue; + } - AssetBase asset = m_scene.AssetService.Get(faceTextures[i].TextureID.ToString()); + AssetBase asset = m_scene.AssetService.Get(bakedTextureFace.TextureID.ToString()); if (asset != null) { @@ -290,11 +304,35 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory else { m_log.WarnFormat( - "[AV FACTORY]: Baked texture {0} for {1} in {2} unexpectedly not found when trying to save permanently", - faceTextures[i].TextureID, sp.Name, m_scene.RegionInfo.RegionName); + "[AV FACTORY]: Baked texture id {0} not found for bake {1} for avatar {2} in {3} when trying to save permanently", + bakedTextureFace.TextureID, bakeType, sp.Name, m_scene.RegionInfo.RegionName); } } +// for (int i = 0; i < faceTextures.Length; i++) +// { +//// m_log.DebugFormat( +//// "[AVFACTORY]: NPC avatar {0} has texture id {1} : {2}", +//// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); +// +// if (faceTextures[i] == null) +// continue; +// +// AssetBase asset = m_scene.AssetService.Get(faceTextures[i].TextureID.ToString()); +// +// if (asset != null) +// { +// asset.Temporary = false; +// m_scene.AssetService.Store(asset); +// } +// else +// { +// m_log.WarnFormat( +// "[AV FACTORY]: Baked texture {0} for {1} in {2} not found when trying to save permanently", +// faceTextures[i].TextureID, sp.Name, m_scene.RegionInfo.RegionName); +// } +// } + return true; } -- cgit v1.1 From 4b88f04c0afd36f9e88680bbafb7ccc4680fd504 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Aug 2011 22:46:42 +0100 Subject: minor: On "login disable/enable" always tell the user the final login status, rather than remaining silent if it was already on/off --- OpenSim/Region/CoreModules/World/Access/AccessModule.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs index c355b13..b5e1fd9 100644 --- a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs +++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs @@ -129,13 +129,11 @@ namespace OpenSim.Region.CoreModules.World switch (cmd[1]) { case "enable": - if (scene.LoginsDisabled) - MainConsole.Instance.Output(String.Format("Enabling logins for region {0}", scene.RegionInfo.RegionName)); + MainConsole.Instance.Output(String.Format("Logins are enabled for region {0}", scene.RegionInfo.RegionName)); scene.LoginsDisabled = false; break; case "disable": - if (!scene.LoginsDisabled) - MainConsole.Instance.Output(String.Format("Disabling logins for region {0}", scene.RegionInfo.RegionName)); + MainConsole.Instance.Output(String.Format("Logins are disabled for region {0}", scene.RegionInfo.RegionName)); scene.LoginsDisabled = true; break; case "status": -- cgit v1.1 From ed142ead25834f6ce77585262a69f873db03a393 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Aug 2011 22:50:58 +0100 Subject: minor: change login enable/disable messages in last commit so that they occur after the setting has been made --- OpenSim/Region/CoreModules/World/Access/AccessModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs index b5e1fd9..2399134 100644 --- a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs +++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs @@ -129,12 +129,12 @@ namespace OpenSim.Region.CoreModules.World switch (cmd[1]) { case "enable": - MainConsole.Instance.Output(String.Format("Logins are enabled for region {0}", scene.RegionInfo.RegionName)); scene.LoginsDisabled = false; + MainConsole.Instance.Output(String.Format("Logins are enabled for region {0}", scene.RegionInfo.RegionName)); break; case "disable": - MainConsole.Instance.Output(String.Format("Logins are disabled for region {0}", scene.RegionInfo.RegionName)); scene.LoginsDisabled = true; + MainConsole.Instance.Output(String.Format("Logins are disabled for region {0}", scene.RegionInfo.RegionName)); break; case "status": if (scene.LoginsDisabled) -- cgit v1.1 From 78ff82bfe9728b83a56e315522ee33961abe9a9d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Aug 2011 23:40:22 +0100 Subject: If a map request to a server fails, always close the outbound connection. This probably doesn't help with the current memory leak. --- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index fac2dab..7b00597 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -682,7 +682,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap mapitemsrequest.ContentLength = buffer.Length; //Count bytes to send os = mapitemsrequest.GetRequestStream(); os.Write(buffer, 0, buffer.Length); //Send it - os.Close(); //m_log.DebugFormat("[WORLD MAP]: Getting MapItems from {0}", httpserver); } catch (WebException ex) @@ -705,6 +704,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap responseMap["connect"] = OSD.FromBoolean(false); return responseMap; } + finally + { + if (os != null) + os.Close(); + } string response_mapItems_reply = null; { // get the response -- cgit v1.1 From 90c6fa89bea62f97376222f8251d576fa9af1298 Mon Sep 17 00:00:00 2001 From: Aaron Duffy Date: Sat, 6 Aug 2011 22:34:41 -0600 Subject: Fix a bug preventing region modules from creating trees at anything but the default scale. --- OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs index c2ad7b8..ab8e1bf 100644 --- a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs +++ b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs @@ -100,15 +100,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Vegetation { case Tree.Cypress1: case Tree.Cypress2: - tree.Scale = new Vector3(4, 4, 10); + tree.Scale *= new Vector3(8, 8, 20); break; // case... other tree types - // tree.Scale = new Vector3(?, ?, ?); + // tree.Scale *= new Vector3(?, ?, ?); // break; default: - tree.Scale = new Vector3(4, 4, 4); + tree.Scale *= new Vector3(8, 8, 8); break; } } -- cgit v1.1 From dcb4b2de09032380fb428f73d9e3fd10aa662377 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 13 Aug 2011 15:16:43 +0100 Subject: Fix a problem in the Flotsam asset cache where assets were being put into the memory cache even when it wasn't enabled. This hopefully addresses http://opensimulator.org/mantis/view.php?id=5634 This is the most probable cause of the memory problems that people have been seeing in the past month. This bug has been around since commit 5dc785b (4th July 2011). Doh! This is why regressions tests are such a good idea... :) Many thanks to Nebadon for using git bisect to track down this bug, which made it a 5 minute fix. --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 7ef759c..abfc771 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -357,8 +357,6 @@ namespace Flotsam.RegionModules.AssetCache asset = (AssetBase)bformatter.Deserialize(stream); - UpdateMemoryCache(id, asset); - m_DiskHits++; } catch (System.Runtime.Serialization.SerializationException e) @@ -419,9 +417,15 @@ namespace Flotsam.RegionModules.AssetCache if (m_MemoryCacheEnabled) asset = GetFromMemoryCache(id); + if (asset == null && m_FileCacheEnabled) + { asset = GetFromFileCache(id); + if (m_MemoryCacheEnabled && asset != null) + UpdateMemoryCache(id, asset); + } + if (((m_LogLevel >= 1)) && (m_HitRateDisplay != 0) && (m_Requests % m_HitRateDisplay == 0)) { m_HitRateFile = (double)m_DiskHits / m_Requests * 100.0; -- cgit v1.1 From e19843a0ee6deb1f9f96a954c97c011b3110aac0 Mon Sep 17 00:00:00 2001 From: Snoopy Pfeffer Date: Sun, 14 Aug 2011 17:45:23 +0200 Subject: WorldMap: Added map item for Land-for-Sale. Implemented backlist item timeouts (default 10 minutes; see also new config file setting BlacklistTimeout) and removing backlisted neigboring regions that have been restarted from the blacklist. --- .../CoreModules/World/WorldMap/WorldMapModule.cs | 206 +++++++++++++++++++-- 1 file changed, 187 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 7b00597..710230a 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -46,6 +46,7 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.CoreModules.World.Land; using Caps=OpenSim.Framework.Capabilities.Caps; using OSDArray=OpenMetaverse.StructuredData.OSDArray; using OSDMap=OpenMetaverse.StructuredData.OSDMap; @@ -68,6 +69,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap protected Scene m_scene; private List cachedMapBlocks = new List(); private int cachedTime = 0; + private int blacklistTimeout = 10*60*1000; // 10 minutes private byte[] myMapImageJPEG; protected volatile bool m_Enabled = false; private Dictionary m_openRequests = new Dictionary(); @@ -85,6 +87,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap IConfig startupConfig = config.Configs["Startup"]; if (startupConfig.GetString("WorldMapModule", "WorldMap") == "WorldMap") m_Enabled = true; + + blacklistTimeout = startupConfig.GetInt("BlacklistTimeout", 10*60) * 1000; } public virtual void AddRegion (Scene scene) @@ -159,11 +163,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_scene.EventManager.OnClientClosed += ClientLoggedOut; m_scene.EventManager.OnMakeChildAgent += MakeChildAgent; m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; + m_scene.EventManager.OnRegionUp += OnRegionUp; + + StartThread(new object()); } // this has to be called with a lock on m_scene protected virtual void RemoveHandlers() { + StopThread(); + + m_scene.EventManager.OnRegionUp -= OnRegionUp; m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent; m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent; m_scene.EventManager.OnClientClosed -= ClientLoggedOut; @@ -279,7 +289,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap /// public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) { - m_log.Debug("[WORLD MAP]: MapLayer Request in region: " + m_scene.RegionInfo.RegionName); + m_log.DebugFormat("[WORLD MAP]: MapLayer Request in region: {0}", m_scene.RegionInfo.RegionName); LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); return mapResponse; @@ -321,8 +331,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap lock (m_rootAgents) { m_rootAgents.Remove(AgentId); - if (m_rootAgents.Count == 0) - StopThread(); } } #endregion @@ -362,6 +370,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, uint EstateID, bool godlike, uint itemtype, ulong regionhandle) { +// m_log.DebugFormat("[WORLD MAP]: Handle MapItem request {0} {1}", regionhandle, itemtype); + lock (m_rootAgents) { if (!m_rootAgents.Contains(remoteClient.AgentId)) @@ -370,7 +380,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap uint xstart = 0; uint ystart = 0; Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out xstart, out ystart); - if (itemtype == 6) // we only sevice 6 right now (avatar green dots) + if (itemtype == 6) // Service 6 right now (MAP_ITEM_AGENTS_LOCATION; green dots) { if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) { @@ -414,14 +424,58 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // Remote Map Item Request // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. - // Note that we only start up a remote mapItem Request thread if there's users who could - // be making requests - if (!threadrunning) + RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); + } + } else if (itemtype == 7) // Service 7 (MAP_ITEM_LAND_FOR_SALE) + { + if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) + { + // Parcels + ILandChannel landChannel = m_scene.LandChannel; + List parcels = landChannel.AllParcels(); + + // Local Map Item Request + int tc = Environment.TickCount; + List mapitems = new List(); + mapItemReply mapitem = new mapItemReply(); + if ((parcels != null) && (parcels.Count >= 1)) { - m_log.Warn("[WORLD MAP]: Starting new remote request thread manually. This means that AvatarEnteringParcel never fired! This needs to be fixed! Don't Mantis this, as the developers can see it in this message"); - StartThread(new object()); + foreach (ILandObject parcel_interface in parcels) + { + // Play it safe + if (!(parcel_interface is LandObject)) + continue; + + LandObject land = (LandObject)parcel_interface; + LandData parcel = land.LandData; + + // Show land for sale + if ((parcel.Flags & (uint)ParcelFlags.ForSale) == (uint)ParcelFlags.ForSale) + { + Vector3 min = parcel.AABBMin; + Vector3 max = parcel.AABBMax; + float x = (min.X+max.X)/2; + float y = (min.Y+max.Y)/2; + + mapitem = new mapItemReply(); + mapitem.x = (uint)(xstart + x); + mapitem.y = (uint)(ystart + y); + // mapitem.z = (uint)m_scene.GetGroundHeight(x,y); + mapitem.id = UUID.Zero; + mapitem.name = parcel.Name; + mapitem.Extra = parcel.Area; + mapitem.Extra2 = parcel.SalePrice; + mapitems.Add(mapitem); + } + } } + remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); + } + else + { + // Remote Map Item Request + // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); } } @@ -542,6 +596,28 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags); } + + // Service 7 (MAP_ITEM_LAND_FOR_SALE) + uint itemtype = 7; + + if (response.ContainsKey(itemtype.ToString())) + { + List returnitems = new List(); + OSDArray itemarray = (OSDArray)response[itemtype.ToString()]; + for (int i = 0; i < itemarray.Count; i++) + { + OSDMap mapitem = (OSDMap)itemarray[i]; + mapItemReply mi = new mapItemReply(); + mi.x = (uint)mapitem["X"].AsInteger(); + mi.y = (uint)mapitem["Y"].AsInteger(); + mi.id = mapitem["ID"].AsUUID(); + mi.Extra = mapitem["Extra"].AsInteger(); + mi.Extra2 = mapitem["Extra2"].AsInteger(); + mi.name = mapitem["Name"].AsString(); + returnitems.Add(mi); + } + av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); + } } } } @@ -589,12 +665,23 @@ namespace OpenSim.Region.CoreModules.World.WorldMap private OSDMap RequestMapItemsAsync(UUID id, uint flags, uint EstateID, bool godlike, uint itemtype, ulong regionhandle) { +// m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); + string httpserver = ""; bool blacklisted = false; lock (m_blacklistedregions) { if (m_blacklistedregions.ContainsKey(regionhandle)) - blacklisted = true; + { + if (Environment.TickCount > (m_blacklistedregions[regionhandle] + blacklistTimeout)) + { + m_log.DebugFormat("[WORLDMAP]: Unblock blacklisted region {0}", regionhandle); + + m_blacklistedregions.Remove(regionhandle); + } + else + blacklisted = true; + } } if (blacklisted) @@ -636,7 +723,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap lock (m_blacklistedurls) { if (m_blacklistedurls.ContainsKey(httpserver)) - blacklisted = true; + { + if (Environment.TickCount > (m_blacklistedurls[httpserver] + blacklistTimeout)) + { + m_log.DebugFormat("[WORLDMAP]: Unblock blacklisted URL {0}", httpserver); + + m_blacklistedurls.Remove(httpserver); + } + else + blacklisted = true; + } } // Can't find the http server @@ -1064,6 +1160,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart); + // Service 6 (MAP_ITEM_AGENTS_LOCATION; green dots) + OSDMap responsemap = new OSDMap(); int tc = Environment.TickCount; if (m_scene.GetRootAgentCount() == 0) @@ -1096,6 +1194,60 @@ namespace OpenSim.Region.CoreModules.World.WorldMap }); responsemap["6"] = responsearr; } + + // Service 7 (MAP_ITEM_LAND_FOR_SALE) + + ILandChannel landChannel = m_scene.LandChannel; + List parcels = landChannel.AllParcels(); + + if ((parcels == null) || (parcels.Count == 0)) + { + OSDMap responsemapdata = new OSDMap(); + responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1)); + responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1)); + responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); + responsemapdata["Name"] = OSD.FromString(""); + responsemapdata["Extra"] = OSD.FromInteger(0); + responsemapdata["Extra2"] = OSD.FromInteger(0); + OSDArray responsearr = new OSDArray(); + responsearr.Add(responsemapdata); + + responsemap["7"] = responsearr; + } + else + { + OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); + foreach (ILandObject parcel_interface in parcels) + { + // Play it safe + if (!(parcel_interface is LandObject)) + continue; + + LandObject land = (LandObject)parcel_interface; + LandData parcel = land.LandData; + + // Show land for sale + if ((parcel.Flags & (uint)ParcelFlags.ForSale) == (uint)ParcelFlags.ForSale) + { + Vector3 min = parcel.AABBMin; + Vector3 max = parcel.AABBMax; + float x = (min.X+max.X)/2; + float y = (min.Y+max.Y)/2; + + OSDMap responsemapdata = new OSDMap(); + responsemapdata["X"] = OSD.FromInteger((int)(xstart + x)); + responsemapdata["Y"] = OSD.FromInteger((int)(ystart + y)); + // responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y)); + responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); + responsemapdata["Name"] = OSD.FromString(parcel.Name); + responsemapdata["Extra"] = OSD.FromInteger(parcel.Area); + responsemapdata["Extra2"] = OSD.FromInteger(parcel.SalePrice); + responsearr.Add(responsemapdata); + } + } + responsemap["7"] = responsearr; + } + return responsemap; } @@ -1144,12 +1296,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap private void MakeRootAgent(ScenePresence avatar) { - // You may ask, why this is in a threadpool to start with.. - // The reason is so we don't cause the thread to freeze waiting - // for the 1 second it costs to start a thread manually. - if (!threadrunning) - Util.FireAndForget(this.StartThread); - lock (m_rootAgents) { if (!m_rootAgents.Contains(avatar.UUID)) @@ -1164,8 +1310,30 @@ namespace OpenSim.Region.CoreModules.World.WorldMap lock (m_rootAgents) { m_rootAgents.Remove(avatar.UUID); - if (m_rootAgents.Count == 0) - StopThread(); + } + } + + public void OnRegionUp(GridRegion otherRegion) + { + ulong regionhandle = otherRegion.RegionHandle; + string httpserver = otherRegion.ServerURI + "MAP/MapItems/" + regionhandle.ToString(); + + lock (m_blacklistedregions) + { + if (!m_blacklistedregions.ContainsKey(regionhandle)) + m_blacklistedregions.Remove(regionhandle); + } + + lock (m_blacklistedurls) + { + if (m_blacklistedurls.ContainsKey(httpserver)) + m_blacklistedurls.Remove(httpserver); + } + + lock (m_cachedRegionMapItemsAddress) + { + if (!m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) + m_cachedRegionMapItemsAddress.Remove(regionhandle); } } -- cgit v1.1 From 8c95c83562db7e273cbf555514224773f21a2b19 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 21:03:43 +0100 Subject: On Flotsam asset cache, go back to moving the file from the temporary location rather than copying. Copying doesn't prevent IOExceptions on Windows due to file locking. (e.g. Mantis 5642, 5630). So instead go back to moving the file, swallowing IOExceptions that occur just for the move due to competing caching threads or even different opensimulator instances. --- .../Region/CoreModules/Asset/FlotsamAssetCache.cs | 73 ++++++++++++++-------- 1 file changed, 47 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index abfc771..b2f6e13 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -593,39 +593,60 @@ namespace Flotsam.RegionModules.AssetCache try { - if (!Directory.Exists(directory)) + try { - Directory.CreateDirectory(directory); + if (!Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } + + stream = File.Open(tempname, FileMode.Create); + BinaryFormatter bformatter = new BinaryFormatter(); + bformatter.Serialize(stream, asset); } + catch (IOException e) + { + m_log.ErrorFormat( + "[FLOTSAM ASSET CACHE]: Failed to write asset {0} to temporary location {1} (final {2}) on cache in {3}. Exception {4} {5}.", + asset.ID, tempname, filename, directory, e.Message, e.StackTrace); - stream = File.Open(tempname, FileMode.Create); - BinaryFormatter bformatter = new BinaryFormatter(); - bformatter.Serialize(stream, asset); - stream.Close(); - - // Now that it's written, rename it so that it can be found. - // We're doing this as a file copy operation so that if two threads are competing to cache this asset, - // then both suceed instead of one failing when it tries to move the file to a final filename that - // already exists. - // This assumes that the file copy operation is atomic. Assuming this holds, then copying also works - // if another simulator is using the same cache directory. - File.Copy(tempname, filename, true); - File.Delete(tempname); + return; + } + finally + { + if (stream != null) + stream.Close(); + } - if (m_LogLevel >= 2) - m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Cache Stored :: {0}", asset.ID); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[FLOTSAM ASSET CACHE]: Failed to write asset {0} to cache. Directory {1}, tempname {2}, filename {3}. Exception {4} {5}.", - asset.ID, directory, tempname, filename, e.Message, e.StackTrace); + try + { + // Now that it's written, rename it so that it can be found. + // + // File.Copy(tempname, filename, true); + // File.Delete(tempname); + // + // For a brief period, this was done as a separate copy and then temporary file delete operation. + // However, this causes exceptions on Windows when other threads attempt to read a file + // which is still being copied. So instead, go back to moving the file and swallowing any IOException + // that occurs because two threads race to cache the same data (and the second fails because the file + // already exists). + // + // This situation occurs fairly rarely anyway. We assume in this that moves are atomic on the + // filesystem. + File.Move(tempname, filename); + + if (m_LogLevel >= 2) + m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Cache Stored :: {0}", asset.ID); + } + catch (IOException) + { + // If we see an IOException here it's likely that some other competing thread has written the + // cache file first, so ignore. Other IOException errors (e.g. filesystem full) should be + // signally by the earlier temporary file writing code. + } } finally { - if (stream != null) - stream.Close(); - // Even if the write fails with an exception, we need to make sure // that we release the lock on that file, otherwise it'll never get // cached -- cgit v1.1 From fd3a7ab70c04742a8ea776180144ea016e0d4e31 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 21:31:08 +0100 Subject: minor: change some comment text in flotsam asset cache --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index b2f6e13..22c301b 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -625,11 +625,10 @@ namespace Flotsam.RegionModules.AssetCache // File.Copy(tempname, filename, true); // File.Delete(tempname); // - // For a brief period, this was done as a separate copy and then temporary file delete operation. + // For a brief period, this was done as a separate copy and then temporary file delete operation to + // avoid an IOException caused by move if some competing thread had already written the file. // However, this causes exceptions on Windows when other threads attempt to read a file - // which is still being copied. So instead, go back to moving the file and swallowing any IOException - // that occurs because two threads race to cache the same data (and the second fails because the file - // already exists). + // which is still being copied. So instead, go back to moving the file and swallow any IOException. // // This situation occurs fairly rarely anyway. We assume in this that moves are atomic on the // filesystem. -- cgit v1.1 From 66eb537d0cedfd017fd8872fb1b60ed15d871d2b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 21:56:56 +0100 Subject: relocate AttachmentTests.cs to AttachmentsModuleTests.cs --- .../Attachments/Tests/AttachmentsModuleTests.cs | 172 +++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs new file mode 100644 index 0000000..cc810d7 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -0,0 +1,172 @@ +/* + * 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.Collections.Generic; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Timers; +using Timer=System.Timers.Timer; +using Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.CoreModules.World.Serialiser; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests +{ + /// + /// Attachment tests + /// + [TestFixture] + public class AttachmentsModuleTests + { + public Scene scene, scene2; + public UUID agent1; + public static Random random; + public ulong region1, region2; + public AgentCircuitData acd1; + public SceneObjectGroup sog1, sog2, sog3; + + [TestFixtureSetUp] + public void Init() + { + TestHelpers.InMethod(); + + scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); + scene2 = SceneHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); + + ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); + interregionComms.Initialise(new IniConfigSource()); + interregionComms.PostInitialise(); + SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); + SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); + + agent1 = UUID.Random(); + random = new Random(); + sog1 = NewSOG(UUID.Random(), scene, agent1); + sog2 = NewSOG(UUID.Random(), scene, agent1); + sog3 = NewSOG(UUID.Random(), scene, agent1); + + //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); + region1 = scene.RegionInfo.RegionHandle; + region2 = scene2.RegionInfo.RegionHandle; + + SceneHelpers.AddScenePresence(scene, agent1); + } + + [Test] + public void T030_TestAddAttachments() + { + TestHelpers.InMethod(); + + ScenePresence presence = scene.GetScenePresence(agent1); + + presence.AddAttachment(sog1); + presence.AddAttachment(sog2); + presence.AddAttachment(sog3); + + Assert.That(presence.HasAttachments(), Is.True); + Assert.That(presence.ValidateAttachments(), Is.True); + } + + [Test] + public void T031_RemoveAttachments() + { + TestHelpers.InMethod(); + + ScenePresence presence = scene.GetScenePresence(agent1); + presence.RemoveAttachment(sog1); + presence.RemoveAttachment(sog2); + presence.RemoveAttachment(sog3); + Assert.That(presence.HasAttachments(), Is.False); + } + + // I'm commenting this test because scene setup NEEDS InventoryService to + // be non-null + //[Test] + public void T032_CrossAttachments() + { + TestHelpers.InMethod(); + + ScenePresence presence = scene.GetScenePresence(agent1); + ScenePresence presence2 = scene2.GetScenePresence(agent1); + presence2.AddAttachment(sog1); + presence2.AddAttachment(sog2); + + ISharedRegionModule serialiser = new SerialiserModule(); + SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); + SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); + + Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); + + //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); + Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); + Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); + } + + private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) + { + SceneObjectPart sop = new SceneObjectPart(); + sop.Name = RandomName(); + sop.Description = RandomName(); + sop.Text = RandomName(); + sop.SitName = RandomName(); + sop.TouchName = RandomName(); + sop.UUID = uuid; + sop.Shape = PrimitiveBaseShape.Default; + sop.Shape.State = 1; + sop.OwnerID = agent; + + SceneObjectGroup sog = new SceneObjectGroup(sop); + sog.SetScene(scene); + + return sog; + } + + private static string RandomName() + { + StringBuilder name = new StringBuilder(); + int size = random.Next(5,12); + char ch; + for (int i = 0; i < size; i++) + { + ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; + name.Append(ch); + } + + return name.ToString(); + } + } +} \ No newline at end of file -- cgit v1.1 From 601257f8b6ff7ad97f62e0ab2a428912095bf6dc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 21:58:52 +0100 Subject: remove setting up of second scene in attachments since it's not currently used --- .../Attachments/Tests/AttachmentsModuleTests.cs | 45 ++++++++++------------ 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index cc810d7..b008499 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -52,10 +52,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests [TestFixture] public class AttachmentsModuleTests { - public Scene scene, scene2; + public Scene scene; public UUID agent1; public static Random random; - public ulong region1, region2; + public ulong region1; public AgentCircuitData acd1; public SceneObjectGroup sog1, sog2, sog3; @@ -65,13 +65,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); - scene2 = SceneHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); interregionComms.Initialise(new IniConfigSource()); interregionComms.PostInitialise(); SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); - SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); agent1 = UUID.Random(); random = new Random(); @@ -81,7 +79,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); region1 = scene.RegionInfo.RegionHandle; - region2 = scene2.RegionInfo.RegionHandle; SceneHelpers.AddScenePresence(scene, agent1); } @@ -116,25 +113,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // I'm commenting this test because scene setup NEEDS InventoryService to // be non-null //[Test] - public void T032_CrossAttachments() - { - TestHelpers.InMethod(); - - ScenePresence presence = scene.GetScenePresence(agent1); - ScenePresence presence2 = scene2.GetScenePresence(agent1); - presence2.AddAttachment(sog1); - presence2.AddAttachment(sog2); - - ISharedRegionModule serialiser = new SerialiserModule(); - SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); - SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); - - Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); - - //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); - Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); - Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); - } +// public void T032_CrossAttachments() +// { +// TestHelpers.InMethod(); +// +// ScenePresence presence = scene.GetScenePresence(agent1); +// ScenePresence presence2 = scene2.GetScenePresence(agent1); +// presence2.AddAttachment(sog1); +// presence2.AddAttachment(sog2); +// +// ISharedRegionModule serialiser = new SerialiserModule(); +// SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); +// SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); +// +// Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); +// +// //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); +// Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); +// Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); +// } private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) { -- cgit v1.1 From c58b32e7baf199fd2168851a1f718d5650f31423 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 22:09:13 +0100 Subject: drop number of attachments in test from 3 to 2 to reduce text complexity --- .../CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index b008499..2e32377 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -57,7 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests public static Random random; public ulong region1; public AgentCircuitData acd1; - public SceneObjectGroup sog1, sog2, sog3; + public SceneObjectGroup sog1, sog2; [TestFixtureSetUp] public void Init() @@ -75,7 +75,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests random = new Random(); sog1 = NewSOG(UUID.Random(), scene, agent1); sog2 = NewSOG(UUID.Random(), scene, agent1); - sog3 = NewSOG(UUID.Random(), scene, agent1); //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); region1 = scene.RegionInfo.RegionHandle; @@ -92,7 +91,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests presence.AddAttachment(sog1); presence.AddAttachment(sog2); - presence.AddAttachment(sog3); Assert.That(presence.HasAttachments(), Is.True); Assert.That(presence.ValidateAttachments(), Is.True); @@ -106,7 +104,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests ScenePresence presence = scene.GetScenePresence(agent1); presence.RemoveAttachment(sog1); presence.RemoveAttachment(sog2); - presence.RemoveAttachment(sog3); Assert.That(presence.HasAttachments(), Is.False); } -- cgit v1.1 From 0bbf7c21d719de19d517417523e36bc25ac6ad70 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 22:13:13 +0100 Subject: Isolate existing incomplete attachments tests rather than have them rely on each other. Much easier to debug this way. --- .../Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 2e32377..d182996 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -59,11 +59,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests public AgentCircuitData acd1; public SceneObjectGroup sog1, sog2; - [TestFixtureSetUp] + [SetUp] public void Init() { - TestHelpers.InMethod(); - scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); @@ -83,7 +81,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests } [Test] - public void T030_TestAddAttachments() + public void TestAddAttachments() { TestHelpers.InMethod(); @@ -97,11 +95,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests } [Test] - public void T031_RemoveAttachments() + public void TestRemoveAttachments() { TestHelpers.InMethod(); ScenePresence presence = scene.GetScenePresence(agent1); + presence.AddAttachment(sog1); + presence.AddAttachment(sog2); presence.RemoveAttachment(sog1); presence.RemoveAttachment(sog2); Assert.That(presence.HasAttachments(), Is.False); -- cgit v1.1 From d3c10e609e2862165c3a9a4e1f436634191201d3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 22:27:52 +0100 Subject: Move some previously common code back into separate tests. Remove unused region handle from test. --- .../Attachments/Tests/AttachmentsModuleTests.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index d182996..c524090 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -55,7 +55,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests public Scene scene; public UUID agent1; public static Random random; - public ulong region1; public AgentCircuitData acd1; public SceneObjectGroup sog1, sog2; @@ -73,11 +72,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests random = new Random(); sog1 = NewSOG(UUID.Random(), scene, agent1); sog2 = NewSOG(UUID.Random(), scene, agent1); - - //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); - region1 = scene.RegionInfo.RegionHandle; - - SceneHelpers.AddScenePresence(scene, agent1); } [Test] @@ -85,8 +79,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests { TestHelpers.InMethod(); - ScenePresence presence = scene.GetScenePresence(agent1); - + ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1); presence.AddAttachment(sog1); presence.AddAttachment(sog2); @@ -99,14 +92,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests { TestHelpers.InMethod(); - ScenePresence presence = scene.GetScenePresence(agent1); + ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1); presence.AddAttachment(sog1); - presence.AddAttachment(sog2); + presence.AddAttachment(sog2); presence.RemoveAttachment(sog1); presence.RemoveAttachment(sog2); Assert.That(presence.HasAttachments(), Is.False); } +// [Test] +// public void TestRezAttachmentsOnAvatarEntrance() +// { +// ScenePresence presence = scene.GetScenePresence(agent1); +// } + // I'm commenting this test because scene setup NEEDS InventoryService to // be non-null //[Test] -- cgit v1.1 From 57e54d84d641787d40a2b45549f6f2d373c5f2f2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 23:05:08 +0100 Subject: Add new FireAndForgetMethod.None. This executes the callback on the same thread that made the request. Designed for use only by regression tests that rely on a predicable event ordering. --- .../Attachments/Tests/AttachmentsModuleTests.cs | 46 ++++++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index c524090..7f25864 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -37,10 +37,11 @@ using NUnit.Framework; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.CoreModules.Avatar.Attachments; using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; @@ -61,18 +62,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests [SetUp] public void Init() { - scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); + // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. + Util.FireAndForgetMethod = FireAndForgetMethod.None; - ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); - interregionComms.Initialise(new IniConfigSource()); - interregionComms.PostInitialise(); - SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); + scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); + SceneHelpers.SetupSceneModules(scene, new AttachmentsModule()); agent1 = UUID.Random(); random = new Random(); sog1 = NewSOG(UUID.Random(), scene, agent1); sog2 = NewSOG(UUID.Random(), scene, agent1); - } + } + + [TearDown] + public void TearDown() + { + // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple + // threads. Possibly, later tests should be rewritten not to worry about such things. + Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; + } [Test] public void TestAddAttachments() @@ -100,11 +108,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(presence.HasAttachments(), Is.False); } -// [Test] -// public void TestRezAttachmentsOnAvatarEntrance() -// { -// ScenePresence presence = scene.GetScenePresence(agent1); -// } + [Test] + public void TestRezAttachmentsOnAvatarEntrance() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID spId = TestHelpers.ParseTail(0x1); + UUID attItemId = TestHelpers.ParseTail(0x2); + UUID attAssetId = TestHelpers.ParseTail(0x3); + + AgentCircuitData acd = SceneHelpers.GenerateAgentData(spId); + acd.Appearance = new AvatarAppearance(); + acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItemId, attAssetId); + ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); + +// Assert.That(presence.HasAttachments(), Is.True); + } // I'm commenting this test because scene setup NEEDS InventoryService to // be non-null -- cgit v1.1 From 696bd448334c89607c95385f05a53e2ab72cb984 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 17 Aug 2011 00:37:33 +0100 Subject: Add new regression TestRezAttachmentsOnAvatarEntrance() to do simple attachments check --- .../Avatar/Attachments/AttachmentsModule.cs | 2 +- .../Attachments/Tests/AttachmentsModuleTests.cs | 22 ++++++++++++++++------ .../InventoryAccess/InventoryAccessModule.cs | 12 ++++++++++++ 3 files changed, 29 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index ebb5bd2..4dbc5e6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -261,7 +261,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments false, false, remoteClient.AgentId, true); // m_log.DebugFormat( -// "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", +// "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", // objatt.Name, remoteClient.Name, AttachmentPt); if (objatt != null) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 7f25864..8c79ab4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -38,6 +38,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.CoreModules.Avatar.Attachments; +using OpenSim.Region.CoreModules.Framework.InventoryAccess; using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Region.Framework.Scenes; @@ -65,8 +66,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. Util.FireAndForgetMethod = FireAndForgetMethod.None; - scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); - SceneHelpers.SetupSceneModules(scene, new AttachmentsModule()); + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); + + scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule()); agent1 = UUID.Random(); random = new Random(); @@ -114,16 +119,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UUID spId = TestHelpers.ParseTail(0x1); + UUID userId = TestHelpers.ParseTail(0x1); UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); - AgentCircuitData acd = SceneHelpers.GenerateAgentData(spId); + UserAccountHelpers.CreateUserWithInventory(scene, userId); + InventoryItemBase attItem + = UserInventoryHelpers.CreateInventoryItem( + scene, "att", attItemId, attAssetId, userId, InventoryType.Object); + + AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); acd.Appearance = new AvatarAppearance(); - acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItemId, attAssetId); + acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); -// Assert.That(presence.HasAttachments(), Is.True); + Assert.That(presence.HasAttachments(), Is.True); } // I'm commenting this test because scene setup NEEDS InventoryService to diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 4933147..65ba87b 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -964,8 +964,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } } } + else + { + m_log.WarnFormat( + "[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()", item.AssetID, item.Name, item.ID, remoteClient.Name); + } + return group; } + else + { + m_log.WarnFormat( + "[InventoryAccessModule]: Could not find item {0} for {1} in RezObject()", + itemID, remoteClient.Name); + } return null; } -- cgit v1.1 From bd5d35ee323df9b15d5303c2dcad7e29a4f3e0eb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 17 Aug 2011 00:42:58 +0100 Subject: extend test to check that there is one attachment and that it has the right name --- .../CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 8c79ab4..5bac4c6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -122,11 +122,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests UUID userId = TestHelpers.ParseTail(0x1); UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); + string attName = "att"; UserAccountHelpers.CreateUserWithInventory(scene, userId); InventoryItemBase attItem = UserInventoryHelpers.CreateInventoryItem( - scene, "att", attItemId, attAssetId, userId, InventoryType.Object); + scene, attName, attItemId, attAssetId, userId, InventoryType.Object); AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); acd.Appearance = new AvatarAppearance(); @@ -134,6 +135,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); Assert.That(presence.HasAttachments(), Is.True); + List attachments = presence.Attachments; + + Assert.That(attachments.Count, Is.EqualTo(1)); + Assert.That(attachments[0].Name, Is.EqualTo(attName)); } // I'm commenting this test because scene setup NEEDS InventoryService to -- cgit v1.1 From acfdca34fd9bf6d66d144ae5c0a325dd5e864517 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 17 Aug 2011 01:35:33 +0100 Subject: Fix issue where loading a new appearance onto an NPC would not remove the previous attachments from the scene. Addresses http://opensimulator.org/mantis/view.php?id=5636 --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 4dbc5e6..0316d29 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -101,7 +101,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) { - m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); +// m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); try { @@ -466,7 +466,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); group.DetachToInventoryPrep(); - m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); +// m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); // If an item contains scripts, it's always changed. // This ensures script state is saved on detach -- cgit v1.1 From 4a9b8184f71197d1270a920b5e4ad85c9de6bed5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 17 Aug 2011 01:51:58 +0100 Subject: For now, supress 'OH NOES' warnings given by HGInventoryBroker.CacheInventoryServiceURL when it tries to cache it for an NPC This concept is meaningless for NPCs. However, it might be better to make NPCism an actual property on ScenePresence and check. Addresses http://opensimulator.org/mantis/view.php?id=5643 --- .../ServiceConnectorsOut/Inventory/HGInventoryBroker.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 698fd56..72ae3363 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -211,11 +211,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return; } } - else - { - m_log.DebugFormat("[HG INVENTORY CONNECTOR]: User {0} does not have InventoryServerURI. OH NOES!", userID); - return; - } +// else +// { +// m_log.DebugFormat("[HG INVENTORY CONNECTOR]: User {0} does not have InventoryServerURI. OH NOES!", userID); +// return; +// } } } if (sp == null) -- cgit v1.1 From d8f886ccdb6f1bf185e7edaed7cd80b3027d58f2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 17 Aug 2011 23:41:20 +0100 Subject: comment out noisy attachments logging --- .../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 0316d29..a3639e8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -226,9 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments public UUID RezSingleAttachmentFromInventory( IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus) { - m_log.DebugFormat( - "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", - (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); +// m_log.DebugFormat( +// "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", +// (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should // be removed when that functionality is implemented in opensim @@ -566,8 +566,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) { - m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", - so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); +// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", +// so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); so.DetachFromBackup(); -- cgit v1.1 From c1a34cd8da293e63d3cba70b5271c9a297789db2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 18 Aug 2011 00:53:05 +0100 Subject: Don't try to save changed attachment states when an NPC with attachments is removed from the scene. This is done by introducing a PresenceType enum into ScenePresence which currently has two values, User and Npc. This seems better than a SaveAttachments flag in terms of code comprehension, though I'm still slightly uneasy about introducing these semantics to core objects --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index a3639e8..97a1be6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -501,10 +501,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// Update the attachment asset for the new sog details if they have changed. /// - /// + /// /// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects, /// these details are not stored on the region. - /// + /// /// /// /// -- cgit v1.1 From c9e6b7bd10b2cdaa917e41259ae0d612f2171f7a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Aug 2011 00:45:22 +0100 Subject: Stop NPC's getting hypergrid like names in some circumstances. This meant punching in another AddUser() method in IUserManagement to do a direct name to UUID associated without the account check (since NPCs don't have accounts). May address http://opensimulator.org/mantis/view.php?id=5645 --- .../UserManagement/UserManagementModule.cs | 45 +++++++++++++++------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index a4861ec..b0b35e4 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -186,7 +186,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement } } - private string[] GetUserNames(UUID uuid) { string[] returnstring = new string[2]; @@ -292,6 +291,25 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement return userID.ToString(); } + public void AddUser(UUID uuid, string first, string last) + { + if (m_UserCache.ContainsKey(uuid)) + return; + + UserData user = new UserData(); + user.Id = uuid; + user.FirstName = first; + user.LastName = last; + // user.ProfileURL = we should initialize this to the default + + AddUserInternal(user); + } + + public void AddUser(UUID uuid, string first, string last, string profileURL) + { + AddUser(uuid, profileURL + ";" + first + " " + last); + } + public void AddUser(UUID id, string creatorData) { if (m_UserCache.ContainsKey(id)) @@ -299,18 +317,17 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData); - UserData user = new UserData(); - user.Id = id; UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); if (account != null) { - user.FirstName = account.FirstName; - user.LastName = account.LastName; - // user.ProfileURL = we should initialize this to the default + AddUser(id, account.FirstName, account.LastName); } else { + UserData user = new UserData(); + user.Id = id; + if (creatorData != null && creatorData != string.Empty) { //creatorData = ; @@ -338,17 +355,19 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement user.FirstName = "Unknown"; user.LastName = "User"; } - } - lock (m_UserCache) - m_UserCache[id] = user; - - m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.HomeURL); + AddUserInternal(user); + } } - public void AddUser(UUID uuid, string first, string last, string profileURL) + void AddUserInternal(UserData user) { - AddUser(uuid, profileURL + ";" + first + " " + last); + lock (m_UserCache) + m_UserCache[user.Id] = user; + + m_log.DebugFormat( + "[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", + user.Id, user.FirstName, user.LastName, user.HomeURL); } //public void AddUser(UUID uuid, string userData) -- cgit v1.1 From 2787207aa287a60a3c7c06fad66d406180033ae2 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 19 Aug 2011 18:47:21 -0400 Subject: Add llRegionSayTo llRegionSayTo(key target, integer channel, string messasge) Allows messages to be sent region-wide to a particular prim. --- .../Scripting/WorldComm/WorldCommModule.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index d647e71..6917b14 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -282,6 +282,27 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm } } + // wComm.DeliverMessageTo(target, channelID, m_host.Name, m_host.UUID, text); + public void DeliverMessageTo(UUID target, int channel, string name, UUID id, string msg) + { + foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) + { + // Dont process if this message is from yourself! + if (li.GetHostID().Equals(id)) + continue; + + SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); + if (sPart == null) + continue; + + if ( li.GetHostID().Equals(target)) + { + QueueMessage(new ListenerInfo(li, name, id, msg)); + return; + } + } + } + protected void QueueMessage(ListenerInfo li) { lock (m_pending.SyncRoot) -- cgit v1.1 From 5e231acdce7a006a4d88a205044d9862f7d4dda8 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 20 Aug 2011 12:36:35 -0400 Subject: Add avatar and attachments to llRegionSay llRegionSay will now message avatars on chan 0 and will message attachments on the avatar that listen on channels other than 0. This behavior is consistant with the LL implementation as tested on regions in Agni with one exception: this implementation does not include issue: https://jira.secondlife.com/browse/SCR-66? --- .../Scripting/WorldComm/WorldCommModule.cs | 71 ++++++++++++++++++++-- 1 file changed, 67 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 6917b14..22352f5 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -282,9 +282,71 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm } } - // wComm.DeliverMessageTo(target, channelID, m_host.Name, m_host.UUID, text); - public void DeliverMessageTo(UUID target, int channel, string name, UUID id, string msg) - { + /// + /// Delivers the message to. + /// + /// + /// Target. + /// + /// + /// Channel. + /// + /// + /// Name. + /// + /// + /// Identifier. + /// + /// + /// Message. + /// + public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) + { + error = null; + // Is id an avatar? + ScenePresence sp = m_scene.GetScenePresence(target); + + if (sp != null) + { + // Send message to avatar + if (channel == 0) + { + m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Owner, 0, pos, name, id, false); + } + + List attachments = sp.Attachments; + // Nothing left to do + if (attachments == null) + return true; + + // Get uuid of attachments + List targets = new List(); + foreach ( SceneObjectGroup sog in attachments ) + { + targets.Add(sog.UUID); + } + // Need to check each attachment + foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) + { + if (li.GetHostID().Equals(id)) + continue; + + if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) + continue; + + if ( targets.Contains(li.GetHostID())) + QueueMessage(new ListenerInfo(li, name, id, msg)); + } + return true; + } + + // Need to toss an error here + if (channel == 0) + { + error = "Cannot use llRegionSayTo to message objects on channel 0"; + return false; + } + foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { // Dont process if this message is from yourself! @@ -298,9 +360,10 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm if ( li.GetHostID().Equals(target)) { QueueMessage(new ListenerInfo(li, name, id, msg)); - return; + break; } } + return true; } protected void QueueMessage(ListenerInfo li) -- cgit v1.1 From db91044593fc2592c7abb21034aeea8965febbd7 Mon Sep 17 00:00:00 2001 From: Snoopy Pfeffer Date: Mon, 22 Aug 2011 14:51:43 +0200 Subject: Thanks Neil Canham for fixing bulk inventory updates, no sending BulkInventoryUpdate after accepting inventory items. --- .../Avatar/Inventory/Transfer/InventoryTransferModule.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index e3d4969..b4f69e6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -278,7 +278,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer else { if (m_TransferModule != null) - m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); + m_TransferModule.SendInstantMessage(im, delegate(bool success) { + // Send BulkUpdateInventory + IInventoryService invService = scene.InventoryService; + UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip + + InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); + folder = invService.GetFolder(folder); + + ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); + + fromUser.ControllingClient.SendBulkUpdateInventory(folder); + }); } } else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) -- cgit v1.1 From d328046efbcd7449e0421f72138f48272f514481 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 23:59:48 +0100 Subject: If an attachment fails, then start logging the exception for now, in order to help with the inconsistent state bug. This also refactors AttachmentsModules to stop pointlessly refetching the ScenePresence in various methods. However, more of this is required. --- .../Avatar/Attachments/AttachmentsModule.cs | 135 ++++++++++++--------- 1 file changed, 80 insertions(+), 55 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 97a1be6..c96de3a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -105,6 +105,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments try { + ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); + + if (sp == null) + { + m_log.ErrorFormat( + "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId); + return; + } + // If we can't take it, we can't attach it! SceneObjectPart part = m_scene.GetSceneObjectPart(objectLocalID); if (part == null) @@ -123,7 +132,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments AttachmentPt &= 0x7f; // Calls attach with a Zero position - if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false)) + if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) { m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); @@ -136,12 +145,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } catch (Exception e) { - m_log.DebugFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}", e); + m_log.ErrorFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}{1}", e.Message, e.StackTrace); } } - + public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent) { + ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); + + if (sp == null) + { + m_log.ErrorFormat( + "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId); + return false; + } + + return AttachObject(sp, group, AttachmentPt, silent); + } + + public bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent) + { Vector3 attachPos = group.AbsolutePosition; // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should @@ -175,32 +198,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments group.AbsolutePosition = attachPos; // Remove any previous attachments - ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); UUID itemID = UUID.Zero; - if (sp != null) + foreach (SceneObjectGroup grp in sp.Attachments) { - foreach (SceneObjectGroup grp in sp.Attachments) + if (grp.GetAttachmentPoint() == (byte)AttachmentPt) { - if (grp.GetAttachmentPoint() == (byte)AttachmentPt) - { - itemID = grp.GetFromItemID(); - break; - } + itemID = grp.GetFromItemID(); + break; } - if (itemID != UUID.Zero) - DetachSingleAttachmentToInv(itemID, remoteClient); } + if (itemID != UUID.Zero) + DetachSingleAttachmentToInv(itemID, sp); + if (group.GetFromItemID() == UUID.Zero) { - m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemID); + m_scene.attachObjectAssetStore(sp.ControllingClient, group, sp.UUID, out itemID); } else { itemID = group.GetFromItemID(); } - ShowAttachInUserInventory(remoteClient, AttachmentPt, itemID, group); + ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); AttachToAgent(sp, group, AttachmentPt, attachPos, silent); @@ -229,19 +249,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", // (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); + + ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); + + if (sp == null) + { + m_log.ErrorFormat( + "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezSingleAttachmentFromInventory()", + remoteClient.Name, remoteClient.AgentId); + return UUID.Zero; + } // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should // be removed when that functionality is implemented in opensim AttachmentPt &= 0x7f; - SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); + SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, AttachmentPt); if (updateInventoryStatus) { if (att == null) - ShowDetachInUserInventory(itemID, remoteClient); + ShowDetachInUserInventory(itemID, sp.ControllingClient); else - ShowAttachInUserInventory(att, remoteClient, itemID, AttachmentPt); + ShowAttachInUserInventory(att, sp, itemID, AttachmentPt); } if (null == att) @@ -250,15 +280,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return att.UUID; } - protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( - IClientAPI remoteClient, UUID itemID, uint AttachmentPt) + private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( + ScenePresence sp, UUID itemID, uint AttachmentPt) { IInventoryAccessModule invAccess = m_scene.RequestModuleInterface(); if (invAccess != null) { - SceneObjectGroup objatt = invAccess.RezObject(remoteClient, + SceneObjectGroup objatt = invAccess.RezObject(sp.ControllingClient, itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, - false, false, remoteClient.AgentId, true); + false, false, sp.UUID, true); // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", @@ -277,10 +307,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // This will throw if the attachment fails try { - AttachObject(remoteClient, objatt, AttachmentPt, false); + AttachObject(sp, objatt, AttachmentPt, false); } - catch + catch (Exception e) { + m_log.ErrorFormat( + "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", + objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); + // Make sure the object doesn't stick around and bail m_scene.DeleteSceneObject(objatt, false); return null; @@ -295,13 +329,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments objatt.ResumeScripts(); // Do this last so that event listeners have access to all the effects of the attachment - m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); + m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID); } else { m_log.WarnFormat( "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", - itemID, remoteClient.Name, AttachmentPt); + itemID, sp.Name, AttachmentPt); } return objatt; @@ -314,12 +348,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// Update the user inventory to the attachment of an item /// /// - /// + /// /// /// /// - protected UUID ShowAttachInUserInventory( - SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt) + private UUID ShowAttachInUserInventory( + SceneObjectGroup att, ScenePresence sp, UUID itemID, uint AttachmentPt) { // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} (item ID {2})", @@ -328,16 +362,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (!att.IsDeleted) AttachmentPt = att.RootPart.AttachmentPoint; - ScenePresence presence; - if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) - { - InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); - item = m_scene.InventoryService.GetItem(item); + InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); + item = m_scene.InventoryService.GetItem(item); - bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); - if (changed && m_scene.AvatarFactory != null) - m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - } + bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); + if (changed && m_scene.AvatarFactory != null) + m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); return att.UUID; } @@ -345,12 +375,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// Update the user inventory to reflect an attachment /// - /// + /// /// /// /// - protected void ShowAttachInUserInventory( - IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) + private void ShowAttachInUserInventory( + ScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) { // m_log.DebugFormat( // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", @@ -374,16 +404,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return; } - ScenePresence presence; - if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) - { - // XXYY!! - InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); - item = m_scene.InventoryService.GetItem(item); - bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); - if (changed && m_scene.AvatarFactory != null) - m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - } + InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); + item = m_scene.InventoryService.GetItem(item); + bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); + if (changed && m_scene.AvatarFactory != null) + m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); } public void DetachObject(uint objectLocalID, IClientAPI remoteClient) @@ -407,9 +432,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments bool changed = presence.Appearance.DetachAttachment(itemID); if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - } - DetachSingleAttachmentToInv(itemID, remoteClient); + DetachSingleAttachmentToInv(itemID, presence); + } } public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) @@ -447,7 +472,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? - protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) + private void DetachSingleAttachmentToInv(UUID itemID, ScenePresence sp) { if (itemID == UUID.Zero) // If this happened, someone made a mistake.... return; @@ -474,7 +499,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (p.Inventory.ContainsScripts()) group.HasGroupChanged = true; - UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID); + UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID); m_scene.DeleteSceneObject(group, false); return; } -- cgit v1.1 From 1f3ce48be110ad048784aef22ee8458466d3fe06 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Aug 2011 00:04:38 +0100 Subject: If an object failed to attach due to an exception, then try and detach it from the avatar's list of attachments as well as delete it from the scene. This may help with the "Inconsistent attachment state" errors seen on teleport. See http://opensimulator.org/mantis/view.php?id=5644 and linked reports --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index c96de3a..90092ce 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -316,6 +316,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); // Make sure the object doesn't stick around and bail + sp.RemoveAttachment(objatt); m_scene.DeleteSceneObject(objatt, false); return null; } @@ -433,7 +434,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - DetachSingleAttachmentToInv(itemID, presence); + DetachSingleAttachmentToInv(itemID, presence); } } -- cgit v1.1 From 34aed96a2f67b94dbb4fb1900f8fa1e3228a7d50 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Aug 2011 21:20:23 +0100 Subject: replace old TestAddAttachments() with a more thorough TestAddAttachment() --- .../Attachments/Tests/AttachmentsModuleTests.cs | 35 +++++++++++++++++----- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 5bac4c6..87255aa 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -60,6 +60,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests public AgentCircuitData acd1; public SceneObjectGroup sog1, sog2; + private AttachmentsModule m_attMod; + [SetUp] public void Init() { @@ -71,7 +73,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); scene = SceneHelpers.SetupScene(); - SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule()); + m_attMod = new AttachmentsModule(); + SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); agent1 = UUID.Random(); random = new Random(); @@ -86,18 +89,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // threads. Possibly, later tests should be rewritten not to worry about such things. Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; } - + [Test] - public void TestAddAttachments() + public void TestAddAttachment() { TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); - ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1); - presence.AddAttachment(sog1); - presence.AddAttachment(sog2); + UUID userId = TestHelpers.ParseTail(0x1); + UUID attItemId = TestHelpers.ParseTail(0x2); + UUID attAssetId = TestHelpers.ParseTail(0x3); + string attName = "att"; + UserAccountHelpers.CreateUserWithInventory(scene, userId); + ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); + InventoryItemBase attItem + = UserInventoryHelpers.CreateInventoryItem( + scene, attName, attItemId, attAssetId, userId, InventoryType.Object); + + m_attMod.RezSingleAttachmentFromInventory( + presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); + + // Check status on scene presence Assert.That(presence.HasAttachments(), Is.True); - Assert.That(presence.ValidateAttachments(), Is.True); + List attachments = presence.Attachments; + Assert.That(attachments.Count, Is.EqualTo(1)); + Assert.That(attachments[0].Name, Is.EqualTo(attName)); + Assert.That(attachments[0].GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + + // Check item status + Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); } [Test] -- cgit v1.1 From 805ba268d5b642b7a9bc8d1ca10ce2e94ae2913a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Aug 2011 21:37:36 +0100 Subject: replace TestRemoveAttachments() with a more thorough TestRemoveAttachment() --- .../Attachments/Tests/AttachmentsModuleTests.cs | 78 ++++++++-------------- 1 file changed, 27 insertions(+), 51 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 87255aa..71321cc 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -54,12 +54,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests [TestFixture] public class AttachmentsModuleTests { - public Scene scene; - public UUID agent1; - public static Random random; - public AgentCircuitData acd1; - public SceneObjectGroup sog1, sog2; - + private Scene scene; private AttachmentsModule m_attMod; [SetUp] @@ -75,11 +70,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests scene = SceneHelpers.SetupScene(); m_attMod = new AttachmentsModule(); SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); - - agent1 = UUID.Random(); - random = new Random(); - sog1 = NewSOG(UUID.Random(), scene, agent1); - sog2 = NewSOG(UUID.Random(), scene, agent1); } [TearDown] @@ -122,16 +112,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests } [Test] - public void TestRemoveAttachments() + public void TestRemoveAttachment() { TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID userId = TestHelpers.ParseTail(0x1); + UUID attItemId = TestHelpers.ParseTail(0x2); + UUID attAssetId = TestHelpers.ParseTail(0x3); + string attName = "att"; + + UserAccountHelpers.CreateUserWithInventory(scene, userId); + ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); + InventoryItemBase attItem + = UserInventoryHelpers.CreateInventoryItem( + scene, attName, attItemId, attAssetId, userId, InventoryType.Object); + + m_attMod.RezSingleAttachmentFromInventory( + presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); + + // ### + m_attMod.ShowDetachInUserInventory(attItemId, presence.ControllingClient); - ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1); - presence.AddAttachment(sog1); - presence.AddAttachment(sog2); - presence.RemoveAttachment(sog1); - presence.RemoveAttachment(sog2); + // Check status on scene presence Assert.That(presence.HasAttachments(), Is.False); + List attachments = presence.Attachments; + Assert.That(attachments.Count, Is.EqualTo(0)); + + // Check item status + Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0)); } [Test] @@ -183,39 +192,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); // Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); // Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); -// } - - private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) - { - SceneObjectPart sop = new SceneObjectPart(); - sop.Name = RandomName(); - sop.Description = RandomName(); - sop.Text = RandomName(); - sop.SitName = RandomName(); - sop.TouchName = RandomName(); - sop.UUID = uuid; - sop.Shape = PrimitiveBaseShape.Default; - sop.Shape.State = 1; - sop.OwnerID = agent; - - SceneObjectGroup sog = new SceneObjectGroup(sop); - sog.SetScene(scene); - - return sog; - } - - private static string RandomName() - { - StringBuilder name = new StringBuilder(); - int size = random.Next(5,12); - char ch; - for (int i = 0; i < size; i++) - { - ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; - name.Append(ch); - } - - return name.ToString(); - } +// } } } \ No newline at end of file -- cgit v1.1 From 014cd4f8bb018391aef8e3301988975403b939a1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Aug 2011 21:41:16 +0100 Subject: remove mono compiler warnings --- .../CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 2 -- .../ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs | 4 ---- .../Authorization/RemoteAuthorizationServiceConnector.cs | 4 ---- .../ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | 2 +- .../ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | 1 - .../CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs | 2 +- OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 2 +- OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | 2 +- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 1 - 9 files changed, 4 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 71321cc..6f242e5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -130,8 +130,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests m_attMod.RezSingleAttachmentFromInventory( presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); - - // ### m_attMod.ShowDetachInUserInventory(attItemId, presence.ControllingClient); // Check status on scene presence diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs index b570155..e5af1f4 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs @@ -48,7 +48,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage private static bool m_Enabled = false; private IConfigSource m_Config; - bool m_Registered = false; #region IRegionModule interface @@ -64,9 +63,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage m_log.Info("[MAP SERVICE IN CONNECTOR]: MapImage Service In Connector enabled"); new MapGetServiceConnector(m_Config, MainServer.Instance, "MapImageService"); } - } - } public void PostInitialise() @@ -106,6 +103,5 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage } #endregion - } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs index 5fa27b8..003324f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs @@ -125,7 +125,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization bool isAuthorized = true; message = String.Empty; - string mail = String.Empty; // get the scene this call is being made for Scene scene = null; @@ -144,9 +143,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization { UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, new UUID(userID)); - if (account != null) - mail = account.Email; - isAuthorized = IsAuthorizedForRegion( userID, firstName, lastName, account.Email, scene.RegionInfo.RegionName, regionID, out message); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 0c57618..65e39c0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -280,7 +280,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { // m_log.DebugFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Requesting inventory item {0}", item.ID); - UUID requestedItemId = item.ID; +// UUID requestedItemId = item.ID; item = m_InventoryService.GetItem(item); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index e224670..6d3ace9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs @@ -61,7 +61,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage private bool m_enabled = false; private IMapImageService m_MapService; - private string m_serverUrl = String.Empty; private Dictionary m_scenes = new Dictionary(); private int m_refreshtime = 0; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index 59a407f..e2e383f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -39,7 +39,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence { public class PresenceDetector { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IPresenceService m_PresenceService; private Scene m_aScene; diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 7554e12..2117827 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -743,7 +743,7 @@ namespace OpenSim.Region.CoreModules.World.Land // Corner case. If an autoreturn happens during sim startup // we will come here with the list uninitialized // - int landId = m_landIDList[x, y]; +// int landId = m_landIDList[x, y]; // if (landId == 0) // m_log.DebugFormat( diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index dca842a..efede5c 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Land public class PrimCountModule : IPrimCountModule, INonSharedRegionModule { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_Scene; private Dictionary m_PrimCounts = diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 710230a..857079c 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -435,7 +435,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap List parcels = landChannel.AllParcels(); // Local Map Item Request - int tc = Environment.TickCount; List mapitems = new List(); mapItemReply mapitem = new mapItemReply(); if ((parcels != null) && (parcels.Count >= 1)) -- cgit v1.1 From 97b207240ee79abfec08d2dfaa9385211eb305c8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Aug 2011 22:05:22 +0100 Subject: rename AttachmentsModule.ShowDetachInUserInventory() to DetachSingleAttachmentToInv() for consistency and to reflect it's actual behaviour --- .../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 11 +++++------ .../Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 90092ce..a854c11 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachmentsFromInventory; client.OnObjectAttach += AttachObject; client.OnObjectDetach += DetachObject; - client.OnDetachAttachmentIntoInv += ShowDetachInUserInventory; + client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; } public void UnsubscribeFromClientEvents(IClientAPI client) @@ -89,7 +89,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachmentsFromInventory; client.OnObjectAttach -= AttachObject; client.OnObjectDetach -= DetachObject; - client.OnDetachAttachmentIntoInv -= ShowDetachInUserInventory; + client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; } /// @@ -269,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (updateInventoryStatus) { if (att == null) - ShowDetachInUserInventory(itemID, sp.ControllingClient); + DetachSingleAttachmentToInv(itemID, sp.ControllingClient); else ShowAttachInUserInventory(att, sp, itemID, AttachmentPt); } @@ -417,12 +417,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID); if (group != null) { - //group.DetachToGround(); - ShowDetachInUserInventory(group.GetFromItemID(), remoteClient); + DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); } } - public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient) + public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) { ScenePresence presence; if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 6f242e5..6695a9d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests m_attMod.RezSingleAttachmentFromInventory( presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); - m_attMod.ShowDetachInUserInventory(attItemId, presence.ControllingClient); + m_attMod.DetachSingleAttachmentToInv(attItemId, presence.ControllingClient); // Check status on scene presence Assert.That(presence.HasAttachments(), Is.False); -- cgit v1.1 From cf3ffe5bb4c6a8bea9599b6143c2f7793500c984 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 20:49:23 +0100 Subject: Fix llAttachToAvatar() Apart from one obvious bug, this was failing because attempting to serialize the script from inside the script (as part of saving the attachment as an inventory asset) was triggering an extremely long delay. So we now don't do this. The state will be serialized anyway when the avatar normally logs out. The worst that can happen is that if the client/server crashes, the attachment scripts start without previous state. --- .../Avatar/Attachments/AttachmentsModule.cs | 35 +++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index a854c11..c274a5b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -101,7 +101,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) { -// m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); +// m_log.DebugFormat( +// "[ATTACHMENTS MODULE]: Attaching object local id {0} to {1} point {2} from ground (silent = {3})", +// objectLocalID, remoteClient.Name, AttachmentPt, silent); try { @@ -163,8 +165,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return AttachObject(sp, group, AttachmentPt, silent); } - public bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent) + private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent) { +// m_log.DebugFormat( +// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", +// group.Name, group.LocalId, sp.Name, AttachmentPt, silent); + + if (sp.GetAttachments(AttachmentPt).Contains(group)) + { +// m_log.WarnFormat( +// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached", +// group.Name, group.LocalId, sp.Name, AttachmentPt); + + return false; + } + Vector3 attachPos = group.AbsolutePosition; // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should @@ -211,14 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (itemID != UUID.Zero) DetachSingleAttachmentToInv(itemID, sp); - if (group.GetFromItemID() == UUID.Zero) - { + itemID = group.GetFromItemID(); + if (itemID == UUID.Zero) m_scene.attachObjectAssetStore(sp.ControllingClient, group, sp.UUID, out itemID); - } - else - { - itemID = group.GetFromItemID(); - } ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); @@ -548,7 +558,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", grp.UUID, grp.GetAttachmentPoint()); - string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); + // If we're being called from a script, then trying to serialize that same script's state will not complete + // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if + // the client/server crashes rather than logging out normally, the attachment's scripts will resume + // without state on relog. Arguably, this is what we want anyway. + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = m_scene.InventoryService.GetItem(item); -- cgit v1.1 From b9ec625dbf99955c983b75651430785217559483 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 21:07:46 +0100 Subject: add TestAddAttachmentFromGround() regression test --- .../Avatar/Attachments/AttachmentsModule.cs | 2 +- .../Attachments/Tests/AttachmentsModuleTests.cs | 32 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index c274a5b..f254974 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -563,7 +563,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // the client/server crashes rather than logging out normally, the attachment's scripts will resume // without state on relog. Arguably, this is what we want anyway. string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); - + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = m_scene.InventoryService.GetItem(item); diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 6695a9d..b4ff055 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -81,7 +81,37 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests } [Test] - public void TestAddAttachment() + public void TestAddAttachmentFromGround() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID userId = TestHelpers.ParseTail(0x1); + string attName = "att"; + + UserAccountHelpers.CreateUserWithInventory(scene, userId); + ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); + SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup; + + m_attMod.AttachObject(presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false); + + SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.UUID); + Assert.That(attSo.IsAttachment); + + // Check status on scene presence + Assert.That(presence.HasAttachments(), Is.True); + List attachments = presence.Attachments; + Assert.That(attachments.Count, Is.EqualTo(1)); + Assert.That(attachments[0].Name, Is.EqualTo(attName)); + Assert.That(attachments[0].GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + + // Check item status + Assert.That(presence.Appearance.GetAttachpoint( + attSo.GetFromItemID()), Is.EqualTo((int)AttachmentPoint.Chest)); + } + + [Test] + public void TestAddAttachmentFromInventory() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); -- cgit v1.1 From ccf07f6ae337acc9c2b8fa30a784ee01ee3de24e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 21:14:57 +0100 Subject: refactor: remove pointless AgentId argument from attachObjectAssetStore() --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index f254974..88fc9e4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -228,7 +228,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments itemID = group.GetFromItemID(); if (itemID == UUID.Zero) - m_scene.attachObjectAssetStore(sp.ControllingClient, group, sp.UUID, out itemID); + m_scene.attachObjectAssetStore(sp.ControllingClient, group, out itemID); ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); -- cgit v1.1 From 5eeee480d47b855774829c94aadcb69af8c0e8da Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 21:35:44 +0100 Subject: refactor: move Scene.Inventory.attachObjectAssetStore() into AttachmentsModule.AddSceneObjectAsAttachment() --- .../Avatar/Attachments/AttachmentsModule.cs | 102 ++++++++++++++++++++- 1 file changed, 100 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 88fc9e4..5661254 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -46,7 +46,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected Scene m_scene = null; + private Scene m_scene = null; + private IDialogModule m_dialogModule; public string Name { get { return "Attachments Module"; } } public Type ReplaceableInterface { get { return null; } } @@ -56,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments public void AddRegion(Scene scene) { m_scene = scene; + m_dialogModule = m_scene.RequestModuleInterface(); m_scene.RegisterModuleInterface(this); m_scene.EventManager.OnNewClient += SubscribeToClientEvents; // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI @@ -228,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments itemID = group.GetFromItemID(); if (itemID == UUID.Zero) - m_scene.attachObjectAssetStore(sp.ControllingClient, group, out itemID); + AddSceneObjectAsAttachment(sp.ControllingClient, group, out itemID); ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); @@ -656,5 +658,101 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // it get cleaned up so.RootPart.RemFlag(PrimFlags.TemporaryOnRez); } + + /// + /// Add a scene object that was previously free in the scene as an attachment to an avatar. + /// + /// + /// + /// + /// + private UUID AddSceneObjectAsAttachment(IClientAPI remoteClient, SceneObjectGroup grp, out UUID itemID) + { +// m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); + + itemID = UUID.Zero; + + Vector3 inventoryStoredPosition = new Vector3 + (((grp.AbsolutePosition.X > (int)Constants.RegionSize) + ? Constants.RegionSize - 6 + : grp.AbsolutePosition.X) + , + (grp.AbsolutePosition.Y > (int)Constants.RegionSize) + ? Constants.RegionSize - 6 + : grp.AbsolutePosition.Y, + grp.AbsolutePosition.Z); + + Vector3 originalPosition = grp.AbsolutePosition; + + grp.AbsolutePosition = inventoryStoredPosition; + + // If we're being called from a script, then trying to serialize that same script's state will not complete + // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if + // the client/server crashes rather than logging out normally, the attachment's scripts will resume + // without state on relog. Arguably, this is what we want anyway. + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); + + grp.AbsolutePosition = originalPosition; + + AssetBase asset = m_scene.CreateAsset( + grp.GetPartName(grp.LocalId), + grp.GetPartDescription(grp.LocalId), + (sbyte)AssetType.Object, + Utils.StringToBytes(sceneObjectXml), + remoteClient.AgentId); + + m_scene.AssetService.Store(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.CreatorId = grp.RootPart.CreatorID.ToString(); + item.CreatorData = grp.RootPart.CreatorData; + item.Owner = remoteClient.AgentId; + item.ID = UUID.Random(); + item.AssetID = asset.FullID; + item.Description = asset.Description; + item.Name = asset.Name; + item.AssetType = asset.Type; + item.InvType = (int)InventoryType.Object; + + InventoryFolderBase folder = m_scene.InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); + if (folder != null) + item.Folder = folder.ID; + else // oopsies + item.Folder = UUID.Zero; + + if ((remoteClient.AgentId != grp.RootPart.OwnerID) && m_scene.Permissions.PropagatePermissions()) + { + item.BasePermissions = grp.RootPart.NextOwnerMask; + item.CurrentPermissions = grp.RootPart.NextOwnerMask; + item.NextPermissions = grp.RootPart.NextOwnerMask; + item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; + item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; + } + else + { + item.BasePermissions = grp.RootPart.BaseMask; + item.CurrentPermissions = grp.RootPart.OwnerMask; + item.NextPermissions = grp.RootPart.NextOwnerMask; + item.EveryOnePermissions = grp.RootPart.EveryoneMask; + item.GroupPermissions = grp.RootPart.GroupMask; + } + item.CreationDate = Util.UnixTimeSinceEpoch(); + + // sets itemID so client can show item as 'attached' in inventory + grp.SetFromItemID(item.ID); + + if (m_scene.AddInventoryItem(item)) + { + remoteClient.SendInventoryItemCreateUpdate(item, 0); + } + else + { + if (m_dialogModule != null) + m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); + } + + itemID = item.ID; + return item.AssetID; + } } } -- cgit v1.1 From 801b7f18a7170b3df7f678e927122125f1c16eba Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 21:40:36 +0100 Subject: return InventoryItemBase from AddSceneObjectAsAttachment() --- .../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 5661254..928d43f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments itemID = group.GetFromItemID(); if (itemID == UUID.Zero) - AddSceneObjectAsAttachment(sp.ControllingClient, group, out itemID); + itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID; ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); @@ -664,14 +664,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// /// - /// - /// - private UUID AddSceneObjectAsAttachment(IClientAPI remoteClient, SceneObjectGroup grp, out UUID itemID) + /// The user inventory item created that holds the attachment. + private InventoryItemBase AddSceneObjectAsAttachment(IClientAPI remoteClient, SceneObjectGroup grp) { // m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); - itemID = UUID.Zero; - Vector3 inventoryStoredPosition = new Vector3 (((grp.AbsolutePosition.X > (int)Constants.RegionSize) ? Constants.RegionSize - 6 @@ -751,8 +748,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); } - itemID = item.ID; - return item.AssetID; + return item; } } } -- cgit v1.1 From 73d913dad25dc1680f66ed2acc32cc6eb672da6b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 22:12:51 +0100 Subject: Make objects attached from the ground phantom --- .../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 ++ .../Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 928d43f..767908e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -669,6 +669,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { // m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); + grp.UpdatePrimFlags(grp.LocalId, grp.UsesPhysics, grp.IsTemporary, true, grp.IsVolumeDetect); + Vector3 inventoryStoredPosition = new Vector3 (((grp.AbsolutePosition.X > (int)Constants.RegionSize) ? Constants.RegionSize - 6 diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index b4ff055..9ea6a16 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -97,6 +97,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.UUID); Assert.That(attSo.IsAttachment); + Assert.That(attSo.IsPhantom); + Assert.That(attSo.UsesPhysics, Is.False); + Assert.That(attSo.IsTemporary, Is.False); // Check status on scene presence Assert.That(presence.HasAttachments(), Is.True); @@ -134,8 +137,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(presence.HasAttachments(), Is.True); List attachments = presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(1)); - Assert.That(attachments[0].Name, Is.EqualTo(attName)); - Assert.That(attachments[0].GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + SceneObjectGroup attSo = attachments[0]; + Assert.That(attSo.Name, Is.EqualTo(attName)); + Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + Assert.That(attSo.IsAttachment); + Assert.That(attSo.IsPhantom); + Assert.That(attSo.UsesPhysics, Is.False); + Assert.That(attSo.IsTemporary, Is.False); // Check item status Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); -- cgit v1.1 From 21f1b68fdf62779419bf03c522a502428a55d2d9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 22:25:23 +0100 Subject: extend initial rez regression test to check that attachment is phantom --- .../Attachments/Tests/AttachmentsModuleTests.cs | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 9ea6a16..2954933 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -95,18 +95,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests m_attMod.AttachObject(presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false); - SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.UUID); - Assert.That(attSo.IsAttachment); - Assert.That(attSo.IsPhantom); - Assert.That(attSo.UsesPhysics, Is.False); - Assert.That(attSo.IsTemporary, Is.False); - // Check status on scene presence Assert.That(presence.HasAttachments(), Is.True); List attachments = presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(1)); - Assert.That(attachments[0].Name, Is.EqualTo(attName)); - Assert.That(attachments[0].GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + SceneObjectGroup attSo = attachments[0]; + Assert.That(attSo.Name, Is.EqualTo(attName)); + Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + Assert.That(attSo.IsAttachment); + Assert.That(attSo.IsPhantom); + Assert.That(attSo.UsesPhysics, Is.False); + Assert.That(attSo.IsTemporary, Is.False); // Check item status Assert.That(presence.Appearance.GetAttachpoint( @@ -204,7 +203,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests List attachments = presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(1)); - Assert.That(attachments[0].Name, Is.EqualTo(attName)); + SceneObjectGroup attSo = attachments[0]; + Assert.That(attSo.Name, Is.EqualTo(attName)); + Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + Assert.That(attSo.IsAttachment); + Assert.That(attSo.IsPhantom); + Assert.That(attSo.UsesPhysics, Is.False); + Assert.That(attSo.IsTemporary, Is.False); } // I'm commenting this test because scene setup NEEDS InventoryService to -- cgit v1.1 From 4b4c5e69e59eb7461ccaa67fd4467e0606ffbe8e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 22:45:51 +0100 Subject: Remove forcing of phantom on ground attached objects - attachments can be both non-phantom and flagged as physical. As per Melanie --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 -- .../CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 3 --- 2 files changed, 5 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 767908e..928d43f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -669,8 +669,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { // m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); - grp.UpdatePrimFlags(grp.LocalId, grp.UsesPhysics, grp.IsTemporary, true, grp.IsVolumeDetect); - Vector3 inventoryStoredPosition = new Vector3 (((grp.AbsolutePosition.X > (int)Constants.RegionSize) ? Constants.RegionSize - 6 diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 2954933..859f6ff 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -103,7 +103,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.Name, Is.EqualTo(attName)); Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); - Assert.That(attSo.IsPhantom); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); @@ -140,7 +139,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.Name, Is.EqualTo(attName)); Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); - Assert.That(attSo.IsPhantom); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); @@ -207,7 +205,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.Name, Is.EqualTo(attName)); Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); - Assert.That(attSo.IsPhantom); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); } -- cgit v1.1 From 6c692d2e2108eac31624b34e462b8b57b5141970 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 21:26:29 +0100 Subject: Fix a very recent regression from llAttachToAvatar() fix where I accidentally stopped normal script state persistence on login/logout and attach/detach --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 928d43f..afaf5c1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -560,11 +560,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", grp.UUID, grp.GetAttachmentPoint()); - // If we're being called from a script, then trying to serialize that same script's state will not complete - // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if - // the client/server crashes rather than logging out normally, the attachment's scripts will resume - // without state on relog. Arguably, this is what we want anyway. - string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = m_scene.InventoryService.GetItem(item); -- cgit v1.1 From fcbed6479af5d64383c4ad5578ea28d7db5c3ae2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 21:46:12 +0100 Subject: Downgrade warning about not saving unchanged attachment to debug instead, and change text to better indicate what it's saying --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index afaf5c1..2c49ba8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -552,7 +552,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { if (!grp.HasGroupChanged) { - m_log.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID); + m_log.DebugFormat( + "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", + grp.UUID, grp.GetAttachmentPoint()); + return; } -- cgit v1.1 From 002313bf132e7eca3d33fdd0c695152146d469b4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:02:23 +0100 Subject: refactor: move sog.DetachToInventoryPrep() into AttachmentsModule.DetachSingleAttachmentToInv() --- .../Avatar/Attachments/AttachmentsModule.cs | 25 ++++++++++++++++------ .../Attachments/Tests/AttachmentsModuleTests.cs | 2 +- 2 files changed, 19 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2c49ba8..732e3e3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -502,17 +502,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (group.GetFromItemID() == itemID) { m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); - group.DetachToInventoryPrep(); -// m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); + sp.RemoveAttachment(group); - // If an item contains scripts, it's always changed. - // This ensures script state is saved on detach - foreach (SceneObjectPart p in group.Parts) - if (p.Inventory.ContainsScripts()) - group.HasGroupChanged = true; + // Prepare sog for storage + group.ForEachPart( + delegate(SceneObjectPart part) + { + part.AttachedAvatar = UUID.Zero; + + // If there are any scripts, + // then always trigger a new object and state persistence in UpdateKnownItem() + if (part.Inventory.ContainsScripts()) + group.HasGroupChanged = true; + } + ); + + group.RootPart.SetParentLocalId(0); + group.RootPart.IsAttachment = false; + group.AbsolutePosition = group.RootPart.AttachedPos; UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID); m_scene.DeleteSceneObject(group, false); + return; } } diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 859f6ff..afcf05a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -147,7 +147,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests } [Test] - public void TestRemoveAttachment() + public void TestDetachAttachmentToInventory() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); -- cgit v1.1 From 1dba047e4d4be6213cfade45630f2b906a5a5755 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:17:05 +0100 Subject: add regression test for detaching an attachment to the scene --- .../Attachments/Tests/AttachmentsModuleTests.cs | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index afcf05a..afa61bc 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -147,6 +147,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests } [Test] + public void TestDetachAttachmentToScene() + { + TestHelpers.InMethod(); + log4net.Config.XmlConfigurator.Configure(); + + UUID userId = TestHelpers.ParseTail(0x1); + UUID attItemId = TestHelpers.ParseTail(0x2); + UUID attAssetId = TestHelpers.ParseTail(0x3); + string attName = "att"; + + UserAccountHelpers.CreateUserWithInventory(scene, userId); + ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); + InventoryItemBase attItem + = UserInventoryHelpers.CreateInventoryItem( + scene, attName, attItemId, attAssetId, userId, InventoryType.Object); + + UUID attSoId = m_attMod.RezSingleAttachmentFromInventory( + presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); + m_attMod.DetachSingleAttachmentToGround(attSoId, presence.ControllingClient); + + // Check status on scene presence + Assert.That(presence.HasAttachments(), Is.False); + List attachments = presence.Attachments; + Assert.That(attachments.Count, Is.EqualTo(0)); + + // Check item status + Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Null); + + // Check object in scene + Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null); + } + + [Test] public void TestDetachAttachmentToInventory() { TestHelpers.InMethod(); -- cgit v1.1 From dc61bf4b1f96323f1392c1b52e0c034f4945825d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:17:27 +0100 Subject: comment out verbose test logging from last commit --- .../CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index afa61bc..072148c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -150,7 +150,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests public void TestDetachAttachmentToScene() { TestHelpers.InMethod(); - log4net.Config.XmlConfigurator.Configure(); +// log4net.Config.XmlConfigurator.Configure(); UUID userId = TestHelpers.ParseTail(0x1); UUID attItemId = TestHelpers.ParseTail(0x2); -- cgit v1.1 From 040ad11e611729be16e61dbc5075eca14067c6a9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:24:51 +0100 Subject: refactor: remove common presence set up in attachments tests --- .../Attachments/Tests/AttachmentsModuleTests.cs | 70 ++++++++++++---------- 1 file changed, 38 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 072148c..b7d21fd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -56,6 +56,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests { private Scene scene; private AttachmentsModule m_attMod; + private ScenePresence m_presence; [SetUp] public void Init() @@ -80,24 +81,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; } + /// + /// Add the standard presence for a test. + /// + private void AddPresence() + { + UUID userId = TestHelpers.ParseTail(0x1); + UserAccountHelpers.CreateUserWithInventory(scene, userId); + m_presence = SceneHelpers.AddScenePresence(scene, userId); + } + [Test] public void TestAddAttachmentFromGround() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UUID userId = TestHelpers.ParseTail(0x1); + AddPresence(); string attName = "att"; - UserAccountHelpers.CreateUserWithInventory(scene, userId); - ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup; - m_attMod.AttachObject(presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false); + m_attMod.AttachObject(m_presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false); // Check status on scene presence - Assert.That(presence.HasAttachments(), Is.True); - List attachments = presence.Attachments; + Assert.That(m_presence.HasAttachments(), Is.True); + List attachments = m_presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); @@ -107,7 +116,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.IsTemporary, Is.False); // Check item status - Assert.That(presence.Appearance.GetAttachpoint( + Assert.That(m_presence.Appearance.GetAttachpoint( attSo.GetFromItemID()), Is.EqualTo((int)AttachmentPoint.Chest)); } @@ -117,23 +126,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UUID userId = TestHelpers.ParseTail(0x1); + AddPresence(); + UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; - UserAccountHelpers.CreateUserWithInventory(scene, userId); - ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); InventoryItemBase attItem = UserInventoryHelpers.CreateInventoryItem( - scene, attName, attItemId, attAssetId, userId, InventoryType.Object); + scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); m_attMod.RezSingleAttachmentFromInventory( - presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); + m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); // Check status on scene presence - Assert.That(presence.HasAttachments(), Is.True); - List attachments = presence.Attachments; + Assert.That(m_presence.HasAttachments(), Is.True); + List attachments = m_presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); @@ -143,7 +151,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.IsTemporary, Is.False); // Check item status - Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); + Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); } [Test] @@ -152,24 +160,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UUID userId = TestHelpers.ParseTail(0x1); + AddPresence(); + UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; - UserAccountHelpers.CreateUserWithInventory(scene, userId); - ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); InventoryItemBase attItem = UserInventoryHelpers.CreateInventoryItem( - scene, attName, attItemId, attAssetId, userId, InventoryType.Object); + scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); UUID attSoId = m_attMod.RezSingleAttachmentFromInventory( - presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); - m_attMod.DetachSingleAttachmentToGround(attSoId, presence.ControllingClient); + m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); + m_attMod.DetachSingleAttachmentToGround(attSoId, m_presence.ControllingClient); // Check status on scene presence - Assert.That(presence.HasAttachments(), Is.False); - List attachments = presence.Attachments; + Assert.That(m_presence.HasAttachments(), Is.False); + List attachments = m_presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(0)); // Check item status @@ -185,28 +192,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UUID userId = TestHelpers.ParseTail(0x1); + AddPresence(); + UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; - UserAccountHelpers.CreateUserWithInventory(scene, userId); - ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); InventoryItemBase attItem = UserInventoryHelpers.CreateInventoryItem( - scene, attName, attItemId, attAssetId, userId, InventoryType.Object); + scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); m_attMod.RezSingleAttachmentFromInventory( - presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); - m_attMod.DetachSingleAttachmentToInv(attItemId, presence.ControllingClient); + m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); + m_attMod.DetachSingleAttachmentToInv(attItemId, m_presence.ControllingClient); // Check status on scene presence - Assert.That(presence.HasAttachments(), Is.False); - List attachments = presence.Attachments; + Assert.That(m_presence.HasAttachments(), Is.False); + List attachments = m_presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(0)); // Check item status - Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0)); + Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0)); } [Test] -- cgit v1.1 From ae614c1264a2c4d06f019f2a91ad481cc2f96770 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:37:53 +0100 Subject: refactor: simplify DetachSingleAttachmentToGround() by retrieving the scene object group direct --- .../Avatar/Attachments/AttachmentsModule.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 732e3e3..42a18c5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -449,29 +449,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } - public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) + public void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient) { - SceneObjectPart part = m_scene.GetSceneObjectPart(itemID); - if (part == null || part.ParentGroup == null) + SceneObjectGroup so = m_scene.GetSceneObjectGroup(sceneObjectID); + + if (so == null) return; - if (part.ParentGroup.RootPart.AttachedAvatar != remoteClient.AgentId) + if (so.RootPart.AttachedAvatar != remoteClient.AgentId) return; - UUID inventoryID = part.ParentGroup.GetFromItemID(); + UUID inventoryID = so.GetFromItemID(); ScenePresence presence; if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) { if (!m_scene.Permissions.CanRezObject( - part.ParentGroup.PrimCount, remoteClient.AgentId, presence.AbsolutePosition)) + so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition)) return; - bool changed = presence.Appearance.DetachAttachment(itemID); + bool changed = presence.Appearance.DetachAttachment(sceneObjectID); if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - part.ParentGroup.DetachToGround(); + so.DetachToGround(); List uuids = new List(); uuids.Add(inventoryID); @@ -479,7 +480,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments remoteClient.SendRemoveInventoryItem(inventoryID); } - m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero); + m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero); } // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. -- cgit v1.1 From 5f3ffc195f60ac54492ccb389843f292b0be7511 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:49:11 +0100 Subject: refactor: move SOG.DetachToGround() to AttachmentsModule.DetachSceneObjectToGround() and remove redundant code --- .../Avatar/Attachments/AttachmentsModule.cs | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 42a18c5..93920b0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -472,7 +472,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - so.DetachToGround(); + presence.RemoveAttachment(so); + DetachSceneObjectToGround(so, presence); List uuids = new List(); uuids.Add(inventoryID); @@ -482,6 +483,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero); } + + /// + /// Detach the given scene objet to the ground. + /// + /// + /// The caller has to take care of all the other work in updating avatar appearance, inventory, etc. + /// + /// The scene object to detach. + /// The scene presence from which the scene object is being detached. + private void DetachSceneObjectToGround(SceneObjectGroup so, ScenePresence sp) + { + SceneObjectPart rootPart = so.RootPart; + + rootPart.FromItemID = UUID.Zero; + so.AbsolutePosition = sp.AbsolutePosition; + so.ForEachPart(part => part.AttachedAvatar = UUID.Zero); + rootPart.SetParentLocalId(0); + so.ClearPartAttachmentData(); + rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim); + so.HasGroupChanged = true; + rootPart.Rezzed = DateTime.Now; + rootPart.RemFlag(PrimFlags.TemporaryOnRez); + so.AttachToBackup(); + m_scene.EventManager.TriggerParcelPrimCountTainted(); + rootPart.ScheduleFullUpdate(); + rootPart.ClearUndoState(); + } // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? -- cgit v1.1 From 15a514fcbc8f7447fc3a5997b6bbc2fe35974c9a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 23:06:41 +0100 Subject: refactor: simplify SOP.AttachedAvatar into SOG.AttachedAvatar This does a tiny bit to reduce code complexity, memory requirement and the cpu time of pointlessly setting this field to the same value in every SOP --- .../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 93920b0..3e1cb02 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -456,7 +456,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (so == null) return; - if (so.RootPart.AttachedAvatar != remoteClient.AgentId) + if (so.AttachedAvatar != remoteClient.AgentId) return; UUID inventoryID = so.GetFromItemID(); @@ -498,7 +498,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments rootPart.FromItemID = UUID.Zero; so.AbsolutePosition = sp.AbsolutePosition; - so.ForEachPart(part => part.AttachedAvatar = UUID.Zero); + so.AttachedAvatar = UUID.Zero; rootPart.SetParentLocalId(0); so.ClearPartAttachmentData(); rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim); @@ -534,11 +534,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments sp.RemoveAttachment(group); // Prepare sog for storage + group.AttachedAvatar = UUID.Zero; + group.ForEachPart( delegate(SceneObjectPart part) { - part.AttachedAvatar = UUID.Zero; - // If there are any scripts, // then always trigger a new object and state persistence in UpdateKnownItem() if (part.Inventory.ContainsScripts()) @@ -656,12 +656,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_scene.DeleteFromStorage(so.UUID); m_scene.EventManager.TriggerParcelPrimCountTainted(); - so.RootPart.AttachedAvatar = avatar.UUID; - - //Anakin Lohner bug #3839 - SceneObjectPart[] parts = so.Parts; - for (int i = 0; i < parts.Length; i++) - parts[i].AttachedAvatar = avatar.UUID; + so.AttachedAvatar = avatar.UUID; if (so.RootPart.PhysActor != null) { -- cgit v1.1 From 33a894f3d2cc95a7a512b86f39f3c6a6afabb015 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 27 Aug 2011 00:15:21 +0100 Subject: refactor: move SOP.IsAttachment and AttachmentPoint up into SOG to avoid pointless duplication of identical values --- .../Avatar/Attachments/AttachmentsModule.cs | 13 ++++++------- .../Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 18 +++++++++--------- .../Framework/EntityTransfer/EntityTransferModule.cs | 2 +- .../Framework/InventoryAccess/InventoryAccessModule.cs | 2 +- 4 files changed, 17 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 3e1cb02..b976020 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -369,11 +369,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments SceneObjectGroup att, ScenePresence sp, UUID itemID, uint AttachmentPt) { // m_log.DebugFormat( -// "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} (item ID {2})", -// remoteClient.Name, att.Name, itemID); +// "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} {2} (item ID {3}) at {4}", +// sp.Name, att.Name, att.LocalId, itemID, AttachmentPt); if (!att.IsDeleted) - AttachmentPt = att.RootPart.AttachmentPoint; + AttachmentPt = att.AttachmentPoint; InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); item = m_scene.InventoryService.GetItem(item); @@ -547,7 +547,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments ); group.RootPart.SetParentLocalId(0); - group.RootPart.IsAttachment = false; + group.IsAttachment = false; group.AbsolutePosition = group.RootPart.AttachedPos; UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID); @@ -569,7 +569,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // Finally, we restore the object's attachment status. byte attachmentPoint = sog.GetAttachmentPoint(); sog.UpdateGroupPosition(pos); - sog.RootPart.IsAttachment = false; + sog.IsAttachment = false; sog.AbsolutePosition = sog.RootPart.AttachedPos; sog.SetAttachmentPoint(attachmentPoint); sog.HasGroupChanged = true; @@ -666,8 +666,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments so.AbsolutePosition = attachOffset; so.RootPart.AttachedPos = attachOffset; - so.RootPart.IsAttachment = true; - + so.IsAttachment = true; so.RootPart.SetParentLocalId(avatar.LocalId); so.SetAttachmentPoint(Convert.ToByte(attachmentpoint)); diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index b7d21fd..790a651 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -110,6 +110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); + Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); @@ -132,9 +133,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; - InventoryItemBase attItem - = UserInventoryHelpers.CreateInventoryItem( - scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); + UserInventoryHelpers.CreateInventoryItem( + scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); m_attMod.RezSingleAttachmentFromInventory( m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); @@ -145,6 +145,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); + Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); @@ -166,9 +167,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; - InventoryItemBase attItem - = UserInventoryHelpers.CreateInventoryItem( - scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); + UserInventoryHelpers.CreateInventoryItem( + scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); UUID attSoId = m_attMod.RezSingleAttachmentFromInventory( m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); @@ -198,9 +198,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; - InventoryItemBase attItem - = UserInventoryHelpers.CreateInventoryItem( - scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); + UserInventoryHelpers.CreateInventoryItem( + scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); m_attMod.RezSingleAttachmentFromInventory( m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); @@ -242,6 +241,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); + Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index f5d49c5..7963e53 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1782,7 +1782,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Set the parent localID to 0 so it transfers over properly. gobj.RootPart.SetParentLocalId(0); gobj.AbsolutePosition = gobj.RootPart.AttachedPos; - gobj.RootPart.IsAttachment = false; + gobj.IsAttachment = false; //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); CrossPrimGroupIntoNewRegion(destination, gobj, silent); diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 65ba87b..fcb7eea 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -841,7 +841,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (attachment) { group.RootPart.Flags |= PrimFlags.Phantom; - group.RootPart.IsAttachment = true; + group.IsAttachment = true; } // If we're rezzing an attachment then don't ask -- cgit v1.1 From b7700428ec298f29ae4cbb0e1090728fe3b93602 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 27 Aug 2011 00:20:15 +0100 Subject: refactor: camel case AttachmentPoint method arg as per code standards --- .../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index b976020..d9259b3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -363,22 +363,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// /// - /// + /// /// private UUID ShowAttachInUserInventory( - SceneObjectGroup att, ScenePresence sp, UUID itemID, uint AttachmentPt) + SceneObjectGroup att, ScenePresence sp, UUID itemID, uint attachmentPoint) { // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} {2} (item ID {3}) at {4}", // sp.Name, att.Name, att.LocalId, itemID, AttachmentPt); if (!att.IsDeleted) - AttachmentPt = att.AttachmentPoint; + attachmentPoint = att.AttachmentPoint; InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); item = m_scene.InventoryService.GetItem(item); - bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); + bool changed = sp.Appearance.SetAttachment((int)attachmentPoint, itemID, item.AssetID); if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); -- cgit v1.1 From 1615e7d29fb6961a3ffe791fde4318f819c1a4b7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 27 Aug 2011 00:33:24 +0100 Subject: Eliminate duplicate AttachmentPoint properties by always using the one stored in the root part's state field. --- .../Avatar/Attachments/AttachmentsModule.cs | 42 +++++++++++----------- .../Attachments/Tests/AttachmentsModuleTests.cs | 3 -- .../Region/CoreModules/World/Sound/SoundModule.cs | 4 +-- 3 files changed, 23 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index d9259b3..2d5eb18 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -167,13 +167,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return AttachObject(sp, group, AttachmentPt, silent); } - private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent) + private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent) { // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", // group.Name, group.LocalId, sp.Name, AttachmentPt, silent); - if (sp.GetAttachments(AttachmentPt).Contains(group)) + if (sp.GetAttachments(attachmentPt).Contains(group)) { // m_log.WarnFormat( // "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached", @@ -186,39 +186,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should // be removed when that functionality is implemented in opensim - AttachmentPt &= 0x7f; + attachmentPt &= 0x7f; // If the attachment point isn't the same as the one previously used // set it's offset position = 0 so that it appears on the attachment point // and not in a weird location somewhere unknown. - if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint()) + if (attachmentPt != 0 && attachmentPt != group.AttachmentPoint) { attachPos = Vector3.Zero; } // AttachmentPt 0 means the client chose to 'wear' the attachment. - if (AttachmentPt == 0) + if (attachmentPt == 0) { // Check object for stored attachment point - AttachmentPt = (uint)group.GetAttachmentPoint(); + attachmentPt = group.AttachmentPoint; } // if we still didn't find a suitable attachment point....... - if (AttachmentPt == 0) + if (attachmentPt == 0) { // Stick it on left hand with Zero Offset from the attachment point. - AttachmentPt = (uint)AttachmentPoint.LeftHand; + attachmentPt = (uint)AttachmentPoint.LeftHand; attachPos = Vector3.Zero; } - group.SetAttachmentPoint((byte)AttachmentPt); + group.AttachmentPoint = attachmentPt; group.AbsolutePosition = attachPos; // Remove any previous attachments UUID itemID = UUID.Zero; foreach (SceneObjectGroup grp in sp.Attachments) { - if (grp.GetAttachmentPoint() == (byte)AttachmentPt) + if (grp.AttachmentPoint == attachmentPt) { itemID = grp.GetFromItemID(); break; @@ -232,9 +232,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (itemID == UUID.Zero) itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID; - ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); + ShowAttachInUserInventory(sp, attachmentPt, itemID, group); - AttachToAgent(sp, group, AttachmentPt, attachPos, silent); + AttachToAgent(sp, group, attachmentPt, attachPos, silent); return true; } @@ -293,7 +293,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( - ScenePresence sp, UUID itemID, uint AttachmentPt) + ScenePresence sp, UUID itemID, uint attachmentPt) { IInventoryAccessModule invAccess = m_scene.RequestModuleInterface(); if (invAccess != null) @@ -313,13 +313,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // since scripts aren't running yet. So, clear it here. objatt.HasGroupChanged = false; bool tainted = false; - if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) + if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) tainted = true; // This will throw if the attachment fails try { - AttachObject(sp, objatt, AttachmentPt, false); + AttachObject(sp, objatt, attachmentPt, false); } catch (Exception e) { @@ -348,7 +348,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { m_log.WarnFormat( "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", - itemID, sp.Name, AttachmentPt); + itemID, sp.Name, attachmentPt); } return objatt; @@ -567,11 +567,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // attachment. This is necessary in order to correctly save // and retrieve GroupPosition information for the attachment. // Finally, we restore the object's attachment status. - byte attachmentPoint = sog.GetAttachmentPoint(); + uint attachmentPoint = sog.AttachmentPoint; sog.UpdateGroupPosition(pos); sog.IsAttachment = false; sog.AbsolutePosition = sog.RootPart.AttachedPos; - sog.SetAttachmentPoint(attachmentPoint); + sog.AttachmentPoint = attachmentPoint; sog.HasGroupChanged = true; } @@ -594,14 +594,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { m_log.DebugFormat( "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", - grp.UUID, grp.GetAttachmentPoint()); + grp.UUID, grp.AttachmentPoint); return; } m_log.DebugFormat( "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", - grp.UUID, grp.GetAttachmentPoint()); + grp.UUID, grp.AttachmentPoint); string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); @@ -668,7 +668,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments so.RootPart.AttachedPos = attachOffset; so.IsAttachment = true; so.RootPart.SetParentLocalId(avatar.LocalId); - so.SetAttachmentPoint(Convert.ToByte(attachmentpoint)); + so.AttachmentPoint = attachmentpoint; avatar.AddAttachment(so); diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 790a651..bb53601 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -111,7 +111,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); - Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); @@ -146,7 +145,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); - Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); @@ -242,7 +240,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); - Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index 09c0ebb..22ffcd6 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs @@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Sound if (grp.IsAttachment) { - if (grp.GetAttachmentPoint() > 30) // HUD + if (grp.AttachmentPoint > 30) // HUD { if (sp.ControllingClient.AgentId != grp.OwnerID) return; @@ -115,7 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Sound { SceneObjectGroup grp = part.ParentGroup; - if (grp.IsAttachment && grp.GetAttachmentPoint() > 30) + if (grp.IsAttachment && grp.AttachmentPoint > 30) { objectID = ownerID; parentID = ownerID; -- cgit v1.1 From be357f8feeb438e3292292d163918a307d69c69a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 30 Aug 2011 01:58:32 +0100 Subject: Fix bug in persisting saved appearances for npcs Assets have to be marked non-local as well as non-temporary to persist. This is now done. Hopefully addresses http://opensimulator.org/mantis/view.php?id=5660 --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 48 ++++++++++++++++---- .../Tests/AvatarFactoryModuleTests.cs | 51 ++++++++++++++++++++++ .../Asset/LocalAssetServiceConnector.cs | 25 ++++++++--- 3 files changed, 111 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 4627701..f34b6d2 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -257,20 +257,27 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory return true; } - public bool SaveBakedTextures(UUID agentId) + public Dictionary GetBakedTextureFaces(UUID agentId) { ScenePresence sp = m_scene.GetScenePresence(agentId); - if (sp == null || sp.IsChildAgent) - return false; + if (sp == null) + return new Dictionary(); + + return GetBakedTextureFaces(sp); + } + + private Dictionary GetBakedTextureFaces(ScenePresence sp) + { + if (sp.IsChildAgent) + return new Dictionary(); + + Dictionary bakedTextures + = new Dictionary(); AvatarAppearance appearance = sp.Appearance; Primitive.TextureEntryFace[] faceTextures = appearance.Texture.FaceTextures; - m_log.DebugFormat( - "[AV FACTORY]: Permanently saving baked textures for {0} in {1}", - sp.Name, m_scene.RegionInfo.RegionName); - foreach (int i in Enum.GetValues(typeof(BakeType))) { BakeType bakeType = (BakeType)i; @@ -283,7 +290,31 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); - Primitive.TextureEntryFace bakedTextureFace = faceTextures[ftIndex]; + bakedTextures[bakeType] = faceTextures[ftIndex]; + } + + return bakedTextures; + } + + public bool SaveBakedTextures(UUID agentId) + { + ScenePresence sp = m_scene.GetScenePresence(agentId); + + if (sp == null) + return false; + + m_log.DebugFormat( + "[AV FACTORY]: Permanently saving baked textures for {0} in {1}", + sp.Name, m_scene.RegionInfo.RegionName); + + Dictionary bakedTextures = GetBakedTextureFaces(sp); + + if (bakedTextures.Count == 0) + return false; + + foreach (BakeType bakeType in bakedTextures.Keys) + { + Primitive.TextureEntryFace bakedTextureFace = bakedTextures[bakeType]; if (bakedTextureFace == null) { @@ -299,6 +330,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory if (asset != null) { asset.Temporary = false; + asset.Local = false; m_scene.AssetService.Store(asset); } else diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index b831b31..7b2f14e 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs @@ -26,9 +26,12 @@ */ using System; +using System.Collections.Generic; +using Nini.Config; using NUnit.Framework; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Region.CoreModules.Asset; using OpenSim.Region.Framework.Scenes; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; @@ -65,5 +68,53 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // TODO: Check baked texture Assert.AreEqual(visualParams, sp.Appearance.VisualParams); } + + [Test] + public void TestSaveBakedTextures() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID userId = TestHelpers.ParseTail(0x1); + UUID eyesTextureId = TestHelpers.ParseTail(0x2); + + // We need an asset cache because otherwise the LocalAssetServiceConnector will short-circuit directly + // to the AssetService, which will then store temporary and local assets permanently + CoreAssetCache assetCache = new CoreAssetCache(); + + AvatarFactoryModule afm = new AvatarFactoryModule(); + TestScene scene = SceneHelpers.SetupScene(assetCache); + SceneHelpers.SetupSceneModules(scene, afm); + IClientAPI tc = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; + + // TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules + AssetBase uploadedAsset; + uploadedAsset = new AssetBase(eyesTextureId, "Baked Texture", (sbyte)AssetType.Texture, userId.ToString()); + uploadedAsset.Data = new byte[] { 2 }; + uploadedAsset.Temporary = true; + uploadedAsset.Local = true; // Local assets aren't persisted, non-local are + scene.AssetService.Store(uploadedAsset); + + byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT]; + for (byte i = 0; i < visualParams.Length; i++) + visualParams[i] = i; + + Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)); + uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes); + Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); + eyesFace.TextureID = eyesTextureId; + + afm.SetAppearanceFromClient(tc, bakedTextureEntry, visualParams); + afm.SaveBakedTextures(userId); +// Dictionary bakedTextures = afm.GetBakedTextureFaces(userId); + + // We should also inpsect the asset data store layer directly, but this is difficult to get at right now. + assetCache.Clear(); + + AssetBase eyesBake = scene.AssetService.Get(eyesTextureId.ToString()); + Assert.That(eyesBake, Is.Not.Null); + Assert.That(eyesBake.Temporary, Is.False); + Assert.That(eyesBake.Local, Is.False); + } } } \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index 51d1d59..cc5d061 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs @@ -129,15 +129,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset m_Cache = null; } - m_log.InfoFormat("[LOCAL ASSET SERVICES CONNECTOR]: Enabled local assets for region {0}", scene.RegionInfo.RegionName); + m_log.DebugFormat( + "[LOCAL ASSET SERVICES CONNECTOR]: Enabled connector for region {0}", scene.RegionInfo.RegionName); if (m_Cache != null) { - m_log.InfoFormat("[LOCAL ASSET SERVICES CONNECTOR]: Enabled asset caching for region {0}", scene.RegionInfo.RegionName); + m_log.DebugFormat( + "[LOCAL ASSET SERVICES CONNECTOR]: Enabled asset caching for region {0}", + scene.RegionInfo.RegionName); } else { - // Short-circuit directly to storage layer + // Short-circuit directly to storage layer. This ends up storing temporary and local assets. // scene.UnregisterModuleInterface(this); scene.RegisterModuleInterface(m_AssetService); @@ -246,9 +249,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset m_Cache.Cache(asset); if (asset.Temporary || asset.Local) + { +// m_log.DebugFormat( +// "[LOCAL ASSET SERVICE CONNECTOR]: Returning asset {0} {1} without querying database since status Temporary = {2}, Local = {3}", +// asset.Name, asset.ID, asset.Temporary, asset.Local); + return asset.ID; - - return m_AssetService.Store(asset); + } + else + { +// m_log.DebugFormat( +// "[LOCAL ASSET SERVICE CONNECTOR]: Passing {0} {1} on to asset service for storage, status Temporary = {2}, Local = {3}", +// asset.Name, asset.ID, asset.Temporary, asset.Local); + + return m_AssetService.Store(asset); + } } public bool UpdateContent(string id, byte[] data) -- cgit v1.1 From e7a515bab0e46c228f8f543397f97b7ba2f0df3c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 30 Aug 2011 22:06:24 +0100 Subject: Fix bug where attachments were remaining on the avatar after being dropped. If the inventory service is configured not to allow deletion then these will not disappear from inventory --- .../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 12 ++++++++++-- .../Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 14 ++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2d5eb18..b7a7f77 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -451,6 +451,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments public void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient) { +// m_log.DebugFormat( +// "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}", +// remoteClient.Name, sceneObjectID); + SceneObjectGroup so = m_scene.GetSceneObjectGroup(sceneObjectID); if (so == null) @@ -461,6 +465,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments UUID inventoryID = so.GetFromItemID(); +// m_log.DebugFormat( +// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}", +// so.Name, so.LocalId, inventoryID); + ScenePresence presence; if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) { @@ -468,7 +476,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition)) return; - bool changed = presence.Appearance.DetachAttachment(sceneObjectID); + bool changed = presence.Appearance.DetachAttachment(inventoryID); if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); @@ -485,7 +493,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } /// - /// Detach the given scene objet to the ground. + /// Detach the given scene object to the ground. /// /// /// The caller has to take care of all the other work in updating avatar appearance, inventory, etc. diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index bb53601..b1f9197 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -138,7 +138,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests m_attMod.RezSingleAttachmentFromInventory( m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); - // Check status on scene presence + // Check scene presence status Assert.That(m_presence.HasAttachments(), Is.True); List attachments = m_presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(1)); @@ -149,12 +149,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); - // Check item status + // Check appearance status Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); } [Test] - public void TestDetachAttachmentToScene() + public void TestDetachAttachmentToGround() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); @@ -168,15 +168,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests UserInventoryHelpers.CreateInventoryItem( scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); +// Check item status + Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Not.Null); + UUID attSoId = m_attMod.RezSingleAttachmentFromInventory( m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); m_attMod.DetachSingleAttachmentToGround(attSoId, m_presence.ControllingClient); - // Check status on scene presence + // Check scene presence status Assert.That(m_presence.HasAttachments(), Is.False); List attachments = m_presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(0)); + // Check appearance status + Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(0)); + // Check item status Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Null); -- cgit v1.1 From 1de68b34d959570c6dc5de42e8dac5e36f960273 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 30 Aug 2011 22:25:38 +0100 Subject: refactor: migrate DropObject handling fully into AttachmentsModule from Scene --- .../Avatar/Attachments/AttachmentsModule.cs | 21 ++++++++++----------- .../Attachments/Tests/AttachmentsModuleTests.cs | 7 ++----- 2 files changed, 12 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index b7a7f77..02fd387 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -46,7 +46,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private Scene m_scene = null; + private Scene m_scene; private IDialogModule m_dialogModule; public string Name { get { return "Attachments Module"; } } @@ -83,6 +83,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments client.OnObjectAttach += AttachObject; client.OnObjectDetach += DetachObject; client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; + client.OnObjectDrop += DetachSingleAttachmentToGround; } public void UnsubscribeFromClientEvents(IClientAPI client) @@ -92,6 +93,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments client.OnObjectAttach -= AttachObject; client.OnObjectDetach -= DetachObject; client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; + client.OnObjectDrop -= DetachSingleAttachmentToGround; } /// @@ -250,12 +252,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } - public UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) + public ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) { return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true); } - public UUID RezSingleAttachmentFromInventory( + public ISceneEntity RezSingleAttachmentFromInventory( IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus) { // m_log.DebugFormat( @@ -269,7 +271,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_log.ErrorFormat( "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezSingleAttachmentFromInventory()", remoteClient.Name, remoteClient.AgentId); - return UUID.Zero; + return null; } // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should @@ -286,10 +288,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments ShowAttachInUserInventory(att, sp, itemID, AttachmentPt); } - if (null == att) - return UUID.Zero; - else - return att.UUID; + return att; } private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( @@ -449,13 +448,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } - public void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient) + public void DetachSingleAttachmentToGround(uint soLocalId, IClientAPI remoteClient) { // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}", // remoteClient.Name, sceneObjectID); - SceneObjectGroup so = m_scene.GetSceneObjectGroup(sceneObjectID); + SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId); if (so == null) return; @@ -489,7 +488,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments remoteClient.SendRemoveInventoryItem(inventoryID); } - m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero); + m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero); } /// diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index b1f9197..b0146a1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -168,12 +168,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests UserInventoryHelpers.CreateInventoryItem( scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); -// Check item status - Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Not.Null); - - UUID attSoId = m_attMod.RezSingleAttachmentFromInventory( + ISceneEntity so = m_attMod.RezSingleAttachmentFromInventory( m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); - m_attMod.DetachSingleAttachmentToGround(attSoId, m_presence.ControllingClient); + m_attMod.DetachSingleAttachmentToGround(so.LocalId, m_presence.ControllingClient); // Check scene presence status Assert.That(m_presence.HasAttachments(), Is.False); -- cgit v1.1 From 04bafd21221a789b83b039efd1c52e141944cde0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 30 Aug 2011 23:05:43 +0100 Subject: refactor: Move ScenePresence.RezAttachments() into AttachmentsModule This adds an incomplete IScenePresence to match ISceneEntity --- .../Avatar/Attachments/AttachmentsModule.cs | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 02fd387..f6aea89 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -95,6 +95,44 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; client.OnObjectDrop -= DetachSingleAttachmentToGround; } + + /// + /// RezAttachments. This should only be called upon login on the first region. + /// Attachment rezzings on crossings and TPs are done in a different way. + /// + public void RezAttachments(IScenePresence sp) + { + if (null == sp.Appearance) + { + m_log.WarnFormat("[ATTACHMENTS MODULE]: Appearance has not been initialized for agent {0}", sp.UUID); + return; + } + + List attachments = sp.Appearance.GetAttachments(); + foreach (AvatarAttachment attach in attachments) + { + int p = attach.AttachPoint; + UUID itemID = attach.ItemID; + + //UUID assetID = attach.AssetID; + // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down + // But they're not used anyway, the item is being looked up for now, so let's proceed. + //if (UUID.Zero == assetID) + //{ + // m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID); + // continue; + //} + + try + { + RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, (uint)p); + } + catch (Exception e) + { + m_log.ErrorFormat("[ATTACHMENTS MODULE]: Unable to rez attachment: {0}{1}", e.Message, e.StackTrace); + } + } + } /// /// Called by client -- cgit v1.1 From ddc733cd3d940a4357eb0d235562050eb6f206bf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 30 Aug 2011 23:32:30 +0100 Subject: refactor: move SP.SaveChangedAttachments() fully into AttachmentsModule --- .../Avatar/Attachments/AttachmentsModule.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index f6aea89..201ce7f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -133,6 +133,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } } + + public void SaveChangedAttachments(IScenePresence sp) + { + // Need to copy this list because DetachToInventoryPrep mods it + List attachments = new List(sp.Attachments.ToArray()); + + foreach (SceneObjectGroup grp in attachments) + { + if (grp.HasGroupChanged) // Resizer scripts? + { + grp.IsAttachment = false; + grp.AbsolutePosition = grp.RootPart.AttachedPos; +// grp.DetachToInventoryPrep(); + UpdateKnownItem(sp.ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID); + grp.IsAttachment = true; + } + } + } /// /// Called by client -- cgit v1.1 From 1809aaf74c3594ec40df8688a2dcc42074ddeec4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 30 Aug 2011 23:36:45 +0100 Subject: minor: remove already processed avatar null check in Scene.RemoveClient() remove some now duplicated method doc --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 201ce7f..e2f6a9e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -145,7 +145,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { grp.IsAttachment = false; grp.AbsolutePosition = grp.RootPart.AttachedPos; -// grp.DetachToInventoryPrep(); UpdateKnownItem(sp.ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID); grp.IsAttachment = true; } -- cgit v1.1 From 2acfff9f6d340984bbc51c4d18c2babe2e3cb6ca Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 30 Aug 2011 23:39:26 +0100 Subject: remove pointless ToArray() call in AttachmentsModule.SaveChangedAttachments() --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index e2f6a9e..f4bc495 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -137,7 +137,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments public void SaveChangedAttachments(IScenePresence sp) { // Need to copy this list because DetachToInventoryPrep mods it - List attachments = new List(sp.Attachments.ToArray()); + List attachments = new List(sp.Attachments); foreach (SceneObjectGroup grp in attachments) { -- cgit v1.1 From 32444d98cb13423fdf8c874e4fbb7ea17670d7c5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 31 Aug 2011 16:29:51 +0100 Subject: Make SP.Attachments available as sp.GetAttachments() instead. The approach here, as in other parts of OpenSim, is to return a copy of the list rather than the attachments list itself This prevents callers from forgetting to lock the list when they read it, as was happening in various parts of the codebase. It also improves liveness. This might improve attachment anomolies when performing region crossings. --- .../Avatar/Attachments/AttachmentsModule.cs | 19 +++---- .../Attachments/Tests/AttachmentsModuleTests.cs | 10 ++-- .../EntityTransfer/EntityTransferModule.cs | 61 ++++++++++++---------- .../Scripting/WorldComm/WorldCommModule.cs | 12 +++-- 4 files changed, 52 insertions(+), 50 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index f4bc495..9e5ce8f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -136,10 +136,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments public void SaveChangedAttachments(IScenePresence sp) { - // Need to copy this list because DetachToInventoryPrep mods it - List attachments = new List(sp.Attachments); - - foreach (SceneObjectGroup grp in attachments) + foreach (SceneObjectGroup grp in sp.GetAttachments()) { if (grp.HasGroupChanged) // Resizer scripts? { @@ -273,14 +270,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // Remove any previous attachments UUID itemID = UUID.Zero; - foreach (SceneObjectGroup grp in sp.Attachments) - { - if (grp.AttachmentPoint == attachmentPt) - { - itemID = grp.GetFromItemID(); - break; - } - } + + List attachments = sp.GetAttachments(attachmentPt); + + // At the moment we can only deal with a single attachment + if (attachments.Count != 0) + itemID = attachments[0].GetFromItemID(); if (itemID != UUID.Zero) DetachSingleAttachmentToInv(itemID, sp); diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index b0146a1..363e258 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // Check status on scene presence Assert.That(m_presence.HasAttachments(), Is.True); - List attachments = m_presence.Attachments; + List attachments = m_presence.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); @@ -140,7 +140,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // Check scene presence status Assert.That(m_presence.HasAttachments(), Is.True); - List attachments = m_presence.Attachments; + List attachments = m_presence.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); @@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // Check scene presence status Assert.That(m_presence.HasAttachments(), Is.False); - List attachments = m_presence.Attachments; + List attachments = m_presence.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(0)); // Check appearance status @@ -208,7 +208,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // Check status on scene presence Assert.That(m_presence.HasAttachments(), Is.False); - List attachments = m_presence.Attachments; + List attachments = m_presence.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(0)); // Check item status @@ -237,7 +237,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); Assert.That(presence.HasAttachments(), Is.True); - List attachments = presence.Attachments; + List attachments = presence.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 7963e53..c24cc17 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -208,7 +208,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); sp.Teleport(position); - foreach (SceneObjectGroup grp in sp.Attachments) + foreach (SceneObjectGroup grp in sp.GetAttachments()) sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT); } else // Another region possibly in another simulator @@ -559,11 +559,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) { - foreach (SceneObjectGroup sop in sp.Attachments) + foreach (SceneObjectGroup sop in sp.GetAttachments()) { sop.Scene.DeleteSceneObject(sop, true); } - sp.Attachments.Clear(); + sp.ClearAttachments(); } protected void KillEntity(Scene scene, uint localID) @@ -1764,34 +1764,33 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected bool CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent) { - List m_attachments = sp.Attachments; - lock (m_attachments) + List m_attachments = sp.GetAttachments(); + + // Validate + foreach (SceneObjectGroup gobj in m_attachments) { - // Validate - foreach (SceneObjectGroup gobj in m_attachments) - { - if (gobj == null || gobj.IsDeleted) - return false; - } + if (gobj == null || gobj.IsDeleted) + return false; + } - foreach (SceneObjectGroup gobj in m_attachments) + foreach (SceneObjectGroup gobj in m_attachments) + { + // If the prim group is null then something must have happened to it! + if (gobj != null && gobj.RootPart != null) { - // If the prim group is null then something must have happened to it! - if (gobj != null && gobj.RootPart != null) - { - // Set the parent localID to 0 so it transfers over properly. - gobj.RootPart.SetParentLocalId(0); - gobj.AbsolutePosition = gobj.RootPart.AttachedPos; - gobj.IsAttachment = false; - //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); - m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); - CrossPrimGroupIntoNewRegion(destination, gobj, silent); - } + // Set the parent localID to 0 so it transfers over properly. + gobj.RootPart.SetParentLocalId(0); + gobj.AbsolutePosition = gobj.RootPart.AttachedPos; + gobj.IsAttachment = false; + //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); + CrossPrimGroupIntoNewRegion(destination, gobj, silent); } - m_attachments.Clear(); - - return true; } + + sp.ClearAttachments(); + + return true; } #endregion @@ -1840,7 +1839,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer int i = 0; if (sp.InTransitScriptStates.Count > 0) { - sp.Attachments.ForEach(delegate(SceneObjectGroup sog) + List attachments = sp.GetAttachments(); + + foreach (SceneObjectGroup sog in attachments) { if (i < sp.InTransitScriptStates.Count) { @@ -1849,8 +1850,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sog.ResumeScripts(); } else - m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: InTransitScriptStates.Count={0} smaller than Attachments.Count={1}", sp.InTransitScriptStates.Count, sp.Attachments.Count); - }); + m_log.ErrorFormat( + "[ENTITY TRANSFER MODULE]: InTransitScriptStates.Count={0} smaller than Attachments.Count={1}", + sp.InTransitScriptStates.Count, attachments.Count); + } sp.InTransitScriptStates.Clear(); } diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 22352f5..057500c 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -283,7 +283,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm } /// - /// Delivers the message to. + /// Delivers the message to a scene entity. /// /// /// Target. @@ -314,17 +314,19 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Owner, 0, pos, name, id, false); } - List attachments = sp.Attachments; + List attachments = sp.GetAttachments(); + // Nothing left to do if (attachments == null) return true; // Get uuid of attachments List targets = new List(); - foreach ( SceneObjectGroup sog in attachments ) + foreach (SceneObjectGroup sog in attachments) { targets.Add(sog.UUID); } + // Need to check each attachment foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { @@ -334,9 +336,10 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) continue; - if ( targets.Contains(li.GetHostID())) + if (targets.Contains(li.GetHostID())) QueueMessage(new ListenerInfo(li, name, id, msg)); } + return true; } @@ -363,6 +366,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm break; } } + return true; } -- cgit v1.1 From 5a5206449f575fa4c6e161aea7202b7b8f628b4a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 31 Aug 2011 16:41:58 +0100 Subject: minor: seal up another instance of using the appearance list without locking --- OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 057500c..f25699b 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -366,7 +366,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm break; } } - + return true; } -- cgit v1.1 From 8c703022c14c55df6e862c6462ec8c7c39917296 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 31 Aug 2011 16:50:18 +0100 Subject: In WorldCommModule, replace the useless Attachments == null check with Attachments.Count == 0 instead --- OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index f25699b..b20a875 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -316,8 +316,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm List attachments = sp.GetAttachments(); - // Nothing left to do - if (attachments == null) + if (attachments.Count == 0) return true; // Get uuid of attachments -- cgit v1.1 From e69f246b861c824149d8b4e7cc4ff7899d5318db Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 31 Aug 2011 17:25:18 +0100 Subject: refactor: move multiple class to set avatar height into associated SP.AddToPhysicalScene() --- OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index f34b6d2..b6a1564 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -214,7 +214,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory changed = sp.Appearance.SetVisualParams(visualParams); if (sp.Appearance.AvatarHeight > 0) sp.SetHeight(sp.Appearance.AvatarHeight); - } + } // Process the baked texture array if (textureEntry != null) -- cgit v1.1 From 7d58b5fa157b4c3e842573d9fb02a9822034f4b0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 31 Aug 2011 17:53:58 +0100 Subject: move common code into AttachmentsModule.DeleteAttachmentsFromScene() --- .../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 10 ++++++++++ .../Framework/EntityTransfer/EntityTransferModule.cs | 6 +----- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 9e5ce8f..587f35e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -147,6 +147,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } } + + public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent) + { + foreach (SceneObjectGroup sop in sp.GetAttachments()) + { + sop.Scene.DeleteSceneObject(sop, silent); + } + + sp.ClearAttachments(); + } /// /// Called by client diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index c24cc17..82bdf20 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -559,11 +559,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) { - foreach (SceneObjectGroup sop in sp.GetAttachments()) - { - sop.Scene.DeleteSceneObject(sop, true); - } - sp.ClearAttachments(); + sp.Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, true); } protected void KillEntity(Scene scene, uint localID) -- cgit v1.1 From ca9a054bba03e58053b4000ec77a6ce6ea492ec6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 31 Aug 2011 18:03:07 +0100 Subject: Don't set a GridUser entry for NPCs. Resolves http://opensimulator.org/mantis/view.php?id=5665 --- .../CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs index d6063ad..4cf62ec 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs @@ -66,7 +66,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser public void OnMakeRootAgent(ScenePresence sp) { // m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); - m_GridUserService.SetLastPosition(sp.UUID.ToString(), UUID.Zero, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); + + if (sp.PresenceType != PresenceType.Npc) + m_GridUserService.SetLastPosition( + sp.UUID.ToString(), UUID.Zero, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); } public void OnNewClient(IClientAPI client) -- cgit v1.1 From 095b3e5756bb3160b30c9c5670ba008fa13d2e66 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 01:22:28 +0100 Subject: Remove pointless cluttering SOP.ParentGroup != null checks. The only times when ParentGroup might be null is during regression tests (which might not be a valid thing) and when scene objects are being constructed from the database. At all other times it's not possible for a SOP not to have a SOG parent. --- .../World/Estate/EstateManagementModule.cs | 50 ++++++++++------------ .../World/Objects/BuySell/BuySellModule.cs | 5 +-- .../World/Permissions/PermissionsModule.cs | 2 +- 3 files changed, 24 insertions(+), 33 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 3aed6ba..d0605e3 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -851,41 +851,35 @@ namespace OpenSim.Region.CoreModules.World.Estate SceneObjectPart prt = Scene.GetSceneObjectPart(obj); if (prt != null) { - if (prt.ParentGroup != null) + SceneObjectGroup sog = prt.ParentGroup; + LandStatReportItem lsri = new LandStatReportItem(); + lsri.LocationX = sog.AbsolutePosition.X; + lsri.LocationY = sog.AbsolutePosition.Y; + lsri.LocationZ = sog.AbsolutePosition.Z; + lsri.Score = SceneData[obj]; + lsri.TaskID = sog.UUID; + lsri.TaskLocalID = sog.LocalId; + lsri.TaskName = sog.GetPartName(obj); + lsri.OwnerName = "waiting"; + lock (uuidNameLookupList) + uuidNameLookupList.Add(sog.OwnerID); + + if (filter.Length != 0) { - SceneObjectGroup sog = prt.ParentGroup; - if (sog != null) + if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter))) { - LandStatReportItem lsri = new LandStatReportItem(); - lsri.LocationX = sog.AbsolutePosition.X; - lsri.LocationY = sog.AbsolutePosition.Y; - lsri.LocationZ = sog.AbsolutePosition.Z; - lsri.Score = SceneData[obj]; - lsri.TaskID = sog.UUID; - lsri.TaskLocalID = sog.LocalId; - lsri.TaskName = sog.GetPartName(obj); - lsri.OwnerName = "waiting"; - lock (uuidNameLookupList) - uuidNameLookupList.Add(sog.OwnerID); - - if (filter.Length != 0) - { - if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter))) - { - } - else - { - continue; - } - } - - SceneReport.Add(lsri); + } + else + { + continue; } } - } + SceneReport.Add(lsri); + } } } + remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray()); if (uuidNameLookupList.Count > 0) diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs index be399ff..8b78701 100644 --- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs @@ -85,7 +85,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell IClientAPI client, UUID agentID, UUID sessionID, uint localID, byte saleType, int salePrice) { SceneObjectPart part = m_scene.GetSceneObjectPart(localID); - if (part == null || part.ParentGroup == null) + if (part == null) return; if (part.ParentGroup.IsDeleted) @@ -111,9 +111,6 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell if (part == null) return false; - if (part.ParentGroup == null) - return false; - SceneObjectGroup group = part.ParentGroup; switch (saleType) diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 7cb3751..b9bd9a4 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -1131,7 +1131,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions SceneObjectPart part = scene.GetSceneObjectPart(objectID); if (part.OwnerID != moverID) { - if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) + if (!part.ParentGroup.IsDeleted) { if (part.ParentGroup.IsAttachment) return false; -- cgit v1.1 From 7eca929686bd2db1cb42f5c9740fd1d186cdc8b1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 02:09:41 +0100 Subject: Eliminate pointless checks of SOG.RootPart != null It's never possible for SOG to have no RootPart, except in the first few picosends of the big bang when it's pulled from region persistence or deserialized --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 6 ------ .../CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 587f35e..ffe76a8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -470,12 +470,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return; } - if (null == att.RootPart) - { - m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment for a prim without the rootpart!"); - return; - } - InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); item = m_scene.InventoryService.GetItem(item); bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 82bdf20..766656c 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1772,7 +1772,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer foreach (SceneObjectGroup gobj in m_attachments) { // If the prim group is null then something must have happened to it! - if (gobj != null && gobj.RootPart != null) + if (gobj != null) { // Set the parent localID to 0 so it transfers over properly. gobj.RootPart.SetParentLocalId(0); -- cgit v1.1 From 616e672fce793350071bff538db4a8dc033f6259 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 02:43:17 +0100 Subject: If the user receiving an inventory folder has left the scene by the time the acceptence message arrives, then don't send them an inventory update. Doing so causes a NullReferenceException --- .../Avatar/Inventory/Transfer/InventoryTransferModule.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index b4f69e6..f46d9f7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -208,9 +208,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length); if (user != null) - { user.ControllingClient.SendBulkUpdateInventory(folderCopy); - } // HACK!! im.imSessionID = folderID.Guid; @@ -240,9 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16); if (user != null) - { user.ControllingClient.SendBulkUpdateInventory(itemCopy); - } // HACK!! im.imSessionID = itemID.Guid; @@ -288,7 +284,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); - fromUser.ControllingClient.SendBulkUpdateInventory(folder); + // If the user has left the scene by the time the message comes back then we can't send + // them the update. + if (fromUser != null) + fromUser.ControllingClient.SendBulkUpdateInventory(folder); }); } } -- cgit v1.1 From 1bf29d60e1a6839a1b81e0afc656a97f252e13cc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 22:05:05 +0100 Subject: Remove code which was automatically deleting non-root prims from scene objects that had previous been attachments. Looks like this code was accidentally uncommented in e1b5c612 from feb 2010. Appears to resolve the rest of http://opensimulator.org/mantis/view.php?id=5664 --- .../CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index fcb7eea..1a591ee 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -946,6 +946,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess rootPart.ScheduleFullUpdate(); } + +// m_log.DebugFormat( +// "[InventoryAccessModule]: Rezzed {0} {1} {2} for {3}", +// group.Name, group.LocalId, group.UUID, remoteClient.Name); } if (!m_Scene.Permissions.BypassPermissions()) -- cgit v1.1 From 8b83c4a4331e759b83112a4e04558ed961ff891a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 23:06:57 +0100 Subject: Remove pointless NRE check in IAM.RezObject() since this can never occur --- .../Framework/InventoryAccess/InventoryAccessModule.cs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 1a591ee..76a1cd0 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -865,21 +865,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess group.SetFromItemID(itemID); } - SceneObjectPart rootPart = null; - - try - { - rootPart = group.GetChildPart(group.UUID); - } - catch (NullReferenceException) - { - string isAttachment = ""; - - if (attachment) - isAttachment = " Object was an attachment"; - - m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); - } + SceneObjectPart rootPart = group.GetChildPart(group.UUID); // Since renaming the item in the inventory does not // affect the name stored in the serialization, transfer -- cgit v1.1 From e30651b9315c121d57d8c4077cf6bdfccb83aa68 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 23:09:14 +0100 Subject: use group.RootPart in IAM.RezObject() rather than group.GetChildPart(group.UUID); --- .../CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 76a1cd0..e0ff5a8 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -865,7 +865,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess group.SetFromItemID(itemID); } - SceneObjectPart rootPart = group.GetChildPart(group.UUID); + SceneObjectPart rootPart = group.RootPart; // Since renaming the item in the inventory does not // affect the name stored in the serialization, transfer -- cgit v1.1 From 712d44635a0f4552fbac4c6423ab88e027cef8a2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 23:14:50 +0100 Subject: refactor: Move sanity checks to the top of IAM.RezObject() to make the code more readable --- .../InventoryAccess/InventoryAccessModule.cs | 434 ++++++++++----------- 1 file changed, 215 insertions(+), 219 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index e0ff5a8..5778dff 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -700,276 +700,272 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess RayStart, RayEnd, RayTargetID, Quaternion.Identity, BypassRayCast, bRayEndIsIntersection, true, scale, false); - // Rez object InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = m_Scene.InventoryService.GetItem(item); - if (item != null) + if (item == null) { - item.Owner = remoteClient.AgentId; + m_log.WarnFormat( + "[InventoryAccessModule]: Could not find item {0} for {1} in RezObject()", + itemID, remoteClient.Name); - AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); + return null; + } - SceneObjectGroup group = null; + item.Owner = remoteClient.AgentId; + AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); - if (rezAsset != null) - { - UUID itemId = UUID.Zero; + if (rezAsset == null) + { + m_log.WarnFormat( + "[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()", + item.AssetID, item.Name, item.ID, remoteClient.Name); - // If we have permission to copy then link the rezzed object back to the user inventory - // item that it came from. This allows us to enable 'save object to inventory' - if (!m_Scene.Permissions.BypassPermissions()) - { - if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) - { - itemId = item.ID; - } - } - else - { - if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) - { - // Brave new fullperm world - itemId = item.ID; - } - } + return null; + } - string xmlData = Utils.BytesToString(rezAsset.Data); - List objlist = - new List(); - List veclist = new List(); + SceneObjectGroup group = null; + UUID itemId = UUID.Zero; - XmlDocument doc = new XmlDocument(); - doc.LoadXml(xmlData); - XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject"); - if (e == null || attachment) // Single - { - SceneObjectGroup g = - SceneObjectSerializer.FromOriginalXmlFormat( - itemId, xmlData); - objlist.Add(g); - veclist.Add(new Vector3(0, 0, 0)); - - float offsetHeight = 0; - pos = m_Scene.GetNewRezLocation( - RayStart, RayEnd, RayTargetID, Quaternion.Identity, - BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false); - pos.Z += offsetHeight; - } - else - { - XmlElement coll = (XmlElement)e; - float bx = Convert.ToSingle(coll.GetAttribute("x")); - float by = Convert.ToSingle(coll.GetAttribute("y")); - float bz = Convert.ToSingle(coll.GetAttribute("z")); - Vector3 bbox = new Vector3(bx, by, bz); + // If we have permission to copy then link the rezzed object back to the user inventory + // item that it came from. This allows us to enable 'save object to inventory' + if (!m_Scene.Permissions.BypassPermissions()) + { + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) + { + itemId = item.ID; + } + } + else + { + if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) + { + // Brave new fullperm world + itemId = item.ID; + } + } + + string xmlData = Utils.BytesToString(rezAsset.Data); + List objlist = + new List(); + List veclist = new List(); - pos = m_Scene.GetNewRezLocation(RayStart, RayEnd, - RayTargetID, Quaternion.Identity, - BypassRayCast, bRayEndIsIntersection, true, - bbox, false); + XmlDocument doc = new XmlDocument(); + doc.LoadXml(xmlData); + XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject"); + if (e == null || attachment) // Single + { + SceneObjectGroup g = + SceneObjectSerializer.FromOriginalXmlFormat( + itemId, xmlData); + objlist.Add(g); + veclist.Add(new Vector3(0, 0, 0)); + + float offsetHeight = 0; + pos = m_Scene.GetNewRezLocation( + RayStart, RayEnd, RayTargetID, Quaternion.Identity, + BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false); + pos.Z += offsetHeight; + } + else + { + XmlElement coll = (XmlElement)e; + float bx = Convert.ToSingle(coll.GetAttribute("x")); + float by = Convert.ToSingle(coll.GetAttribute("y")); + float bz = Convert.ToSingle(coll.GetAttribute("z")); + Vector3 bbox = new Vector3(bx, by, bz); - pos -= bbox / 2; + pos = m_Scene.GetNewRezLocation(RayStart, RayEnd, + RayTargetID, Quaternion.Identity, + BypassRayCast, bRayEndIsIntersection, true, + bbox, false); - XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); - foreach (XmlNode n in groups) - { - SceneObjectGroup g = - SceneObjectSerializer.FromOriginalXmlFormat( - itemId, n.OuterXml); - objlist.Add(g); - XmlElement el = (XmlElement)n; - - string rawX = el.GetAttribute("offsetx"); - string rawY = el.GetAttribute("offsety"); - string rawZ = el.GetAttribute("offsetz"); + pos -= bbox / 2; + + XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); + foreach (XmlNode n in groups) + { + SceneObjectGroup g = + SceneObjectSerializer.FromOriginalXmlFormat( + itemId, n.OuterXml); + objlist.Add(g); + XmlElement el = (XmlElement)n; + + string rawX = el.GetAttribute("offsetx"); + string rawY = el.GetAttribute("offsety"); + string rawZ = el.GetAttribute("offsetz"); // // m_log.DebugFormat( // "[INVENTORY ACCESS MODULE]: Converting coalesced object {0} offset <{1}, {2}, {3}>", // g.Name, rawX, rawY, rawZ); - - float x = Convert.ToSingle(rawX); - float y = Convert.ToSingle(rawY); - float z = Convert.ToSingle(rawZ); - veclist.Add(new Vector3(x, y, z)); - } - } - int primcount = 0; - foreach (SceneObjectGroup g in objlist) - primcount += g.PrimCount; + float x = Convert.ToSingle(rawX); + float y = Convert.ToSingle(rawY); + float z = Convert.ToSingle(rawZ); + veclist.Add(new Vector3(x, y, z)); + } + } - if (!m_Scene.Permissions.CanRezObject( - primcount, remoteClient.AgentId, pos) - && !attachment) - { - // The client operates in no fail mode. It will - // have already removed the item from the folder - // if it's no copy. - // Put it back if it's not an attachment - // - if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) - remoteClient.SendBulkUpdateInventory(item); + int primcount = 0; + foreach (SceneObjectGroup g in objlist) + primcount += g.PrimCount; - return null; - } + if (!m_Scene.Permissions.CanRezObject( + primcount, remoteClient.AgentId, pos) + && !attachment) + { + // The client operates in no fail mode. It will + // have already removed the item from the folder + // if it's no copy. + // Put it back if it's not an attachment + // + if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) + remoteClient.SendBulkUpdateInventory(item); - for (int i = 0 ; i < objlist.Count; i++) - { - group = objlist[i]; + return null; + } + + for (int i = 0 ; i < objlist.Count; i++) + { + group = objlist[i]; // Vector3 storedPosition = group.AbsolutePosition; - if (group.UUID == UUID.Zero) - { - m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3"); - } + if (group.UUID == UUID.Zero) + { + m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3"); + } - group.RootPart.FromFolderID = item.Folder; + group.RootPart.FromFolderID = item.Folder; - // If it's rezzed in world, select it. Much easier to - // find small items. - // - if (!attachment) - { - group.RootPart.CreateSelected = true; - foreach (SceneObjectPart child in group.Parts) - child.CreateSelected = true; - } + // If it's rezzed in world, select it. Much easier to + // find small items. + // + if (!attachment) + { + group.RootPart.CreateSelected = true; + foreach (SceneObjectPart child in group.Parts) + child.CreateSelected = true; + } - group.ResetIDs(); + group.ResetIDs(); - if (attachment) - { - group.RootPart.Flags |= PrimFlags.Phantom; - group.IsAttachment = true; - } + if (attachment) + { + group.RootPart.Flags |= PrimFlags.Phantom; + group.IsAttachment = true; + } - // If we're rezzing an attachment then don't ask - // AddNewSceneObject() to update the client since - // we'll be doing that later on. Scheduling more than - // one full update during the attachment - // process causes some clients to fail to display the - // attachment properly. - m_Scene.AddNewSceneObject(group, true, false); - - // if attachment we set it's asset id so object updates - // can reflect that, if not, we set it's position in world. - if (!attachment) - { - group.ScheduleGroupForFullUpdate(); - - group.AbsolutePosition = pos + veclist[i]; - } - else - { - group.SetFromItemID(itemID); - } + // If we're rezzing an attachment then don't ask + // AddNewSceneObject() to update the client since + // we'll be doing that later on. Scheduling more than + // one full update during the attachment + // process causes some clients to fail to display the + // attachment properly. + m_Scene.AddNewSceneObject(group, true, false); + + // if attachment we set it's asset id so object updates + // can reflect that, if not, we set it's position in world. + if (!attachment) + { + group.ScheduleGroupForFullUpdate(); - SceneObjectPart rootPart = group.RootPart; + group.AbsolutePosition = pos + veclist[i]; + } + else + { + group.SetFromItemID(itemID); + } - // Since renaming the item in the inventory does not - // affect the name stored in the serialization, transfer - // the correct name from the inventory to the - // object itself before we rez. - // - // Only do these for the first object if we are rezzing a coalescence. - if (i == 0) - { - rootPart.Name = item.Name; - rootPart.Description = item.Description; - rootPart.ObjectSaleType = item.SaleType; - rootPart.SalePrice = item.SalePrice; - } + SceneObjectPart rootPart = group.RootPart; - group.SetGroup(remoteClient.ActiveGroupId, remoteClient); - if ((rootPart.OwnerID != item.Owner) || - (item.CurrentPermissions & 16) != 0) - { - //Need to kill the for sale here - rootPart.ObjectSaleType = 0; - rootPart.SalePrice = 10; + // Since renaming the item in the inventory does not + // affect the name stored in the serialization, transfer + // the correct name from the inventory to the + // object itself before we rez. + // + // Only do these for the first object if we are rezzing a coalescence. + if (i == 0) + { + rootPart.Name = item.Name; + rootPart.Description = item.Description; + rootPart.ObjectSaleType = item.SaleType; + rootPart.SalePrice = item.SalePrice; + } - if (m_Scene.Permissions.PropagatePermissions()) - { - foreach (SceneObjectPart part in group.Parts) - { - if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) - { - part.EveryoneMask = item.EveryOnePermissions; - part.NextOwnerMask = item.NextPermissions; - } - part.GroupMask = 0; // DO NOT propagate here - } - - group.ApplyNextOwnerPermissions(); - } - } + group.SetGroup(remoteClient.ActiveGroupId, remoteClient); + if ((rootPart.OwnerID != item.Owner) || + (item.CurrentPermissions & 16) != 0) + { + //Need to kill the for sale here + rootPart.ObjectSaleType = 0; + rootPart.SalePrice = 10; + if (m_Scene.Permissions.PropagatePermissions()) + { foreach (SceneObjectPart part in group.Parts) { - if ((part.OwnerID != item.Owner) || - (item.CurrentPermissions & 16) != 0) + if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) { - part.LastOwnerID = part.OwnerID; - part.OwnerID = item.Owner; - part.Inventory.ChangeInventoryOwner(item.Owner); - part.GroupMask = 0; // DO NOT propagate here + part.EveryoneMask = item.EveryOnePermissions; + part.NextOwnerMask = item.NextPermissions; } - part.EveryoneMask = item.EveryOnePermissions; - part.NextOwnerMask = item.NextPermissions; + part.GroupMask = 0; // DO NOT propagate here } - rootPart.TrimPermissions(); - - if (!attachment) - { - if (group.RootPart.Shape.PCode == (byte)PCode.Prim) - group.ClearPartAttachmentData(); - - // Fire on_rez - group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); - rootPart.ParentGroup.ResumeScripts(); - - rootPart.ScheduleFullUpdate(); - } - -// m_log.DebugFormat( -// "[InventoryAccessModule]: Rezzed {0} {1} {2} for {3}", -// group.Name, group.LocalId, group.UUID, remoteClient.Name); + group.ApplyNextOwnerPermissions(); } + } - if (!m_Scene.Permissions.BypassPermissions()) + foreach (SceneObjectPart part in group.Parts) + { + if ((part.OwnerID != item.Owner) || + (item.CurrentPermissions & 16) != 0) { - if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) - { - // If this is done on attachments, no - // copy ones will be lost, so avoid it - // - if (!attachment) - { - List uuids = new List(); - uuids.Add(item.ID); - m_Scene.InventoryService.DeleteItems(item.Owner, uuids); - } - } + part.LastOwnerID = part.OwnerID; + part.OwnerID = item.Owner; + part.Inventory.ChangeInventoryOwner(item.Owner); + part.GroupMask = 0; // DO NOT propagate here } + part.EveryoneMask = item.EveryOnePermissions; + part.NextOwnerMask = item.NextPermissions; } - else + + rootPart.TrimPermissions(); + + if (!attachment) { - m_log.WarnFormat( - "[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()", item.AssetID, item.Name, item.ID, remoteClient.Name); + if (group.RootPart.Shape.PCode == (byte)PCode.Prim) + group.ClearPartAttachmentData(); + + // Fire on_rez + group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); + rootPart.ParentGroup.ResumeScripts(); + + rootPart.ScheduleFullUpdate(); } - return group; +// m_log.DebugFormat( +// "[InventoryAccessModule]: Rezzed {0} {1} {2} for {3}", +// group.Name, group.LocalId, group.UUID, remoteClient.Name); } - else + + if (!m_Scene.Permissions.BypassPermissions()) { - m_log.WarnFormat( - "[InventoryAccessModule]: Could not find item {0} for {1} in RezObject()", - itemID, remoteClient.Name); + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) + { + // If this is done on attachments, no + // copy ones will be lost, so avoid it + // + if (!attachment) + { + List uuids = new List(); + uuids.Add(item.ID); + m_Scene.InventoryService.DeleteItems(item.Owner, uuids); + } + } } - return null; + return group; } protected void AddUserData(SceneObjectGroup sog) -- cgit v1.1 From cc8897127b30b90bae1adfe7d6968974540cc669 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 23:37:03 +0100 Subject: remove the pointless m_Scene.GetNewRezLocation() call at the top of IAM.RezObject() since its always recalculated later on anyway --- .../Framework/InventoryAccess/InventoryAccessModule.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 5778dff..9cad003 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -693,12 +693,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) { // m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); - - byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); - Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); - Vector3 pos = m_Scene.GetNewRezLocation( - RayStart, RayEnd, RayTargetID, Quaternion.Identity, - BypassRayCast, bRayEndIsIntersection, true, scale, false); InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = m_Scene.InventoryService.GetItem(item); @@ -731,7 +725,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // item that it came from. This allows us to enable 'save object to inventory' if (!m_Scene.Permissions.BypassPermissions()) { - if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) + == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) { itemId = item.ID; } @@ -749,6 +744,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess List objlist = new List(); List veclist = new List(); + byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); + Vector3 pos; XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlData); -- cgit v1.1 From 3e86064d6bdf46eb3dcbb9e9058cd7226f9e5367 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 23:49:38 +0100 Subject: refactor: factor out DoPostRezWhenFromItem() from IAM.RezObject() --- .../Framework/InventoryAccess/InventoryAccessModule.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 9cad003..41f0e8c 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -946,6 +946,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // group.Name, group.LocalId, group.UUID, remoteClient.Name); } + DoPostRezWhenFromItem(item, attachment); + + return group; + } + + private void DoPostRezWhenFromItem(InventoryItemBase item, bool isAttachment) + { if (!m_Scene.Permissions.BypassPermissions()) { if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) @@ -953,7 +960,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // If this is done on attachments, no // copy ones will be lost, so avoid it // - if (!attachment) + if (!isAttachment) { List uuids = new List(); uuids.Add(item.ID); @@ -961,8 +968,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } } } - - return group; } protected void AddUserData(SceneObjectGroup sog) -- cgit v1.1 From 01146bb3e3b60fd3ab54a1321fb58fe2e8cfbf1e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 2 Sep 2011 00:04:22 +0100 Subject: factor out a section of IAM.RezObject() into DoPreRezWhenFromItem() --- .../InventoryAccess/InventoryAccessModule.cs | 88 ++++++++++++---------- 1 file changed, 48 insertions(+), 40 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 41f0e8c..9bc7a09 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -822,7 +822,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess return null; } - for (int i = 0 ; i < objlist.Count; i++) + for (int i = 0; i < objlist.Count; i++) { group = objlist[i]; @@ -832,8 +832,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3"); } - group.RootPart.FromFolderID = item.Folder; - // If it's rezzed in world, select it. Much easier to // find small items. // @@ -890,44 +888,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } group.SetGroup(remoteClient.ActiveGroupId, remoteClient); - if ((rootPart.OwnerID != item.Owner) || - (item.CurrentPermissions & 16) != 0) - { - //Need to kill the for sale here - rootPart.ObjectSaleType = 0; - rootPart.SalePrice = 10; - - if (m_Scene.Permissions.PropagatePermissions()) - { - foreach (SceneObjectPart part in group.Parts) - { - if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) - { - part.EveryoneMask = item.EveryOnePermissions; - part.NextOwnerMask = item.NextPermissions; - } - part.GroupMask = 0; // DO NOT propagate here - } - - group.ApplyNextOwnerPermissions(); - } - } - foreach (SceneObjectPart part in group.Parts) - { - if ((part.OwnerID != item.Owner) || - (item.CurrentPermissions & 16) != 0) - { - part.LastOwnerID = part.OwnerID; - part.OwnerID = item.Owner; - part.Inventory.ChangeInventoryOwner(item.Owner); - part.GroupMask = 0; // DO NOT propagate here - } - part.EveryoneMask = item.EveryOnePermissions; - part.NextOwnerMask = item.NextPermissions; - } - - rootPart.TrimPermissions(); + DoPreRezWhenFromItem(item, group); if (!attachment) { @@ -951,6 +913,52 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess return group; } + private void DoPreRezWhenFromItem(InventoryItemBase item, SceneObjectGroup so) + { + so.RootPart.FromFolderID = item.Folder; + + SceneObjectPart rootPart = so.RootPart; + + if ((rootPart.OwnerID != item.Owner) || + (item.CurrentPermissions & 16) != 0) + { + //Need to kill the for sale here + rootPart.ObjectSaleType = 0; + rootPart.SalePrice = 10; + + if (m_Scene.Permissions.PropagatePermissions()) + { + foreach (SceneObjectPart part in so.Parts) + { + if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) + { + part.EveryoneMask = item.EveryOnePermissions; + part.NextOwnerMask = item.NextPermissions; + } + part.GroupMask = 0; // DO NOT propagate here + } + + so.ApplyNextOwnerPermissions(); + } + } + + foreach (SceneObjectPart part in so.Parts) + { + if ((part.OwnerID != item.Owner) || + (item.CurrentPermissions & 16) != 0) + { + part.LastOwnerID = part.OwnerID; + part.OwnerID = item.Owner; + part.Inventory.ChangeInventoryOwner(item.Owner); + part.GroupMask = 0; // DO NOT propagate here + } + part.EveryoneMask = item.EveryOnePermissions; + part.NextOwnerMask = item.NextPermissions; + } + + rootPart.TrimPermissions(); + } + private void DoPostRezWhenFromItem(InventoryItemBase item, bool isAttachment) { if (!m_Scene.Permissions.BypassPermissions()) -- cgit v1.1 From 15ea82e925af419f811a3c8c603bdc1e9103d22c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 2 Sep 2011 00:25:05 +0100 Subject: move more of IAM.RezObject() into DoPreRezWhenFromItem() --- .../InventoryAccess/InventoryAccessModule.cs | 148 ++++++++++++--------- 1 file changed, 85 insertions(+), 63 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 9bc7a09..e94d059 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -803,24 +803,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } } - int primcount = 0; - foreach (SceneObjectGroup g in objlist) - primcount += g.PrimCount; - - if (!m_Scene.Permissions.CanRezObject( - primcount, remoteClient.AgentId, pos) - && !attachment) - { - // The client operates in no fail mode. It will - // have already removed the item from the folder - // if it's no copy. - // Put it back if it's not an attachment - // - if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) - remoteClient.SendBulkUpdateInventory(item); - + if (!DoPreRezWhenFromItem(remoteClient, item, objlist, pos, attachment)) return null; - } for (int i = 0; i < objlist.Count; i++) { @@ -829,7 +813,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // Vector3 storedPosition = group.AbsolutePosition; if (group.UUID == UUID.Zero) { - m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3"); + m_log.Debug("[InventoryAccessModule]: Object has UUID.Zero! Position 3"); } // If it's rezzed in world, select it. Much easier to @@ -873,24 +857,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess SceneObjectPart rootPart = group.RootPart; - // Since renaming the item in the inventory does not - // affect the name stored in the serialization, transfer - // the correct name from the inventory to the - // object itself before we rez. - // - // Only do these for the first object if we are rezzing a coalescence. - if (i == 0) - { - rootPart.Name = item.Name; - rootPart.Description = item.Description; - rootPart.ObjectSaleType = item.SaleType; - rootPart.SalePrice = item.SalePrice; - } - group.SetGroup(remoteClient.ActiveGroupId, remoteClient); - DoPreRezWhenFromItem(item, group); - if (!attachment) { if (group.RootPart.Shape.PCode == (byte)PCode.Prim) @@ -913,52 +881,106 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess return group; } - private void DoPreRezWhenFromItem(InventoryItemBase item, SceneObjectGroup so) + /// + /// Do pre-rez processing when the object comes from an item. + /// + /// + /// + /// + /// + /// + /// true if we can processed with rezzing, false if we need to abort + private bool DoPreRezWhenFromItem( + IClientAPI remoteClient, InventoryItemBase item, List objlist, Vector3 pos, bool isAttachment) { - so.RootPart.FromFolderID = item.Folder; + int primcount = 0; + foreach (SceneObjectGroup g in objlist) + primcount += g.PrimCount; + + if (!m_Scene.Permissions.CanRezObject( + primcount, remoteClient.AgentId, pos) + && !isAttachment) + { + // The client operates in no fail mode. It will + // have already removed the item from the folder + // if it's no copy. + // Put it back if it's not an attachment + // + if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!isAttachment)) + remoteClient.SendBulkUpdateInventory(item); - SceneObjectPart rootPart = so.RootPart; + return false; + } - if ((rootPart.OwnerID != item.Owner) || - (item.CurrentPermissions & 16) != 0) + for (int i = 0; i < objlist.Count; i++) { - //Need to kill the for sale here - rootPart.ObjectSaleType = 0; - rootPart.SalePrice = 10; + SceneObjectGroup so = objlist[i]; + SceneObjectPart rootPart = so.RootPart; + + // Since renaming the item in the inventory does not + // affect the name stored in the serialization, transfer + // the correct name from the inventory to the + // object itself before we rez. + // + // Only do these for the first object if we are rezzing a coalescence. + if (i == 0) + { + rootPart.Name = item.Name; + rootPart.Description = item.Description; + rootPart.ObjectSaleType = item.SaleType; + rootPart.SalePrice = item.SalePrice; + } - if (m_Scene.Permissions.PropagatePermissions()) + rootPart.FromFolderID = item.Folder; + + if ((rootPart.OwnerID != item.Owner) || + (item.CurrentPermissions & 16) != 0) { - foreach (SceneObjectPart part in so.Parts) + //Need to kill the for sale here + rootPart.ObjectSaleType = 0; + rootPart.SalePrice = 10; + + if (m_Scene.Permissions.PropagatePermissions()) { - if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) + foreach (SceneObjectPart part in so.Parts) { - part.EveryoneMask = item.EveryOnePermissions; - part.NextOwnerMask = item.NextPermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) + { + part.EveryoneMask = item.EveryOnePermissions; + part.NextOwnerMask = item.NextPermissions; + } + part.GroupMask = 0; // DO NOT propagate here } - part.GroupMask = 0; // DO NOT propagate here + + so.ApplyNextOwnerPermissions(); } - - so.ApplyNextOwnerPermissions(); } - } - - foreach (SceneObjectPart part in so.Parts) - { - if ((part.OwnerID != item.Owner) || - (item.CurrentPermissions & 16) != 0) + + foreach (SceneObjectPart part in so.Parts) { - part.LastOwnerID = part.OwnerID; - part.OwnerID = item.Owner; - part.Inventory.ChangeInventoryOwner(item.Owner); - part.GroupMask = 0; // DO NOT propagate here + if ((part.OwnerID != item.Owner) || + (item.CurrentPermissions & 16) != 0) + { + part.LastOwnerID = part.OwnerID; + part.OwnerID = item.Owner; + part.Inventory.ChangeInventoryOwner(item.Owner); + part.GroupMask = 0; // DO NOT propagate here + } + part.EveryoneMask = item.EveryOnePermissions; + part.NextOwnerMask = item.NextPermissions; } - part.EveryoneMask = item.EveryOnePermissions; - part.NextOwnerMask = item.NextPermissions; + + rootPart.TrimPermissions(); } - rootPart.TrimPermissions(); + return true; } + /// + /// Do post-rez processing when the object comes from an item. + /// + /// + /// private void DoPostRezWhenFromItem(InventoryItemBase item, bool isAttachment) { if (!m_Scene.Permissions.BypassPermissions()) -- cgit v1.1 From 9c0a03731d531430d5c2b8b43d2384c0dd086f88 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 2 Sep 2011 00:41:21 +0100 Subject: Move more of IAM.RezObject() into DoPreRezWhenFromItem() --- .../InventoryAccess/InventoryAccessModule.cs | 51 ++++++++++++---------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index e94d059..f8515b4 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -719,26 +719,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } SceneObjectGroup group = null; - UUID itemId = UUID.Zero; - - // If we have permission to copy then link the rezzed object back to the user inventory - // item that it came from. This allows us to enable 'save object to inventory' - if (!m_Scene.Permissions.BypassPermissions()) - { - if ((item.CurrentPermissions & (uint)PermissionMask.Copy) - == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) - { - itemId = item.ID; - } - } - else - { - if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) - { - // Brave new fullperm world - itemId = item.ID; - } - } string xmlData = Utils.BytesToString(rezAsset.Data); List objlist = @@ -753,8 +733,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (e == null || attachment) // Single { SceneObjectGroup g = - SceneObjectSerializer.FromOriginalXmlFormat( - itemId, xmlData); + SceneObjectSerializer.FromOriginalXmlFormat(UUID.Zero, xmlData); + objlist.Add(g); veclist.Add(new Vector3(0, 0, 0)); @@ -783,8 +763,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess foreach (XmlNode n in groups) { SceneObjectGroup g = - SceneObjectSerializer.FromOriginalXmlFormat( - itemId, n.OuterXml); + SceneObjectSerializer.FromOriginalXmlFormat(UUID.Zero, n.OuterXml); + objlist.Add(g); XmlElement el = (XmlElement)n; @@ -893,6 +873,27 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess private bool DoPreRezWhenFromItem( IClientAPI remoteClient, InventoryItemBase item, List objlist, Vector3 pos, bool isAttachment) { + UUID fromUserInventoryItemId = UUID.Zero; + + // If we have permission to copy then link the rezzed object back to the user inventory + // item that it came from. This allows us to enable 'save object to inventory' + if (!m_Scene.Permissions.BypassPermissions()) + { + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) + == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) + { + fromUserInventoryItemId = item.ID; + } + } + else + { + if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) + { + // Brave new fullperm world + fromUserInventoryItemId = item.ID; + } + } + int primcount = 0; foreach (SceneObjectGroup g in objlist) primcount += g.PrimCount; @@ -958,6 +959,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess foreach (SceneObjectPart part in so.Parts) { + part.FromUserInventoryItemID = fromUserInventoryItemId; + if ((part.OwnerID != item.Owner) || (item.CurrentPermissions & 16) != 0) { -- cgit v1.1 From af7c6c5f39dc05dccb891e7bc19ec158de7718a9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 2 Sep 2011 00:50:16 +0100 Subject: stop passing FromUserInventoryItemID right down into the deserializer. the code becomes simpler if this is set from the outside - only one place needs to do this. --- .../CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index f8515b4..e6b58b3 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -732,8 +732,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject"); if (e == null || attachment) // Single { - SceneObjectGroup g = - SceneObjectSerializer.FromOriginalXmlFormat(UUID.Zero, xmlData); + SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); objlist.Add(g); veclist.Add(new Vector3(0, 0, 0)); @@ -762,8 +761,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); foreach (XmlNode n in groups) { - SceneObjectGroup g = - SceneObjectSerializer.FromOriginalXmlFormat(UUID.Zero, n.OuterXml); + SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); objlist.Add(g); XmlElement el = (XmlElement)n; -- cgit v1.1 From 26b471f25a27d7e888d31854a3437f85191538a7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 2 Sep 2011 22:28:27 +0100 Subject: Go back to resetting the State parameter for all parts of a SOG when SOG.ClearPartAttachmentData() is called. Even though we don't use these on rez they are still present after an unlink, after which selecting them causes various viewers to crash Hopefully really does address http://opensimulator.org/mantis/view.php?id=5664 --- .../Framework/InventoryAccess/InventoryAccessModule.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index e6b58b3..4b39341 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -794,14 +794,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_log.Debug("[InventoryAccessModule]: Object has UUID.Zero! Position 3"); } - // If it's rezzed in world, select it. Much easier to - // find small items. - // if (!attachment) { + // If it's rezzed in world, select it. Much easier to + // find small items. + // group.RootPart.CreateSelected = true; - foreach (SceneObjectPart child in group.Parts) - child.CreateSelected = true; + + foreach (SceneObjectPart part in group.Parts) + { + part.CreateSelected = true; + } } group.ResetIDs(); -- cgit v1.1 From dbcfb25a52282a4cde84a770d4d9894b00c2c8b8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 2 Sep 2011 22:54:03 +0100 Subject: Remove redundant RootPart.CreatedSelected = true in IAM.RezObject() since this is done through parts iteration --- .../CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 4b39341..0c0b0c5 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -799,8 +799,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // If it's rezzed in world, select it. Much easier to // find small items. // - group.RootPart.CreateSelected = true; - foreach (SceneObjectPart part in group.Parts) { part.CreateSelected = true; -- cgit v1.1 From e6eb0d9a6f2c0e792e3c1a77990fe18e153e454d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 2 Sep 2011 23:19:27 +0100 Subject: Comment out Scene.CleanDroppedAttachments() and calls. This method wasn't actually doing anything since dropped attachments retain a PCode of 9. Also, behaviour of dropped attachments in other places appears to be that they persist after avatar logout rather than get deleted. --- .../Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 766656c..45506ed 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -493,7 +493,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Now let's make it officially a child agent sp.MakeChildAgent(); - sp.Scene.CleanDroppedAttachments(); +// sp.Scene.CleanDroppedAttachments(); // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone -- cgit v1.1 From 5c1fa968ab954bec9860023dffc8f68baf3c0620 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Sep 2011 01:11:16 +0100 Subject: Stop NPCs losing attachments when the source avatar takes them off. This was happening because we were using the source avatar's item IDs in the clone appearance. Switch to using the asset IDs of attachments instead for NPCs. The InventoryAccessModule and AttachmentModule had to be changed to allow rezzing of an object without an associated inventory item. Hopefully goes some way towards resolving http://opensimulator.org/mantis/view.php?id=5653 --- .../Avatar/Attachments/AttachmentsModule.cs | 76 ++++++++++++++-------- .../InventoryAccess/InventoryAccessModule.cs | 67 ++++++++++--------- 2 files changed, 83 insertions(+), 60 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index ffe76a8..4881499 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -111,10 +111,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments List attachments = sp.Appearance.GetAttachments(); foreach (AvatarAttachment attach in attachments) { - int p = attach.AttachPoint; - UUID itemID = attach.ItemID; + uint p = (uint)attach.AttachPoint; + +// m_log.DebugFormat( +// "[ATTACHMENTS MODULE]: Doing initial rez of attachment with itemID {0}, assetID {1}, point {2} for {3} in {4}", +// attach.ItemID, attach.AssetID, p, sp.Name, m_scene.RegionInfo.RegionName); - //UUID assetID = attach.AssetID; // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down // But they're not used anyway, the item is being looked up for now, so let's proceed. //if (UUID.Zero == assetID) @@ -125,7 +127,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments try { - RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, (uint)p); + // If we're an NPC then skip all the item checks and manipulations since we don't have an + // inventory right now. + if (sp.PresenceType == PresenceType.Npc) + RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p); + else + RezSingleAttachmentFromInventory(sp.ControllingClient, attach.ItemID, p); } catch (Exception e) { @@ -231,7 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return AttachObject(sp, group, AttachmentPt, silent); } - private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent) + private bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent) { // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", @@ -284,17 +291,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments List attachments = sp.GetAttachments(attachmentPt); // At the moment we can only deal with a single attachment - if (attachments.Count != 0) - itemID = attachments[0].GetFromItemID(); - - if (itemID != UUID.Zero) - DetachSingleAttachmentToInv(itemID, sp); - - itemID = group.GetFromItemID(); - if (itemID == UUID.Zero) - itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID; - - ShowAttachInUserInventory(sp, attachmentPt, itemID, group); + // We also don't want to do any of the inventory operations for an NPC. + if (sp.PresenceType != PresenceType.Npc) + { + if (attachments.Count != 0) + itemID = attachments[0].GetFromItemID(); + + if (itemID != UUID.Zero) + DetachSingleAttachmentToInv(itemID, sp); + + itemID = group.GetFromItemID(); + if (itemID == UUID.Zero) + itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID; + + ShowAttachInUserInventory(sp, attachmentPt, itemID, group); + } AttachToAgent(sp, group, attachmentPt, attachPos, silent); @@ -312,7 +323,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } - public ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) + public ISceneEntity RezSingleAttachmentFromInventory( + IClientAPI remoteClient, UUID itemID, uint AttachmentPt) { return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true); } @@ -338,7 +350,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // be removed when that functionality is implemented in opensim AttachmentPt &= 0x7f; - SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, AttachmentPt); + SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt); if (updateInventoryStatus) { @@ -352,14 +364,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( - ScenePresence sp, UUID itemID, uint attachmentPt) + IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt) { IInventoryAccessModule invAccess = m_scene.RequestModuleInterface(); if (invAccess != null) { - SceneObjectGroup objatt = invAccess.RezObject(sp.ControllingClient, - itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, - false, false, sp.UUID, true); + SceneObjectGroup objatt; + + if (itemID != UUID.Zero) + objatt = invAccess.RezObject(sp.ControllingClient, + itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, + false, false, sp.UUID, true); + else + objatt = invAccess.RezObject(sp.ControllingClient, + null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, + false, false, sp.UUID, true); // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", @@ -425,7 +444,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// private UUID ShowAttachInUserInventory( - SceneObjectGroup att, ScenePresence sp, UUID itemID, uint attachmentPoint) + SceneObjectGroup att, IScenePresence sp, UUID itemID, uint attachmentPoint) { // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} {2} (item ID {3}) at {4}", @@ -452,7 +471,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// private void ShowAttachInUserInventory( - ScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) + IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) { // m_log.DebugFormat( // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", @@ -574,7 +593,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? - private void DetachSingleAttachmentToInv(UUID itemID, ScenePresence sp) + private void DetachSingleAttachmentToInv(UUID itemID, IScenePresence sp) { if (itemID == UUID.Zero) // If this happened, someone made a mistake.... return; @@ -697,16 +716,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// Attach this scene object to the given avatar. /// - /// + /// /// This isn't publicly available since attachments should always perform the corresponding inventory /// operation (to show the attach in user inventory and update the asset with positional information). - /// + /// /// /// /// /// /// - protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) + private void AttachToAgent( + IScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) { // m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", // so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 0c0b0c5..4e8466d 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -669,28 +669,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess return item; } - /// - /// Rez an object into the scene from the user's inventory - /// - /// - /// FIXME: It would be really nice if inventory access modules didn't also actually do the work of rezzing - /// things to the scene. The caller should be doing that, I think. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The SceneObjectGroup rezzed or null if rez was unsuccessful. - public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, - UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, - bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) + public virtual SceneObjectGroup RezObject( + IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, + UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, + bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) { // m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); @@ -707,13 +689,34 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } item.Owner = remoteClient.AgentId; - AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); + + return RezObject( + remoteClient, item, item.AssetID, + RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, + RezSelected, RemoveItem, fromTaskID, attachment); + } + + public virtual SceneObjectGroup RezObject( + IClientAPI remoteClient, InventoryItemBase item, UUID assetID, Vector3 RayEnd, Vector3 RayStart, + UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, + bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) + { + AssetBase rezAsset = m_Scene.AssetService.Get(assetID.ToString()); if (rezAsset == null) { - m_log.WarnFormat( - "[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()", - item.AssetID, item.Name, item.ID, remoteClient.Name); + if (item != null) + { + m_log.WarnFormat( + "[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()", + assetID, item.Name, item.ID, remoteClient.Name); + } + else + { + m_log.WarnFormat( + "[InventoryAccessModule]: Could not find asset {0} for {1} in RezObject()", + assetID, remoteClient.Name); + } return null; } @@ -781,7 +784,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } } - if (!DoPreRezWhenFromItem(remoteClient, item, objlist, pos, attachment)) + if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, attachment)) return null; for (int i = 0; i < objlist.Count; i++) @@ -829,10 +832,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess group.AbsolutePosition = pos + veclist[i]; } - else - { - group.SetFromItemID(itemID); - } SceneObjectPart rootPart = group.RootPart; @@ -855,7 +854,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // group.Name, group.LocalId, group.UUID, remoteClient.Name); } - DoPostRezWhenFromItem(item, attachment); + if (item != null) + DoPostRezWhenFromItem(item, attachment); return group; } @@ -973,6 +973,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } rootPart.TrimPermissions(); + + if (isAttachment) + so.SetFromItemID(item.ID); } return true; -- cgit v1.1