equal
deleted
inserted
replaced
133 } |
133 } |
134 |
134 |
135 /* Train sorting functions */ |
135 /* Train sorting functions */ |
136 static int CDECL TrainEngineCostSorter(const void *a, const void *b) |
136 static int CDECL TrainEngineCostSorter(const void *a, const void *b) |
137 { |
137 { |
138 int va = RailVehInfo(*(const EngineID*)a)->base_cost; |
138 int va = RailVehInfo(*(const EngineID*)a)->cost_factor; |
139 int vb = RailVehInfo(*(const EngineID*)b)->base_cost; |
139 int vb = RailVehInfo(*(const EngineID*)b)->cost_factor; |
140 int r = va - vb; |
140 int r = va - vb; |
141 |
141 |
142 return _internal_sort_order ? -r : r; |
142 return _internal_sort_order ? -r : r; |
143 } |
143 } |
144 |
144 |
221 } |
221 } |
222 |
222 |
223 /* Road vehicle sorting functions */ |
223 /* Road vehicle sorting functions */ |
224 static int CDECL RoadVehEngineCostSorter(const void *a, const void *b) |
224 static int CDECL RoadVehEngineCostSorter(const void *a, const void *b) |
225 { |
225 { |
226 int va = RoadVehInfo(*(const EngineID*)a)->base_cost; |
226 int va = RoadVehInfo(*(const EngineID*)a)->cost_factor; |
227 int vb = RoadVehInfo(*(const EngineID*)b)->base_cost; |
227 int vb = RoadVehInfo(*(const EngineID*)b)->cost_factor; |
228 int r = va - vb; |
228 int r = va - vb; |
229 |
229 |
230 return _internal_sort_order ? -r : r; |
230 return _internal_sort_order ? -r : r; |
231 } |
231 } |
232 |
232 |
269 } |
269 } |
270 |
270 |
271 /* Road vehicle sorting functions */ |
271 /* Road vehicle sorting functions */ |
272 static int CDECL ShipEngineCostSorter(const void *a, const void *b) |
272 static int CDECL ShipEngineCostSorter(const void *a, const void *b) |
273 { |
273 { |
274 int va = ShipVehInfo(*(const EngineID*)a)->base_cost; |
274 int va = ShipVehInfo(*(const EngineID*)a)->cost_factor; |
275 int vb = ShipVehInfo(*(const EngineID*)b)->base_cost; |
275 int vb = ShipVehInfo(*(const EngineID*)b)->cost_factor; |
276 int r = va - vb; |
276 int r = va - vb; |
277 |
277 |
278 return _internal_sort_order ? -r : r; |
278 return _internal_sort_order ? -r : r; |
279 } |
279 } |
280 |
280 |
315 |
315 |
316 /* Aircraft sorting functions */ |
316 /* Aircraft sorting functions */ |
317 |
317 |
318 static int CDECL AircraftEngineCostSorter(const void *a, const void *b) |
318 static int CDECL AircraftEngineCostSorter(const void *a, const void *b) |
319 { |
319 { |
320 const int va = AircraftVehInfo(*(const EngineID*)a)->base_cost; |
320 const int va = AircraftVehInfo(*(const EngineID*)a)->cost_factor; |
321 const int vb = AircraftVehInfo(*(const EngineID*)b)->base_cost; |
321 const int vb = AircraftVehInfo(*(const EngineID*)b)->cost_factor; |
322 int r = va - vb; |
322 int r = va - vb; |
323 |
323 |
324 return _internal_sort_order ? -r : r; |
324 return _internal_sort_order ? -r : r; |
325 } |
325 } |
326 |
326 |
484 |
484 |
485 /* Draw rail wagon specific details */ |
485 /* Draw rail wagon specific details */ |
486 static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi) |
486 static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi) |
487 { |
487 { |
488 /* Purchase cost */ |
488 /* Purchase cost */ |
489 SetDParam(0, (GetEngineProperty(engine_number, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8); |
489 SetDParam(0, (GetEngineProperty(engine_number, 0x17, rvi->cost_factor) * _price.build_railwagon) >> 8); |
490 DrawString(x, y, STR_PURCHASE_INFO_COST, TC_FROMSTRING); |
490 DrawString(x, y, STR_PURCHASE_INFO_COST, TC_FROMSTRING); |
491 y += 10; |
491 y += 10; |
492 |
492 |
493 /* Wagon weight - (including cargo) */ |
493 /* Wagon weight - (including cargo) */ |
494 uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight); |
494 uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight); |
522 { |
522 { |
523 int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0); |
523 int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0); |
524 uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight); |
524 uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight); |
525 |
525 |
526 /* Purchase Cost - Engine weight */ |
526 /* Purchase Cost - Engine weight */ |
527 SetDParam(0, GetEngineProperty(engine_number, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5); |
527 SetDParam(0, GetEngineProperty(engine_number, 0x17, rvi->cost_factor) * (_price.build_railvehicle >> 3) >> 5); |
528 SetDParam(1, weight << multihead); |
528 SetDParam(1, weight << multihead); |
529 DrawString(x, y, STR_PURCHASE_INFO_COST_WEIGHT, TC_FROMSTRING); |
529 DrawString(x, y, STR_PURCHASE_INFO_COST_WEIGHT, TC_FROMSTRING); |
530 y += 10; |
530 y += 10; |
531 |
531 |
532 /* Max speed - Engine power */ |
532 /* Max speed - Engine power */ |
564 static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const RoadVehicleInfo *rvi) |
564 static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const RoadVehicleInfo *rvi) |
565 { |
565 { |
566 bool refittable = (EngInfo(engine_number)->refit_mask != 0); |
566 bool refittable = (EngInfo(engine_number)->refit_mask != 0); |
567 |
567 |
568 /* Purchase cost - Max speed */ |
568 /* Purchase cost - Max speed */ |
569 SetDParam(0, GetEngineProperty(engine_number, 0x11, rvi->base_cost) * (_price.roadveh_base >> 3) >> 5); |
569 SetDParam(0, GetEngineProperty(engine_number, 0x11, rvi->cost_factor) * (_price.roadveh_base >> 3) >> 5); |
570 SetDParam(1, rvi->max_speed * 10 / 32); |
570 SetDParam(1, rvi->max_speed * 10 / 32); |
571 DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING); |
571 DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING); |
572 y += 10; |
572 y += 10; |
573 |
573 |
574 /* Running cost */ |
574 /* Running cost */ |
582 |
582 |
583 /* Draw ship specific details */ |
583 /* Draw ship specific details */ |
584 static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi) |
584 static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi) |
585 { |
585 { |
586 /* Purchase cost - Max speed */ |
586 /* Purchase cost - Max speed */ |
587 SetDParam(0, GetEngineProperty(engine_number, 0x0A, svi->base_cost) * (_price.ship_base >> 3) >> 5); |
587 SetDParam(0, GetEngineProperty(engine_number, 0x0A, svi->cost_factor) * (_price.ship_base >> 3) >> 5); |
588 SetDParam(1, GetEngineProperty(engine_number, 0x0B, svi->max_speed) * 10 / 32); |
588 SetDParam(1, GetEngineProperty(engine_number, 0x0B, svi->max_speed) * 10 / 32); |
589 DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING); |
589 DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING); |
590 y += 10; |
590 y += 10; |
591 |
591 |
592 /* Cargo type + capacity */ |
592 /* Cargo type + capacity */ |
608 static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const AircraftVehicleInfo *avi) |
608 static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const AircraftVehicleInfo *avi) |
609 { |
609 { |
610 CargoID cargo; |
610 CargoID cargo; |
611 |
611 |
612 /* Purchase cost - Max speed */ |
612 /* Purchase cost - Max speed */ |
613 SetDParam(0, GetEngineProperty(engine_number, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5); |
613 SetDParam(0, GetEngineProperty(engine_number, 0x0B, avi->cost_factor) * (_price.aircraft_base >> 3) >> 5); |
614 SetDParam(1, avi->max_speed * 10 / 16); |
614 SetDParam(1, avi->max_speed * 10 / 16); |
615 DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING); |
615 DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING); |
616 y += 10; |
616 y += 10; |
617 |
617 |
618 /* Cargo capacity */ |
618 /* Cargo capacity */ |