36 #include "table/strings.h"
57 lengthof(_orig_aircraft_vehicle_info),
76 this->list_position = base;
87 if (
type ==
VEH_ROAD) this->u.road.tractive_effort = 0x4C;
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 for (uint internal_id = 0; internal_id <
_engine_counts[type]; internal_id++) {
516 eid.
grfid = INVALID_GRFID;
571 [[maybe_unused]] uint index = 0;
576 [[maybe_unused]]
const Engine *e =
new Engine(eid.type, eid.internal_id);
577 assert(e->
index == index);
582 void ShowEnginePreviewWindow(
EngineID engine);
603 if (e->display_last_variant == engine_id) e->display_last_variant =
INVALID_ENGINE;
619 uint32_t age = re->
age;
620 if (new_month && re->
index > e->
index && age != INT32_MAX) age++;
626 if (retire_early != 0 && age >= retire_early_max_age) {
634 if (age < e->duration_phase_1) {
699 uint32_t r = Random();
707 int aging_months = aging_ymd.year.base() * 12 + aging_ymd.month;
708 int intro_months = intro_ymd.year.base() * 12 + intro_ymd.month;
709 if (intro_ymd.day > 1) intro_months++;
710 e->
age = aging_months - intro_months;
722 (re->
index << 16) ^ (re->info.
base_intro.base() << 12) ^ (re->info.decay_speed << 8) ^
728 const uint16_t RELIABILITY_START = UINT16_MAX * 48 / 100;
729 const uint16_t RELIABILITY_MAX = UINT16_MAX * 75 / 100;
730 const uint16_t RELIABILITY_FINAL = UINT16_MAX * 25 / 100;
732 static_assert(RELIABILITY_START == 0x7AE0);
733 static_assert(RELIABILITY_MAX == 0xBFFF);
734 static_assert(RELIABILITY_FINAL == 0x3FFF);
768 uint32_t seed = Random();
864 if (recursion_depth >= 10)
return;
886 int32_t best_hist = -1;
889 c->old_economy[0].performance_history > best_hist) {
893 if (v->owner != c->index || v->type != e->
type)
continue;
894 if (!v->GetEngine()->CanCarryCargo() || !
HasBit(cargomask, v->cargo_type))
continue;
896 best_hist = c->old_economy[0].performance_history;
897 best_company = c->index;
921 default: NOT_REACHED();
939 if (!--e->preview_wait) {
951 SetBit(e->preview_asked, e->preview_company);
952 e->preview_wait = 20;
972 SB(e->company_hidden, cid, 1, 0);
1052 uint block_preview = c->block_preview;
1057 c->block_preview = 20;
1062 if (v->owner == c->index && v->engine_type == index) {
1064 c->block_preview = block_preview;
1114 bool refresh =
false;
1124 if (!e->IsEnabled())
continue;
1137 if (
IsWagon(e->index))
continue;
1145 e->preview_asked = 0;
1171 if (!e->name.empty() && e->name == name)
return false;
1189 bool reset = text.empty();
1223 if (e ==
nullptr)
return false;
1226 if (e->
type != type)
return false;
1264 if (e ==
nullptr)
return false;
1269 if (ei->refit_mask == 0)
return false;
1277 CargoTypes default_cargo_mask = 0;
1278 SetBit(default_cargo_mask, default_cargo);
1279 return IsValidCargoID(default_cargo) && ei->refit_mask != default_cargo_mask;
1287 TimerGameCalendar::Date min_date = INT32_MAX;
1290 if (!e->IsEnabled())
continue;
1299 min_date = std::min(min_date, e->info.base_intro);
1302 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.
constexpr debug_inline 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.
constexpr static debug_inline 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.
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.
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.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
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.
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.
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.
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.
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
@ RAILVEH_WAGON
simple wagon, not motorized
@ RAILVEH_MULTIHEAD
indicates a combination of two locomotives
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.
@ 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.
@ 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.
This file contains all the data for vehicles.
constexpr debug_inline 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, const 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.
VehicleType type
The engine type.
uint32_t grfid
The GRF ID of the file the entity belongs to.
uint8_t substitute_id
The (original) entity ID to use if this GRF is not available (currently not used)
uint16_t internal_id
The internal ID within the GRF file.
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 GetID(VehicleType type, uint16_t grf_local_id, uint32_t grfid)
Looks up an EngineID in the EngineOverrideManager.
static const uint NUM_DEFAULT_ENGINES
Number of default entries.
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.
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.
const Engine * GetDisplayVariant() const
Get the last display variant for an engine.
TimerGameCalendar::Date intro_date
Date of introduction of the engine.
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.
const GRFFile * GetGRF() const
Retrieve the NewGRF the engine is tied to.
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.
static Pool::IterateWrapperFiltered< Engine, EngineTypeFilter > IterateType(VehicleType vt, size_t from=0)
Returns an iterable ensemble of all valid engines of the given type.
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 Titem * Get(size_t index)
Returns Titem with given index.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
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.
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: