summaryrefslogtreecommitdiff
path: root/landscape.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-08-12 12:56:45 +0000
committertron <tron@openttd.org>2006-08-12 12:56:45 +0000
commit012e144cc10a5df24523085aab3ac78767fa92d4 (patch)
tree0bf68ac462bfafbdd65f20f1b609ed958b616c74 /landscape.c
parentde4a96fd7a3a3fefb9119ffc4bf57cc27e8ae0a6 (diff)
downloadopenttd-012e144cc10a5df24523085aab3ac78767fa92d4.tar.xz
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
Diffstat (limited to 'landscape.c')
-rw-r--r--landscape.c61
1 files changed, 40 insertions, 21 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);
}
}