Changeset - r17748:5f2cf48eef70
[Not reviewed]
master
0 3 0
terkhen - 13 years ago 2011-06-04 21:21:00
terkhen@openttd.org
(svn r22542) -Add: Store cargo acceptance stats for stations.
3 files changed with 31 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/economy.cpp
Show inline comments
 
@@ -930,20 +930,27 @@ static uint DeliverGoodsToIndustry(const
 
 * @note The cargo is just added to the stockpile of the industry. It is due to the caller to trigger the industry's production machinery
 
 */
 
static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, TileIndex source_tile, byte days_in_transit, Company *company, SourceType src_type, SourceID src)
 
{
 
	assert(num_pieces > 0);
 

	
 
	const Station *st = Station::Get(dest);
 
	Station *st = Station::Get(dest);
 

	
 
	/* Give the goods to the industry. */
 
	uint accepted = DeliverGoodsToIndustry(st, cargo_type, num_pieces, src_type == ST_INDUSTRY ? src : INVALID_INDUSTRY);
 

	
 
	/* If this cargo type is always accepted, accept all */
 
	if (HasBit(st->always_accepted, cargo_type)) accepted = num_pieces;
 

	
 
	/* Update station statistics */
 
	if (accepted > 0) {
 
		SetBit(st->goods[cargo_type].acceptance_pickup, GoodsEntry::GES_EVER_ACCEPTED);
 
		SetBit(st->goods[cargo_type].acceptance_pickup, GoodsEntry::GES_CURRENT_MONTH);
 
		SetBit(st->goods[cargo_type].acceptance_pickup, GoodsEntry::GES_ACCEPTED_BIGTICK);
 
	}
 

	
 
	/* Update company statistics */
 
	company->cur_economy.delivered_cargo += accepted;
 
	if (accepted > 0) SetBit(company->cargo_types, cargo_type);
 

	
 
	/* Increase town's counter for some special goods types */
 
	const CargoSpec *cs = CargoSpec::Get(cargo_type);
src/station_base.h
Show inline comments
 
@@ -26,14 +26,18 @@ static const byte INITIAL_STATION_RATING
 
/**
 
 * Stores station stats for a single cargo.
 
 */
 
struct GoodsEntry {
 
	/** Status of this cargo for the station. */
 
	enum GoodsEntryStatus {
 
		GES_ACCEPTANCE, ///< This cargo is currently being accepted by the station.
 
		GES_PICKUP,     ///< This cargo has been picked up at this station at least once.
 
		GES_ACCEPTANCE,       ///< This cargo is currently being accepted by the station.
 
		GES_PICKUP,           ///< This cargo has been picked up at this station at least once.
 
		GES_EVER_ACCEPTED,    ///< The cargo has been accepted at least once.
 
		GES_LAST_MONTH,       ///< The cargo was accepted last month.
 
		GES_CURRENT_MONTH,    ///< The cargo was accepted this month.
 
		GES_ACCEPTED_BIGTICK, ///< The cargo has been accepted since the last periodic processing.
 
	};
 

	
 
	GoodsEntry() :
 
		acceptance_pickup(0),
 
		days_since_pickup(255),
 
		rating(INITIAL_STATION_RATING),
src/station_cmd.cpp
Show inline comments
 
@@ -2998,12 +2998,19 @@ static bool StationHandleBigTick(BaseSta
 
{
 
	if (!st->IsInUse() && ++st->delete_ctr >= 8) {
 
		delete st;
 
		return false;
 
	}
 

	
 
	if (Station::IsExpected(st)) {
 
		for (CargoID i = 0; i < NUM_CARGO; i++) {
 
			ClrBit(Station::From(st)->goods[i].acceptance_pickup, GoodsEntry::GES_ACCEPTED_BIGTICK);
 
		}
 
	}
 

	
 

	
 
	if ((st->facilities & FACIL_WAYPOINT) == 0) UpdateStationAcceptance(Station::From(st), true);
 

	
 
	return true;
 
}
 

	
 
static inline void byte_inc_sat(byte *p)
 
@@ -3168,15 +3175,24 @@ void OnTick_Station()
 
			TriggerStationAnimation(st, st->xy, SAT_250_TICKS);
 
			if (Station::IsExpected(st)) AirportAnimationTrigger(Station::From(st), AAT_STATION_250_TICKS);
 
		}
 
	}
 
}
 

	
 
/** Monthly loop for stations. */
 
void StationMonthlyLoop()
 
{
 
	/* not used */
 
	Station *st;
 

	
 
	FOR_ALL_STATIONS(st) {
 
		for (CargoID i = 0; i < NUM_CARGO; i++) {
 
			GoodsEntry *ge = &st->goods[i];
 
			SB(ge->acceptance_pickup, GoodsEntry::GES_LAST_MONTH, 1, GB(ge->acceptance_pickup, GoodsEntry::GES_CURRENT_MONTH, 1));
 
			ClrBit(ge->acceptance_pickup, GoodsEntry::GES_CURRENT_MONTH);
 
		}
 
	}
 
}
 

	
 

	
 
void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius)
 
{
 
	Station *st;
0 comments (0 inline, 0 general)