diff options
-rw-r--r-- | landscape.c | 61 | ||||
-rw-r--r-- | rail_cmd.c | 12 | ||||
-rw-r--r-- | table/autorail.h | 8 | ||||
-rw-r--r-- | variables.h | 2 |
4 files changed, 53 insertions, 30 deletions
diff --git a/landscape.c b/landscape.c index 8f6289888..007d653e0 100644 --- a/landscape.c +++ b/landscape.c @@ -51,7 +51,9 @@ const byte _tileh_to_sprite[32] = { }; const byte _inclined_tileh[] = { - SLOPE_SW, SLOPE_NW, SLOPE_SW, SLOPE_SE, SLOPE_NE, SLOPE_SE, SLOPE_NE, SLOPE_NW + SLOPE_SW, SLOPE_NW, SLOPE_SW, SLOPE_SE, SLOPE_NE, SLOPE_SE, SLOPE_NE, SLOPE_NW, + SLOPE_E, SLOPE_N, SLOPE_W, SLOPE_S, + SLOPE_NWS, SLOPE_WSE, SLOPE_SEN, SLOPE_ENW }; @@ -203,31 +205,48 @@ void DrawFoundation(TileInfo *ti, uint f) if (!HasFoundationNW(ti->tile, slope, z)) sprite_base += 22; if (!HasFoundationNE(ti->tile, slope, z)) sprite_base += 44; - if (f < 15) { - // leveled foundation - // Use the original slope sprites if NW and NE borders should be visible - if (sprite_base == SPR_SLOPES_BASE - 15) sprite_base = SPR_FOUNDATION_BASE; + if (IsSteepSlope(ti->tileh)) { + uint32 lower_base; - AddSortableSpriteToDraw(sprite_base + f, ti->x, ti->y, 16, 16, 7, ti->z); + // Lower part of foundation + lower_base = sprite_base; + if (lower_base == SPR_SLOPES_BASE - 15) lower_base = SPR_FOUNDATION_BASE; + AddSortableSpriteToDraw( + lower_base + (ti->tileh & ~SLOPE_STEEP), ti->x, ti->y, 16, 16, 7, ti->z + ); ti->z += TILE_HEIGHT; - ti->tileh = SLOPE_FLAT; - OffsetGroundSprite(31, 1); + ti->tileh = _inclined_tileh[f - 15]; + if (f < 15 + 8) { + // inclined + AddSortableSpriteToDraw(sprite_base + f, ti->x, ti->y, 16, 16, 1, ti->z); + OffsetGroundSprite(31, 9); + } else if (f >= 15 + 8 + 4) { + // three corners raised + uint32 upper = sprite_base + 15 + (f - 15 - 8 - 4) * 2; + + AddSortableSpriteToDraw(upper, ti->x, ti->y, 16, 16, 1, ti->z); + AddChildSpriteScreen(upper + 1, 31, 9); + OffsetGroundSprite(31, 9); + } else { + // one corner raised + OffsetGroundSprite(31, 1); + } } else { - // inclined foundation - if (IsSteepSlope(ti->tileh)) { - uint32 lower_base; - - // Lower part of foundation - lower_base = sprite_base; - if (lower_base == SPR_SLOPES_BASE - 15) lower_base = SPR_FOUNDATION_BASE; - AddSortableSpriteToDraw( - lower_base + (ti->tileh & ~SLOPE_STEEP), ti->x, ti->y, 16, 16, 7, ti->z - ); + if (f < 15) { + // leveled foundation + // Use the original slope sprites if NW and NE borders should be visible + if (sprite_base == SPR_SLOPES_BASE - 15) sprite_base = SPR_FOUNDATION_BASE; + + AddSortableSpriteToDraw(sprite_base + f, ti->x, ti->y, 16, 16, 7, ti->z); ti->z += TILE_HEIGHT; + ti->tileh = SLOPE_FLAT; + OffsetGroundSprite(31, 1); + } else { + // inclined foundation + AddSortableSpriteToDraw(sprite_base + f, ti->x, ti->y, 16, 16, 1, ti->z); + ti->tileh = _inclined_tileh[f - 15]; + OffsetGroundSprite(31, 9); } - AddSortableSpriteToDraw(sprite_base + f, ti->x, ti->y, 16, 16, 1, ti->z); - ti->tileh = _inclined_tileh[f - 15]; - OffsetGroundSprite(31, 9); } } diff --git a/rail_cmd.c b/rail_cmd.c index f94f4e2c2..4676d492b 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -160,9 +160,13 @@ uint GetRailFoundation(Slope tileh, TrackBits bits) } switch (bits) { + default: NOT_REACHED(); case TRACK_BIT_X: i = 0; break; case TRACK_BIT_Y: i = 1; break; - default: return 0; + case TRACK_BIT_LEFT: return 15 + 8 + (tileh == SLOPE_STEEP_W ? 4 : 0); + case TRACK_BIT_LOWER: return 15 + 8 + (tileh == SLOPE_STEEP_S ? 5 : 1); + case TRACK_BIT_RIGHT: return 15 + 8 + (tileh == SLOPE_STEEP_E ? 6 : 2); + case TRACK_BIT_UPPER: return 15 + 8 + (tileh == SLOPE_STEEP_N ? 7 : 3); } switch (tileh) { case SLOPE_W: @@ -182,9 +186,9 @@ uint GetRailFoundation(Slope tileh, TrackBits bits) static uint32 CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile) { if (IsSteepSlope(tileh)) { - if (existing == 0 && - (rail_bits == TRACK_BIT_X || rail_bits == TRACK_BIT_Y)) { - return _price.terraform; + if (existing == 0) { + TrackBits valid = TRACK_BIT_CROSS | (HASBIT(1 << SLOPE_STEEP_W | 1 << SLOPE_STEEP_E, tileh) ? TRACK_BIT_VERT : TRACK_BIT_HORZ); + if (valid & rail_bits) return _price.terraform; } } else { rail_bits |= existing; diff --git a/table/autorail.h b/table/autorail.h index b8af0a604..bc5a9cbbd 100644 --- a/table/autorail.h +++ b/table/autorail.h @@ -38,14 +38,14 @@ static const int _AutorailTilehSprite[][6] = { { 0, 1, 2, 3, 4, 5 }, // invalid (20) { 0, 1, 2, 3, 4, 5 }, // invalid (21) { 0, 1, 2, 3, 4, 5 }, // invalid (22) - { 6, 11, RED(17), RED(27), RED(39), RED(47) }, // tileh = 23 + { 6, 11, 17, 27, RED(39), RED(47) }, // tileh = 23 { 0, 1, 2, 3, 4, 5 }, // invalid (24) { 0, 1, 2, 3, 4, 5 }, // invalid (25) { 0, 1, 2, 3, 4, 5 }, // invalid (26) - { 7, 15, RED(24), RED(33), RED(36), RED(44) }, // tileh = 27 + { 7, 15, RED(24), RED(33), 36, 44 }, // tileh = 27 { 0, 1, 2, 3, 4, 5 }, // invalid (28) - { 3, 14, RED(18), RED(26), RED(41), RED(49) }, // tileh = 29 - { 4, 12, RED(21), RED(30), RED(37), RED(45) } // tileh = 30 + { 3, 14, 18, 26, RED(41), RED(49) }, // tileh = 29 + { 4, 12, RED(21), RED(30), 37, 45 } // tileh = 30 }; #undef RED diff --git a/variables.h b/variables.h index e67b96573..b47108f36 100644 --- a/variables.h +++ b/variables.h @@ -405,7 +405,7 @@ StringID BindCString(const char *str); /* landscape.c */ extern const byte _tileh_to_sprite[32]; -extern const byte _inclined_tileh[8]; +extern const byte _inclined_tileh[16]; extern const TileTypeProcs * const _tile_type_procs[16]; |