summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gfx.cpp2
-rw-r--r--src/spriteloader/grf.cpp12
2 files changed, 11 insertions, 3 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 7fab69db3..5247daccb 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -70,7 +70,7 @@ static ReusableBuffer<uint8> _cursor_backup;
*/
static Rect _invalid_rect;
static const byte *_colour_remap_ptr;
-static byte _string_colourremap[3];
+static byte _string_colourremap[3]; ///< Recoloursprite for stringdrawing. The grf loader ensures, that ST_FONT sprites only use colours 0 to 2.
enum {
DIRTY_BLOCK_HEIGHT = 8,
diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp
index 3b1ccc5f3..4600c4225 100644
--- a/src/spriteloader/grf.cpp
+++ b/src/spriteloader/grf.cpp
@@ -127,7 +127,11 @@ bool SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot,
}
for (int x = 0; x < length; x++) {
- data->m = ((sprite_type == ST_NORMAL && _palette_remap_grf[file_slot]) ? _palette_remap[*dest] : *dest);
+ switch (sprite_type) {
+ case ST_NORMAL: data->m = _palette_remap_grf[file_slot] ? _palette_remap[*dest] : *dest; break;
+ case ST_FONT: data->m = min(*dest, 2u); break;
+ default: data->m = *dest; break;
+ }
dest++;
data++;
}
@@ -148,7 +152,11 @@ bool SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot,
dest = dest_orig;
for (int i = 0; i < sprite->width * sprite->height; i++) {
- sprite->data[i].m = ((sprite_type == ST_NORMAL && _palette_remap_grf[file_slot]) ? _palette_remap[dest[i]] : dest[i]);
+ switch (sprite_type) {
+ case ST_NORMAL: sprite->data[i].m = _palette_remap_grf[file_slot] ? _palette_remap[dest[i]] : dest[i]; break;
+ case ST_FONT: sprite->data[i].m = min(dest[i], 2u); break;
+ default: sprite->data[i].m = dest[i]; break;
+ }
}
}