35 #include "table/strings.h"
56 lengthof(_orig_aircraft_vehicle_info),
82 this->list_position = base;
86 if (base >= _engine_counts[type]) {
90 if (type ==
VEH_ROAD) this->u.road.tractive_effort = 0x4C;
110 default: NOT_REACHED();
113 this->u.rail = _orig_rail_vehicle_info[base];
115 this->info.
string_id = STR_VEHICLE_NAME_TRAIN_ENGINE_RAIL_KIRBY_PAUL_TANK_STEAM + base;
123 this->u.road = _orig_road_vehicle_info[base];
125 this->info.
string_id = STR_VEHICLE_NAME_ROAD_VEHICLE_MPS_REGAL_BUS + base;
129 this->u.ship = _orig_ship_vehicle_info[base];
131 this->info.
string_id = STR_VEHICLE_NAME_SHIP_MPS_OIL_TANKER + base;
135 this->u.air = _orig_aircraft_vehicle_info[base];
137 this->info.
string_id = STR_VEHICLE_NAME_AIRCRAFT_SAMPSON_U52 + base;
165 return file == NULL ? 0 : file->grfid;
180 switch (this->type) {
182 if (this->u.rail.capacity == 0)
return false;
186 if (this->u.road.capacity == 0)
return false;
193 default: NOT_REACHED();
209 if (mail_capacity != NULL) *mail_capacity = 0;
223 (new_multipliers || default_cargo != cargo_type || (v != NULL && v->
cargo_subtype != 0))) {
230 uint extra_mail_cap = 0;
231 switch (this->type) {
236 if (v == NULL && this->u.rail.railveh_type ==
RAILVEH_MULTIHEAD) capacity += this->u.rail.capacity;
252 if (!new_multipliers && cargo_type == CT_MAIL)
return capacity + extra_mail_cap;
253 default_cargo = CT_PASSENGERS;
256 default: NOT_REACHED();
259 if (!new_multipliers) {
261 capacity += extra_mail_cap;
266 if (new_multipliers || (this->type !=
VEH_SHIP && default_cargo != cargo_type)) {
267 uint16 default_multiplier = new_multipliers ? 0x100 :
CargoSpec::Get(default_cargo)->multiplier;
269 capacity *= cargo_multiplier;
270 if (extra_mail_cap > 0) {
272 capacity += (default_multiplier * extra_mail_cap * cargo_multiplier + mail_multiplier / 2) / mail_multiplier;
274 capacity = (capacity + default_multiplier / 2) / default_multiplier;
288 switch (this->type) {
290 base_price = this->u.road.running_cost_class;
291 if (base_price == INVALID_PRICE)
return 0;
296 base_price = this->u.rail.running_cost_class;
297 if (base_price == INVALID_PRICE)
return 0;
302 base_price = PR_RUNNING_SHIP;
307 base_price = PR_RUNNING_AIRCRAFT;
311 default: NOT_REACHED();
325 switch (this->type) {
327 base_price = PR_BUILD_VEHICLE_ROAD;
333 base_price = PR_BUILD_VEHICLE_WAGON;
336 base_price = PR_BUILD_VEHICLE_TRAIN;
342 base_price = PR_BUILD_VEHICLE_SHIP;
347 base_price = PR_BUILD_VEHICLE_AIRCRAFT;
351 default: NOT_REACHED();
363 switch (this->type) {
369 return (max_speed != 0) ? max_speed * 2 : this->u.road.max_speed / 2;
377 if (max_speed != 0) {
378 return (max_speed * 128) / 10;
380 return this->u.air.max_speed;
383 default: NOT_REACHED();
396 switch (this->type) {
402 default: NOT_REACHED();
414 switch (this->type) {
420 default: NOT_REACHED();
432 switch (this->type) {
438 default: NOT_REACHED();
458 switch (this->type) {
462 default: NOT_REACHED();
473 for (uint internal_id = 0; internal_id < _engine_counts[type]; internal_id++) {
476 eid->
grfid = INVALID_GRFID;
497 if (eid->type == type && eid->grfid == grfid && eid->internal_id == grf_local_id) {
538 const Engine *e =
new Engine(eid->type, eid->internal_id);
539 assert(e->
index == index);
543 void ShowEnginePreviewWindow(
EngineID engine);
568 if (retire_early != 0 && age >= retire_early_max_age) {
575 if (age < e->duration_phase_1) {
681 FOR_ALL_COMPANIES(c) {
738 int32 best_hist = -1;
740 FOR_ALL_COMPANIES(c) {
751 best_company = c->
index;
775 default: NOT_REACHED();
783 FOR_ALL_COMPANIES(c) {
889 FOR_ALL_COMPANIES(c) {
921 RailType railtype = e->u.rail.railtype;
996 if (e->
name != NULL && strcmp(e->
name, name) == 0)
return false;
1052 if (e == NULL)
return false;
1055 if (e->
type != type)
return false;
1088 if (e == NULL)
return false;
1093 if (ei->refit_mask == 0)
return false;
1101 return default_cargo !=
CT_INVALID && ei->refit_mask != 1U << default_cargo;
1110 Date min_date = INT32_MAX;
1112 FOR_ALL_ENGINES(e) {
1122 if (min_date < INT32_MAX) {