Scale displayed running costs by day length factor

pull/59/head
Jonathan G Rennison 6 years ago
parent aa1a914d96
commit a6a1e67dbc

@ -586,7 +586,7 @@ static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine
/* Running cost */
if (rvi->running_cost_class != INVALID_PRICE) {
SetDParam(0, e->GetRunningCost());
SetDParam(0, e->GetDisplayRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;
}
@ -620,7 +620,7 @@ static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engin
/* Running cost */
if (rvi->running_cost_class != INVALID_PRICE) {
SetDParam(0, e->GetRunningCost());
SetDParam(0, e->GetDisplayRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;
}
@ -674,7 +674,7 @@ static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_n
}
/* Running cost */
SetDParam(0, e->GetRunningCost());
SetDParam(0, e->GetDisplayRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;
@ -717,7 +717,7 @@ static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_numb
y += FONT_HEIGHT_NORMAL;
/* Running cost */
SetDParam(0, e->GetRunningCost());
SetDParam(0, e->GetDisplayRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;
@ -764,7 +764,7 @@ static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_
y += FONT_HEIGHT_NORMAL;
/* Running cost */
SetDParam(0, e->GetRunningCost());
SetDParam(0, e->GetDisplayRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;

@ -30,6 +30,7 @@
#include "company_base.h"
#include "vehicle_func.h"
#include "articulated_vehicles.h"
#include "settings_type.h"
#include "error.h"
#include "table/strings.h"
@ -277,6 +278,15 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const
return capacity;
}
/**
* Return display value of how much the running costs of this engine are.
* @return Yearly running cost of the engine.
*/
Money Engine::GetDisplayRunningCost() const
{
return this->GetRunningCost() * _settings_game.economy.day_length_factor;
}
/**
* Return how much the running costs of this engine are.
* @return Yearly running cost of the engine.

@ -104,6 +104,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
}
Money GetRunningCost() const;
Money GetDisplayRunningCost() const;
Money GetCost() const;
uint GetDisplayMaxSpeed() const;
uint GetPower() const;

@ -174,7 +174,7 @@ static StringID GetTrainEngineInfoString(const Engine *e)
SetDParam(1, e->GetDisplayWeight());
SetDParam(7, e->GetDisplayMaxTractiveEffort());
SetDParam(4, e->GetRunningCost());
SetDParam(4, e->GetDisplayRunningCost());
uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
if (capacity != 0) {
@ -204,10 +204,10 @@ static StringID GetAircraftEngineInfoString(const Engine *e)
if (mail_capacity > 0) {
SetDParam(i++, CT_MAIL);
SetDParam(i++, mail_capacity);
SetDParam(i++, e->GetRunningCost());
SetDParam(i++, e->GetDisplayRunningCost());
return range > 0 ? STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_RANGE_CAP_CAP_RUNCOST : STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_CAP_CAP_RUNCOST;
} else {
SetDParam(i++, e->GetRunningCost());
SetDParam(i++, e->GetDisplayRunningCost());
return range > 0 ? STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_RANGE_CAP_RUNCOST : STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_CAP_RUNCOST;
}
}
@ -224,7 +224,7 @@ static StringID GetRoadVehEngineInfoString(const Engine *e)
} else {
SetDParam(2, CT_INVALID);
}
SetDParam(4, e->GetRunningCost());
SetDParam(4, e->GetDisplayRunningCost());
return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST;
} else {
SetDParam(0, e->GetCost());
@ -233,7 +233,7 @@ static StringID GetRoadVehEngineInfoString(const Engine *e)
SetDParam(1, e->GetDisplayWeight());
SetDParam(7, e->GetDisplayMaxTractiveEffort());
SetDParam(4, e->GetRunningCost());
SetDParam(4, e->GetDisplayRunningCost());
uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
if (capacity != 0) {
@ -252,7 +252,7 @@ static StringID GetShipEngineInfoString(const Engine *e)
SetDParam(1, e->GetDisplayMaxSpeed());
SetDParam(2, e->GetDefaultCargoType());
SetDParam(3, e->GetDisplayDefaultCapacity());
SetDParam(4, e->GetRunningCost());
SetDParam(4, e->GetDisplayRunningCost());
return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST;
}

@ -572,7 +572,7 @@ public:
* Gets the running cost of a vehicle that can be sent into SetDParam for string processing.
* @return the vehicle's running cost
*/
Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8) * _settings_game.economy.day_length_factor; }
/**
* Gets the profit vehicle had this year. It can be sent into SetDParam for string processing.

Loading…
Cancel
Save