Queue consumed on dispatch; engine chain hardened; queued planes unsellable (ISS-088)
CI / build + unit + e2e (pull_request) Failing after 12m59s
CI / build + unit + e2e (pull_request) Failing after 12m59s
This commit is contained in:
@@ -153,6 +153,12 @@ export async function flyPlane(inst: GameDb, planeId: string, destIcao: string):
|
||||
const sim = (await inst.db.select().from(schema.simState))[0];
|
||||
if (!sim) throw new Error('sim_state row missing');
|
||||
|
||||
// v0.46.0 (ISS-088): flying to the FIRST queued leg consumes it — otherwise the engine would
|
||||
// chain a zero-distance self-hop on landing (queue[0] === the airport just reached). Skip-ahead
|
||||
// to a non-first queued dest is an explicit override: the queue stays intact, FIFO preserved.
|
||||
const queue = parseIcaoQueue(plane.queue);
|
||||
if (queue.length > 0 && queue[0] === destIcao) queue.shift();
|
||||
|
||||
await inst.db.update(schema.planes)
|
||||
.set({
|
||||
status: 'flying',
|
||||
@@ -161,6 +167,7 @@ export async function flyPlane(inst: GameDb, planeId: string, destIcao: string):
|
||||
lat: origin.lat,
|
||||
lon: origin.lon,
|
||||
fuel: target, // ISS-082: the post-top-up level (unchanged when no top-up was needed)
|
||||
queue: JSON.stringify(queue),
|
||||
})
|
||||
.where(eq(schema.planes.id, planeId));
|
||||
if (cost > 0) {
|
||||
@@ -340,6 +347,11 @@ export async function sellPlane(inst: GameDb, planeId: string): Promise<{ payout
|
||||
throw new GameActionError(409, `cannot sell a plane carrying cargo`);
|
||||
}
|
||||
|
||||
// v0.46.0 (ISS-088): selling a plane with queued legs would silently drop them — force an explicit cancel first.
|
||||
if (parseIcaoQueue(plane.queue).length > 0) {
|
||||
throw new GameActionError(409, 'the plane has queued legs — cancel queued legs first');
|
||||
}
|
||||
|
||||
const all = await inst.db.select().from(schema.planes);
|
||||
if (all.length <= 1) throw new GameActionError(409, 'cannot sell the last remaining plane');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user