Mantis #2584 (again)

Next step of diva's TP fixes and HG support
0.6.1-post-fixes
Melanie Thielker 2008-11-30 23:36:56 +00:00
parent 96921c402c
commit d1841ca94d
6 changed files with 93 additions and 22 deletions

View File

@ -347,6 +347,12 @@ namespace OpenSim.Framework
return (x + y - (min >> 1) - (min >> 2) + (min >> 4));
}
public static bool IsOutsideView(uint oldx, uint newx, uint oldy, uint newy)
{
// Eventually this will be a function of the draw distance / camera position too.
return ((Math.Abs((int)(oldx - newx)) > 1) || (Math.Abs((int)(oldy - newy)) > 1));
}
public static string FieldToString(byte[] bytes)
{
return FieldToString(bytes, String.Empty);

View File

@ -644,6 +644,7 @@ namespace OpenSim.Region.Communications.Hypergrid
public override bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID)
{
m_log.Debug("[HGrid]: TellRegion " + regionHandle + " ToCloseChildConnection for " + agentID);
RegionInfo regInfo = null;
try
{

View File

@ -222,25 +222,28 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid
KiPrimitive(avatar.LocalId);
}
avatar.Close();
uint newRegionX = (uint)(reg.RegionHandle >> 40);
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
// Let's close some children agents
if (isHyperLink) // close them all
SendCloseChildAgentConnections(avatar.UUID, avatar.GetKnownRegionList());
else // close just a few
avatar.CloseChildAgents(newRegionX, newRegionY);
avatar.Close();
// Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
///
/// Hypergrid mod: extra check for isHyperLink
///
if ((Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) || isHyperLink)
//if ((Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 1) || isHyperLink)
//if (((int)Math.Abs((int)(newRegionX - oldRegionX)) > 1) || ((int)Math.Abs((int)(newRegionY - oldRegionY)) > 1) || isHyperLink)
if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
{
//SendCloseChildAgentConnections(avatar.UUID, avatar.GetKnownRegionList());
SendCloseChildAgentConnections(avatar.UUID, childRegions);
if (eq != null)
{
OSD Item = EventQueueHelper.DisableSimulator(m_regionInfo.RegionHandle);
eq.Enqueue(Item, avatar.UUID);
}
Thread.Sleep(2000);
CloseConnection(avatar.UUID);
}
// if (teleport success) // seems to be always success here

View File

@ -52,6 +52,7 @@ using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
using Image = System.Drawing.Image;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
using Timer = System.Timers.Timer;
using OSD = OpenMetaverse.StructuredData.OSD;
namespace OpenSim.Region.Environment.Scenes
{
@ -2807,9 +2808,10 @@ namespace OpenSim.Region.Environment.Scenes
capsPaths[agent.AgentID] = agent.CapsPath;
AddCapsHandler(agent.AgentID);
if (!agent.child)
{
AddCapsHandler(agent.AgentID);
// Honor parcel landing type and position.
ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
@ -3027,7 +3029,18 @@ namespace OpenSim.Region.Environment.Scenes
// }
// Tell a single agent to disconnect from the region.
// This sends DisableSimulator over UDP, but that doesn't seem to be working
// well with the latest LL viewer, so we're sending it also via the EQ
presence.ControllingClient.SendShutdownConnectionNotice();
IEventQueue eq = RequestModuleInterface<IEventQueue>();
if (eq != null)
{
OSD Item = EventQueueHelper.DisableSimulator(m_regInfo.RegionHandle);
eq.Enqueue(Item, agentID);
m_log.Debug("[Scene]: Enqueuing DisableSimulator for " + agentID + " in region " + m_regInfo.RegionName);
Thread.Sleep(2000);
}
RemoveCapsHandler(agentID);
presence.ControllingClient.Close(true);
}

View File

@ -230,7 +230,7 @@ namespace OpenSim.Region.Environment.Scenes
protected bool CloseConnection(UUID agentID)
{
m_log.Debug("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID);
handlerCloseAgentConnection = OnCloseAgentConnection;
if (handlerCloseAgentConnection != null)
{
@ -727,24 +727,31 @@ namespace OpenSim.Region.Environment.Scenes
KiPrimitive(avatar.LocalId);
}
avatar.Close();
uint newRegionX = (uint)(reg.RegionHandle >> 40);
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3)
// Let's close some children agents
avatar.CloseChildAgents(newRegionX, newRegionY);
avatar.Close();
// Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
// This is a little too fast of a distance computation... it's not consistent with the rule
// of having child agents in exactly the adjacent regions. Some topologies result in orphan
// children
//if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3)
//if (((int)Math.Abs((int)(newRegionX - oldRegionX)) > 1) || ((int)Math.Abs((int)(newRegionY - oldRegionY)) > 1))
if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
{
//SendCloseChildAgentConnections(avatar.UUID,avatar.GetKnownRegionList());
SendCloseChildAgentConnections(avatar.UUID, childRegions);
if (eq != null)
{
OSD Item = EventQueueHelper.DisableSimulator(m_regionInfo.RegionHandle);
eq.Enqueue(Item, avatar.UUID);
}
Thread.Sleep(2000);
//SendCloseChildAgentConnections(avatar.UUID, childRegions);
CloseConnection(avatar.UUID);
}
// if (teleport success) // seems to be always success here
// the user may change their profile information in other region,
// so the userinfo in UserProfileCache is not reliable any more, delete it

View File

@ -2373,7 +2373,10 @@ namespace OpenSim.Region.Environment.Scenes
CrossAttachmentsIntoNewRegion(neighbourHandle, true);
// m_scene.SendKillObject(m_localId);
// Next, let's close the child agent connections that are too far away.
CloseChildAgents(neighbourx, neighboury);
// m_scene.SendKillObject(m_localId);
m_scene.NotifyMyCoarseLocationChange();
// the user may change their profile information in other region,
@ -2391,6 +2394,44 @@ namespace OpenSim.Region.Environment.Scenes
}
}
/// <summary>
/// Computes which child agents to close when the scene presence moves to another region.
/// Removes those regions from m_knownRegions.
/// </summary>
/// <param name="newRegionX">The new region's x on the map</param>
/// <param name="newRegionY">The new region's y on the map</param>
/// <returns></returns>
public void CloseChildAgents(uint newRegionX, uint newRegionY)
{
List<ulong> byebyeRegions = new List<ulong>();
foreach (ulong handle in m_knownChildRegions)
{
uint x, y;
Utils.LongToUInts(handle, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
if (Util.IsOutsideView(x, newRegionX, y, newRegionY))
{
Console.WriteLine("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs(x-newRegionX));
Console.WriteLine("---> y: " + y + "; newy:" + newRegionY);
byebyeRegions.Add(handle);
}
}
foreach (ulong handle in byebyeRegions)
{
RemoveNeighbourRegion(handle);
}
if (byebyeRegions.Count > 0)
{
m_log.Info("[AVATAR]: Closing " + byebyeRegions.Count + " child agents");
m_scene.SceneGridService.SendCloseChildAgentConnections(m_controllingClient.AgentId, byebyeRegions);
}
}
#endregion
/// <summary>