Ensure zoom levels are always multiples of 4.

Also changed zoom level specification to direct integer sizes rather
than multiplication factors, so they can be specified accurately.

It has always been the case that they were required to be multiples
of four. This was just violated at some point.

This fixes problems with overlapping fog textures at some zoom
levels, and may also prevent some other rendering glitches.
This commit is contained in:
Tommy 2023-11-04 11:24:08 +13:00
parent 2f8cfbb08c
commit 278ba34071
2 changed files with 10 additions and 3 deletions

View file

@ -33,8 +33,10 @@
hp_bar_scaling=0.6
xp_bar_scaling=0.5
# zoom factors must be a sorted list of ascending multipliers
zoom_levels = 0.25, 0.33333333333333333, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0, 4.0
# zoom_levels must be an ascending list of hex sizes in pixels.
# hex sizes must be divisible by 4 to prevent graphical glitches.
# sizes are in draw space, so standard 1x zoom is always 72.
zoom_levels = 16, 24, 36, 52, 72, 100, 144, 216, 288
flag_rgb=flag_green
unit_rgb=magenta

View file

@ -274,7 +274,12 @@ void load_config(const config &v)
if(!zoom_levels_str.empty()) {
zoom_levels.clear();
std::transform(zoom_levels_str.begin(), zoom_levels_str.end(), std::back_inserter(zoom_levels), [](const std::string zoom) {
return static_cast<int>(std::stold(zoom) * tile_size);
int z = std::stoi(zoom);
if((z / 4) * 4 != z) {
ERR_NG << "zoom level " << z << " is not divisible by 4."
<< " This will cause graphical glitches!";
}
return z;
});
}