1
0
Fork 0

(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.

release/0.6
rubidium 2006-12-29 10:16:36 +00:00
parent 0d459f909c
commit 1e41e28026
1 changed files with 6 additions and 29 deletions

View File

@ -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,36 +983,15 @@ 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) {
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;
}