refactor: Split most of EntityTransferModule.Teleport() into its same region and different region teleport components.
DoTeleport() now retrives IEventQueue itself rather than requiring it to be passed in.0.7.4.1
parent
b678ea18b2
commit
37dd174697
OpenSim/Region
CoreModules
Avatar/Lure
Framework/EntityTransfer
Framework/Interfaces
|
@ -240,9 +240,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
|
||||||
{
|
{
|
||||||
ScenePresence sp = scene.GetScenePresence(client.AgentId);
|
ScenePresence sp = scene.GetScenePresence(client.AgentId);
|
||||||
IEntityTransferModule transferMod = scene.RequestModuleInterface<IEntityTransferModule>();
|
IEntityTransferModule transferMod = scene.RequestModuleInterface<IEntityTransferModule>();
|
||||||
IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
|
|
||||||
if (transferMod != null && sp != null && eq != null)
|
if (transferMod != null && sp != null)
|
||||||
transferMod.DoTeleport(sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 0f), Vector3.UnitX, teleportflags, eq);
|
transferMod.DoTeleport(
|
||||||
|
sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 0f),
|
||||||
|
Vector3.UnitX, teleportflags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,8 +170,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
if (!sp.Scene.Permissions.CanTeleport(sp.UUID))
|
if (!sp.Scene.Permissions.CanTeleport(sp.UUID))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
|
|
||||||
|
|
||||||
// Reset animations; the viewer does that in teleports.
|
// Reset animations; the viewer does that in teleports.
|
||||||
sp.Animator.ResetAnimations();
|
sp.Animator.ResetAnimations();
|
||||||
|
|
||||||
|
@ -183,9 +181,41 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
{
|
{
|
||||||
destinationRegionName = sp.Scene.RegionInfo.RegionName;
|
destinationRegionName = sp.Scene.RegionInfo.RegionName;
|
||||||
|
|
||||||
|
TeleportAgentWithinRegion(sp, position, lookAt, teleportFlags);
|
||||||
|
}
|
||||||
|
else // Another region possibly in another simulator
|
||||||
|
{
|
||||||
|
GridRegion finalDestination;
|
||||||
|
TeleportAgentToDifferentRegion(
|
||||||
|
sp, regionHandle, position, lookAt, teleportFlags, out finalDestination);
|
||||||
|
|
||||||
|
if (finalDestination != null)
|
||||||
|
destinationRegionName = finalDestination.RegionName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[ENTITY TRANSFER MODULE]: Exception on teleport of {0} from {1}@{2} to {3}@{4}: {5}{6}",
|
||||||
|
sp.Name, sp.AbsolutePosition, sp.Scene.RegionInfo.RegionName, position, destinationRegionName,
|
||||||
|
e.Message, e.StackTrace);
|
||||||
|
|
||||||
|
sp.ControllingClient.SendTeleportFailed("Internal error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Teleports the agent within its current region.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sp"></param>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <param name="lookAt"></param>
|
||||||
|
/// <param name="teleportFlags"></param
|
||||||
|
private void TeleportAgentWithinRegion(ScenePresence sp, Vector3 position, Vector3 lookAt, uint teleportFlags)
|
||||||
|
{
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[ENTITY TRANSFER MODULE]: Teleport for {0} to {1} within {2}",
|
"[ENTITY TRANSFER MODULE]: Teleport for {0} to {1} within {2}",
|
||||||
sp.Name, position, destinationRegionName);
|
sp.Name, position, sp.Scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
// Teleport within the same region
|
// Teleport within the same region
|
||||||
if (IsOutsideRegion(sp.Scene, position) || position.Z < 0)
|
if (IsOutsideRegion(sp.Scene, position) || position.Z < 0)
|
||||||
|
@ -226,7 +256,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT);
|
sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Another region possibly in another simulator
|
|
||||||
|
/// <summary>
|
||||||
|
/// Teleports the agent to a different region.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='sp'></param>
|
||||||
|
/// <param name='regionHandle'>/param>
|
||||||
|
/// <param name='position'></param>
|
||||||
|
/// <param name='lookAt'></param>
|
||||||
|
/// <param name='teleportFlags'></param>
|
||||||
|
/// <param name='finalDestination'></param>
|
||||||
|
private void TeleportAgentToDifferentRegion(
|
||||||
|
ScenePresence sp, ulong regionHandle, Vector3 position,
|
||||||
|
Vector3 lookAt, uint teleportFlags, out GridRegion finalDestination)
|
||||||
{
|
{
|
||||||
uint x = 0, y = 0;
|
uint x = 0, y = 0;
|
||||||
Utils.LongToUInts(regionHandle, out x, out y);
|
Utils.LongToUInts(regionHandle, out x, out y);
|
||||||
|
@ -234,7 +276,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
|
|
||||||
if (reg != null)
|
if (reg != null)
|
||||||
{
|
{
|
||||||
GridRegion finalDestination = GetFinalDestination(reg);
|
finalDestination = GetFinalDestination(reg);
|
||||||
|
|
||||||
if (finalDestination == null)
|
if (finalDestination == null)
|
||||||
{
|
{
|
||||||
m_log.WarnFormat(
|
m_log.WarnFormat(
|
||||||
|
@ -245,8 +288,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
destinationRegionName = finalDestination.RegionName;
|
|
||||||
|
|
||||||
uint curX = 0, curY = 0;
|
uint curX = 0, curY = 0;
|
||||||
Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY);
|
Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY);
|
||||||
int curCellX = (int)(curX / Constants.RegionSize);
|
int curCellX = (int)(curX / Constants.RegionSize);
|
||||||
|
@ -283,13 +324,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
//
|
//
|
||||||
// This is it
|
// This is it
|
||||||
//
|
//
|
||||||
DoTeleport(sp, reg, finalDestination, position, lookAt, teleportFlags, eq);
|
DoTeleport(sp, reg, finalDestination, position, lookAt, teleportFlags);
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
finalDestination = null;
|
||||||
|
|
||||||
// TP to a place that doesn't exist (anymore)
|
// TP to a place that doesn't exist (anymore)
|
||||||
// Inform the viewer about that
|
// Inform the viewer about that
|
||||||
sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
|
sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
|
||||||
|
@ -308,20 +351,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
sp.ControllingClient.SendMapBlock(blocks, 0);
|
sp.ControllingClient.SendMapBlock(blocks, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat(
|
|
||||||
"[ENTITY TRANSFER MODULE]: Exception on teleport of {0} from {1}@{2} to {3}@{4}: {5}{6}",
|
|
||||||
sp.Name, sp.AbsolutePosition, sp.Scene.RegionInfo.RegionName, position, destinationRegionName,
|
|
||||||
e.Message, e.StackTrace);
|
|
||||||
|
|
||||||
sp.ControllingClient.SendTeleportFailed("Internal error");
|
public void DoTeleport(
|
||||||
}
|
ScenePresence sp, GridRegion reg, GridRegion finalDestination,
|
||||||
}
|
Vector3 position, Vector3 lookAt, uint teleportFlags)
|
||||||
|
|
||||||
public void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq)
|
|
||||||
{
|
{
|
||||||
|
IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
|
||||||
|
|
||||||
if (reg == null || finalDestination == null)
|
if (reg == null || finalDestination == null)
|
||||||
{
|
{
|
||||||
sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
|
sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
|
||||||
|
|
|
@ -242,13 +242,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
|
|
||||||
GridRegion homeGatekeeper = MakeRegion(aCircuit);
|
GridRegion homeGatekeeper = MakeRegion(aCircuit);
|
||||||
|
|
||||||
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}",
|
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}",
|
||||||
aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName);
|
aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName);
|
||||||
|
|
||||||
DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq);
|
DoTeleport(
|
||||||
|
sp, homeGatekeeper, finalDestination,
|
||||||
|
position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -288,17 +289,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
{
|
{
|
||||||
ScenePresence sp = scene.GetScenePresence(remoteClient.AgentId);
|
ScenePresence sp = scene.GetScenePresence(remoteClient.AgentId);
|
||||||
IEntityTransferModule transferMod = scene.RequestModuleInterface<IEntityTransferModule>();
|
IEntityTransferModule transferMod = scene.RequestModuleInterface<IEntityTransferModule>();
|
||||||
IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
|
|
||||||
if (transferMod != null && sp != null && eq != null)
|
if (transferMod != null && sp != null)
|
||||||
transferMod.DoTeleport(sp, gatekeeper, finalDestination, lm.Position,
|
transferMod.DoTeleport(
|
||||||
Vector3.UnitX, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark), eq);
|
sp, gatekeeper, finalDestination, lm.Position, Vector3.UnitX,
|
||||||
|
(uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// can't find the region: Tell viewer and abort
|
// can't find the region: Tell viewer and abort
|
||||||
remoteClient.SendTeleportFailed("The teleport destination could not be found.");
|
remoteClient.SendTeleportFailed("The teleport destination could not be found.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -37,12 +37,41 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
{
|
{
|
||||||
public interface IEntityTransferModule
|
public interface IEntityTransferModule
|
||||||
{
|
{
|
||||||
void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position,
|
/// <summary>
|
||||||
Vector3 lookAt, uint teleportFlags);
|
/// Teleport an agent within the same or to a different region.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='agent'></param>
|
||||||
|
/// <param name='regionHandle'>
|
||||||
|
/// The handle of the destination region. If it's the same as the region currently
|
||||||
|
/// occupied by the agent then the teleport will be within that region.
|
||||||
|
/// </param>
|
||||||
|
/// <param name='position'></param>
|
||||||
|
/// <param name='lookAt'></param>
|
||||||
|
/// <param name='teleportFlags'></param>
|
||||||
|
void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags);
|
||||||
|
|
||||||
void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination,
|
/// <summary>
|
||||||
Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq);
|
/// Teleport an agent directly to a given region without checking whether the region should be subsituted.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Please use Teleport() instead unless you know exactly what you're doing.
|
||||||
|
/// Do not use for same region teleports.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name='sp'></param>
|
||||||
|
/// <param name='reg'></param>
|
||||||
|
/// <param name='finalDestination'>/param>
|
||||||
|
/// <param name='position'></param>
|
||||||
|
/// <param name='lookAt'></param>
|
||||||
|
/// <param name='teleportFlags'></param>
|
||||||
|
void DoTeleport(
|
||||||
|
ScenePresence sp, GridRegion reg, GridRegion finalDestination,
|
||||||
|
Vector3 position, Vector3 lookAt, uint teleportFlags);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Teleports the agent for the given client to their home destination.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='id'></param>
|
||||||
|
/// <param name='client'></param>
|
||||||
void TeleportHome(UUID id, IClientAPI client);
|
void TeleportHome(UUID id, IClientAPI client);
|
||||||
|
|
||||||
bool Cross(ScenePresence agent, bool isFlying);
|
bool Cross(ScenePresence agent, bool isFlying);
|
||||||
|
|
Loading…
Reference in New Issue