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);
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);
if (sp.Scene.CapsModule != null)
@ -1920,6 +1917,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
/// <param name="sp"></param>
public void EnableChildAgents(ScenePresence sp)
{
// assumes that out of view range regions are disconnected by the previus region
List<GridRegion> neighbours = new List<GridRegion>();
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);
List<ulong> newneighbours = new List<ulong>();
List<AgentCircuitData> cagents = new List<AgentCircuitData>();
List<GridRegion> newneighbours = new List<GridRegion>();
ulong currentRegionHandler = sp.Scene.RegionInfo.RegionHandle;
@ -1961,9 +1960,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
{
ulong handler = neighbour.RegionHandle;
if (previousRegionNeighbourHandles.Contains(handler))
{
// agent already knows this region
previousRegionNeighbourHandles.Remove(handler);
continue;
}
if (handler == currentRegionHandler)
continue;
// a new region to add
AgentCircuitData agent = sp.ControllingClient.RequestClientInfo();
agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero;
@ -1982,58 +1989,43 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
agent.Id0 = currentAgentCircuit.Id0;
}
if (previousRegionNeighbourHandles.Contains(handler))
{
previousRegionNeighbourHandles.Remove(handler);
agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, handler);
}
else
{
newneighbours.Add(handler);
newneighbours.Add(neighbour);
agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
sp.AddNeighbourRegion(handler, agent.CapsPath);
seeds.Add(handler, agent.CapsPath);
}
cagents.Add(agent);
}
//sp.DropOldNeighbours(previousRegionNeighbourHandles);
foreach (ulong handle in previousRegionNeighbourHandles)
{
sp.RemoveNeighbourRegion(handle);
Scene.CapsModule.DropChildSeed(sp.UUID, handle);
}
if (previousRegionNeighbourHandles.Contains(currentRegionHandler))
previousRegionNeighbourHandles.Remove(currentRegionHandler);
// previousRegionNeighbourHandles now contains regions to forget
foreach (uint handler in previousRegionNeighbourHandles)
seeds.Remove(handler);
/// Update all child agent with everyone's seeds
foreach (AgentCircuitData a in cagents)
{
a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
}
if (sp.Scene.CapsModule != null)
{
sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds);
}
sp.KnownRegions = seeds;
//avatar.Scene.DumpChildrenSeeds(avatar.UUID);
//avatar.DumpKnownRegions();
if (newneighbours.Count > 0)
{
Util.FireAndForget(delegate
{
Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start
int count = 0;
bool newagent;
foreach (GridRegion neighbour in neighbours)
foreach (GridRegion neighbour in newneighbours)
{
try
{
newagent = newneighbours.Contains(neighbour.RegionHandle);
InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newagent);
InformClientOfNeighbourAsync(sp, cagents[count], neighbour,
neighbour.ExternalEndPoint, true);
count++;
}
catch (ArgumentOutOfRangeException)
{
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.
// throw e;
}
count++;
}
});
}
}
Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour)
{
@ -2094,10 +2086,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
/// <param name="endPoint"></param>
private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg,
IPEndPoint endPoint, bool newAgent)
{
if (newAgent)
{
Scene scene = sp.Scene;
if (!newAgent)
return;
m_log.DebugFormat(
"[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);
if (regionAccepted && newAgent)
if (regionAccepted)
{
// give time for createAgent to finish, since it is async and does grid services access
Thread.Sleep(500);
@ -2147,6 +2140,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
reg.RegionName, sp.Name, sp.UUID, reason);
}
}
/// <summary>
/// Gets the range considered in view of this megaregion (assuming this is a megaregion).
/// </summary>
@ -2203,6 +2198,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
int endX = (int)pRegionLocX * (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 =
avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
@ -2227,7 +2225,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return neighbours;
}
}
/* not in use
private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
{
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); });
// }
private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
{
return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
}
// private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
// {
// return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
// }
private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
{
List<ulong> handles = new List<ulong>();
foreach (GridRegion reg in neighbours)
{
handles.Add(reg.RegionHandle);
}
return handles;
}
// private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
// {
// List<ulong> handles = new List<ulong>();
// foreach (GridRegion reg in neighbours)
// {
// handles.Add(reg.RegionHandle);
// }
// return 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);
// }
// }
*/
#endregion
#region Agent Arrived

View File

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