diff options
author | rubidium <rubidium@openttd.org> | 2006-12-29 10:16:36 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2006-12-29 10:16:36 +0000 |
commit | e04d84c7b0916a7f912c0078b084180962a9db12 (patch) | |
tree | 1f82c84f7b15e2539caf67c8428be4cfb0e9e946 | |
parent | 50d681c1e9c87b4b1c7addbbfc1d11226eb51f26 (diff) | |
download | openttd-e04d84c7b0916a7f912c0078b084180962a9db12.tar.xz |
(svn r7609) -Codechange: remove some direct map accesses to m5 and some unneeded signal removal code in ClearTileTrack as it is done in CmdRemoveSingleRail too, which is called for every removed trackbit.
-rw-r--r-- | rail_cmd.c | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/rail_cmd.c b/rail_cmd.c index 78ba7c2ad..dcc749310 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -272,7 +272,7 @@ int32 CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (flags & DC_EXEC) { SetRailGroundType(tile, RAIL_GROUND_BARREN); - _m[tile].m5 |= trackbit; + SetTrackBits(tile, GetTrackBits(tile) | trackbit); } break; @@ -967,9 +967,7 @@ static int32 ClearTile_Track(TileIndex tile, byte flags) { int32 cost; int32 ret; - byte m5; - - m5 = _m[tile].m5; + TrackBits tracks = GetTrackBits(tile); if (flags & DC_AUTO) { if (!IsTileOwner(tile, _current_player)) @@ -985,35 +983,14 @@ static int32 ClearTile_Track(TileIndex tile, byte flags) cost = 0; switch (GetRailTileType(tile)) { - /* XXX: Why the fuck do we remove these thow signals first? */ case RAIL_TILE_SIGNALS: - if (HasSignalOnTrack(tile, TRACK_X)) { - ret = DoCommand(tile, TRACK_X, 0, flags, CMD_REMOVE_SIGNALS); - if (CmdFailed(ret)) return CMD_ERROR; - cost += ret; - } - if (HasSignalOnTrack(tile, TRACK_LOWER)) { - ret = DoCommand(tile, TRACK_LOWER, 0, flags, CMD_REMOVE_SIGNALS); - if (CmdFailed(ret)) return CMD_ERROR; - cost += ret; - } - - m5 &= TRACK_BIT_MASK; - if (!(flags & DC_EXEC)) { - for (; m5 != 0; m5 >>= 1) if (m5 & 1) cost += _price.remove_rail; - return cost; - } - /* FALLTHROUGH */ - case RAIL_TILE_NORMAL: { uint i; - for (i = 0; m5 != 0; i++, m5 >>= 1) { - if (m5 & 1) { - ret = DoCommand(tile, 0, i, flags, CMD_REMOVE_SINGLE_RAIL); - if (CmdFailed(ret)) return CMD_ERROR; - cost += ret; - } + for_each_bit (i, tracks) { + ret = DoCommand(tile, 0, i, flags, CMD_REMOVE_SINGLE_RAIL); + if (CmdFailed(ret)) return CMD_ERROR; + cost += ret; } return cost; } |