summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormaedhros <maedhros@openttd.org>2007-06-10 21:28:20 +0000
committermaedhros <maedhros@openttd.org>2007-06-10 21:28:20 +0000
commitfe3a7cc5ed86e271842dd7e055ad9ad00f8e177b (patch)
treee0fc4bc7b8baa0fa1fc68bcb0ad24447b5ef5f56 /src
parenta0ffa793cc99116e5f8b12b29c42f2bef4233c34 (diff)
downloadopenttd-fe3a7cc5ed86e271842dd7e055ad9ad00f8e177b.tar.xz
(svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
Diffstat (limited to 'src')
-rw-r--r--src/rail_gui.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index cf18b58a5..10db2d61d 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -165,32 +165,27 @@ static void PlaceRail_Station(TileIndex tile)
static void GenericPlaceSignals(TileIndex tile)
{
- byte trackstat;
- uint i;
+ TrackBits trackbits = (TrackBits)GB(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0), 0, 6);
- trackstat = (byte)GetTileTrackStatus(tile, TRANSPORT_RAIL, 0);
-
- if (trackstat & TRACK_BIT_VERT) // N-S direction
- trackstat = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT;
-
- if (trackstat & TRACK_BIT_HORZ) // E-W direction
- trackstat = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER;
+ if (trackbits & TRACK_BIT_VERT) { // N-S direction
+ trackbits = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT;
+ }
- // Lookup the bit index
- i = 0;
- if (trackstat != 0) {
- for (; !(trackstat & 1); trackstat >>= 1) i++;
+ if (trackbits & TRACK_BIT_HORZ) { // E-W direction
+ trackbits = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER;
}
+ Track track = TrackBitsToTrack(trackbits);
+
if (!_remove_button_clicked) {
- uint32 p1 = GB(i, 0, 3);
+ uint32 p1 = track;
SB(p1, 3, 1, _ctrl_pressed);
SB(p1, 4, 1, _cur_year < _patches.semaphore_build_before);
DoCommandP(tile, p1, 0, CcPlaySound1E,
CMD_BUILD_SIGNALS | CMD_AUTO | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE));
} else {
- DoCommandP(tile, i, 0, CcPlaySound1E,
+ DoCommandP(tile, track, 0, CcPlaySound1E,
CMD_REMOVE_SIGNALS | CMD_AUTO | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM));
}
}