10#ifndef NEWGRF_ENGINE_H
11#define NEWGRF_ENGINE_H
39 void SetVehicle(
const Vehicle *
v) { this->v =
v; }
42 uint32_t
GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter,
bool &available)
const override;
73static const uint TRAININFO_DEFAULT_VEHICLE_WIDTH = 29;
74static const uint ROADVEHINFO_DEFAULT_VEHICLE_WIDTH = 32;
75static const uint VEHICLEINFO_FULL_VEHICLE_WIDTH = 32;
81void SetCustomEngineSprites(
EngineID engine, uint8_t cargo,
const struct SpriteGroup *group);
84#define GetCustomVehicleSprite(v, direction, image_type, result) GetCustomEngineSprite(v->engine_type, v, direction, image_type, result)
85#define GetCustomVehicleIcon(et, direction, image_type, result) GetCustomEngineSprite(et, nullptr, direction, image_type, result)
88#define GetCustomRotorSprite(v, image_type, result) GetRotorOverrideSprite(v->engine_type, v, image_type, result)
89#define GetCustomRotorIcon(et, image_type, result) GetRotorOverrideSprite(et, nullptr, image_type, result)
103int GetVehicleProperty(
const Vehicle *v,
PropertyID property,
int orig_value,
bool is_signed =
false);
104int GetEngineProperty(
EngineID engine,
PropertyID property,
int orig_value,
const Vehicle *v =
nullptr,
bool is_signed =
false);
106enum class BuildProbabilityType {
113 VEHICLE_TRIGGER_NEW_CARGO = 0x01,
115 VEHICLE_TRIGGER_DEPOT = 0x02,
117 VEHICLE_TRIGGER_EMPTY = 0x04,
119 VEHICLE_TRIGGER_ANY_NEW_CARGO = 0x08,
121 VEHICLE_TRIGGER_CALLBACK_32 = 0x10,
123void TriggerVehicle(
Vehicle *veh, VehicleTrigger trigger);
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
Different types to 'show' directions.
Direction
Defines the 8 directions on the map.
Types related to engines.
uint16_t EngineID
Unique identification number of an engine.
Types related to the graphics and/or input devices.
Callbacks that NewGRFs could implement.
CallbackID
List of implemented NewGRF callbacks.
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
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.
void FillNewGRFVehicleCache(const Vehicle *v)
Fill the grf_cache of the given vehicle.
uint16_t GetVehicleCallbackParent(CallbackID callback, uint32_t param1, uint32_t param2, EngineID engine, const Vehicle *v, const Vehicle *parent)
Evaluate a newgrf callback for vehicles with a different vehicle for parent scope.
bool UsesWagonOverride(const Vehicle *v)
Check if a wagon is currently using a wagon override.
EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16_t internal_id)
Return the ID of a new engine.
bool TestVehicleBuildProbability(Vehicle *v, EngineID engine, BuildProbabilityType type)
Test for vehicle build probablity type.
uint16_t GetVehicleCallback(CallbackID callback, uint32_t param1, uint32_t param2, EngineID engine, const Vehicle *v)
Evaluate a newgrf callback for vehicles.
void CommitVehicleListOrderChanges()
Deternine default engine sorting and execute recorded ListOrderChanges from AlterVehicleListOrder.
void AlterVehicleListOrder(EngineID engine, uint16_t target)
Record a vehicle ListOrderChange.
Properties of NewGRF Action 0.
PropertyID
List of NewGRF properties used in Action 0 or Callback 0x36 (CBID_VEHICLE_MODIFY_PROPERTY).
@ VSG_SCOPE_SELF
Resolved object itself.
Aircraft, helicopters, rotors and their shadows belong to this class.
Dynamic data of a loaded NewGRF.
Interface for SpriteGroup-s to access the gamestate.
uint32_t callback_param2
Second parameter (var 18) of the callback.
CallbackID callback
Callback being resolved.
uint32_t callback_param1
First parameter (var 10) of the callback.
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope).
ResolverObject & ro
Surrounding resolver object.
Resolver for a vehicle (chain)
VehicleScopeResolver self_scope
Scope resolver for the indicated vehicle.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0) override
Get a resolver for the scope.
const SpriteGroup * ResolveReal(const RealSpriteGroup *group) const override
Get the real sprites of the grf.
VehicleScopeResolver parent_scope
Scope resolver for its parent vehicle.
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
VehicleScopeResolver relative_scope
Scope resolver for an other vehicle in the chain.
@ WO_NONE
Resolve no wagon overrides.
@ WO_SELF
Resolve self-override (helicopter rotors and such).
@ WO_UNCACHED
Resolve wagon overrides.
@ WO_CACHED
Resolve wagon overrides using TrainCache::cached_override.
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
uint8_t cached_relative_count
Relative position of the other vehicle.
Resolver for a vehicle scope.
bool rotor_in_gui
Helicopter rotor is drawn in GUI.
uint32_t GetTriggers() const override
Get the triggers.
const struct Vehicle * v
The vehicle being resolved.
EngineID self_type
Type of the vehicle.
uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const override
Get a variable value.
VehicleScopeResolver(ResolverObject &ro, EngineID engine_type, const Vehicle *v, bool rotor_in_gui)
Scope resolver of a single vehicle.
uint32_t GetRandomBits() const override
Get a few random bits.
Sprite sequence for a vehicle part.
Types related to vehicles.
EngineImageType
Visualisation contexts of vehicles and engines.
VehicleType
Available vehicle types.