Scale displayed running costs by day length factor

This commit is contained in:
Jonathan G Rennison
2018-01-25 18:23:15 +00:00
parent aa1a914d96
commit a6a1e67dbc
5 changed files with 23 additions and 12 deletions

View File

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

View File

@@ -30,6 +30,7 @@
#include "company_base.h" #include "company_base.h"
#include "vehicle_func.h" #include "vehicle_func.h"
#include "articulated_vehicles.h" #include "articulated_vehicles.h"
#include "settings_type.h"
#include "error.h" #include "error.h"
#include "table/strings.h" #include "table/strings.h"
@@ -277,6 +278,15 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const
return capacity; 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 how much the running costs of this engine are.
* @return Yearly running cost of the engine. * @return Yearly running cost of the engine.

View File

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

View File

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

View File

@@ -572,7 +572,7 @@ public:
* Gets the running cost of a vehicle that can be sent into SetDParam for string processing. * Gets the running cost of a vehicle that can be sent into SetDParam for string processing.
* @return the vehicle's running cost * @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. * Gets the profit vehicle had this year. It can be sent into SetDParam for string processing.