From 02e80336d4611274833136f1e9778c83889e6b49 Mon Sep 17 00:00:00 2001 From: Rangi Date: Sat, 21 Nov 2026 03:12:02 -0500 Subject: [PATCH] Factor out `MAX_NB_PALETTES` constant --- include/gfx/main.hpp | 1 + src/gfx/main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/gfx/main.hpp b/include/gfx/main.hpp index 892fa247..9708d2cb 100644 --- a/include/gfx/main.hpp +++ b/include/gfx/main.hpp @@ -19,6 +19,7 @@ static constexpr uint32_t TILE_WIDTH = 8; // in pixels static constexpr uint32_t TILE_HEIGHT = 8; // in pixels static constexpr size_t MAX_PAL_COLORS = 4; +static constexpr size_t MAX_NB_PALETTES = 256; // Forward declaration so `inputSlice`'s `bottom` method inside `Options` can refer to `options`. struct Options; diff --git a/src/gfx/main.cpp b/src/gfx/main.cpp index fc9f4249..91a877d2 100644 --- a/src/gfx/main.cpp +++ b/src/gfx/main.cpp @@ -358,8 +358,8 @@ static void parseArg(int ch, char *arg) { case 'n': if (std::optional number = parseWholeNumber(argPtr); !number) { error("Invalid argument for number of palettes"); - } else if (*number > 256) { - error("Number of palettes must not exceed 256"); + } else if (*number > MAX_NB_PALETTES) { + error("Number of palettes must not exceed %zu", MAX_NB_PALETTES); } else if (*number == 0) { error("Number of palettes may not be 0"); } else {