1
0
Fork 0

Change: Separate ground sprite from foundation sprite offsets.

pull/10278/head
Peter Nelson 2022-12-18 12:35:08 +00:00 committed by PeterN
parent 002fe67bef
commit 138198e971
3 changed files with 17 additions and 13 deletions

View File

@ -516,26 +516,27 @@ void DrawFoundation(TileInfo *ti, Foundation f)
f == FOUNDATION_INCLINED_Y ? 16 : 1, f == FOUNDATION_INCLINED_Y ? 16 : 1,
TILE_HEIGHT, ti->z TILE_HEIGHT, ti->z
); );
OffsetGroundSprite(31, 9); OffsetGroundSprite(0, 0);
} else if (IsLeveledFoundation(f)) { } else if (IsLeveledFoundation(f)) {
AddSortableSpriteToDraw(leveled_base + SlopeWithOneCornerRaised(highest_corner), PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z - TILE_HEIGHT); AddSortableSpriteToDraw(leveled_base + SlopeWithOneCornerRaised(highest_corner), PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z - TILE_HEIGHT);
OffsetGroundSprite(31, 1); OffsetGroundSprite(0, -8);
} else if (f == FOUNDATION_STEEP_LOWER) { } else if (f == FOUNDATION_STEEP_LOWER) {
/* one corner raised */ /* one corner raised */
OffsetGroundSprite(31, 1); OffsetGroundSprite(0, -8);
} else { } else {
/* halftile foundation */ /* halftile foundation */
int x_bb = (((highest_corner == CORNER_W) || (highest_corner == CORNER_S)) ? 8 : 0); int x_bb = (((highest_corner == CORNER_W) || (highest_corner == CORNER_S)) ? 8 : 0);
int y_bb = (((highest_corner == CORNER_S) || (highest_corner == CORNER_E)) ? 8 : 0); int y_bb = (((highest_corner == CORNER_S) || (highest_corner == CORNER_E)) ? 8 : 0);
AddSortableSpriteToDraw(halftile_base + highest_corner, PAL_NONE, ti->x + x_bb, ti->y + y_bb, 8, 8, 7, ti->z + TILE_HEIGHT); AddSortableSpriteToDraw(halftile_base + highest_corner, PAL_NONE, ti->x + x_bb, ti->y + y_bb, 8, 8, 7, ti->z + TILE_HEIGHT);
OffsetGroundSprite(31, 9); Point pt = {(y_bb - x_bb) * 2, y_bb + x_bb};
OffsetGroundSprite(-pt.x, -pt.y);
} }
} else { } else {
if (IsLeveledFoundation(f)) { if (IsLeveledFoundation(f)) {
/* leveled foundation */ /* leveled foundation */
AddSortableSpriteToDraw(leveled_base + ti->tileh, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z); AddSortableSpriteToDraw(leveled_base + ti->tileh, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z);
OffsetGroundSprite(31, 1); OffsetGroundSprite(0, -8);
} else if (IsNonContinuousFoundation(f)) { } else if (IsNonContinuousFoundation(f)) {
/* halftile foundation */ /* halftile foundation */
Corner halftile_corner = GetHalftileFoundationCorner(f); Corner halftile_corner = GetHalftileFoundationCorner(f);
@ -543,7 +544,8 @@ void DrawFoundation(TileInfo *ti, Foundation f)
int y_bb = (((halftile_corner == CORNER_S) || (halftile_corner == CORNER_E)) ? 8 : 0); int y_bb = (((halftile_corner == CORNER_S) || (halftile_corner == CORNER_E)) ? 8 : 0);
AddSortableSpriteToDraw(halftile_base + halftile_corner, PAL_NONE, ti->x + x_bb, ti->y + y_bb, 8, 8, 7, ti->z); AddSortableSpriteToDraw(halftile_base + halftile_corner, PAL_NONE, ti->x + x_bb, ti->y + y_bb, 8, 8, 7, ti->z);
OffsetGroundSprite(31, 9); Point pt = {(y_bb - x_bb) * 2, y_bb + x_bb};
OffsetGroundSprite(-pt.x, -pt.y);
} else if (IsSpecialRailFoundation(f)) { } else if (IsSpecialRailFoundation(f)) {
/* anti-zig-zag foundation */ /* anti-zig-zag foundation */
SpriteID spr; SpriteID spr;
@ -555,7 +557,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
spr = inclined_base + 2 * GetRailFoundationCorner(f) + ((ti->tileh == SLOPE_SW || ti->tileh == SLOPE_NE) ? 1 : 0); spr = inclined_base + 2 * GetRailFoundationCorner(f) + ((ti->tileh == SLOPE_SW || ti->tileh == SLOPE_NE) ? 1 : 0);
} }
AddSortableSpriteToDraw(spr, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z); AddSortableSpriteToDraw(spr, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z);
OffsetGroundSprite(31, 9); OffsetGroundSprite(0, 0);
} else { } else {
/* inclined foundation */ /* inclined foundation */
byte inclined = GetHighestSlopeCorner(ti->tileh) * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0); byte inclined = GetHighestSlopeCorner(ti->tileh) * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0);
@ -565,7 +567,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
f == FOUNDATION_INCLINED_Y ? 16 : 1, f == FOUNDATION_INCLINED_Y ? 16 : 1,
TILE_HEIGHT, ti->z TILE_HEIGHT, ti->z
); );
OffsetGroundSprite(31, 9); OffsetGroundSprite(0, 0);
} }
ti->z += ApplyPixelFoundationToSlope(f, &ti->tileh); ti->z += ApplyPixelFoundationToSlope(f, &ti->tileh);
} }

View File

@ -2921,7 +2921,7 @@ static void DrawTile_Station(TileInfo *ti)
EndSpriteCombine(); EndSpriteCombine();
} }
OffsetGroundSprite(31, 1); OffsetGroundSprite(0, -8);
ti->z += ApplyPixelFoundationToSlope(FOUNDATION_LEVELED, &ti->tileh); ti->z += ApplyPixelFoundationToSlope(FOUNDATION_LEVELED, &ti->tileh);
} else { } else {
draw_default_foundation: draw_default_foundation:

View File

@ -538,7 +538,7 @@ static void AddChildSpriteToFoundation(SpriteID image, PaletteID pal, const SubS
int *old_child = _vd.last_child; int *old_child = _vd.last_child;
_vd.last_child = _vd.last_foundation_child[foundation_part]; _vd.last_child = _vd.last_foundation_child[foundation_part];
AddChildSpriteScreen(image, pal, offs.x + extra_offs_x, offs.y + extra_offs_y, false, sub, false); AddChildSpriteScreen(image, pal, offs.x + extra_offs_x, offs.y + extra_offs_y, false, sub, false, false);
/* Switch back to last ChildSprite list */ /* Switch back to last ChildSprite list */
_vd.last_child = old_child; _vd.last_child = old_child;
@ -876,16 +876,18 @@ 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 extra_offs_x Pixel X offset for the sprite position.
* @param extra_offs_y Pixel Y offset for the sprite position.
*/ */
static void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part) static void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part, int extra_offs_x = 0, int extra_offs_y = 0)
{ {
/* 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, nullptr, extra_offs_x, extra_offs_y);
} else { } else {
/* draw on top of foundation */ /* draw on top of foundation */
AddChildSpriteToFoundation(image, pal, nullptr, foundation_part, 0, -z_offset * ZOOM_LVL_BASE); AddChildSpriteToFoundation(image, pal, nullptr, foundation_part, extra_offs_x, extra_offs_y - z_offset * ZOOM_LVL_BASE);
} }
} }