mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-04 16:22:48 +08:00
fix(clearance): generate octal squawks and skip reserved codes
genSquawk() drew a decimal number in 1000-8999, so clearances could contain the digits 8 or 9 — codes no transponder can dial. Replace it with a shared generateSquawk() that draws four octal digits and re-rolls the reserved codes (7500/7600/7700, 7000, 2000, 1200, 0000). shared/learn/scenario.ts had its own octal generator that could still draw an emergency code; it now uses the same helper. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import type {
|
||||
} from '../types/decision'
|
||||
import type { FlowActivationInstruction, FlowActivationMode, LLMDecisionTrace } from '../types/llm'
|
||||
import { normalizeRadioPhrase, DEFAULT_AIRLINE_TELEPHONY } from './radioSpeech'
|
||||
import { generateSquawk } from './transponder'
|
||||
|
||||
// --- DecisionTree runtime types ---
|
||||
type Role = 'pilot' | 'atc' | 'system'
|
||||
@@ -783,7 +784,7 @@ export default function useCommunicationsEngine() {
|
||||
dest: fpl.arr || fpl.arrival || 'EDDM',
|
||||
stand: genStand(),
|
||||
runway: genRunway(),
|
||||
squawk: fpl.assignedsquawk || genSquawk(),
|
||||
squawk: fpl.assignedsquawk || generateSquawk(),
|
||||
atis_code: genATIS(),
|
||||
sid: genSID(fpl.route || ''),
|
||||
transition: 'DCT',
|
||||
@@ -1509,10 +1510,6 @@ export default function useCommunicationsEngine() {
|
||||
return arr[Math.floor(Math.random() * arr.length)]
|
||||
}
|
||||
|
||||
function genSquawk() {
|
||||
return String(Math.floor(Math.random() * 8000 + 1000)).padStart(4, '0')
|
||||
}
|
||||
|
||||
function genATIS() {
|
||||
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
return letters[Math.floor(Math.random() * letters.length)]
|
||||
|
||||
Reference in New Issue
Block a user