diff options
author | celestar <celestar@openttd.org> | 2005-01-30 22:04:14 +0000 |
---|---|---|
committer | celestar <celestar@openttd.org> | 2005-01-30 22:04:14 +0000 |
commit | b312055c805286641ce1fb57fb7efdc63daed870 (patch) | |
tree | 1b4965bbdd1fe6252f37dc3900abe5b0c5313de7 /station_cmd.c | |
parent | 1c109afdaafe6d2ce6fe8fd34678d7f9a50d5fcd (diff) | |
download | openttd-b312055c805286641ce1fb57fb7efdc63daed870.tar.xz |
(svn r1743) -Fix: Multistop: Added some debug output and made sure that orphaned slots are cleared.
Diffstat (limited to 'station_cmd.c')
-rw-r--r-- | station_cmd.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/station_cmd.c b/station_cmd.c index a1694a009..d6d81c702 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -2398,6 +2398,43 @@ static void StationHandleBigTick(Station *st) if (++st->delete_ctr >= 8) DeleteStation(st); } + + //Here we saveguard against orphaned slots + { + RoadStop *rs; + + for (rs = GetPrimaryRoadStop(st, RS_BUS); rs != NULL; rs = rs->next) { + int k; + for (k = 0; k < NUM_SLOTS; k++) { + if (rs->slot[k] != INVALID_SLOT) { + Vehicle *v = GetVehicle(rs->slot[k]); + + if (v->u.road.slot != rs) { + DEBUG(misc, 1) ("Bus Slot Desync! cleaning up (Don't panic)"); + v->u.road.slot = NULL; + v->u.road.slot_age = 0; + rs->slot[k] = INVALID_SLOT; + } + } + } + } + + for (rs = GetPrimaryRoadStop(st, RS_TRUCK); rs != NULL; rs = rs->next) { + int k; + for (k = 0; k < NUM_SLOTS; k++) { + if (rs->slot[k] != INVALID_SLOT) { + Vehicle *v = GetVehicle(rs->slot[k]); + + if (v->u.road.slot != rs) { + DEBUG(misc, 1) ("Truck Slot Desync! cleaning up (Don't panic)"); + v->u.road.slot = NULL; + v->u.road.slot_age = 0; + rs->slot[k] = INVALID_SLOT; + } + } + } + } + } } static inline void byte_inc_sat(byte *p) { byte b = *p + 1; if (b != 0) *p = b; } |