Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
73 lines
3.0 KiB
C
73 lines
3.0 KiB
C
class ERR_LagFixture
|
|
{
|
|
static vector Centre;
|
|
static vector Observer;
|
|
static bool Ready;
|
|
static int WorkCount;
|
|
static int WorkMax;
|
|
static int WorkSum;
|
|
static int Admitted;
|
|
static int Unsafe;
|
|
static bool Place(IEntity entity)
|
|
{
|
|
Centre = entity.GetOrigin(); Observer = ERR_Actors.Ground(Centre + "690 0 0"); Ready = true; return false;
|
|
}
|
|
static bool Town(IEntity entity)
|
|
{
|
|
MapDescriptorComponent d = MapDescriptorComponent.Cast(entity.FindComponent(MapDescriptorComponent));
|
|
return d && d.GetBaseType() == EMapDescriptorType.MDT_NAME_CITY;
|
|
}
|
|
}
|
|
modded class ERR_TownGarrisons
|
|
{
|
|
override protected void Players(out array<vector> positions)
|
|
{
|
|
positions.Clear(); if (ERR_LagFixture.Ready) positions.Insert(ERR_LagFixture.Observer);
|
|
}
|
|
override protected void Work(float now)
|
|
{
|
|
int start=System.GetTickCount(); super.Work(now); int elapsed=System.GetTickCount()-start;
|
|
ERR_LagFixture.WorkCount++; ERR_LagFixture.WorkMax=Math.Max(ERR_LagFixture.WorkMax,elapsed); ERR_LagFixture.WorkSum+=elapsed;
|
|
}
|
|
override protected void Admitted(ERR_TownGarrison town)
|
|
{
|
|
super.Admitted(town); ERR_LagFixture.Admitted++;
|
|
array<AIAgent> agents={};town.Group.GetAgents(agents);
|
|
foreach(AIAgent a:agents) if(vector.DistanceXZ(a.GetControlledEntity().GetOrigin(),ERR_LagFixture.Observer)<SpawnDistance()) ERR_LagFixture.Unsafe++;
|
|
}
|
|
}
|
|
modded class ArmaReforgerScripted
|
|
{
|
|
protected float m_LagStart,m_LagNext,m_LagPrint;
|
|
protected bool m_LagDone,m_LagAirborne;
|
|
override void OnUpdate(BaseWorld world,float timeslice)
|
|
{
|
|
super.OnUpdate(world,timeslice);
|
|
ERR_GameMode mode=ERR_GameMode.Get();ERR_HQ hq=ERR_HQ.Get();
|
|
if(!mode||!hq||!mode.Active()||m_LagDone)return;
|
|
float now=world.GetWorldTime();
|
|
if(m_LagStart==0)
|
|
{
|
|
m_LagStart=now;
|
|
vector low,high;GetGame().GetWorldEntity().GetWorldBounds(low,high);
|
|
world.QueryEntitiesByAABB(low,high,ERR_LagFixture.Place,ERR_LagFixture.Town,EQueryEntitiesFlags.ALL);
|
|
mode.Transition(ERR_Phase.RADIO_SEARCH);
|
|
PrintFormat("ERR PLANE GUARD FIXTURE ready=%1 observer=%2",ERR_LagFixture.Ready,ERR_LagFixture.Observer);
|
|
}
|
|
if(now>=m_LagNext){m_LagNext=now+1000;hq.Tick(now);hq.Journal().Flush();}
|
|
ERR_PlaneFlight flight=hq.PlaneRecon().Current();
|
|
if(flight&&flight.Airborne())m_LagAirborne=true;
|
|
if(now>=m_LagPrint){m_LagPrint=now+10000;PrintFormat("ERR PLANE GUARD samples=%1 max=%2 admitted=%3 unsafe=%4 status=%5",ERR_LagFixture.WorkCount,ERR_LagFixture.WorkMax,ERR_LagFixture.Admitted,ERR_LagFixture.Unsafe,hq.PlaneRecon().Status());}
|
|
if(now-m_LagStart>150000)
|
|
{
|
|
m_LagDone=true;PrintFormat("ERR PLANE COMPLETE guards=%1 unsafe=%2 slices=%3 max_ms=%4 sum_ms=%5 plane_airborne=%6",ERR_LagFixture.Admitted,ERR_LagFixture.Unsafe,ERR_LagFixture.WorkCount,ERR_LagFixture.WorkMax,ERR_LagFixture.WorkSum,m_LagAirborne);
|
|
}
|
|
}
|
|
}
|
|
// Component fixture: do not generate unrelated optional mission sites. The
|
|
// production guard discovery/placement, physics, roster and plane remain active.
|
|
modded class ERR_ScenarioComponent
|
|
{
|
|
override protected void BackgroundStep() {}
|
|
}
|