mirror of https://github.com/OpenTTD/OpenTTD
Change: Transparent depots show all rail track.
parent
8488abaf2f
commit
dbd895ee6a
|
@ -276,4 +276,14 @@ inline bool IsDiagonalDirection(Direction dir)
|
||||||
return (dir & 1) != 0;
|
return (dir & 1) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a given DiagDirection is facing south.
|
||||||
|
* @param diag_dir Diagonal direction to check
|
||||||
|
* @return true iff the diagonal direction is facing south.
|
||||||
|
*/
|
||||||
|
static inline bool IsDiagDirFacingSouth(DiagDirection diag_dir)
|
||||||
|
{
|
||||||
|
return diag_dir == DIAGDIR_SE || diag_dir == DIAGDIR_SW;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* DIRECTION_FUNC_H */
|
#endif /* DIRECTION_FUNC_H */
|
||||||
|
|
157
src/rail_cmd.cpp
157
src/rail_cmd.cpp
|
@ -2117,7 +2117,12 @@ static inline void DrawTrackSprite(SpriteID sprite, PaletteID pal, const TileInf
|
||||||
static void DrawTrackBitsOverlay(TileInfo *ti, TrackBits track, const RailTypeInfo *rti)
|
static void DrawTrackBitsOverlay(TileInfo *ti, TrackBits track, const RailTypeInfo *rti)
|
||||||
{
|
{
|
||||||
RailGroundType rgt = GetRailGroundType(ti->tile);
|
RailGroundType rgt = GetRailGroundType(ti->tile);
|
||||||
Foundation f = GetRailFoundation(ti->tileh, track);
|
Foundation f = FOUNDATION_NONE;
|
||||||
|
if (IsRailDepot(ti->tile)) {
|
||||||
|
if (ti->tileh != SLOPE_FLAT) f = FOUNDATION_LEVELED;
|
||||||
|
} else {
|
||||||
|
f = GetRailFoundation(ti->tileh, track);
|
||||||
|
}
|
||||||
Corner halftile_corner = CORNER_INVALID;
|
Corner halftile_corner = CORNER_INVALID;
|
||||||
|
|
||||||
if (IsNonContinuousFoundation(f)) {
|
if (IsNonContinuousFoundation(f)) {
|
||||||
|
@ -2157,7 +2162,18 @@ static void DrawTrackBitsOverlay(TileInfo *ti, TrackBits track, const RailTypeIn
|
||||||
bool no_combine = ti->tileh == SLOPE_FLAT && HasBit(rti->flags, RTF_NO_SPRITE_COMBINE);
|
bool no_combine = ti->tileh == SLOPE_FLAT && HasBit(rti->flags, RTF_NO_SPRITE_COMBINE);
|
||||||
SpriteID overlay = GetCustomRailSprite(rti, ti->tile, RTSG_OVERLAY);
|
SpriteID overlay = GetCustomRailSprite(rti, ti->tile, RTSG_OVERLAY);
|
||||||
SpriteID ground = GetCustomRailSprite(rti, ti->tile, no_combine ? RTSG_GROUND_COMPLETE : RTSG_GROUND);
|
SpriteID ground = GetCustomRailSprite(rti, ti->tile, no_combine ? RTSG_GROUND_COMPLETE : RTSG_GROUND);
|
||||||
TrackBits pbs = _settings_client.gui.show_track_reservation ? GetRailReservationTrackBits(ti->tile) : TRACK_BIT_NONE;
|
|
||||||
|
TrackBits pbs = TRACK_BIT_NONE;
|
||||||
|
if (_settings_client.gui.show_track_reservation) {
|
||||||
|
if (IsPlainRail(ti->tile)) {
|
||||||
|
pbs = GetRailReservationTrackBits(ti->tile);
|
||||||
|
} else {
|
||||||
|
assert(IsRailDepot(ti->tile));
|
||||||
|
if (HasDepotReservation(ti->tile)) {
|
||||||
|
pbs = track;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (track == TRACK_BIT_NONE) {
|
if (track == TRACK_BIT_NONE) {
|
||||||
/* Half-tile foundation, no track here? */
|
/* Half-tile foundation, no track here? */
|
||||||
|
@ -2387,7 +2403,14 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track)
|
||||||
/* PBS debugging, draw reserved tracks darker */
|
/* PBS debugging, draw reserved tracks darker */
|
||||||
if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation) {
|
if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation) {
|
||||||
/* Get reservation, but mask track on halftile slope */
|
/* Get reservation, but mask track on halftile slope */
|
||||||
TrackBits pbs = GetRailReservationTrackBits(ti->tile) & track;
|
TrackBits pbs = TRACK_BIT_NONE;
|
||||||
|
if (IsPlainRail(ti->tile)) {
|
||||||
|
pbs = GetRailReservationTrackBits(ti->tile) & track;
|
||||||
|
} else {
|
||||||
|
assert(IsRailDepot(ti->tile));
|
||||||
|
if (HasDepotReservation(ti->tile)) pbs = track;
|
||||||
|
}
|
||||||
|
|
||||||
if (pbs & TRACK_BIT_X) {
|
if (pbs & TRACK_BIT_X) {
|
||||||
if (ti->tileh == SLOPE_FLAT || ti->tileh == SLOPE_ELEVATED) {
|
if (ti->tileh == SLOPE_FLAT || ti->tileh == SLOPE_ELEVATED) {
|
||||||
DrawGroundSprite(rti->base_sprites.single_x, PALETTE_CRASH);
|
DrawGroundSprite(rti->base_sprites.single_x, PALETTE_CRASH);
|
||||||
|
@ -2470,124 +2493,40 @@ static void DrawTile_Track(TileInfo *ti)
|
||||||
|
|
||||||
_drawtile_track_palette = COMPANY_SPRITE_COLOUR(GetTileOwner(ti->tile));
|
_drawtile_track_palette = COMPANY_SPRITE_COLOUR(GetTileOwner(ti->tile));
|
||||||
|
|
||||||
|
TrackBits rails = TRACK_BIT_NONE;
|
||||||
if (IsPlainRail(ti->tile)) {
|
if (IsPlainRail(ti->tile)) {
|
||||||
TrackBits rails = GetTrackBits(ti->tile);
|
rails = GetTrackBits(ti->tile);
|
||||||
|
|
||||||
DrawTrackBits(ti, rails);
|
|
||||||
|
|
||||||
if (HasBit(_display_opt, DO_FULL_DETAIL)) DrawTrackDetails(ti, rti);
|
|
||||||
|
|
||||||
if (HasRailCatenaryDrawn(GetRailType(ti->tile))) DrawRailCatenary(ti);
|
|
||||||
|
|
||||||
if (HasSignals(ti->tile)) DrawSignals(ti->tile, rails, rti);
|
|
||||||
} else {
|
} else {
|
||||||
|
assert(IsRailDepot(ti->tile));
|
||||||
|
DiagDirection dir = GetRailDepotDirection(ti->tile);
|
||||||
|
if (IsDiagDirFacingSouth(dir) || IsTransparencySet(TO_BUILDINGS)) {
|
||||||
|
rails = TrackToTrackBits(GetRailDepotTrack(ti->tile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawTrackBits(ti, rails);
|
||||||
|
|
||||||
|
if (IsPlainRail(ti->tile) && HasBit(_display_opt, DO_FULL_DETAIL)) DrawTrackDetails(ti, rti);
|
||||||
|
|
||||||
|
if (HasRailCatenaryDrawn(GetRailType(ti->tile))) DrawRailCatenary(ti);
|
||||||
|
|
||||||
|
if (IsRailDepot(ti->tile) && !IsInvisibilitySet(TO_BUILDINGS)) {
|
||||||
/* draw depot */
|
/* draw depot */
|
||||||
const DrawTileSprites *dts;
|
const DrawTileSprites *dts = &_depot_gfx_table[GetRailDepotDirection(ti->tile)];
|
||||||
PaletteID pal = PAL_NONE;
|
|
||||||
SpriteID relocation;
|
|
||||||
|
|
||||||
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
|
|
||||||
|
|
||||||
if (IsInvisibilitySet(TO_BUILDINGS)) {
|
|
||||||
/* Draw rail instead of depot */
|
|
||||||
dts = &_depot_invisible_gfx_table[GetRailDepotDirection(ti->tile)];
|
|
||||||
} else {
|
|
||||||
dts = &_depot_gfx_table[GetRailDepotDirection(ti->tile)];
|
|
||||||
}
|
|
||||||
|
|
||||||
SpriteID image;
|
|
||||||
if (rti->UsesOverlay()) {
|
|
||||||
image = SPR_FLAT_GRASS_TILE;
|
|
||||||
} else {
|
|
||||||
image = dts->ground.sprite;
|
|
||||||
if (image != SPR_FLAT_GRASS_TILE) image += rti->GetRailtypeSpriteOffset();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust ground tile for desert and snow. */
|
|
||||||
if (IsSnowRailGround(ti->tile)) {
|
|
||||||
if (image != SPR_FLAT_GRASS_TILE) {
|
|
||||||
image += rti->snow_offset; // tile with tracks
|
|
||||||
} else {
|
|
||||||
image = SPR_FLAT_SNOW_DESERT_TILE; // flat ground
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, _drawtile_track_palette));
|
|
||||||
|
|
||||||
if (rti->UsesOverlay()) {
|
|
||||||
SpriteID ground = GetCustomRailSprite(rti, ti->tile, RTSG_GROUND);
|
|
||||||
|
|
||||||
switch (GetRailDepotDirection(ti->tile)) {
|
|
||||||
case DIAGDIR_NE:
|
|
||||||
if (!IsInvisibilitySet(TO_BUILDINGS)) break;
|
|
||||||
[[fallthrough]];
|
|
||||||
case DIAGDIR_SW:
|
|
||||||
DrawGroundSprite(ground + RTO_X, PAL_NONE);
|
|
||||||
break;
|
|
||||||
case DIAGDIR_NW:
|
|
||||||
if (!IsInvisibilitySet(TO_BUILDINGS)) break;
|
|
||||||
[[fallthrough]];
|
|
||||||
case DIAGDIR_SE:
|
|
||||||
DrawGroundSprite(ground + RTO_Y, PAL_NONE);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_settings_client.gui.show_track_reservation && HasDepotReservation(ti->tile)) {
|
|
||||||
SpriteID overlay = GetCustomRailSprite(rti, ti->tile, RTSG_OVERLAY);
|
|
||||||
|
|
||||||
switch (GetRailDepotDirection(ti->tile)) {
|
|
||||||
case DIAGDIR_NE:
|
|
||||||
if (!IsInvisibilitySet(TO_BUILDINGS)) break;
|
|
||||||
[[fallthrough]];
|
|
||||||
case DIAGDIR_SW:
|
|
||||||
DrawGroundSprite(overlay + RTO_X, PALETTE_CRASH);
|
|
||||||
break;
|
|
||||||
case DIAGDIR_NW:
|
|
||||||
if (!IsInvisibilitySet(TO_BUILDINGS)) break;
|
|
||||||
[[fallthrough]];
|
|
||||||
case DIAGDIR_SE:
|
|
||||||
DrawGroundSprite(overlay + RTO_Y, PALETTE_CRASH);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* PBS debugging, draw reserved tracks darker */
|
|
||||||
if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasDepotReservation(ti->tile)) {
|
|
||||||
switch (GetRailDepotDirection(ti->tile)) {
|
|
||||||
case DIAGDIR_NE:
|
|
||||||
if (!IsInvisibilitySet(TO_BUILDINGS)) break;
|
|
||||||
[[fallthrough]];
|
|
||||||
case DIAGDIR_SW:
|
|
||||||
DrawGroundSprite(rti->base_sprites.single_x, PALETTE_CRASH);
|
|
||||||
break;
|
|
||||||
case DIAGDIR_NW:
|
|
||||||
if (!IsInvisibilitySet(TO_BUILDINGS)) break;
|
|
||||||
[[fallthrough]];
|
|
||||||
case DIAGDIR_SE:
|
|
||||||
DrawGroundSprite(rti->base_sprites.single_y, PALETTE_CRASH);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int depot_sprite = GetCustomRailSprite(rti, ti->tile, RTSG_DEPOT);
|
int depot_sprite = GetCustomRailSprite(rti, ti->tile, RTSG_DEPOT);
|
||||||
relocation = depot_sprite != 0 ? depot_sprite - SPR_RAIL_DEPOT_SE_1 : rti->GetRailtypeSpriteOffset();
|
SpriteID relocation = depot_sprite != 0 ? depot_sprite - SPR_RAIL_DEPOT_SE_1 : rti->GetRailtypeSpriteOffset();
|
||||||
|
|
||||||
if (HasRailCatenaryDrawn(GetRailType(ti->tile))) DrawRailCatenary(ti);
|
|
||||||
|
|
||||||
DrawRailTileSeq(ti, dts, TO_BUILDINGS, relocation, 0, _drawtile_track_palette);
|
DrawRailTileSeq(ti, dts, TO_BUILDINGS, relocation, 0, _drawtile_track_palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (HasSignals(ti->tile)) DrawSignals(ti->tile, rails, rti);
|
||||||
|
|
||||||
DrawBridgeMiddle(ti);
|
DrawBridgeMiddle(ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTrainDepotSprite(int x, int y, int dir, RailType railtype)
|
void DrawTrainDepotSprite(int x, int y, int dir, RailType railtype)
|
||||||
{
|
{
|
||||||
const DrawTileSprites *dts = &_depot_gfx_table[dir];
|
const DrawTileSprites *dts = &_depot_gfx_gui_table[dir];
|
||||||
const RailTypeInfo *rti = GetRailTypeInfo(railtype);
|
const RailTypeInfo *rti = GetRailTypeInfo(railtype);
|
||||||
SpriteID image = rti->UsesOverlay() ? SPR_FLAT_GRASS_TILE : dts->ground.sprite;
|
SpriteID image = rti->UsesOverlay() ? SPR_FLAT_GRASS_TILE : dts->ground.sprite;
|
||||||
uint32_t offset = rti->GetRailtypeSpriteOffset();
|
uint32_t offset = rti->GetRailtypeSpriteOffset();
|
||||||
|
|
|
@ -33,18 +33,18 @@ static const DrawTileSeqStruct _depot_gfx_NW[] = {
|
||||||
TILE_SEQ_END()
|
TILE_SEQ_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
static const DrawTileSprites _depot_gfx_table[] = {
|
static const DrawTileSprites _depot_gfx_gui_table[] = {
|
||||||
{ {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NE },
|
{ {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NE },
|
||||||
{ {SPR_RAIL_TRACK_Y, PAL_NONE}, _depot_gfx_SE },
|
{ {SPR_RAIL_TRACK_Y, PAL_NONE}, _depot_gfx_SE },
|
||||||
{ {SPR_RAIL_TRACK_X, PAL_NONE}, _depot_gfx_SW },
|
{ {SPR_RAIL_TRACK_X, PAL_NONE}, _depot_gfx_SW },
|
||||||
{ {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NW }
|
{ {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NW }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const DrawTileSprites _depot_invisible_gfx_table[] = {
|
static const DrawTileSprites _depot_gfx_table[] = {
|
||||||
{ {SPR_RAIL_TRACK_X, PAL_NONE}, _depot_gfx_NE },
|
{ {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NE },
|
||||||
{ {SPR_RAIL_TRACK_Y, PAL_NONE}, _depot_gfx_SE },
|
{ {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_SE },
|
||||||
{ {SPR_RAIL_TRACK_X, PAL_NONE}, _depot_gfx_SW },
|
{ {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_SW },
|
||||||
{ {SPR_RAIL_TRACK_Y, PAL_NONE}, _depot_gfx_NW }
|
{ {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NW }
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef TILE_SEQ_LINE
|
#undef TILE_SEQ_LINE
|
||||||
|
|
Loading…
Reference in New Issue