From 5d312671855bf5fda2ae5960fdcd19f1d9f1d1cb Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 22 Feb 2012 00:55:16 +0000 Subject: [PATCH 1/4] Remove two spurious m_sceneGraph != null checks in Scene.cs. It's set in constructor and never subsequent set to null. --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e7f835cdb6..ec327019a0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4257,10 +4257,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void ForEachRootScenePresence(Action action) { - if (m_sceneGraph != null) - { - m_sceneGraph.ForEachAvatar(action); - } + m_sceneGraph.ForEachAvatar(action); } /// @@ -4269,10 +4266,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void ForEachScenePresence(Action action) { - if (m_sceneGraph != null) - { - m_sceneGraph.ForEachScenePresence(action); - } + m_sceneGraph.ForEachScenePresence(action); } /// From 3796e08b5977d363a97a3e2ca27df0f710f2ba2a Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 22 Feb 2012 23:14:29 +0100 Subject: [PATCH 2/4] Count agents for LSL instead of relying on SceneGraph to have the correct value. Fixes a reported glitch. --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 84792c0b1a..a7341a9a5a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5709,7 +5709,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetRegionAgentCount() { m_host.AddScriptLPS(1); - return new LSL_Integer(World.GetRootAgentCount()); + + int count = 0; + World.ForEachRootScenePresence(delegate(ScenePresence sp) { + count++; + }); + + return new LSL_Integer(count); } public LSL_Vector llGetRegionCorner() From c0b8f3d0bcc71d31cd92bb47e10a7d6a96d7900e Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 23 Feb 2012 00:08:31 +0100 Subject: [PATCH 3/4] Add permission checks to scripted object movements, which didn't respect bans and parcel settings until now. Add llSetRegionPos() function according to LL spec --- .../Shared/Api/Implementation/LSL_Api.cs | 54 ++++++++++++++++++- .../Shared/Api/Interface/ILSL_Api.cs | 1 + .../Shared/Api/Runtime/LSL_Stub.cs | 5 ++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a7341a9a5a..d0430f476e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2177,6 +2177,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return real_vec; } + public LSL_Integer llSetRegionPos(LSL_Vector pos) + { + return new LSL_Integer(SetRegionPos(m_host, pos)); + } + + protected int SetRegionPos(SceneObjectPart part, LSL_Vector targetPos) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return 0; + + SceneObjectGroup grp = part.ParentGroup; + + if (grp.IsAttachment) + return 0; + + if (grp.RootPart.PhysActor != null && grp.RootPart.PhysActor.IsPhysical) + return 0; + + if (targetPos.x < -10.0f || targetPos.x >= (float)Constants.RegionSize || targetPos.y < -10.0f || targetPos.y >= (float)Constants.RegionSize || targetPos.z < 0 || targetPos.z >= 4096.0f) + return 0; + + float constrainedX = (float)targetPos.x; + float constrainedY = (float)targetPos.y; + + if (constrainedX < 0.0f) + constrainedX = 0.0f; + if (constrainedY < 0.0f) + constrainedY = 0.0f; + if (constrainedX >= (float)Constants.RegionSize) + constrainedX = (float)Constants.RegionSize - 0.1f; + if (constrainedY >= (float)Constants.RegionSize) + constrainedY = (float)Constants.RegionSize -0.1f; + + float ground = World.GetGroundHeight(constrainedX, constrainedY); + + if (targetPos.z < ground) + targetPos.z = ground; + + Vector3 dest = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z); + + if (!World.Permissions.CanObjectEntry(grp.UUID, false, dest)) + return 0; + + grp.UpdateGroupPosition(dest); + + return 1; + } + protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) { if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) @@ -2185,11 +2233,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Vector currentPos = GetPartLocalPos(part); LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos); + if (part.ParentGroup.RootPart == part) { SceneObjectGroup parent = part.ParentGroup; + Vector3 dest = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); + if (!World.Permissions.CanObjectEntry(parent.UUID, false, dest)) + return; Util.FireAndForget(delegate(object x) { - parent.UpdateGroupPosition(new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z)); + parent.UpdateGroupPosition(dest); }); } else diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index f2d4399fd7..967979804c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -346,6 +346,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llSetParcelMusicURL(string url); void llSetPayPrice(int price, LSL_List quick_pay_buttons); void llSetPos(LSL_Vector pos); + LSL_Integer llSetRegionPos(LSL_Vector pos); LSL_Integer llSetPrimMediaParams(int face, LSL_List rules); void llSetPrimitiveParams(LSL_List rules); void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index fad6c350b4..dcaa3b4747 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -1580,6 +1580,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llSetPos(pos); } + public LSL_Integer llSetRegionPos(LSL_Vector pos) + { + return m_LSL_Functions.llSetRegionPos(pos); + } + public void llSetPrimitiveParams(LSL_List rules) { m_LSL_Functions.llSetPrimitiveParams(rules); From 1dfc9902649bfb4f02340644a0589fe139a3322a Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 23 Feb 2012 01:40:30 +0000 Subject: [PATCH 4/4] Add a position parameter to region crossing of objects. This avoids the potential bad update that places an object at the opposite side of the origin sim for a moment before actually crossing it. Especially important in grids like OSG where lag between sims is high. --- .../Framework/EntityTransfer/EntityTransferModule.cs | 9 ++++----- .../Simulation/LocalSimulationConnector.cs | 6 +++--- .../Simulation/RemoteSimulationConnector.cs | 6 +++--- OpenSim/Region/Framework/Scenes/Scene.cs | 5 ++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs | 10 +++++++--- .../Simulation/SimulationServiceConnector.cs | 3 ++- OpenSim/Services/Interfaces/ISimulationService.cs | 2 +- 8 files changed, 25 insertions(+), 18 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 8f047ead81..f6e4dbf74b 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1704,14 +1704,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Offset the positions for the new region across the border Vector3 oldGroupPosition = grp.RootPart.GroupPosition; - grp.RootPart.GroupPosition = pos; // If we fail to cross the border, then reset the position of the scene object on that border. uint x = 0, y = 0; Utils.LongToUInts(newRegionHandle, out x, out y); GridRegion destination = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); - if (destination == null || !CrossPrimGroupIntoNewRegion(destination, grp, silent)) + if (destination == null || !CrossPrimGroupIntoNewRegion(destination, pos, grp, silent)) { m_log.InfoFormat("[ENTITY TRANSFER MODULE] cross region transfer failed for object {0}",grp.UUID); @@ -1741,7 +1740,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer /// true if the crossing itself was successful, false on failure /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region /// - protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, SceneObjectGroup grp, bool silent) + protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, Vector3 newPosition, SceneObjectGroup grp, bool silent) { //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<"); @@ -1766,7 +1765,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer //if (m_interregionCommsOut != null) // successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true); if (m_aScene.SimulationService != null) - successYN = m_aScene.SimulationService.CreateObject(destination, grp, true); + successYN = m_aScene.SimulationService.CreateObject(destination, newPosition, grp, true); if (successYN) { @@ -1825,7 +1824,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer gobj.IsAttachment = false; //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); - CrossPrimGroupIntoNewRegion(destination, gobj, silent); + CrossPrimGroupIntoNewRegion(destination, Vector3.Zero, gobj, silent); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index a17c6aed22..85e7e94c1e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -315,7 +315,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation * Object-related communications */ - public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) + public bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog, bool isLocalCall) { if (destination == null) return false; @@ -330,12 +330,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation // We need to make a local copy of the object ISceneObject sogClone = sog.CloneForNewScene(); sogClone.SetState(sog.GetStateSnapshot(), s); - return s.IncomingCreateObject(sogClone); + return s.IncomingCreateObject(newPosition, sogClone); } else { // Use the object as it came through the wire - return s.IncomingCreateObject(sog); + return s.IncomingCreateObject(newPosition, sog); } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index f8cea71b43..eaf9506332 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -282,13 +282,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation * Object-related communications */ - public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) + public bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog, bool isLocalCall) { if (destination == null) return false; // Try local first - if (m_localBackend.CreateObject(destination, sog, isLocalCall)) + if (m_localBackend.CreateObject(destination, newPosition, sog, isLocalCall)) { //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded"); return true; @@ -296,7 +296,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation // else do the remote thing if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) - return m_remoteConnector.CreateObject(destination, sog, isLocalCall); + return m_remoteConnector.CreateObject(destination, newPosition, sog, isLocalCall); return false; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e7f835cdb6..7b79732dce 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2317,7 +2317,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public bool IncomingCreateObject(ISceneObject sog) + public bool IncomingCreateObject(Vector3 newPosition, ISceneObject sog) { //m_log.DebugFormat(" >>> IncomingCreateObject(sog) <<< {0} deleted? {1} isAttach? {2}", ((SceneObjectGroup)sog).AbsolutePosition, // ((SceneObjectGroup)sog).IsDeleted, ((SceneObjectGroup)sog).RootPart.IsAttachment); @@ -2333,6 +2333,9 @@ namespace OpenSim.Region.Framework.Scenes return false; } + if (newPosition != Vector3.Zero) + newObject.RootPart.GroupPosition = newPosition; + if (!AddSceneObject(newObject)) { m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index daf711c673..9cfdf9fe9f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3223,7 +3223,7 @@ namespace OpenSim.Region.Framework.Scenes ((SceneObjectGroup)so).LocalId = 0; ((SceneObjectGroup)so).RootPart.ClearUpdateSchedule(); so.SetState(cAgent.AttachmentObjectStates[i++], m_scene); - m_scene.IncomingCreateObject(so); + m_scene.IncomingCreateObject(Vector3.Zero, so); } } } diff --git a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs index 984b843401..f0d8f69827 100644 --- a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs @@ -136,6 +136,8 @@ namespace OpenSim.Server.Handlers.Simulation int x = 0, y = 0; UUID uuid = UUID.Zero; string regionname = string.Empty; + Vector3 newPosition = Vector3.Zero; + if (args.ContainsKey("destination_x") && args["destination_x"] != null) Int32.TryParse(args["destination_x"].AsString(), out x); if (args.ContainsKey("destination_y") && args["destination_y"] != null) @@ -144,6 +146,8 @@ namespace OpenSim.Server.Handlers.Simulation UUID.TryParse(args["destination_uuid"].AsString(), out uuid); if (args.ContainsKey("destination_name") && args["destination_name"] != null) regionname = args["destination_name"].ToString(); + if (args.ContainsKey("new_position") && args["new_position"] != null) + Vector3.TryParse(args["new_position"], out newPosition); GridRegion destination = new GridRegion(); destination.RegionID = uuid; @@ -199,7 +203,7 @@ namespace OpenSim.Server.Handlers.Simulation try { // This is the meaning of POST object - result = CreateObject(destination, sog); + result = CreateObject(destination, newPosition, sog); } catch (Exception e) { @@ -211,9 +215,9 @@ namespace OpenSim.Server.Handlers.Simulation } // subclasses can override this - protected virtual bool CreateObject(GridRegion destination, ISceneObject sog) + protected virtual bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog) { - return m_SimulationService.CreateObject(destination, sog, false); + return m_SimulationService.CreateObject(destination, newPosition, sog, false); } protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, UUID regionID) diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 65f01b39c5..cb003d1dd2 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -408,7 +408,7 @@ namespace OpenSim.Services.Connectors.Simulation /// /// /// - public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) + public bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog, bool isLocalCall) { // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateObject start"); @@ -421,6 +421,7 @@ namespace OpenSim.Services.Connectors.Simulation args["sog"] = OSD.FromString(sog.ToXml2()); args["extra"] = OSD.FromString(sog.ExtraToXmlString()); args["modified"] = OSD.FromBoolean(sog.HasGroupChanged); + args["new_position"] = newPosition.ToString(); string state = sog.GetStateSnapshot(); if (state.Length > 0) diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs index 5f9ce6d8b8..36fd6fcaa9 100644 --- a/OpenSim/Services/Interfaces/ISimulationService.cs +++ b/OpenSim/Services/Interfaces/ISimulationService.cs @@ -98,7 +98,7 @@ namespace OpenSim.Services.Interfaces /// /// /// - bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall); + bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog, bool isLocalCall); /// /// Create an object from the user's inventory in the destination region.