diff options
author | frosch <frosch@openttd.org> | 2012-11-12 18:11:26 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-11-12 18:11:26 +0000 |
commit | 0566b29ab7af463d815b67b05cff638423b68b98 (patch) | |
tree | c348caf5419e271a851443e9f10c9f6533f5b3d4 /src | |
parent | 03c94ae6a329b9098dd8df86afc1e9b96a6de2c5 (diff) | |
download | openttd-0566b29ab7af463d815b67b05cff638423b68b98.tar.xz |
(svn r24708) -Codechange: Check magic values of GoodsEntry::last_speed only via wrapper function.
Diffstat (limited to 'src')
-rw-r--r-- | src/station_base.h | 7 | ||||
-rw-r--r-- | src/station_cmd.cpp | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/station_base.h b/src/station_base.h index dcfc51418..5f179eb32 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -107,6 +107,13 @@ struct GoodsEntry { byte amount_fract; ///< Fractional part of the amount in the cargo list StationCargoList cargo; ///< The cargo packets of cargo waiting in this station + + /** + * Reports whether a vehicle has ever tried to load the cargo at this station. + * This does not imply that there was cargo available for loading. Refer to GES_PICKUP for that. + * @return true if vehicle tried to load. + */ + bool HasVehicleEverTriedLoading() const { return this->last_speed != 0; } }; /** All airport-related information. Only valid if tile != INVALID_TILE. */ diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 263bf49c0..b7725b459 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3138,8 +3138,7 @@ static void UpdateStationRating(Station *st) * waiting cargo ratings must not be executed. */ /* NewGRFs expect last speed to be 0xFF when no vehicle has arrived yet. */ - uint last_speed = ge->last_speed; - if (last_speed == 0) last_speed = 0xFF; + uint last_speed = ge->HasVehicleEverTriedLoading() ? ge->last_speed : 0xFF; uint32 var18 = min(ge->days_since_pickup, 0xFF) | (min(waiting, 0xFFFF) << 8) | (min(last_speed, 0xFF) << 24); /* Convert to the 'old' vehicle types */ @@ -3456,7 +3455,7 @@ uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, Sourc if (st->goods[type].rating == 0) continue; // Lowest possible rating, better not to give cargo anymore - if (_settings_game.order.selectgoods && st->goods[type].last_speed == 0) continue; // Selectively servicing stations, and not this one + if (_settings_game.order.selectgoods && !st->goods[type].HasVehicleEverTriedLoading()) continue; // Selectively servicing stations, and not this one if (IsCargoInClass(type, CC_PASSENGERS)) { if (st->facilities == FACIL_TRUCK_STOP) continue; // passengers are never served by just a truck stop |