From 57094bd0177e656ce1ed08df87b19657a6043c68 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 8 Jul 2012 13:02:02 -0400 Subject: [PATCH 1/6] Add more automation keys to OpenSim.ini.example --- bin/OpenSim.ini.example | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index c07e1abeea..ce571ee2d9 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -61,17 +61,20 @@ ;; Place to create a PID file ; PIDFile = "/tmp/my.pid" + ;# {region_info_source} {} {Where to load region from?} {filesystem web} filesystem ;; Determine where OpenSimulator looks for the files which tell it ;; which regions to server ;; Default is "filesystem" ; region_info_source = "filesystem" ; region_info_source = "web" - + + ;# {regionload_regionsdir} {region_info_source} {Location of file?} {} Regions ;; Determines where the region XML files are stored if you are loading ;; these from the filesystem. ;; Defaults to bin/Regions in your OpenSimulator installation directory ; regionload_regionsdir="C:\somewhere\xmlfiles\" + ;# {regionload_webserver_url} {region_info_source} {URL to load region from?} {} ;; Determines the page from which regions xml is retrieved if you are ;; loading these from the web. ;; The XML here has the same format as it does on the filesystem @@ -92,6 +95,7 @@ ;; Maximum size where a prim can be physical. Affects resizing of existing prims. This can be overriden in the region config file. ; PhysicalPrimMax = 10 + ;# {ClampPrimSize} {} {Clamp viewer rezzed prims to max sizes?} {true false} false ;; If a viewer attempts to rez a prim larger than the non-physical or physical prim max, clamp the dimensions to the appropriate maximum ;; This can be overriden in the region config file. ; ClampPrimSize = false @@ -117,6 +121,7 @@ ;; This will likely break them ; CombineContiguousRegions = false + ;# {InworldRestartShutsDown} {} {Shutdown instance on region restart?} {true false} false ;; If you have only one region in an instance, or to avoid the many bugs ;; that you can trigger in modules by restarting a region, set this to ;; true to make the entire instance exit instead of restarting the region. @@ -131,14 +136,17 @@ ;; If both of these values are set to zero then persistence of all changed ;; objects will happen on every sweep. + ;# {MinimumTimeBeforePersistenceConsidered} {} {Time before un-changed object may be persisted} {} 60 ;; Objects will be considered for persistance in the next sweep when they ;; have not changed for this number of seconds. ; MinimumTimeBeforePersistenceConsidered = 60 + ;# {MaximumTimeBeforePersistenceConsidered} {} {Time before changed objects may be persisted?} {} 600 ;; Objects will always be considered for persistance in the next sweep ;; if the first change occurred this number of seconds ago. ; MaximumTimeBeforePersistenceConsidered = 600 + ;# {see_into_this_sim_from_neighbor} {} {Should avatars in neighbor sims see objects in this sim?} {true false} true ;; Should avatars in neighbor sims see objects in this sim? ; see_into_this_sim_from_neighbor = true @@ -153,6 +161,7 @@ ;; Note that only the ODE physics engine currently deals with meshed ;; prims in a satisfactory way. + ;# {meshing} {} {Select mesher} {Meshmerizer ZeroMesher} Meshmerizer ;; ZeroMesher is faster but leaves the physics engine to model the mesh ;; using the basic shapes that it supports. ;; Usually this is only a box. @@ -161,6 +170,7 @@ ; meshing = ZeroMesher ;; Choose one of the physics engines below + ;# {physics} {} {Select physics engine} {OpenDynamicsEngine BulletSim basicphysics POS} OpenDynamicsEngine ;; OpenDynamicsEngine is by some distance the most developed physics engine ;; BulletSim is incomplete and experimental but in active development ;; basicphysics effectively does not model physics at all, making all objects phantom @@ -184,38 +194,52 @@ ;; If set to true, then all permissions checks are carried out ; serverside_object_permissions = true + ;# {allow_grid_gods} {} {Allow grid gods?} {true false} false ;; This allows users with a UserLevel of 200 or more to assume god ;; powers in the regions in this simulator. ; allow_grid_gods = false ;; This allows some control over permissions ;; please note that this still doesn't duplicate SL, and is not intended to + ;# {region_owner_is_god} {} {Allow region owner gods} {true false} true + ;; Allow region owners to assume god powers in their regions ; region_owner_is_god = true + + ;# {region_manager_is_god} {} {Allow region manager gods} {true false} false + ;; Allow region managers to assume god powers in regions they manage ; region_manager_is_god = false + + ;# {parcel_owner_is_god} {} {Allow parcel owner gods} {true false} true + ;; Allow parcel owners to assume god powers in their parcels ; parcel_owner_is_god = true + ;# {simple_build_permissions} {} {Allow building in parcel by access list (no groups)} {true false} false ;; More control over permissions ;; This is definitely not SL! - ; Provides a simple control for land owners to give build rights to specific avatars - ; in publicly accessible parcels that disallow object creation in general. - ; Owners specific avatars by adding them to the Access List of the parcel - ; without having to use the Groups feature + ;; Provides a simple control for land owners to give build rights to specific avatars + ;; in publicly accessible parcels that disallow object creation in general. + ;; Owners specific avatars by adding them to the Access List of the parcel + ;; without having to use the Groups feature ; simple_build_permissions = false + ;# {DefaultScriptEngine} {} {Default script engine} {XEngine} XEngine ;; Default script engine to use. Currently, we only have XEngine ; DefaultScriptEngine = "XEngine" + ;# {GenerateMaptiles} {} {Generate map tiles?} {true false} true ;; Map tile options. You can choose to generate no map tiles at all, ;; generate normal maptiles, or nominate an uploaded texture to ;; be the map tile ; GenerateMaptiles = true + ;# {MaptileRefresh} {GenerateMaptiles} {Maptile refresh period?} {} 0 ;; If desired, a running region can update the map tiles periodically ;; to reflect building activity. This names no sense of you don't have ;; prims on maptiles. Value is in seconds. ; MaptileRefresh = 0 + ;# {MaptileStaticUUID} {} {Asset ID for static map texture} {} 00000000-0000-0000-0000-000000000000 ;; If not generating maptiles, use this static texture asset ID ; MaptileStaticUUID = "00000000-0000-0000-0000-000000000000" @@ -228,9 +252,11 @@ ;; got a large number of objects, so you can turn it off here if you'd like. ; DrawPrimOnMapTile = true + ;# {HttpProxy} {} {Proxy URL for llHTTPRequest and dynamic texture loading} {} http://proxy.com:8080 ;; Http proxy setting for llHTTPRequest and dynamic texture loading, if required ; HttpProxy = "http://proxy.com:8080" + ;# {HttpProxyExceptions} {HttpProxy} {Set of regular expressions defining URL that should not be proxied} {} ;; If you're using HttpProxy, then you can set HttpProxyExceptions to a list of regular expressions for URLs that you don't want to go through the proxy ;; For example, servers inside your firewall. ;; Separate patterns with a ';' @@ -254,7 +280,8 @@ ;; default is false ; TelehubAllowLandmark = false - ;# Comma separated list of viewers which may gain access to the regions. + ;# {AllowedViewerList} {} {Comma separated list of allowed viewers} {} + ;; Comma separated list of viewers which may gain access to the regions. ;; One can use a Substring of the viewer name to enable only certain subversions ;; Example: Agent uses the viewer "Imprudence 1.3.2.0" ;; - "Imprudence" has access @@ -262,6 +289,7 @@ ;; - "Imprudence 1.3.1" has no access ;; AllowedViewerList = + ;# {BannedViewerList} {} {Comma separated list of banned viewers} {} ;# Comma separated list of viewers which may not gain access to the regions. ;; One can use a Substring of the viewer name to disable only certain subversions ;; Example: Agent uses the viewer "Imprudence 1.3.2.0" From a96ac7330291c3041729fac08b06d0098469f4d7 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 8 Jul 2012 13:44:04 -0400 Subject: [PATCH 2/6] Add more keys for OpenSim.ini.defaults automation --- bin/OpenSim.ini.example | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index ce571ee2d9..661abc0f71 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -304,16 +304,30 @@ ; If these values are uncommented then they will be used to create a default estate as necessary. ; New regions will be automatically assigned to that default estate. + ;# {DefaultEstateName} {} {Default name for estate?} {} My Estate + ;; Name for the default estate ; DefaultEstateName = My Estate - ; DefaultEstateOwnerName = FirstName LastName - - ; The following parameters will only be used on a standalone system to create an estate owner that does not already exist - ; If DefaultEstateOwnerUUID is left at UUID.Zero (as below) then a random UUID will be assigned. - ; This is normally what you want + ;# {DefaultEstateOwnerName} {} {Default estate owner name?} {} FirstName LastName + ;; Name for default estate owner + ; DefaultEstateOwnerName = FirstName LastName + + + ; ** Standalone Estate Settings ** + ; The following parameters will only be used on a standalone system to + ; create an estate owner that does not already exist + + ;# {DefaultEstateOwnerUUID} {} {Default estate owner UUID?} {} 00000000-0000-0000-0000-000000000000 + ;; If DefaultEstateOwnerUUID is left at UUID.Zero (as below) then a random + ;; UUID will be assigned. This is normally what you want ; DefaultEstateOwnerUUID = 00000000-0000-0000-0000-000000000000 + ;# {DefaultEstateOwnerEMail} {} {Default estate owner email?} {} + ;; Email address for the default estate owner ; DefaultEstateOwnerEMail = owner@domain.com + + ;# {DefaultEstateOwnerPassword} {} {Default estate owner password} {} + ;; Password for the default estate owner ; DefaultEstateOwnerPassword = password From 1a2ab7bc691192f4a263d3d57e2d83bb05f8c69c Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 8 Jul 2012 22:49:36 -0400 Subject: [PATCH 3/6] More keys for automated ini processing --- bin/OpenSim.ini.example | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 661abc0f71..33eaccb8dd 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -364,10 +364,14 @@ ; SMTP_SERVER_PASSWORD = "" [Network] + + ;# {ConsoleUser} {} {User name for console account} {} ;; Configure the remote console user here. This will not actually be used ;; unless you use -console=rest at startup. ; ConsoleUser = "Test" + ;# {ConsolePass} {} {Password for console account} {} ; ConsolePass = "secret" + ;# {console_port} {} {Port for console connections} {} 0 ; console_port = 0 ;# {http_listener_port} {} {TCP Port for this simulator to listen on? (This must be unique to the simulator!)} {} 9000 @@ -431,11 +435,14 @@ [SimulatorFeatures] + + ;# {MapImageServerURI} {} {URL for the map server} {} ; Experimental new information sent in SimulatorFeatures cap for Kokua viewers ; meant to override the MapImage and search server url given at login, and varying ; on a sim-basis. ; Viewers that don't understand it, will ignore it ;MapImageServerURI = "http://127.0.0.1:9000/" + ;# {SearchServerURI} {} {URL of the search server} {} ;SearchServerURI = "http://127.0.0.1:9000/" @@ -629,6 +636,7 @@ [Economy] + ;# {SellEnabled} {} {Enable selling for 0?} {true false} true ; The default economy module only implements just enough to allow free actions (transfer of objects, etc). ; There is no intention to implement anything further in core OpenSimulator. ; This functionality has to be provided by third party modules. @@ -636,9 +644,11 @@ ;; Enables selling things for $0. Default is true. ; SellEnabled = true + ;# {PriceUpload} {} {Price for uploading?} {} 0 ;; Money Unit fee to upload textures, animations etc. Default is 0. ; PriceUpload = 0 + ;# {PriceGroupCreate} {} {Fee for group creation} {} 0 ;; Money Unit fee to create groups. Default is 0. ; PriceGroupCreate = 0 @@ -748,32 +758,41 @@ ; If both Allow_ and Creators_ are given, effective permissions ; are the union of the two. + ;# {EventLimit} {} {Amount of time a script can spend in an event handler} {} 30 ;; Time a script can spend in an event handler before it is interrupted ; EventLimit = 30 + ;# {KillTimedOutScripts} {} {Kill script in case of event time overruns?} {true false} false ;; If a script overruns it's event limit, kill the script? ; KillTimedOutScripts = false + ;# {ScriptDelayFactor} {} {Multiplier for scripting delays} {} 1.0 ;; Sets the multiplier for the scripting delays ; ScriptDelayFactor = 1.0 + ;# {ScriptDistanceLimitFactor} {} {Multiplier for 10.0m distance limits?} {} ;; The factor the 10 m distances limits are multiplied by ; ScriptDistanceLimitFactor = 1.0 + ;# {NotecardLineReadCharsMax} {} {Maximum length of notecard line?} {} 255 ;; Maximum length of notecard line read ;; Increasing this to large values potentially opens ;; up the system to malicious scripters ; NotecardLineReadCharsMax = 255 + ;# {SensorMaxRange} {} {Sensor range} {} 96.0 ;; Sensor settings ; SensorMaxRange = 96.0 + ;# {SensorMaxResults} {} {Max sensor results returned?} {} ; SensorMaxResults = 16 + ;# {DisableUndergroundMovement} {} {Disable underground movement of prims} {true false} true ;; Disable underground movement of prims (default true); set to ;; false to allow script controlled underground positioning of ;; prims ; DisableUndergroundMovement = true + ;# {ScriptEnginesPath} {} {Path to script assemblies} {} ScriptEngines ;; Path to script engine assemblies ;; Default is ./bin/ScriptEngines ; ScriptEnginesPath = "ScriptEngines" From 2eaa6d5ace738cf1848f82ce7a0b435928b6846f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 9 Jul 2012 21:24:32 +0100 Subject: [PATCH 4/6] Do not allow a script to attach a prim if its being sat upon. This prevents a stack overflow where a get position on the avatar will refer to the attachment which will in turn refer back to the avatar. This required recording of all sitting avatars on a prim which is done separately from recording the sit target avatar. Recording HashSet is null if there are no sitting avatars in order to save memory. --- .../Avatar/Attachments/AttachmentsModule.cs | 9 ++ .../Tests/AttachmentsModuleTests.cs | 32 +++++- .../Framework/Scenes/SceneObjectGroup.cs | 14 +++ .../Framework/Scenes/SceneObjectPart.cs | 98 +++++++++++++++++-- .../Region/Framework/Scenes/ScenePresence.cs | 18 +++- OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 71 +++++++++++--- .../Common/Helpers/UserAccountHelpers.cs | 9 ++ 7 files changed, 227 insertions(+), 24 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 9eb0e383c0..eccf7a6977 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -251,6 +251,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", // group.Name, group.LocalId, sp.Name, attachmentPt, silent); + + if (group.GetSittingAvatarsCount() != 0) + { +// m_log.WarnFormat( +// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since {4} avatars are still sitting on it", +// group.Name, group.LocalId, sp.Name, attachmentPt, group.GetSittingAvatarsCount()); + + return false; + } if (sp.GetAttachments(attachmentPt).Contains(group)) { diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 5dcbd28f59..3e06900648 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -118,7 +118,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Scene scene = CreateDefaultTestScene(); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); - ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); string attName = "att"; @@ -154,6 +154,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // TestHelpers.DisableLogging(); } + /// + /// Test that we do not attempt to attach an in-world object that someone else is sitting on. + /// + [Test] + public void TestAddSatOnAttachmentFromGround() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + Scene scene = CreateDefaultTestScene(); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); + + string attName = "att"; + + SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); + + UserAccount ua2 = UserAccountHelpers.CreateUserWithInventory(scene, 0x2); + ScenePresence sp2 = SceneHelpers.AddScenePresence(scene, ua2); + + // Put avatar within 10m of the prim so that sit doesn't fail. + sp2.AbsolutePosition = new Vector3(0, 0, 0); + sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); + + scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false); + + Assert.That(sp.HasAttachments(), Is.False); + Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); + } + [Test] public void TestAddAttachmentFromInventory() { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4e0e183b5f..fc0476157f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3401,6 +3401,20 @@ namespace OpenSim.Region.Framework.Scenes return count; } + /// + /// Gets the number of sitting avatars. + /// + /// This applies to all sitting avatars whether there is a sit target set or not. + /// + public int GetSittingAvatarsCount() + { + int count = 0; + + Array.ForEach(m_parts.GetArray(), p => count += p.GetSittingAvatarsCount()); + + return count; + } + public override string ToString() { return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 3d8135826b..6518b84e49 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -374,7 +374,6 @@ namespace OpenSim.Region.Framework.Scenes private uint _category; private Int32 _creationDate; private uint _parentID = 0; - private UUID m_sitTargetAvatar = UUID.Zero; private uint _baseMask = (uint)PermissionMask.All; private uint _ownerMask = (uint)PermissionMask.All; private uint _groupMask = (uint)PermissionMask.None; @@ -1233,13 +1232,20 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero + /// ID of the avatar that is sat on us if we have a sit target. If there is no such avatar then is UUID.Zero /// - public UUID SitTargetAvatar - { - get { return m_sitTargetAvatar; } - set { m_sitTargetAvatar = value; } - } + public UUID SitTargetAvatar { get; set; } + + /// + /// IDs of all avatars start on this object part. + /// + /// + /// We need to track this so that we can stop sat upon prims from being attached. + /// + /// + /// null if there are no sitting avatars. This is to save us create a hashset for every prim in a scene. + /// + private HashSet m_sittingAvatars; public virtual UUID RegionID { @@ -4493,5 +4499,83 @@ namespace OpenSim.Region.Framework.Scenes Color color = Color; return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); } + + /// + /// Record an avatar sitting on this part. + /// + /// This is called for all the sitting avatars whether there is a sit target set or not. + /// + /// true if the avatar was not already recorded, false otherwise. + /// + /// + protected internal bool AddSittingAvatar(UUID avatarId) + { + HashSet sittingAvatars = m_sittingAvatars; + + if (sittingAvatars == null) + sittingAvatars = new HashSet(); + + lock (sittingAvatars) + { + m_sittingAvatars = sittingAvatars; + return m_sittingAvatars.Add(avatarId); + } + } + + /// + /// Remove an avatar recorded as sitting on this part. + /// + /// This applies to all sitting avatars whether there is a sit target set or not. + /// + /// true if the avatar was present and removed, false if it was not present. + /// + /// + protected internal bool RemoveSittingAvatar(UUID avatarId) + { + HashSet sittingAvatars = m_sittingAvatars; + + // This can occur under a race condition where another thread + if (sittingAvatars == null) + return false; + + lock (sittingAvatars) + { + if (sittingAvatars.Remove(avatarId)) + { + if (sittingAvatars.Count == 0) + m_sittingAvatars = null; + + return true; + } + } + + return false; + } + + /// + /// Get a copy of the list of sitting avatars. + /// + /// This applies to all sitting avatars whether there is a sit target set or not. + /// + public HashSet GetSittingAvatars() + { + return new HashSet(m_sittingAvatars); + } + + /// + /// Gets the number of sitting avatars. + /// + /// This applies to all sitting avatars whether there is a sit target set or not. + /// + public int GetSittingAvatarsCount() + { + HashSet sittingAvatars = m_sittingAvatars; + + if (sittingAvatars == null) + return 0; + + lock (sittingAvatars) + return sittingAvatars.Count; + } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c7a670f2c2..c6a2a032dc 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -577,6 +577,12 @@ namespace OpenSim.Region.Framework.Scenes /// public uint ParentID { get; set; } + /// + /// Are we sitting on an object? + /// + /// A more readable way of testing presence sit status than ParentID == 0 + public bool IsSatOnObject { get { return ParentID != 0; } } + /// /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null. /// @@ -1808,6 +1814,8 @@ namespace OpenSim.Region.Framework.Scenes SendAvatarDataToAllAgents(); m_requestedSitTargetID = 0; + part.RemoveSittingAvatar(UUID); + if (part != null) part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); } @@ -1887,7 +1895,7 @@ namespace OpenSim.Region.Framework.Scenes ) )); -// m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); + m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); if (PhysicsActor != null) m_sitAvatarHeight = PhysicsActor.Size.Z; @@ -1920,6 +1928,12 @@ namespace OpenSim.Region.Framework.Scenes AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); canSit = true; } +// else +// { +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m", +// Name, part.Name, part.LocalId); +// } } if (canSit) @@ -1930,6 +1944,8 @@ namespace OpenSim.Region.Framework.Scenes RemoveFromPhysicalScene(); } + part.AddSittingAvatar(UUID); + cameraAtOffset = part.GetCameraAtOffset(); cameraEyeOffset = part.GetCameraEyeOffset(); forceMouselook = part.GetForceMouselook(); diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index d5354cbcac..769de83c9c 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -412,26 +412,49 @@ namespace OpenSim.Tests.Common /// public static AgentCircuitData GenerateAgentData(UUID agentId) { - string firstName = "testfirstname"; + AgentCircuitData acd = GenerateCommonAgentData(); - AgentCircuitData agentData = new AgentCircuitData(); - agentData.AgentID = agentId; - agentData.firstname = firstName; - agentData.lastname = "testlastname"; + acd.AgentID = agentId; + acd.firstname = "testfirstname"; + acd.lastname = "testlastname"; + acd.ServiceURLs = new Dictionary(); + + return acd; + } + + /// + /// Generate some standard agent connection data. + /// + /// + /// + public static AgentCircuitData GenerateAgentData(UserAccount ua) + { + AgentCircuitData acd = GenerateCommonAgentData(); + + acd.AgentID = ua.PrincipalID; + acd.firstname = ua.FirstName; + acd.lastname = ua.LastName; + acd.ServiceURLs = ua.ServiceURLs; + + return acd; + } + + private static AgentCircuitData GenerateCommonAgentData() + { + AgentCircuitData acd = new AgentCircuitData(); // XXX: Sessions must be unique, otherwise one presence can overwrite another in NullPresenceData. - agentData.SessionID = UUID.Random(); - agentData.SecureSessionID = UUID.Random(); + acd.SessionID = UUID.Random(); + acd.SecureSessionID = UUID.Random(); - agentData.circuitcode = 123; - agentData.BaseFolder = UUID.Zero; - agentData.InventoryFolder = UUID.Zero; - agentData.startpos = Vector3.Zero; - agentData.CapsPath = "http://wibble.com"; - agentData.ServiceURLs = new Dictionary(); - agentData.Appearance = new AvatarAppearance(); + acd.circuitcode = 123; + acd.BaseFolder = UUID.Zero; + acd.InventoryFolder = UUID.Zero; + acd.startpos = Vector3.Zero; + acd.CapsPath = "http://wibble.com"; + acd.Appearance = new AvatarAppearance(); - return agentData; + return acd; } /// @@ -440,6 +463,9 @@ namespace OpenSim.Tests.Common /// /// This can be used for tests where there is only one region or where there are multiple non-neighbour regions /// and teleport doesn't take place. + /// + /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will + /// make the agent circuit data (e.g. first, lastname) consistent with the user account data. /// /// /// @@ -452,6 +478,10 @@ namespace OpenSim.Tests.Common /// /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test /// + /// + /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will + /// make the agent circuit data (e.g. first, lastname) consistent with the user account data. + /// /// /// /// @@ -461,6 +491,17 @@ namespace OpenSim.Tests.Common return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager); } + /// + /// Add a root agent. + /// + /// + /// + /// + public static ScenePresence AddScenePresence(Scene scene, UserAccount ua) + { + return AddScenePresence(scene, GenerateAgentData(ua)); + } + /// /// Add a root agent. /// diff --git a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs index 3d3e65c58c..2fbebc4ea9 100644 --- a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs @@ -138,6 +138,15 @@ namespace OpenSim.Tests.Common CreateUserWithInventory(scene, ua, pw); return ua; } + + public static UserAccount CreateUserWithInventory( + Scene scene, string firstName, string lastName, int userId, string pw) + { + UserAccount ua + = new UserAccount(TestHelpers.ParseTail(userId)) { FirstName = firstName, LastName = lastName }; + CreateUserWithInventory(scene, ua, pw); + return ua; + } public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw) { From d6f563794efb857210f4c773ef5218855c9a4ea4 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 9 Jul 2012 21:43:44 +0100 Subject: [PATCH 5/6] Don't allow a prim to be sat upon if its part of an attachment --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c6a2a032dc..51ca9bdeaa 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2219,6 +2219,15 @@ namespace OpenSim.Region.Framework.Scenes if (part != null) { + if (part.ParentGroup.IsAttachment) + { + m_log.WarnFormat( + "[SCENE PRESENCE]: Avatar {0} tried to sit on part {1} from object {2} in {3} but this is an attachment for avatar id {4}", + Name, part.Name, part.ParentGroup.Name, Scene.Name, part.ParentGroup.AttachedAvatar); + + return; + } + if (part.SitTargetAvatar == UUID) { Vector3 sitTargetPos = part.SitTargetPosition; From c8af20f966e005fb512869299d80be6b83cb70bf Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 9 Jul 2012 23:08:41 +0100 Subject: [PATCH 6/6] This script allows an object to be attached directly from prim inventory to another avatar in the scene. Very useful in serious game/environment scenarios where its only allowed for trusted creators. Threat level Severe --- .../Shared/Api/Implementation/OSSL_Api.cs | 25 +++++++-- .../Shared/Api/Interface/IOSSL_Api.cs | 18 ++++++- .../Shared/Api/Runtime/OSSL_Stub.cs | 5 ++ .../Shared/Tests/OSSL_ApiAttachmentTests.cs | 53 +++++++++++++++++++ 4 files changed, 96 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 61394afe91..e90f57754e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -3190,13 +3190,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory"); + m_host.AddScriptLPS(1); + + ForceAttachToAvatarFromInventory(m_host.OwnerID, itemName, attachmentPoint); + } + + public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint) + { + CheckThreatLevel(ThreatLevel.Severe, "osForceAttachToOtherAvatarFromInventory"); + + m_host.AddScriptLPS(1); + + UUID avatarId; + + if (!UUID.TryParse(rawAvatarId, out avatarId)) + return; + + ForceAttachToAvatarFromInventory(avatarId, itemName, attachmentPoint); + } + + public void ForceAttachToAvatarFromInventory(UUID avatarId, string itemName, int attachmentPoint) + { IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; if (attachmentsModule == null) return; - m_host.AddScriptLPS(1); - InitLSL(); TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); @@ -3219,7 +3238,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - ScenePresence sp = World.GetScenePresence(m_host.OwnerID); + ScenePresence sp = World.GetScenePresence(avatarId); if (sp == null) return; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index d38709e2b9..b5416c8b0e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -101,18 +101,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces // Attachment commands /// - /// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH + /// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH /// /// The attachment point. For example, ATTACH_CHEST void osForceAttachToAvatar(int attachment); /// - /// Attach the inventory item in the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH + /// Attach an inventory item in the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH /// + /// + /// Nothing happens if the owner is not in the region. + /// /// Tha name of the item. If this is not found then a warning is said to the owner /// The attachment point. For example, ATTACH_CHEST void osForceAttachToAvatarFromInventory(string itemName, int attachment); + /// + /// Attach an inventory item in the object containing this script to any avatar in the region without asking for PERMISSION_ATTACH + /// + /// + /// Nothing happens if the avatar is not in the region. + /// + /// The UUID of the avatar to which to attach. Nothing happens if this is not a UUID + /// The name of the item. If this is not found then a warning is said to the owner + /// The attachment point. For example, ATTACH_CHEST + void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint); + /// /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 692bb0a510..b40bdf0b17 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -301,6 +301,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osForceAttachToAvatarFromInventory(itemName, attachmentPoint); } + public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint) + { + m_OSSL_Functions.osForceAttachToOtherAvatarFromInventory(rawAvatarId, itemName, attachmentPoint); + } + public void osForceDetachFromAvatar() { m_OSSL_Functions.osForceDetachFromAvatar(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs index 78db2c6a48..f5aa51843f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs @@ -174,5 +174,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests List attachmentsInAppearance = sp.Appearance.GetAttachments(); Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0)); } + + [Test] + public void TestOsForceAttachToOtherAvatarFromInventory() + { + TestHelpers.InMethod(); + TestHelpers.EnableLogging(); + + string taskInvObjItemName = "sphere"; + UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); + AttachmentPoint attachPoint = AttachmentPoint.Chin; + + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, "user", "one", 0x1, "pass"); + UserAccount ua2 = UserAccountHelpers.CreateUserWithInventory(m_scene, "user", "two", 0x2, "pass"); + + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1); + SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); + TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); + + new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); + OSSL_Api osslApi = new OSSL_Api(); + osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); + + // Create an object embedded inside the first + TaskInventoryHelpers.AddSceneObject(m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); + + ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, ua2); + + osslApi.osForceAttachToOtherAvatarFromInventory(sp2.UUID.ToString(), taskInvObjItemName, (int)attachPoint); + + // Check scene presence status + Assert.That(sp.HasAttachments(), Is.False); + List attachments = sp.GetAttachments(); + Assert.That(attachments.Count, Is.EqualTo(0)); + + Assert.That(sp2.HasAttachments(), Is.True); + List attachments2 = sp2.GetAttachments(); + Assert.That(attachments2.Count, Is.EqualTo(1)); + SceneObjectGroup attSo = attachments2[0]; + Assert.That(attSo.Name, Is.EqualTo(taskInvObjItemName)); + Assert.That(attSo.OwnerID, Is.EqualTo(ua2.PrincipalID)); + Assert.That(attSo.AttachmentPoint, Is.EqualTo((uint)attachPoint)); + Assert.That(attSo.IsAttachment); + Assert.That(attSo.UsesPhysics, Is.False); + Assert.That(attSo.IsTemporary, Is.False); + + // Check appearance status + List attachmentsInAppearance = sp.Appearance.GetAttachments(); + Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0)); + + List attachmentsInAppearance2 = sp2.Appearance.GetAttachments(); + Assert.That(attachmentsInAppearance2.Count, Is.EqualTo(1)); + Assert.That(sp2.Appearance.GetAttachpoint(attachmentsInAppearance2[0].ItemID), Is.EqualTo((uint)attachPoint)); + } } } \ No newline at end of file