Skip to content

Instantly share code, notes, and snippets.

@andythenorth
Last active April 5, 2021 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andythenorth/1b3fa6c44d3b9a2790fae202e846d147 to your computer and use it in GitHub Desktop.
Save andythenorth/1b3fa6c44d3b9a2790fae202e846d147 to your computer and use it in GitHub Desktop.
diff --git a/src/economy.cpp b/src/economy.cpp
index 716446ba9e..1ff14d85f0 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -963,7 +963,7 @@ Money GetPrice(Price index, uint cost_factor, const GRFFile *grf_file, int shift
return cost;
}
-Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type)
+Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type, uint multiplier)
{
const CargoSpec *cs = CargoSpec::Get(cargo_type);
if (!cs->IsValid()) {
@@ -1008,7 +1008,7 @@ Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, C
*/
const int time_factor = std::max(MAX_TIME_FACTOR - days_over_days1 - days_over_days2, MIN_TIME_FACTOR);
- return BigMulS(dist * time_factor * num_pieces, cs->current_payment, 21);
+ return BigMulS(dist * time_factor * num_pieces, multiplier * cs->current_payment, 21);
}
/** The industries we've currently brought cargo to. */
@@ -1108,7 +1108,8 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
st->town->received[cs->town_effect].new_act += accepted_total;
/* Determine profit */
- Money profit = GetTransportedGoodsIncome(accepted_total, DistanceManhattan(source_tile, st->xy), days_in_transit, cargo_type);
+ uint multiplier = 2;
+ Money profit = GetTransportedGoodsIncome(accepted_total, DistanceManhattan(source_tile, st->xy), days_in_transit, cargo_type, multiplier);
/* Update the cargo monitor. */
AddCargoDelivery(cargo_type, company->index, accepted_total - accepted_ind, src_type, src, st);
@@ -1226,13 +1227,15 @@ void CargoPayment::PayFinalDelivery(const CargoPacket *cp, uint count)
*/
Money CargoPayment::PayTransfer(const CargoPacket *cp, uint count)
{
+ uint multiplier = 2;
Money profit = -cp->FeederShare(count) + GetTransportedGoodsIncome(
count,
/* pay transfer vehicle the difference between the payment for the journey from
* the source to the current point, and the sum of the previous transfer payments */
DistanceManhattan(cp->SourceStationXY(), Station::Get(this->current_station)->xy),
cp->DaysInTransit(),
- this->ct);
+ this->ct,
+ multiplier);
profit = profit * _settings_game.economy.feeder_payment_share / 100;
diff --git a/src/economy_func.h b/src/economy_func.h
index 69980b4758..94450c018e 100644
--- a/src/economy_func.h
+++ b/src/economy_func.h
@@ -28,7 +28,7 @@ extern Prices _price;
int UpdateCompanyRatingAndValue(Company *c, bool update);
void StartupIndustryDailyChanges(bool init_counter);
-Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type);
+Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type, uint multiplier);
uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations, Owner exclusivity = INVALID_OWNER);
void PrepareUnload(Vehicle *front_v);
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 5b04592bff..33cea3958e 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -1039,7 +1039,8 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
this->colours[i] = cs->legend_colour;
for (uint j = 0; j != 20; j++) {
- this->cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 4 + 4, cs->Index());
+ uint multiplier = 2;
+ this->cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 4 + 4, cs->Index(), multiplier);
}
i++;
}
diff --git a/src/script/api/script_cargo.cpp b/src/script/api/script_cargo.cpp
index 5e092b52a0..5870c87497 100644
--- a/src/script/api/script_cargo.cpp
+++ b/src/script/api/script_cargo.cpp
@@ -73,7 +73,7 @@
/* static */ Money ScriptCargo::GetCargoIncome(CargoID cargo_type, uint32 distance, uint32 days_in_transit)
{
if (!IsValidCargo(cargo_type)) return -1;
- return ::GetTransportedGoodsIncome(1, distance, Clamp(days_in_transit * 2 / 5, 0, 255), cargo_type);
+ return ::GetTransportedGoodsIncome(1, distance, Clamp(days_in_transit * 2 / 5, 0, 255), cargo_type, 1);
}
/* static */ ScriptCargo::DistributionType ScriptCargo::GetDistributionType(CargoID cargo_type)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment