Fix display of zoning overlay sprites on half-tile foundations
Partly based on commit 598b781259a5c1ad25cf3de85807b9c79e9f08fe
This commit is contained in:
@@ -149,14 +149,6 @@ struct ChildScreenSpriteToDraw {
|
|||||||
int next; ///< next child to draw (-1 at the end)
|
int next; ///< next child to draw (-1 at the end)
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Enumeration of multi-part foundations */
|
|
||||||
enum FoundationPart {
|
|
||||||
FOUNDATION_PART_NONE = 0xFF, ///< Neither foundation nor groundsprite drawn yet.
|
|
||||||
FOUNDATION_PART_NORMAL = 0, ///< First part (normal foundation or no foundation)
|
|
||||||
FOUNDATION_PART_HALFTILE = 1, ///< Second part (halftile foundation)
|
|
||||||
FOUNDATION_PART_END
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mode of "sprite combining"
|
* Mode of "sprite combining"
|
||||||
* @see StartSpriteCombine
|
* @see StartSpriteCombine
|
||||||
@@ -1015,16 +1007,17 @@ static void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint
|
|||||||
* @param ti TileInfo Tile that is being drawn
|
* @param ti TileInfo Tile that is being drawn
|
||||||
* @param z_offset Z offset relative to the groundsprite. Only used for the sprite position, not for sprite sorting.
|
* @param z_offset Z offset relative to the groundsprite. Only used for the sprite position, not for sprite sorting.
|
||||||
* @param foundation_part Foundation part the sprite belongs to.
|
* @param foundation_part Foundation part the sprite belongs to.
|
||||||
|
* @param sub Sub-section of sprite to draw.
|
||||||
*/
|
*/
|
||||||
static void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part)
|
void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part, const SubSprite *sub)
|
||||||
{
|
{
|
||||||
/* FIXME: This is not totally valid for some autorail highlights that extend over the edges of the tile. */
|
/* FIXME: This is not totally valid for some autorail highlights that extend over the edges of the tile. */
|
||||||
if (_vd.foundation[foundation_part] == -1) {
|
if (_vd.foundation[foundation_part] == -1) {
|
||||||
/* draw on real ground */
|
/* draw on real ground */
|
||||||
AddTileSpriteToDraw(image, pal, ti->x, ti->y, ti->z + z_offset);
|
AddTileSpriteToDraw(image, pal, ti->x, ti->y, ti->z + z_offset, sub);
|
||||||
} else {
|
} else {
|
||||||
/* draw on top of foundation */
|
/* draw on top of foundation */
|
||||||
AddChildSpriteToFoundation(image, pal, NULL, foundation_part, 0, -z_offset * ZOOM_LVL_BASE);
|
AddChildSpriteToFoundation(image, pal, sub, foundation_part, 0, -z_offset * ZOOM_LVL_BASE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1034,7 +1027,7 @@ static void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *t
|
|||||||
* @param ti TileInfo Tile that is being drawn
|
* @param ti TileInfo Tile that is being drawn
|
||||||
* @param pal Palette to apply.
|
* @param pal Palette to apply.
|
||||||
*/
|
*/
|
||||||
static void DrawTileSelectionRect(const TileInfo *ti, PaletteID pal)
|
void DrawTileSelectionRect(const TileInfo *ti, PaletteID pal)
|
||||||
{
|
{
|
||||||
if (!IsValidTile(ti->tile)) return;
|
if (!IsValidTile(ti->tile)) return;
|
||||||
|
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
#include "station_type.h"
|
#include "station_type.h"
|
||||||
#include "vehicle_base.h"
|
#include "vehicle_base.h"
|
||||||
|
|
||||||
|
struct TileInfo;
|
||||||
|
|
||||||
static const int TILE_HEIGHT_STEP = 50; ///< One Z unit tile height difference is displayed as 50m.
|
static const int TILE_HEIGHT_STEP = 50; ///< One Z unit tile height difference is displayed as 50m.
|
||||||
|
|
||||||
void SetSelectionRed(bool);
|
void SetSelectionRed(bool);
|
||||||
@@ -98,4 +100,7 @@ void ShowTooltipForTile(Window *w, const TileIndex tile);
|
|||||||
void ViewportMapClearTunnelCache();
|
void ViewportMapClearTunnelCache();
|
||||||
void ViewportMapInvalidateTunnelCacheByTile(const TileIndex tile);
|
void ViewportMapInvalidateTunnelCacheByTile(const TileIndex tile);
|
||||||
|
|
||||||
|
void DrawTileSelectionRect(const TileInfo *ti, PaletteID pal);
|
||||||
|
void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part, const SubSprite *sub = NULL);
|
||||||
|
|
||||||
#endif /* VIEWPORT_FUNC_H */
|
#endif /* VIEWPORT_FUNC_H */
|
||||||
|
@@ -149,4 +149,12 @@ enum ViewportScrollTarget {
|
|||||||
VST_CLIENT, ///< Single player
|
VST_CLIENT, ///< Single player
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Enumeration of multi-part foundations */
|
||||||
|
enum FoundationPart {
|
||||||
|
FOUNDATION_PART_NONE = 0xFF, ///< Neither foundation nor groundsprite drawn yet.
|
||||||
|
FOUNDATION_PART_NORMAL = 0, ///< First part (normal foundation or no foundation)
|
||||||
|
FOUNDATION_PART_HALFTILE = 1, ///< Second part (halftile foundation)
|
||||||
|
FOUNDATION_PART_END
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* VIEWPORT_TYPE_H */
|
#endif /* VIEWPORT_TYPE_H */
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include "tracerestrict.h"
|
#include "tracerestrict.h"
|
||||||
#include "window_func.h"
|
#include "window_func.h"
|
||||||
#include "zoning.h"
|
#include "zoning.h"
|
||||||
|
#include "viewport_func.h"
|
||||||
#include "3rdparty/cpp-btree/btree_set.h"
|
#include "3rdparty/cpp-btree/btree_set.h"
|
||||||
|
|
||||||
Zoning _zoning;
|
Zoning _zoning;
|
||||||
@@ -391,11 +392,34 @@ void DrawTileZoning(const TileInfo *ti)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_zoning.outer != ZEM_NOTHING) {
|
if (_zoning.outer != ZEM_NOTHING) {
|
||||||
DrawZoningSprites(SPR_SELECT_TILE, TileZoningSpriteEvaluationCached(ti->tile, _local_company, _zoning.outer, false), ti);
|
const SpriteID colour = TileZoningSpriteEvaluationCached(ti->tile, _local_company, _zoning.outer, false);
|
||||||
|
|
||||||
|
if (colour != ZONING_INVALID_SPRITE_ID) {
|
||||||
|
DrawTileSelectionRect(ti, colour);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_zoning.inner != ZEM_NOTHING) {
|
if (_zoning.inner != ZEM_NOTHING) {
|
||||||
DrawZoningSprites(SPR_ZONING_INNER_HIGHLIGHT_BASE, TileZoningSpriteEvaluationCached(ti->tile, _local_company, _zoning.inner, true), ti);
|
const SpriteID colour = TileZoningSpriteEvaluationCached(ti->tile, _local_company, _zoning.inner, true);
|
||||||
|
|
||||||
|
if (colour != ZONING_INVALID_SPRITE_ID) {
|
||||||
|
SpriteID sprite = SPR_ZONING_INNER_HIGHLIGHT_BASE;
|
||||||
|
|
||||||
|
if (IsHalftileSlope(ti->tileh)) {
|
||||||
|
const int INF = 1000;
|
||||||
|
static const SubSprite sub_sprites[4] = {
|
||||||
|
{ -INF , -INF , 32 - 33, INF }, // CORNER_W, clip 33 pixels from right
|
||||||
|
{ -INF , 0 + 22, INF , INF }, // CORNER_S, clip 22 pixels from top
|
||||||
|
{ -31 + 34, -INF , INF , INF }, // CORNER_E, clip 34 pixels from left
|
||||||
|
{ -INF , -INF , INF , 30 - 8 } // CORNER_N, clip 8 pixels from bottom
|
||||||
|
};
|
||||||
|
|
||||||
|
DrawSelectionSprite(sprite, colour, ti, 7 + TILE_HEIGHT, FOUNDATION_PART_HALFTILE, &(sub_sprites[GetHalftileSlopeCorner(ti->tileh)]));
|
||||||
|
} else {
|
||||||
|
sprite += SlopeToSpriteOffset(ti->tileh);
|
||||||
|
}
|
||||||
|
DrawSelectionSprite(sprite, colour, ti, 7, FOUNDATION_PART_NORMAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user