diff --git a/code/iff_defs/iff_defs.cpp b/code/iff_defs/iff_defs.cpp index 16378f3f16f..85787a84b25 100644 --- a/code/iff_defs/iff_defs.cpp +++ b/code/iff_defs/iff_defs.cpp @@ -33,6 +33,15 @@ int IFF_COLOR_TAGGED = 2; // global only to file SCP_vector > Iff_colors; // AL 1-2-97: Create two IFF colors, regular and bright +typedef struct { + int r; + int g; + int b; +} temp_color_t; + +// parallel to Iff_colors +static SCP_vector temp_colors; + flag_def_list rti_flags[] = { { "crosshairs", RTIF_CROSSHAIRS, 0 }, { "blink", RTIF_BLINK, 0 }, @@ -82,16 +91,8 @@ int iff_get_alpha_value(bool is_bright) */ int iff_init_color(int r, int g, int b) { - typedef struct { - int r; - int g; - int b; - } temp_color_t; - int i, idx; - static SCP_vector temp_colors; - Assert(r >= 0 && r <= 255); Assert(g >= 0 && g <= 255); Assert(b >= 0 && b <= 255); @@ -662,6 +663,22 @@ void iff_init() resolve_iff_data(); } +void iff_close() +{ + Iff_info.clear(); + Iff_info_names.clear(); + Iff_colors.clear(); + temp_colors.clear(); + + attack_names.clear(); + observed_color_table.clear(); + accessibility_observed_color_table.clear(); + + strcpy_s(traitor_name, "Traitor"); + Iff_traitor = 0; + AccessiblitySupported = false; +} + /** * Find the iff name * diff --git a/code/iff_defs/iff_defs.h b/code/iff_defs/iff_defs.h index 9b8ed5dfe7a..4111276bf5a 100644 --- a/code/iff_defs/iff_defs.h +++ b/code/iff_defs/iff_defs.h @@ -72,6 +72,9 @@ extern int iff_init_color(int r, int g, int b); // load the iff table extern void iff_init(); +// free the iff table +extern void iff_close(); + // search for iff extern int iff_lookup(const char *iff_name); diff --git a/test/src/iff_defs/test_iff_accessibility.cpp b/test/src/iff_defs/test_iff_accessibility.cpp index 2975b0efadc..332623c1250 100644 --- a/test/src/iff_defs/test_iff_accessibility.cpp +++ b/test/src/iff_defs/test_iff_accessibility.cpp @@ -14,6 +14,14 @@ class IffAccessibilityTest : public test::FSTestFixture { { pushModDir("iff/tbm_adds_iff"); } + + protected: + void TearDown() override + { + iff_close(); + + test::FSTestFixture::TearDown(); + } }; namespace { @@ -31,7 +39,6 @@ ::testing::AssertionResult has_rgb(int color_index, int r, int g, int b) } } // namespace -// one test: nothing clears Iff_info, so a second iff_init() in the process fails on duplicate IFF names TEST_F(IffAccessibilityTest, TbmIffsKeepTheirColorsAndBuiltInsUseAccessibilityColors) { iff_init();