diff options
author | tron <tron@openttd.org> | 2006-03-04 13:52:52 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-03-04 13:52:52 +0000 |
commit | d49ad36ed8d9e745d3b50be47d6cda2c1d78870a (patch) | |
tree | 2ebe4bf240436920f6c8b0522cd46a018dedee87 | |
parent | f4cf9b0a91dbf35ebd7ac61aa9a758f00dd1342a (diff) | |
download | openttd-d49ad36ed8d9e745d3b50be47d6cda2c1d78870a.tar.xz |
(svn r3760) Replace some magic numbers for checking for a suitable slope for a level crossing by some less magic numbers. Quite similar to r3699, though this time for placing the rails
-rw-r--r-- | rail_cmd.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/rail_cmd.c b/rail_cmd.c index 22ce7cc3e..5a76eed5d 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -130,7 +130,7 @@ static bool CheckTrackCombination(TileIndex tile, TrackBits to_build, uint flags } -static const byte _valid_tileh_slopes[4][15] = { +static const byte _valid_tileh_slopes[][15] = { // set of normal ones { @@ -197,15 +197,6 @@ static const byte _valid_tileh_slopes[4][15] = { TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_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 - } }; uint GetRailFoundation(uint tileh, uint bits) @@ -346,8 +337,13 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2) break; case MP_STREET: - if (!_valid_tileh_slopes[3][tileh]) // prevent certain slopes +#define M(x) (1 << (x)) + /* Level crossings may only be built on these slopes */ + if (!HASBIT(M(14) | M(13) | M(11) | M(10) | M(7) | M(5) | M(0), tileh)) { return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); + } +#undef M + if (!EnsureNoVehicle(tile)) return CMD_ERROR; if (GetRoadType(tile) == ROAD_NORMAL && ( |