diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index e3f9d898a5..1933756e55 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -92,6 +92,7 @@ what it is today. * dslake * eeyore * FredoChaplin +* FreakyTech * Garmin Kawaguichi * Gerhard * Godfrey @@ -128,6 +129,7 @@ what it is today. * LuciusSirnah * lulurun * M.Igarashi +* Magnuz Binder * maimedleech * Mana Janus * MarcelEdward diff --git a/OpenSim/Addons/Groups/RemoteConnectorCacheWrapper.cs b/OpenSim/Addons/Groups/RemoteConnectorCacheWrapper.cs index f121737d82..813f79658e 100644 --- a/OpenSim/Addons/Groups/RemoteConnectorCacheWrapper.cs +++ b/OpenSim/Addons/Groups/RemoteConnectorCacheWrapper.cs @@ -145,14 +145,20 @@ namespace OpenSim.Groups if (firstCall) { - //group = m_GroupsService.GetGroupRecord(RequestingAgentID, GroupID, GroupName); - group = d(); - - lock (m_Cache) + try + { + //group = m_GroupsService.GetGroupRecord(RequestingAgentID, GroupID, GroupName); + group = d(); + + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, group, GROUPS_CACHE_TIMEOUT); + return (ExtendedGroupRecord)group; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, group, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (ExtendedGroupRecord)group; } } else @@ -244,13 +250,19 @@ namespace OpenSim.Groups if (firstCall) { - membership = d(); - - lock (m_Cache) + try + { + membership = d(); + + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, membership, GROUPS_CACHE_TIMEOUT); + return (ExtendedGroupMembershipData)membership; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, membership, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (ExtendedGroupMembershipData)membership; } } else @@ -287,12 +299,18 @@ namespace OpenSim.Groups if (firstCall) { - membership = d(); - lock (m_Cache) + try + { + membership = d(); + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, membership, GROUPS_CACHE_TIMEOUT); + return (ExtendedGroupMembershipData)membership; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, membership, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (ExtendedGroupMembershipData)membership; } } else @@ -328,12 +346,18 @@ namespace OpenSim.Groups if (firstCall) { - memberships = d(); - lock (m_Cache) + try + { + memberships = d(); + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, memberships, GROUPS_CACHE_TIMEOUT); + return (List)memberships; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, memberships, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (List)memberships; } } else @@ -370,20 +394,26 @@ namespace OpenSim.Groups if (firstCall) { - List _members = d(); - - if (_members != null && _members.Count > 0) - members = _members.ConvertAll(new Converter(m_ForeignImporter.ConvertGroupMembersData)); - else - members = new List(); - - lock (m_Cache) + try { - //m_Cache.AddOrUpdate(cacheKey, members, GROUPS_CACHE_TIMEOUT); - m_Cache.AddOrUpdate(cacheKey, _members, GROUPS_CACHE_TIMEOUT); - m_ActiveRequests.Remove(cacheKey); + List _members = d(); - return (List)members; + if (_members != null && _members.Count > 0) + members = _members.ConvertAll(new Converter(m_ForeignImporter.ConvertGroupMembersData)); + else + members = new List(); + + lock (m_Cache) + { + //m_Cache.AddOrUpdate(cacheKey, members, GROUPS_CACHE_TIMEOUT); + m_Cache.AddOrUpdate(cacheKey, _members, GROUPS_CACHE_TIMEOUT); + + return (List)members; + } + } + finally + { + m_ActiveRequests.Remove(cacheKey); } } else @@ -498,16 +528,22 @@ namespace OpenSim.Groups if (firstCall) { - roles = d(); - if (roles != null) + try { - lock (m_Cache) + roles = d(); + if (roles != null) { - m_Cache.AddOrUpdate(cacheKey, roles, GROUPS_CACHE_TIMEOUT); - m_ActiveRequests.Remove(cacheKey); - return (List)roles; + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, roles, GROUPS_CACHE_TIMEOUT); + return (List)roles; + } } } + finally + { + m_ActiveRequests.Remove(cacheKey); + } } else Thread.Sleep(50); @@ -542,23 +578,29 @@ namespace OpenSim.Groups if (firstCall) { - List _rmembers = d(); - - if (_rmembers != null && _rmembers.Count > 0) - rmembers = _rmembers.ConvertAll(new Converter(m_ForeignImporter.ConvertGroupRoleMembersData)); - else - rmembers = new List(); - - lock (m_Cache) + try + { + List _rmembers = d(); + + if (_rmembers != null && _rmembers.Count > 0) + rmembers = _rmembers.ConvertAll(new Converter(m_ForeignImporter.ConvertGroupRoleMembersData)); + else + rmembers = new List(); + + lock (m_Cache) + { + // For some strange reason, when I cache the list of GroupRoleMembersData, + // it gets emptied out. The TryGet gets an empty list... + //m_Cache.AddOrUpdate(cacheKey, rmembers, GROUPS_CACHE_TIMEOUT); + // Caching the list of ExtendedGroupRoleMembersData doesn't show that issue + // I don't get it. + m_Cache.AddOrUpdate(cacheKey, _rmembers, GROUPS_CACHE_TIMEOUT); + return (List)rmembers; + } + } + finally { - // For some strange reason, when I cache the list of GroupRoleMembersData, - // it gets emptied out. The TryGet gets an empty list... - //m_Cache.AddOrUpdate(cacheKey, rmembers, GROUPS_CACHE_TIMEOUT); - // Caching the list of ExtendedGroupRoleMembersData doesn't show that issue - // I don't get it. - m_Cache.AddOrUpdate(cacheKey, _rmembers, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (List)rmembers; } } else @@ -667,12 +709,19 @@ namespace OpenSim.Groups if (firstCall) { - roles = d(); - lock (m_Cache) + try + { + roles = d(); + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, roles, GROUPS_CACHE_TIMEOUT); + m_ActiveRequests.Remove(cacheKey); + return (List)roles; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, roles, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (List)roles; } } else @@ -768,13 +817,19 @@ namespace OpenSim.Groups if (firstCall) { - GroupNoticeInfo _notice = d(); - - lock (m_Cache) + try + { + GroupNoticeInfo _notice = d(); + + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, _notice, GROUPS_CACHE_TIMEOUT); + return _notice; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, _notice, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return _notice; } } else @@ -810,20 +865,24 @@ namespace OpenSim.Groups if (firstCall) { - notices = d(); - - lock (m_Cache) + try + { + notices = d(); + + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, notices, GROUPS_CACHE_TIMEOUT); + return (List)notices; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, notices, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (List)notices; } } else Thread.Sleep(50); } } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs b/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs index 08faf2d91a..589602df9c 100644 --- a/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs @@ -97,9 +97,9 @@ namespace OpenSim.Capabilities.Handlers osdname["display_name"] = OSD.FromString(name); osdname["legacy_first_name"] = parts[0]; osdname["legacy_last_name"] = parts[1]; - osdname["username"] = ""; + osdname["username"] = OSD.FromString(name); osdname["id"] = OSD.FromUUID(uuid); - osdname["is_display_name_default"] = OSD.FromBoolean(false); + osdname["is_display_name_default"] = OSD.FromBoolean(true); agents.Add(osdname); } diff --git a/OpenSim/Framework/Monitoring/JobEngine.cs b/OpenSim/Framework/Monitoring/JobEngine.cs index 44f5d9a9d7..6db9a67376 100644 --- a/OpenSim/Framework/Monitoring/JobEngine.cs +++ b/OpenSim/Framework/Monitoring/JobEngine.cs @@ -78,7 +78,7 @@ namespace OpenSim.Framework.Monitoring private BlockingCollection m_jobQueue; - private CancellationTokenSource m_cancelSource = new CancellationTokenSource(); + private CancellationTokenSource m_cancelSource; /// /// Used to signal that we are ready to complete stop. @@ -105,6 +105,7 @@ namespace OpenSim.Framework.Monitoring m_finishedProcessingAfterStop.Reset(); m_jobQueue = new BlockingCollection(new ConcurrentQueue(), 5000); + m_cancelSource = new CancellationTokenSource(); WorkManager.StartThread( ProcessRequests, @@ -160,7 +161,6 @@ namespace OpenSim.Framework.Monitoring finally { m_cancelSource.Dispose(); - m_jobQueue = null; } } } @@ -249,7 +249,19 @@ namespace OpenSim.Framework.Monitoring { while (IsRunning || m_jobQueue.Count > 0) { - CurrentJob = m_jobQueue.Take(m_cancelSource.Token); + try + { + CurrentJob = m_jobQueue.Take(m_cancelSource.Token); + } + catch (ObjectDisposedException e) + { + // If we see this whilst not running then it may be due to a race where this thread checks + // IsRunning after the stopping thread sets it to false and disposes of the cancellation source. + if (IsRunning) + throw e; + else + break; + } if (LogLevel >= 1) m_log.DebugFormat("[{0}]: Processing job {1}", LoggingName, CurrentJob.Name); diff --git a/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs index d182a717ff..b3d64e1e64 100644 --- a/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs +++ b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs @@ -1,4 +1,31 @@ -using System; +/* + * 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.Collections.Specialized; using System.Reflection; diff --git a/OpenSim/Framework/ServiceAuth/IServiceAuth.cs b/OpenSim/Framework/ServiceAuth/IServiceAuth.cs index 415dc12e18..fdd97b21c3 100644 --- a/OpenSim/Framework/ServiceAuth/IServiceAuth.cs +++ b/OpenSim/Framework/ServiceAuth/IServiceAuth.cs @@ -1,4 +1,31 @@ -using System; +/* + * 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.Collections.Specialized; diff --git a/OpenSim/Framework/ServiceAuth/ServiceAuth.cs b/OpenSim/Framework/ServiceAuth/ServiceAuth.cs index bc32d901bf..5ab613b377 100644 --- a/OpenSim/Framework/ServiceAuth/ServiceAuth.cs +++ b/OpenSim/Framework/ServiceAuth/ServiceAuth.cs @@ -1,4 +1,31 @@ -using System; +/* + * 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 Nini.Config; diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 836fa5fcaa..56a90b1b5d 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -420,6 +420,22 @@ namespace OpenSim.Framework return x; } + /// + /// Check if any of the values in a Vector3 are NaN or Infinity + /// + /// Vector3 to check + /// + public static bool IsNanOrInfinity(Vector3 v) + { + if (float.IsNaN(v.X) || float.IsNaN(v.Y) || float.IsNaN(v.Z)) + return true; + + if (float.IsInfinity(v.X) || float.IsInfinity(v.Y) || float.IsNaN(v.Z)) + return true; + + return false; + } + // Inclusive, within range test (true if equal to the endpoints) public static bool InRange(T x, T min, T max) where T : IComparable diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index bb4f8a7cd5..311dd31956 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -772,9 +772,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP catch (Exception e) { // Make sure that we see any exception caused by the asynchronous operation. - m_log.ErrorFormat( - "[LLCLIENTVIEW]: Caught exception while processing {0} for {1}, {2} {3}", - packetObject.Pack, Name, e.Message, e.StackTrace); + m_log.Error( + string.Format( + "[LLCLIENTVIEW]: Caught exception while processing {0} for {1} ", packetObject.Pack, Name), + e); } } @@ -9903,6 +9904,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP } return true; + case "kickestate": + + if(((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + UUID invoice = messagePacket.MethodData.Invoice; + UUID SenderID = messagePacket.AgentData.AgentID; + UUID Prey; + + UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[0].Parameter), out Prey); + + OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey); + } + return true; + default: m_log.WarnFormat( "[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}", diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 5fb995b2f7..f0dc2385e8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -546,7 +546,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10); TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript( - scene, + scene.AssetService, so.RootPart, "scriptItem", "default { attach(key id) { if (id != NULL_KEY) { llSay(0, \"Hello World\"); } } }"); @@ -659,7 +659,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10); TaskInventoryItem scriptTaskItem = TaskInventoryHelpers.AddScript( - scene, + scene.AssetService, so.RootPart, "scriptItem", "default { attach(key id) { if (id != NULL_KEY) { llSay(0, \"Hello World\"); } } }"); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index c632798a74..c88141c10f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -455,6 +455,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer { // Check if it's a type of message that we should handle if (!((im.dialog == (byte) InstantMessageDialog.InventoryOffered) + || (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered) || (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) || (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) || (im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined))) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index 6abdc6fa09..8b09b3ef52 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs @@ -318,8 +318,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess writer.WriteString(reader.Value); break; + case XmlNodeType.XmlDeclaration: + // For various reasons, not all serializations have xml declarations (or consistent ones) + // and as it's embedded inside a byte stream we don't need it anyway, so ignore. + break; + default: - m_log.WarnFormat("[HG ASSET MAPPER]: Unrecognized node in asset XML transform in {0}", m_scene.Name); + m_log.WarnFormat( + "[HG ASSET MAPPER]: Unrecognized node {0} in asset XML transform in {1}", + reader.NodeType, m_scene.Name); break; } } @@ -336,8 +343,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess { TransformXml(reader, writer); - writer.WriteEndDocument(); - // Console.WriteLine("Output: [{0}]", sw.ToString()); return sw.ToString(); @@ -478,12 +483,37 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess { asset = m_scene.AssetService.Get(uuid.ToString()); if (asset == null) + { m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); + } else - success &= PostAsset(userAssetURL, asset); + { + try + { + success &= PostAsset(userAssetURL, asset); + } + catch (Exception e) + { + m_log.Error( + string.Format( + "[HG ASSET MAPPER]: Failed to post asset {0} (type {1}, length {2}) referenced from {3} to {4} with exception ", + asset.ID, asset.Type, asset.Data.Length, assetID, userAssetURL), + e); + + // For debugging purposes for now we will continue to throw the exception up the stack as was already happening. However, after + // debugging we may want to simply report the failure if we can tell this is due to a failure + // with a particular asset and not a destination network failure where all asset posts will fail (and + // generate large amounts of log spam). + throw e; + } + } } else - m_log.DebugFormat("[HG ASSET MAPPER]: Didn't post asset {0} because it already exists in asset server {1}", uuid, userAssetURL); + { + m_log.DebugFormat( + "[HG ASSET MAPPER]: Didn't post asset {0} referenced from {1} because it already exists in asset server {2}", + uuid, assetID, userAssetURL); + } } if (!success) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index f958510da3..a77bc635d1 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -614,6 +614,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess protected InventoryItemBase CreateItemForObject( DeRezAction action, IClientAPI remoteClient, SceneObjectGroup so, UUID folderID) { +// m_log.DebugFormat( +// "[BASIC INVENTORY ACCESS MODULE]: Creating item for object {0} {1} for folder {2}, action {3}", +// so.Name, so.UUID, folderID, action); +// // Get the user info of the item destination // UUID userID = UUID.Zero; diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index d8f9f8ce06..780ec69bc6 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -801,8 +801,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions // Friends with benefits should be able to edit the objects too if (IsFriendWithPerms(currentUser, objectOwner)) + { // Return immediately, so that the administrator can share objects with friends return true; + } // Users should be able to edit what is over their land. ILandObject parcel = m_scene.LandChannel.GetLandObject(group.AbsolutePosition.X, group.AbsolutePosition.Y); @@ -1522,6 +1524,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (m_bypassPermissions) return m_bypassPermissionsValue; bool permission = GenericObjectPermission(userID, objectID, false); + + SceneObjectGroup so = (SceneObjectGroup)m_scene.Entities[objectID]; + if (!permission) { if (!m_scene.Entities.ContainsKey(objectID)) @@ -1535,31 +1540,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions return false; } - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID]; // UUID taskOwner = null; // Added this because at this point in time it wouldn't be wise for // the administrator object permissions to take effect. // UUID objectOwner = task.OwnerID; - if ((task.RootPart.EveryoneMask & PERM_COPY) != 0) + if ((so.RootPart.EveryoneMask & PERM_COPY) != 0) permission = true; + } - if (task.OwnerID != userID) - { - if ((task.GetEffectivePermissions() & (PERM_COPY | PERM_TRANS)) != (PERM_COPY | PERM_TRANS)) - permission = false; - } - else - { - if ((task.GetEffectivePermissions() & PERM_COPY) != PERM_COPY) - permission = false; - } + if (so.OwnerID != userID) + { + if ((so.GetEffectivePermissions() & (PERM_COPY | PERM_TRANS)) != (PERM_COPY | PERM_TRANS)) + permission = false; } else { - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID]; - - if ((task.GetEffectivePermissions() & (PERM_COPY | PERM_TRANS)) != (PERM_COPY | PERM_TRANS)) + if ((so.GetEffectivePermissions() & PERM_COPY) != PERM_COPY) permission = false; } diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs index 62d232e833..be1fb24d67 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs @@ -27,6 +27,7 @@ using System; using System.IO; +using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -73,12 +74,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders public ITerrainChannel LoadFile(string filename) { FileInfo file = new FileInfo(filename); - FileStream s = file.Open(FileMode.Open, FileAccess.Read); - ITerrainChannel retval = LoadStream(s); - s.Close(); + ITerrainChannel channel; - return retval; + using (FileStream s = file.Open(FileMode.Open, FileAccess.Read)) + channel = LoadStream(s); + + return channel; } public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) @@ -86,153 +88,159 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); FileInfo file = new FileInfo(filename); - FileStream s = file.Open(FileMode.Open, FileAccess.Read); - BinaryReader bs = new BinaryReader(s); - int currFileYOffset = fileHeight - 1; - - // if our region isn't on the first Y section of the areas to be landscaped, then - // advance to our section of the file - while (currFileYOffset > offsetY) + using (FileStream s = file.Open(FileMode.Open, FileAccess.Read)) + using (BinaryReader bs = new BinaryReader(s)) { - // read a whole strip of regions - int heightsToRead = sectionHeight * (fileWidth * sectionWidth); - bs.ReadBytes(heightsToRead * 13); // because there are 13 fun channels - currFileYOffset--; - } + int currFileYOffset = fileHeight - 1; - // got to the Y start offset within the file of our region - // so read the file bits associated with our region - int y; - // for each Y within our Y offset - for (y = sectionHeight - 1; y >= 0; y--) - { - int currFileXOffset = 0; - - // if our region isn't the first X section of the areas to be landscaped, then - // advance the stream to the X start pos of our section in the file - // i.e. eat X upto where we start - while (currFileXOffset < offsetX) + // if our region isn't on the first Y section of the areas to be landscaped, then + // advance to our section of the file + while (currFileYOffset > offsetY) { - bs.ReadBytes(sectionWidth * 13); - currFileXOffset++; + // read a whole strip of regions + int heightsToRead = sectionHeight * (fileWidth * sectionWidth); + bs.ReadBytes(heightsToRead * 13); // because there are 13 fun channels + currFileYOffset--; } - // got to our X offset, so write our regions X line - int x; - for (x = 0; x < sectionWidth; x++) - { - // Read a strip and continue - retval[x, y] = bs.ReadByte() * (bs.ReadByte() / 128.0); - bs.ReadBytes(11); - } - // record that we wrote it - currFileXOffset++; + // got to the Y start offset within the file of our region + // so read the file bits associated with our region + int y; - // if our region isn't the last X section of the areas to be landscaped, then - // advance the stream to the end of this Y column - while (currFileXOffset < fileWidth) + // for each Y within our Y offset + for (y = sectionHeight - 1; y >= 0; y--) { - // eat the next regions x line - bs.ReadBytes(sectionWidth * 13); //The 13 channels again + int currFileXOffset = 0; + + // if our region isn't the first X section of the areas to be landscaped, then + // advance the stream to the X start pos of our section in the file + // i.e. eat X upto where we start + while (currFileXOffset < offsetX) + { + bs.ReadBytes(sectionWidth * 13); + currFileXOffset++; + } + + // got to our X offset, so write our regions X line + int x; + for (x = 0; x < sectionWidth; x++) + { + // Read a strip and continue + retval[x, y] = bs.ReadByte() * (bs.ReadByte() / 128.0); + bs.ReadBytes(11); + } + // record that we wrote it currFileXOffset++; + + // if our region isn't the last X section of the areas to be landscaped, then + // advance the stream to the end of this Y column + while (currFileXOffset < fileWidth) + { + // eat the next regions x line + bs.ReadBytes(sectionWidth * 13); //The 13 channels again + currFileXOffset++; + } } } - bs.Close(); - s.Close(); - return retval; } public ITerrainChannel LoadStream(Stream s) { - TerrainChannel retval = new TerrainChannel(); + // The raw format doesn't contain any dimension information. + // Guess the square dimensions by using the length of the raw file. + double dimension = Math.Sqrt((double)(s.Length / 13)); + // Regions are always multiples of 256. + int trimmedDimension = (int)dimension - ((int)dimension % (int)Constants.RegionSize); + if (trimmedDimension < Constants.RegionSize) + trimmedDimension = (int)Constants.RegionSize; - BinaryReader bs = new BinaryReader(s); - int y; - for (y = 0; y < retval.Height; y++) + TerrainChannel retval = new TerrainChannel(trimmedDimension, trimmedDimension); + + using (BinaryReader bs = new BinaryReader(s)) { - int x; - for (x = 0; x < retval.Width; x++) + int y; + for (y = 0; y < retval.Height; y++) { - retval[x, (retval.Height - 1) - y] = bs.ReadByte() * (bs.ReadByte() / 128.0); - bs.ReadBytes(11); // Advance the stream to next bytes. + int x; + for (x = 0; x < retval.Width; x++) + { + retval[x, (retval.Height - 1) - y] = bs.ReadByte() * (bs.ReadByte() / 128.0); + bs.ReadBytes(11); // Advance the stream to next bytes. + } } } - bs.Close(); - return retval; } public void SaveFile(string filename, ITerrainChannel map) { FileInfo file = new FileInfo(filename); - FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); - SaveStream(s, map); - s.Close(); + using (FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write)) + SaveStream(s, map); } public void SaveStream(Stream s, ITerrainChannel map) { - BinaryWriter binStream = new BinaryWriter(s); - - // Output the calculated raw - for (int y = 0; y < map.Height; y++) + using (BinaryWriter binStream = new BinaryWriter(s)) { - for (int x = 0; x < map.Width; x++) + // Output the calculated raw + for (int y = 0; y < map.Height; y++) { - double t = map[x, (map.Height - 1) - y]; - //if height is less than 0, set it to 0 as - //can't save -ve values in a LLRAW file - if (t < 0d) + for (int x = 0; x < map.Width; x++) { - t = 0d; + double t = map[x, (map.Height - 1) - y]; + //if height is less than 0, set it to 0 as + //can't save -ve values in a LLRAW file + if (t < 0d) + { + t = 0d; + } + + int index = 0; + + // The lookup table is pre-sorted, so we either find an exact match or + // the next closest (smaller) match with a binary search + index = Array.BinarySearch(LookupHeightTable, new HeightmapLookupValue(0, (float)t)); + if (index < 0) + index = ~index - 1; + + index = LookupHeightTable[index].Index; + + byte red = (byte) (index & 0xFF); + byte green = (byte) ((index >> 8) & 0xFF); + const byte blue = 20; + const byte alpha1 = 0; + const byte alpha2 = 0; + const byte alpha3 = 0; + const byte alpha4 = 0; + const byte alpha5 = 255; + const byte alpha6 = 255; + const byte alpha7 = 255; + const byte alpha8 = 255; + byte alpha9 = red; + byte alpha10 = green; + + binStream.Write(red); + binStream.Write(green); + binStream.Write(blue); + binStream.Write(alpha1); + binStream.Write(alpha2); + binStream.Write(alpha3); + binStream.Write(alpha4); + binStream.Write(alpha5); + binStream.Write(alpha6); + binStream.Write(alpha7); + binStream.Write(alpha8); + binStream.Write(alpha9); + binStream.Write(alpha10); } - - int index = 0; - - // The lookup table is pre-sorted, so we either find an exact match or - // the next closest (smaller) match with a binary search - index = Array.BinarySearch(LookupHeightTable, new HeightmapLookupValue(0, (float)t)); - if (index < 0) - index = ~index - 1; - - index = LookupHeightTable[index].Index; - - byte red = (byte) (index & 0xFF); - byte green = (byte) ((index >> 8) & 0xFF); - const byte blue = 20; - const byte alpha1 = 0; - const byte alpha2 = 0; - const byte alpha3 = 0; - const byte alpha4 = 0; - const byte alpha5 = 255; - const byte alpha6 = 255; - const byte alpha7 = 255; - const byte alpha8 = 255; - byte alpha9 = red; - byte alpha10 = green; - - binStream.Write(red); - binStream.Write(green); - binStream.Write(blue); - binStream.Write(alpha1); - binStream.Write(alpha2); - binStream.Write(alpha3); - binStream.Write(alpha4); - binStream.Write(alpha5); - binStream.Write(alpha6); - binStream.Write(alpha7); - binStream.Write(alpha8); - binStream.Write(alpha9); - binStream.Write(alpha10); } } - - binStream.Close(); } public string FileExtension @@ -259,7 +267,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders public bool SupportsTileSave() { return false; - } - + } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index c1a398d669..d862f181f7 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -217,8 +217,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap { if (regionInfos.Count == 0) remoteClient.SendAlertMessage("No regions found with that name."); - else if (regionInfos.Count == 1) - remoteClient.SendAlertMessage("Region found!"); + // this seems unnecessary because found regions will show up in the search results + //else if (regionInfos.Count == 1) + // remoteClient.SendAlertMessage("Region found!"); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 55db968949..4961309658 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -807,7 +807,7 @@ namespace OpenSim.Region.Framework.Scenes UUID recipientId, UUID senderId, UUID folderId, UUID recipientParentFolderId) { //// Retrieve the folder from the sender - InventoryFolderBase folder = InventoryService.GetFolder(new InventoryFolderBase(folderId)); + InventoryFolderBase folder = InventoryService.GetFolder(new InventoryFolderBase(folderId, senderId)); if (null == folder) { m_log.ErrorFormat( diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 527ca35248..81cef5b3f9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -265,6 +265,7 @@ namespace OpenSim.Region.Framework.Scenes for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; +// m_log.DebugFormat("[SCENE OBJECT GROUP INVENTORY]: Effective perms of {0} are {1}", part.Name, (OpenMetaverse.PermissionMask)part.OwnerMask); ownerMask &= part.OwnerMask; perms &= part.Inventory.MaskEffectivePermissions(); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 19e557f06c..0a1a226c36 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -924,13 +924,17 @@ namespace OpenSim.Region.Framework.Scenes string uuid = reader.GetAttribute("UUID"); + // Even if there is no UUID attribute for some strange reason, we must always read the inner XML + // so we don't continually keep checking the same SavedScriptedState element. + string innerXml = reader.ReadInnerXml(); + if (uuid != null) { // m_log.DebugFormat("[SCENE OBJECT GROUP]: Found state for item ID {0} in object {1}", uuid, Name); UUID itemid = new UUID(uuid); if (itemid != UUID.Zero) - m_savedScriptState[itemid] = reader.ReadInnerXml(); + m_savedScriptState[itemid] = innerXml; } else { @@ -2943,6 +2947,11 @@ namespace OpenSim.Region.Framework.Scenes uint lockMask = ~(uint)(PermissionMask.Move | PermissionMask.Modify); uint lockBit = RootPart.OwnerMask & (uint)(PermissionMask.Move | PermissionMask.Modify); RootPart.OwnerMask = (RootPart.OwnerMask & lockBit) | ((newOwnerMask | foldedPerms) & lockMask); + +// m_log.DebugFormat( +// "[SCENE OBJECT GROUP]: RootPart.OwnerMask now {0} for {1} in {2}", +// (OpenMetaverse.PermissionMask)RootPart.OwnerMask, Name, Scene.Name); + RootPart.ScheduleFullUpdate(); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 1ca250a958..57ec1ae291 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -266,7 +266,7 @@ namespace OpenSim.Region.Framework.Scenes public Quaternion SpinOldOrientation = Quaternion.Identity; - protected int m_APIDIterations = 0; + protected bool m_APIDActive = false; protected Quaternion m_APIDTarget = Quaternion.Identity; protected float m_APIDDamp = 0; protected float m_APIDStrength = 0; @@ -642,6 +642,12 @@ namespace OpenSim.Region.Framework.Scenes } } + protected bool APIDActive + { + get { return m_APIDActive; } + set { m_APIDActive = value; } + } + protected Quaternion APIDTarget { get { return m_APIDTarget; } @@ -923,14 +929,17 @@ namespace OpenSim.Region.Framework.Scenes set { - m_velocity = value; + if (Util.IsNanOrInfinity(value)) + m_velocity = Vector3.Zero; + else + m_velocity = value; PhysicsActor actor = PhysActor; if (actor != null) { if (actor.IsPhysical) { - actor.Velocity = value; + actor.Velocity = m_velocity; ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); } } @@ -957,14 +966,30 @@ namespace OpenSim.Region.Framework.Scenes } return m_angularVelocity; } - set { m_angularVelocity = value; } + set + { + if (Util.IsNanOrInfinity(value)) + m_angularVelocity = Vector3.Zero; + else + m_angularVelocity = value; + + PhysicsActor actor = PhysActor; + if ((actor != null) && actor.IsPhysical) + actor.RotationalVelocity = m_angularVelocity; + } } /// public Vector3 Acceleration { get { return m_acceleration; } - set { m_acceleration = value; } + set + { + if (Util.IsNanOrInfinity(value)) + m_acceleration = Vector3.Zero; + else + m_acceleration = value; + } } public string Description { get; set; } @@ -2610,7 +2635,7 @@ namespace OpenSim.Region.Framework.Scenes return; } - m_APIDIterations = 1 + (int)(Math.PI * APIDStrength); + APIDActive = true; } // Necessary to get the lookat deltas applied @@ -2624,7 +2649,7 @@ namespace OpenSim.Region.Framework.Scenes public void StopLookAt() { - APIDTarget = Quaternion.Identity; + APIDActive = false; } @@ -4873,20 +4898,44 @@ namespace OpenSim.Region.Framework.Scenes { try { - if (APIDTarget != Quaternion.Identity) + if (APIDActive) { - if (m_APIDIterations <= 1) + PhysicsActor pa = ParentGroup.RootPart.PhysActor; + if (pa == null || !pa.IsPhysical || APIDStrength < 0.04) { - UpdateRotation(APIDTarget); - APIDTarget = Quaternion.Identity; + StopLookAt(); return; } - Quaternion rot = Quaternion.Slerp(RotationOffset,APIDTarget,1.0f/(float)m_APIDIterations); - rot.Normalize(); - UpdateRotation(rot); + Quaternion currRot = GetWorldRotation(); + currRot.Normalize(); + + // difference between current orientation and desired orientation + Quaternion dR = new Quaternion(currRot.X, currRot.Y, currRot.Z, -currRot.W) * APIDTarget; - m_APIDIterations--; + // find axis of rotation to rotate to desired orientation + Vector3 axis = Vector3.UnitX; + float s = (float)Math.Sqrt(1.0f - dR.W * dR.W); + if (s >= 0.001) + { + float invS = 1.0f / s; + if (dR.W < 0) invS = -invS; + axis = new Vector3(dR.X * invS, dR.Y * invS, dR.Z * invS) * currRot; + axis.Normalize(); + } + + // angle between current and desired orientation + float angle = 2.0f * (float)Math.Acos(dR.W); + if (angle > Math.PI) + angle = 2.0f * (float)Math.PI - angle; + + // clamp strength to avoid overshoot + float strength = 1.0f / APIDStrength; + if (strength > 1.0) strength = 1.0f; + + // set angular velocity to rotate to desired orientation + // with velocity proportional to strength and angle + AngularVelocity = axis * angle * strength * (float)Math.PI; // This ensures that we'll check this object on the next iteration ParentGroup.QueueForUpdateCheck(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 0414f893c3..b0aa434829 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -378,6 +378,11 @@ namespace OpenSim.Region.Framework.Scenes /// public uint MovementFlag { get; private set; } + /// + /// Set this if we need to force a movement update on the next received AgentUpdate from the viewer. + /// + private const uint ForceUpdateMovementFlagValue = uint.MaxValue; + /// /// Is the agent stop control flag currently active? /// @@ -822,7 +827,7 @@ namespace OpenSim.Region.Framework.Scenes } private bool m_mouseLook; - private bool m_leftButtonDown; +// private bool m_leftButtonDown; private bool m_inTransit; @@ -1005,23 +1010,6 @@ namespace OpenSim.Region.Framework.Scenes Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge } - private Vector3[] GetWalkDirectionVectors() - { - Vector3[] vector = new Vector3[11]; - vector[0] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD - vector[1] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK - vector[2] = Vector3.UnitY; //LEFT - vector[3] = -Vector3.UnitY; //RIGHT - vector[4] = new Vector3(CameraAtAxis.Z, 0f, CameraUpAxis.Z); //UP - vector[5] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN - vector[6] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD_NUDGE - vector[7] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK_NUDGE - vector[8] = Vector3.UnitY; //LEFT_NUDGE - vector[9] = -Vector3.UnitY; //RIGHT_NUDGE - vector[10] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN_NUDGE - return vector; - } - #endregion #region Status Methods @@ -1267,7 +1255,7 @@ namespace OpenSim.Region.Framework.Scenes // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will // stall on the border crossing since the existing child agent will still have the last movement // recorded, which stops the input from being processed. - MovementFlag = 0; + MovementFlag = ForceUpdateMovementFlagValue; m_scene.EventManager.TriggerOnMakeRootAgent(this); @@ -1925,13 +1913,13 @@ namespace OpenSim.Region.Framework.Scenes /// public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) { - //m_log.DebugFormat( - // "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", - // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", +// Scene.Name, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); if (IsChildAgent) { - // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); +// m_log.DebugFormat("DEBUG: HandleAgentUpdate: child agent in {0}", Scene.Name); return; } @@ -1973,7 +1961,12 @@ namespace OpenSim.Region.Framework.Scenes // DrawDistance = Scene.DefaultDrawDistance; m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; - m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; + + // FIXME: This does not work as intended because the viewer only sends the lbutton down when the button + // is first pressed, not whilst it is held down. If this is required in the future then need to look + // for an AGENT_CONTROL_LBUTTON_UP event and make sure to handle cases where an initial DOWN is not + // received (e.g. on holding LMB down on the avatar in a viewer). +// m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; #endregion Inputs @@ -2066,6 +2059,14 @@ namespace OpenSim.Region.Framework.Scenes bool update_movementflag = false; + // If we were just made root agent then we must perform movement updates for the first AgentUpdate that + // we get + if (MovementFlag == ForceUpdateMovementFlagValue) + { + MovementFlag = 0; + update_movementflag = true; + } + if (agentData.UseClientAgentPosition) { MovingToTarget = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; @@ -2097,15 +2098,6 @@ namespace OpenSim.Region.Framework.Scenes { bool bAllowUpdateMoveToPosition = false; - Vector3[] dirVectors; - - // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying - // this prevents 'jumping' in inappropriate situations. - if (!Flying && (m_mouseLook || m_leftButtonDown)) - dirVectors = GetWalkDirectionVectors(); - else - dirVectors = Dir_Vectors; - // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) { @@ -2115,7 +2107,9 @@ namespace OpenSim.Region.Framework.Scenes try { - agent_control_v3 += dirVectors[i]; + // Don't slide against ground when crouching if camera is panned around avatar + if (Flying || DCF != Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN) + agent_control_v3 += Dir_Vectors[i]; //m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]); } catch (IndexOutOfRangeException) @@ -3149,7 +3143,17 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", // vec, Rotation, thisAddSpeedModifier, Name); - Vector3 direc = vec * Rotation; + Quaternion rot = Rotation; + if (!(Flying && m_mouseLook) && (PresenceType != PresenceType.Npc)) + { + // The only situation in which we care about X and Y is in mouselook flying. The rest of the time + // these parameters are not relevant for determining avatar movement direction and cause issues such + // as wrong walk speed if the camera is rotated. + rot.X = 0; + rot.Y = 0; + } + + Vector3 direc = vec * rot; direc.Normalize(); if (Flying != FlyingOld) // add for fly velocity control diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs new file mode 100644 index 0000000000..1d41d3381d --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs @@ -0,0 +1,347 @@ +/* + * 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 Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Region.CoreModules.Framework.EntityTransfer; +using OpenSim.Region.CoreModules.Framework.InventoryAccess; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; +using OpenSim.Region.CoreModules.World.Permissions; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenSim.Tests.Common; + +namespace OpenSim.Region.Framework.Scenes.Tests +{ + /// + /// Test copying of scene objects. + /// + /// + /// This is at a level above the SceneObjectBasicTests, which act on the scene directly. + /// + [TestFixture] + public class SceneObjectCopyTests : OpenSimTestCase + { + [TestFixtureSetUp] + public void FixtureInit() + { + // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. + // This facility was added after the original async delete tests were written, so it may be possible now + // to not bother explicitly disabling their async (since everything will be running sync). + Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; + } + + [TestFixtureTearDown] + 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 so none of them require async stuff (which regression + // tests really shouldn't). + Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; + } + + [Test] + public void TestTakeCopyWhenCopierIsOwnerWithPerms() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); + + TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); + SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); + UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); + TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient; + + // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. + AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; + sogd.Enabled = false; + + SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", ua.PrincipalID); + uint soLocalId = so.LocalId; +// so.UpdatePermissions( +// ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Copy, 1); +// so.UpdatePermissions( +// ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0); +// so.UpdatePermissions( +// ua.PrincipalID, (byte)PermissionWho.Base, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0); +// scene.HandleObjectPermissionsUpdate(client, client.AgentId, client.SessionId, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0); + + // Ideally we might change these via client-focussed method calls as commented out above. However, this + // becomes very convoluted so we will set only the copy perm directly. + so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Copy; +// so.RootPart.OwnerMask = (uint)OpenMetaverse.PermissionMask.Copy; + + List localIds = new List(); + localIds.Add(so.LocalId); + + // Specifying a UUID.Zero in this case will currently plop it in Lost and Found + scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); + + // Check that object isn't copied until we crank the sogd handle. + SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart, Is.Not.Null); + Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); + + sogd.InventoryDeQueueAndDelete(); + + // Check that object is still there. + SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart2, Is.Not.Null); + Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); + + // Check that we have a copy in inventory + InventoryItemBase item + = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Lost And Found/so1"); + Assert.That(item, Is.Not.Null); + } + + [Test] + public void TestTakeCopyWhenCopierIsOwnerWithoutPerms() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); + + TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); + SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); + UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); + TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient; + + // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. + AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; + sogd.Enabled = false; + + SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", ua.PrincipalID); + uint soLocalId = so.LocalId; + + so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.All & ~OpenMetaverse.PermissionMask.Copy); + //so.RootPart.OwnerMask = (uint)(OpenMetaverse.PermissionMask.Copy & ~OpenMetaverse.PermissionMask.Copy); + + List localIds = new List(); + localIds.Add(so.LocalId); + + // Specifying a UUID.Zero in this case will currently plop it in Lost and Found + scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); + + // Check that object isn't copied until we crank the sogd handle. + SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart, Is.Not.Null); + Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); + + sogd.InventoryDeQueueAndDelete(); + + // Check that object is still there. + SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart2, Is.Not.Null); + Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); + + // Check that we do not have a copy in inventory + InventoryItemBase item + = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Lost And Found/so1"); + Assert.That(item, Is.Null); + } + + [Test] + public void TestTakeCopyWhenCopierIsNotOwnerWithPerms() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); + + TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); + SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); + UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); + TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient; + + // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. + AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; + sogd.Enabled = false; + + SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", TestHelpers.ParseTail(0x2)); + uint soLocalId = so.LocalId; + + // Base must allow transfer and copy + so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.Copy | OpenMetaverse.PermissionMask.Transfer); + // Must be set so anyone can copy + so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy; + + List localIds = new List(); + localIds.Add(so.LocalId); + + // Specifying a UUID.Zero in this case will plop it in the Objects folder + scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); + + // Check that object isn't copied until we crank the sogd handle. + SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart, Is.Not.Null); + Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); + + sogd.InventoryDeQueueAndDelete(); + + // Check that object is still there. + SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart2, Is.Not.Null); + Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); + + // Check that we have a copy in inventory + InventoryItemBase item + = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1"); + Assert.That(item, Is.Not.Null); + } + + [Test] + public void TestTakeCopyWhenCopierIsNotOwnerWithoutPerms() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); + + TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); + SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); + UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); + TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient; + + // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. + AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; + sogd.Enabled = false; + + SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", TestHelpers.ParseTail(0x2)); + uint soLocalId = so.LocalId; + + { + // Check that object is not copied if copy base perms is missing. + // Should not allow copy if base does not have this. + so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Transfer; + // Must be set so anyone can copy + so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy; + + // Check that object is not copied + List localIds = new List(); + localIds.Add(so.LocalId); + + // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms + scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); + + // Check that object isn't copied until we crank the sogd handle. + SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart, Is.Not.Null); + Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); + + sogd.InventoryDeQueueAndDelete(); + // Check that object is still there. + SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart2, Is.Not.Null); + Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); + + // Check that we have a copy in inventory + InventoryItemBase item + = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1"); + Assert.That(item, Is.Null); + } + + { + // Check that object is not copied if copy trans perms is missing. + // Should not allow copy if base does not have this. + so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Copy; + // Must be set so anyone can copy + so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy; + + // Check that object is not copied + List localIds = new List(); + localIds.Add(so.LocalId); + + // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms + scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); + + // Check that object isn't copied until we crank the sogd handle. + SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart, Is.Not.Null); + Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); + + sogd.InventoryDeQueueAndDelete(); + // Check that object is still there. + SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart2, Is.Not.Null); + Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); + + // Check that we have a copy in inventory + InventoryItemBase item + = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1"); + Assert.That(item, Is.Null); + } + + { + // Check that object is not copied if everyone copy perms is missing. + // Should not allow copy if base does not have this. + so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.Copy | OpenMetaverse.PermissionMask.Transfer); + // Make sure everyone perm does not allow copy + so.RootPart.EveryoneMask = (uint)(OpenMetaverse.PermissionMask.All & ~OpenMetaverse.PermissionMask.Copy); + + // Check that object is not copied + List localIds = new List(); + localIds.Add(so.LocalId); + + // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms + scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); + + // Check that object isn't copied until we crank the sogd handle. + SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart, Is.Not.Null); + Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); + + sogd.InventoryDeQueueAndDelete(); + // Check that object is still there. + SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart2, Is.Not.Null); + Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); + + // Check that we have a copy in inventory + InventoryItemBase item + = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1"); + Assert.That(item, Is.Null); + } + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 9655d19cef..8ec69740e7 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Tests // Create an object embedded inside the first UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); - TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID); + TaskInventoryHelpers.AddSceneObject(scene.AssetService, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID); TaskInventoryItem addedItem = sop1.Inventory.GetInventoryItem(taskSceneObjectItemId); Assert.That(addedItem.ItemID, Is.EqualTo(taskSceneObjectItemId)); @@ -88,7 +88,7 @@ namespace OpenSim.Region.Framework.Tests // Create an object embedded inside the first UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); TaskInventoryItem taskSceneObjectItem - = TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID); + = TaskInventoryHelpers.AddSceneObject(scene.AssetService, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID); scene.AddSceneObject(sog1); @@ -129,7 +129,7 @@ namespace OpenSim.Region.Framework.Tests SceneObjectPart sop1 = sog1.RootPart; TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard( - scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); + scene.AssetService, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); InventoryFolderBase folder = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; @@ -162,7 +162,7 @@ namespace OpenSim.Region.Framework.Tests SceneObjectPart sop1 = sog1.RootPart; TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard( - scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); + scene.AssetService, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); // Perform test string message; diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index 4ae27d7b85..937c4149e4 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -89,7 +89,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - + UUID ownerId = TestHelpers.ParseTail(0x10); UUID embeddedId = TestHelpers.ParseTail(0x20); UUID secondLevelEmbeddedId = TestHelpers.ParseTail(0x21); @@ -120,5 +120,39 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(embeddedId)); Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(secondLevelEmbeddedId)); } + + [Test] + public void TestTaskItems() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + UUID ownerId = TestHelpers.ParseTail(0x10); + + SceneObjectGroup soL0 = SceneHelpers.CreateSceneObject(1, ownerId, "l0", 0x20); + SceneObjectGroup soL1 = SceneHelpers.CreateSceneObject(1, ownerId, "l1", 0x21); + SceneObjectGroup soL2 = SceneHelpers.CreateSceneObject(1, ownerId, "l2", 0x22); + + TaskInventoryHelpers.AddScript( + m_assetService, soL2.RootPart, TestHelpers.ParseTail(0x33), TestHelpers.ParseTail(0x43), "l3-script", "gibberish"); + + TaskInventoryHelpers.AddSceneObject( + m_assetService, soL1.RootPart, "l2-item", TestHelpers.ParseTail(0x32), soL2, TestHelpers.ParseTail(0x42)); + TaskInventoryHelpers.AddSceneObject( + m_assetService, soL0.RootPart, "l1-item", TestHelpers.ParseTail(0x31), soL1, TestHelpers.ParseTail(0x41)); + + m_uuidGatherer.AddForInspection(soL0); + m_uuidGatherer.GatherAll(); + +// foreach (UUID key in m_uuidGatherer.GatheredUuids.Keys) +// System.Console.WriteLine("key : {0}", key); + + // We expect to see the default prim texture and the assets of the contained task items + Assert.That(m_uuidGatherer.GatheredUuids.Count, Is.EqualTo(4)); + Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(new UUID(Constants.DefaultTexture))); + Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(TestHelpers.ParseTail(0x41))); + Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(TestHelpers.ParseTail(0x42))); + Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(TestHelpers.ParseTail(0x43))); + } } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 69dc133668..9ec4e1d003 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -123,6 +123,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_assetUuidsToInspect.Contains(uuid)) return false; +// m_log.DebugFormat("[UUID GATHERER]: Adding asset {0} for inspection", uuid); + m_assetUuidsToInspect.Enqueue(uuid); return true; @@ -238,7 +240,11 @@ namespace OpenSim.Region.Framework.Scenes if (Complete) return false; - GetAssetUuids(m_assetUuidsToInspect.Dequeue()); + UUID nextToInspect = m_assetUuidsToInspect.Dequeue(); + +// m_log.DebugFormat("[UUID GATHERER]: Inspecting asset {0}", nextToInspect); + + GetAssetUuids(nextToInspect); return true; } @@ -322,8 +328,6 @@ namespace OpenSim.Region.Framework.Scenes // Here, we want to collect uuids which require further asset fetches but mark the others as gathered try { - GatheredUuids[assetUuid] = assetType; - if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType || (sbyte)AssetType.Gesture == assetType @@ -334,11 +338,15 @@ namespace OpenSim.Region.Framework.Scenes { AddForInspection(assetUuid); } + else + { + GatheredUuids[assetUuid] = assetType; + } } catch (Exception) { m_log.ErrorFormat( - "[ITERATABLE UUID GATHERER]: Failed to gather uuids for asset id {0}, type {1}", + "[UUID GATHERER]: Failed to gather uuids for asset id {0}, type {1}", assetUuid, assetType); throw; } diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index ea582faf01..3ce6178a60 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -67,18 +67,17 @@ namespace OpenSim.Region.OptionalModules.Materials private bool m_enabled = false; public Dictionary m_regionMaterials = new Dictionary(); - + public void Initialise(IConfigSource source) { + m_enabled = true; // default is enabled + IConfig config = source.Configs["Materials"]; - if (config == null) - return; + if (config != null) + m_enabled = config.GetBoolean("enable_materials", m_enabled); - m_enabled = config.GetBoolean("enable_materials", true); - if (!m_enabled) - return; - - m_log.DebugFormat("[Materials]: Initialized"); + if (m_enabled) + m_log.DebugFormat("[Materials]: Initialized"); } public void Close() diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index f5a25d68cb..f934b8a32a 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -785,6 +785,14 @@ namespace OpenSim.Region.Physics.OdePlugin } } + private void setAngularVelocity(float x, float y, float z) + { + if (Body != (IntPtr)0) + { + d.BodySetAngularVel(Body, x, y, z); + } + } + /// /// Stop a prim from being subject to physics. /// @@ -2645,6 +2653,7 @@ Console.WriteLine(" JointCreateFixed"); if (value.IsFinite()) { m_rotationalVelocity = value; + setAngularVelocity(value.X, value.Y, value.Z); } else { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 97e3eeb170..23b74ce9ee 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3092,26 +3092,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Determine where we are looking from LSL_Vector from = llGetPos(); - // Work out the normalised vector from the source to the target - LSL_Vector delta = llVecNorm(target - from); - LSL_Vector angle = new LSL_Vector(0,0,0); + // normalized direction to target + LSL_Vector dir = llVecNorm(target - from); + // use vertical to help compute left axis + LSL_Vector up = new LSL_Vector(0.0, 0.0, 1.0); + // find normalized left axis parallel to horizon + LSL_Vector left = llVecNorm(LSL_Vector.Cross(up, dir)); + // make up orthogonal to left and dir + up = LSL_Vector.Cross(dir, left); - // Calculate the yaw - // subtracting PI_BY_TWO is required to compensate for the odd SL co-ordinate system - angle.x = llAtan2(delta.z, delta.y) - ScriptBaseClass.PI_BY_TWO; - - // Calculate pitch - angle.y = llAtan2(delta.x, llSqrt((delta.y * delta.y) + (delta.z * delta.z))); - - // we need to convert from a vector describing - // the angles of rotation in radians into rotation value - LSL_Rotation rot = llEuler2Rot(angle); + // compute rotation based on orthogonal axes + LSL_Rotation rot = new LSL_Rotation(0.0, 0.707107, 0.0, 0.707107) * llAxes2Rot(dir, left, up); // Per discussion with Melanie, for non-physical objects llLookAt appears to simply // set the rotation of the object, copy that behavior PhysicsActor pa = m_host.PhysActor; - if (strength == 0 || pa == null || !pa.IsPhysical) + if (m_host.ParentGroup.IsAttachment || strength == 0 || pa == null || !pa.IsPhysical) { llSetRot(rot); } @@ -9012,7 +9009,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api res.Add(new LSL_Vector(textColor.R, textColor.G, textColor.B)); - res.Add(new LSL_Float(textColor.A)); + res.Add(new LSL_Float(1.0 - textColor.A)); break; case (int)ScriptBaseClass.PRIM_NAME: res.Add(new LSL_String(part.Name)); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs index 14e45ff7e9..e35de9c762 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs @@ -100,7 +100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests SceneHelpers.SetupSceneModules(m_scene, new IniConfigSource(), m_engine, m_urlModule); SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); - m_scriptItem = TaskInventoryHelpers.AddScript(m_scene, so.RootPart); + m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, so.RootPart); // This is disconnected from the actual script - the mock engine does not set up any LSL_Api atm. // Possibly this could be done and we could obtain it directly from the MockScriptEngine. diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs index 9fd8532bc4..3ff4c6b747 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs @@ -91,7 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Create an object embedded inside the first UUID itemId = TestHelpers.ParseTail(0x20); - TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, userId); + TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, userId); LSL_Api api = new LSL_Api(); api.Initialize(m_engine, so1.RootPart, null, null); @@ -131,7 +131,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Create an object embedded inside the first UUID itemId = TestHelpers.ParseTail(0x20); - TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, user1Id); + TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id); // Create a second object SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); @@ -188,7 +188,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Create an object embedded inside the first UUID itemId = TestHelpers.ParseTail(0x20); - TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, user1Id); + TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id); UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id); @@ -223,7 +223,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Create an object embedded inside the first UUID itemId = TestHelpers.ParseTail(0x20); TaskInventoryItem tii - = TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, user1Id); + = TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id); tii.NextPermissions &= ~((uint)PermissionMask.Modify); UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id); @@ -251,7 +251,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests m_scene.AddSceneObject(sourceSo); LSL_Api api = new LSL_Api(); api.Initialize(m_engine, sourceSo.RootPart, null, null); - TaskInventoryHelpers.AddScript(m_scene, sourceSo.RootPart, "script", "Hello World"); + TaskInventoryHelpers.AddScript(m_scene.AssetService, sourceSo.RootPart, "script", "Hello World"); SceneObjectGroup targetSo = SceneHelpers.AddSceneObject(m_scene, "targetSo", user1Id); SceneObjectGroup otherOwnedTargetSo = SceneHelpers.AddSceneObject(m_scene, "otherOwnedTargetSo", user2Id); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs index f347869e1c..b6f5e099c2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs @@ -92,7 +92,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // FIXME: This should really be a script item (with accompanying script) TaskInventoryItem grp1Item = TaskInventoryHelpers.AddNotecard( - m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); + m_scene.AssetService, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); @@ -126,7 +126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // FIXME: This should really be a script item (with accompanying script) TaskInventoryItem grp1Item = TaskInventoryHelpers.AddNotecard( - m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); + m_scene.AssetService, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; @@ -155,7 +155,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // FIXME: This should really be a script item (with accompanying script) TaskInventoryItem grp1Item = TaskInventoryHelpers.AddNotecard( - m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); + m_scene.AssetService, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs index b9028ab385..2ac12cb890 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs @@ -61,7 +61,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests SceneHelpers.SetupSceneModules(m_scene, new IniConfigSource(), m_engine); m_so = SceneHelpers.AddSceneObject(m_scene); - m_scriptItem = TaskInventoryHelpers.AddScript(m_scene, m_so.RootPart); + m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, m_so.RootPart); // This is disconnected from the actual script - the mock engine does not set up any LSL_Api atm. // Possibly this could be done and we could obtain it directly from the MockScriptEngine. @@ -77,7 +77,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests string[] ncLines = { "One", "Twoè", "Three" }; TaskInventoryItem ncItem - = TaskInventoryHelpers.AddNotecard(m_scene, m_so.RootPart, "nc", "1", "10", string.Join("\n", ncLines)); + = TaskInventoryHelpers.AddNotecard(m_scene.AssetService, m_so.RootPart, "nc", "1", "10", string.Join("\n", ncLines)); AssertValidNotecardLine(ncItem.Name, 0, ncLines[0]); AssertValidNotecardLine(ncItem.Name, 2, ncLines[2]); @@ -102,7 +102,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests { TestHelpers.InMethod(); - TaskInventoryItem ncItem = TaskInventoryHelpers.AddScript(m_scene, m_so.RootPart, "nc1", "Not important"); + TaskInventoryItem ncItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, m_so.RootPart, "nc1", "Not important"); AssertInValidNotecardLine(ncItem.Name, 0); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiUserTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiUserTests.cs index 6424ea1584..40082b5c4d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiUserTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiUserTests.cs @@ -68,7 +68,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, userId); SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; - TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, part); + TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, part); LSL_Api apiGrp1 = new LSL_Api(); apiGrp1.Initialize(m_engine, part, scriptItem, null); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs index caba4a4a4c..2fe558a7e6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs @@ -96,7 +96,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID); SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); - TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); + TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, inWorldObj.RootPart); new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); OSSL_Api osslApi = new OSSL_Api(); @@ -105,7 +105,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ua1.PrincipalID); // Create an object embedded inside the first - TaskInventoryHelpers.AddSceneObject(m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); + TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint); @@ -142,7 +142,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID); SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); - TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); + TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, inWorldObj.RootPart); new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); OSSL_Api osslApi = new OSSL_Api(); @@ -150,7 +150,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Create an object embedded inside the first TaskInventoryHelpers.AddNotecard( - m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900), "Hello World!"); + m_scene.AssetService, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900), "Hello World!"); bool exceptionCaught = false; @@ -190,7 +190,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1); SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); - TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); + TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, inWorldObj.RootPart); new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); OSSL_Api osslApi = new OSSL_Api(); @@ -198,7 +198,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Create an object embedded inside the first TaskInventoryHelpers.AddSceneObject( - m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); + m_scene.AssetService, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, ua2); diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEnginePersistenceTests.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEnginePersistenceTests.cs index 5b7e5f7722..2ef405861e 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEnginePersistenceTests.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEnginePersistenceTests.cs @@ -114,7 +114,7 @@ namespace OpenSim.Region.ScriptEngine.Tests SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10); TaskInventoryHelpers.AddScript( - scene, + scene.AssetService, so.RootPart, "scriptItem", "default { attach(key id) { if (id != NULL_KEY) { llSay(0, \"Hello World\"); } } }"); diff --git a/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs index 9d01b4785d..37f93749b8 100644 --- a/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs +++ b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs @@ -248,7 +248,6 @@ namespace OpenSim.Service.Connectors public void StoreEstateSettings(EstateSettings es) { - string reply = string.Empty; // /estates/estate/ string uri = m_ServerURI + ("/estates/estate"); @@ -260,7 +259,6 @@ namespace OpenSim.Service.Connectors public bool LinkRegion(UUID regionID, int estateID) { - string reply = string.Empty; // /estates/estate/?eid=int®ion=uuid string uri = m_ServerURI + String.Format("/estates/estate/?eid={0}®ion={1}", estateID, regionID); diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs index b4bd50b745..3a3b33a6a9 100644 --- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs @@ -43,7 +43,7 @@ namespace OpenSim.Tests.Common /// /// Add a notecard item to the given part. /// - /// + /// /// /// /// UUID or UUID stem @@ -51,16 +51,16 @@ namespace OpenSim.Tests.Common /// The tex to put in the notecard. /// The item that was added public static TaskInventoryItem AddNotecard( - Scene scene, SceneObjectPart part, string itemName, string itemIDStem, string assetIDStem, string text) + IAssetService assetService, SceneObjectPart part, string itemName, string itemIDStem, string assetIDStem, string text) { return AddNotecard( - scene, part, itemName, TestHelpers.ParseStem(itemIDStem), TestHelpers.ParseStem(assetIDStem), text); + assetService, part, itemName, TestHelpers.ParseStem(itemIDStem), TestHelpers.ParseStem(assetIDStem), text); } /// /// Add a notecard item to the given part. /// - /// + /// /// /// /// @@ -68,7 +68,7 @@ namespace OpenSim.Tests.Common /// The tex to put in the notecard. /// The item that was added public static TaskInventoryItem AddNotecard( - Scene scene, SceneObjectPart part, string itemName, UUID itemID, UUID assetID, string text) + IAssetService assetService, SceneObjectPart part, string itemName, UUID itemID, UUID assetID, string text) { AssetNotecard nc = new AssetNotecard(); nc.BodyText = text; @@ -76,7 +76,7 @@ namespace OpenSim.Tests.Common AssetBase ncAsset = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero); - scene.AssetService.Store(ncAsset); + assetService.Store(ncAsset); TaskInventoryItem ncItem = new TaskInventoryItem @@ -94,12 +94,12 @@ namespace OpenSim.Tests.Common /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these /// functions more than once in a test. /// - /// + /// /// /// The item that was added - public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part) + public static TaskInventoryItem AddScript(IAssetService assetService, SceneObjectPart part) { - return AddScript(scene, part, "scriptItem", "default { state_entry() { llSay(0, \"Hello World\"); } }"); + return AddScript(assetService, part, "scriptItem", "default { state_entry() { llSay(0, \"Hello World\"); } }"); } /// @@ -109,15 +109,15 @@ namespace OpenSim.Tests.Common /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather /// than a random component. /// - /// + /// /// /// Name of the script to add /// LSL script source /// The item that was added public static TaskInventoryItem AddScript( - Scene scene, SceneObjectPart part, string scriptName, string scriptSource) + IAssetService assetService, SceneObjectPart part, string scriptName, string scriptSource) { - return AddScript(scene, part, UUID.Random(), UUID.Random(), scriptName, scriptSource); + return AddScript(assetService, part, UUID.Random(), UUID.Random(), scriptName, scriptSource); } /// @@ -127,7 +127,7 @@ namespace OpenSim.Tests.Common /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather /// than a random component. /// - /// + /// /// /// Item UUID for the script /// Asset UUID for the script @@ -135,7 +135,7 @@ namespace OpenSim.Tests.Common /// LSL script source /// The item that was added public static TaskInventoryItem AddScript( - Scene scene, SceneObjectPart part, UUID itemId, UUID assetId, string scriptName, string scriptSource) + IAssetService assetService, SceneObjectPart part, UUID itemId, UUID assetId, string scriptName, string scriptSource) { AssetScriptText ast = new AssetScriptText(); ast.Source = scriptSource; @@ -143,7 +143,7 @@ namespace OpenSim.Tests.Common AssetBase asset = AssetHelpers.CreateAsset(assetId, AssetType.LSLText, ast.AssetData, UUID.Zero); - scene.AssetService.Store(asset); + assetService.Store(asset); TaskInventoryItem item = new TaskInventoryItem { Name = scriptName, AssetID = assetId, ItemID = itemId, @@ -153,6 +153,37 @@ namespace OpenSim.Tests.Common return item; } + /// + /// Add a scene object item to the given part. + /// + /// + /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these + /// functions more than once in a test. + /// + /// + /// + /// + /// + /// + /// + /// + public static TaskInventoryItem AddSceneObject( + IAssetService assetService, SceneObjectPart sop, string itemName, UUID itemId, SceneObjectGroup soToAdd, UUID soAssetId) + { + AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(soAssetId, soToAdd); + assetService.Store(taskSceneObjectAsset); + TaskInventoryItem taskSceneObjectItem + = new TaskInventoryItem + { Name = itemName, + AssetID = taskSceneObjectAsset.FullID, + ItemID = itemId, + OwnerID = soToAdd.OwnerID, + Type = (int)AssetType.Object, + InvType = (int)InventoryType.Object }; + sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); + + return taskSceneObjectItem; + } /// /// Add a scene object item to the given part. @@ -162,28 +193,18 @@ namespace OpenSim.Tests.Common /// functions more than once in a test. /// /// - /// + /// /// /// /// /// public static TaskInventoryItem AddSceneObject( - Scene scene, SceneObjectPart sop, string itemName, UUID id, UUID userId) + IAssetService assetService, SceneObjectPart sop, string itemName, UUID itemId, UUID userId) { - SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, UUID.Zero); - AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); - scene.AssetService.Store(taskSceneObjectAsset); - TaskInventoryItem taskSceneObjectItem - = new TaskInventoryItem - { Name = itemName, - AssetID = taskSceneObjectAsset.FullID, - ItemID = id, - OwnerID = userId, - Type = (int)AssetType.Object, - InvType = (int)InventoryType.Object }; - sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); + SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, userId); - return taskSceneObjectItem; + return TaskInventoryHelpers.AddSceneObject( + assetService, sop, itemName, itemId, taskSceneObject, TestHelpers.ParseTail(0x10)); } } } \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs index a8883b8fa2..c97a765f50 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs @@ -185,7 +185,7 @@ namespace OpenSim.Tests.Common public void addInventoryItem(InventoryItemBase item) { -// InventoryFolderBase folder = m_folders[item.Folder]; + InventoryFolderBase folder = m_folders[item.Folder]; // m_log.DebugFormat( // "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID); diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs index be3a0cbaf9..2b272e6168 100644 --- a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs @@ -46,20 +46,33 @@ namespace OpenSim.Tests.Common public XInventoryItem[] GetItems(string[] fields, string[] vals) { +// Console.WriteLine( +// "Requesting items, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals)); + List origItems = Get(fields, vals, m_allItems.Values.ToList()); - return origItems.Select(i => i.Clone()).ToArray(); + XInventoryItem[] items = origItems.Select(i => i.Clone()).ToArray(); + +// Console.WriteLine("Found {0} items", items.Length); +// Array.ForEach(items, i => Console.WriteLine("Found item {0} {1}", i.inventoryName, i.inventoryID)); + + return items; } public XInventoryFolder[] GetFolders(string[] fields, string[] vals) { // Console.WriteLine( -// "Requesting folders, fields {0}, vals {1}", string.Join(",", fields), string.Join(",", vals)); +// "Requesting folders, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals)); List origFolders = Get(fields, vals, m_allFolders.Values.ToList()); - return origFolders.Select(f => f.Clone()).ToArray(); + XInventoryFolder[] folders = origFolders.Select(f => f.Clone()).ToArray(); + +// Console.WriteLine("Found {0} folders", folders.Length); +// Array.ForEach(folders, f => Console.WriteLine("Found folder {0} {1}", f.folderName, f.folderID)); + + return folders; } public bool StoreFolder(XInventoryFolder folder) @@ -75,7 +88,9 @@ namespace OpenSim.Tests.Common { m_allItems[item.inventoryID] = item.Clone(); -// Console.WriteLine("Added item {0} {1}, creator {2}, owner {3}", item.inventoryName, item.inventoryID, item.creatorID, item.avatarID); +// Console.WriteLine( +// "Added item {0} {1}, folder {2}, creator {3}, owner {4}", +// item.inventoryName, item.inventoryID, item.parentFolderID, item.creatorID, item.avatarID); return true; } diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 987d8b2265..39ee520c73 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -187,12 +187,13 @@ ;; YOU HAVE BEEN WARNED!!! ; TrustBinaries = false - ;# {CombineContiguousRegions} {} {Create megaregions where possible? (Do not use with existing content!)} {true false} false + ;# {CombineContiguousRegions} {} {Create megaregions where possible? (Do not use with existing content or varregions!)} {true false} false ;; Combine all contiguous regions into one large megaregion ;; Order your regions from South to North, West to East in your regions.ini ;; and then set this to true ;; Warning! Don't use this with regions that have existing content!, ;; This will likely break them + ;; Also, this setting should be set to false for varregions as they are proper larger single regions rather than combined smaller regions. ; CombineContiguousRegions = false ;# {InworldRestartShutsDown} {} {Shutdown instance on region restart?} {true false} false diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll index ddc2f48573..6d006bf593 100755 Binary files a/bin/lib32/BulletSim.dll and b/bin/lib32/BulletSim.dll differ diff --git a/bin/lib32/libBulletSim.dylib b/bin/lib32/libBulletSim.dylib index 3c2de2dd9f..b7a42e374b 100755 Binary files a/bin/lib32/libBulletSim.dylib and b/bin/lib32/libBulletSim.dylib differ diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so index 86375283bc..ec29f58f61 100755 Binary files a/bin/lib32/libBulletSim.so and b/bin/lib32/libBulletSim.so differ diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll index 60fa59e4f5..82774a22f0 100755 Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ diff --git a/bin/lib64/libBulletSim.so b/bin/lib64/libBulletSim.so index e3df064899..8b092751d7 100755 Binary files a/bin/lib64/libBulletSim.so and b/bin/lib64/libBulletSim.so differ