diff options
author | rubidium <rubidium@openttd.org> | 2007-09-01 08:31:36 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-09-01 08:31:36 +0000 |
commit | 56ab253307c128cd99342ab1b6809e02b3fe9dcc (patch) | |
tree | 6358623fdcb900c9c4bcb968c9388b48c33f1cb5 /src/road_cmd.cpp | |
parent | 0df355bbda0e97edb0c642188db663620dd2e4f6 (diff) | |
download | openttd-56ab253307c128cd99342ab1b6809e02b3fe9dcc.tar.xz |
(svn r11031) -Codechange: reduce the amount of duplication of bit counting functions. Based on patches by skidd13, SmatZ and Belugas.
Diffstat (limited to 'src/road_cmd.cpp')
-rw-r--r-- | src/road_cmd.cpp | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 34163d16d..cf5015c8d 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -33,19 +33,6 @@ #include "tunnel_map.h" #include "misc/autoptr.hpp" - -static uint CountRoadBits(RoadBits r) -{ - uint count = 0; - - if (r & ROAD_NW) ++count; - if (r & ROAD_SW) ++count; - if (r & ROAD_SE) ++count; - if (r & ROAD_NE) ++count; - return count; -} - - bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt) { RoadBits present; @@ -225,7 +212,7 @@ CommandCost CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) MarkTileDirtyByTile(tile); } } - return CommandCost(CountRoadBits(c) * _price.remove_road); + return CommandCost(COUNTBITS(c) * _price.remove_road); } case ROAD_TILE_CROSSING: { @@ -487,7 +474,7 @@ do_clear:; pieces &= ComplementRoadBits(existing); } - cost.AddCost(CountRoadBits(pieces) * _price.build_road); + cost.AddCost(COUNTBITS(pieces) * _price.build_road); if (IsTileType(tile, MP_TUNNELBRIDGE)) { /* Pay for *every* tile of the bridge or tunnel */ cost.MultiplyCost(DistanceManhattan(IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile), tile)); |