forked from mirror/OpenTTD
Codechange: ZOOM_LVL_SHIFT/BASE are not actually ZOOM_LVLs.
Rename to ZOOM_BASE_SHIFT and ZOOM_BASE respectively, and derive from ZOOM_LVL instead of numeric value.
This commit is contained in:
@@ -106,10 +106,10 @@ ViewportSignKdtree _viewport_sign_kdtree(&Kdtree_ViewportSignXYFunc);
|
||||
static int _viewport_sign_maxwidth = 0;
|
||||
|
||||
|
||||
static const int MAX_TILE_EXTENT_LEFT = ZOOM_LVL_BASE * TILE_PIXELS; ///< Maximum left extent of tile relative to north corner.
|
||||
static const int MAX_TILE_EXTENT_RIGHT = ZOOM_LVL_BASE * TILE_PIXELS; ///< Maximum right extent of tile relative to north corner.
|
||||
static const int MAX_TILE_EXTENT_TOP = ZOOM_LVL_BASE * MAX_BUILDING_PIXELS; ///< Maximum top extent of tile relative to north corner (not considering bridges).
|
||||
static const int MAX_TILE_EXTENT_BOTTOM = ZOOM_LVL_BASE * (TILE_PIXELS + 2 * TILE_HEIGHT); ///< Maximum bottom extent of tile relative to north corner (worst case: #SLOPE_STEEP_N).
|
||||
static const int MAX_TILE_EXTENT_LEFT = ZOOM_BASE * TILE_PIXELS; ///< Maximum left extent of tile relative to north corner.
|
||||
static const int MAX_TILE_EXTENT_RIGHT = ZOOM_BASE * TILE_PIXELS; ///< Maximum right extent of tile relative to north corner.
|
||||
static const int MAX_TILE_EXTENT_TOP = ZOOM_BASE * MAX_BUILDING_PIXELS; ///< Maximum top extent of tile relative to north corner (not considering bridges).
|
||||
static const int MAX_TILE_EXTENT_BOTTOM = ZOOM_BASE * (TILE_PIXELS + 2 * TILE_HEIGHT); ///< Maximum bottom extent of tile relative to north corner (worst case: #SLOPE_STEEP_N).
|
||||
|
||||
struct StringSpriteToDraw {
|
||||
std::string string;
|
||||
@@ -570,9 +570,9 @@ void DrawGroundSpriteAt(SpriteID image, PaletteID pal, int32_t x, int32_t y, int
|
||||
|
||||
if (_vd.foundation[_vd.foundation_part] != -1) {
|
||||
Point pt = RemapCoords(x, y, z);
|
||||
AddChildSpriteToFoundation(image, pal, sub, _vd.foundation_part, pt.x + extra_offs_x * ZOOM_LVL_BASE, pt.y + extra_offs_y * ZOOM_LVL_BASE);
|
||||
AddChildSpriteToFoundation(image, pal, sub, _vd.foundation_part, pt.x + extra_offs_x * ZOOM_BASE, pt.y + extra_offs_y * ZOOM_BASE);
|
||||
} else {
|
||||
AddTileSpriteToDraw(image, pal, _cur_ti.x + x, _cur_ti.y + y, _cur_ti.z + z, sub, extra_offs_x * ZOOM_LVL_BASE, extra_offs_y * ZOOM_LVL_BASE);
|
||||
AddTileSpriteToDraw(image, pal, _cur_ti.x + x, _cur_ti.y + y, _cur_ti.z + z, sub, extra_offs_x * ZOOM_BASE, extra_offs_y * ZOOM_BASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,8 +614,8 @@ void OffsetGroundSprite(int x, int y)
|
||||
/* _vd.last_child == nullptr if foundation sprite was clipped by the viewport bounds */
|
||||
if (_vd.last_child != nullptr) _vd.foundation[_vd.foundation_part] = (uint)_vd.parent_sprites_to_draw.size() - 1;
|
||||
|
||||
_vd.foundation_offset[_vd.foundation_part].x = x * ZOOM_LVL_BASE;
|
||||
_vd.foundation_offset[_vd.foundation_part].y = y * ZOOM_LVL_BASE;
|
||||
_vd.foundation_offset[_vd.foundation_part].x = x * ZOOM_BASE;
|
||||
_vd.foundation_offset[_vd.foundation_part].y = y * ZOOM_BASE;
|
||||
_vd.last_foundation_child[_vd.foundation_part] = _vd.last_child;
|
||||
}
|
||||
|
||||
@@ -845,8 +845,8 @@ void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool tran
|
||||
cs.image = image;
|
||||
cs.pal = pal;
|
||||
cs.sub = sub;
|
||||
cs.x = scale ? x * ZOOM_LVL_BASE : x;
|
||||
cs.y = scale ? y * ZOOM_LVL_BASE : y;
|
||||
cs.x = scale ? x * ZOOM_BASE : x;
|
||||
cs.y = scale ? y * ZOOM_BASE : y;
|
||||
cs.relative = relative;
|
||||
cs.next = -1;
|
||||
|
||||
@@ -892,7 +892,7 @@ static void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *t
|
||||
AddTileSpriteToDraw(image, pal, ti->x, ti->y, ti->z + z_offset, nullptr, extra_offs_x, extra_offs_y);
|
||||
} else {
|
||||
/* draw on top of foundation */
|
||||
AddChildSpriteToFoundation(image, pal, nullptr, foundation_part, extra_offs_x, extra_offs_y - z_offset * ZOOM_LVL_BASE);
|
||||
AddChildSpriteToFoundation(image, pal, nullptr, foundation_part, extra_offs_x, extra_offs_y - z_offset * ZOOM_BASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1177,7 +1177,7 @@ draw_inner:
|
||||
static int GetViewportY(Point tile)
|
||||
{
|
||||
/* Each increment in X or Y direction moves down by half a tile, i.e. TILE_PIXELS / 2. */
|
||||
return (tile.y * (int)(TILE_PIXELS / 2) + tile.x * (int)(TILE_PIXELS / 2) - TilePixelHeightOutsideMap(tile.x, tile.y)) << ZOOM_LVL_SHIFT;
|
||||
return (tile.y * (int)(TILE_PIXELS / 2) + tile.x * (int)(TILE_PIXELS / 2) - TilePixelHeightOutsideMap(tile.x, tile.y)) << ZOOM_BASE_SHIFT;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1207,7 +1207,7 @@ static void ViewportAddLandscape()
|
||||
int left_column = (upper_left.y - upper_left.x) / (int)TILE_SIZE - 2;
|
||||
int right_column = (upper_right.y - upper_right.x) / (int)TILE_SIZE + 2;
|
||||
|
||||
int potential_bridge_height = ZOOM_LVL_BASE * TILE_HEIGHT * _settings_game.construction.max_bridge_height;
|
||||
int potential_bridge_height = ZOOM_BASE * TILE_HEIGHT * _settings_game.construction.max_bridge_height;
|
||||
|
||||
/* Rows overlap with neighbouring rows by a half tile.
|
||||
* The first row that could possibly be visible is the row above upper_left (if it is at height 0).
|
||||
@@ -1267,7 +1267,7 @@ static void ViewportAddLandscape()
|
||||
if (IsBridgeAbove(_cur_ti.tile)) {
|
||||
/* Is the bridge visible? */
|
||||
TileIndex bridge_tile = GetNorthernBridgeEnd(_cur_ti.tile);
|
||||
int bridge_height = ZOOM_LVL_BASE * (GetBridgePixelHeight(bridge_tile) - TilePixelHeight(_cur_ti.tile));
|
||||
int bridge_height = ZOOM_BASE * (GetBridgePixelHeight(bridge_tile) - TilePixelHeight(_cur_ti.tile));
|
||||
if (min_visible_height < bridge_height + MAX_TILE_EXTENT_TOP) tile_visible = true;
|
||||
}
|
||||
|
||||
@@ -1883,7 +1883,7 @@ static inline void ClampViewportToMap(const Viewport *vp, int *scroll_x, int *sc
|
||||
static void ClampSmoothScroll(uint32_t delta_ms, int64_t delta_hi, int64_t delta_lo, int &delta_hi_clamped, int &delta_lo_clamped)
|
||||
{
|
||||
/** A tile is 64 pixels in width at 1x zoom; viewport coordinates are in 4x zoom. */
|
||||
constexpr int PIXELS_PER_TILE = TILE_PIXELS * 2 * ZOOM_LVL_BASE;
|
||||
constexpr int PIXELS_PER_TILE = TILE_PIXELS * 2 * ZOOM_BASE;
|
||||
|
||||
assert(delta_hi != 0);
|
||||
|
||||
@@ -2053,7 +2053,7 @@ void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_heigh
|
||||
Point pt = RemapCoords(TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE, tile_height_override * TILE_HEIGHT);
|
||||
MarkAllViewportsDirty(
|
||||
pt.x - MAX_TILE_EXTENT_LEFT,
|
||||
pt.y - MAX_TILE_EXTENT_TOP - ZOOM_LVL_BASE * TILE_HEIGHT * bridge_level_offset,
|
||||
pt.y - MAX_TILE_EXTENT_TOP - ZOOM_BASE * TILE_HEIGHT * bridge_level_offset,
|
||||
pt.x + MAX_TILE_EXTENT_RIGHT,
|
||||
pt.y + MAX_TILE_EXTENT_BOTTOM);
|
||||
}
|
||||
@@ -2131,15 +2131,15 @@ static void SetSelectionTilesDirty()
|
||||
/* the 'x' coordinate of 'top' and 'bot' is the same (and always in the same distance from tile middle),
|
||||
* tile height/slope affects only the 'y' on-screen coordinate! */
|
||||
|
||||
int l = top.x - TILE_PIXELS * ZOOM_LVL_BASE; // 'x' coordinate of left side of the dirty rectangle
|
||||
int l = top.x - TILE_PIXELS * ZOOM_BASE; // 'x' coordinate of left side of the dirty rectangle
|
||||
int t = top.y; // 'y' coordinate of top side of the dirty rectangle
|
||||
int r = top.x + TILE_PIXELS * ZOOM_LVL_BASE; // 'x' coordinate of right side of the dirty rectangle
|
||||
int r = top.x + TILE_PIXELS * ZOOM_BASE; // 'x' coordinate of right side of the dirty rectangle
|
||||
int b = bot.y; // 'y' coordinate of bottom side of the dirty rectangle
|
||||
|
||||
static const int OVERLAY_WIDTH = 4 * ZOOM_LVL_BASE; // part of selection sprites is drawn outside the selected area (in particular: terraforming)
|
||||
static const int OVERLAY_WIDTH = 4 * ZOOM_BASE; // part of selection sprites is drawn outside the selected area (in particular: terraforming)
|
||||
|
||||
/* For halftile foundations on SLOPE_STEEP_S the sprite extents some more towards the top */
|
||||
MarkAllViewportsDirty(l - OVERLAY_WIDTH, t - OVERLAY_WIDTH - TILE_HEIGHT * ZOOM_LVL_BASE, r + OVERLAY_WIDTH, b + OVERLAY_WIDTH);
|
||||
MarkAllViewportsDirty(l - OVERLAY_WIDTH, t - OVERLAY_WIDTH - TILE_HEIGHT * ZOOM_BASE, r + OVERLAY_WIDTH, b + OVERLAY_WIDTH);
|
||||
|
||||
/* haven't we reached the topmost tile yet? */
|
||||
if (top_x != x_start) {
|
||||
|
Reference in New Issue
Block a user