diff options
author | tron <tron@openttd.org> | 2006-03-08 06:55:33 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-03-08 06:55:33 +0000 |
commit | 8cfcdaa733684b00500f7811087312e6d8e60bc0 (patch) | |
tree | 5dc0e72ac096a8404e81f92e3e1480cb29c96061 /rail_cmd.c | |
parent | 3027b8673e31b52f50201e9571612a946cb3aade (diff) | |
download | openttd-8cfcdaa733684b00500f7811087312e6d8e60bc0.tar.xz |
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
Diffstat (limited to 'rail_cmd.c')
-rw-r--r-- | rail_cmd.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/rail_cmd.c b/rail_cmd.c index 3aad4431e..5f19dec00 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -1788,8 +1788,8 @@ bool UpdateSignalsOnSegment(TileIndex tile, Direction dir) void SetSignalsOnBothDir(TileIndex tile, byte track) { - static const byte _search_dir_1[6] = {1, 3, 1, 3, 5, 3}; - static const byte _search_dir_2[6] = {5, 7, 7, 5, 7, 1}; + static const Direction _search_dir_1[] = { DIR_NE, DIR_SE, DIR_NE, DIR_SE, DIR_SW, DIR_SE }; + static const Direction _search_dir_2[] = { DIR_SW, DIR_NW, DIR_NW, DIR_SW, DIR_NW, DIR_NE }; UpdateSignalsOnSegment(tile, _search_dir_1[track]); UpdateSignalsOnSegment(tile, _search_dir_2[track]); @@ -2069,15 +2069,13 @@ static const byte _deltacoord_leaveoffset[8] = { -1, 0, 1, 0, /* x */ 0, 1, 0, -1 /* y */ }; -static const byte _enter_directions[4] = {5, 7, 1, 3}; -static const byte _leave_directions[4] = {1, 3, 5, 7}; static const byte _depot_track_mask[4] = {1, 2, 1, 2}; static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y) { byte fract_coord; byte fract_coord_leave; - int dir; + DiagDirection dir; int length; // this routine applies only to trains in depot tiles @@ -2102,11 +2100,11 @@ static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y) /* make sure a train is not entering the tile from behind */ return 8; } else if (_fractcoords_enter[dir] == fract_coord) { - if (_enter_directions[dir] == v->direction) { + if (DiagDirToDir(ReverseDiagDir(dir)) == v->direction) { /* enter the depot */ v->u.rail.track = 0x80, v->vehstatus |= VS_HIDDEN; /* hide it */ - v->direction ^= 4; + v->direction = ReverseDir(v->direction); if (v->next == NULL) TrainEnterDepot(v, tile); v->tile = tile; @@ -2114,7 +2112,7 @@ static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y) return 4; } } else if (fract_coord_leave == fract_coord) { - if (_leave_directions[dir] == v->direction) { + if (DiagDirToDir(dir) == v->direction) { /* leave the depot? */ if ((v = v->next) != NULL) { v->vehstatus &= ~VS_HIDDEN; |