OpenTTD Source  1.11.0-beta2
engine.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "company_func.h"
12 #include "command_func.h"
13 #include "news_func.h"
14 #include "aircraft.h"
15 #include "newgrf.h"
16 #include "newgrf_engine.h"
17 #include "strings_func.h"
18 #include "core/random_func.hpp"
19 #include "window_func.h"
20 #include "date_func.h"
21 #include "autoreplace_gui.h"
22 #include "string_func.h"
23 #include "ai/ai.hpp"
24 #include "core/pool_func.hpp"
25 #include "engine_gui.h"
26 #include "engine_func.h"
27 #include "engine_base.h"
28 #include "company_base.h"
29 #include "vehicle_func.h"
30 #include "articulated_vehicles.h"
31 #include "error.h"
32 
33 #include "table/strings.h"
34 #include "table/engines.h"
35 
36 #include "safeguards.h"
37 
38 EnginePool _engine_pool("Engine");
40 
41 EngineOverrideManager _engine_mngr;
42 
48 
50 const uint8 _engine_counts[4] = {
51  lengthof(_orig_rail_vehicle_info),
52  lengthof(_orig_road_vehicle_info),
53  lengthof(_orig_ship_vehicle_info),
54  lengthof(_orig_aircraft_vehicle_info),
55 };
56 
58 const uint8 _engine_offsets[4] = {
59  0,
60  lengthof(_orig_rail_vehicle_info),
61  lengthof(_orig_rail_vehicle_info) + lengthof(_orig_road_vehicle_info),
62  lengthof(_orig_rail_vehicle_info) + lengthof(_orig_road_vehicle_info) + lengthof(_orig_ship_vehicle_info),
63 };
64 
65 static_assert(lengthof(_orig_rail_vehicle_info) + lengthof(_orig_road_vehicle_info) + lengthof(_orig_ship_vehicle_info) + lengthof(_orig_aircraft_vehicle_info) == lengthof(_orig_engine_info));
66 
68 
69 Engine::Engine() :
70  overrides_count(0),
71  overrides(nullptr)
72 {
73 }
74 
75 Engine::Engine(VehicleType type, EngineID base)
76 {
77  this->type = type;
78  this->grf_prop.local_id = base;
79  this->list_position = base;
81 
82  /* Check if this base engine is within the original engine data range */
83  if (base >= _engine_counts[type]) {
84  /* Set model life to maximum to make wagons available */
85  this->info.base_life = 0xFF;
86  /* Set road vehicle tractive effort to the default value */
87  if (type == VEH_ROAD) this->u.road.tractive_effort = 0x4C;
88  /* Aircraft must have CT_INVALID as default, as there is no property */
89  if (type == VEH_AIRCRAFT) this->info.cargo_type = CT_INVALID;
90  /* Set visual effect to the default value */
91  switch (type) {
92  case VEH_TRAIN: this->u.rail.visual_effect = VE_DEFAULT; break;
93  case VEH_ROAD: this->u.road.visual_effect = VE_DEFAULT; break;
94  case VEH_SHIP: this->u.ship.visual_effect = VE_DEFAULT; break;
95  default: break; // The aircraft, disasters and especially visual effects have no NewGRF configured visual effects
96  }
97  /* Set cargo aging period to the default value. */
99  return;
100  }
101 
102  /* Copy the original engine info for this slot */
103  this->info = _orig_engine_info[_engine_offsets[type] + base];
104 
105  /* Copy the original engine data for this slot */
106  switch (type) {
107  default: NOT_REACHED();
108 
109  case VEH_TRAIN:
110  this->u.rail = _orig_rail_vehicle_info[base];
111  this->original_image_index = this->u.rail.image_index;
112  this->info.string_id = STR_VEHICLE_NAME_TRAIN_ENGINE_RAIL_KIRBY_PAUL_TANK_STEAM + base;
113 
114  /* Set the default model life of original wagons to "infinite" */
115  if (this->u.rail.railveh_type == RAILVEH_WAGON) this->info.base_life = 0xFF;
116 
117  break;
118 
119  case VEH_ROAD:
120  this->u.road = _orig_road_vehicle_info[base];
121  this->original_image_index = this->u.road.image_index;
122  this->info.string_id = STR_VEHICLE_NAME_ROAD_VEHICLE_MPS_REGAL_BUS + base;
123  break;
124 
125  case VEH_SHIP:
126  this->u.ship = _orig_ship_vehicle_info[base];
127  this->original_image_index = this->u.ship.image_index;
128  this->info.string_id = STR_VEHICLE_NAME_SHIP_MPS_OIL_TANKER + base;
129  break;
130 
131  case VEH_AIRCRAFT:
132  this->u.air = _orig_aircraft_vehicle_info[base];
133  this->original_image_index = this->u.air.image_index;
134  this->info.string_id = STR_VEHICLE_NAME_AIRCRAFT_SAMPSON_U52 + base;
135  break;
136  }
137 }
138 
139 Engine::~Engine()
140 {
141  UnloadWagonOverrides(this);
142 }
143 
148 bool Engine::IsEnabled() const
149 {
150  return this->info.string_id != STR_NEWGRF_INVALID_ENGINE && HasBit(this->info.climates, _settings_game.game_creation.landscape);
151 }
152 
158 uint32 Engine::GetGRFID() const
159 {
160  const GRFFile *file = this->GetGRF();
161  return file == nullptr ? 0 : file->grfid;
162 }
163 
170 {
171  /* For engines that can appear in a consist (i.e. rail vehicles and (articulated) road vehicles), a capacity
172  * of zero is a special case, to define the vehicle to not carry anything. The default cargotype is still used
173  * for livery selection etc.
174  * Note: Only the property is tested. A capacity callback returning 0 does not have the same effect.
175  */
176  switch (this->type) {
177  case VEH_TRAIN:
178  if (this->u.rail.capacity == 0) return false;
179  break;
180 
181  case VEH_ROAD:
182  if (this->u.road.capacity == 0) return false;
183  break;
184 
185  case VEH_SHIP:
186  case VEH_AIRCRAFT:
187  break;
188 
189  default: NOT_REACHED();
190  }
191  return this->GetDefaultCargoType() != CT_INVALID;
192 }
193 
194 
202 uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const
203 {
204  assert(v == nullptr || this->index == v->engine_type);
205  if (mail_capacity != nullptr) *mail_capacity = 0;
206 
207  if (!this->CanCarryCargo()) return 0;
208 
209  bool new_multipliers = HasBit(this->info.misc_flags, EF_NO_DEFAULT_CARGO_MULTIPLIER);
210  CargoID default_cargo = this->GetDefaultCargoType();
211  CargoID cargo_type = (v != nullptr) ? v->cargo_type : default_cargo;
212 
213  if (mail_capacity != nullptr && this->type == VEH_AIRCRAFT && IsCargoInClass(cargo_type, CC_PASSENGERS)) {
214  *mail_capacity = GetEngineProperty(this->index, PROP_AIRCRAFT_MAIL_CAPACITY, this->u.air.mail_capacity, v);
215  }
216 
217  /* Check the refit capacity callback if we are not in the default configuration, or if we are using the new multiplier algorithm. */
219  (new_multipliers || default_cargo != cargo_type || (v != nullptr && v->cargo_subtype != 0))) {
220  uint16 callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, this->index, v);
221  if (callback != CALLBACK_FAILED) return callback;
222  }
223 
224  /* Get capacity according to property resp. CB */
225  uint capacity;
226  uint extra_mail_cap = 0;
227  switch (this->type) {
228  case VEH_TRAIN:
229  capacity = GetEngineProperty(this->index, PROP_TRAIN_CARGO_CAPACITY, this->u.rail.capacity, v);
230 
231  /* In purchase list add the capacity of the second head. Always use the plain property for this. */
232  if (v == nullptr && this->u.rail.railveh_type == RAILVEH_MULTIHEAD) capacity += this->u.rail.capacity;
233  break;
234 
235  case VEH_ROAD:
236  capacity = GetEngineProperty(this->index, PROP_ROADVEH_CARGO_CAPACITY, this->u.road.capacity, v);
237  break;
238 
239  case VEH_SHIP:
240  capacity = GetEngineProperty(this->index, PROP_SHIP_CARGO_CAPACITY, this->u.ship.capacity, v);
241  break;
242 
243  case VEH_AIRCRAFT:
244  capacity = GetEngineProperty(this->index, PROP_AIRCRAFT_PASSENGER_CAPACITY, this->u.air.passenger_capacity, v);
245  if (!IsCargoInClass(cargo_type, CC_PASSENGERS)) {
246  extra_mail_cap = GetEngineProperty(this->index, PROP_AIRCRAFT_MAIL_CAPACITY, this->u.air.mail_capacity, v);
247  }
248  if (!new_multipliers && cargo_type == CT_MAIL) return capacity + extra_mail_cap;
249  default_cargo = CT_PASSENGERS; // Always use 'passengers' wrt. cargo multipliers
250  break;
251 
252  default: NOT_REACHED();
253  }
254 
255  if (!new_multipliers) {
256  /* Use the passenger multiplier for mail as well */
257  capacity += extra_mail_cap;
258  extra_mail_cap = 0;
259  }
260 
261  /* Apply multipliers depending on cargo- and vehicletype. */
262  if (new_multipliers || (this->type != VEH_SHIP && default_cargo != cargo_type)) {
263  uint16 default_multiplier = new_multipliers ? 0x100 : CargoSpec::Get(default_cargo)->multiplier;
264  uint16 cargo_multiplier = CargoSpec::Get(cargo_type)->multiplier;
265  capacity *= cargo_multiplier;
266  if (extra_mail_cap > 0) {
267  uint mail_multiplier = CargoSpec::Get(CT_MAIL)->multiplier;
268  capacity += (default_multiplier * extra_mail_cap * cargo_multiplier + mail_multiplier / 2) / mail_multiplier;
269  }
270  capacity = (capacity + default_multiplier / 2) / default_multiplier;
271  }
272 
273  return capacity;
274 }
275 
281 {
282  Price base_price;
283  uint cost_factor;
284  switch (this->type) {
285  case VEH_ROAD:
286  base_price = this->u.road.running_cost_class;
287  if (base_price == INVALID_PRICE) return 0;
288  cost_factor = GetEngineProperty(this->index, PROP_ROADVEH_RUNNING_COST_FACTOR, this->u.road.running_cost);
289  break;
290 
291  case VEH_TRAIN:
292  base_price = this->u.rail.running_cost_class;
293  if (base_price == INVALID_PRICE) return 0;
294  cost_factor = GetEngineProperty(this->index, PROP_TRAIN_RUNNING_COST_FACTOR, this->u.rail.running_cost);
295  break;
296 
297  case VEH_SHIP:
298  base_price = PR_RUNNING_SHIP;
299  cost_factor = GetEngineProperty(this->index, PROP_SHIP_RUNNING_COST_FACTOR, this->u.ship.running_cost);
300  break;
301 
302  case VEH_AIRCRAFT:
303  base_price = PR_RUNNING_AIRCRAFT;
304  cost_factor = GetEngineProperty(this->index, PROP_AIRCRAFT_RUNNING_COST_FACTOR, this->u.air.running_cost);
305  break;
306 
307  default: NOT_REACHED();
308  }
309 
310  return GetPrice(base_price, cost_factor, this->GetGRF(), -8);
311 }
312 
318 {
319  Price base_price;
320  uint cost_factor;
321  switch (this->type) {
322  case VEH_ROAD:
323  base_price = PR_BUILD_VEHICLE_ROAD;
324  cost_factor = GetEngineProperty(this->index, PROP_ROADVEH_COST_FACTOR, this->u.road.cost_factor);
325  break;
326 
327  case VEH_TRAIN:
328  if (this->u.rail.railveh_type == RAILVEH_WAGON) {
329  base_price = PR_BUILD_VEHICLE_WAGON;
330  cost_factor = GetEngineProperty(this->index, PROP_TRAIN_COST_FACTOR, this->u.rail.cost_factor);
331  } else {
332  base_price = PR_BUILD_VEHICLE_TRAIN;
333  cost_factor = GetEngineProperty(this->index, PROP_TRAIN_COST_FACTOR, this->u.rail.cost_factor);
334  }
335  break;
336 
337  case VEH_SHIP:
338  base_price = PR_BUILD_VEHICLE_SHIP;
339  cost_factor = GetEngineProperty(this->index, PROP_SHIP_COST_FACTOR, this->u.ship.cost_factor);
340  break;
341 
342  case VEH_AIRCRAFT:
343  base_price = PR_BUILD_VEHICLE_AIRCRAFT;
344  cost_factor = GetEngineProperty(this->index, PROP_AIRCRAFT_COST_FACTOR, this->u.air.cost_factor);
345  break;
346 
347  default: NOT_REACHED();
348  }
349 
350  return GetPrice(base_price, cost_factor, this->GetGRF(), -8);
351 }
352 
358 {
359  switch (this->type) {
360  case VEH_TRAIN:
361  return GetEngineProperty(this->index, PROP_TRAIN_SPEED, this->u.rail.max_speed);
362 
363  case VEH_ROAD: {
364  uint max_speed = GetEngineProperty(this->index, PROP_ROADVEH_SPEED, 0);
365  return (max_speed != 0) ? max_speed * 2 : this->u.road.max_speed / 2;
366  }
367 
368  case VEH_SHIP:
369  return GetEngineProperty(this->index, PROP_SHIP_SPEED, this->u.ship.max_speed) / 2;
370 
371  case VEH_AIRCRAFT: {
372  uint max_speed = GetEngineProperty(this->index, PROP_AIRCRAFT_SPEED, 0);
373  if (max_speed != 0) {
374  return (max_speed * 128) / 10;
375  }
376  return this->u.air.max_speed;
377  }
378 
379  default: NOT_REACHED();
380  }
381 }
382 
389 uint Engine::GetPower() const
390 {
391  /* Only trains and road vehicles have 'power'. */
392  switch (this->type) {
393  case VEH_TRAIN:
394  return GetEngineProperty(this->index, PROP_TRAIN_POWER, this->u.rail.power);
395  case VEH_ROAD:
396  return GetEngineProperty(this->index, PROP_ROADVEH_POWER, this->u.road.power) * 10;
397 
398  default: NOT_REACHED();
399  }
400 }
401 
408 {
409  /* Only trains and road vehicles have 'weight'. */
410  switch (this->type) {
411  case VEH_TRAIN:
412  return GetEngineProperty(this->index, PROP_TRAIN_WEIGHT, this->u.rail.weight) << (this->u.rail.railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
413  case VEH_ROAD:
414  return GetEngineProperty(this->index, PROP_ROADVEH_WEIGHT, this->u.road.weight) / 4;
415 
416  default: NOT_REACHED();
417  }
418 }
419 
426 {
427  /* Only trains and road vehicles have 'tractive effort'. */
428  switch (this->type) {
429  case VEH_TRAIN:
430  return (GROUND_ACCELERATION * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_TRAIN_TRACTIVE_EFFORT, this->u.rail.tractive_effort)) / 256 / 1000;
431  case VEH_ROAD:
432  return (GROUND_ACCELERATION * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_ROADVEH_TRACTIVE_EFFORT, this->u.road.tractive_effort)) / 256 / 1000;
433 
434  default: NOT_REACHED();
435  }
436 }
437 
443 {
444  /* Assume leap years; this gives the player a bit more than the given amount of years, but never less. */
446 }
447 
452 uint16 Engine::GetRange() const
453 {
454  switch (this->type) {
455  case VEH_AIRCRAFT:
456  return GetEngineProperty(this->index, PROP_AIRCRAFT_RANGE, this->u.air.max_range);
457 
458  default: NOT_REACHED();
459  }
460 }
461 
467 {
468  switch (this->type) {
469  case VEH_AIRCRAFT:
470  switch (this->u.air.subtype) {
471  case AIR_HELI: return STR_LIVERY_HELICOPTER;
472  case AIR_CTOL: return STR_LIVERY_SMALL_PLANE;
473  case AIR_CTOL | AIR_FAST: return STR_LIVERY_LARGE_PLANE;
474  default: NOT_REACHED();
475  }
476 
477  default: NOT_REACHED();
478  }
479 }
480 
485 {
486  this->clear();
487  for (VehicleType type = VEH_TRAIN; type <= VEH_AIRCRAFT; type++) {
488  for (uint internal_id = 0; internal_id < _engine_counts[type]; internal_id++) {
489  EngineIDMapping &eid = this->emplace_back();
490  eid.type = type;
491  eid.grfid = INVALID_GRFID;
492  eid.internal_id = internal_id;
493  eid.substitute_id = internal_id;
494  }
495  }
496 }
497 
507 EngineID EngineOverrideManager::GetID(VehicleType type, uint16 grf_local_id, uint32 grfid)
508 {
509  EngineID index = 0;
510  for (const EngineIDMapping &eid : *this) {
511  if (eid.type == type && eid.grfid == grfid && eid.internal_id == grf_local_id) {
512  return index;
513  }
514  index++;
515  }
516  return INVALID_ENGINE;
517 }
518 
525 {
526  for (const Vehicle *v : Vehicle::Iterate()) {
527  if (IsCompanyBuildableVehicleType(v)) return false;
528  }
529 
530  /* Reset the engines, they will get new EngineIDs */
531  _engine_mngr.ResetToDefaultMapping();
533 
534  return true;
535 }
536 
541 {
543  _engine_pool.CleanPool();
544 
545  assert(_engine_mngr.size() >= _engine_mngr.NUM_DEFAULT_ENGINES);
546  uint index = 0;
547  for (const EngineIDMapping &eid : _engine_mngr) {
548  /* Assert is safe; there won't be more than 256 original vehicles
549  * in any case, and we just cleaned the pool. */
550  assert(Engine::CanAllocateItem());
551  const Engine *e = new Engine(eid.type, eid.internal_id);
552  assert(e->index == index);
553  index++;
554  }
555 }
556 
557 void ShowEnginePreviewWindow(EngineID engine);
558 
564 static bool IsWagon(EngineID index)
565 {
566  const Engine *e = Engine::Get(index);
567  return e->type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON;
568 }
569 
575 {
576  uint age = e->age;
577 
578  /* Check for early retirement */
579  if (e->company_avail != 0 && !_settings_game.vehicle.never_expire_vehicles && e->info.base_life != 0xFF) {
580  int retire_early = e->info.retire_early;
581  uint retire_early_max_age = std::max(0, e->duration_phase_1 + e->duration_phase_2 - retire_early * 12);
582  if (retire_early != 0 && age >= retire_early_max_age) {
583  /* Early retirement is enabled and we're past the date... */
584  e->company_avail = 0;
586  }
587  }
588 
589  if (age < e->duration_phase_1) {
590  uint start = e->reliability_start;
591  e->reliability = age * (e->reliability_max - start) / e->duration_phase_1 + start;
592  } else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _settings_game.vehicle.never_expire_vehicles || e->info.base_life == 0xFF) {
593  /* We are at the peak of this engines life. It will have max reliability.
594  * This is also true if the engines never expire. They will not go bad over time */
596  } else if ((age -= e->duration_phase_2) < e->duration_phase_3) {
597  uint max = e->reliability_max;
598  e->reliability = (int)age * (int)(e->reliability_final - max) / e->duration_phase_3 + max;
599  } else {
600  /* time's up for this engine.
601  * We will now completely retire this design */
602  e->company_avail = 0;
604  /* Kick this engine out of the lists */
606  }
607  SetWindowClassesDirty(WC_BUILD_VEHICLE); // Update to show the new reliability
609 }
610 
613 {
614  /* Determine last engine aging year, default to 2050 as previously. */
616 
617  for (const Engine *e : Engine::Iterate()) {
618  const EngineInfo *ei = &e->info;
619 
620  /* Exclude certain engines */
622  if (e->type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON) continue;
623 
624  /* Base year ending date on half the model life */
625  YearMonthDay ymd;
626  ConvertDateToYMD(ei->base_intro + (ei->lifelength * DAYS_IN_LEAP_YEAR) / 2, &ymd);
627 
629  }
630 }
631 
637 void StartupOneEngine(Engine *e, Date aging_date)
638 {
639  const EngineInfo *ei = &e->info;
640 
641  e->age = 0;
642  e->flags = 0;
643  e->company_avail = 0;
644  e->company_hidden = 0;
645 
646  /* Vehicles with the same base_intro date shall be introduced at the same time.
647  * Make sure they use the same randomisation of the date. */
648  SavedRandomSeeds saved_seeds;
649  SaveRandomSeeds(&saved_seeds);
651  ei->base_intro ^
652  e->type ^
653  e->GetGRFID());
654  uint32 r = Random();
655 
656  /* Don't randomise the start-date in the first two years after gamestart to ensure availability
657  * of engines in early starting games.
658  * Note: TTDP uses fixed 1922 */
660  if (e->intro_date <= _date) {
661  e->age = (aging_date - e->intro_date) >> 5;
662  e->company_avail = (CompanyMask)-1;
663  e->flags |= ENGINE_AVAILABLE;
664  }
665 
666  RestoreRandomSeeds(saved_seeds);
667 
668  r = Random();
669  e->reliability_start = GB(r, 16, 14) + 0x7AE0;
670  e->reliability_max = GB(r, 0, 14) + 0xBFFF;
671 
672  r = Random();
673  e->reliability_final = GB(r, 16, 14) + 0x3FFF;
674  e->duration_phase_1 = GB(r, 0, 5) + 7;
675  e->duration_phase_2 = GB(r, 5, 4) + ei->base_life * 12 - 96;
676  e->duration_phase_3 = GB(r, 9, 7) + 120;
677 
678  e->reliability_spd_dec = ei->decay_speed << 2;
679 
681 
682  /* prevent certain engines from ever appearing. */
684  e->flags |= ENGINE_AVAILABLE;
685  e->company_avail = 0;
686  }
687 }
688 
694 {
695  /* Aging of vehicles stops, so account for that when starting late */
696  const Date aging_date = std::min(_date, ConvertYMDToDate(_year_engine_aging_stops, 0, 1));
697 
698  for (Engine *e : Engine::Iterate()) {
699  StartupOneEngine(e, aging_date);
700  }
701 
702  /* Update the bitmasks for the vehicle lists */
703  for (Company *c : Company::Iterate()) {
704  c->avail_railtypes = GetCompanyRailtypes(c->index);
705  c->avail_roadtypes = GetCompanyRoadTypes(c->index);
706  }
707 
708  /* Invalidate any open purchase lists */
710 }
711 
717 static void EnableEngineForCompany(EngineID eid, CompanyID company)
718 {
719  Engine *e = Engine::Get(eid);
720  Company *c = Company::Get(company);
721 
722  SetBit(e->company_avail, company);
723  if (e->type == VEH_TRAIN) {
724  assert(e->u.rail.railtype < RAILTYPE_END);
726  } else if (e->type == VEH_ROAD) {
727  assert(e->u.road.roadtype < ROADTYPE_END);
729  }
730 
731  if (company == _local_company) {
733 
734  /* Update the toolbar. */
739  }
740 }
741 
747 static void DisableEngineForCompany(EngineID eid, CompanyID company)
748 {
749  Engine *e = Engine::Get(eid);
750 
751  ClrBit(e->company_avail, company);
752 
753  if (company == _local_company) {
755  }
756 }
757 
763 static void AcceptEnginePreview(EngineID eid, CompanyID company)
764 {
765  Engine *e = Engine::Get(eid);
766 
768  e->preview_asked = (CompanyMask)-1;
769 
770  EnableEngineForCompany(eid, company);
771 
772  /* Notify preview window, that it might want to close.
773  * Note: We cannot directly close the window.
774  * In singleplayer this function is called from the preview window, so
775  * we have to use the GUI-scope scheduling of InvalidateWindowData.
776  */
778 }
779 
786 {
787  CompanyID best_company = INVALID_COMPANY;
788 
789  /* For trains the cargomask has no useful meaning, since you can attach other wagons */
790  CargoTypes cargomask = e->type != VEH_TRAIN ? GetUnionOfArticulatedRefitMasks(e->index, true) : ALL_CARGOTYPES;
791 
792  int32 best_hist = -1;
793  for (const Company *c : Company::Iterate()) {
794  if (c->block_preview == 0 && !HasBit(e->preview_asked, c->index) &&
795  c->old_economy[0].performance_history > best_hist) {
796 
797  /* Check whether the company uses similar vehicles */
798  for (const Vehicle *v : Vehicle::Iterate()) {
799  if (v->owner != c->index || v->type != e->type) continue;
800  if (!v->GetEngine()->CanCarryCargo() || !HasBit(cargomask, v->cargo_type)) continue;
801 
802  best_hist = c->old_economy[0].performance_history;
803  best_company = c->index;
804  break;
805  }
806  }
807  }
808 
809  return best_company;
810 }
811 
819 static bool IsVehicleTypeDisabled(VehicleType type, bool ai)
820 {
821  switch (type) {
826 
827  default: NOT_REACHED();
828  }
829 }
830 
833 {
834  for (Company *c : Company::Iterate()) {
835  c->avail_railtypes = AddDateIntroducedRailTypes(c->avail_railtypes, _date);
836  c->avail_roadtypes = AddDateIntroducedRoadTypes(c->avail_roadtypes, _date);
837  }
838 
839  if (_cur_year >= _year_engine_aging_stops) return;
840 
841  for (Engine *e : Engine::Iterate()) {
842  EngineID i = e->index;
843  if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) {
844  if (e->preview_company != INVALID_COMPANY) {
845  if (!--e->preview_wait) {
847  e->preview_company = INVALID_COMPANY;
848  }
849  } else if (CountBits(e->preview_asked) < MAX_COMPANIES) {
850  e->preview_company = GetPreviewCompany(e);
851 
852  if (e->preview_company == INVALID_COMPANY) {
853  e->preview_asked = (CompanyMask)-1;
854  continue;
855  }
856 
857  SetBit(e->preview_asked, e->preview_company);
858  e->preview_wait = 20;
859  /* AIs are intentionally not skipped for preview even if they cannot build a certain
860  * vehicle type. This is done to not give poor performing human companies an "unfair"
861  * boost that they wouldn't have gotten against other human companies. The check on
862  * the line below is just to make AIs not notice that they have a preview if they
863  * cannot build the vehicle. */
864  if (!IsVehicleTypeDisabled(e->type, true)) AI::NewEvent(e->preview_company, new ScriptEventEnginePreview(i));
865  if (IsInteractiveCompany(e->preview_company)) ShowEnginePreviewWindow(i);
866  }
867  }
868  }
869 }
870 
876 {
877  for (Engine *e : Engine::Iterate()) {
878  SB(e->company_hidden, cid, 1, 0);
879  }
880 }
881 
891 CommandCost CmdSetVehicleVisibility(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
892 {
893  Engine *e = Engine::GetIfValid(GB(p2, 0, 31));
894  if (e == nullptr || _current_company >= MAX_COMPANIES) return CMD_ERROR;
895  if (!IsEngineBuildable(e->index, e->type, _current_company)) return CMD_ERROR;
896 
897  if ((flags & DC_EXEC) != 0) {
898  SB(e->company_hidden, _current_company, 1, GB(p2, 31, 1));
900  }
901 
902  return CommandCost();
903 }
904 
915 CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
916 {
917  Engine *e = Engine::GetIfValid(p1);
918  if (e == nullptr || !(e->flags & ENGINE_EXCLUSIVE_PREVIEW) || e->preview_company != _current_company) return CMD_ERROR;
919 
920  if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_company);
921 
922  return CommandCost();
923 }
924 
936 CommandCost CmdEngineCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
937 {
938  if (_current_company != OWNER_DEITY) return CMD_ERROR;
939  EngineID engine_id = (EngineID)p1;
940  CompanyID company_id = (CompanyID)GB(p2, 0, 8);
941  bool allow = HasBit(p2, 31);
942 
943  if (!Engine::IsValidID(engine_id) || !Company::IsValidID(company_id)) return CMD_ERROR;
944 
945  if (flags & DC_EXEC) {
946  if (allow) {
947  EnableEngineForCompany(engine_id, company_id);
948  } else {
949  DisableEngineForCompany(engine_id, company_id);
950  }
951  }
952 
953  return CommandCost();
954 }
955 
962 {
963  EngineID index = e->index;
964 
965  /* In case the company didn't build the vehicle during the intro period,
966  * prevent that company from getting future intro periods for a while. */
967  if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) {
968  for (Company *c : Company::Iterate()) {
969  uint block_preview = c->block_preview;
970 
971  if (!HasBit(e->company_avail, c->index)) continue;
972 
973  /* We assume the user did NOT build it.. prove me wrong ;) */
974  c->block_preview = 20;
975 
976  for (const Vehicle *v : Vehicle::Iterate()) {
977  if (v->type == VEH_TRAIN || v->type == VEH_ROAD || v->type == VEH_SHIP ||
978  (v->type == VEH_AIRCRAFT && Aircraft::From(v)->IsNormalAircraft())) {
979  if (v->owner == c->index && v->engine_type == index) {
980  /* The user did prove me wrong, so restore old value */
981  c->block_preview = block_preview;
982  break;
983  }
984  }
985  }
986  }
987  }
988 
991 
992  /* Now available for all companies */
993  e->company_avail = (CompanyMask)-1;
994 
995  /* Do not introduce new rail wagons */
996  if (IsWagon(index)) return;
997 
998  if (e->type == VEH_TRAIN) {
999  /* maybe make another rail type available */
1000  RailType railtype = e->u.rail.railtype;
1001  assert(railtype < RAILTYPE_END);
1002  for (Company *c : Company::Iterate()) c->avail_railtypes = AddDateIntroducedRailTypes(c->avail_railtypes | GetRailTypeInfo(e->u.rail.railtype)->introduces_railtypes, _date);
1003  } else if (e->type == VEH_ROAD) {
1004  /* maybe make another road type available */
1005  assert(e->u.road.roadtype < ROADTYPE_END);
1006  for (Company* c : Company::Iterate()) c->avail_roadtypes = AddDateIntroducedRoadTypes(c->avail_roadtypes | GetRoadTypeInfo(e->u.road.roadtype)->introduces_roadtypes, _date);
1007  }
1008 
1009  /* Only broadcast event if AIs are able to build this vehicle type. */
1010  if (!IsVehicleTypeDisabled(e->type, true)) AI::BroadcastNewEvent(new ScriptEventEngineAvailable(index));
1011 
1012  /* Only provide the "New Vehicle available" news paper entry, if engine can be built. */
1013  if (!IsVehicleTypeDisabled(e->type, false)) {
1014  SetDParam(0, GetEngineCategoryName(index));
1015  SetDParam(1, index);
1016  AddNewsItem(STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE, NT_NEW_VEHICLES, NF_VEHICLE, NR_ENGINE, index);
1017  }
1018 
1019  /* Update the toolbar. */
1023 
1024  /* Close pending preview windows */
1026 }
1027 
1030 {
1032  for (Engine *e : Engine::Iterate()) {
1033  /* Age the vehicle */
1034  if ((e->flags & ENGINE_AVAILABLE) && e->age != MAX_DAY) {
1035  e->age++;
1037  }
1038 
1039  /* Do not introduce invalid engines */
1040  if (!e->IsEnabled()) continue;
1041 
1042  if (!(e->flags & ENGINE_AVAILABLE) && _date >= (e->intro_date + DAYS_IN_YEAR)) {
1043  /* Introduce it to all companies */
1045  } else if (!(e->flags & (ENGINE_AVAILABLE | ENGINE_EXCLUSIVE_PREVIEW)) && _date >= e->intro_date) {
1046  /* Introduction date has passed...
1047  * Check if it is allowed to build this vehicle type at all
1048  * based on the current game settings. If not, it does not
1049  * make sense to show the preview dialog to any company. */
1050  if (IsVehicleTypeDisabled(e->type, false)) continue;
1051 
1052  /* Do not introduce new rail wagons */
1053  if (IsWagon(e->index)) continue;
1054 
1055  /* Show preview dialog to one of the companies. */
1056  e->flags |= ENGINE_EXCLUSIVE_PREVIEW;
1057  e->preview_company = INVALID_COMPANY;
1058  e->preview_asked = 0;
1059  }
1060  }
1061 
1062  InvalidateWindowClassesData(WC_BUILD_VEHICLE); // rebuild the purchase list (esp. when sorted by reliability)
1063  }
1064 }
1065 
1071 static bool IsUniqueEngineName(const char *name)
1072 {
1073  for (const Engine *e : Engine::Iterate()) {
1074  if (!e->name.empty() && e->name == name) return false;
1075  }
1076 
1077  return true;
1078 }
1079 
1089 CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
1090 {
1091  Engine *e = Engine::GetIfValid(p1);
1092  if (e == nullptr) return CMD_ERROR;
1093 
1094  bool reset = StrEmpty(text);
1095 
1096  if (!reset) {
1098  if (!IsUniqueEngineName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
1099  }
1100 
1101  if (flags & DC_EXEC) {
1102  if (reset) {
1103  e->name.clear();
1104  } else {
1105  e->name = text;
1106  }
1107 
1109  }
1110 
1111  return CommandCost();
1112 }
1113 
1114 
1124 {
1125  const Engine *e = Engine::GetIfValid(engine);
1126 
1127  /* check if it's an engine that is in the engine array */
1128  if (e == nullptr) return false;
1129 
1130  /* check if it's an engine of specified type */
1131  if (e->type != type) return false;
1132 
1133  /* check if it's available ... */
1134  if (company == OWNER_DEITY) {
1135  /* ... for any company (preview does not count) */
1136  if (!(e->flags & ENGINE_AVAILABLE) || e->company_avail == 0) return false;
1137  } else {
1138  /* ... for this company */
1139  if (!HasBit(e->company_avail, company)) return false;
1140  }
1141 
1142  if (!e->IsEnabled()) return false;
1143 
1144  if (type == VEH_TRAIN && company != OWNER_DEITY) {
1145  /* Check if the rail type is available to this company */
1146  const Company *c = Company::Get(company);
1147  if (((GetRailTypeInfo(e->u.rail.railtype))->compatible_railtypes & c->avail_railtypes) == 0) return false;
1148  }
1149  if (type == VEH_ROAD && company != OWNER_DEITY) {
1150  /* Check if the road type is available to this company */
1151  const Company *c = Company::Get(company);
1152  if ((GetRoadTypeInfo(e->u.road.roadtype)->powered_roadtypes & c->avail_roadtypes) == ROADTYPES_NONE) return false;
1153  }
1154 
1155  return true;
1156 }
1157 
1165 {
1166  const Engine *e = Engine::GetIfValid(engine);
1167 
1168  /* check if it's an engine that is in the engine array */
1169  if (e == nullptr) return false;
1170 
1171  if (!e->CanCarryCargo()) return false;
1172 
1173  const EngineInfo *ei = &e->info;
1174  if (ei->refit_mask == 0) return false;
1175 
1176  /* Are there suffixes?
1177  * Note: This does not mean the suffixes are actually available for every consist at any time. */
1178  if (HasBit(ei->callback_mask, CBM_VEHICLE_CARGO_SUFFIX)) return true;
1179 
1180  /* Is there any cargo except the default cargo? */
1181  CargoID default_cargo = e->GetDefaultCargoType();
1182  CargoTypes default_cargo_mask = 0;
1183  SetBit(default_cargo_mask, default_cargo);
1184  return default_cargo != CT_INVALID && ei->refit_mask != default_cargo_mask;
1185 }
1186 
1191 {
1192  Date min_date = INT32_MAX;
1193 
1194  for (const Engine *e : Engine::Iterate()) {
1195  if (!e->IsEnabled()) continue;
1196 
1197  /* We have an available engine... yay! */
1198  if ((e->flags & ENGINE_AVAILABLE) != 0 && e->company_avail != 0) return;
1199 
1200  /* Okay, try to find the earliest date. */
1201  min_date = std::min(min_date, e->info.base_intro);
1202  }
1203 
1204  if (min_date < INT32_MAX) {
1205  SetDParam(0, min_date);
1206  ShowErrorMessage(STR_ERROR_NO_VEHICLES_AVAILABLE_YET, STR_ERROR_NO_VEHICLES_AVAILABLE_YET_EXPLANATION, WL_WARNING);
1207  } else {
1208  ShowErrorMessage(STR_ERROR_NO_VEHICLES_AVAILABLE_AT_ALL, STR_ERROR_NO_VEHICLES_AVAILABLE_AT_ALL_EXPLANATION, WL_WARNING);
1209  }
1210 }
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
AddDateIntroducedRailTypes
RailTypes AddDateIntroducedRailTypes(RailTypes current, Date date)
Add the rail types that are to be introduced at the given date.
Definition: rail.cpp:218
INVALID_ENGINE
static const EngineID INVALID_ENGINE
Constant denoting an invalid engine.
Definition: engine_type.h:174
EngineInfo::base_life
Year base_life
Basic duration of engine availability (without random parts). 0xFF means infinite life.
Definition: engine_type.h:135
IsCompanyBuildableVehicleType
static bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
Definition: vehicle_func.h:89
VehicleSettings::max_aircraft
UnitID max_aircraft
max planes in game per company
Definition: settings_type.h:460
Engine::GetGRFID
uint32 GetGRFID() const
Retrieve the GRF ID of the NewGRF the engine is tied to.
Definition: engine.cpp:158
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
InvalidateWindowData
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Definition: window.cpp:3321
CheckEngines
void CheckEngines()
Check for engines that have an appropriate availability.
Definition: engine.cpp:1190
PROP_TRAIN_SPEED
@ PROP_TRAIN_SPEED
Max. speed: 1 unit = 1/1.6 mph = 1 km-ish/h.
Definition: newgrf_properties.h:21
GameCreationSettings::generation_seed
uint32 generation_seed
noise seed for world generation
Definition: settings_type.h:282
EngineOverrideManager::ResetToCurrentNewGRFConfig
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
Definition: engine.cpp:524
NT_NEW_VEHICLES
@ NT_NEW_VEHICLES
New vehicle has become available.
Definition: news_type.h:33
Pool::PoolItem<&_engine_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:329
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition: window_type.h:66
EngineOverrideManager::ResetToDefaultMapping
void ResetToDefaultMapping()
Initializes the EngineOverrideManager with the default engines.
Definition: engine.cpp:484
PROP_TRAIN_CARGO_CAPACITY
@ PROP_TRAIN_CARGO_CAPACITY
Capacity (if dualheaded: for each single vehicle)
Definition: newgrf_properties.h:24
AISettings::ai_disable_veh_roadveh
bool ai_disable_veh_roadveh
disable types for AI
Definition: settings_type.h:335
PROP_ROADVEH_TRACTIVE_EFFORT
@ PROP_ROADVEH_TRACTIVE_EFFORT
Tractive effort coefficient in 1/256.
Definition: newgrf_properties.h:38
ReloadNewGRFData
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Definition: afterload.cpp:3162
EngineIDMapping::grfid
uint32 grfid
The GRF ID of the file the entity belongs to.
Definition: engine_base.h:164
Engine::reliability_max
uint16 reliability_max
Maximal reliability of the engine.
Definition: engine_base.h:28
GetPrice
Money GetPrice(Price index, uint cost_factor, const GRFFile *grf_file, int shift)
Determine a certain price.
Definition: economy.cpp:950
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
Engine::duration_phase_3
uint16 duration_phase_3
Third reliability phase in months, decaying to reliability_final.
Definition: engine_base.h:32
PROP_ROADVEH_COST_FACTOR
@ PROP_ROADVEH_COST_FACTOR
Purchase cost.
Definition: newgrf_properties.h:34
command_func.h
Pool::PoolItem<&_engine_pool >::GetIfValid
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:340
CMD_ERROR
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Definition: command_func.h:23
Company::avail_railtypes
RailTypes avail_railtypes
Rail types available to this company.
Definition: company_base.h:115
WL_WARNING
@ WL_WARNING
Other information.
Definition: error.h:23
PROP_TRAIN_RUNNING_COST_FACTOR
@ PROP_TRAIN_RUNNING_COST_FACTOR
Yearly runningcost (if dualheaded: sum of both vehicles)
Definition: newgrf_properties.h:23
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:295
Engine::reliability_spd_dec
uint16 reliability_spd_dec
Speed of reliability decay between services (per day).
Definition: engine_base.h:26
RoadTypeInfo::introduces_roadtypes
RoadTypes introduces_roadtypes
Bitmask of which other roadtypes are introduced when this roadtype is introduced.
Definition: road.h:174
Company::avail_roadtypes
RoadTypes avail_roadtypes
Road types available to this company.
Definition: company_base.h:116
CmdEngineCtrl
CommandCost CmdEngineCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Allow or forbid a specific company to use an engine.
Definition: engine.cpp:936
_engine_counts
const uint8 _engine_counts[4]
Number of engines of each vehicle type in original engine data.
Definition: engine.cpp:50
company_base.h
IsWagon
static bool IsWagon(EngineID index)
Determine whether an engine type is a wagon (and not a loco).
Definition: engine.cpp:564
GetPreviewCompany
static CompanyID GetPreviewCompany(Engine *e)
Get the best company for an engine preview.
Definition: engine.cpp:785
_cur_year
Year _cur_year
Current year, starting at 0.
Definition: date.cpp:26
PROP_TRAIN_TRACTIVE_EFFORT
@ PROP_TRAIN_TRACTIVE_EFFORT
Tractive effort coefficient in 1/256.
Definition: newgrf_properties.h:27
EnginesDailyLoop
void EnginesDailyLoop()
Daily check to offer an exclusive engine preview to the companies.
Definition: engine.cpp:832
Pool::CleanPool
virtual void CleanPool()
Virtual method that deletes all items in the pool.
_year_engine_aging_stops
static Year _year_engine_aging_stops
Year that engine aging stops.
Definition: engine.cpp:47
Price
Price
Enumeration of all base prices for use with Prices.
Definition: economy_type.h:74
PROP_AIRCRAFT_MAIL_CAPACITY
@ PROP_AIRCRAFT_MAIL_CAPACITY
Mail Capacity.
Definition: newgrf_properties.h:52
Engine::company_avail
CompanyMask company_avail
Bit for each company whether the engine is available for that company.
Definition: engine_base.h:37
WC_ENGINE_PREVIEW
@ WC_ENGINE_PREVIEW
Engine preview window; Window numbers:
Definition: window_type.h:583
Engine::GetDisplayMaxTractiveEffort
uint GetDisplayMaxTractiveEffort() const
Returns the tractive effort of the engine for display purposes.
Definition: engine.cpp:425
VE_DEFAULT
@ VE_DEFAULT
Default value to indicate that visual effect should be based on engine class.
Definition: vehicle_base.h:92
SavedRandomSeeds
Stores the state of all random number generators.
Definition: random_func.hpp:33
Pool::PoolItem<&_engine_pool >::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:227
CargoSpec::Get
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
Definition: cargotype.h:117
PROP_SHIP_CARGO_CAPACITY
@ PROP_SHIP_CARGO_CAPACITY
Capacity.
Definition: newgrf_properties.h:44
Engine::duration_phase_1
uint16 duration_phase_1
First reliability phase in months, increasing reliability from reliability_start to reliability_max.
Definition: engine_base.h:30
PROP_AIRCRAFT_RUNNING_COST_FACTOR
@ PROP_AIRCRAFT_RUNNING_COST_FACTOR
Yearly runningcost.
Definition: newgrf_properties.h:50
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
EnableEngineForCompany
static void EnableEngineForCompany(EngineID eid, CompanyID company)
Allows engine eid to be used by a company company.
Definition: engine.cpp:717
SaveRandomSeeds
static void SaveRandomSeeds(SavedRandomSeeds *storage)
Saves the current seeds.
Definition: random_func.hpp:42
Engine::GetRunningCost
Money GetRunningCost() const
Return how much the running costs of this engine are.
Definition: engine.cpp:280
ClrBit
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
Definition: bitmath_func.hpp:151
Engine::reliability_start
uint16 reliability_start
Initial reliability of the engine.
Definition: engine_base.h:27
GetEngineCategoryName
StringID GetEngineCategoryName(EngineID engine)
Return the category of an engine.
Definition: engine_gui.cpp:38
Year
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:18
autoreplace_gui.h
aircraft.h
ROADTYPE_END
@ ROADTYPE_END
Used for iterations.
Definition: road_type.h:26
SetupEngines
void SetupEngines()
Initialise the engine pool with the data from the original vehicles.
Definition: engine.cpp:540
AddDateIntroducedRoadTypes
RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, Date date)
Add the road types that are to be introduced at the given date.
Definition: road.cpp:155
Engine::preview_company
CompanyID preview_company
Company which is currently being offered a preview INVALID_COMPANY means no company.
Definition: engine_base.h:35
GetCompanyRoadTypes
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
Definition: road.cpp:188
StartupOneEngine
void StartupOneEngine(Engine *e, Date aging_date)
Start/initialise one engine.
Definition: engine.cpp:637
DeleteWindowByClass
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
Definition: window.cpp:1178
Engine::GetLifeLengthInDays
Date GetLifeLengthInDays() const
Returns the vehicle's (not model's!) life length in days.
Definition: engine.cpp:442
EngineInfo
Information about a vehicle.
Definition: engine_type.h:132
EngineInfo::base_intro
Date base_intro
Basic date of engine introduction (without random parts).
Definition: engine_type.h:133
CBM_VEHICLE_CARGO_SUFFIX
@ CBM_VEHICLE_CARGO_SUFFIX
Show suffix after cargo name.
Definition: newgrf_callbacks.h:294
Engine
Definition: engine_base.h:21
MAX_DAY
#define MAX_DAY
The number of days till the last day.
Definition: date_type.h:97
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
CC_PASSENGERS
@ CC_PASSENGERS
Passengers.
Definition: cargotype.h:39
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:222
EngineIDMapping::internal_id
uint16 internal_id
The internal ID within the GRF file.
Definition: engine_base.h:165
Engine::GetDefaultCargoType
CargoID GetDefaultCargoType() const
Determines the default cargo type of an engine.
Definition: engine_base.h:79
Engine::company_hidden
CompanyMask company_hidden
Bit for each company whether the engine is normally hidden in the build gui for that company.
Definition: engine_base.h:38
RoadVehicleInfo::roadtype
RoadType roadtype
Road type.
Definition: engine_type.h:125
StartupEngines
void StartupEngines()
Start/initialise all our engines.
Definition: engine.cpp:693
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
GetVehicleCallback
uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v)
Evaluate a newgrf callback for vehicles.
Definition: newgrf_engine.cpp:1188
DC_EXEC
@ DC_EXEC
execute the given command
Definition: command_type.h:348
DisableEngineForCompany
static void DisableEngineForCompany(EngineID eid, CompanyID company)
Forbids engine eid to be used by a company company.
Definition: engine.cpp:747
EngineOverrideManager::GetID
EngineID GetID(VehicleType type, uint16 grf_local_id, uint32 grfid)
Looks up an EngineID in the EngineOverrideManager.
Definition: engine.cpp:507
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:199
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition: command_type.h:346
CmdRenameEngine
CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Rename an engine.
Definition: engine.cpp:1089
RestoreRandomSeeds
static void RestoreRandomSeeds(const SavedRandomSeeds &storage)
Restores previously saved seeds.
Definition: random_func.hpp:52
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
Definition: error_gui.cpp:372
CountBits
static uint CountBits(T value)
Counts the number of set bits in a variable.
Definition: bitmath_func.hpp:251
VehicleSettings::extend_vehicle_life
byte extend_vehicle_life
extend vehicle life by this many years
Definition: settings_type.h:466
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:550
ai.hpp
EngineInfo::lifelength
Year lifelength
Lifetime of a single vehicle.
Definition: engine_type.h:134
Engine::GetGRF
const GRFFile * GetGRF() const
Retrieve the NewGRF the engine is tied to.
Definition: engine_base.h:138
TRANSPORT_ROAD
@ TRANSPORT_ROAD
Transport by road vehicle.
Definition: transport_type.h:28
GetRailTypeInfo
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:304
ENGINE_EXCLUSIVE_PREVIEW
@ ENGINE_EXCLUSIVE_PREVIEW
This vehicle is in the exclusive preview stage, either being used or being offered to a company.
Definition: engine_type.h:169
Engine::GetDisplayMaxSpeed
uint GetDisplayMaxSpeed() const
Returns max speed of the engine for display purposes.
Definition: engine.cpp:357
Utf8StringLength
size_t Utf8StringLength(const char *s)
Get the length of an UTF-8 encoded string in number of characters and thus not the number of bytes th...
Definition: string.cpp:334
PROP_ROADVEH_SPEED
@ PROP_ROADVEH_SPEED
Max. speed: 1 unit = 1/0.8 mph = 2 km-ish/h.
Definition: newgrf_properties.h:37
IsVehicleTypeDisabled
static bool IsVehicleTypeDisabled(VehicleType type, bool ai)
Checks if a vehicle type is disabled for all/ai companies.
Definition: engine.cpp:819
EngineID
uint16 EngineID
Unique identification number of an engine.
Definition: engine_type.h:21
RoadTypeInfo::powered_roadtypes
RoadTypes powered_roadtypes
bitmask to the OTHER roadtypes on which a vehicle of THIS roadtype generates power
Definition: road.h:119
return_cmd_error
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
Definition: command_func.h:33
AISettings::ai_disable_veh_train
bool ai_disable_veh_train
disable types for AI
Definition: settings_type.h:334
AI::NewEvent
static void NewEvent(CompanyID company, ScriptEvent *event)
Queue a new event for an AI.
Definition: ai_core.cpp:234
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
CommandCost
Common return value for all commands.
Definition: command_type.h:23
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:28
GetUnionOfArticulatedRefitMasks
CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
Ors the refit_masks of all articulated parts.
Definition: articulated_vehicles.cpp:255
newgrf_engine.h
EngineInfo::callback_mask
byte callback_mask
Bitmask of vehicle callbacks that have to be called.
Definition: engine_type.h:143
VehicleSettings::max_ships
UnitID max_ships
max ships in game per company
Definition: settings_type.h:461
CARGO_AGING_TICKS
static const int CARGO_AGING_TICKS
cycle duration for aging cargo
Definition: date_type.h:35
Vehicle::engine_type
EngineID engine_type
The type of engine used for this vehicle.
Definition: vehicle_base.h:297
SB
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Definition: bitmath_func.hpp:58
ConvertYMDToDate
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: date.cpp:149
GROUND_ACCELERATION
static const int GROUND_ACCELERATION
Acceleration due to gravity, 9.8 m/s^2.
Definition: vehicle_type.h:18
MAX_LENGTH_ENGINE_NAME_CHARS
static const uint MAX_LENGTH_ENGINE_NAME_CHARS
The maximum length of an engine name in characters including '\0'.
Definition: engine_type.h:172
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
Engine::preview_asked
CompanyMask preview_asked
Bit for each company which has already been offered a preview.
Definition: engine_base.h:34
WC_REPLACE_VEHICLE
@ WC_REPLACE_VEHICLE
Replace vehicle window; Window numbers:
Definition: window_type.h:211
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:80
Engine::GetDisplayWeight
uint GetDisplayWeight() const
Returns the weight of the engine for display purposes.
Definition: engine.cpp:407
ConvertDateToYMD
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
Definition: date.cpp:94
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
AI::BroadcastNewEvent
static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company=MAX_COMPANIES)
Broadcast a new event to all active AIs.
Definition: ai_core.cpp:259
safeguards.h
IsInteractiveCompany
static bool IsInteractiveCompany(CompanyID company)
Is the user representing company?
Definition: company_func.h:53
CalcEngineReliability
static void CalcEngineReliability(Engine *e)
Update Engine::reliability and (if needed) update the engine GUIs.
Definition: engine.cpp:574
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:60
EnginesMonthlyLoop
void EnginesMonthlyLoop()
Monthly update of the availability, reliability, and preview offers of the engines.
Definition: engine.cpp:1029
error.h
EngineIDMapping
Definition: engine_base.h:163
EngineInfo::retire_early
int8 retire_early
Number of years early to retire vehicle.
Definition: engine_type.h:144
DAYS_IN_LEAP_YEAR
static const int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
Definition: date_type.h:30
EngineIDMapping::substitute_id
uint8 substitute_id
The (original) entity ID to use if this GRF is not available (currently not used)
Definition: engine_base.h:167
Engine::GetCost
Money GetCost() const
Return how much a new engine costs.
Definition: engine.cpp:317
date_func.h
stdafx.h
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
PROP_AIRCRAFT_COST_FACTOR
@ PROP_AIRCRAFT_COST_FACTOR
Purchase cost.
Definition: newgrf_properties.h:48
ENGINE_AVAILABLE
@ ENGINE_AVAILABLE
This vehicle is available to everyone.
Definition: engine_type.h:168
EngineInfo::misc_flags
byte misc_flags
Miscellaneous flags.
Definition: engine_type.h:142
PROP_SHIP_RUNNING_COST_FACTOR
@ PROP_SHIP_RUNNING_COST_FACTOR
Yearly runningcost.
Definition: newgrf_properties.h:45
RAILVEH_WAGON
@ RAILVEH_WAGON
simple wagon, not motorized
Definition: engine_type.h:29
CBM_VEHICLE_REFIT_CAPACITY
@ CBM_VEHICLE_REFIT_CAPACITY
Cargo capacity after refit.
Definition: newgrf_callbacks.h:292
Engine::reliability_final
uint16 reliability_final
Final reliability of the engine.
Definition: engine_base.h:29
_engine_offsets
const uint8 _engine_offsets[4]
Offset of the first engine of each vehicle type in original engine data.
Definition: engine.cpp:58
IsUniqueEngineName
static bool IsUniqueEngineName(const char *name)
Is name still free as name for an engine?
Definition: engine.cpp:1071
GameSettings::ai
AISettings ai
what may the AI do?
Definition: settings_type.h:552
YearMonthDay::year
Year year
Year (0...)
Definition: date_type.h:104
string_func.h
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition: newgrf_callbacks.h:404
UnloadWagonOverrides
void UnloadWagonOverrides(Engine *e)
Unload all wagon override sprite groups.
Definition: newgrf_engine.cpp:73
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
AISettings::ai_disable_veh_ship
bool ai_disable_veh_ship
disable types for AI
Definition: settings_type.h:337
_current_company
CompanyID _current_company
Company currently doing an action.
Definition: company_cmd.cpp:47
vehicle_func.h
PROP_TRAIN_WEIGHT
@ PROP_TRAIN_WEIGHT
Weight in t (if dualheaded: for each single vehicle)
Definition: newgrf_properties.h:25
Engine::name
std::string name
Custom name of engine.
Definition: engine_base.h:22
Pool::PoolItem<&_vehicle_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:378
engine_gui.h
strings_func.h
Pool
Base class for all pools.
Definition: pool_type.hpp:81
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1165
Engine::CanCarryCargo
bool CanCarryCargo() const
Determines whether an engine can carry something.
Definition: engine.cpp:169
VehicleSettings::max_trains
UnitID max_trains
max trains in game per company
Definition: settings_type.h:458
SetRandomSeed
void SetRandomSeed(uint32 seed)
(Re)set the state of the random number generators.
Definition: random_func.cpp:65
WC_BUILD_VEHICLE
@ WC_BUILD_VEHICLE
Build vehicle; Window numbers:
Definition: window_type.h:376
SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From
static Aircraft * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Definition: vehicle_base.h:1162
Engine::GetPower
uint GetPower() const
Returns the power of the engine for display and sorting purposes.
Definition: engine.cpp:389
RAILTYPE_END
@ RAILTYPE_END
Used for iterations.
Definition: rail_type.h:33
EF_NO_DEFAULT_CARGO_MULTIPLIER
@ EF_NO_DEFAULT_CARGO_MULTIPLIER
Use the new capacity algorithm. The default cargotype of the vehicle does not affect capacity multipl...
Definition: engine_type.h:159
InvalidateWindowClassesData
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Definition: window.cpp:3339
Aircraft::IsNormalAircraft
bool IsNormalAircraft() const
Check if the aircraft type is a normal flying device; eg not a rotor or a shadow.
Definition: aircraft.h:121
EngineOverrideManager
Stores the mapping of EngineID to the internal id of newgrfs.
Definition: engine_base.h:174
RAILVEH_MULTIHEAD
@ RAILVEH_MULTIHEAD
indicates a combination of two locomotives
Definition: engine_type.h:28
TRANSPORT_WATER
@ TRANSPORT_WATER
Transport over water.
Definition: transport_type.h:29
GetCompanyRailtypes
RailTypes GetCompanyRailtypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
Definition: rail.cpp:251
AISettings::ai_disable_veh_aircraft
bool ai_disable_veh_aircraft
disable types for AI
Definition: settings_type.h:336
newgrf.h
Pool::PoolItem<&_engine_pool >::CanAllocateItem
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
Definition: pool_type.hpp:299
DAYS_IN_YEAR
static const int DAYS_IN_YEAR
days per year
Definition: date_type.h:29
GetRoadTypeInfo
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Definition: road.h:224
TRANSPORT_AIR
@ TRANSPORT_AIR
Transport through air.
Definition: transport_type.h:30
NewVehicleAvailable
static void NewVehicleAvailable(Engine *e)
An engine has become available for general use.
Definition: engine.cpp:961
PROP_ROADVEH_CARGO_CAPACITY
@ PROP_ROADVEH_CARGO_CAPACITY
Capacity.
Definition: newgrf_properties.h:33
OWNER_DEITY
@ OWNER_DEITY
The object is owned by a superuser / goal script.
Definition: company_type.h:27
GameCreationSettings::starting_year
Year starting_year
starting date
Definition: settings_type.h:283
company_func.h
VehicleSettings::max_roadveh
UnitID max_roadveh
max trucks in game per company
Definition: settings_type.h:459
Engine::original_image_index
uint8 original_image_index
Original vehicle image index, thus the image index of the overridden vehicle.
Definition: engine_base.h:39
INSTANTIATE_POOL_METHODS
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
Definition: pool_func.hpp:224
CargoSpec::multiplier
uint16 multiplier
Capacity multiplier for vehicles. (8 fractional bits)
Definition: cargotype.h:61
AddNewsItem
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1=NR_NONE, uint32 ref1=UINT32_MAX, NewsReferenceType reftype2=NR_NONE, uint32 ref2=UINT32_MAX, void *free_data=nullptr)
Add a new newsitem to be shown.
Definition: news_gui.cpp:789
AIR_CTOL
@ AIR_CTOL
Conventional Take Off and Landing, i.e. planes.
Definition: engine_type.h:92
window_func.h
NF_VEHICLE
@ NF_VEHICLE
Vehicle news item. (new engine available)
Definition: news_type.h:79
SetBit
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:367
YearMonthDay
Data structure to convert between Date and triplet (year, month, and day).
Definition: date_type.h:103
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1619
CBID_VEHICLE_REFIT_CAPACITY
@ CBID_VEHICLE_REFIT_CAPACITY
Refit capacity, the passed vehicle needs to have its ->cargo_type set to the cargo we are refitting t...
Definition: newgrf_callbacks.h:48
random_func.hpp
Engine::DetermineCapacity
uint DetermineCapacity(const Vehicle *v, uint16 *mail_capacity=nullptr) const
Determines capacity of a given vehicle from scratch.
Definition: engine.cpp:202
OverflowSafeInt< int64, INT64_MAX, INT64_MIN >
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
VehicleSettings::never_expire_vehicles
bool never_expire_vehicles
never expire vehicles
Definition: settings_type.h:465
Engine::IsEnabled
bool IsEnabled() const
Checks whether the engine is a valid (non-articulated part of an) engine.
Definition: engine.cpp:148
INVALID_COMPANY
@ INVALID_COMPANY
An invalid company.
Definition: company_type.h:30
PROP_SHIP_COST_FACTOR
@ PROP_SHIP_COST_FACTOR
Purchase cost.
Definition: newgrf_properties.h:42
engine_base.h
Vehicle::cargo_type
CargoID cargo_type
type of cargo this vehicle is carrying
Definition: vehicle_base.h:314
Engine::grf_prop
GRFFilePropsBase< NUM_CARGO+2 > grf_prop
Properties related the the grf file.
Definition: engine_base.h:58
GRFFilePropsBase::local_id
uint16 local_id
id defined by the grf file for this entity
Definition: newgrf_commons.h:319
articulated_vehicles.h
GameSettings::vehicle
VehicleSettings vehicle
options for vehicles
Definition: settings_type.h:558
Vehicle::cargo_subtype
byte cargo_subtype
Used for livery refits (NewGRF variations)
Definition: vehicle_base.h:315
EngineInfo::climates
byte climates
Climates supported by the engine.
Definition: engine_type.h:138
PROP_SHIP_SPEED
@ PROP_SHIP_SPEED
Max. speed: 1 unit = 1/3.2 mph = 0.5 km-ish/h.
Definition: newgrf_properties.h:43
PROP_AIRCRAFT_PASSENGER_CAPACITY
@ PROP_AIRCRAFT_PASSENGER_CAPACITY
Passenger Capacity.
Definition: newgrf_properties.h:51
IsEngineRefittable
bool IsEngineRefittable(EngineID engine)
Check if an engine is refittable.
Definition: engine.cpp:1164
PROP_ROADVEH_POWER
@ PROP_ROADVEH_POWER
Power in 10 HP.
Definition: newgrf_properties.h:35
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
Pool::PoolItem<&_engine_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:318
PROP_TRAIN_COST_FACTOR
@ PROP_TRAIN_COST_FACTOR
Purchase cost (if dualheaded: sum of both vehicles)
Definition: newgrf_properties.h:26
PROP_AIRCRAFT_SPEED
@ PROP_AIRCRAFT_SPEED
Max. speed: 1 unit = 8 mph = 12.8 km-ish/h.
Definition: newgrf_properties.h:49
engines.h
Engine::GetRange
uint16 GetRange() const
Get the range of an aircraft type.
Definition: engine.cpp:452
EngineIDMapping::type
VehicleType type
The engine type.
Definition: engine_base.h:166
Engine::flags
byte flags
Flags of the engine.
Definition: engine_base.h:33
pool_func.hpp
EngineInfo::string_id
StringID string_id
Default name of engine.
Definition: engine_type.h:145
ClearEnginesHiddenFlagOfCompany
void ClearEnginesHiddenFlagOfCompany(CompanyID cid)
Clear the 'hidden' flag for all engines of a new company.
Definition: engine.cpp:875
CmdSetVehicleVisibility
CommandCost CmdSetVehicleVisibility(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Set the visibility of an engine.
Definition: engine.cpp:891
CT_INVALID
@ CT_INVALID
Invalid cargo type.
Definition: cargo_type.h:68
IsCargoInClass
static bool IsCargoInClass(CargoID c, CargoClass cc)
Does cargo c have cargo class cc?
Definition: cargotype.h:148
PROP_TRAIN_POWER
@ PROP_TRAIN_POWER
Power in hp (if dualheaded: sum of both vehicles)
Definition: newgrf_properties.h:22
CmdWantEnginePreview
CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Accept an engine prototype.
Definition: engine.cpp:915
AddRemoveEngineFromAutoreplaceAndBuildWindows
void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
When an engine is made buildable or is removed from being buildable, add/remove it from the build/aut...
Definition: autoreplace_gui.cpp:63
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
ROADTYPES_NONE
@ ROADTYPES_NONE
No roadtypes.
Definition: road_type.h:37
Company
Definition: company_base.h:110
PROP_ROADVEH_RUNNING_COST_FACTOR
@ PROP_ROADVEH_RUNNING_COST_FACTOR
Yearly runningcost.
Definition: newgrf_properties.h:32
WC_MAIN_TOOLBAR
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
Definition: window_type.h:51
SetWindowClassesDirty
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
Definition: window.cpp:3248
PROP_AIRCRAFT_RANGE
@ PROP_AIRCRAFT_RANGE
Aircraft range.
Definition: newgrf_properties.h:54
EngineInfo::cargo_age_period
uint16 cargo_age_period
Number of ticks before carried cargo is aged.
Definition: engine_type.h:146
SetYearEngineAgingStops
void SetYearEngineAgingStops()
Compute the value for _year_engine_aging_stops.
Definition: engine.cpp:612
IsEngineBuildable
bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company)
Check if an engine is buildable.
Definition: engine.cpp:1123
Engine::intro_date
Date intro_date
Date of introduction of the engine.
Definition: engine_base.h:23
Engine::GetAircraftTypeText
StringID GetAircraftTypeText() const
Get the name of the aircraft type for display purposes.
Definition: engine.cpp:466
EngineOverrideManager::NUM_DEFAULT_ENGINES
static const uint NUM_DEFAULT_ENGINES
Number of default entries.
Definition: engine_base.h:175
NR_ENGINE
@ NR_ENGINE
Reference engine.
Definition: news_type.h:56
GRFFile
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:105
Engine::reliability
uint16 reliability
Current reliability of the engine.
Definition: engine_base.h:25
Engine::type
VehicleType type
Vehicle type, ie VEH_ROAD, VEH_TRAIN, etc.
Definition: engine_base.h:40
AcceptEnginePreview
static void AcceptEnginePreview(EngineID eid, CompanyID company)
Company company accepts engine eid for preview.
Definition: engine.cpp:763
Engine::duration_phase_2
uint16 duration_phase_2
Second reliability phase in months, keeping reliability_max.
Definition: engine_base.h:31
PROP_ROADVEH_WEIGHT
@ PROP_ROADVEH_WEIGHT
Weight in 1/4 t.
Definition: newgrf_properties.h:36
engine_func.h
news_func.h
RailtypeInfo::introduces_railtypes
RailTypes introduces_railtypes
Bitmask of which other railtypes are introduced when this railtype is introduced.
Definition: rail.h:263