equal
deleted
inserted
replaced
14 #include "engine.h" |
14 #include "engine.h" |
15 #include "player.h" |
15 #include "player.h" |
16 #include "sound.h" |
16 #include "sound.h" |
17 #include "depot.h" |
17 #include "depot.h" |
18 #include "waypoint.h" |
18 #include "waypoint.h" |
|
19 #include "vehicle_gui.h" |
19 |
20 |
20 #define is_firsthead_sprite(spritenum) \ |
21 #define is_firsthead_sprite(spritenum) \ |
21 (is_custom_sprite(spritenum) \ |
22 (is_custom_sprite(spritenum) \ |
22 ? is_custom_firsthead_sprite(spritenum) \ |
23 ? is_custom_firsthead_sprite(spritenum) \ |
23 : _engine_sprite_add[spritenum] == 0) |
24 : _engine_sprite_add[spritenum] == 0) |
1315 |
1316 |
1316 if (v->u.rail.track == 0x40) { tile = GetVehicleOutOfTunnelTile(v); } |
1317 if (v->u.rail.track == 0x40) { tile = GetVehicleOutOfTunnelTile(v); } |
1317 |
1318 |
1318 if (_patches.new_pathfinding_all) { |
1319 if (_patches.new_pathfinding_all) { |
1319 NPFFoundTargetData ftd; |
1320 NPFFoundTargetData ftd; |
1320 byte trackdir = _track_direction_to_trackdir[FIND_FIRST_BIT(v->u.rail.track)][v->direction]; |
1321 byte trackdir = GetVehicleTrackdir(v); |
|
1322 assert (trackdir != 0xFF); |
1321 ftd = NPFRouteToDepotBreadthFirst(v->tile, trackdir, TRANSPORT_RAIL, v->owner); |
1323 ftd = NPFRouteToDepotBreadthFirst(v->tile, trackdir, TRANSPORT_RAIL, v->owner); |
1322 if (ftd.best_bird_dist == 0) { |
1324 if (ftd.best_bird_dist == 0) { |
1323 /* Found target */ |
1325 /* Found target */ |
1324 tfdd.tile = ftd.node.tile; |
1326 tfdd.tile = ftd.node.tile; |
1325 tfdd.best_length = ftd.best_path_dist / NPF_TILE_LENGTH; |
1327 tfdd.best_length = ftd.best_path_dist / NPF_TILE_LENGTH; |
1666 NPFFoundTargetData ftd; |
1668 NPFFoundTargetData ftd; |
1667 byte trackdir; |
1669 byte trackdir; |
1668 |
1670 |
1669 NPFFillWithOrderData(&fstd, v); |
1671 NPFFillWithOrderData(&fstd, v); |
1670 /* The enterdir for the new tile, is the exitdir for the old tile */ |
1672 /* The enterdir for the new tile, is the exitdir for the old tile */ |
1671 trackdir = _track_exitdir_to_trackdir[FIND_FIRST_BIT(v->u.rail.track)][enterdir]; |
1673 trackdir = GetVehicleTrackdir(v); |
1672 assert(trackdir != 0xff); |
1674 assert(trackdir != 0xff); |
1673 |
1675 |
1674 ftd = NPFRouteToStationOrTile(tile - TileOffsByDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, v->owner); |
1676 ftd = NPFRouteToStationOrTile(tile - TileOffsByDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, v->owner); |
1675 |
1677 |
1676 if (ftd.best_trackdir == 0xff) { |
1678 if (ftd.best_trackdir == 0xff) { |
1802 byte trackdir, trackdir_rev; |
1804 byte trackdir, trackdir_rev; |
1803 Vehicle* last = GetLastVehicleInChain(v); |
1805 Vehicle* last = GetLastVehicleInChain(v); |
1804 |
1806 |
1805 NPFFillWithOrderData(&fstd, v); |
1807 NPFFillWithOrderData(&fstd, v); |
1806 |
1808 |
1807 trackdir = _track_direction_to_trackdir[FIND_FIRST_BIT(v->u.rail.track)][v->direction]; |
1809 trackdir = GetVehicleTrackdir(v); |
1808 trackdir_rev = REVERSE_TRACKDIR(_track_direction_to_trackdir[FIND_FIRST_BIT(last->u.rail.track)][last->direction]); |
1810 trackdir_rev = REVERSE_TRACKDIR(GetVehicleTrackdir(v)); |
1809 assert(trackdir != 0xff); |
1811 assert(trackdir != 0xff); |
1810 assert(trackdir_rev != 0xff); |
1812 assert(trackdir_rev != 0xff); |
1811 |
1813 |
1812 ftd = NPFRouteToStationOrTileTwoWay(v->tile, trackdir, last->tile, trackdir_rev, &fstd, TRANSPORT_RAIL, v->owner); |
1814 ftd = NPFRouteToStationOrTileTwoWay(v->tile, trackdir, last->tile, trackdir_rev, &fstd, TRANSPORT_RAIL, v->owner); |
1813 if (ftd.best_bird_dist != 0) { |
1815 if (ftd.best_bird_dist != 0) { |