diff options
author | michi_cc <michi_cc@openttd.org> | 2011-10-31 22:31:40 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2011-10-31 22:31:40 +0000 |
commit | e094d7db624b69d2f0121e84e07abdb821f45ec9 (patch) | |
tree | 48fc1d4db1dd49d16838af094d6db5c323c7398d /src/station_cmd.cpp | |
parent | f66cd97776cd73c653fad685c9a74538b4d8a2a8 (diff) | |
download | openttd-e094d7db624b69d2f0121e84e07abdb821f45ec9.tar.xz |
(svn r23072) -Feature: [NewGRF] House callback 0x148.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 02d00238c..d79844214 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -49,6 +49,7 @@ #include "table/airporttile_ids.h" #include "newgrf_airporttiles.h" #include "order_backup.h" +#include "newgrf_house.h" #include "table/strings.h" @@ -2987,6 +2988,31 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i } /** + * Run the watched cargo callback for all houses in the catchment area. + * @param st Station. + */ +void TriggerWatchedCargoCallbacks(Station *st) +{ + /* Collect cargoes accepted since the last big tick. */ + uint cargoes = 0; + for (CargoID cid = 0; cid < NUM_CARGO; cid++) { + if (HasBit(st->goods[cid].acceptance_pickup, GoodsEntry::GES_ACCEPTED_BIGTICK)) SetBit(cargoes, cid); + } + + /* Anything to do? */ + if (cargoes == 0) return; + + /* Loop over all houses in the catchment. */ + Rect r = st->GetCatchmentRect(); + TileArea ta(TileXY(r.left, r.top), TileXY(r.right, r.bottom)); + TILE_AREA_LOOP(tile, ta) { + if (IsTileType(tile, MP_HOUSE)) { + WatchedCargoCallback(tile, cargoes); + } + } +} + +/** * 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. @@ -3000,6 +3026,8 @@ static bool StationHandleBigTick(BaseStation *st) } if (Station::IsExpected(st)) { + TriggerWatchedCargoCallbacks(Station::From(st)); + for (CargoID i = 0; i < NUM_CARGO; i++) { ClrBit(Station::From(st)->goods[i].acceptance_pickup, GoodsEntry::GES_ACCEPTED_BIGTICK); } |