45 e->overrides =
ReallocT(e->overrides, e->overrides_count);
47 wo = &e->overrides[e->overrides_count - 1];
51 wo->train_id = MallocT<EngineID>(trains);
52 memcpy(wo->train_id, train_id, trains *
sizeof *train_id);
59 for (uint i = 0; i < e->overrides_count; i++) {
62 if (wo->cargo != cargo && wo->cargo != CT_DEFAULT)
continue;
64 for (uint j = 0; j < wo->trains; j++) {
65 if (wo->train_id[j] == overriding_engine)
return wo->group;
76 for (uint i = 0; i < e->overrides_count; i++) {
81 e->overrides_count = 0;
92 grfmsg(6,
"SetCustomEngineSprites: engine %d cargo %d already has group -- replacing", engine, cargo);
111 static int MapOldSubType(
const Vehicle *v)
123 default: NOT_REACHED();
129 enum TTDPAircraftMovementStates {
135 AMS_TTDP_TO_ENTRY_2_AND_3,
136 AMS_TTDP_TO_ENTRY_2_AND_3_AND_H,
137 AMS_TTDP_TO_JUNCTION,
138 AMS_TTDP_LEAVE_RUNWAY,
146 AMS_TTDP_FLIGHT_APPROACH,
147 AMS_TTDP_UNUSED_0x11,
148 AMS_TTDP_FLIGHT_TO_TOWER,
149 AMS_TTDP_UNUSED_0x13,
150 AMS_TTDP_FLIGHT_FINAL,
151 AMS_TTDP_FLIGHT_DESCENT,
153 AMS_TTDP_HELI_TAKEOFF_AIRPORT,
154 AMS_TTDP_HELI_TO_TAKEOFF_AIRPORT,
155 AMS_TTDP_HELI_LAND_AIRPORT,
156 AMS_TTDP_HELI_TAKEOFF_HELIPORT,
157 AMS_TTDP_HELI_TO_TAKEOFF_HELIPORT,
158 AMS_TTDP_HELI_LAND_HELIPORT,
169 if (st == NULL)
return AMS_TTDP_FLIGHT_TO_TOWER;
186 if (amdflag &
AMED_SLOWTURN)
return AMS_TTDP_FLIGHT_TO_TOWER;
193 return AMS_TTDP_TO_HANGAR;
196 if (amdflag & AMED_EXACTPOS)
return AMS_TTDP_TO_PAD1;
197 return AMS_TTDP_TO_JUNCTION;
200 if (amdflag & AMED_EXACTPOS)
return AMS_TTDP_TO_PAD2;
201 return AMS_TTDP_TO_ENTRY_2_AND_3_AND_H;
210 if (amdflag & AMED_EXACTPOS)
return AMS_TTDP_TO_PAD3;
211 return AMS_TTDP_TO_ENTRY_2_AND_3_AND_H;
217 if (amdflag & AMED_HELI_LOWER)
return AMS_TTDP_HELI_LAND_AIRPORT;
218 if (amdflag & AMED_SLOWTURN)
return AMS_TTDP_FLIGHT_TO_TOWER;
219 return AMS_TTDP_TO_JUNCTION;
222 return AMS_TTDP_TO_OUTWAY;
225 return AMS_TTDP_TAKEOFF;
228 return AMS_TTDP_CLIMBING;
233 AMS_TTDP_HELI_TAKEOFF_AIRPORT : AMS_TTDP_TO_JUNCTION;
235 return AMS_TTDP_HELI_TAKEOFF_HELIPORT;
239 return amdflag &
AMED_HOLD ? AMS_TTDP_FLIGHT_APPROACH : AMS_TTDP_FLIGHT_TO_TOWER;
242 return AMS_TTDP_FLIGHT_DESCENT;
245 if (amdflag &
AMED_BRAKE)
return AMS_TTDP_BRAKING;
247 return AMS_TTDP_TO_INWAY;
251 if (amdflag & AMED_HELI_LOWER) {
253 AMS_TTDP_HELI_LAND_AIRPORT : AMS_TTDP_HELI_LAND_HELIPORT;
255 return AMS_TTDP_FLIGHT_TO_TOWER;
259 return AMS_TTDP_HANGAR;
265 enum TTDPAircraftMovementActions {
270 AMA_TTDP_HANGAR_TO_PAD1,
271 AMA_TTDP_HANGAR_TO_PAD2,
272 AMA_TTDP_HANGAR_TO_PAD3,
273 AMA_TTDP_LANDING_TO_PAD1,
274 AMA_TTDP_LANDING_TO_PAD2,
275 AMA_TTDP_LANDING_TO_PAD3,
276 AMA_TTDP_PAD1_TO_HANGAR,
277 AMA_TTDP_PAD2_TO_HANGAR,
278 AMA_TTDP_PAD3_TO_HANGAR,
279 AMA_TTDP_PAD1_TO_TAKEOFF,
280 AMA_TTDP_PAD2_TO_TAKEOFF,
281 AMA_TTDP_PAD3_TO_TAKEOFF,
282 AMA_TTDP_HANGAR_TO_TAKOFF,
283 AMA_TTDP_LANDING_TO_HANGAR,
297 return (v->
cur_speed > 0) ? AMA_TTDP_LANDING_TO_HANGAR : AMA_TTDP_IN_HANGAR;
301 return (v->
current_order.
IsType(OT_LOADING)) ? AMA_TTDP_ON_PAD1 : AMA_TTDP_LANDING_TO_PAD1;
305 return (v->
current_order.
IsType(OT_LOADING)) ? AMA_TTDP_ON_PAD2 : AMA_TTDP_LANDING_TO_PAD2;
314 return (v->
current_order.
IsType(OT_LOADING)) ? AMA_TTDP_ON_PAD3 : AMA_TTDP_LANDING_TO_PAD3;
321 return AMA_TTDP_PAD1_TO_TAKEOFF;
324 return AMA_TTDP_IN_FLIGHT;
332 AMA_TTDP_LANDING_TO_HANGAR : AMA_TTDP_LANDING_TO_PAD1;
335 return AMA_TTDP_IN_HANGAR;
357 int32 count =
GB(relative, 0, 4);
358 if (this->self_scope.v != NULL && (relative != this->cached_relative_count || count == 0)) {
364 switch (
GB(relative, 6, 2)) {
365 default: NOT_REACHED();
367 v = this->self_scope.v;
370 v = this->self_scope.v;
374 v = this->parent_scope.v;
377 const Vehicle *
self = this->self_scope.v;
379 if (u->engine_type != self->engine_type) {
382 if (v == NULL) v = u;
385 if (v == NULL) v =
self;
389 this->relative_scope.SetVehicle(v->
Move(count));
391 return &this->relative_scope;
432 byte chain_before = 0;
433 byte chain_after = 0;
435 for (u = v->
First(); u != v; u = u->
Next()) {
445 return chain_before | chain_after << 8 | (chain_before + chain_after + consecutive) << 16;
472 byte cargo_classes = 0;
474 uint8 common_subtypes[256];
475 byte user_def_data = 0;
477 uint8 common_subtype = 0xFF;
480 memset(common_cargoes, 0,
sizeof(common_cargoes));
481 memset(common_subtypes, 0,
sizeof(common_subtypes));
483 for (u = v; u != NULL; u = u->
Next()) {
494 uint common_cargo_best_amount = 0;
496 if (common_cargoes[cargo] > common_cargo_best_amount) {
497 common_cargo_best_amount = common_cargoes[cargo];
498 common_cargo_type = cargo;
503 for (u = v; u != NULL; u = u->
Next()) {
511 uint common_subtype_best_amount = 0;
512 for (uint i = 0; i <
lengthof(common_subtypes); i++) {
513 if (common_subtypes[i] > common_subtype_best_amount) {
514 common_subtype_best_amount = common_subtypes[i];
536 const GRFFile *grffile =
object->ro.grffile;
537 uint8 common_bitnum = (common_cargo_type ==
CT_INVALID) ? 0xFF :
564 return (
Clamp(altitude, 0, 0xFF) << 8) | airporttype;
624 byte artic_before = 0;
626 byte artic_after = 0;
639 for (; v != NULL; v = v->
Next()) {
656 if (u == NULL)
return 0;
658 if (parameter == 0x5F) {
662 return VehicleGetVariable(u,
object, parameter,
GetRegister(0x10E), available);
679 if (u == NULL)
return 0;
682 bool prev = (int8)parameter < 0;
703 const Train *u = is_powered_wagon ? t->
First() : t;
705 bool powered = t->
IsEngine() || is_powered_wagon;
708 if (powered && has_power)
SetBit(modflags, 5);
709 if (powered && !has_power)
SetBit(modflags, 6);
715 return variable == 0xFE ? modflags :
GB(modflags, 8, 8);
720 switch (variable - 0x80) {
721 case 0x00:
return v->
type + 0x10;
722 case 0x01:
return MapOldSubType(v);
723 case 0x04:
return v->
index;
724 case 0x05:
return GB(v->
index, 8, 8);
738 default: ticks = 0;
break;
741 return (variable - 0x80) == 0x10 ? ticks :
GB(ticks, 8, 8);
745 case 0x14:
return v->GetServiceInterval();
746 case 0x15:
return GB(v->GetServiceInterval(), 8, 8);
761 return (variable - 0x80) == 0x18 ? max_speed :
GB(max_speed, 8, 8);
763 case 0x1A:
return v->
x_pos;
764 case 0x1B:
return GB(v->
x_pos, 8, 8);
765 case 0x1C:
return v->
y_pos;
766 case 0x1D:
return GB(v->
y_pos, 8, 8);
767 case 0x1E:
return v->
z_pos;
827 switch (variable - 0x80) {
828 case 0x62:
return t->track;
829 case 0x66:
return t->railtype;
844 switch (variable - 0x80) {
845 case 0x62:
return rv->
state;
846 case 0x64:
return rv->blocked_ctr;
847 case 0x65:
return GB(rv->blocked_ctr, 8, 8);
858 switch (variable - 0x80) {
859 case 0x62:
return s->
state;
866 switch (variable - 0x80) {
877 DEBUG(grf, 1,
"Unhandled vehicle variable 0x%X, type 0x%X", variable, (uint)v->
type);
885 if (this->v == NULL) {
895 return (cs->
classes << 16) | (cs->
weight << 8) | this->ro.grffile->cargo_map[cargo_type];
900 case 0x48:
return Engine::Get(this->self_type)->flags;
902 case 0x4B:
return _date;
914 return VehicleGetVariable(const_cast<Vehicle*>(this->v),
this, variable, parameter, available);
920 const Vehicle *v = this->self_scope.v;
932 if (totalsets == 0)
return NULL;
935 set =
min(
set, totalsets - 1);
948 return (e != NULL) ? e->
GetGRF() : NULL;
962 CallbackID callback, uint32 callback_param1, uint32 callback_param2)
964 self_scope(*this, engine_type, v, info_view),
965 parent_scope(*this, engine_type, ((v != NULL) ? v->First() : v), info_view),
966 relative_scope(*this, engine_type, v, info_view),
967 cached_relative_count(0)
969 if (wagon_override ==
WO_SELF) {
970 this->
root_spritegroup = GetWagonOverrideSpriteSet(engine_type, CT_DEFAULT, engine_type);
1002 uint max_stack = sprite_stack ?
lengthof(result->seq) : 1;
1003 for (uint stack = 0; stack < max_stack; ++stack) {
1004 object.ResetState();
1005 object.callback_param1 = image_type | (stack << 8);
1007 uint32 reg100 = sprite_stack ?
GetRegister(0x100) : 0;
1008 if (group != NULL && group->GetNumResults() != 0) {
1009 result->seq[result->count].
sprite = group->GetResult() + (direction % group->GetNumResults());
1010 result->seq[result->count].
pal =
GB(reg100, 0, 16);
1013 if (!
HasBit(reg100, 31))
break;
1028 uint rotor_pos = v == NULL || info_view ? 0 : v->
Next()->
Next()->
state;
1031 uint max_stack = sprite_stack ?
lengthof(result->seq) : 1;
1032 for (uint stack = 0; stack < max_stack; ++stack) {
1033 object.ResetState();
1034 object.callback_param1 = image_type | (stack << 8);
1036 uint32 reg100 = sprite_stack ?
GetRegister(0x100) : 0;
1037 if (group != NULL && group->GetNumResults() != 0) {
1038 result->seq[result->count].
sprite = group->GetResult() + (rotor_pos % group->GetNumResults());
1039 result->seq[result->count].
pal =
GB(reg100, 0, 16);
1042 if (!
HasBit(reg100, 31))
break;
1055 return Train::From(v)->tcache.cached_override != NULL;
1070 return object.ResolveCallback();
1086 object.parent_scope.SetVehicle(parent);
1087 return object.ResolveCallback();
1094 return GetEngineProperty(v->
engine_type, property, orig_value, v);
1107 static void DoTriggerVehicle(
Vehicle *v, VehicleTrigger trigger, byte base_random_bits,
bool first)
1117 if (group == NULL)
return;
1123 byte new_random_bits = Random();
1124 uint32
reseed =
object.GetReseedSum();
1126 v->
random_bits |= (first ? new_random_bits : base_random_bits) & reseed;
1129 case VEHICLE_TRIGGER_NEW_CARGO:
1138 DoTriggerVehicle(v->
First(), VEHICLE_TRIGGER_ANY_NEW_CARGO, new_random_bits,
false);
1141 case VEHICLE_TRIGGER_DEPOT:
1145 if (v->
Next() != NULL) DoTriggerVehicle(v->
Next(), trigger, 0,
true);
1148 case VEHICLE_TRIGGER_EMPTY:
1153 if (v->
Next() != NULL) DoTriggerVehicle(v->
Next(), trigger, first ? new_random_bits : base_random_bits,
false);
1156 case VEHICLE_TRIGGER_ANY_NEW_CARGO:
1160 if (v->
Next() != NULL) DoTriggerVehicle(v->
Next(), VEHICLE_TRIGGER_ANY_NEW_CARGO, base_random_bits,
false);
1163 case VEHICLE_TRIGGER_CALLBACK_32:
1169 void TriggerVehicle(
Vehicle *v, VehicleTrigger trigger)
1171 if (trigger == VEHICLE_TRIGGER_DEPOT) {
1177 DoTriggerVehicle(v, trigger, 0,
true);
1200 loc->engine = engine;
1233 FOR_ALL_ENGINES(e) {
1242 uint local_target = it->target;
1245 if (id_source->
internal_id == local_target)
continue;
1250 int source_index = ordering.
FindIndex(source);
1251 int target_index = ordering.
FindIndex(target);
1253 assert(source_index >= 0 && target_index >= 0);
1254 assert(source_index != target_index);
1257 if (source_index < target_index) {
1259 for (
int i = source_index; i < target_index; ++i) list[i] = list[i + 1];
1260 list[target_index] = source;
1262 for (
int i = source_index; i > target_index; --i) list[i] = list[i - 1];
1263 list[target_index] = source;
1270 for (
const EngineID *it = ordering.
Begin(); it != idend; ++it, ++index) {
1275 _list_order_changes.
Reset();
1287 static const int cache_entries[][2] = {
1297 for (
size_t i = 0; i <
lengthof(cache_entries); i++) {
StationID Source() const
Returns source of the first cargo packet in this list.
static bool HasPowerOnRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType got power on a tile with a given RailType.
TTDPAirportType ttd_airport_type
ttdpatch airport type (Small/Large/Helipad/Oilrig)
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope)...
This bit will be set if the NewGRF var 41 currently stored is valid.
Vehicle * Previous() const
Get the previous vehicle of this vehicle.
Airplane wants to leave the airport.
VehicleCargoList cargo
The cargo this vehicle is carrying.
Resolver for a vehicle scope.
Definition of stuff that is very close to a company, like the company struct itself.
uint32 motion_counter
counter to occasionally play a vehicle sound.
Money value
Value of the vehicle.
Airplane has reached end-point of the take-off runway.
NewGRF handling of rail types.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Finite sTate mAchine (FTA) of an airport.
This bit will be set if the NewGRF var 40 currently stored is valid.
const AirportSpec * GetSpec() const
Get the AirportSpec that from the airport type of this airport.
uint8 weight
Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
bool UsesWagonOverride(const Vehicle *v)
Check if a wagon is currently using a wagon override.
StationID targetairport
Airport to go to next.
void AlterVehicleListOrder(EngineID engine, uint target)
Record a vehicle ListOrderChange.
void UnloadWagonOverrides(Engine *e)
Unload all wagon override sprite groups.
Money GetDisplayProfitThisYear() const
Gets the profit vehicle had this year.
DirectionByte direction
facing
RailType
Enumeration for all possible railtypes.
uint32 grfid
The GRF ID of the file the entity belongs to.
ResolverObject & ro
Surrounding resolver object.
#define DAYS_TILL_ORIGINAL_BASE_YEAR
The offset in days from the '_date == 0' till 'ConvertYMDToDate(ORIGINAL_BASE_YEAR, 0, 1)'.
static const GRFFile * GetEngineGrfFile(EngineID engine_type)
Get the grf file associated with an engine type.
static Titem * Get(size_t index)
Returns Titem with given index.
bool CanCarryCargo() const
Determines whether an engine can carry something.
Functions related to dates.
Conventional Take Off and Landing, i.e. planes.
static const Year ORIGINAL_MAX_YEAR
The maximum year of the original TTD.
void Reset()
Remove all items from the list and free allocated memory.
const AirportFTAClass * GetFTA() const
Get the finite-state machine for this airport or the finite-state machine for the dummy airport in ca...
byte breakdown_delay
Counter for managing breakdown length.
Base for the train class.
uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent)
Evaluate a newgrf callback for vehicles with a different vehicle for parent scope.
Functions related to debugging.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Called to spawn visual effects for vehicles.
byte pos
Next desired position of the aircraft.
uint16 cur_speed
current speed
Interface for SpriteGroup-s to access the gamestate.
GRFFilePropsBase< NUM_CARGO+2 > grf_prop
Properties related the the grf file.
static byte MapAircraftMovementState(const Aircraft *v)
Map OTTD aircraft movement states to TTDPatch style movement states (VarAction 2 Variable 0xE2) ...
byte spritenum
currently displayed sprite index 0xfd == custom sprite, 0xfe == custom second head sprite 0xff == res...
Both directions faces to the same direction.
Specification of a cargo type.
static const Livery * LiveryHelper(EngineID engine, const Vehicle *v)
Determines the livery of an engine.
uint16 wait_counter
Ticks waiting in front of a signal, ticks being stuck or a counter for forced proceeding through sign...
Functions related to vehicles.
Aircraft, helicopters, rotors and their shadows belong to this class.
This bit will be set if the NewGRF var 43 currently stored is valid.
Called when the company (or AI) tries to start or stop a vehicle.
const Livery * GetEngineLivery(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v, byte livery_setting)
Determines the livery for a vehicle.
void Clear()
Clear all information.
uint DaysInTransit() const
Returns average number of days in transit for a cargo entity.
const T * Begin() const
Get the pointer to the first item (const)
Set when using the callback resolve system, but not to resolve a callback.
TrackBitsByte state
The "track" the ship is following.
Tindex index
Index of this pool item.
Vehicle is flying in the air.
EngineID GetID(VehicleType type, uint16 grf_local_id, uint32 grfid)
Looks up an EngineID in the EngineOverrideManager.
void CommitVehicleListOrderChanges()
Deternine default engine sorting and execute recorded ListOrderChanges from AlterVehicleListOrder.
T * First() const
Get the first vehicle in the chain.
Vehicle is unloading cargo.
PropertyID
List of NewGRF properties used in Action 0 or Callback 0x36 (CBID_VEHICLE_MODIFY_PROPERTY).
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
StationID last_station_visited
The last station we stopped at.
uint16 reliability_spd_dec
Reliability decrease speed.
uint32 position_consist_length
Cache for NewGRF var 40.
Simple vector template class.
byte user_def_data
Cached property 0x25. Can be set by Callback 0x36.
Determine whether a wagon can be attached to an already existing train.
Relative position (vehicles only)
byte num_loaded
Number of loaded groups.
uint32 cached_power
Total power of the consist (valid only for the first engine).
uint32 reseed[VSG_END]
Collects bits to rerandomise while triggering triggers.
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
static T max(const T a, const T b)
Returns the maximum of two values.
uint16 MapOldOrder() const
Pack this order into a 16 bits integer as close to the TTD representation as possible.
uint16 classes
Classes of this cargo type.
EngineImageType
Visualisation contexts of vehicles and engines.
byte flags
Flags of the engine.
Year _cur_year
Current year, starting at 0.
Helicopter wants to land.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
byte overtaking
Set to RVSB_DRIVE_SIDE when overtaking, otherwise 0.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
uint16 cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
const T * End() const
Get the pointer behind the last valid item (const)
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
CargoID GetDefaultCargoType() const
Determines the default cargo type of an engine.
bool IsNormalAircraft() const
Check if the aircraft type is a normal flying device; eg not a rotor or a shadow. ...
Go exactly to the destination coordinates.
Direction
Defines the 8 directions on the map.
static uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
T * Append(uint to_add=1)
Append an item and return it.
EngineID first_engine
Cached EngineID of the front vehicle. INVALID_ENGINE for the front vehicle itself.
Holding pattern movement (above the airport).
Pseudo random number generator.
const SpriteGroup * root_spritegroup
Root SpriteGroup to use for resolving.
byte breakdown_ctr
Counter for managing breakdown events.
Vehicle * Move(int n)
Get the vehicle at offset n of this vehicle chain.
byte subtype
subtype (Filled with values from #EffectVehicles/#TrainSubTypes/#AircraftSubTypes) ...
Buses, trucks and trams belong to this class.
uint16 cargo_cap
total capacity
Vehicle is a prototype (accepted as exclusive preview).
Turn slowly (mostly used in the air).
byte acceleration
used by train & aircraft
static uint32 GetRegister(uint i)
Gets the value of a so-called newgrf "register".
Resolve no wagon overrides.
virtual const SpriteGroup * Resolve(ResolverObject &object) const
Base sprite group resolver.
uint16 internal_id
The internal ID within the GRF file.
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
UnitID unitnumber
unit number, for display purposes only
const SpriteGroup ** loaded
List of loaded groups (can be SpriteIDs or Callback results)
byte cargo_subtype
Used for livery refits (NewGRF variations)
uint Length() const
Get the number of items in the list.
byte subtype
Type of aircraft.
static byte MapAircraftMovementAction(const Aircraft *v)
Map OTTD aircraft movement states to TTDPatch style movement actions (VarAction 2 Variable 0xE6) This...
GroundVehicleCache * GetGroundVehicleCache()
Access the ground vehicle cache of the vehicle.
bool IsType(OrderType type) const
Check whether this order is of the given type.
Called to modify various vehicle properties.
Resolver for a vehicle (chain)
T * Next() const
Get next vehicle in the chain.
Draw vehicle by stacking multiple sprites.
Definition of base types and functions in a cross-platform compatible way.
static const uint VEHICLE_LENGTH
The length of a vehicle in tile units.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
A number of safeguards to prevent using unsafe methods.
void InvalidateNewGRFCacheOfChain()
Invalidates cached NewGRF variables of all vehicles in the chain (after the current vehicle) ...
void VehicleEnteredDepotThisTick(Vehicle *v)
Adds a vehicle to the list of vehicles that visited a depot this tick.
byte waiting_triggers
Triggers to be yet matched before rerandomizing the random bits.
DirDiff
Enumeration for the difference between two directions.
Station * GetTargetAirportIfValid(const Aircraft *v)
Returns aircraft's target station if v->target_airport is a valid station with airport.
uint32 position_same_id_length
Cache for NewGRF var 41.
void FillNewGRFVehicleCache(const Vehicle *v)
Fill the grf_cache of the given vehicle.
VehicleType type
Vehicle type, ie VEH_ROAD, VEH_TRAIN, etc.
virtual int GetCurrentMaxSpeed() const
Calculates the maximum speed of the vehicle under its current conditions.
CargoID cargo_type
type of cargo this vehicle is carrying
Information about a particular livery.
Effect vehicle type (smoke, explosions, sparks, bubbles)
static T * ReallocT(T *t_ptr, size_t num_elements)
Simplified reallocation function that allocates the specified number of elements of the given type...
uint16 load_unload_ticks
Ticks to wait before starting next cycle.
static const byte LIT_ALL
Show the liveries of all companies.
byte misc_flags
Miscellaneous flags.
TileIndex tile
Current tile index.
VehicleResolverObject(EngineID engine_type, const Vehicle *v, WagonOverride wagon_override, bool info_view=false, CallbackID callback=CBID_NO_CALLBACK, uint32 callback_param1=0, uint32 callback_param2=0)
Resolver of a vehicle (chain).
This bit will be set if the NewGRF var 42 currently stored is valid.
bool HasArticulatedPart() const
Check if an engine has an articulated part.
const SpriteGroup ** loading
List of loading groups (can be SpriteIDs or Callback results)
static DirDiff DirDifference(Direction d0, Direction d1)
Calculate the difference between two directions.
Sprite sequence for a vehicle part.
uint8 cargo_map[NUM_CARGO]
Inverse cargo translation table (CargoID -> local ID)
Called to determine if a specific colour map should be used for a vehicle instead of the default live...
Airplane has arrived at a runway for take-off.
#define lengthof(x)
Return the length of an fixed size array.
const AirportMovingData * MovingData(byte position) const
Get movement data at a position.
static T min(const T a, const T b)
Returns the minimum of two values.
byte random_bits
Bits used for determining which randomized variational spritegroups to use when drawing.
byte breakdowns_since_last_service
Counter for the amount of breakdowns.
uint16 reliability
Reliability.
static const Year ORIGINAL_BASE_YEAR
The minimum starting year/base year of the original TTD.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
byte tick_counter
Increased by one for each tick.
uint16 crashed_ctr
Animation counter when the vehicle has crashed.
const struct SpriteGroup * spritegroup[Tcnt]
pointer to the different sprites of the entity
All ships have this type.
Year build_year
Year the vehicle has been built.
byte state
State of the airport.
virtual uint32 GetVariable(byte variable, uint32 parameter, bool *available) const
Get a variable value.
byte turn_counter
Ticks between each turn to prevent > 45 degree turns.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const
Get a variable value.
#define DEBUG(name, level,...)
Output a line of debugging information.
'Train' is either a loco or a wagon.
Maximal number of cargo types in a game.
TileIndex tile
The base tile of the area.
byte breakdown_chance
Current chance of breakdowns.
This bit will be set if the NewGRF var 4D currently stored is valid.
byte num_loading
Number of loading groups.
static const EngineID INVALID_ENGINE
Constant denoting an invalid engine.
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
static int32 ClampToI32(const int64 a)
Reduce a signed 64-bit int to a signed 32-bit one.
Functions related to companies.
uint32 company_information
Cache for NewGRF var 43.
Called for every vehicle every 32 days (not all on same date though).
RailType GetTileRailType(TileIndex tile)
Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
int FindIndex(const T &item) const
Search for the first occurrence of an item.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
const GRFFile * GetGRF() const
Retrieve the NewGRF the engine is tied to.
DestinationID GetDestination() const
Gets the destination of this order.
byte subspeed
fractional speed
Used for vehicle var 0xFE bit 8 (toggled each time the train is reversed, accurate for first vehicle ...
uint16 EngineID
Unique identification number of an engine.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
CompanyByte _current_company
Company currently doing an action.
Cargo support for NewGRFs.
Vehicle * Next() const
Get the next vehicle of this vehicle.
Date date_of_last_service
Last date the vehicle had a service at a depot.
uint32 consist_cargo_information
Cache for NewGRF var 42. (Note: The cargotype is untranslated in the cache because the accessing GRF ...
Related object of the resolved one.
Resolve self-override (helicopter rotors and such).
VehicleTypeByte type
The engine type.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
OwnerByte owner
Which company owns the vehicle?
uint32 position_in_vehicle
Cache for NewGRF var 4D.
void CDECL grfmsg(int severity, const char *str,...)
DEBUG() function dedicated to newGRF debugging messages Function is essentially the same as DEBUG(grf...
CallbackID callback
Callback being resolved.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
uint32 GetCompanyInfo(CompanyID owner, const Livery *l)
Returns company information like in vehicle var 43 or station var 43.
Reverse the visible direction of the vehicle.
uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
Perform a reverse railtype lookup to get the GRF internal ID.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
uint16 local_id
id defined by the grf file for this entity
uint32 GetGRFID() const
Retrieve the GRF ID of the NewGRF the vehicle is tied to.
static int CDECL EnginePreSort(const EngineID *a, const EngineID *b)
Comparator function to sort engines via scope-GRFID and local ID.
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v)
Evaluate a newgrf callback for vehicles.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
uint8 cached_veh_length
Length of this vehicle in units of 1/VEHICLE_LENGTH of normal length. It is cached because this can b...
Airport airport
Tile area the airport covers.
static DirDiff ChangeDirDiff(DirDiff d, DirDiff delta)
Applies two differences together.
EngineID engine_type
The type of engine used for this vehicle.
const struct GRFFile * grffile
grf file that introduced this entity
uint8 bitnum
Cargo bit number, is INVALID_CARGO for a non-used spec.
const SpriteGroup * ResolveReal(const RealSpriteGroup *group) const
Get the real sprites of the grf.
CallbackID
List of implemented NewGRF callbacks.
Helicopter wants to finish landing.
uint16 vehicle_flags
Used for gradual loading and other miscellaneous things (.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Set when calling a randomizing trigger (almost undocumented).
uint8 cache_valid
Bitset that indicates which cache values are valid.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
const T * Get(uint index) const
Get the pointer to item "number" (const)
uint16 flag
special flags when moving towards the destination.
byte CargoID
Cargo slots to indicate a cargo type within a game.
One direction is the opposite of the other one.
static uint32 PositionHelper(const Vehicle *v, bool consecutive)
Helper to get the position of a vehicle within a chain of vehicles.
SpriteID sprite
The 'real' sprite.
Base classes/functions for stations.
VehicleCache vcache
Cache of often used vehicle values.
Date _date
Current date in days (day counter)
static void QSortT(T *base, uint num, int(CDECL *comparator)(const T *, const T *), bool desc=false)
Type safe qsort()
uint32 GetTriggers() const
Get the triggers.
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
VehicleTypeByte type
Type of vehicle.
Airplane wants to finish landing.
static uint16 ClampToU16(const uint64 a)
Reduce an unsigned 64-bit int to an unsigned 16-bit one.
NewGRFCache grf_cache
Cache of often used calculated NewGRF values.
Money GetDisplayProfitLastYear() const
Gets the profit vehicle had last year.
byte day_counter
Increased by one for each day.
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
byte delta_z
Z adjustment for helicopter pads.
Order current_order
The current order (+ status, like: loading)
uint32 GetRandomBits() const
Get a few random bits.
bool IsEngine() const
Check if a vehicle is an engine (can be first in a consist).
GroundVehicleCache gcache
Cache of often calculated values.
byte overtaking_ctr
The length of the current overtake attempt.
Dynamic data of a loaded NewGRF.
Helicopter wants to leave the airport.
PaletteID pal
The palette (use PAL_NONE) if not needed)
void SetEngineGRF(EngineID engine, const GRFFile *file)
Tie a GRFFile entry to an engine, to allow us to retrieve GRF parameters etc during a game...
Resolve wagon overrides using TrainCache::cached_override.