summaryrefslogtreecommitdiff
path: root/src/spriteloader
diff options
context:
space:
mode:
authorMatt Kimber <mattkimber@users.noreply.github.com>2021-03-13 09:00:53 +0000
committerGitHub <noreply@github.com>2021-03-13 10:00:53 +0100
commitbcb3313e134e0e8cf12366ec9d1340e9986ccc57 (patch)
tree39141bec1ab454c06deab1f4227f401f864fe970 /src/spriteloader
parente708fb38da7a3635c7cc15dd1cc516ea1d2d5871 (diff)
downloadopenttd-bcb3313e134e0e8cf12366ec9d1340e9986ccc57.tar.xz
Feature: allow setting maximum zoom level at which sprites are drawn (#8604)
Diffstat (limited to 'src/spriteloader')
-rw-r--r--src/spriteloader/grf.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp
index f3c3ed8ac..30ea09444 100644
--- a/src/spriteloader/grf.cpp
+++ b/src/spriteloader/grf.cpp
@@ -11,6 +11,7 @@
#include "../gfx_func.h"
#include "../fileio_func.h"
#include "../debug.h"
+#include "../settings_type.h"
#include "../strings_func.h"
#include "table/strings.h"
#include "../error.h"
@@ -265,7 +266,16 @@ uint8 LoadSpriteV2(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t file_po
byte colour = type & SCC_MASK;
byte zoom = FioReadByte();
- if (colour != 0 && (load_32bpp ? colour != SCC_PAL : colour == SCC_PAL) && (sprite_type != ST_MAPGEN ? zoom < lengthof(zoom_lvl_map) : zoom == 0)) {
+ bool is_wanted_colour_depth = (colour != 0 && (load_32bpp ? colour != SCC_PAL : colour == SCC_PAL));
+ bool is_wanted_zoom_lvl;
+
+ if (sprite_type != ST_MAPGEN) {
+ is_wanted_zoom_lvl = (zoom < lengthof(zoom_lvl_map) && zoom_lvl_map[zoom] >= _settings_client.gui.sprite_zoom_min);
+ } else {
+ is_wanted_zoom_lvl = (zoom == 0);
+ }
+
+ if (is_wanted_colour_depth && is_wanted_zoom_lvl) {
ZoomLevel zoom_lvl = (sprite_type != ST_MAPGEN) ? zoom_lvl_map[zoom] : ZOOM_LVL_NORMAL;
if (HasBit(loaded_sprites, zoom_lvl)) {