some shortcuts on local osTeleport, reduce its time penalty, do it with script thread
parent
3ce909528d
commit
0418542344
|
@ -4824,16 +4824,34 @@ Label_GroupsDone:
|
|||
public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
|
||||
Vector3 lookat, uint teleportFlags)
|
||||
{
|
||||
GridRegion region = GridService.GetRegionByName(RegionInfo.ScopeID, regionName);
|
||||
if (EntityTransferModule == null)
|
||||
{
|
||||
m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
|
||||
return;
|
||||
}
|
||||
|
||||
if (region == null)
|
||||
ScenePresence sp = GetScenePresence(remoteClient.AgentId);
|
||||
if (sp == null || sp.IsDeleted || sp.IsInTransit)
|
||||
return;
|
||||
|
||||
ulong regionHandle = 0;
|
||||
if(regionName == RegionInfo.RegionName)
|
||||
regionHandle = RegionInfo.RegionHandle;
|
||||
else
|
||||
{
|
||||
GridRegion region = GridService.GetRegionByName(RegionInfo.ScopeID, regionName);
|
||||
if (region != null)
|
||||
regionHandle = region.RegionHandle;
|
||||
}
|
||||
|
||||
if(regionHandle == 0)
|
||||
{
|
||||
// can't find the region: Tell viewer and abort
|
||||
remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found.");
|
||||
return;
|
||||
}
|
||||
|
||||
RequestTeleportLocation(remoteClient, region.RegionHandle, position, lookat, teleportFlags);
|
||||
EntityTransferModule.Teleport(sp, regionHandle, position, lookat, teleportFlags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -4847,19 +4865,17 @@ Label_GroupsDone:
|
|||
public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position,
|
||||
Vector3 lookAt, uint teleportFlags)
|
||||
{
|
||||
ScenePresence sp = GetScenePresence(remoteClient.AgentId);
|
||||
if (sp != null)
|
||||
{
|
||||
if (EntityTransferModule != null)
|
||||
{
|
||||
EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
|
||||
}
|
||||
else
|
||||
if (EntityTransferModule == null)
|
||||
{
|
||||
m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
|
||||
sp.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ScenePresence sp = GetScenePresence(remoteClient.AgentId);
|
||||
if (sp == null || sp.IsDeleted || sp.IsInTransit)
|
||||
return;
|
||||
|
||||
EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
|
||||
}
|
||||
|
||||
public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
|
||||
|
|
|
@ -859,29 +859,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
//
|
||||
CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent");
|
||||
|
||||
TeleportAgent(agent, regionName, position, lookat, false);
|
||||
TeleportAgent(agent, regionName, position, lookat);
|
||||
}
|
||||
|
||||
private void TeleportAgent(string agent, string regionName,
|
||||
LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions)
|
||||
LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
UUID agentId = new UUID();
|
||||
if(String.IsNullOrWhiteSpace(regionName))
|
||||
return;
|
||||
|
||||
UUID agentId;
|
||||
if (UUID.TryParse(agent, out agentId))
|
||||
{
|
||||
ScenePresence presence = World.GetScenePresence(agentId);
|
||||
if (presence != null)
|
||||
if (presence == null || presence.IsDeleted || presence.IsInTransit)
|
||||
return;
|
||||
|
||||
if(regionName == World.RegionInfo.RegionName)
|
||||
{
|
||||
// should be faster than going to threadpool
|
||||
World.RequestTeleportLocation(presence.ControllingClient, regionName, position,
|
||||
lookat, (uint)TPFlags.ViaLocation);
|
||||
ScriptSleep(500);
|
||||
}
|
||||
else
|
||||
{
|
||||
// For osTeleportAgent, agent must be over owners land to avoid abuse
|
||||
// For osTeleportOwner, this restriction isn't necessary
|
||||
|
||||
// commented out because its redundant and uneeded please remove eventually.
|
||||
// if (relaxRestrictions ||
|
||||
// m_host.OwnerID
|
||||
// == World.LandChannel.GetLandObject(
|
||||
// presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
|
||||
// {
|
||||
|
||||
// We will launch the teleport on a new thread so that when the script threads are terminated
|
||||
// before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
|
||||
Util.FireAndForget(
|
||||
|
@ -889,11 +892,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
presence.ControllingClient, regionName, position,
|
||||
lookat, (uint)TPFlags.ViaLocation),
|
||||
null, "OSSL_Api.TeleportAgentByRegionCoords");
|
||||
|
||||
ScriptSleep(5000);
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -913,24 +912,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
ulong regionHandle = Util.RegionGridLocToHandle((uint)regionGridX, (uint)regionGridY);
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
UUID agentId = new UUID();
|
||||
UUID agentId;
|
||||
if (UUID.TryParse(agent, out agentId))
|
||||
{
|
||||
ScenePresence presence = World.GetScenePresence(agentId);
|
||||
if (presence != null)
|
||||
{
|
||||
// For osTeleportAgent, agent must be over owners land to avoid abuse
|
||||
// For osTeleportOwner, this restriction isn't necessary
|
||||
if (presence == null || presence.IsDeleted || presence.IsInTransit)
|
||||
return;
|
||||
|
||||
// commented out because its redundant and uneeded please remove eventually.
|
||||
// if (relaxRestrictions ||
|
||||
// m_host.OwnerID
|
||||
// == World.LandChannel.GetLandObject(
|
||||
// presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
|
||||
// {
|
||||
|
||||
// We will launch the teleport on a new thread so that when the script threads are terminated
|
||||
// before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
|
||||
Util.FireAndForget(
|
||||
o => World.RequestTeleportLocation(
|
||||
presence.ControllingClient, regionHandle,
|
||||
|
@ -938,16 +926,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
null, "OSSL_Api.TeleportAgentByRegionName");
|
||||
|
||||
ScriptSleep(5000);
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
|
||||
{
|
||||
osTeleportAgent(agent, World.RegionInfo.RegionName, position, lookat);
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
UUID agentId;
|
||||
if (UUID.TryParse(agent, out agentId))
|
||||
{
|
||||
ScenePresence presence = World.GetScenePresence(agentId);
|
||||
if (presence == null || presence.IsDeleted || presence.IsInTransit)
|
||||
return;
|
||||
|
||||
World.RequestTeleportLocation(presence.ControllingClient, World.RegionInfo.RegionName, position,
|
||||
lookat, (uint)TPFlags.ViaLocation);
|
||||
ScriptSleep(500);
|
||||
}
|
||||
}
|
||||
|
||||
public void osTeleportOwner(string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
|
||||
|
@ -955,12 +951,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
// Threat level None because this is what can already be done with the World Map in the viewer
|
||||
CheckThreatLevel(ThreatLevel.None, "osTeleportOwner");
|
||||
|
||||
TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat, true);
|
||||
TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat);
|
||||
}
|
||||
|
||||
public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
|
||||
{
|
||||
osTeleportOwner(World.RegionInfo.RegionName, position, lookat);
|
||||
osTeleportAgent(m_host.OwnerID.ToString(), position, lookat);
|
||||
}
|
||||
|
||||
public void osTeleportOwner(int regionGridX, int regionGridY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
|
||||
|
|
Loading…
Reference in New Issue