mirror of https://github.com/OpenTTD/OpenTTD
(svn r22542) -Add: Store cargo acceptance stats for stations.
parent
9f68c20d10
commit
8e00fa39b2
|
@ -933,7 +933,7 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
|
||||||
{
|
{
|
||||||
assert(num_pieces > 0);
|
assert(num_pieces > 0);
|
||||||
|
|
||||||
const Station *st = Station::Get(dest);
|
Station *st = Station::Get(dest);
|
||||||
|
|
||||||
/* Give the goods to the industry. */
|
/* Give the goods to the industry. */
|
||||||
uint accepted = DeliverGoodsToIndustry(st, cargo_type, num_pieces, src_type == ST_INDUSTRY ? src : INVALID_INDUSTRY);
|
uint accepted = DeliverGoodsToIndustry(st, cargo_type, num_pieces, src_type == ST_INDUSTRY ? src : INVALID_INDUSTRY);
|
||||||
|
@ -941,6 +941,13 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
|
||||||
/* If this cargo type is always accepted, accept all */
|
/* If this cargo type is always accepted, accept all */
|
||||||
if (HasBit(st->always_accepted, cargo_type)) accepted = num_pieces;
|
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 */
|
/* Update company statistics */
|
||||||
company->cur_economy.delivered_cargo += accepted;
|
company->cur_economy.delivered_cargo += accepted;
|
||||||
if (accepted > 0) SetBit(company->cargo_types, cargo_type);
|
if (accepted > 0) SetBit(company->cargo_types, cargo_type);
|
||||||
|
|
|
@ -31,6 +31,10 @@ struct GoodsEntry {
|
||||||
enum GoodsEntryStatus {
|
enum GoodsEntryStatus {
|
||||||
GES_ACCEPTANCE, ///< This cargo is currently being accepted by the station.
|
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_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() :
|
GoodsEntry() :
|
||||||
|
|
|
@ -3001,6 +3001,13 @@ static bool StationHandleBigTick(BaseStation *st)
|
||||||
return false;
|
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);
|
if ((st->facilities & FACIL_WAYPOINT) == 0) UpdateStationAcceptance(Station::From(st), true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -3171,9 +3178,18 @@ void OnTick_Station()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Monthly loop for stations. */
|
||||||
void StationMonthlyLoop()
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue