mantis 8909: take number of npcs out of avatars limit check

This commit is contained in:
UbitUmarov
2021-07-16 01:14:51 +01:00
parent 9e7f77135d
commit 011868adc7
4 changed files with 44 additions and 15 deletions

View File

@@ -5202,9 +5202,9 @@ Label_GroupsDone:
#region SceneGraph wrapper methods
public void SwapRootAgentCount(bool rootChildChildRootTF)
public void SwapRootAgentCount(bool rootChildChildRootTF, bool isnpc)
{
m_sceneGraph.SwapRootChildAgent(rootChildChildRootTF);
m_sceneGraph.SwapRootChildAgent(rootChildChildRootTF, isnpc);
}
public void AddPhysicalPrim(int num)
@@ -6167,9 +6167,7 @@ Environment.Exit(1);
return false;
}
// FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
// However, the long term fix is to make sure root agent count is always accurate.
m_sceneGraph.RecalculateStats();
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(agentID);
// Fake AgentCircuitData to keep IAuthorizationModule smiling
@@ -6222,7 +6220,12 @@ Environment.Exit(1);
if(isManager)
return true;
// FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
// However, the long term fix is to make sure root agent count is always accurate.
m_sceneGraph.RecalculateStats();
int num = m_sceneGraph.GetRootAgentCount();
num -= m_sceneGraph.GetRootNPCCount();
if (num >= RegionInfo.RegionSettings.AgentLimit)
{
reason = "The region is full";

View File

@@ -79,10 +79,12 @@ namespace OpenSim.Region.Framework.Scenes
private PhysicsScene _PhyScene;
private int m_numRootAgents = 0;
private int m_numChildAgents = 0;
private int m_numRootNPC = 0;
private int m_numTotalPrim = 0;
private int m_numPrim = 0;
private int m_numMesh = 0;
private int m_numChildAgents = 0;
private int m_physicalPrim = 0;
private int m_activeScripts = 0;
@@ -763,6 +765,14 @@ namespace OpenSim.Region.Framework.Scenes
// Find the index in the list where the old ref was stored and remove the reference
m_scenePresenceLocalIDMap.Remove(oldref.LocalId);
m_scenePresenceList = null;
if(oldref.IsChildAgent)
--m_numChildAgents;
else
{
--m_numRootAgents;
if(oldref.IsNPC)
--m_numRootNPC;
}
}
else
{
@@ -776,17 +786,21 @@ namespace OpenSim.Region.Framework.Scenes
}
}
protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F)
protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F, bool isnpc = false)
{
if (direction_RC_CR_T_F)
{
m_numRootAgents--;
--m_numRootAgents;
if(isnpc)
--m_numRootNPC;
m_numChildAgents++;
}
else
{
m_numChildAgents--;
m_numRootAgents++;
--m_numChildAgents;
++m_numRootAgents;
if (isnpc)
++m_numRootNPC;
}
}
@@ -806,18 +820,25 @@ namespace OpenSim.Region.Framework.Scenes
{
int rootcount = 0;
int childcount = 0;
int rootnpccount = 0;
List<ScenePresence> presences = GetScenePresences();
for (int i = 0; i < presences.Count; ++i)
{
if (presences[i].IsChildAgent)
ScenePresence sp = presences[i];
if (sp.IsChildAgent)
++childcount;
else
{
++rootcount;
};
if(sp.IsNPC)
++rootnpccount;
}
}
m_numRootAgents = rootcount;
m_numChildAgents = childcount;
m_numRootNPC = rootnpccount;
}
public int GetChildAgentCount()
@@ -830,6 +851,11 @@ namespace OpenSim.Region.Framework.Scenes
return m_numRootAgents;
}
public int GetRootNPCCount()
{
return m_numRootNPC;
}
public int GetTotalObjectsCount()
{
return m_numTotalPrim;

View File

@@ -1574,7 +1574,7 @@ namespace OpenSim.Region.Framework.Scenes
}
//m_log.DebugFormat("[MakeRootAgent] position and physical: {0}ms", Util.EnvironmentTickCountSubtract(ts));
m_scene.SwapRootAgentCount(false);
m_scene.SwapRootAgentCount(false, IsNPC);
// If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will
// stall on the border crossing since the existing child agent will still have the last movement
@@ -1711,7 +1711,7 @@ namespace OpenSim.Region.Framework.Scenes
//Velocity = new Vector3(0, 0, 0);
IsChildAgent = true;
m_scene.SwapRootAgentCount(true);
m_scene.SwapRootAgentCount(true, IsNPC);
RemoveFromPhysicalScene();
ParentID = 0; // Child agents can't be sitting

View File

@@ -48,7 +48,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>();
private readonly Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>();
private NPCOptionsFlags m_NPCOptionFlags;
public NPCOptionsFlags NPCOptionFlags {get {return m_NPCOptionFlags;}}