41 lines
1.5 KiB
C
41 lines
1.5 KiB
C
// HQ creates these snapshots from delivered sightings and sends each command
|
|
// through the original group's physical radio downlink before execution.
|
|
class ERR_ConvoyCombatOrder
|
|
{
|
|
int CommandId;
|
|
int ReportId;
|
|
int VehicleIndex;
|
|
string SourceId;
|
|
SCR_AIGroup Group;
|
|
bool Hold;
|
|
float ObservedAt = -1;
|
|
float IssuedAt = -1;
|
|
float ExpiresAt = -1;
|
|
}
|
|
|
|
class ERR_ConvoyCombatState
|
|
{
|
|
bool Held;
|
|
int LastCommandId;
|
|
int ReportId;
|
|
float ObservedAt = -1;
|
|
}
|
|
|
|
class ERR_ConvoyCombatRules
|
|
{
|
|
static bool Accept(ERR_ConvoyCombatState state, ERR_ConvoyCombatOrder order, float now)
|
|
{
|
|
if (!state || !order || order.CommandId <= state.LastCommandId || order.CommandId <= 0 || order.ReportId <= 0) return false;
|
|
if (!ERR_ForceRules.Finite(now) || !ERR_ForceRules.Finite(order.ObservedAt) || !ERR_ForceRules.Finite(order.IssuedAt) || !ERR_ForceRules.Finite(order.ExpiresAt)) return false;
|
|
if (order.ObservedAt < 0 || order.IssuedAt < order.ObservedAt || now < order.IssuedAt || now >= order.ExpiresAt || order.ExpiresAt <= order.IssuedAt || order.ExpiresAt - order.IssuedAt > 30000) return false;
|
|
if (order.Hold)
|
|
{
|
|
if (now - order.ObservedAt > 60000 || order.ObservedAt < state.ObservedAt) return false;
|
|
if (state.ReportId == order.ReportId && state.ObservedAt != order.ObservedAt) return false;
|
|
if (order.ReportId < state.ReportId) return false;
|
|
return true;
|
|
}
|
|
return state.Held && order.ReportId == state.ReportId && order.ObservedAt == state.ObservedAt && order.IssuedAt - state.ObservedAt >= 60000;
|
|
}
|
|
}
|