Changeset - r19753:99ea1b960c98
[Not reviewed]
master
0 2 0
frosch - 12 years ago 2012-11-12 18:11:26
frosch@openttd.org
(svn r24708) -Codechange: Check magic values of GoodsEntry::last_speed only via wrapper function.
2 files changed with 9 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/station_base.h
Show inline comments
 
@@ -104,12 +104,19 @@ struct GoodsEntry {
 
	 * This does not imply there was any cargo to load.
 
	 */
 
	byte last_age;
 

	
 
	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. */
 
struct Airport : public TileArea {
 
	Airport() : TileArea(INVALID_TILE, 0, 0) {}
 

	
src/station_cmd.cpp
Show inline comments
 
@@ -3135,14 +3135,13 @@ static void UpdateStationRating(Station 
 

	
 
			if (HasBit(cs->callback_mask, CBM_CARGO_STATION_RATING_CALC)) {
 
				/* Perform custom station rating. If it succeeds the speed, days in transit and
 
				 * 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 */
 
				uint32 var10 = (st->last_vehicle_type == VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
 
				uint16 callback = GetCargoCallback(CBID_CARGO_STATION_RATING_CALC, var10, var18, cs);
 
				if (callback != CALLBACK_FAILED) {
 
@@ -3453,13 +3452,13 @@ uint MoveGoodsToStation(CargoID type, ui
 

	
 
		/* Is the station reserved exclusively for somebody else? */
 
		if (st->town->exclusive_counter > 0 && st->town->exclusivity != st->owner) continue;
 

	
 
		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
 
		} else {
 
			if (st->facilities == FACIL_BUS_STOP) continue; // non-passengers are never served by just a bus stop
 
		}
0 comments (0 inline, 0 general)