do agent crossing async, including QUERYACCESS ( need to check vehicles for

this also ), so it doesn't stop heartbeat
avinationmerge
UbitUmarov 2014-10-21 11:57:47 +01:00
parent afa9b4a002
commit 59413adcee
3 changed files with 56 additions and 10 deletions

View File

@ -1510,6 +1510,30 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
} }
public bool Cross(ScenePresence agent, bool isFlying) public bool Cross(ScenePresence agent, bool isFlying)
{
agent.IsInTransit = true;
CrossAsyncDelegate d = CrossAsync;
d.BeginInvoke(agent, isFlying, CrossCompleted, d);
return true;
}
private void CrossCompleted(IAsyncResult iar)
{
CrossAsyncDelegate icon = (CrossAsyncDelegate)iar.AsyncState;
ScenePresence agent = icon.EndInvoke(iar);
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
if(!agent.IsChildAgent)
{
// crossing failed
agent.CrossToNewRegionFail();
}
agent.IsInTransit = false;
}
public ScenePresence CrossAsync(ScenePresence agent, bool isFlying)
{ {
uint x; uint x;
uint y; uint y;
@ -1525,16 +1549,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (reason == String.Empty) if (reason == String.Empty)
agent.ControllingClient.SendAlertMessage("Cannot cross to region"); agent.ControllingClient.SendAlertMessage("Cannot cross to region");
else else
agent.ControllingClient.SendAlertMessage("Cannot cross to region: " + reason); agent.ControllingClient.SendAlertMessage("Cannot cross to region: " + reason);
return false; return agent;
} }
agent.IsInTransit = true; // agent.IsInTransit = true;
CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; CrossAgentToNewRegionAsync(agent, newpos, neighbourRegion, isFlying, version);
d.BeginInvoke(agent, newpos, neighbourRegion, isFlying, version, CrossAgentToNewRegionCompleted, d); agent.IsInTransit = false;
return agent;
return true;
} }
@ -1787,8 +1810,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
agent.CloseChildAgents(neighbourx, neighboury); agent.CloseChildAgents(neighbourx, neighboury);
// the user may change their profile information in other region, // the user may change their profile information in other region,
// so the userinfo in UserProfileCache is not reliable any more, delete it // so the userinfo in UserProfileCache is not reliable any more, delete it
// REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!

View File

@ -36,6 +36,7 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Framework.Interfaces namespace OpenSim.Region.Framework.Interfaces
{ {
public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version); public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version);
public delegate ScenePresence CrossAsyncDelegate(ScenePresence agent, bool isFlying);
public interface IEntityTransferModule public interface IEntityTransferModule
{ {

View File

@ -3980,6 +3980,30 @@ namespace OpenSim.Region.Framework.Scenes
} }
public void CrossToNewRegionFail()
{
if (m_requestedSitTargetUUID == UUID.Zero)
{
bool isFlying = 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);
}
}
/// <summary> /// <summary>
/// Moves the agent outside the region bounds /// Moves the agent outside the region bounds
/// Tells neighbor region that we're crossing to it /// Tells neighbor region that we're crossing to it
@ -3996,7 +4020,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
catch catch
{ {
result = m_scene.CrossAgentToNewRegion(this, false); // result = m_scene.CrossAgentToNewRegion(this, false);
} }
// if(!result) // if(!result)
// parcelRegionCross(true); // parcelRegionCross(true);