mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-31 02:19:09 +00:00
(svn r2448) General cleanup of rail related code, more to follow.
* Add: rail.[ch] for rail-related enums and wrapper functions. * Codechange: Removed dozens of magic numbers with below enums. * Codechange: Rewrote CheckTrackCombination(). * Add: TILE_SIZE, TILE_PIXELS and TILE_HEIGHT constants. * Add: enums RailTileType, RailTileSubtype, SignalType to mask against the map arrays. * Add: enums Track, TrackBits, Trackdir, TrackdirBits for railway track data. (Note that the old RAIL_BIT constants are replaced by TRACK_BIT ones). * Add: enums Direction and DiagDirection * Codechange: Moved a bunch of track(dir) related lookup arrays from npf.[ch] to rail.[ch]. * Codechange: move RailType enum from tile.h to rail.h. * Add: Wrapper functions for masking signal status in the map arrays: SignalAlongTrackdir, SignalAgainstTrackdir and SignalOnTrack. * Add: Wrapper functions to access rail tiles, using above enums * Add: Wrapper functions to modify tracks, trackdirs, directions, etc. * Add: Wrapper functions for all lookup arrays in rail.[ch] (Arrays are still used in parts of the code) * Codechange: Renamed some variables and arguments to better represent what they contain (railbit -> track, bits -> trackdirbits, etc.). * Codechange: Don't use FindLandscapeHeight() in CmdRemoveSingleRail(), since it returns way too much info. Use GetTileSlope() instead. * Codechange: [NPF] Removed some unused globals and code from npf.c.
This commit is contained in:
@@ -568,7 +568,7 @@ static int ChooseShipTrack(Vehicle *v, uint tile, int enterdir, uint tracks)
|
||||
if (_patches.new_pathfinding_all) {
|
||||
NPFFindStationOrTileData fstd;
|
||||
NPFFoundTargetData ftd;
|
||||
uint src_tile = TILE_ADD(tile, TileOffsByDir(_reverse_dir[enterdir]));
|
||||
uint src_tile = TILE_ADD(tile, TileOffsByDir(ReverseDiagdir(enterdir)));
|
||||
byte trackdir = GetVehicleTrackdir(v);
|
||||
assert (trackdir != 0xFF); /* Check that we are not in a depot */
|
||||
|
||||
@@ -594,9 +594,9 @@ static int ChooseShipTrack(Vehicle *v, uint tile, int enterdir, uint tracks)
|
||||
tot_dist = (uint)-1;
|
||||
|
||||
/* Let's find out how far it would be if we would reverse first */
|
||||
b = GetTileShipTrackStatus(tile2) & _ship_sometracks[_reverse_dir[enterdir]] & v->u.ship.state;
|
||||
b = GetTileShipTrackStatus(tile2) & _ship_sometracks[ReverseDiagdir(enterdir)] & v->u.ship.state;
|
||||
if (b != 0) {
|
||||
dist = FindShipTrack(v, tile2, _reverse_dir[enterdir], b, tile, &track);
|
||||
dist = FindShipTrack(v, tile2, ReverseDiagdir(enterdir), b, tile, &track);
|
||||
if (dist != (uint)-1)
|
||||
tot_dist = dist + 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user