Integrate finite infantry resupply with delivered low-ammunition reports
This commit is contained in:
@@ -20,7 +20,8 @@ methods='\n'.join(cpp(body(H,s)) for s in ('protected bool ConvoyPositionKnown('
|
||||
downlink=cpp(body(H,'if (unit.Downlink)\n'))
|
||||
cancel=cpp(body(H,'void CancelPending('))
|
||||
src=H.read_text()
|
||||
assert src.index('PlanConvoy(now); Assign(now);') > src.index('override void Tick(')
|
||||
tick=body(H,'override void Tick(')
|
||||
assert tick.index('PlanConvoy(now);') < tick.index('PlanResupply(now);') < tick.index('Assign(now);')
|
||||
assert 'm_Contacts' in body(H,'protected ERR_HQReport ConvoyContact(')
|
||||
assert 'GetOrigin' not in methods and 'Target' not in methods
|
||||
run(r'''
|
||||
@@ -41,7 +42,7 @@ struct ERR_HQRoute {int MessageId=0;string Payload;int result=0;int Advance(floa
|
||||
struct Network {bool available=true;int calls=0;ERR_HQRoute* Route(void*,bool down){assert(down);calls++;return available?new ERR_HQRoute:nullptr;}};
|
||||
struct ERR_ConvoyCombatOrder {int CommandId=0,ReportId=0,VehicleIndex=0;string SourceId;SCR_AIGroup* Group=nullptr;bool Hold=false;float ObservedAt=-1,IssuedAt=0,ExpiresAt=0;};
|
||||
struct CombatState {bool Held=false;int LastCommandId=0,ReportId=0;float ObservedAt=-1;};
|
||||
struct ERR_ConvoyVehicle {int Index=0;SCR_AIGroup* Group=nullptr;bool Released=false,Arrived=false,Registered=true;CombatState state;CombatState* Combat=&state;};
|
||||
struct ERR_ConvoyVehicle {int SupplyToken=0,Index=0;SCR_AIGroup* Group=nullptr;bool Released=false,Arrived=false,Registered=true;CombatState state;CombatState* Combat=&state;};
|
||||
struct Receipt {string SourceId="convoy-1";};
|
||||
struct ConvoyTask {bool Stopped=false,Ready=true;struct Receipt receipt;struct Receipt* Receipt=&receipt;std::vector<ERR_ConvoyVehicle*> Vehicles;};
|
||||
struct Service {int calls=0;bool valid=true;ERR_ConvoyCombatOrder* last=nullptr;
|
||||
@@ -66,6 +67,7 @@ int main(){
|
||||
ERR_HQReport r;r.MessageId=1;r.ObservedAt=2000;r.Position={200,0};
|
||||
h.PlanConvoy(3000);assert(!u.Downlink); // no delivered own status or target report
|
||||
h.m_Watch.entries[u.ForceSourceId]=&e;h.PlanConvoy(3000);assert(!u.Downlink);
|
||||
h.m_Contacts={&r};v.SupplyToken=100001;h.PlanConvoy(3000);assert(!u.Downlink);v.SupplyToken=0;
|
||||
h.m_Contacts={&r};h.m_Network.available=false;h.PlanConvoy(3000);assert(!u.Downlink&&!v.Combat->Held);
|
||||
h.m_Network.available=true;h.PlanConvoy(3000);assert(u.Downlink&&u.PendingConvoyOrder->Hold);
|
||||
auto pending=u.PendingConvoyOrder;int calls=h.m_Network.calls;h.PlanConvoy(4000);assert(h.m_Network.calls==calls&&u.PendingConvoyOrder==pending);
|
||||
|
||||
Reference in New Issue
Block a user