|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
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;
247 if (!new_multipliers && cargo_type == CT_MAIL)
return capacity + extra_mail_cap;
248 default_cargo = CT_PASSENGERS;
251 default: NOT_REACHED();
254 if (!new_multipliers) {
256 capacity += extra_mail_cap;
261 if (new_multipliers || (this->type !=
VEH_SHIP && default_cargo != cargo_type)) {
264 capacity *= cargo_multiplier;
265 if (extra_mail_cap > 0) {
267 capacity += (default_multiplier * extra_mail_cap * cargo_multiplier + mail_multiplier / 2) / mail_multiplier;
269 capacity = (capacity + default_multiplier / 2) / default_multiplier;
283 switch (this->type) {
285 base_price = this->u.road.running_cost_class;
286 if (base_price == INVALID_PRICE)
return 0;
291 base_price = this->u.rail.running_cost_class;
292 if (base_price == INVALID_PRICE)
return 0;
297 base_price = PR_RUNNING_SHIP;
302 base_price = PR_RUNNING_AIRCRAFT;
306 default: NOT_REACHED();
320 switch (this->type) {
322 base_price = PR_BUILD_VEHICLE_ROAD;
328 base_price = PR_BUILD_VEHICLE_WAGON;
331 base_price = PR_BUILD_VEHICLE_TRAIN;
337 base_price = PR_BUILD_VEHICLE_SHIP;
342 base_price = PR_BUILD_VEHICLE_AIRCRAFT;
346 default: NOT_REACHED();
358 switch (this->type) {
364 return (max_speed != 0) ? max_speed * 2 : this->u.road.max_speed / 2;
372 if (max_speed != 0) {
373 return (max_speed * 128) / 10;
375 return this->u.air.max_speed;
378 default: NOT_REACHED();
391 switch (this->type) {
397 default: NOT_REACHED();
409 switch (this->type) {
415 default: NOT_REACHED();
427 switch (this->type) {
433 default: NOT_REACHED();
453 switch (this->type) {
457 default: NOT_REACHED();
467 switch (this->type) {
469 switch (this->u.air.subtype) {
470 case AIR_HELI:
return STR_LIVERY_HELICOPTER;
471 case AIR_CTOL:
return STR_LIVERY_SMALL_PLANE;
472 case AIR_CTOL | AIR_FAST:
return STR_LIVERY_LARGE_PLANE;
473 default: NOT_REACHED();
476 default: NOT_REACHED();
511 for (uint internal_id = 0; internal_id <
_engine_counts[type]; internal_id++) {
514 eid.
grfid = INVALID_GRFID;
569 [[maybe_unused]] uint index = 0;
574 [[maybe_unused]]
const Engine *e =
new Engine(eid.type, eid.internal_id);
575 assert(e->
index == index);
580 void ShowEnginePreviewWindow(
EngineID engine);
601 if (e->display_last_variant == engine_id) e->display_last_variant =
INVALID_ENGINE;
617 uint32_t age = re->
age;
618 if (new_month && re->
index > e->
index && age != INT32_MAX) age++;
624 if (retire_early != 0 && age >= retire_early_max_age) {
632 if (age < e->duration_phase_1) {
697 uint32_t r = Random();
705 int aging_months = aging_ymd.year.base() * 12 + aging_ymd.month;
706 int intro_months = intro_ymd.year.base() * 12 + intro_ymd.month;
707 if (intro_ymd.day > 1) intro_months++;
708 e->
age = aging_months - intro_months;
720 (re->
index << 16) ^ (re->info.
base_intro.base() << 12) ^ (re->info.decay_speed << 8) ^
726 const uint16_t RELIABILITY_START = UINT16_MAX * 48 / 100;
727 const uint16_t RELIABILITY_MAX = UINT16_MAX * 75 / 100;
728 const uint16_t RELIABILITY_FINAL = UINT16_MAX * 25 / 100;
730 static_assert(RELIABILITY_START == 0x7AE0);
731 static_assert(RELIABILITY_MAX == 0xBFFF);
732 static_assert(RELIABILITY_FINAL == 0x3FFF);
766 uint32_t seed = Random();
862 if (recursion_depth >= 10)
return;
884 int32_t best_hist = -1;
887 c->old_economy[0].performance_history > best_hist) {
891 if (v->owner != c->index || v->type != e->
type)
continue;
892 if (!v->GetEngine()->CanCarryCargo() || !
HasBit(cargomask, v->cargo_type))
continue;
894 best_hist = c->old_economy[0].performance_history;
895 best_company = c->index;
919 default: NOT_REACHED();
937 if (!--e->preview_wait) {
949 SetBit(e->preview_asked, e->preview_company);
950 e->preview_wait = 20;
970 SB(e->company_hidden, cid, 1, 0);
1050 uint block_preview = c->block_preview;
1055 c->block_preview = 20;
1060 if (v->owner == c->index && v->engine_type == index) {
1062 c->block_preview = block_preview;
1112 bool refresh =
false;
1122 if (!e->IsEnabled())
continue;
1135 if (
IsWagon(e->index))
continue;
1143 e->preview_asked = 0;
1169 if (!e->name.empty() && e->name == name)
return false;
1187 bool reset = text.empty();
1221 if (e ==
nullptr)
return false;
1224 if (e->
type != type)
return false;
1262 if (e ==
nullptr)
return false;
1267 if (ei->refit_mask == 0)
return false;
1275 CargoTypes default_cargo_mask = 0;
1276 SetBit(default_cargo_mask, default_cargo);
1277 return IsValidCargoID(default_cargo) && ei->refit_mask != default_cargo_mask;
1285 TimerGameCalendar::Date min_date = INT32_MAX;
1288 if (!e->IsEnabled())
continue;
1297 min_date = std::min(min_date, e->info.base_intro);
1300 if (min_date < INT32_MAX) {
@ VEH_AIRCRAFT
Aircraft vehicle type.
static constexpr TimerGameTick::Ticks CARGO_AGING_TICKS
Cycle duration for aging cargo.
uint16_t reliability_max
Maximal reliability of the engine.
static const EngineID INVALID_ENGINE
Constant denoting an invalid engine.
UnitID max_aircraft
max planes in game per company
bool IsVariantHidden(CompanyID c) const
Check whether the engine variant chain is hidden in the GUI for the given company.
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 CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
void CheckEngines()
Check for engines that have an appropriate availability.
@ PROP_TRAIN_SPEED
Max. speed: 1 unit = 1/1.6 mph = 1 km-ish/h.
@ ROADTYPE_END
Used for iterations.
static Pool::IterateWrapperFiltered< Engine, EngineTypeFilter > IterateType(VehicleType vt, size_t from=0)
Returns an iterable ensemble of all valid engines of the given type.
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
static Titem * Get(size_t index)
Returns Titem with given index.
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
void ResetToDefaultMapping()
Initializes the EngineOverrideManager with the default engines.
@ PROP_TRAIN_CARGO_CAPACITY
Capacity (if dualheaded: for each single vehicle)
bool ai_disable_veh_roadveh
disable types for AI
@ PROP_ROADVEH_TRACTIVE_EFFORT
Tractive effort coefficient in 1/256.
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Money GetPrice(Price index, uint cost_factor, const GRFFile *grf_file, int shift)
Determine a certain price.
@ PROP_ROADVEH_COST_FACTOR
Purchase cost.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
void CalcEngineReliability(Engine *e, bool new_month)
Update Engine::reliability and (if needed) update the engine GUIs.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
const uint8_t _engine_offsets[4]
Offset of the first engine of each vehicle type in original engine data.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
RailTypes avail_railtypes
Rail types available to this company.
@ WL_WARNING
Other information.
@ PROP_TRAIN_RUNNING_COST_FACTOR
Yearly runningcost (if dualheaded: sum of both vehicles)
byte landscape
the landscape we're currently in
RoadTypes introduces_roadtypes
Bitmask of which other roadtypes are introduced when this roadtype is introduced.
RoadTypes avail_roadtypes
Road types available to this company.
static bool IsWagon(EngineID index)
Determine whether an engine type is a wagon (and not a loco).
static CompanyID GetPreviewCompany(Engine *e)
Get the best company for an engine preview.
uint16_t reliability_spd_dec
Speed of reliability decay between services (per day).
@ PROP_TRAIN_TRACTIVE_EFFORT
Tractive effort coefficient in 1/256.
TimerGameCalendar::Date GetLifeLengthInDays() const
Returns the vehicle's (not model's!) life length in days.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Price
Enumeration of all base prices for use with Prices.
@ PROP_AIRCRAFT_MAIL_CAPACITY
Mail Capacity.
CompanyMask company_avail
Bit for each company whether the engine is available for that company.
@ WC_ENGINE_PREVIEW
Engine preview window; Window numbers:
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
uint GetDisplayMaxTractiveEffort() const
Returns the tractive effort of the engine for display purposes.
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.
@ VE_DEFAULT
Default value to indicate that visual effect should be based on engine class.
Stores the state of all random number generators.
Tindex index
Index of this pool item.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
@ PROP_SHIP_CARGO_CAPACITY
Capacity.
@ PROP_AIRCRAFT_RUNNING_COST_FACTOR
Yearly runningcost.
uint16_t reliability_final
Final reliability of the engine.
static void EnableEngineForCompany(EngineID eid, CompanyID company)
Allows engine eid to be used by a company company.
Money GetRunningCost() const
Return how much the running costs of this engine are.
StringID GetEngineCategoryName(EngineID engine)
Return the category of an engine.
void SaveRandomSeeds(SavedRandomSeeds *storage)
Saves the current seeds.
void SetupEngines()
Initialise the engine pool with the data from the original vehicles.
@ TRANSPORT_WATER
Transport over water.
CompanyID preview_company
Company which is currently being offered a preview INVALID_COMPANY means no company.
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
Templated helper to make a type-safe 'typedef' representing a single POD value.
Information about a vehicle.
@ CBM_VEHICLE_CARGO_SUFFIX
Show suffix after cargo name.
@ VEH_ROAD
Road vehicle type.
@ CC_PASSENGERS
Passengers.
CargoID GetDefaultCargoType() const
Determines the default cargo type of an engine.
CompanyMask company_hidden
Bit for each company whether the engine is normally hidden in the build gui for that company.
RoadType roadtype
Road type.
void StartupEngines()
Start/initialise all our engines.
Owner
Enum for all companies/owners.
@ DC_EXEC
execute the given command
const uint8_t _engine_counts[4]
Number of engines of each vehicle type in original engine data.
uint32_t GetGRFID() const
Retrieve the GRF ID of the NewGRF the engine is tied to.
static void DisableEngineForCompany(EngineID eid, CompanyID company)
Forbids engine eid to be used by a company company.
DoCommandFlag
List of flags for a command.
byte extend_vehicle_life
extend vehicle life by this many years
GameCreationSettings game_creation
settings used during the creation of a game (map)
CommandCost CmdWantEnginePreview(DoCommandFlag flags, EngineID engine_id)
Accept an engine prototype.
@ NR_ENGINE
Reference engine.
const GRFFile * GetGRF() const
Retrieve the NewGRF the engine is tied to.
static bool IsUniqueEngineName(const std::string &name)
Is name still free as name for an engine?
@ ENGINE_EXCLUSIVE_PREVIEW
This vehicle is in the exclusive preview stage, either being used or being offered to a company.
EngineID display_last_variant
NOSAVE client-side-only last variant selected.
uint DetermineCapacity(const Vehicle *v, uint16_t *mail_capacity=nullptr) const
Determines capacity of a given vehicle from scratch.
uint GetDisplayMaxSpeed() const
Returns max speed of the engine for display purposes.
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...
static void AcceptEnginePreview(EngineID eid, CompanyID company, int recursion_depth=0)
Company company accepts engine eid for preview.
@ ROADTYPES_NONE
No roadtypes.
@ PROP_ROADVEH_SPEED
Max. speed: 1 unit = 1/0.8 mph = 2 km-ish/h.
static bool IsVehicleTypeDisabled(VehicleType type, bool ai)
Checks if a vehicle type is disabled for all/ai companies.
RoadTypes powered_roadtypes
bitmask to the OTHER roadtypes on which a vehicle of THIS roadtype generates power
@ NT_NEW_VEHICLES
New vehicle has become available.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
uint16_t callback_mask
Bitmask of vehicle callbacks that have to be called.
bool ai_disable_veh_train
disable types for AI
static constexpr int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
static void NewEvent(CompanyID company, ScriptEvent *event)
Queue a new event for an AI.
Common return value for all commands.
@ PreviewNews
Name is shown in exclusive preview or newspaper.
void StartupOneEngine(Engine *e, const TimerGameCalendar::YearMonthDay &aging_ymd, uint32_t seed)
Start/initialise one engine.
CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
Ors the refit_masks of all articulated parts.
UnitID max_ships
max ships in game per company
RailTypes AddDateIntroducedRailTypes(RailTypes current, TimerGameCalendar::Date date)
Add the rail types that are to be introduced at the given date.
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.
EngineID engine_type
The type of engine used for this vehicle.
TimerGameCalendar::Date intro_date
Date of introduction of the engine.
uint32_t grfid
The GRF ID of the file the entity belongs to.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static const int GROUND_ACCELERATION
Acceleration due to gravity, 9.8 m/s^2.
void CalendarEnginesMonthlyLoop()
Monthly update of the availability, reliability, and preview offers of the engines.
static const uint MAX_LENGTH_ENGINE_NAME_CHARS
The maximum length of an engine name in characters including '\0'.
CompanyMask preview_asked
Bit for each company which has already been offered a preview.
@ WC_REPLACE_VEHICLE
Replace vehicle window; Window numbers:
GameSettings _settings_game
Game settings of a running game or the scenario editor.
bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
uint GetDisplayWeight() const
Returns the weight of the engine for display purposes.
@ MAX_COMPANIES
Maximum number of companies.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company=MAX_COMPANIES)
Broadcast a new event to all active AIs.
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
uint8_t substitute_id
The (original) entity ID to use if this GRF is not available (currently not used)
TimerGameCalendar::Year starting_year
starting date
void SetRandomSeed(uint32_t seed)
(Re)set the state of the random number generators.
@ NoNews
No 'new vehicle' news will be generated.
void CleanPool() override
Virtual method that deletes all items in the pool.
@ JoinPreview
Engine will join exclusive preview with variant parent.
uint16_t duration_phase_1
First reliability phase in months, increasing reliability from reliability_start to reliability_max.
Money GetCost() const
Return how much a new engine costs.
VehicleType
Available vehicle types.
@ PROP_AIRCRAFT_COST_FACTOR
Purchase cost.
constexpr uint CountBits(T value)
Counts the number of set bits in a variable.
uint16_t reliability
Current reliability of the engine.
@ ENGINE_AVAILABLE
This vehicle is available to everyone.
byte misc_flags
Miscellaneous flags.
@ NoPreview
No exclusive preview will be offered.
@ PROP_SHIP_RUNNING_COST_FACTOR
Yearly runningcost.
@ RAILVEH_WAGON
simple wagon, not motorized
@ CBM_VEHICLE_REFIT_CAPACITY
Cargo capacity after refit.
uint16_t local_id
id defined by the grf file for this entity
@ SyncReliability
Engine reliability will be synced with variant parent.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
static void ClearLastVariant(EngineID engine_id, VehicleType type)
Ensure engine is not set as the last used variant for any other engine.
uint16_t reliability_start
Initial reliability of the engine.
AISettings ai
what may the AI do?
RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, TimerGameCalendar::Date date)
Add the road types that are to be introduced at the given date.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
bool ai_disable_veh_ship
disable types for AI
CompanyID _current_company
Company currently doing an action.
@ PROP_TRAIN_WEIGHT
Weight in t (if dualheaded: for each single vehicle)
std::string name
Custom name of engine.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Base class for all pools.
bool IsHidden(CompanyID c) const
Check whether the engine is hidden in the GUI for the given company.
uint16_t internal_id
The internal ID within the GRF file.
bool CanCarryCargo() const
Determines whether an engine can carry something.
TimerGameCalendar::Year base_life
Basic duration of engine availability (without random parts). 0xFF means infinite life.
uint32_t generation_seed
noise seed for world generation
CommandCost CmdSetVehicleVisibility(DoCommandFlag flags, EngineID engine_id, bool hide)
Set the visibility of an engine.
UnitID max_trains
max trains in game per company
RailTypes GetCompanyRailTypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
@ WC_BUILD_VEHICLE
Build vehicle; Window numbers:
static Aircraft * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
uint GetPower() const
Returns the power of the engine for display and sorting purposes.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
@ RAILTYPE_END
Used for iterations.
@ EF_NO_DEFAULT_CARGO_MULTIPLIER
Use the new capacity algorithm. The default cargotype of the vehicle does not affect capacity multipl...
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...
bool IsNormalAircraft() const
Check if the aircraft type is a normal flying device; eg not a rotor or a shadow.
CommandCost CmdRenameEngine(DoCommandFlag flags, EngineID engine_id, const std::string &text)
Rename an engine.
Stores the mapping of EngineID to the internal id of newgrfs.
@ RAILVEH_MULTIHEAD
indicates a combination of two locomotives
EngineID variant_id
Engine variant ID. If set, will be treated specially in purchase lists.
EngineID GetID(VehicleType type, uint16_t grf_local_id, uint32_t grfid)
Looks up an EngineID in the EngineOverrideManager.
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.
bool ai_disable_veh_aircraft
disable types for AI
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
uint16_t cargo_age_period
Number of ticks before carried cargo is aged.
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
@ TRANSPORT_AIR
Transport through air.
static void NewVehicleAvailable(Engine *e)
An engine has become available for general use.
RailType railtype
Railtype, mangled if elrail is disabled.
@ PROP_ROADVEH_CARGO_CAPACITY
Capacity.
@ OWNER_DEITY
The object is owned by a superuser / goal script.
UnitID max_roadveh
max trucks in game per company
void RestoreRandomSeeds(const SavedRandomSeeds &storage)
Restores previously saved seeds.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
RailTypes introduces_railtypes
Bitmask of which other railtypes are introduced when this railtype is introduced.
@ AIR_CTOL
Conventional Take Off and Landing, i.e. planes.
@ NF_VEHICLE
Vehicle news item. (new engine available)
int8_t retire_early
Number of years early to retire vehicle.
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.
#define lengthof(x)
Return the length of an fixed size array.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
@ CBID_VEHICLE_REFIT_CAPACITY
Refit capacity, the passed vehicle needs to have its ->cargo_type set to the cargo we are refitting t...
byte CargoID
Cargo slots to indicate a cargo type within a game.
bool never_expire_vehicles
never expire vehicles
bool IsEnabled() const
Checks whether the engine is a valid (non-articulated part of an) engine.
bool IsInteractiveCompany(CompanyID company)
Is the user representing company?
CommandCost CmdEngineCtrl(DoCommandFlag flags, EngineID engine_id, CompanyID company_id, bool allow)
Allow or forbid a specific company to use an engine.
@ INVALID_COMPANY
An invalid company.
@ PROP_SHIP_COST_FACTOR
Purchase cost.
@ TRANSPORT_ROAD
Transport by road vehicle.
CargoID cargo_type
type of cargo this vehicle is carrying
uint8_t original_image_index
Original vehicle image index, thus the image index of the overridden vehicle.
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
GRFFilePropsBase< NUM_CARGO+2 > grf_prop
Properties related the the grf file.
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.
static Date date
Current date in days (day counter).
VehicleSettings vehicle
options for vehicles
uint16_t EngineID
Unique identification number of an engine.
byte cargo_subtype
Used for livery refits (NewGRF variations)
byte climates
Climates supported by the engine.
@ PROP_SHIP_SPEED
Max. speed: 1 unit = 1/3.2 mph = 0.5 km-ish/h.
@ PROP_AIRCRAFT_PASSENGER_CAPACITY
Passenger Capacity.
bool IsEngineRefittable(EngineID engine)
Check if an engine is refittable.
@ PROP_ROADVEH_POWER
Power in 10 HP.
@ VEH_TRAIN
Train vehicle type.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
@ PROP_TRAIN_COST_FACTOR
Purchase cost (if dualheaded: sum of both vehicles)
@ PROP_AIRCRAFT_SPEED
Max. speed: 1 unit = 8 mph = 12.8 km-ish/h.
static TimerGameCalendar::Year _year_engine_aging_stops
Year that engine aging stops.
VehicleType type
The engine type.
byte flags
Flags of the engine.
StringID string_id
Default name of engine.
void ClearEnginesHiddenFlagOfCompany(CompanyID cid)
Clear the 'hidden' flag for all engines of a new company.
uint16_t GetVehicleCallback(CallbackID callback, uint32_t param1, uint32_t param2, EngineID engine, const Vehicle *v)
Evaluate a newgrf callback for vehicles.
uint16_t duration_phase_2
Second reliability phase in months, keeping reliability_max.
@ PROP_TRAIN_POWER
Power in hp (if dualheaded: sum of both vehicles)
void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
When an engine is made buildable or is removed from being buildable, add/remove it from the build/aut...
@ VEH_SHIP
Ship vehicle type.
bool IsCargoInClass(CargoID c, CargoClass cc)
Does cargo c have cargo class cc?
@ PROP_ROADVEH_RUNNING_COST_FACTOR
Yearly runningcost.
static constexpr int DAYS_IN_YEAR
days per year
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
@ PROP_AIRCRAFT_RANGE
Aircraft range.
uint16_t duration_phase_3
Third reliability phase in months, decaying to reliability_final.
void SetYearEngineAgingStops()
Compute the value for _year_engine_aging_stops.
bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company)
Check if an engine is buildable.
StringID GetAircraftTypeText() const
Get the name of the aircraft type for display purposes.
uint16_t multiplier
Capacity multiplier for vehicles. (8 fractional bits)
static const uint NUM_DEFAULT_ENGINES
Number of default entries.
TimerGameCalendar::Date base_intro
Basic date of engine introduction (without random parts).
TimerGameCalendar::Year lifelength
Lifetime of a single vehicle.
Dynamic data of a loaded NewGRF.
VehicleType type
Vehicle type, ie VEH_ROAD, VEH_TRAIN, etc.
uint16_t GetRange() const
Get the range of an aircraft type.
@ PROP_ROADVEH_WEIGHT
Weight in 1/4 t.
const Engine * GetDisplayVariant() const
Get the last display variant for an engine.
static Year year
Current year, starting at 0.
int32_t age
Age of the engine in months.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.