From 2bc3cc5b673b437fbaef279795c8d349a98d7656 Mon Sep 17 00:00:00 2001 From: ladysadie <144490006+ladysadie@users.noreply.github.com> Date: Sat, 15 Jun 2024 23:54:41 -0700 Subject: [PATCH] Codechange: Compiler check for _fios_colours/DetailedFileType (#12781) --- src/fileio_type.h | 2 ++ src/fios_gui.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fileio_type.h b/src/fileio_type.h index c871c1c14b..a353e12b8a 100644 --- a/src/fileio_type.h +++ b/src/fileio_type.h @@ -40,6 +40,8 @@ enum DetailedFileType { DFT_FIOS_DIR, ///< A directory entry. DFT_FIOS_DIRECT, ///< Direct filename. + DFT_END, ///< End of this enum. Supports a compile time size check against _fios_colours in fios_gui.cpp + DFT_INVALID = 255, ///< Unknown or invalid file. }; diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index bea51f9851..993d331a55 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -238,7 +238,8 @@ static const TextColour _fios_colours[] = { TC_DARK_GREEN, // DFT_FIOS_DIR TC_ORANGE, // DFT_FIOS_DIRECT }; - +/* This should align with the DetailedFileType enum defined in fileio_type.h */ +static_assert(std::size(_fios_colours) == DFT_END); /** * Sort the collected list save games prior to displaying it in the save/load gui.