From 65e35eeea84d533c75911ee2b0dc93c56b984b4d Mon Sep 17 00:00:00 2001 From: dominik Date: Tue, 10 Aug 2004 18:35:43 +0000 Subject: [PATCH] (svn r14) Fix: railroad crossings on slopes are now possible --- rail_cmd.c | 21 +++++++++++++++++---- road_cmd.c | 31 +++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/rail_cmd.c b/rail_cmd.c index e3cecd9266..2b89a89776 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -118,7 +118,7 @@ static bool CheckTrackCombination(byte map5, byte trackbits, byte flags) } -static const byte _valid_tileh_slopes[3][15] = { +static const byte _valid_tileh_slopes[4][15] = { // set of normal ones { @@ -184,6 +184,15 @@ static const byte _valid_tileh_slopes[3][15] = { RAIL_BIT_DIAG2|RAIL_BIT_RIGHT|RAIL_BIT_UPPER, RAIL_BIT_DIAG1|RAIL_BIT_DIAG2|RAIL_BIT_UPPER|RAIL_BIT_LOWER|RAIL_BIT_LEFT|RAIL_BIT_RIGHT, RAIL_BIT_DIAG1|RAIL_BIT_DIAG2|RAIL_BIT_UPPER|RAIL_BIT_LOWER|RAIL_BIT_LEFT|RAIL_BIT_RIGHT, + }, + + // valid railway crossings on slopes + { + 1, 0, 0, // 0, 1, 2 + 0, 0, 1, // 3, 4, 5 + 0, 1, 0, // 6, 7, 8 + 0, 1, 1, // 9, 10, 11 + 0, 1, 1, // 12, 13, 14 } }; @@ -275,8 +284,12 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2) } else if (ti.type == MP_STREET) { byte m5; /* BUILD ON STREET CODE */ - if (ti.tileh != 0) goto need_clear; - + if (ti.tileh & 0x10) // very steep tile + return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); + + if (!_valid_tileh_slopes[3][ti.tileh]) // prevent certain slopes + return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); + if (!(ti.map5 & 0xF0)) { if ((ti.map5 & 0x0F) == 0xA) { if (rail_bit != 2) goto need_clear; @@ -1652,7 +1665,7 @@ uint GetSlopeZ_Track(TileInfo *ti) { uint z = ti->z; int th = ti->tileh; - + // check if it's a foundation if (ti->tileh != 0) { if ((ti->map5 & 0x80) == 0) { diff --git a/road_cmd.c b/road_cmd.c index 0e6de269e3..265a988d47 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -253,7 +253,7 @@ enum { ROAD_ALL = (ROAD_NW | ROAD_SW | ROAD_SE | ROAD_NE) }; -static const byte _valid_tileh_slopes_road[2][15] = { +static const byte _valid_tileh_slopes_road[3][15] = { // set of normal ones { ROAD_ALL, 0, 0, @@ -282,6 +282,14 @@ static const byte _valid_tileh_slopes_road[2][15] = { ROAD_NW | ROAD_SE | ROAD_NE, // 12 ROAD_ALL, ROAD_ALL + }, + // valid railway crossings on slopes + { + 1, 0, 0, // 0, 1, 2 + 0, 0, 1, // 3, 4, 5 + 0, 1, 0, // 6, 7, 8 + 0, 1, 1, // 9, 10, 11 + 0, 1, 1, // 12, 13, 14 } }; @@ -347,8 +355,12 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) } else if (ti.type == MP_RAILWAY) { byte m5; - if (ti.tileh != 0) goto do_clear; - + if (ti.tileh & 0x10) // very steep tile + return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); + + if(!_valid_tileh_slopes_road[2][ti.tileh]) // prevent certain slopes + return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); + if (ti.map5 == 2) { if (pieces & 5) goto do_clear; m5 = 0x10; @@ -371,7 +383,7 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) } else if (ti.type == MP_TUNNELBRIDGE) { /* check for flat land */ - if (ti.tileh & 0x10) //goto do_clear; // very steep tile + if (ti.tileh & 0x10) // very steep tile return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); /* is this middle part of a bridge? */ @@ -691,6 +703,10 @@ static uint GetRoadFoundation(uint tileh, uint bits) { ((bits == (ROAD_SW | ROAD_NE)) || (i++, bits == (ROAD_NW | ROAD_SE)))) return i + 15; + // rail crossing + if ((bits & 0x10) && _valid_tileh_slopes_road[2][tileh]) + return tileh; + return 0; } @@ -755,7 +771,10 @@ static void DrawTile_Road(TileInfo *ti) AddSortableSpriteToDraw(image, x, y, 2, 2, 0x10, z); drts++; } - } else if ( (ti->map5 & 0xE0) == 0) { + } else if ( (ti->map5 & 0xE0) == 0) { // railroad crossing + int f = GetRoadFoundation(ti->tileh, ti->map5 & 0xF); + if (f) DrawFoundation(ti, f); + image = 0x55B; if ( (ti->map5 & 8) != 0) @@ -836,7 +855,7 @@ uint GetSlopeZ_Road(TileInfo *ti) // check if it's a foundation if (ti->tileh != 0) { - if ((ti->map5 & 0xF0) == 0) { + if ((ti->map5 & 0xE0) == 0) { /* road or crossing */ uint f = GetRoadFoundation(ti->tileh, ti->map5 & 0x3F); if (f != 0) { if (f < 15) {