mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
Fix bumping into sim borders and check estate bans for walking crossings
This commit is contained in:
@@ -42,7 +42,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
|
||||
void TeleportHome(UUID id, IClientAPI client);
|
||||
|
||||
void Cross(ScenePresence agent, bool isFlying);
|
||||
bool Cross(ScenePresence agent, bool isFlying);
|
||||
|
||||
void AgentArrivedAtDestination(UUID agent);
|
||||
|
||||
|
||||
@@ -3861,14 +3861,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
RequestTeleportLocation(remoteClient, info.RegionHandle, position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark));
|
||||
}
|
||||
|
||||
public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
|
||||
public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
|
||||
{
|
||||
if (m_teleportModule != null)
|
||||
m_teleportModule.Cross(agent, isFlying);
|
||||
return m_teleportModule.Cross(agent, isFlying);
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence)
|
||||
|
||||
@@ -2725,29 +2725,57 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// Makes sure avatar does not end up outside region
|
||||
if (neighbor <= 0)
|
||||
{
|
||||
if (!needsTransit)
|
||||
if (needsTransit)
|
||||
{
|
||||
if (m_requestedSitTargetUUID == UUID.Zero)
|
||||
{
|
||||
bool isFlying = m_physicsActor.Flying;
|
||||
RemoveFromPhysicalScene();
|
||||
|
||||
Vector3 pos = AbsolutePosition;
|
||||
if (AbsolutePosition.X < 0)
|
||||
pos.X += Velocity.X;
|
||||
pos.X += Velocity.X * 2;
|
||||
else if (AbsolutePosition.X > Constants.RegionSize)
|
||||
pos.X -= Velocity.X;
|
||||
pos.X -= Velocity.X * 2;
|
||||
if (AbsolutePosition.Y < 0)
|
||||
pos.Y += Velocity.Y;
|
||||
pos.Y += Velocity.Y * 2;
|
||||
else if (AbsolutePosition.Y > Constants.RegionSize)
|
||||
pos.Y -= Velocity.Y;
|
||||
pos.Y -= Velocity.Y * 2;
|
||||
Velocity = Vector3.Zero;
|
||||
AbsolutePosition = pos;
|
||||
|
||||
AddToPhysicalScene(isFlying);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (neighbor > 0)
|
||||
CrossToNewRegion();
|
||||
{
|
||||
if (!CrossToNewRegion())
|
||||
{
|
||||
if (m_requestedSitTargetUUID == UUID.Zero)
|
||||
{
|
||||
bool isFlying = m_physicsActor.Flying;
|
||||
RemoveFromPhysicalScene();
|
||||
|
||||
Vector3 pos = AbsolutePosition;
|
||||
if (AbsolutePosition.X < 0)
|
||||
pos.X += Velocity.X * 2;
|
||||
else if (AbsolutePosition.X > Constants.RegionSize)
|
||||
pos.X -= Velocity.X * 2;
|
||||
if (AbsolutePosition.Y < 0)
|
||||
pos.Y += Velocity.Y * 2;
|
||||
else if (AbsolutePosition.Y > Constants.RegionSize)
|
||||
pos.Y -= Velocity.Y * 2;
|
||||
Velocity = Vector3.Zero;
|
||||
AbsolutePosition = pos;
|
||||
|
||||
AddToPhysicalScene(isFlying);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveFromPhysicalScene();
|
||||
// This constant has been inferred from experimentation
|
||||
// I'm not sure what this value should be, so I tried a few values.
|
||||
timeStep = 0.04f;
|
||||
@@ -2796,16 +2824,15 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// If the neighbor accepts, remove the agent's viewable avatar from this scene
|
||||
/// set them to a child agent.
|
||||
/// </summary>
|
||||
protected void CrossToNewRegion()
|
||||
protected bool CrossToNewRegion()
|
||||
{
|
||||
InTransit();
|
||||
try
|
||||
{
|
||||
m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying);
|
||||
return m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_scene.CrossAgentToNewRegion(this, false);
|
||||
return m_scene.CrossAgentToNewRegion(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user