35 #include "table/strings.h"
61 lengthof(_orig_aircraft_vehicle_info),
87 this->list_position = base;
90 if (base >= _engine_counts[type]) {
94 if (type ==
VEH_ROAD) this->u.road.tractive_effort = 0x4C;
114 default: NOT_REACHED();
117 this->u.rail = _orig_rail_vehicle_info[base];
119 this->info.
string_id = STR_VEHICLE_NAME_TRAIN_ENGINE_RAIL_KIRBY_PAUL_TANK_STEAM + base;
127 this->u.road = _orig_road_vehicle_info[base];
129 this->info.
string_id = STR_VEHICLE_NAME_ROAD_VEHICLE_MPS_REGAL_BUS + base;
133 this->u.ship = _orig_ship_vehicle_info[base];
135 this->info.
string_id = STR_VEHICLE_NAME_SHIP_MPS_OIL_TANKER + base;
139 this->u.air = _orig_aircraft_vehicle_info[base];
141 this->info.
string_id = STR_VEHICLE_NAME_AIRCRAFT_SAMPSON_U52 + base;
169 return file == NULL ? 0 : file->grfid;
184 switch (this->type) {
186 if (this->u.rail.capacity == 0)
return false;
190 if (this->u.road.capacity == 0)
return false;
197 default: NOT_REACHED();
213 if (mail_capacity != NULL) *mail_capacity = 0;
227 (new_multipliers || default_cargo != cargo_type || (v != NULL && v->
cargo_subtype != 0))) {
234 uint extra_mail_cap = 0;
235 switch (this->type) {
240 if (v == NULL && this->u.rail.railveh_type ==
RAILVEH_MULTIHEAD) capacity += this->u.rail.capacity;
256 if (!new_multipliers && cargo_type == CT_MAIL)
return capacity + extra_mail_cap;
257 default_cargo = CT_PASSENGERS;
260 default: NOT_REACHED();
263 if (!new_multipliers) {
265 capacity += extra_mail_cap;
270 if (new_multipliers || (this->type !=
VEH_SHIP && default_cargo != cargo_type)) {
271 uint16 default_multiplier = new_multipliers ? 0x100 :
CargoSpec::Get(default_cargo)->multiplier;
273 capacity *= cargo_multiplier;
274 if (extra_mail_cap > 0) {
276 capacity += (default_multiplier * extra_mail_cap * cargo_multiplier + mail_multiplier / 2) / mail_multiplier;
278 capacity = (capacity + default_multiplier / 2) / default_multiplier;
292 switch (this->type) {
294 base_price = this->u.road.running_cost_class;
295 if (base_price == INVALID_PRICE)
return 0;
300 base_price = this->u.rail.running_cost_class;
301 if (base_price == INVALID_PRICE)
return 0;
306 base_price = PR_RUNNING_SHIP;
311 base_price = PR_RUNNING_AIRCRAFT;
315 default: NOT_REACHED();
329 switch (this->type) {
331 base_price = PR_BUILD_VEHICLE_ROAD;
337 base_price = PR_BUILD_VEHICLE_WAGON;
340 base_price = PR_BUILD_VEHICLE_TRAIN;
346 base_price = PR_BUILD_VEHICLE_SHIP;
351 base_price = PR_BUILD_VEHICLE_AIRCRAFT;
355 default: NOT_REACHED();
367 switch (this->type) {
373 return (max_speed != 0) ? max_speed * 2 : this->u.road.max_speed / 2;
381 if (max_speed != 0) {
382 return (max_speed * 128) / 10;
384 return this->u.air.max_speed;
387 default: NOT_REACHED();
400 switch (this->type) {
406 default: NOT_REACHED();
418 switch (this->type) {
424 default: NOT_REACHED();
436 switch (this->type) {
442 default: NOT_REACHED();
462 switch (this->type) {
466 default: NOT_REACHED();
477 for (uint internal_id = 0; internal_id < _engine_counts[type]; internal_id++) {
480 eid->
grfid = INVALID_GRFID;
501 if (eid->type == type && eid->grfid == grfid && eid->internal_id == grf_local_id) {
542 const Engine *e =
new Engine(eid->type, eid->internal_id);
543 assert(e->
index == index);
562 FOR_ALL_COMPANIES(c) {
570 void ShowEnginePreviewWindow(
EngineID engine);
595 if (retire_early != 0 && age >= retire_early_max_age) {
602 if (age < e->duration_phase_1) {
708 FOR_ALL_COMPANIES(c) {
778 int32 best_hist = -1;
780 FOR_ALL_COMPANIES(c) {
791 best_company = c->
index;
815 default: NOT_REACHED();
926 FOR_ALL_COMPANIES(c) {
958 RailType railtype = e->u.rail.railtype;
1032 FOR_ALL_ENGINES(e) {
1033 if (e->
name != NULL && strcmp(e->
name, name) == 0)
return false;
1089 if (e == NULL)
return false;
1092 if (e->
type != type)
return false;
1125 if (e == NULL)
return false;
1130 if (ei->refit_mask == 0)
return false;
1138 return default_cargo !=
CT_INVALID && ei->refit_mask != 1U << default_cargo;
1147 Date min_date = INT32_MAX;
1149 FOR_ALL_ENGINES(e) {
1159 if (min_date < INT32_MAX) {