|
@@ -824,25 +824,25 @@ void StartupEconomy()
|
|
|
_economy.fluct = GB(Random(), 0, 8) + 168;
|
|
|
|
|
|
StartupIndustryDailyChanges(true); // As we are starting a new game, initialize the counter too
|
|
|
|
|
|
}
|
|
|
|
|
|
void ResetEconomy()
|
|
|
{
|
|
|
/* Test if resetting the economy is needed. */
|
|
|
bool needed = false;
|
|
|
|
|
|
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
|
|
const CargoSpec *cs = GetCargo(c);
|
|
|
const CargoSpec *cs = CargoSpec::Get(c);
|
|
|
if (!cs->IsValid()) continue;
|
|
|
if (_cargo_payment_rates[c] == 0) {
|
|
|
needed = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!needed) return;
|
|
|
|
|
|
/* Remember old unrounded maximum loan value. NewGRF has the ability
|
|
|
* to change all the other inflation affected base costs. */
|
|
|
Money old_value = _economy.max_loan_unround;
|
|
@@ -857,25 +857,25 @@ void ResetEconomy()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Money GetPriceByIndex(uint8 index)
|
|
|
{
|
|
|
if (index > NUM_PRICES) return 0;
|
|
|
|
|
|
return ((Money*)&_price)[index];
|
|
|
}
|
|
|
|
|
|
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type)
|
|
|
{
|
|
|
const CargoSpec *cs = GetCargo(cargo_type);
|
|
|
const CargoSpec *cs = CargoSpec::Get(cargo_type);
|
|
|
|
|
|
/* Use callback to calculate cargo profit, if available */
|
|
|
if (HasBit(cs->callback_mask, CBM_CARGO_PROFIT_CALC)) {
|
|
|
uint32 var18 = min(dist, 0xFFFF) | (min(num_pieces, 0xFF) << 16) | (transit_days << 24);
|
|
|
uint16 callback = GetCargoCallback(CBID_CARGO_PROFIT_CALC, 0, var18, cs);
|
|
|
if (callback != CALLBACK_FAILED) {
|
|
|
int result = GB(callback, 0, 14);
|
|
|
|
|
|
/* Simulate a 15 bit signed value */
|
|
|
if (HasBit(callback, 14)) result = 0x4000 - result;
|
|
|
|
|
|
/* "The result should be a signed multiplier that gets multiplied
|
|
@@ -1080,25 +1080,25 @@ static Money DeliverGoods(int num_pieces
|
|
|
SetBit(company->cargo_types, cargo_type);
|
|
|
|
|
|
const Station *s_to = Station::Get(dest);
|
|
|
|
|
|
if (source != INVALID_STATION) {
|
|
|
const Station *s_from = Station::Get(source);
|
|
|
|
|
|
/* Check if a subsidy applies. */
|
|
|
subsidised = CheckSubsidised(s_from, s_to, cargo_type, company->index);
|
|
|
}
|
|
|
|
|
|
/* Increase town's counter for some special goods types */
|
|
|
const CargoSpec *cs = GetCargo(cargo_type);
|
|
|
const CargoSpec *cs = CargoSpec::Get(cargo_type);
|
|
|
if (cs->town_effect == TE_FOOD) s_to->town->new_act_food += num_pieces;
|
|
|
if (cs->town_effect == TE_WATER) s_to->town->new_act_water += num_pieces;
|
|
|
|
|
|
/* Give the goods to the industry. */
|
|
|
DeliverGoodsToIndustry(s_to, cargo_type, num_pieces);
|
|
|
|
|
|
/* Determine profit */
|
|
|
Money profit = GetTransportedGoodsIncome(num_pieces, DistanceManhattan(source_tile, s_to->xy), days_in_transit, cargo_type);
|
|
|
|
|
|
/* Modify profit if a subsidy is in effect */
|
|
|
if (subsidised) {
|
|
|
switch (_settings_game.difficulty.subsidy_multiplier) {
|