Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
104 lines
4.4 KiB
C
104 lines
4.4 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 int Burst;
|
|
static bool Moved, Cancelled;
|
|
static int PlaneFailures;
|
|
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 Attempt(ERR_TownGarrison town, array<vector> players, float now)
|
|
{
|
|
int before=town.Spawned; super.Attempt(town,players,now);
|
|
ERR_LagFixture.Burst=Math.Max(ERR_LagFixture.Burst,town.Spawned-before);
|
|
if(!ERR_LagFixture.Moved&&town.Spawned==1&&!town.Finished&&town.Positions.Count()>1)
|
|
{
|
|
ERR_LagFixture.Moved=true; ERR_LagFixture.Observer=town.Positions[1];
|
|
Print("ERR PLANE TEST observer moved into remaining planned guard positions");
|
|
}
|
|
if(ERR_LagFixture.Moved&&town.Finished&&!town.Admitted&&town.Spawned==1&&!town.Group) ERR_LagFixture.Cancelled=true;
|
|
}
|
|
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;
|
|
protected int m_StoppedCount;
|
|
protected float m_DoneAt;
|
|
protected bool m_FinalPrinted;
|
|
protected void CheckStop()
|
|
{
|
|
PrintFormat("ERR PLANE COMPLETE faults birth_burst=%1 moved=%2 cancelled=%3 setup_failures=%4 callbacks_stopped=%5",ERR_LagFixture.Burst,ERR_LagFixture.Moved,ERR_LagFixture.Cancelled,ERR_LagFixture.PlaneFailures,ERR_LagFixture.WorkCount==m_StoppedCount);
|
|
}
|
|
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())return;
|
|
if(m_LagDone) { if(!m_FinalPrinted && world.GetWorldTime()-m_DoneAt>2000) { m_FinalPrinted=true;CheckStop(); } 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; m_DoneAt=now; m_StoppedCount=ERR_LagFixture.WorkCount; hq.Stop(); PrintFormat("ERR PLANE FAULT SUMMARY 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() {}
|
|
}
|
|
|
|
// Deliberate preparation failure tests the production retry circuit breaker.
|
|
modded class ERR_PlaneFlight
|
|
{
|
|
override protected bool Prepare(float now)
|
|
{
|
|
ERR_LagFixture.PlaneFailures++; Fail("injected native fixture preparation failure"); return false;
|
|
}
|
|
}
|