From aaef497afbedef9382c9afdcb9f8d0d5b0a0e0bc Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 9 Sep 2020 22:59:24 +1000 Subject: Various teleport fixes. TPs from scripts avoid all that silly raycasting nonsense, just go where we ask. For the "teleport from above" case, do the right thing. Which includes looking for designated floor prims, which have ^ as the first character of their description. Don't do "teleport from above" when we have proper coords. Teleport home from off grid shouldn't land on roofs either. --- .../EntityTransfer/EntityTransferModule.cs | 7 +-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 57 +++++++++++++++------- .../Shared/Api/Implementation/LSL_Api.cs | 6 +-- .../Shared/Api/Implementation/OSSL_Api.cs | 2 +- 4 files changed, 48 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index fa49546..9970132 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -673,9 +673,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string homeURI = Scene.GetAgentHomeURI(sp.ControllingClient.AgentId); - m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: Teleporting {0} {1} from {2} to {3} ({4}) {5}/{6}", - sp.Name, sp.UUID, sp.Scene.RegionInfo.RegionName, +//// m_log.DebugFormat( + m_log.InfoFormat( + "[ENTITY TRANSFER MODULE]: Teleporting {0} {1} from {2}/{3} to {4} ({5}) {6}/{7}", + sp.Name, sp.UUID, sp.Scene.RegionInfo.RegionName, sp.AbsolutePosition, reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position); RegionInfo sourceRegion = sp.Scene.RegionInfo; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 0d8f286..e84018e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1406,15 +1406,18 @@ namespace OpenSim.Region.Framework.Scenes if (groundHeight > pos.Z) pos.Z = groundHeight; + if (((m_teleportFlags & TeleportFlags.ViaMap) == 0) && (Math.Truncate(pos.Z) == pos.Z)) + m_teleportFlags |= TeleportFlags.ViaMap; bool checkPhysics = !positionChanged && m_scene.SupportsRayCastFiltered() && pos.Z < physTestHeight && ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) - || (m_teleportFlags & TeleportFlags.ViaLocation) != 0 +//// || (m_teleportFlags & TeleportFlags.ViaLocation) != 0 + || (m_teleportFlags & TeleportFlags.ViaMap) != 0 || (m_teleportFlags & TeleportFlags.ViaHGLogin) != 0); - if(checkPhysics) + if(checkPhysics && ((m_teleportFlags & TeleportFlags.ViaScript) == 0) && ((m_teleportFlags & TeleportFlags.ViaHome) == 0)) { // land check was done above RayFilterFlags rayfilter = RayFilterFlags.BackFaceCull; @@ -1443,29 +1446,49 @@ namespace OpenSim.Region.Framework.Scenes return a.Depth.CompareTo(b.Depth); }); - int sel = 0; + int sel = -1; int count = physresults.Count; float curd = physresults[0].Depth; float nextd = curd + PhysMinSkipGap; float maxDepth = dist - pos.Z; - for(int i = 1; i < count; i++) + // Try to find a designated floor. + for(int i = 0; i < count; i++) { - curd = physresults[i].Depth; - if(curd >= nextd) - { - sel = i; - if(curd >= maxDepth || curd >= nextd + PhysSkipGapDelta) - break; - } - nextd = curd + PhysMinSkipGap; + SceneObjectPart part = m_scene.GetSceneObjectPart(physresults[i].ConsumerID); + if ((null != part) && (string.Empty != part.Description) && ('^' == part.Description[0])) + { + sel = i; + dest = physresults[sel].Pos.Z; + break; + } + } + + if (-1 == sel) + { + sel = 0; + for (int i = 1; i < count; i++) + { + curd = physresults[i].Depth; + if(curd >= nextd) + { + sel = i; + if(curd >= maxDepth || curd >= nextd + PhysSkipGapDelta) + break; + } + nextd = curd + PhysMinSkipGap; + } + dest = physresults[sel].Pos.Z; } - dest = physresults[sel].Pos.Z; } - dest += localAVHalfHeight; - if(dest > pos.Z) - pos.Z = dest; - break; + dest += localAVHalfHeight; +if ((m_teleportFlags & TeleportFlags.ViaMap) != 0) + m_log.InfoFormat("[SCENE PRESENCE]: Teleport from above, for {0} @ {1}, landing height {2}", Name, pos, dest); +else + m_log.ErrorFormat("[SCENE PRESENCE]: Teleport from above NOMAP, for {0} @ {1}, landing height {2}", Name, pos, dest); + if(dest > pos.Z) + pos.Z = dest; + break; } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c9ee28e..10afe99 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5245,7 +5245,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) != 0) { - World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); + World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)(Constants.TeleportFlags.ViaLocation | Constants.TeleportFlags.ViaScript)); } } } @@ -5259,7 +5259,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Use it as a sim name if (assetID == UUID.Zero) { - World.RequestTeleportLocation(sp.ControllingClient, destination, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); + World.RequestTeleportLocation(sp.ControllingClient, destination, targetPos, targetLookAt, (uint)(Constants.TeleportFlags.ViaLocation | Constants.TeleportFlags.ViaScript)); return; } @@ -5272,7 +5272,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AssetLandmark lm = new AssetLandmark(lma); - World.RequestTeleportLocation(sp.ControllingClient, lm.RegionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); + World.RequestTeleportLocation(sp.ControllingClient, lm.RegionHandle, targetPos, targetLookAt, (uint)(Constants.TeleportFlags.ViaLocation | Constants.TeleportFlags.ViaScript)); } public void llTextBox(string agent, string message, int chatChannel) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index d268609..48f9d0b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1071,7 +1071,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Util.FireAndForget( o => World.RequestTeleportLocation( presence.ControllingClient, regionName, position, - lookat, (uint)TPFlags.ViaLocation), + lookat, (uint)(TPFlags.ViaLocation | TPFlags.ViaScript)), null, "OSSL_Api.TeleportAgentByRegionCoords"); ScriptSleep(5000); } -- cgit v1.1