Skip to content

fix: -intercept reads its six mission flags at option-relative argv indices - #7

Open
tomingtoming wants to merge 1 commit into
captainys:masterfrom
tomingtoming:upstream-fix/intercept-arg-index
Open

tomingtoming wants to merge 1 commit into
captainys:masterfrom
tomingtoming:upstream-fix/intercept-arg-index

Conversation

@tomingtoming

Copy link
Copy Markdown

-intercept AIR FLD S AC H B N W reads its six trailing mission flags from the absolute argv positions av[3..8], while every other option in FsCommandParameter::RecognizeCommandParameter reads option-relative av[i+3..i+8].

Consequences:

  • The flags only line up when -intercept happens to be the first option (i==1) — and even then everything is shifted by one: allowStealth receives the FIELD string, each subsequent flag receives the previous flag's value, and the documented last parameter (NWingmen) is dropped.
  • With any option before -intercept, the six flags read unrelated argv entries.

Fix: read av[i+3..i+8], matching -freeflight, -endurance, etc. The documented argument order (-intercept Airplane Field Stealth Escort HeavyBomber Bomb NEnemy NWingmen) then takes effect regardless of the option's position.

Verification

Built ysflight64_gl2 on Linux (gcc) from current master with only this commit applied, and called RecognizeCommandParameter directly with the documented argument order and the values 1 0 1 0 3 2 (stealth=1, escort=0, heavy bomber=1, bomb=0, NEnemy=3, NWingmen=2):

argv layout master with this fix
-intercept first stealth=0 aircover=1 heavyBomber=0 bomb=1 maxNumAttacker=1 numWingman=2 (shifted by one) 1 0 1 0 3 2 as documented
-autoexit before -intercept stealth=0 aircover=0 heavyBomber=1 bomb=0 maxNumAttacker=1 numWingman=0 (reads AIR FLD 1 0 1 0) 1 0 1 0 3 2 as documented

executionMode, airName and fldName are correct in all cases (those already used option-relative indices).

Found while porting YSFLIGHT to WebAssembly (ysflight-web) — the bug is in the original desktop code path as well. Thank you for releasing the source, and no hurry at all with this one!

The six mission parameters after "-intercept AIR FLD" were read from
av[3..8] instead of av[i+3..i+8], so they only lined up when -intercept
happened to start at av[1] — and even then everything was off by one
(allowStealth got FLD, numWingman got the intended maxNumAttacker, and
the real last parameter was ignored).  Use i-relative indices like every
other option in this parser.

Pure upstream-candidate bug fix, kept as a standalone commit so it can
be cherry-picked and proposed as-is.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TpRG2watB63MUc5r4Vy5yx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant