37#include "table/strings.h"
58 lengthof(_orig_aircraft_vehicle_info),
75 this->list_position = base;
86 if (
type ==
VEH_ROAD) this->u.road.tractive_effort = 0x4C;
88 this->info.cargo_type = INVALID_CARGO;
111 default: NOT_REACHED();
114 this->u.rail = _orig_rail_vehicle_info[base];
116 this->info.
string_id = STR_VEHICLE_NAME_TRAIN_ENGINE_RAIL_KIRBY_PAUL_TANK_STEAM + base;
124 this->u.road = _orig_road_vehicle_info[base];
126 this->info.
string_id = STR_VEHICLE_NAME_ROAD_VEHICLE_MPS_REGAL_BUS + base;
130 this->u.ship = _orig_ship_vehicle_info[base];
132 this->info.
string_id = STR_VEHICLE_NAME_SHIP_MPS_OIL_TANKER + base;
136 this->u.air = _orig_aircraft_vehicle_info[base];
138 this->info.
string_id = STR_VEHICLE_NAME_AIRCRAFT_SAMPSON_U52 + base;
160 return file ==
nullptr ? 0 : file->grfid;
175 switch (this->type) {
177 if (this->u.rail.capacity == 0)
return false;
181 if (this->u.road.capacity == 0)
return false;
188 default: NOT_REACHED();
204 if (mail_capacity !=
nullptr) *mail_capacity = 0;
218 (new_multipliers || default_cargo != cargo_type || (v !=
nullptr && v->
cargo_subtype != 0))) {
225 uint extra_mail_cap = 0;
226 switch (this->type) {
231 if (v ==
nullptr && this->u.rail.railveh_type ==
RAILVEH_MULTIHEAD) capacity += this->u.rail.capacity;
248 if (!new_multipliers && cargo_type == GetCargoIDByLabel(CT_MAIL))
return capacity + extra_mail_cap;
253 default: NOT_REACHED();
256 if (!new_multipliers) {
258 capacity += extra_mail_cap;
263 if (new_multipliers || (this->type !=
VEH_SHIP && default_cargo != cargo_type)) {
266 capacity *= cargo_multiplier;
267 if (extra_mail_cap > 0 &&
IsValidCargoID(GetCargoIDByLabel(CT_MAIL))) {
269 capacity += (default_multiplier * extra_mail_cap * cargo_multiplier + mail_multiplier / 2) / mail_multiplier;
271 capacity = (capacity + default_multiplier / 2) / default_multiplier;
285 switch (this->type) {
287 base_price = this->u.road.running_cost_class;
288 if (base_price == INVALID_PRICE)
return 0;
293 base_price = this->u.rail.running_cost_class;
294 if (base_price == INVALID_PRICE)
return 0;
299 base_price = PR_RUNNING_SHIP;
304 base_price = PR_RUNNING_AIRCRAFT;
308 default: NOT_REACHED();
322 switch (this->type) {
324 base_price = PR_BUILD_VEHICLE_ROAD;
330 base_price = PR_BUILD_VEHICLE_WAGON;
333 base_price = PR_BUILD_VEHICLE_TRAIN;
339 base_price = PR_BUILD_VEHICLE_SHIP;
344 base_price = PR_BUILD_VEHICLE_AIRCRAFT;
348 default: NOT_REACHED();
360 switch (this->type) {
366 return (max_speed != 0) ? max_speed * 2 : this->u.road.max_speed / 2;
374 if (max_speed != 0) {
375 return (max_speed * 128) / 10;
377 return this->u.air.max_speed;
380 default: NOT_REACHED();
393 switch (this->type) {
399 default: NOT_REACHED();
411 switch (this->type) {
417 default: NOT_REACHED();
429 switch (this->type) {
435 default: NOT_REACHED();
455 switch (this->type) {
459 default: NOT_REACHED();
469 switch (this->type) {
471 switch (this->u.air.subtype) {
472 case AIR_HELI:
return STR_LIVERY_HELICOPTER;
473 case AIR_CTOL:
return STR_LIVERY_SMALL_PLANE;
474 case AIR_CTOL | AIR_FAST:
return STR_LIVERY_LARGE_PLANE;
475 default: NOT_REACHED();
478 default: NOT_REACHED();
513 auto &map = this->mappings[type];
515 for (uint internal_id = 0; internal_id <
_engine_counts[type]; internal_id++,
id++) {
516 map.emplace_back(INVALID_GRFID, internal_id, type, internal_id,
id);
532 const auto &map = this->mappings[type];
533 const auto key = EngineIDMapping::Key(grfid, grf_local_id);
535 if (it == std::end(map) || it->Key() != key)
return INVALID_ENGINE;
551 auto &map = _engine_mngr.mappings[type];
552 const auto key = EngineIDMapping::Key(INVALID_GRFID, grf_local_id);
554 if (it == std::end(map) || it->Key() != key)
return INVALID_ENGINE;
556 if (!static_access && grfid != INVALID_GRFID) {
562 it =
Slide(it, std::next(it), p).first;
568void EngineOverrideManager::SetID(
VehicleType type, uint16_t grf_local_id, uint32_t grfid, uint8_t substitute_id,
EngineID engine)
570 auto &map = this->mappings[type];
571 const auto key = EngineIDMapping::Key(grfid, grf_local_id);
573 if (it == std::end(map) || it->Key() != key) {
574 map.emplace(it, grfid, grf_local_id, type, substitute_id, engine);
607 const auto &mapping = _engine_mngr.mappings[type];
613 new (eid.engine)
Engine(type, eid.internal_id);
618void ShowEnginePreviewWindow(
EngineID engine);
639 if (e->display_last_variant == engine_id) e->display_last_variant =
INVALID_ENGINE;
655 uint32_t age = re->
age;
656 if (new_month && re->
index > e->
index && age != INT32_MAX) age++;
662 if (retire_early != 0 && age >= retire_early_max_age) {
670 if (age < e->duration_phase_1) {
735 uint32_t r = Random();
743 int aging_months = aging_ymd.year.base() * 12 + aging_ymd.month;
744 int intro_months = intro_ymd.year.base() * 12 + intro_ymd.month;
745 if (intro_ymd.day > 1) intro_months++;
746 e->
age = aging_months - intro_months;
758 (re->
index << 16) ^ (re->info.
base_intro.base() << 12) ^ (re->info.decay_speed << 8) ^
764 const uint16_t RELIABILITY_START = UINT16_MAX * 48 / 100;
765 const uint16_t RELIABILITY_MAX = UINT16_MAX * 75 / 100;
766 const uint16_t RELIABILITY_FINAL = UINT16_MAX * 25 / 100;
768 static_assert(RELIABILITY_START == 0x7AE0);
769 static_assert(RELIABILITY_MAX == 0xBFFF);
770 static_assert(RELIABILITY_FINAL == 0x3FFF);
804 uint32_t seed = Random();
900 if (recursion_depth >= 10)
return;
922 int32_t best_hist = -1;
925 c->old_economy[0].performance_history > best_hist) {
929 if (v->owner != c->index || v->type != e->
type)
continue;
930 if (!v->GetEngine()->CanCarryCargo() || !
HasBit(cargomask, v->cargo_type))
continue;
932 best_hist = c->old_economy[0].performance_history;
933 best_company = c->index;
957 default: NOT_REACHED();
975 if (!--e->preview_wait) {
987 SetBit(e->preview_asked, e->preview_company);
988 e->preview_wait = 20;
1008 SB(e->company_hidden, cid, 1, 0);
1088 uint block_preview = c->block_preview;
1093 c->block_preview = 20;
1098 if (v->owner == c->index && v->engine_type == index) {
1100 c->block_preview = block_preview;
1150 bool refresh =
false;
1160 if (!e->IsEnabled())
continue;
1173 if (
IsWagon(e->index))
continue;
1181 e->preview_asked = 0;
1207 if (!e->name.empty() && e->name == name)
return false;
1225 bool reset = text.empty();
1259 if (e ==
nullptr)
return false;
1262 if (e->
type != type)
return false;
1300 if (e ==
nullptr)
return false;
1305 if (ei->refit_mask == 0)
return false;
1313 CargoTypes default_cargo_mask = 0;
1314 SetBit(default_cargo_mask, default_cargo);
1315 return IsValidCargoID(default_cargo) && ei->refit_mask != default_cargo_mask;
1323 TimerGameCalendar::Date min_date = INT32_MAX;
1326 if (!e->IsEnabled())
continue;
1335 min_date = std::min(min_date, e->info.base_intro);
1338 if (min_date < INT32_MAX) {
Base functions for all AIs.
CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
Ors the refit_masks of all articulated parts.
Functions related to articulated vehicles.
void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
When an engine is made buildable or is removed from being buildable, add/remove it from the build/aut...
Functions related to the autoreplace GUIs.
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T AssignBit(T &x, const uint8_t y, bool value)
Assigns a bit in a variable.
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr uint CountBits(T value)
Counts the number of set bits in a variable.
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
static constexpr CargoLabel CT_INVALID
Invalid cargo type.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
static constexpr CargoLabel CT_PASSENGERS
Available types of cargo Labels may be re-used between different climates.
bool IsCargoInClass(CargoID c, CargoClass cc)
Does cargo c have cargo class cc?
@ CC_PASSENGERS
Passengers.
static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company=MAX_COMPANIES)
Broadcast a new event to all active AIs.
static void NewEvent(CompanyID company, ScriptEvent *event)
Queue a new event for an AI.
Common return value for all commands.
An interval timer will fire every interval, and will continue to fire until it is deleted.
RailTypes introduces_railtypes
Bitmask of which other railtypes are introduced when this railtype is introduced.
RoadTypes powered_roadtypes
bitmask to the OTHER roadtypes on which a vehicle of THIS roadtype generates power
RoadTypes introduces_roadtypes
Bitmask of which other roadtypes are introduced when this roadtype is introduced.
static constexpr TimerGameTick::Ticks CARGO_AGING_TICKS
Cycle duration for aging cargo.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
static Date date
Current date in days (day counter).
static Year year
Current year, starting at 0.
static constexpr int DAYS_IN_YEAR
days per year
static constexpr int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
Functions related to commands.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
DoCommandFlag
List of flags for a command.
@ DC_EXEC
execute the given command
Definition of stuff that is very close to a company, like the company struct itself.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
CompanyID _current_company
Company currently doing an action.
Functions related to companies.
bool IsInteractiveCompany(CompanyID company)
Is the user representing company?
Owner
Enum for all companies/owners.
@ INVALID_COMPANY
An invalid company.
@ OWNER_DEITY
The object is owned by a superuser / goal script.
@ MAX_COMPANIES
Maximum number of companies.
Some simple functions to help with accessing containers.
auto Slide(TIter first, TIter last, TIter position) -> std::pair< TIter, TIter >
Move elements between first and last to a new position, rotating elements in between as necessary.
Money GetPrice(Price index, uint cost_factor, const GRFFile *grf_file, int shift)
Determine a certain price.
Price
Enumeration of all base prices for use with Prices.
void ClearEnginesHiddenFlagOfCompany(CompanyID cid)
Clear the 'hidden' flag for all engines of a new company.
void SetYearEngineAgingStops()
Compute the value for _year_engine_aging_stops.
static void NewVehicleAvailable(Engine *e)
An engine has become available for general use.
const uint8_t _engine_counts[4]
Number of engines of each vehicle type in original engine data.
void SetupEngines()
Initialise the engine pool with the data from the original vehicles.
CommandCost CmdSetVehicleVisibility(DoCommandFlag flags, EngineID engine_id, bool hide)
Set the visibility of an engine.
static CompanyID GetPreviewCompany(Engine *e)
Get the best company for an engine preview.
const uint8_t _engine_offsets[4]
Offset of the first engine of each vehicle type in original engine data.
static void ClearLastVariant(EngineID engine_id, VehicleType type)
Ensure engine is not set as the last used variant for any other engine.
static bool IsVehicleTypeDisabled(VehicleType type, bool ai)
Checks if a vehicle type is disabled for all/ai companies.
CommandCost CmdWantEnginePreview(DoCommandFlag flags, EngineID engine_id)
Accept an engine prototype.
CommandCost CmdEngineCtrl(DoCommandFlag flags, EngineID engine_id, CompanyID company_id, bool allow)
Allow or forbid a specific company to use an engine.
static void AcceptEnginePreview(EngineID eid, CompanyID company, int recursion_depth=0)
Company company accepts engine eid for preview.
void CalendarEnginesMonthlyLoop()
Monthly update of the availability, reliability, and preview offers of the engines.
static bool IsUniqueEngineName(const std::string &name)
Is name still free as name for an engine?
bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company)
Check if an engine is buildable.
static TimerGameCalendar::Year _year_engine_aging_stops
Year that engine aging stops.
static void DisableEngineForCompany(EngineID eid, CompanyID company)
Forbids engine eid to be used by a company company.
void StartupEngines()
Start/initialise all our engines.
static bool IsWagon(EngineID index)
Determine whether an engine type is a wagon (and not a loco).
void StartupOneEngine(Engine *e, const TimerGameCalendar::YearMonthDay &aging_ymd, uint32_t seed)
Start/initialise one engine.
void CheckEngines()
Check for engines that have an appropriate availability.
bool IsEngineRefittable(EngineID engine)
Check if an engine is refittable.
static IntervalTimer< TimerGameCalendar > _calendar_engines_daily({TimerGameCalendar::DAY, TimerGameCalendar::Priority::ENGINE}, [](auto) { for(Company *c :Company::Iterate()) { c->avail_railtypes=AddDateIntroducedRailTypes(c->avail_railtypes, TimerGameCalendar::date);c->avail_roadtypes=AddDateIntroducedRoadTypes(c->avail_roadtypes, TimerGameCalendar::date);} if(TimerGameCalendar::year >=_year_engine_aging_stops) return;for(Engine *e :Engine::Iterate()) { EngineID i=e->index;if(e->flags &ENGINE_EXCLUSIVE_PREVIEW) { if(e->preview_company !=INVALID_COMPANY) { if(!--e->preview_wait) { CloseWindowById(WC_ENGINE_PREVIEW, i);e->preview_company=INVALID_COMPANY;} } else if(CountBits(e->preview_asked)< MAX_COMPANIES) { e->preview_company=GetPreviewCompany(e);if(e->preview_company==INVALID_COMPANY) { e->preview_asked=MAX_UVALUE(CompanyMask);continue;} SetBit(e->preview_asked, e->preview_company);e->preview_wait=20;if(!IsVehicleTypeDisabled(e->type, true)) AI::NewEvent(e->preview_company, new ScriptEventEnginePreview(i));if(IsInteractiveCompany(e->preview_company)) ShowEnginePreviewWindow(i);} } } })
Daily check to offer an exclusive engine preview to the companies.
void CalcEngineReliability(Engine *e, bool new_month)
Update Engine::reliability and (if needed) update the engine GUIs.
static void EnableEngineForCompany(EngineID eid, CompanyID company)
Allows engine eid to be used by a company company.
CommandCost CmdRenameEngine(DoCommandFlag flags, EngineID engine_id, const std::string &text)
Rename an engine.
Functions related to engines.
StringID GetEngineCategoryName(EngineID engine)
Return the category of an engine.
Engine GUI functions, used by build_vehicle_gui and autoreplace_gui
@ SyncReliability
Engine reliability will be synced with variant parent.
@ NoNews
No 'new vehicle' news will be generated.
@ JoinPreview
Engine will join exclusive preview with variant parent.
@ NoPreview
No exclusive preview will be offered.
static const uint MAX_LENGTH_ENGINE_NAME_CHARS
The maximum length of an engine name in characters including '\0'.
static const EngineID INVALID_ENGINE
Constant denoting an invalid engine.
uint16_t EngineID
Unique identification number of an engine.
@ AIR_CTOL
Conventional Take Off and Landing, i.e. planes.
uint64_t PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32_t extra_data=0)
Combine an engine ID and a name context to an engine name dparam.
@ ENGINE_EXCLUSIVE_PREVIEW
This vehicle is in the exclusive preview stage, either being used or being offered to a company.
@ ENGINE_AVAILABLE
This vehicle is available to everyone.
@ EF_NO_DEFAULT_CARGO_MULTIPLIER
Use the new capacity algorithm. The default cargotype of the vehicle does not affect capacity multipl...
@ PreviewNews
Name is shown in exclusive preview or newspaper.
@ RAILVEH_WAGON
simple wagon, not motorized
@ RAILVEH_MULTIHEAD
indicates a combination of two locomotives
This file contains all the data for vehicles.
debug_inline constexpr bool HasFlag(const T x, const T y)
Checks if a value in a bitset enum is set.
Functions related to errors.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
@ WL_WARNING
Other information.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Base for the NewGRF implementation.
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
@ CBID_VEHICLE_REFIT_CAPACITY
Refit capacity, the passed vehicle needs to have its ->cargo_type set to the cargo we are refitting t...
@ CBM_VEHICLE_CARGO_SUFFIX
Show suffix after cargo name.
@ CBM_VEHICLE_REFIT_CAPACITY
Cargo capacity after refit.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
uint16_t GetVehicleCallback(CallbackID callback, uint32_t param1, uint32_t param2, EngineID engine, const Vehicle *v)
Evaluate a newgrf callback for vehicles.
Functions for NewGRF engines.
@ PROP_AIRCRAFT_PASSENGER_CAPACITY
Passenger Capacity.
@ PROP_ROADVEH_WEIGHT
Weight in 1/4 t.
@ PROP_TRAIN_COST_FACTOR
Purchase cost (if dualheaded: sum of both vehicles)
@ PROP_TRAIN_WEIGHT
Weight in t (if dualheaded: for each single vehicle)
@ PROP_AIRCRAFT_RANGE
Aircraft range.
@ PROP_TRAIN_CARGO_CAPACITY
Capacity (if dualheaded: for each single vehicle)
@ PROP_AIRCRAFT_RUNNING_COST_FACTOR
Yearly runningcost.
@ PROP_ROADVEH_RUNNING_COST_FACTOR
Yearly runningcost.
@ PROP_TRAIN_TRACTIVE_EFFORT
Tractive effort coefficient in 1/256.
@ PROP_SHIP_CARGO_CAPACITY
Capacity.
@ PROP_ROADVEH_TRACTIVE_EFFORT
Tractive effort coefficient in 1/256.
@ PROP_SHIP_COST_FACTOR
Purchase cost.
@ PROP_ROADVEH_CARGO_CAPACITY
Capacity.
@ PROP_AIRCRAFT_SPEED
Max. speed: 1 unit = 8 mph = 12.8 km-ish/h.
@ PROP_AIRCRAFT_MAIL_CAPACITY
Mail Capacity.
@ PROP_SHIP_SPEED
Max. speed: 1 unit = 1/3.2 mph = 0.5 km-ish/h.
@ PROP_SHIP_RUNNING_COST_FACTOR
Yearly runningcost.
@ PROP_ROADVEH_COST_FACTOR
Purchase cost.
@ PROP_ROADVEH_POWER
Power in 10 HP.
@ PROP_AIRCRAFT_COST_FACTOR
Purchase cost.
@ PROP_TRAIN_RUNNING_COST_FACTOR
Yearly runningcost (if dualheaded: sum of both vehicles)
@ PROP_TRAIN_POWER
Power in hp (if dualheaded: sum of both vehicles)
@ PROP_TRAIN_SPEED
Max. speed: 1 unit = 1/1.6 mph = 1 km-ish/h.
@ PROP_ROADVEH_SPEED
Max. speed: 1 unit = 1/0.8 mph = 2 km-ish/h.
Functions related to news.
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1=NR_NONE, uint32_t ref1=UINT32_MAX, NewsReferenceType reftype2=NR_NONE, uint32_t ref2=UINT32_MAX, std::unique_ptr< NewsAllocatedData > &&data=nullptr)
Add a new newsitem to be shown.
@ NT_NEW_VEHICLES
New vehicle has become available.
@ NR_ENGINE
Reference engine.
@ NF_VEHICLE
Vehicle news item. (new engine available)
Some methods of Pool are placed here in order to reduce compilation time and binary size.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
RailTypes GetCompanyRailTypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
RailTypes AddDateIntroducedRailTypes(RailTypes current, TimerGameCalendar::Date date)
Add the rail types that are to be introduced at the given date.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
@ RAILTYPE_END
Used for iterations.
void SetRandomSeed(uint32_t seed)
(Re)set the state of the random number generators.
Pseudo random number generator.
void SaveRandomSeeds(SavedRandomSeeds *storage)
Saves the current seeds.
void RestoreRandomSeeds(const SavedRandomSeeds &storage)
Restores previously saved seeds.
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, TimerGameCalendar::Date date)
Add the road types that are to be introduced at the given date.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
@ ROADTYPES_NONE
No roadtypes.
@ ROADTYPE_END
Used for iterations.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of base types and functions in a cross-platform compatible way.
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
#define lengthof(array)
Return the length of an fixed size array.
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...
Functions related to low-level strings.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
bool ai_disable_veh_roadveh
disable types for AI
bool ai_disable_veh_ship
disable types for AI
bool ai_disable_veh_train
disable types for AI
bool ai_disable_veh_aircraft
disable types for AI
bool IsNormalAircraft() const
Check if the aircraft type is a normal flying device; eg not a rotor or a shadow.
uint16_t multiplier
Capacity multiplier for vehicles. (8 fractional bits)
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
RoadTypes avail_roadtypes
Road types available to this company.
RailTypes avail_railtypes
Rail types available to this company.
Projection to get a unique key of an EngineIDMapping, used for sorting in EngineOverrideManager.
Information about a vehicle.
uint16_t cargo_age_period
Number of ticks before carried cargo is aged.
TimerGameCalendar::Year base_life
Basic duration of engine availability (without random parts). 0xFF means infinite life.
EngineID variant_id
Engine variant ID. If set, will be treated specially in purchase lists.
uint8_t misc_flags
Miscellaneous flags.
StringID string_id
Default name of engine.
uint8_t climates
Climates supported by the engine.
TimerGameCalendar::Date base_intro
Basic date of engine introduction (without random parts).
uint16_t callback_mask
Bitmask of vehicle callbacks that have to be called.
int8_t retire_early
Number of years early to retire vehicle.
TimerGameCalendar::Year lifelength
Lifetime of a single vehicle.
Stores the mapping of EngineID to the internal id of newgrfs.
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
void ResetToDefaultMapping()
Initializes the EngineOverrideManager with the default engines.
EngineID UseUnreservedID(VehicleType type, uint16_t grf_local_id, uint32_t grfid, bool static_access)
Look for an unreserved EngineID matching the local id, and reserve it if found.
EngineID GetID(VehicleType type, uint16_t grf_local_id, uint32_t grfid)
Looks up an EngineID in the EngineOverrideManager.
StringID GetAircraftTypeText() const
Get the name of the aircraft type for display purposes.
uint GetPower() const
Returns the power of the engine for display and sorting purposes.
const Engine * GetDisplayVariant() const
Get the last display variant for an engine.
CargoID GetDefaultCargoType() const
Determines the default cargo type of an engine.
uint16_t GetRange() const
Get the range of an aircraft type.
GRFFilePropsBase< NUM_CARGO+2 > grf_prop
Properties related the the grf file.
uint32_t GetGRFID() const
Retrieve the GRF ID of the NewGRF the engine is tied to.
uint16_t reliability_spd_dec
Speed of reliability decay between services (per day).
Money GetCost() const
Return how much a new engine costs.
uint16_t reliability_start
Initial reliability of the engine.
TimerGameCalendar::Date intro_date
Date of introduction of the engine.
const GRFFile * GetGRF() const
Retrieve the NewGRF the engine is tied to.
static Pool::IterateWrapperFiltered< Engine, EngineTypeFilter > IterateType(VehicleType vt, size_t from=0)
Returns an iterable ensemble of all valid engines of the given type.
uint GetDisplayMaxSpeed() const
Returns max speed of the engine for display purposes.
uint DetermineCapacity(const Vehicle *v, uint16_t *mail_capacity=nullptr) const
Determines capacity of a given vehicle from scratch.
CompanyMask company_avail
Bit for each company whether the engine is available for that company.
uint16_t reliability_max
Maximal reliability of the engine.
uint GetDisplayWeight() const
Returns the weight of the engine for display purposes.
uint8_t original_image_index
Original vehicle image index, thus the image index of the overridden vehicle.
bool IsEnabled() const
Checks whether the engine is a valid (non-articulated part of an) engine.
VehicleType type
Vehicle type, ie VEH_ROAD, VEH_TRAIN, etc.
bool IsVariantHidden(CompanyID c) const
Check whether the engine variant chain is hidden in the GUI for the given company.
uint16_t reliability_final
Final reliability of the engine.
CompanyID preview_company
Company which is currently being offered a preview INVALID_COMPANY means no company.
TimerGameCalendar::Date GetLifeLengthInDays() const
Returns the vehicle's (not model's!) life length in days.
uint16_t duration_phase_3
Third reliability phase in months, decaying to reliability_final.
uint16_t duration_phase_2
Second reliability phase in months, keeping reliability_max.
CompanyMask company_hidden
Bit for each company whether the engine is normally hidden in the build gui for that company.
Money GetRunningCost() const
Return how much the running costs of this engine are.
uint16_t reliability
Current reliability of the engine.
CompanyMask preview_asked
Bit for each company which has already been offered a preview.
uint GetDisplayMaxTractiveEffort() const
Returns the tractive effort of the engine for display purposes.
int32_t age
Age of the engine in months.
bool IsHidden(CompanyID c) const
Check whether the engine is hidden in the GUI for the given company.
bool CanCarryCargo() const
Determines whether an engine can carry something.
std::string name
Custom name of engine.
EngineID display_last_variant
NOSAVE client-side-only last variant selected.
uint16_t duration_phase_1
First reliability phase in months, increasing reliability from reliability_start to reliability_max.
uint8_t flags
Flags of the engine.
uint16_t local_id
id defined by the grf file for this entity
Dynamic data of a loaded NewGRF.
uint8_t landscape
the landscape we're currently in
TimerGameCalendar::Year starting_year
starting date
uint32_t generation_seed
noise seed for world generation
AISettings ai
what may the AI do?
GameCreationSettings game_creation
settings used during the creation of a game (map)
VehicleSettings vehicle
options for vehicles
Tindex index
Index of this pool item.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static Titem * Get(size_t index)
Returns Titem with given index.
Base class for all pools.
void CleanPool() override
Virtual method that deletes all items in the pool.
RailType railtype
Railtype, mangled if elrail is disabled.
RoadType roadtype
Road type.
Stores the state of all random number generators.
static Aircraft * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Templated helper to make a type-safe 'typedef' representing a single POD value.
UnitID max_ships
max ships in game per company
UnitID max_trains
max trains in game per company
uint8_t extend_vehicle_life
extend vehicle life by this many years
UnitID max_aircraft
max planes in game per company
UnitID max_roadveh
max trucks in game per company
bool never_expire_vehicles
never expire vehicles
EngineID engine_type
The type of engine used for this vehicle.
CargoID cargo_type
type of cargo this vehicle is carrying
uint8_t cargo_subtype
Used for livery refits (NewGRF variations)
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
Definition of the tick-based game-timer.
@ TRANSPORT_ROAD
Transport by road vehicle.
@ TRANSPORT_WATER
Transport over water.
@ TRANSPORT_AIR
Transport through air.
@ VE_DEFAULT
Default value to indicate that visual effect should be based on engine class.
Functions related to vehicles.
bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
VehicleType
Available vehicle types.
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_TRAIN
Train vehicle type.
@ VEH_COMPANY_END
Last company-ownable type.
static const int GROUND_ACCELERATION
Acceleration due to gravity, 9.8 m/s^2.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
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-...
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...
Window functions not directly related to making/drawing windows.
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
@ WC_REPLACE_VEHICLE
Replace vehicle window; Window numbers:
@ WC_ENGINE_PREVIEW
Engine preview window; Window numbers:
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
@ WC_BUILD_VEHICLE
Build vehicle; Window numbers: