mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
(svn r16681) -Codechange: only resolve the company once for vehicle payment instead of each time a cargo packet is delivered
This commit is contained in:
parent
eb4380f5ea
commit
778e92cf54
@ -1060,20 +1060,18 @@ static void DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, int nu
|
|||||||
* @param source_tile The origin of the cargo for distance calculation
|
* @param source_tile The origin of the cargo for distance calculation
|
||||||
* @param days_in_transit Travel time
|
* @param days_in_transit Travel time
|
||||||
* @param industry_set The delivered industry will be inserted into this set, if not yet contained
|
* @param industry_set The delivered industry will be inserted into this set, if not yet contained
|
||||||
|
* @param company The company delivering the cargo
|
||||||
* The cargo is just added to the stockpile of the industry. It is due to the caller to trigger the industry's production machinery
|
* 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 source, StationID dest, TileIndex source_tile, byte days_in_transit, SmallIndustryList *industry_set)
|
static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID source, StationID dest, TileIndex source_tile, byte days_in_transit, SmallIndustryList *industry_set, Company *company)
|
||||||
{
|
{
|
||||||
bool subsidised = false;
|
bool subsidised = false;
|
||||||
|
|
||||||
assert(num_pieces > 0);
|
assert(num_pieces > 0);
|
||||||
|
|
||||||
/* Update company statistics */
|
/* Update company statistics */
|
||||||
{
|
company->cur_economy.delivered_cargo += num_pieces;
|
||||||
Company *c = Company::Get(_current_company);
|
SetBit(company->cargo_types, cargo_type);
|
||||||
c->cur_economy.delivered_cargo += num_pieces;
|
|
||||||
SetBit(c->cargo_types, cargo_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Station *s_to = Station::Get(dest);
|
const Station *s_to = Station::Get(dest);
|
||||||
|
|
||||||
@ -1157,6 +1155,7 @@ void VehiclePayment(Vehicle *front_v)
|
|||||||
|
|
||||||
StationID last_visited = front_v->last_station_visited;
|
StationID last_visited = front_v->last_station_visited;
|
||||||
Station *st = Station::Get(last_visited);
|
Station *st = Station::Get(last_visited);
|
||||||
|
Company *company = Company::Get(front_v->owner);
|
||||||
|
|
||||||
/* The owner of the train wants to be paid */
|
/* The owner of the train wants to be paid */
|
||||||
CompanyID old_company = _current_company;
|
CompanyID old_company = _current_company;
|
||||||
@ -1195,7 +1194,7 @@ void VehiclePayment(Vehicle *front_v)
|
|||||||
st->time_since_unload = 0;
|
st->time_since_unload = 0;
|
||||||
|
|
||||||
/* handle end of route payment */
|
/* handle end of route payment */
|
||||||
Money profit = DeliverGoods(cp->count, v->cargo_type, cp->source, last_visited, cp->source_xy, cp->days_in_transit, &industry_set);
|
Money profit = DeliverGoods(cp->count, v->cargo_type, cp->source, last_visited, cp->source_xy, cp->days_in_transit, &industry_set, company);
|
||||||
cp->paid_for = true;
|
cp->paid_for = true;
|
||||||
route_profit += profit; // display amount paid for final route delivery, A-D of a chain A-B-C-D
|
route_profit += profit; // display amount paid for final route delivery, A-D of a chain A-B-C-D
|
||||||
vehicle_profit += profit - cp->feeder_share; // whole vehicle is not payed for transfers picked up earlier
|
vehicle_profit += profit - cp->feeder_share; // whole vehicle is not payed for transfers picked up earlier
|
||||||
|
Loading…
Reference in New Issue
Block a user