From 86be6d7e0b5e3925a04c81976c5df0b3a2e14483 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 28 Dec 2023 16:06:35 +0000 Subject: [PATCH] Codechange: Off-by-one in colour gradient initialisation. Remap sprites start with a count byte followed by 256 entries, but SetupColoursAndInitialWindow did not take account of this extra byte and therefore started at palette index 0xC5 instead of 0xC6. This caused the first colour of each gradient to be incorrect and all shades were actually 1 step lower in the gradient than indicated. --- src/main_gui.cpp | 2 +- src/palette_func.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 686629f1fe..a413cd3594 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -541,7 +541,7 @@ void ShowSelectGameWindow(); void SetupColoursAndInitialWindow() { for (Colours i = COLOUR_BEGIN; i != COLOUR_END; i++) { - const byte *b = GetNonSprite(GENERAL_SPRITE_COLOUR(i), SpriteType::Recolour); + const byte *b = GetNonSprite(GENERAL_SPRITE_COLOUR(i), SpriteType::Recolour) + 1; assert(b != nullptr); for (ColourShade j = SHADE_BEGIN; j < SHADE_END; j++) { SetColourGradient(i, j, b[0xC6 + j]); diff --git a/src/palette_func.h b/src/palette_func.h index c7d4f30cb1..0f35bc0258 100644 --- a/src/palette_func.h +++ b/src/palette_func.h @@ -42,13 +42,14 @@ TextColour GetContrastColour(uint8_t background, uint8_t threshold = 128); enum ColourShade : uint8_t { SHADE_BEGIN = 0, - SHADE_DARKEST, + SHADE_DARKEST = SHADE_BEGIN, SHADE_DARKER, SHADE_DARK, SHADE_NORMAL, SHADE_LIGHT, SHADE_LIGHTER, SHADE_LIGHTEST, + SHADE_LIGHTEREST, SHADE_END, }; DECLARE_POSTFIX_INCREMENT(ColourShade)