Mercurial > hg > openttd
changeset 3070:9c9666dd671a draft
(svn r3659) Add function to get the road bits of a level crossing
author | tron <tron@openttd.org> |
---|---|
date | Thu, 23 Feb 2006 11:53:48 +0000 |
parents | a7c09d88896f |
children | d1a65c954e58 |
files | road.h road_cmd.c |
diffstat | 2 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/road.h +++ b/road.h @@ -20,6 +20,11 @@ return GB(_m[tile].m5, 0, 4); } +static inline RoadBits GetCrossingRoadBits(TileIndex tile) +{ + return _m[tile].m5 & 8 ? ROAD_Y : ROAD_X; +} + typedef enum RoadType { ROAD_NORMAL, ROAD_CROSSING,
--- a/road_cmd.c +++ b/road_cmd.c @@ -34,7 +34,7 @@ case MP_STREET: switch (GetRoadType(tile)) { case ROAD_NORMAL: b = GetRoadBits(tile); break; - case ROAD_CROSSING: b = (_m[tile].m5 & 8 ? ROAD_Y : ROAD_X); break; + case ROAD_CROSSING: b = GetCrossingRoadBits(tile); break; case ROAD_DEPOT: return (~_m[tile].m5 & 3) == i; default: return false; } @@ -709,7 +709,7 @@ if (flags & DC_AUTO) return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); - ret = DoCommandByTile(tile, (_m[tile].m5 & 8 ? ROAD_Y : ROAD_X), 0, flags, CMD_REMOVE_ROAD); + ret = DoCommandByTile(tile, GetCrossingRoadBits(tile), 0, flags, CMD_REMOVE_ROAD); if (CmdFailed(ret)) return CMD_ERROR; if (flags & DC_EXEC) { @@ -1212,10 +1212,10 @@ break; case ROAD_CROSSING: - _m[tile].m5 = (_m[tile].m5&8) ? 0x5 : 0xA; SetTileOwner(tile, _m[tile].m3); _m[tile].m3 = 0; _m[tile].m4 &= 0x80; + _m[tile].m5 = GetCrossingRoadBits(tile); break; default: