Changeset - r28815:5e58b8dec74d
[Not reviewed]
master
0 2 0
Peter Nelson - 4 months ago 2023-12-28 16:06:35
peter1138@openttd.org
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.
2 files changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/main_gui.cpp
Show inline comments
 
@@ -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]);
src/palette_func.h
Show inline comments
 
@@ -42,13 +42,14 @@ TextColour GetContrastColour(uint8_t bac
 

	
 
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)
0 comments (0 inline, 0 general)