summaryrefslogtreecommitdiff
path: root/station_cmd.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-09-05 16:15:22 +0000
committertruelight <truelight@openttd.org>2004-09-05 16:15:22 +0000
commit10d54ac604b2d4d761877de1ceda07ceb3aa96bf (patch)
treeee4a252395acdf618350f3ff31b92a1b493f12ef /station_cmd.c
parent1846563cf89fc4cdd41691ddadac6b56dd8c2e58 (diff)
downloadopenttd-10d54ac604b2d4d761877de1ceda07ceb3aa96bf.tar.xz
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
-Fix: some minor fixes around GetTileTrackStatus (blathijs)
Diffstat (limited to 'station_cmd.c')
-rw-r--r--station_cmd.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/station_cmd.c b/station_cmd.c
index b2bd2f54a..c34aeb620 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -12,6 +12,7 @@
#include "economy.h"
#include "player.h"
#include "airport.h"
+#include "table/directions.h"
// FIXME -- need to be embedded into Airport variable. Is dynamically
// deducteable from graphics-tile array, so will not be needed
@@ -1837,21 +1838,34 @@ static void GetTileDesc_Station(uint tile, TileDesc *td)
static const byte _tile_track_status_rail[8] = { 1,2,1,2,1,2,1,2 };
-static uint32 GetTileTrackStatus_Station(uint tile, int mode) {
+static uint32 GetTileTrackStatus_Station(uint tile, TransportType mode) {
uint i = _map5[tile];
uint j = 0;
- if (mode == 0) {
+ if (mode == TRANSPORT_RAIL) {
if (i < 8)
j = _tile_track_status_rail[i];
- } else if (mode == 2) {
- // not needed
- } else if (mode == 4) {
- // buoy
+ j += (j << 8);
+ } else if (mode == TRANSPORT_ROAD) {
+ Station *st = DEREF_STATION(_map2[tile]);
+ if ( (IS_BYTE_INSIDE(i, 0x43, 0x47) && (_patches.roadveh_queue || st->truck_stop_status&3)) ||
+ (IS_BYTE_INSIDE(i, 0x47, 0x4B) && (_patches.roadveh_queue || st->bus_stop_status&3)) ) {
+ /* This is a bus/truck stop, and there is free space
+ * (or we allow queueing) */
+
+ /* We reverse the dir because it points out of the
+ * exit, and we want to get in. Maybe we should return
+ * both dirs here? */
+ byte dir = _reverse_dir[(i-0x43)&3];
+ j = 1 << _dir_to_straight_trackdir[dir];
+ }
+ } else if (mode == TRANSPORT_WATER) {
+ // buoy is coded as a station, it is always on open water
+ // (0x3F, all tracks available)
if (i == 0x52) j = 0x3F;
+ j += (j << 8);
}
-
- return j + (j << 8);
+ return j;
}
static void TileLoop_Station(uint tile)