summaryrefslogtreecommitdiff
path: root/roadveh_cmd.c
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2004-09-14 01:21:07 +0000
committerdarkvater <darkvater@openttd.org>2004-09-14 01:21:07 +0000
commitbf703a0e825c16d07cf64f62ace41ff8b9bd69c0 (patch)
treecb5704e43e9954b1ccb64ff71ccd664d49cb0deb /roadveh_cmd.c
parent72457bac0dd4d20e98a1f7d537316f34a2ec5844 (diff)
downloadopenttd-bf703a0e825c16d07cf64f62ace41ff8b9bd69c0.tar.xz
(svn r242) -Fix: Pathfinding bug for road vehicles introduced in r160 fixed (blathijs)
-Fix: Pathfinding under bridges bug for ships introduced in r160 fixed (Darkvater)
Diffstat (limited to 'roadveh_cmd.c')
-rw-r--r--roadveh_cmd.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index c93ab2ee4..6255cafd6 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -1023,22 +1023,33 @@ static int RoadFindPathToDest(Vehicle *v, uint tile, int direction)
{
uint32 r;
- r = GetTileTrackStatus(tile, TRANSPORT_ROAD);
+ r = GetTileTrackStatus(tile, TRANSPORT_ROAD);
signal = (uint16)(r >> 16);
bitmask = (uint16)r;
}
-
- /* Most of the checks that used to be here, are now integrated into
- * GetTileTrackStatus now. The only thing still remaining is the
- * owner check for stations and depots, since GetTileTrackStatus
- * doesn't know about owner */
- if (IS_TILETYPE(tile, MP_STREET) && (_map5[tile]&0xF0) == 0x20 && v->owner != _map_owner[tile])
- /* Depot not owned by us */
- bitmask = 0;
- if (IS_TILETYPE(tile, MP_STATION) && _map_owner[tile] != OWNER_NONE && _map_owner[tile] != v->owner)
- /* Station not owned by us */
- bitmask = 0;
+ if (IS_TILETYPE(tile, MP_STREET)) {
+ if ((_map5[tile]&0xF0) == 0x20 && v->owner == _map_owner[tile])
+ /* Road crossing */
+ bitmask |= _road_veh_fp_ax_or[_map5[tile]&3];
+ } else if (IS_TILETYPE(tile, MP_STATION)) {
+ if (_map_owner[tile] == OWNER_NONE || _map_owner[tile] == v->owner) {
+ /* Our station */
+ Station *st = DEREF_STATION(_map2[tile]);
+ byte val = _map5[tile];
+ if (v->cargo_type != CT_PASSENGERS) {
+ if (IS_BYTE_INSIDE(val, 0x43, 0x47) && (_patches.roadveh_queue || st->truck_stop_status&3))
+ bitmask |= _road_veh_fp_ax_or[(val-0x43)&3];
+ } else {
+ if (IS_BYTE_INSIDE(val, 0x47, 0x4B) && (_patches.roadveh_queue || st->bus_stop_status&3))
+ bitmask |= _road_veh_fp_ax_or[(val-0x47)&3];
+ }
+ }
+ }
+ /* The above lookups should be moved to GetTileTrackStatus in the
+ * future, but that requires more changes to the pathfinder and other
+ * stuff, probably even more arguments to GTTS.
+ */
/* remove unreachable tracks */
bitmask &= _road_veh_fp_ax_and[direction];