From 778e92cf549a344462b8b6492a8966069e75ad46 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 28 Jun 2009 14:33:10 +0000 Subject: (svn r16681) -Codechange: only resolve the company once for vehicle payment instead of each time a cargo packet is delivered --- src/economy.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/economy.cpp') diff --git a/src/economy.cpp b/src/economy.cpp index 46b8ac90b..d717b3cff 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -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 days_in_transit Travel time * @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 */ -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; assert(num_pieces > 0); /* Update company statistics */ - { - Company *c = Company::Get(_current_company); - c->cur_economy.delivered_cargo += num_pieces; - SetBit(c->cargo_types, cargo_type); - } + company->cur_economy.delivered_cargo += num_pieces; + SetBit(company->cargo_types, cargo_type); const Station *s_to = Station::Get(dest); @@ -1157,6 +1155,7 @@ void VehiclePayment(Vehicle *front_v) StationID last_visited = front_v->last_station_visited; Station *st = Station::Get(last_visited); + Company *company = Company::Get(front_v->owner); /* The owner of the train wants to be paid */ CompanyID old_company = _current_company; @@ -1195,7 +1194,7 @@ void VehiclePayment(Vehicle *front_v) st->time_since_unload = 0; /* 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; 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 -- cgit v1.2.3-70-g09d2