Skip to content

Add iff_close() so IFF tables can be re-parsed in tests - #8077

Open
Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:fix/iff_tests
Open

Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:fix/iff_tests

Conversation

@Goober5000

Copy link
Copy Markdown
Contributor

Nothing ever reset the IFF module's state, so calling iff_init() a second time in the same process failed with IFF Friendly already exists. All IFF names must be unique.

The game only calls iff_init() once, so this never came up until #7856 added IffAccessibilityTest, which calls it. Any later test in the same unittests run that also needs IFFs now fails in setup. This is what's breaking CI on #7909: all four ShipSharedModelTest cases fail in SetUp().

Changes

  • Add iff_close(). It clears Iff_info, Iff_info_names, Iff_colors, and the per-IFF attack/observed-color tables that are indexed in parallel with Iff_info. It also resets the traitor name and index and $Accessibility Supported:.
  • Move the color cache out of iff_init_color() to file scope, so it can be cleared along with Iff_colors. If it isn't cleared, cached color indices would point at the wrong colors after a reset.
  • IffAccessibilityTest now calls iff_close() in TearDown().

Once this is merged, #7909's test can drop its own one-time init guard and just call iff_init() / iff_close() around each test.

🤖 Generated with Claude Code

Nothing reset the IFF module's state, so a second iff_init() in the same
process failed on duplicate IFF names.  IffAccessibilityTest (scp-fs2open#7856) calls
iff_init(), which broke any later test that also needed IFFs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Goober5000 Goober5000 added fix A fix for bugs, not-a-bugs, and/or regressions. ci A feature or issue related to the continous integration tools labels Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci A feature or issue related to the continous integration tools fix A fix for bugs, not-a-bugs, and/or regressions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant