diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index d338ce7e0f..8d200fef60 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -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; diff --git a/src/engine.cpp b/src/engine.cpp index b0af3bc4df..11440a21ea 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -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. diff --git a/src/engine_base.h b/src/engine_base.h index 25c6bfbeb9..0c327eebe0 100644 --- a/src/engine_base.h +++ b/src/engine_base.h @@ -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; diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index 2808d4e676..c9989e17d1 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -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; } diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 6477e1654b..7c34c7e738 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -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.