|
|
|
@ -165,11 +165,8 @@ static int CDECL TrainEnginePowerSorter(const void *a, const void *b)
|
|
|
|
|
|
|
|
|
|
static int CDECL TrainEngineRunningCostSorter(const void *a, const void *b)
|
|
|
|
|
{
|
|
|
|
|
const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a);
|
|
|
|
|
const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b);
|
|
|
|
|
|
|
|
|
|
Money va = rvi_a->running_cost * GetPriceByIndex(rvi_a->running_cost_class);
|
|
|
|
|
Money vb = rvi_b->running_cost * GetPriceByIndex(rvi_b->running_cost_class);
|
|
|
|
|
Money va = GetEngine(*(const EngineID*)a)->GetRunningCost();
|
|
|
|
|
Money vb = GetEngine(*(const EngineID*)b)->GetRunningCost();
|
|
|
|
|
int r = ClampToI32(va - vb);
|
|
|
|
|
|
|
|
|
|
return _internal_sort_order ? -r : r;
|
|
|
|
@ -186,8 +183,8 @@ static int CDECL TrainEnginePowerVsRunningCostSorter(const void *a, const void *
|
|
|
|
|
* Because of this, the return value have to be reversed as well and we return b - a instead of a - b.
|
|
|
|
|
* Another thing is that both power and running costs should be doubled for multiheaded engines.
|
|
|
|
|
* Since it would be multipling with 2 in both numerator and denumerator, it will even themselves out and we skip checking for multiheaded. */
|
|
|
|
|
Money va = (rvi_a->running_cost * GetPriceByIndex(rvi_a->running_cost_class)) / max(1U, (uint)rvi_a->power);
|
|
|
|
|
Money vb = (rvi_b->running_cost * GetPriceByIndex(rvi_b->running_cost_class)) / max(1U, (uint)rvi_b->power);
|
|
|
|
|
Money va = (GetEngine(*(const EngineID*)a)->GetRunningCost()) / max(1U, (uint)rvi_a->power);
|
|
|
|
|
Money vb = (GetEngine(*(const EngineID*)b)->GetRunningCost()) / max(1U, (uint)rvi_b->power);
|
|
|
|
|
int r = ClampToI32(vb - va);
|
|
|
|
|
|
|
|
|
|
return _internal_sort_order ? -r : r;
|
|
|
|
@ -244,11 +241,8 @@ static int CDECL RoadVehEngineSpeedSorter(const void *a, const void *b)
|
|
|
|
|
|
|
|
|
|
static int CDECL RoadVehEngineRunningCostSorter(const void *a, const void *b)
|
|
|
|
|
{
|
|
|
|
|
const RoadVehicleInfo *rvi_a = RoadVehInfo(*(const EngineID*)a);
|
|
|
|
|
const RoadVehicleInfo *rvi_b = RoadVehInfo(*(const EngineID*)b);
|
|
|
|
|
|
|
|
|
|
Money va = rvi_a->running_cost * GetPriceByIndex(rvi_a->running_cost_class);
|
|
|
|
|
Money vb = rvi_b->running_cost * GetPriceByIndex(rvi_b->running_cost_class);
|
|
|
|
|
Money va = GetEngine(*(const EngineID*)a)->GetRunningCost();
|
|
|
|
|
Money vb = GetEngine(*(const EngineID*)b)->GetRunningCost();
|
|
|
|
|
int r = ClampToI32(va - vb);
|
|
|
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
@ -292,8 +286,8 @@ static int CDECL ShipEngineSpeedSorter(const void *a, const void *b)
|
|
|
|
|
|
|
|
|
|
static int CDECL ShipEngineRunningCostSorter(const void *a, const void *b)
|
|
|
|
|
{
|
|
|
|
|
const int va = ShipVehInfo(*(const EngineID*)a)->running_cost;
|
|
|
|
|
const int vb = ShipVehInfo(*(const EngineID*)b)->running_cost;
|
|
|
|
|
const int va = GetEngine(*(const EngineID*)a)->GetRunningCost();
|
|
|
|
|
const int vb = GetEngine(*(const EngineID*)b)->GetRunningCost();
|
|
|
|
|
const int r = va - vb;
|
|
|
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
@ -342,8 +336,8 @@ static int CDECL AircraftEngineSpeedSorter(const void *a, const void *b)
|
|
|
|
|
|
|
|
|
|
static int CDECL AircraftEngineRunningCostSorter(const void *a, const void *b)
|
|
|
|
|
{
|
|
|
|
|
const int va = AircraftVehInfo(*(const EngineID*)a)->running_cost;
|
|
|
|
|
const int vb = AircraftVehInfo(*(const EngineID*)b)->running_cost;
|
|
|
|
|
const int va = GetEngine(*(const EngineID*)a)->GetRunningCost();
|
|
|
|
|
const int vb = GetEngine(*(const EngineID*)b)->GetRunningCost();
|
|
|
|
|
const int r = va - vb;
|
|
|
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
@ -512,7 +506,7 @@ static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const
|
|
|
|
|
|
|
|
|
|
/* Running cost */
|
|
|
|
|
if (rvi->running_cost_class != 0xFF) {
|
|
|
|
|
SetDParam(0, GetEngineProperty(engine_number, 0x0D, rvi->running_cost) * GetPriceByIndex(rvi->running_cost_class) >> 8);
|
|
|
|
|
SetDParam(0, GetEngine(engine_number)->GetRunningCost());
|
|
|
|
|
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
|
|
|
|
|
y += 10;
|
|
|
|
|
}
|
|
|
|
@ -547,7 +541,7 @@ static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, cons
|
|
|
|
|
|
|
|
|
|
/* Running cost */
|
|
|
|
|
if (rvi->running_cost_class != 0xFF) {
|
|
|
|
|
SetDParam(0, GetEngineProperty(engine_number, 0x0D, rvi->running_cost) * GetPriceByIndex(rvi->running_cost_class) >> 8);
|
|
|
|
|
SetDParam(0, GetEngine(engine_number)->GetRunningCost());
|
|
|
|
|
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
|
|
|
|
|
y += 10;
|
|
|
|
|
}
|
|
|
|
@ -573,7 +567,7 @@ static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const R
|
|
|
|
|
y += 10;
|
|
|
|
|
|
|
|
|
|
/* Running cost */
|
|
|
|
|
SetDParam(0, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) >> 8);
|
|
|
|
|
SetDParam(0, GetEngine(engine_number)->GetRunningCost());
|
|
|
|
|
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
|
|
|
|
|
y += 10;
|
|
|
|
|
|
|
|
|
@ -598,7 +592,7 @@ static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const Ship
|
|
|
|
|
y += 10;
|
|
|
|
|
|
|
|
|
|
/* Running cost */
|
|
|
|
|
SetDParam(0, GetEngineProperty(engine_number, 0x0F, svi->running_cost) * _price.ship_running >> 8);
|
|
|
|
|
SetDParam(0, GetEngine(engine_number)->GetRunningCost());
|
|
|
|
|
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
|
|
|
|
|
y += 10;
|
|
|
|
|
|
|
|
|
@ -633,7 +627,7 @@ static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const
|
|
|
|
|
y += 10;
|
|
|
|
|
|
|
|
|
|
/* Running cost */
|
|
|
|
|
SetDParam(0, GetEngineProperty(engine_number, 0x0E, avi->running_cost) * _price.aircraft_running >> 8);
|
|
|
|
|
SetDParam(0, GetEngine(engine_number)->GetRunningCost());
|
|
|
|
|
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
|
|
|
|
|
y += 10;
|
|
|
|
|
|
|
|
|
|