35 #include "table/strings.h"
61 lengthof(_orig_aircraft_vehicle_info),
87 this->list_position = base;
91 if (base >= _engine_counts[type]) {
95 if (type ==
VEH_ROAD) this->u.road.tractive_effort = 0x4C;
115 default: NOT_REACHED();
118 this->u.rail = _orig_rail_vehicle_info[base];
120 this->info.
string_id = STR_VEHICLE_NAME_TRAIN_ENGINE_RAIL_KIRBY_PAUL_TANK_STEAM + base;
128 this->u.road = _orig_road_vehicle_info[base];
130 this->info.
string_id = STR_VEHICLE_NAME_ROAD_VEHICLE_MPS_REGAL_BUS + base;
134 this->u.ship = _orig_ship_vehicle_info[base];
136 this->info.
string_id = STR_VEHICLE_NAME_SHIP_MPS_OIL_TANKER + base;
140 this->u.air = _orig_aircraft_vehicle_info[base];
142 this->info.
string_id = STR_VEHICLE_NAME_AIRCRAFT_SAMPSON_U52 + base;
170 return file == NULL ? 0 : file->grfid;
185 switch (this->type) {
187 if (this->u.rail.capacity == 0)
return false;
191 if (this->u.road.capacity == 0)
return false;
198 default: NOT_REACHED();
214 if (mail_capacity != NULL) *mail_capacity = 0;
228 (new_multipliers || default_cargo != cargo_type || (v != NULL && v->
cargo_subtype != 0))) {
235 uint extra_mail_cap = 0;
236 switch (this->type) {
241 if (v == NULL && this->u.rail.railveh_type ==
RAILVEH_MULTIHEAD) capacity += this->u.rail.capacity;
257 if (!new_multipliers && cargo_type == CT_MAIL)
return capacity + extra_mail_cap;
258 default_cargo = CT_PASSENGERS;
261 default: NOT_REACHED();
264 if (!new_multipliers) {
266 capacity += extra_mail_cap;
271 if (new_multipliers || (this->type !=
VEH_SHIP && default_cargo != cargo_type)) {
272 uint16 default_multiplier = new_multipliers ? 0x100 :
CargoSpec::Get(default_cargo)->multiplier;
274 capacity *= cargo_multiplier;
275 if (extra_mail_cap > 0) {
277 capacity += (default_multiplier * extra_mail_cap * cargo_multiplier + mail_multiplier / 2) / mail_multiplier;
279 capacity = (capacity + default_multiplier / 2) / default_multiplier;
293 switch (this->type) {
295 base_price = this->u.road.running_cost_class;
296 if (base_price == INVALID_PRICE)
return 0;
301 base_price = this->u.rail.running_cost_class;
302 if (base_price == INVALID_PRICE)
return 0;
307 base_price = PR_RUNNING_SHIP;
312 base_price = PR_RUNNING_AIRCRAFT;
316 default: NOT_REACHED();
330 switch (this->type) {
332 base_price = PR_BUILD_VEHICLE_ROAD;
338 base_price = PR_BUILD_VEHICLE_WAGON;
341 base_price = PR_BUILD_VEHICLE_TRAIN;
347 base_price = PR_BUILD_VEHICLE_SHIP;
352 base_price = PR_BUILD_VEHICLE_AIRCRAFT;
356 default: NOT_REACHED();
368 switch (this->type) {
374 return (max_speed != 0) ? max_speed * 2 : this->u.road.max_speed / 2;
382 if (max_speed != 0) {
383 return (max_speed * 128) / 10;
385 return this->u.air.max_speed;
388 default: NOT_REACHED();
401 switch (this->type) {
407 default: NOT_REACHED();
419 switch (this->type) {
425 default: NOT_REACHED();
437 switch (this->type) {
443 default: NOT_REACHED();
463 switch (this->type) {
467 default: NOT_REACHED();
478 for (uint internal_id = 0; internal_id < _engine_counts[type]; internal_id++) {
481 eid->
grfid = INVALID_GRFID;
502 if (eid->type == type && eid->grfid == grfid && eid->internal_id == grf_local_id) {
543 const Engine *e =
new Engine(eid->type, eid->internal_id);
544 assert(e->
index == index);
563 FOR_ALL_COMPANIES(c) {
571 void ShowEnginePreviewWindow(
EngineID engine);
596 if (retire_early != 0 && age >= retire_early_max_age) {
603 if (age < e->duration_phase_1) {
709 FOR_ALL_COMPANIES(c) {
779 int32 best_hist = -1;
781 FOR_ALL_COMPANIES(c) {
792 best_company = c->
index;
816 default: NOT_REACHED();
927 FOR_ALL_COMPANIES(c) {
959 RailType railtype = e->u.rail.railtype;
1033 FOR_ALL_ENGINES(e) {
1034 if (e->
name != NULL && strcmp(e->
name, name) == 0)
return false;
1090 if (e == NULL)
return false;
1093 if (e->
type != type)
return false;
1126 if (e == NULL)
return false;
1131 if (ei->refit_mask == 0)
return false;
1139 return default_cargo !=
CT_INVALID && ei->refit_mask != 1U << default_cargo;
1148 Date min_date = INT32_MAX;
1150 FOR_ALL_ENGINES(e) {
1160 if (min_date < INT32_MAX) {