From 45af2a294c813eb87fe130d0fbcdba0af254963e Mon Sep 17 00:00:00 2001 From: smatz Date: Wed, 27 May 2009 23:11:52 +0000 Subject: (svn r16452) -Fix: don't trigger station animations when the station was deleted in the same tick --- src/station_cmd.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index d2403bb4f..4e5bb3c06 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2696,13 +2696,18 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i * This function is called for each station once every 250 ticks. * Not all stations will get the tick at the same time. * @param st the station receiving the tick. + * @return true if the station is still valid (wasn't deleted) */ -static void StationHandleBigTick(Station *st) +static bool StationHandleBigTick(Station *st) { UpdateStationAcceptance(st, true); - if (st->facilities == 0 && ++st->delete_ctr >= 8) delete st; + if (st->facilities == 0 && ++st->delete_ctr >= 8) { + delete st; + return false; + } + return true; } static inline void byte_inc_sat(byte *p) @@ -2844,7 +2849,8 @@ void OnTick_Station() * Station index is included so that triggers are not all done * at the same time. */ if ((_tick_counter + st->index) % 250 == 0) { - StationHandleBigTick(st); + /* Stop processing this station if it was deleted */ + if (!StationHandleBigTick(st)) continue; StationAnimationTrigger(st, st->xy, STAT_ANIM_250_TICKS); } } -- cgit v1.2.3-70-g09d2