Fix convoy coordination, AI combat and spectator recovery
This commit is contained in:
@@ -63,12 +63,12 @@ run(r'''
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
struct vector {float x=0,y=0,z=0;static float Distance(vector a,vector b){return std::sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));}static float DistanceXZ(vector a,vector b){a.y=0;b.y=0;return Distance(a,b);}};
|
||||
struct vector {float x=0,y=0,z=0;std::string ToString(){return "point";}static float Distance(vector a,vector b){return std::sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));}static float DistanceXZ(vector a,vector b){a.y=0;b.y=0;return Distance(a,b);}};
|
||||
using IEntity=void*;
|
||||
template<class T>struct Items {std::vector<T> values;void Insert(T t){values.push_back(t);}};
|
||||
struct Replication {static inline bool server=true;static bool IsServer(){return server;}};
|
||||
struct ERR_HQReport {IEntity Target=this;int MessageId=1;float ObservedAt=0;bool Distress=false;vector Position{};std::string TravelMode="foot";std::string Description(float){return "contact";}ERR_HQReport* Snapshot(){return new ERR_HQReport(*this);}};
|
||||
struct ERR_MortarPrediction {static constexpr float MAX_REPORT_AGE_MS=60000;
|
||||
struct ERR_MortarPrediction {static constexpr float MAX_REPORT_AGE_MS=60000;static bool Predict(ERR_HQReport*,float,float,vector&){return true;}
|
||||
'''+fresh+r'''};
|
||||
struct ERR_MortarRefreshRules {
|
||||
'''+newer+r'''};
|
||||
@@ -90,6 +90,7 @@ struct ERR_MortarBattery {
|
||||
bool Operational(){return operational;}
|
||||
bool CanRefresh(ERR_HQReport*,float);bool BeginRefresh(ERR_HQReport*,ERR_HQRoute*,float);void RejectRefresh(std::string);
|
||||
void Cancel(std::string reason="cancel requested");void ObserveProjectile(IEntity,IEntity,bool);void FlushTraces(){}void DetachActivity(){}
|
||||
void Trace(std::string,std::string,std::string){}
|
||||
void Update(float){}bool SupplyPending(){return false;}int CountShells(){return 27;}
|
||||
bool CanRequest(ERR_HQReport*,float){return false;}bool BeginRequest(ERR_HQReport*,float){assert(false);return false;}
|
||||
};
|
||||
@@ -100,7 +101,7 @@ struct ERR_MortarAimSolution {
|
||||
IEntity Gun=nullptr;ERR_HQReport* Report=nullptr;int OrderId=1,Shot=0,Charge=0;vector GunOrigin{},Impact{500,0,0},AimTarget{500,500,0};float FlightTime=30;
|
||||
'''+matches+r'''};
|
||||
struct ERR_MortarSystem {
|
||||
HQ hq;HQ* m_HQ=&hq;int failures=0;
|
||||
HQ hq;HQ* m_HQ=&hq;int failures=0;std::string SafetyReason;bool Safe(ERR_MortarBattery*,vector,float){return true;}
|
||||
Items<ERR_MortarBattery*> m_Batteries;bool m_Stopped=false;float m_NextDecision=1e9f,m_NextRefreshDecision=0;
|
||||
bool Withhold(ERR_MortarBattery* b,const char* why){b->Rejected=true;b->LastFailure=why;failures++;return false;}
|
||||
void AdvanceRefresh(ERR_MortarBattery*,float);
|
||||
@@ -196,7 +197,7 @@ int main(){
|
||||
interrupted.b.ObserveProjectile(&interrupted.next,nullptr,false); // actual physical-event bookkeeping, not native launch proof
|
||||
assert(!interrupted.b.Released&&interrupted.b.OrderShots==1&&interrupted.b.TotalShots==1&&interrupted.b.Report==&interrupted.old);
|
||||
interrupted.system.Tick(25003);assert(!interrupted.b.CommandOpen&&!interrupted.b.Activity&&!interrupted.b.Report&&!interrupted.b.RefreshRejected);
|
||||
assert(interrupted.b.originalActivity.completions==1&&interrupted.b.transfer.invalidated==1&&interrupted.b.NextOrder==35003);
|
||||
assert(interrupted.b.originalActivity.completions==1&&interrupted.b.transfer.invalidated==1&&interrupted.b.NextOrder==85003);
|
||||
assert(interrupted.b.OrderShots==1&&interrupted.b.TotalShots==1&&interrupted.b.m_ReportLedger.claimed.count(2));
|
||||
F noRoute;noRoute.system.hq.contacts.Insert(&noRoute.next);noRoute.b.Released=true;
|
||||
noRoute.system.Tick(25000);assert(noRoute.system.hq.downlinks==1&&noRoute.b.RefreshRejected&&noRoute.b.Released);
|
||||
|
||||
Reference in New Issue
Block a user