diff options
author | dominik <dominik@openttd.org> | 2004-12-19 09:39:19 +0000 |
---|---|---|
committer | dominik <dominik@openttd.org> | 2004-12-19 09:39:19 +0000 |
commit | bb5dca016ddbd7d21373c052cefa96f894e1e2fc (patch) | |
tree | 67065372ddab844b0eca1fb7b664f60f5c1d957a /train_cmd.c | |
parent | cf89cb12cd49333fba3b72001f52f1032c036f62 (diff) | |
download | openttd-bb5dca016ddbd7d21373c052cefa96f894e1e2fc.tar.xz |
(svn r1167) Feature: Added the possibility to add validation functions to NewsItems. This is now done for "Train in depot" messages. Before displaying such a message, it checks if the train really still is in the depot. Can be applied to other news items as well.
Diffstat (limited to 'train_cmd.c')
-rw-r--r-- | train_cmd.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/train_cmd.c b/train_cmd.c index d2bab6abf..389141d46 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -2546,6 +2546,16 @@ void Train_Tick(Vehicle *v) static const byte _depot_track_ind[4] = {0,1,0,1}; +// Validation for the news item "Train is waiting in depot" +bool ValidateTrainInDepot( uint data_a, uint data_b ) +{ + Vehicle *v = &_vehicles[data_a]; + if (v->u.rail.track == 0x80 && (v->vehstatus | VS_STOPPED)) + return true; + else + return false; +} + void TrainEnterDepot(Vehicle *v, uint tile) { SetSignalsOnBothDir(tile, _depot_track_ind[_map5[tile]&3]); @@ -2580,11 +2590,12 @@ void TrainEnterDepot(Vehicle *v, uint tile) v->vehstatus |= VS_STOPPED; if (v->owner == _local_player) { SetDParam(0, v->unitnumber); - AddNewsItem( + AddValidatedNewsItem( STR_8814_TRAIN_IS_WAITING_IN_DEPOT, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, - 0); + 0, + ValidateTrainInDepot); } } } |