Merge branch 'master' into jgrpp

# Conflicts:
#	Makefile.src.in
#	findversion.sh
#	projects/determineversion.vbs
#	src/aircraft_cmd.cpp
#	src/lang/dutch.txt
#	src/linkgraph/linkgraph_gui.cpp
#	src/linkgraph/linkgraph_gui.h
#	src/order_cmd.cpp
#	src/settings_gui.cpp
#	src/smallmap_gui.cpp
#	src/town_cmd.cpp
#	src/viewport.cpp
#	src/water_map.h
This commit is contained in:
Jonathan G Rennison
2019-03-04 00:51:24 +00:00
178 changed files with 1894 additions and 866 deletions

View File

@@ -1062,9 +1062,10 @@ static SmallIndustryList _cargo_delivery_destinations;
* @param cargo_type Type of cargo delivered
* @param num_pieces Amount of cargo delivered
* @param source The source of the cargo
* @param company The company delivering the cargo
* @return actually accepted pieces of cargo
*/
static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint num_pieces, IndustryID source)
static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint num_pieces, IndustryID source, CompanyID company)
{
/* Find the nearest industrytile to the station sign inside the catchment area, whose industry accepts the cargo.
* This fails in three cases:
@@ -1097,6 +1098,9 @@ static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint n
ind->last_cargo_accepted_at[cargo_index] = _date;
num_pieces -= amount;
accepted += amount;
/* Update the cargo monitor. */
AddCargoDelivery(cargo_type, company, amount, ST_INDUSTRY, source, st, ind->index);
}
return accepted;
@@ -1122,30 +1126,30 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
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);
uint accepted_ind = DeliverGoodsToIndustry(st, cargo_type, num_pieces, src_type == ST_INDUSTRY ? src : INVALID_INDUSTRY, company->index);
/* If this cargo type is always accepted, accept all */
if (HasBit(st->always_accepted, cargo_type)) accepted = num_pieces;
uint accepted_total = HasBit(st->always_accepted, cargo_type) ? num_pieces : accepted_ind;
/* Update station statistics */
if (accepted > 0) {
if (accepted_total > 0) {
SetBit(st->goods[cargo_type].status, GoodsEntry::GES_EVER_ACCEPTED);
SetBit(st->goods[cargo_type].status, GoodsEntry::GES_CURRENT_MONTH);
SetBit(st->goods[cargo_type].status, GoodsEntry::GES_ACCEPTED_BIGTICK);
}
/* Update company statistics */
company->cur_economy.delivered_cargo[cargo_type] += accepted;
company->cur_economy.delivered_cargo[cargo_type] += accepted_total;
/* Increase town's counter for town effects */
const CargoSpec *cs = CargoSpec::Get(cargo_type);
st->town->received[cs->town_effect].new_act += accepted;
st->town->received[cs->town_effect].new_act += accepted_total;
/* Determine profit */
Money profit = GetTransportedGoodsIncome(accepted, DistanceManhattan(source_tile, st->xy), days_in_transit, cargo_type);
Money profit = GetTransportedGoodsIncome(accepted_total, DistanceManhattan(source_tile, st->xy), days_in_transit, cargo_type);
/* Update the cargo monitor. */
AddCargoDelivery(cargo_type, company->index, accepted, src_type, src, st);
AddCargoDelivery(cargo_type, company->index, accepted_total - accepted_ind, src_type, src, st);
/* Modify profit if a subsidy is in effect */
if (CheckSubsidised(cargo_type, company->index, src_type, src, st)) {