change child agents creation/notification. As before this assumes that

sending regions close out of view connections.
avinationmerge
UbitUmarov 2014-10-18 18:27:38 +01:00
parent f9588730cf
commit b7708b9d1f
2 changed files with 120 additions and 122 deletions

View File

@ -1875,9 +1875,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
//m_log.DebugFormat("[XXX] Seeds 2 {0}", agent.ChildrenCapSeeds.Count); //m_log.DebugFormat("[XXX] Seeds 2 {0}", agent.ChildrenCapSeeds.Count);
sp.AddNeighbourRegion(region.RegionHandle, agent.CapsPath); sp.AddNeighbourRegion(region.RegionHandle, agent.CapsPath);
//foreach (ulong h in agent.ChildrenCapSeeds.Keys)
// m_log.DebugFormat("[XXX] --> {0}", h);
//m_log.DebugFormat("[XXX] Adding {0}", region.RegionHandle);
agent.ChildrenCapSeeds.Add(region.RegionHandle, agent.CapsPath); agent.ChildrenCapSeeds.Add(region.RegionHandle, agent.CapsPath);
if (sp.Scene.CapsModule != null) if (sp.Scene.CapsModule != null)
@ -1920,6 +1917,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
/// <param name="sp"></param> /// <param name="sp"></param>
public void EnableChildAgents(ScenePresence sp) public void EnableChildAgents(ScenePresence sp)
{ {
// assumes that out of view range regions are disconnected by the previus region
List<GridRegion> neighbours = new List<GridRegion>(); List<GridRegion> neighbours = new List<GridRegion>();
RegionInfo m_regionInfo = sp.Scene.RegionInfo; RegionInfo m_regionInfo = sp.Scene.RegionInfo;
@ -1952,8 +1951,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
List<ulong> newneighbours = new List<ulong>();
List<AgentCircuitData> cagents = new List<AgentCircuitData>(); List<AgentCircuitData> cagents = new List<AgentCircuitData>();
List<GridRegion> newneighbours = new List<GridRegion>();
ulong currentRegionHandler = sp.Scene.RegionInfo.RegionHandle; ulong currentRegionHandler = sp.Scene.RegionInfo.RegionHandle;
@ -1961,9 +1960,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
{ {
ulong handler = neighbour.RegionHandle; ulong handler = neighbour.RegionHandle;
if (previousRegionNeighbourHandles.Contains(handler))
{
// agent already knows this region
previousRegionNeighbourHandles.Remove(handler);
continue;
}
if (handler == currentRegionHandler) if (handler == currentRegionHandler)
continue; continue;
// a new region to add
AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); AgentCircuitData agent = sp.ControllingClient.RequestClientInfo();
agent.BaseFolder = UUID.Zero; agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero; agent.InventoryFolder = UUID.Zero;
@ -1982,58 +1989,43 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
agent.Id0 = currentAgentCircuit.Id0; agent.Id0 = currentAgentCircuit.Id0;
} }
if (previousRegionNeighbourHandles.Contains(handler)) newneighbours.Add(neighbour);
{
previousRegionNeighbourHandles.Remove(handler);
agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, handler);
}
else
{
newneighbours.Add(handler);
agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
sp.AddNeighbourRegion(handler, agent.CapsPath);
seeds.Add(handler, agent.CapsPath); seeds.Add(handler, agent.CapsPath);
}
cagents.Add(agent); cagents.Add(agent);
} }
//sp.DropOldNeighbours(previousRegionNeighbourHandles); if (previousRegionNeighbourHandles.Contains(currentRegionHandler))
foreach (ulong handle in previousRegionNeighbourHandles) previousRegionNeighbourHandles.Remove(currentRegionHandler);
{
sp.RemoveNeighbourRegion(handle); // previousRegionNeighbourHandles now contains regions to forget
Scene.CapsModule.DropChildSeed(sp.UUID, handle); foreach (uint handler in previousRegionNeighbourHandles)
} seeds.Remove(handler);
/// Update all child agent with everyone's seeds /// Update all child agent with everyone's seeds
foreach (AgentCircuitData a in cagents) foreach (AgentCircuitData a in cagents)
{
a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds); a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
}
if (sp.Scene.CapsModule != null) if (sp.Scene.CapsModule != null)
{
sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds); sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds);
}
sp.KnownRegions = seeds; sp.KnownRegions = seeds;
//avatar.Scene.DumpChildrenSeeds(avatar.UUID);
//avatar.DumpKnownRegions();
if (newneighbours.Count > 0)
{
Util.FireAndForget(delegate Util.FireAndForget(delegate
{ {
Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start
int count = 0; int count = 0;
bool newagent;
foreach (GridRegion neighbour in neighbours) foreach (GridRegion neighbour in newneighbours)
{ {
try try
{ {
newagent = newneighbours.Contains(neighbour.RegionHandle); InformClientOfNeighbourAsync(sp, cagents[count], neighbour,
InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newagent); neighbour.ExternalEndPoint, true);
count++;
} }
catch (ArgumentOutOfRangeException) catch (ArgumentOutOfRangeException)
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
@ -2059,10 +2051,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// XXX: Well, decided to swallow the exception instead for now. Let us see how that goes. // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
// throw e; // throw e;
} }
count++;
} }
}); });
} }
}
Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour) Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour)
{ {
@ -2094,10 +2086,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
/// <param name="endPoint"></param> /// <param name="endPoint"></param>
private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg, private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg,
IPEndPoint endPoint, bool newAgent) IPEndPoint endPoint, bool newAgent)
{
if (newAgent)
{ {
Scene scene = sp.Scene; Scene scene = sp.Scene;
if (!newAgent)
return;
m_log.DebugFormat( m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})", "[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})",
@ -2109,7 +2102,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
bool regionAccepted = scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason); bool regionAccepted = scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason);
if (regionAccepted && newAgent) if (regionAccepted)
{ {
// give time for createAgent to finish, since it is async and does grid services access // give time for createAgent to finish, since it is async and does grid services access
Thread.Sleep(500); Thread.Sleep(500);
@ -2127,7 +2120,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " + m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " +
"and EstablishAgentCommunication with seed cap {8}", LogHeader, "and EstablishAgentCommunication with seed cap {8}", LogHeader,
scene.RegionInfo.RegionName, sp.Name, scene.RegionInfo.RegionName, sp.Name,
reg.RegionName, reg.RegionLocX, reg.RegionLocY, reg.RegionSizeX, reg.RegionSizeY , capsPath); reg.RegionName, reg.RegionLocX, reg.RegionLocY, reg.RegionSizeX, reg.RegionSizeY, capsPath);
m_eqModule.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID, reg.RegionSizeX, reg.RegionSizeY); m_eqModule.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID, reg.RegionSizeX, reg.RegionSizeY);
m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath, reg.RegionHandle, reg.RegionSizeX, reg.RegionSizeY); m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath, reg.RegionHandle, reg.RegionSizeX, reg.RegionSizeY);
@ -2147,6 +2140,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
reg.RegionName, sp.Name, sp.UUID, reason); reg.RegionName, sp.Name, sp.UUID, reason);
} }
}
/// <summary> /// <summary>
/// Gets the range considered in view of this megaregion (assuming this is a megaregion). /// Gets the range considered in view of this megaregion (assuming this is a megaregion).
/// </summary> /// </summary>
@ -2203,6 +2198,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
int endX = (int)pRegionLocX * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2); int endX = (int)pRegionLocX * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2);
int endY = (int)pRegionLocY * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2); int endY = (int)pRegionLocY * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2);
if (startX < 0) startX = 0;
if (startY < 0) startY = 0;
List<GridRegion> neighbours = List<GridRegion> neighbours =
avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY); avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
@ -2227,7 +2225,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return neighbours; return neighbours;
} }
} }
/* not in use
private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
{ {
return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); }); return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); });
@ -2238,20 +2236,20 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); }); // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); });
// } // }
private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) // private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
{ // {
return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); }); // return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
} // }
private List<ulong> NeighbourHandles(List<GridRegion> neighbours) // private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
{ // {
List<ulong> handles = new List<ulong>(); // List<ulong> handles = new List<ulong>();
foreach (GridRegion reg in neighbours) // foreach (GridRegion reg in neighbours)
{ // {
handles.Add(reg.RegionHandle); // handles.Add(reg.RegionHandle);
} // }
return handles; // return handles;
} // }
// private void Dump(string msg, List<ulong> handles) // private void Dump(string msg, List<ulong> handles)
// { // {
@ -2265,7 +2263,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// m_log.InfoFormat("({0}, {1})", x, y); // m_log.InfoFormat("({0}, {1})", x, y);
// } // }
// } // }
*/
#endregion #endregion
#region Agent Arrived #region Agent Arrived

View File

@ -4082,13 +4082,13 @@ namespace OpenSim.Region.Framework.Scenes
"[SCENE]: Adjusting known seeds for existing agent {0} in {1}", "[SCENE]: Adjusting known seeds for existing agent {0} in {1}",
acd.AgentID, RegionInfo.RegionName); acd.AgentID, RegionInfo.RegionName);
sp.AdjustKnownSeeds();
if (CapsModule != null) if (CapsModule != null)
{ {
CapsModule.SetAgentCapsSeeds(acd); CapsModule.SetAgentCapsSeeds(acd);
CapsModule.CreateCaps(acd.AgentID, acd.circuitcode); CapsModule.CreateCaps(acd.AgentID, acd.circuitcode);
} }
sp.AdjustKnownSeeds();
} }
} }