Add typed field-flight prototype and preserve native qualification failures

This commit is contained in:
2026-09-19 21:01:20 +02:00
parent 83ea247e62
commit 61e165ef5b
91 changed files with 40570 additions and 85 deletions
@@ -6,7 +6,7 @@ class ERR_AircraftServiceEntry
SCR_AIGroup Group;
IEntity Pilot;
PilotCompartmentSlot Seat;
ref ERR_AircraftRouteFlight Flight;
ref ERR_AircraftFlight Flight;
int Token;
float Deadline;
vector Destination;
@@ -89,18 +89,45 @@ class ERR_AircraftService
if (!Context() || m_Stopping || !entry || entry.Pending || entry.Retired || s_Retainers.Get(aircraft) != this) return false;
return PhysicalReady(entry);
}
bool StartRoute(Vehicle aircraft, ERR_AircraftRouteEnvelope qualification, int token, float deadline)
// Both explicit kinds share one attempt history and physical reservation.
protected ERR_AircraftServiceEntry BeginAttempt(Vehicle aircraft, int token, float deadline)
{
if (!Context() || m_Stopping || !qualification || token <= 0 || m_UsedTokens.Contains(token) || m_UsedTokens.Count() >= MAX_ORDERS || !Ready(aircraft)) return false;
if (!Context() || m_Stopping || token <= 0 || m_UsedTokens.Contains(token) || m_UsedTokens.Count() >= MAX_ORDERS || !Ready(aircraft)) return null;
float now = m_World.GetWorldTime();
if (!ERR_AircraftFlightRules.Deadline(now, deadline)) return false;
if (!ERR_AircraftFlightRules.Deadline(now, deadline)) return null;
ERR_AircraftServiceEntry entry = Find(aircraft);
// Commit the attempt before calling the native-backed controller. No retry of
// this token, including a partially initialized or conflicting Start refusal.
m_UsedTokens.Insert(token); entry.Token = token; entry.Deadline = deadline;
entry.Destination = qualification.Destination(); entry.CancelRequested = false;
entry.Flight = new ERR_AircraftRouteFlight(); entry.Pending = true;
bool started = entry.Flight.StartRoute(m_Mode, entry.Aircraft, entry.Group, entry.Pilot, entry.Seat, qualification, token, deadline);
entry.CancelRequested = false;
return entry;
}
bool StartRoute(Vehicle aircraft, ERR_AircraftRouteEnvelope qualification, int token, float deadline)
{
if (!qualification) return false;
ERR_AircraftServiceEntry entry = BeginAttempt(aircraft, token, deadline);
if (!entry) return false;
entry.Destination = qualification.Destination();
ERR_AircraftRouteFlight flight = new ERR_AircraftRouteFlight();
entry.Flight = flight; entry.Pending = true;
bool started = flight.StartRoute(m_Mode, entry.Aircraft, entry.Group, entry.Pilot, entry.Seat, qualification, token, deadline);
return RecordStart(entry, started);
}
// This explicit prototype entry point accepts only a field certificate and
// constructs its known controller. No arbitrary caller-owned flight is adopted.
bool StartField(Vehicle aircraft, ERR_AircraftFieldEnvelope qualification, int token, float deadline)
{
if (!qualification) return false;
ERR_AircraftServiceEntry entry = BeginAttempt(aircraft, token, deadline);
if (!entry) return false;
entry.Destination = qualification.Destination();
ERR_AircraftFieldFlight flight = new ERR_AircraftFieldFlight();
entry.Flight = flight; entry.Pending = true;
bool started = flight.StartField(m_Mode, entry.Aircraft, entry.Group, entry.Pilot, entry.Seat, qualification, token, deadline);
return RecordStart(entry, started);
}
protected bool RecordStart(ERR_AircraftServiceEntry entry, bool started)
{
if (!started)
{
entry.Retired = true; entry.Reason = "flight start refused; no automatic retry or replacement";