Add: Slope-aware and roadtype-specific one-way sprites. (#10282)
This commit is contained in:
@@ -6274,9 +6274,17 @@ static void GraphicsNew(ByteReader *buf)
|
||||
if (offset <= depot_no_track_offset && offset + num > depot_no_track_offset) _loaded_newgrf_features.tram = TRAMWAY_REPLACE_DEPOT_NO_TRACK;
|
||||
}
|
||||
|
||||
/* If the baseset or grf only provides sprites for flat tiles (pre #10282), duplicate those for use on slopes. */
|
||||
bool dup_oneway_sprites = ((type == 0x09) && (offset + num <= SPR_ONEWAY_SLOPE_N_OFFSET));
|
||||
|
||||
for (; num > 0; num--) {
|
||||
_cur.nfo_line++;
|
||||
LoadNextSprite(replace == 0 ? _cur.spriteid++ : replace++, *_cur.file, _cur.nfo_line);
|
||||
int load_index = (replace == 0 ? _cur.spriteid++ : replace++);
|
||||
LoadNextSprite(load_index, *_cur.file, _cur.nfo_line);
|
||||
if (dup_oneway_sprites) {
|
||||
DupSprite(load_index, load_index + SPR_ONEWAY_SLOPE_N_OFFSET);
|
||||
DupSprite(load_index, load_index + SPR_ONEWAY_SLOPE_S_OFFSET);
|
||||
}
|
||||
}
|
||||
|
||||
_cur.skip_sprites = skip_num;
|
||||
|
@@ -66,6 +66,7 @@ enum RoadTypeSpriteGroup {
|
||||
ROTSG_DEPOT, ///< Optional: Depot images
|
||||
ROTSG_reserved3, ///< Placeholder, if we add road fences (for highways).
|
||||
ROTSG_ROADSTOP, ///< Required: Drive-in stop surface
|
||||
ROTSG_ONEWAY, ///< Optional: One-way indicator images
|
||||
ROTSG_END,
|
||||
};
|
||||
|
||||
|
@@ -1606,7 +1606,17 @@ static void DrawRoadBits(TileInfo *ti)
|
||||
if (road_rti != nullptr) {
|
||||
DisallowedRoadDirections drd = GetDisallowedRoadDirections(ti->tile);
|
||||
if (drd != DRD_NONE) {
|
||||
DrawGroundSpriteAt(SPR_ONEWAY_BASE + drd - 1 + ((road == ROAD_X) ? 0 : 3), PAL_NONE, 8, 8, GetPartialPixelZ(8, 8, ti->tileh));
|
||||
SpriteID oneway = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_ONEWAY);
|
||||
|
||||
if (oneway == 0) oneway = SPR_ONEWAY_BASE;
|
||||
|
||||
if ((ti->tileh == SLOPE_NE) || (ti->tileh == SLOPE_NW)) {
|
||||
oneway += SPR_ONEWAY_SLOPE_N_OFFSET;
|
||||
} else if ((ti->tileh == SLOPE_SE) || (ti->tileh == SLOPE_SW)) {
|
||||
oneway += SPR_ONEWAY_SLOPE_S_OFFSET;
|
||||
}
|
||||
|
||||
DrawGroundSpriteAt(oneway + drd - 1 + ((road == ROAD_X) ? 0 : 3), PAL_NONE, 8, 8, GetPartialPixelZ(8, 8, ti->tileh));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -290,8 +290,10 @@ static const SpriteID SPR_TRAMWAY_DEPOT_NO_TRACK = SPR_TRAMWAY_BASE + 113;
|
||||
static const uint16 TRAMWAY_SPRITE_COUNT = 119;
|
||||
|
||||
/** One way road sprites */
|
||||
static const SpriteID SPR_ONEWAY_BASE = SPR_TRAMWAY_BASE + TRAMWAY_SPRITE_COUNT;
|
||||
static const uint16 ONEWAY_SPRITE_COUNT = 6;
|
||||
static const SpriteID SPR_ONEWAY_BASE = SPR_TRAMWAY_BASE + TRAMWAY_SPRITE_COUNT;
|
||||
static const SpriteID SPR_ONEWAY_SLOPE_N_OFFSET = 6;
|
||||
static const SpriteID SPR_ONEWAY_SLOPE_S_OFFSET = 12;
|
||||
static const uint16 ONEWAY_SPRITE_COUNT = 18;
|
||||
|
||||
/** Tunnel sprites with grass only for custom railtype tunnel. */
|
||||
static const SpriteID SPR_RAILTYPE_TUNNEL_BASE = SPR_ONEWAY_BASE + ONEWAY_SPRITE_COUNT;
|
||||
|
Reference in New Issue
Block a user