OpenTTD Source 20260208-master-g43af8e94d0
newgrf_internal_vehicle.h File Reference

NewGRF internal processing state for vehicles. More...

#include "../newgrf.h"
#include "../engine_base.h"
#include "../vehicle_func.h"
#include "newgrf_internal.h"

Go to the source code of this file.

Data Structures

struct  GRFTempEngineData
 Temporary engine data used when loading only. More...

Functions

EngineGetNewEngine (const GRFFile *file, VehicleType type, uint16_t internal_id, bool static_access=false)
 Returns the engine associated to a certain internal_id, resp.
void ConvertTTDBasePrice (uint32_t base_pointer, std::string_view error_location, Price *index)
 Converts TTD(P) Base Price pointers into the enum used by OTTD See http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts.
template<VehicleType T>
static bool IsValidNewGRFImageIndex (uint8_t image_index)
 Helper to check whether an image index is valid for a particular NewGRF vehicle.
ChangeInfoResult CommonVehicleChangeInfo (EngineInfo *ei, int prop, ByteReader &buf)
 Define properties common to all vehicles.

Variables

TypedIndexContainer< std::vector< GRFTempEngineData >, EngineID_gted
 Temporary engine data used during NewGRF loading.

Detailed Description

NewGRF internal processing state for vehicles.

Definition in file newgrf_internal_vehicle.h.

Function Documentation

◆ CommonVehicleChangeInfo()

◆ ConvertTTDBasePrice()

void ConvertTTDBasePrice ( uint32_t base_pointer,
std::string_view error_location,
Price * index )

Converts TTD(P) Base Price pointers into the enum used by OTTD See http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts.

Parameters
base_pointerTTD(P) Base Price Pointer
error_locationFunction name for grf error messages
[out]indexIf base_pointer is valid, index is assigned to the matching price; else it is left unchanged

< Position of first base price

< Size of each base price record

Definition at line 333 of file newgrf.cpp.

References End, Invalid, and to_underlying().

Referenced by RailVehicleChangeInfo(), and RoadVehicleChangeInfo().

◆ GetNewEngine()

Engine * GetNewEngine ( const GRFFile * file,
VehicleType type,
uint16_t internal_id,
bool static_access )

Returns the engine associated to a certain internal_id, resp.

allocates it.

Parameters
fileNewGRF that wants to change the engine.
typeVehicle type.
internal_idEngine ID inside the NewGRF.
static_accessIf the engine is not present, return nullptr instead of allocating a new engine. (Used for static Action 0x04).
Returns
The requested engine.

Definition at line 215 of file newgrf.cpp.

References _engine_counts, _gted, _settings_game, GetFileByGRFID(), GetRailTypeInfo(), Engine::grf_prop, GRFFilePropsBase::HasGrfFile(), RailVehicleInfo::railtypes, GRFFilePropsBase::SetGRFFile(), and VEH_TRAIN.

Referenced by AircraftVehicleChangeInfo(), RailVehicleChangeInfo(), RoadVehicleChangeInfo(), and ShipVehicleChangeInfo().

◆ IsValidNewGRFImageIndex()

template<VehicleType T>
bool IsValidNewGRFImageIndex ( uint8_t image_index)
inlinestatic

Helper to check whether an image index is valid for a particular NewGRF vehicle.

Template Parameters
TThe type of vehicle.
Parameters
image_indexThe image index to check.
Returns
True iff the image index is valid, or CUSTOM_VEHICLE_SPRITENUM (use new graphics).

Definition at line 64 of file newgrf_internal_vehicle.h.

References CUSTOM_VEHICLE_SPRITENUM, and IsValidImageIndex().

Referenced by AircraftVehicleChangeInfo(), RailVehicleChangeInfo(), RoadVehicleChangeInfo(), and ShipVehicleChangeInfo().

Variable Documentation

◆ _gted

TypedIndexContainer<std::vector<GRFTempEngineData>, EngineID> _gted
extern