OpenTTD Source: src/newgrf.cpp File Reference

OpenTTD Source 15.0-beta1

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
newgrf.cpp File Reference

Base of all NewGRF support. More...

`#include "stdafx.h"`
`#include "core/backup_type.hpp"`
`#include "core/container_func.hpp"`
`#include "debug.h"`
`#include "fileio_func.h"`
`#include "engine_func.h"`
`#include "engine_base.h"`
`#include "bridge.h"`
`#include "town.h"`
`#include "newgrf_engine.h"`
`#include "newgrf_text.h"`
`#include "fontcache.h"`
`#include "currency.h"`
`#include "landscape.h"`
`#include "newgrf_cargo.h"`
`#include "newgrf_house.h"`
`#include "newgrf_sound.h"`
`#include "newgrf_station.h"`
`#include "industrytype.h"`
`#include "industry_map.h"`
`#include "newgrf_act5.h"`
`#include "newgrf_canal.h"`
`#include "newgrf_townname.h"`
`#include "newgrf_industries.h"`
`#include "newgrf_airporttiles.h"`
`#include "newgrf_airport.h"`
`#include "newgrf_object.h"`
`#include "rev.h"`
`#include "fios.h"`
`#include "strings_func.h"`
`#include "timer/timer_game_tick.h"`
`#include "timer/timer_game_calendar.h"`
`#include "string_func.h"`
`#include "network/core/config.h"`
`#include "smallmap_gui.h"`
`#include "genworld.h"`
`#include "error.h"`
`#include "error_func.h"`
`#include "vehicle_func.h"`
`#include "language.h"`
`#include "vehicle_base.h"`
`#include "road.h"`
`#include "newgrf_roadstop.h"`
`#include "table/strings.h"`
`#include "table/build_industry.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | GrfProcessingState
| Temporary data during loading of GRFs. More...
struct | GrfProcessingState::SpriteSet
| Definition of a single Action1 spriteset. More...
class | OTTDByteReaderSignal
class | ByteReader
| Class to read from a NewGRF file. More...
struct | GRFTempEngineData
| Temporary engine data used when loading only. More...
struct | GRFLocation
struct | StringIDMapping
| Information for mapping static StringIDs. More...
struct | AllowedSubtags
| Data structure to store the allowed id/type combinations for action 14. More...

## Macros
#define | TEXTID_TO_STRINGID(begin, end, stringid, stringend)

## Typedefs
typedef void(* | SpecialSpriteHandler) (ByteReader &buf)
typedef std::map< GRFLocation, std::vector< uint8_t > > | GRFLineToSpriteOverride
typedef ChangeInfoResult(* | VCI_Handler) (uint engine, int numinfo, int prop, ByteReader &buf)
using | CachedCallback = std::pair< uint16_t, SpriteGroupID >
typedef bool(* | DataHandler) (size_t, ByteReader &)
| Type of callback function for binary nodes.
typedef bool(* | TextHandler) (uint8_t, std::string_view str)
| Type of callback function for text nodes.
typedef bool(* | BranchHandler) (ByteReader &)
| Type of callback function for branch nodes.

## Enumerations
enum | ChangeInfoResult { CIR_SUCCESS , CIR_DISABLED , CIR_UNHANDLED , CIR_UNKNOWN , CIR_INVALID_ID }
| Possible return values for the FeatureChangeInfo functions. More...

## Functions
const std::vector< GRFFile * > & | GetAllGRFFiles ()
template<VehicleType T>
static bool | IsValidNewGRFImageIndex (uint8_t image_index)
| Helper to check whether an image index is valid for a particular NewGRF vehicle.
void | GrfMsgI (int severity, const std::string &msg)
| Debug() function dedicated to newGRF debugging messages Function is essentially the same as Debug(grf, severity, ...) with the addition of file:line information when parsing grf files.
static GRFFile * | GetFileByGRFID (uint32_t grfid)
| Obtain a NewGRF file by its grfID.
static GRFFile * | GetFileByFilename (const std::string &filename)
| Obtain a NewGRF file by its filename.
static void | ClearTemporaryNewGRFData (GRFFile *gf)
| Reset all NewGRFData that was used only while processing data.
static GRFError * | DisableGrf (StringID message=STR_NULL, GRFConfig *config=nullptr)
| Disable a GRF.
static void | AddStringForMapping (StringID source, std::function< void(StringID)> &&func)
| Record a static StringID for getting translated later.
static void | AddStringForMapping (StringID source, StringID *target)
| Record a static StringID for getting translated later.
static StringID | TTDPStringIDToOTTDStringIDMapping (StringID str)
| Perform a mapping from TTDPatch's string IDs to OpenTTD's string IDs, but only for the ones we are aware off; the rest like likely unused and will show a warning.
StringID | MapGRFStringID (uint32_t grfid, StringID str)
| Used when setting an object's property to map to the GRF's strings while taking in consideration the "drift" between TTDPatch string system and OpenTTD's one.
static void | SetNewGRFOverride (uint32_t source_grfid, uint32_t target_grfid)
| Set the override for a NewGRF.
static GRFFile * | GetCurrentGRFOverride ()
| Get overridden GRF for current GRF if present.
static Engine * | GetNewEngine (const GRFFile *file, VehicleType type, uint16_t internal_id, bool static_access=false)
| Returns the engine associated to a certain internal_id, resp.
EngineID | GetNewEngineID (const GRFFile *file, VehicleType type, uint16_t internal_id)
| Return the ID of a new engine.
static void | MapSpriteMappingRecolour (PalSpriteID *grf_sprite)
| Map the colour modifiers of TTDPatch to those that Open is using.
static TileLayoutFlags | ReadSpriteLayoutSprite (ByteReader &buf, bool read_flags, bool invert_action1_flag, bool use_cur_spritesets, int feature, PalSpriteID *grf_sprite, uint16_t *max_sprite_offset=nullptr, uint16_t *max_palette_offset=nullptr)
| Read a sprite and a palette from the GRF and convert them into a format suitable to OpenTTD.
static void | ReadSpriteLayoutRegisters (ByteReader &buf, TileLayoutFlags flags, bool is_parent, NewGRFSpriteLayout *dts, uint index)
| Preprocess the TileLayoutFlags and read register modifiers from the GRF.
static bool | ReadSpriteLayout (ByteReader &buf, uint num_building_sprites, bool use_cur_spritesets, uint8_t feature, bool allow_var10, bool no_z_position, NewGRFSpriteLayout *dts)
| Read a spritelayout from the GRF.
static CargoTypes | TranslateRefitMask (uint32_t refit_mask)
| Translate the refit mask.
static void | ConvertTTDBasePrice (uint32_t base_pointer, const char *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.
static ChangeInfoResult | CommonVehicleChangeInfo (EngineInfo *ei, int prop, ByteReader &buf)
| Define properties common to all vehicles.
static ChangeInfoResult | RailVehicleChangeInfo (uint engine, int numinfo, int prop, ByteReader &buf)
| Define properties for rail vehicles.
static ChangeInfoResult | RoadVehicleChangeInfo (uint engine, int numinfo, int prop, ByteReader &buf)
| Define properties for road vehicles.
static ChangeInfoResult | ShipVehicleChangeInfo (uint engine, int numinfo, int prop, ByteReader &buf)
| Define properties for ships.
static ChangeInfoResult | AircraftVehicleChangeInfo (uint engine, int numinfo, int prop, ByteReader &buf)
| Define properties for aircraft.
static ChangeInfoResult | StationChangeInfo (uint stid, int numinfo, int prop, ByteReader &buf)
| Define properties for stations.
static ChangeInfoResult | CanalChangeInfo (uint id, int numinfo, int prop, ByteReader &buf)
| Define properties for water features.
static ChangeInfoResult | BridgeChangeInfo (uint brid, int numinfo, int prop, ByteReader &buf)
| Define properties for bridges.
static ChangeInfoResult | IgnoreTownHouseProperty (int prop, ByteReader &buf)
| Ignore a house property.
static ChangeInfoResult | TownHouseChangeInfo (uint hid, int numinfo, int prop, ByteReader &buf)
| Define properties for houses.
template<typename T , typename TGetTableFunc >
static ChangeInfoResult | LoadTranslationTable (uint gvid, int numinfo, ByteReader &buf, TGetTableFunc gettable, std::string_view name)
| Load a cargo- or railtype-translation table.
static std::string | ReadDWordAsString (ByteReader &reader)
| Helper to read a DWord worth of bytes from the reader and to return it as a valid string.
static ChangeInfoResult | GlobalVarChangeInfo (uint gvid, int numinfo, int prop, ByteReader &buf)
| Define properties for global variables.
static ChangeInfoResult | GlobalVarReserveInfo (uint gvid, int numinfo, int prop, ByteReader &buf)
static ChangeInfoResult | CargoChangeInfo (uint cid, int numinfo, int prop, ByteReader &buf)
| Define properties for cargoes.
static ChangeInfoResult | SoundEffectChangeInfo (uint sid, int numinfo, int prop, ByteReader &buf)
| Define properties for sound effects.
static ChangeInfoResult | IgnoreIndustryTileProperty (int prop, ByteReader &buf)
| Ignore an industry tile property.
static ChangeInfoResult | IndustrytilesChangeInfo (uint indtid, int numinfo, int prop, ByteReader &buf)
| Define properties for industry tiles.
static ChangeInfoResult | IgnoreIndustryProperty (int prop, ByteReader &buf)
| Ignore an industry property.
static bool | ValidateIndustryLayout (const IndustryTileLayout &layout)
| Validate the industry layout; e.g.
static ChangeInfoResult | IndustriesChangeInfo (uint indid, int numinfo, int prop, ByteReader &buf)
| Define properties for industries.
static ChangeInfoResult | AirportChangeInfo (uint airport, int numinfo, int prop, ByteReader &buf)
| Define properties for airports.
static ChangeInfoResult | IgnoreObjectProperty (uint prop, ByteReader &buf)
| Ignore properties for objects.
static ChangeInfoResult | ObjectChangeInfo (uint id, int numinfo, int prop, ByteReader &buf)
| Define properties for objects.
static ChangeInfoResult | RailTypeChangeInfo (uint id, int numinfo, int prop, ByteReader &buf)
| Define properties for railtypes.
static ChangeInfoResult | RailTypeReserveInfo (uint id, int numinfo, int prop, ByteReader &buf)
static ChangeInfoResult | RoadTypeChangeInfo (uint id, int numinfo, int prop, ByteReader &buf, RoadTramType rtt)
| Define properties for roadtypes.
static ChangeInfoResult | RoadTypeChangeInfo (uint id, int numinfo, int prop, ByteReader &buf)
static ChangeInfoResult | TramTypeChangeInfo (uint id, int numinfo, int prop, ByteReader &buf)
static ChangeInfoResult | RoadTypeReserveInfo (uint id, int numinfo, int prop, ByteReader &buf, RoadTramType rtt)
static ChangeInfoResult | RoadTypeReserveInfo (uint id, int numinfo, int prop, ByteReader &buf)
static ChangeInfoResult | TramTypeReserveInfo (uint id, int numinfo, int prop, ByteReader &buf)
static ChangeInfoResult | AirportTilesChangeInfo (uint airtid, int numinfo, int prop, ByteReader &buf)
static ChangeInfoResult | IgnoreRoadStopProperty (uint prop, ByteReader &buf)
| Ignore properties for roadstops.
static ChangeInfoResult | RoadStopChangeInfo (uint id, int numinfo, int prop, ByteReader &buf)
static bool | HandleChangeInfoResult (const char *caller, ChangeInfoResult cir, uint8_t feature, uint8_t property)
static void | FeatureChangeInfo (ByteReader &buf)
static void | SafeChangeInfo (ByteReader &buf)
static void | ReserveChangeInfo (ByteReader &buf)
static void | NewSpriteSet (ByteReader &buf)
static void | SkipAct1 (ByteReader &buf)
static const SpriteGroup * | GetCallbackResultGroup (uint16_t value)
static const SpriteGroup * | GetGroupFromGroupID (uint8_t setid, uint8_t type, uint16_t groupid)
static const SpriteGroup * | CreateGroupFromGroupID (uint8_t feature, uint8_t setid, uint8_t type, uint16_t spriteid)
| Helper function to either create a callback or a result sprite group.
static void | NewSpriteGroup (ByteReader &buf)
std::span< const CargoLabel > | GetCargoTranslationTable (const GRFFile &grffile)
| Get the cargo translation table to use for the given GRF file.
static CargoID | TranslateCargo (uint8_t feature, uint8_t ctype)
static bool | IsValidGroupID (uint16_t groupid, const char *function)
static void | VehicleMapSpriteGroup (ByteReader &buf, uint8_t feature, uint8_t idcount)
static void | CanalMapSpriteGroup (ByteReader &buf, uint8_t idcount)
static void | StationMapSpriteGroup (ByteReader &buf, uint8_t idcount)
static void | TownHouseMapSpriteGroup (ByteReader &buf, uint8_t idcount)
static void | IndustryMapSpriteGroup (ByteReader &buf, uint8_t idcount)
static void | IndustrytileMapSpriteGroup (ByteReader &buf, uint8_t idcount)
static void | CargoMapSpriteGroup (ByteReader &buf, uint8_t idcount)
static void | ObjectMapSpriteGroup (ByteReader &buf, uint8_t idcount)
static void | RailTypeMapSpriteGroup (ByteReader &buf, uint8_t idcount)
static void | RoadTypeMapSpriteGroup (ByteReader &buf, uint8_t idcount, RoadTramType rtt)
static void | AirportMapSpriteGroup (ByteReader &buf, uint8_t idcount)
static void | AirportTileMapSpriteGroup (ByteReader &buf, uint8_t idcount)
static void | RoadStopMapSpriteGroup (ByteReader &buf, uint8_t idcount)
static void | FeatureMapSpriteGroup (ByteReader &buf)
static void | FeatureNewName (ByteReader &buf)
static uint16_t | SanitizeSpriteOffset (uint16_t &num, uint16_t offset, int max_sprites, const std::string_view name)
| Sanitize incoming sprite offsets for Action 5 graphics replacements.
std::span< const Action5Type > | GetAction5Types ()
| Get list of all action 5 types.
static void | GraphicsNew (ByteReader &buf)
static void | SkipAct5 (ByteReader &buf)
bool | GetGlobalVariable (uint8_t param, uint32_t *value, const GRFFile *grffile)
| Reads a variable common to VarAction2 and Action7/9/D.
static uint32_t | GetParamVal (uint8_t param, uint32_t *cond_val)
static void | CfgApply (ByteReader &buf)
static void | DisableStaticNewGRFInfluencingNonStaticNewGRFs (GRFConfig *c)
| Disable a static NewGRF when it is influencing another (non-static) NewGRF as this could cause desyncs.
static void | SkipIf (ByteReader &buf)
static void | ScanInfo (ByteReader &buf)
static void | GRFInfo (ByteReader &buf)
static bool | IsGRMReservedSprite (SpriteID first_sprite, uint16_t num_sprites)
| Check if a sprite ID range is within the GRM reversed range for the currently loading NewGRF.
static void | SpriteReplace (ByteReader &buf)
static void | SkipActA (ByteReader &buf)
static void | GRFLoadError (ByteReader &buf)
static void | GRFComment (ByteReader &buf)
static void | SafeParamSet (ByteReader &buf)
static uint32_t | GetPatchVariable (uint8_t param)
static uint32_t | PerformGRM (uint32_t *grm, uint16_t num_ids, uint16_t count, uint8_t op, uint8_t target, const char *type)
static void | ParamSet (ByteReader &buf)
| Action 0x0D: Set parameter.
static void | SafeGRFInhibit (ByteReader &buf)
static void | GRFInhibit (ByteReader &buf)
static void | FeatureTownName (ByteReader &buf)
| Action 0x0F - Define Town names.
static void | DefineGotoLabel (ByteReader &buf)
| Action 0x10 - Define goto label.
static void | ImportGRFSound (SoundEntry *sound)
| Process a sound import from another GRF file.
static void | LoadGRFSound (size_t offs, SoundEntry *sound)
| Load a sound from a file.
static void | GRFSound (ByteReader &buf)
static void | SkipAct11 (ByteReader &buf)
static void | LoadFontGlyph (ByteReader &buf)
| Action 0x12.
static void | SkipAct12 (ByteReader &buf)
| Action 0x12 (SKIP)
static void | TranslateGRFStrings (ByteReader &buf)
| Action 0x13.
static bool | ChangeGRFName (uint8_t langid, std::string_view str)
| Callback function for 'INFO'->'NAME' to add a translation to the newgrf name.
static bool | ChangeGRFDescription (uint8_t langid, std::string_view str)
| Callback function for 'INFO'->'DESC' to add a translation to the newgrf description.
static bool | ChangeGRFURL (uint8_t langid, std::string_view str)
| Callback function for 'INFO'->'URL_' to set the newgrf url.
static bool | ChangeGRFNumUsedParams (size_t len, ByteReader &buf)
| Callback function for 'INFO'->'NPAR' to set the number of valid parameters.
static bool | ChangeGRFPalette (size_t len, ByteReader &buf)
| Callback function for 'INFO'->'PALS' to set the number of valid parameters.
static bool | ChangeGRFBlitter (size_t len, ByteReader &buf)
| Callback function for 'INFO'->'BLTR' to set the blitter info.
static bool | ChangeGRFVersion (size_t len, ByteReader &buf)
| Callback function for 'INFO'->'VRSN' to the version of the NewGRF.
static bool | ChangeGRFMinVersion (size_t len, ByteReader &buf)
| Callback function for 'INFO'->'MINV' to the minimum compatible version of the NewGRF.
static bool | ChangeGRFParamName (uint8_t langid, std::string_view str)
| Callback function for 'INFO'->'PARAM'->param_num->'NAME' to set the name of a parameter.
static bool | ChangeGRFParamDescription (uint8_t langid, std::string_view str)
| Callback function for 'INFO'->'PARAM'->param_num->'DESC' to set the description of a parameter.
static bool | ChangeGRFParamType (size_t len, ByteReader &buf)
| Callback function for 'INFO'->'PARAM'->param_num->'TYPE' to set the typeof a parameter.
static bool | ChangeGRFParamLimits (size_t len, ByteReader &buf)
| Callback function for 'INFO'->'PARAM'->param_num->'LIMI' to set the min/max value of a parameter.
static bool | ChangeGRFParamMask (size_t len, ByteReader &buf)
| Callback function for 'INFO'->'PARAM'->param_num->'MASK' to set the parameter and bits to use.
static bool | ChangeGRFParamDefault (size_t len, ByteReader &buf)
| Callback function for 'INFO'->'PARAM'->param_num->'DFLT' to set the default value.
static bool | SkipUnknownInfo (ByteReader &buf, uint8_t type)
| Try to skip the current node and all subnodes (if it's a branch node).
static bool | HandleNodes (ByteReader &buf, AllowedSubtags *tags)
static bool | ChangeGRFParamValueNames (ByteReader &buf)
| Callback function for 'INFO'->'PARA'->param_num->'VALU' to set the names of some parameter values (type uint/enum) or the names of some bits (type bitmask).
static bool | HandleParameterInfo (ByteReader &buf)
| Callback function for 'INFO'->'PARA' to set extra information about the parameters.
static bool | HandleNode (uint8_t type, uint32_t id, ByteReader &buf, AllowedSubtags subtags[])
| Handle the nodes of an Action14.
static bool | HandleNodes (ByteReader &buf, AllowedSubtags subtags[])
| Handle the contents of a 'C' choice of an Action14.
static void | StaticGRFInfo (ByteReader &buf)
| Handle Action 0x14.
static void | GRFUnsafe (ByteReader &)
| Set the current NewGRF as unsafe for static use.
static void | InitializeGRFSpecial ()
| Initialize the TTDPatch flags.
static void | ResetCustomStations ()
| Reset and clear all NewGRF stations.
static void | ResetCustomHouses ()
| Reset and clear all NewGRF houses.
static void | ResetCustomAirports ()
| Reset and clear all NewGRF airports.
static void | ResetCustomIndustries ()
| Reset and clear all NewGRF industries.
static void | ResetCustomObjects ()
| Reset and clear all NewObjects.
static void | ResetCustomRoadStops ()
static void | ResetNewGRF ()
| Reset and clear all NewGRFs.
static void | ResetNewGRFErrors ()
| Clear all NewGRF errors.
void | ResetNewGRFData ()
| Reset all NewGRF loaded data.
void | ResetPersistentNewGRFData ()
| Reset NewGRF data which is stored persistently in savegames.
static void | BuildCargoTranslationMap ()
| Construct the Cargo Mapping.
static void | InitNewGRFFile (const GRFConfig *config)
| Prepare loading a NewGRF file with its config.
static CargoLabel | GetActiveCargoLabel (const std::initializer_list< CargoLabel > &labels)
| Find first cargo label that exists and is active from a list of cargo labels.
static CargoLabel | GetActiveCargoLabel (const std::variant< CargoLabel, MixedCargoType > &label)
| Get active cargo label from either a cargo label or climate-dependent mixed cargo type.
static void | CalculateRefitMasks ()
| Precalculate refit masks from cargo classes for all vehicles.
static void | FinaliseCanals ()
| Set to use the correct action0 properties for each canal feature.
static void | FinaliseEngineArray ()
| Check for invalid engines.
void | FinaliseCargoArray ()
| Check for invalid cargoes.
static bool | IsHouseSpecValid (HouseSpec *hs, const HouseSpec *next1, const HouseSpec *next2, const HouseSpec *next3, const std::string &filename)
| Check if a given housespec is valid and disable it if it's not.
static void | EnsureEarlyHouse (HouseZones bitmask)
| Make sure there is at least one house available in the year 0 for the given climate / housezone combination.
static void | FinaliseHouseArray ()
| Add all new houses to the house array.
static void | FinaliseIndustriesArray ()
| Add all new industries to the industry array.
static void | FinaliseObjectsArray ()
| Add all new objects to the object array.
static void | FinaliseAirportsArray ()
| Add all new airports to the airport array.
static void | DecodeSpecialSprite (uint8_t *buf, uint num, GrfLoadingStage stage)
static void | LoadNewGRFFileFromFile (GRFConfig *config, GrfLoadingStage stage, SpriteFile &file)
| Load a particular NewGRF from a SpriteFile.
void | LoadNewGRFFile (GRFConfig *config, GrfLoadingStage stage, Subdirectory subdir, bool temporary)
| Load a particular NewGRF.
static void | ActivateOldShore ()
| Relocates the old shore sprites at new positions.
static void | ActivateOldTramDepot ()
| Replocate the old tram depot sprites to the new position, if no new ones were loaded.
static void | FinalisePriceBaseMultipliers ()
| Decide whether price base multipliers of grfs shall apply globally or only to the grf specifying them.
void | InitGRFTownGeneratorNames ()
| Allocate memory for the NewGRF town names.
static void | AfterLoadGRFs ()
| Finish loading NewGRFs and execute needed post-processing.
void | LoadNewGRF (SpriteID load_index, uint num_baseset)
| Load all the NewGRFs.

## Variables
static std::vector< GRFFile * > | _grf_files
| List of all loaded GRF files.
uint8_t | _misc_grf_features = 0
| Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E.
static uint32_t | _ttdpatch_flags [8]
| 32 * 8 = 256 flags.
GRFLoadedFeatures | _loaded_newgrf_features
| Indicates which are the newgrf features currently loaded ingame.
static const uint | MAX_SPRITEGROUP = UINT8_MAX
| Maximum GRF-local ID for a spritegroup.
static GrfProcessingState | _cur
static const uint | NUM_STATIONS_PER_GRF = UINT16_MAX - 1
| The maximum amount of stations a single GRF is allowed to add.
static std::vector< GRFTempEngineData > | _gted
| Temporary engine data used during NewGRF loading.
static uint32_t | _grm_engines [256]
| Contains the GRF ID of the owner of a vehicle if it has been reserved.
static uint32_t | _grm_cargoes [NUM_CARGO *2]
| Contains the GRF ID of the owner of a cargo if it has been reserved.
static std::map< GRFLocation, std::pair< SpriteID, uint16_t > > | _grm_sprites
static GRFLineToSpriteOverride | _grf_line_to_action6_sprite_override
static std::vector< StringIDMapping > | _string_to_grf_mapping
| Strings to be mapped during load.
static std::map< uint32_t, uint32_t > | _grf_id_overrides
static std::vector< CachedCallback > | _cached_callback_groups
| Sorted list of cached callback result spritegroups.
static constexpr auto | _action5_types
| The information about action 5 types.
static GRFParameterInfo * | _cur_parameter
| The parameter which info is currently changed by the newgrf.
AllowedSubtags | _tags_parameters []
| Action14 parameter tags.
AllowedSubtags | _tags_info []
| Action14 tags for the INFO node.
AllowedSubtags | _tags_root []
| Action14 root tags.

## Detailed Description

Base of all NewGRF support.

Definition in file newgrf.cpp.

## Macro Definition Documentation

## ◆ TEXTID_TO_STRINGID

#define TEXTID_TO_STRINGID | ( |  | begin,
|  |  | end,
|  |  | stringid,
|  |  | stringend
| ) |  |

Value:
static_assert(stringend - stringid == end - begin); \
if (str >= begin && str <= end) return str + (stringid - begin)

## Typedef Documentation

## ◆ BranchHandler

typedef bool(* BranchHandler) (ByteReader &)

Type of callback function for branch nodes.

Definition at line 8365 of file newgrf.cpp.

## ◆ CachedCallback

using CachedCallback = std::pair<uint16_t, SpriteGroupID>

Definition at line 5155 of file newgrf.cpp.

## ◆ DataHandler

typedef bool(* DataHandler) (size_t, ByteReader &)

Type of callback function for binary nodes.

Definition at line 8363 of file newgrf.cpp.

## ◆ GRFLineToSpriteOverride

typedef std::map<GRFLocation, std::vector<uint8_t> > GRFLineToSpriteOverride

Definition at line 377 of file newgrf.cpp.

## ◆ SpecialSpriteHandler

typedef void(* SpecialSpriteHandler) (ByteReader &buf)

Definition at line 309 of file newgrf.cpp.

## ◆ TextHandler

typedef bool(* TextHandler) (uint8_t, std::string_view str)

Type of callback function for text nodes.

Definition at line 8364 of file newgrf.cpp.

## ◆ VCI_Handler

typedef ChangeInfoResult(* VCI_Handler) (uint engine, int numinfo, int prop, ByteReader &buf)

Definition at line 1008 of file newgrf.cpp.

## Enumeration Type Documentation

## ◆ ChangeInfoResult

enum ChangeInfoResult

Possible return values for the FeatureChangeInfo functions.

Enumerator
CIR_SUCCESS | Variable was parsed and read.
CIR_DISABLED | GRF was disabled due to error.
CIR_UNHANDLED | Variable was parsed but unread.
CIR_UNKNOWN | Variable is unknown.
CIR_INVALID_ID | Attempt to modify an invalid ID.

Definition at line 1000 of file newgrf.cpp.

## Function Documentation

## ◆ ActivateOldShore()

static void ActivateOldShore | ( |  | ) |
| static

Relocates the old shore sprites at new positions.

1. If shore sprites are neither loaded by Action5 nor ActionA, the extra sprites from openttd(w/d).grf are used. (SHORE_REPLACE_ONLY_NEW)
2. If a newgrf replaces some shore sprites by ActionA. The (maybe also replaced) grass tiles are used for corner shores. (SHORE_REPLACE_ACTION_A)
3. If a newgrf replaces shore sprites by Action5 any shore replacement by ActionA has no effect. (SHORE_REPLACE_ACTION_5)

Definition at line 9826 of file newgrf.cpp.

References _loaded_newgrf_features, GRFLoadedFeatures::shore, SHORE_REPLACE_ACTION_5, SHORE_REPLACE_ACTION_A, SHORE_REPLACE_NONE, and SPR_SHORE_BASE.

Referenced by AfterLoadGRFs().

## ◆ ActivateOldTramDepot()

static void ActivateOldTramDepot | ( |  | ) |
| static

Replocate the old tram depot sprites to the new position, if no new ones were loaded.

Definition at line 9863 of file newgrf.cpp.

References _loaded_newgrf_features, GRFLoadedFeatures::tram, and TRAMWAY_REPLACE_DEPOT_WITH_TRACK.

Referenced by AfterLoadGRFs().

## ◆ AddStringForMapping() [1/2]

static void AddStringForMapping | ( | StringID | source,
|  | std::function< void(StringID)> && | func
| ) |  |
| static

Record a static StringID for getting translated later.

Parameters

  source | Source StringID (GRF local).
  func | Function to call to set the mapping result.

Definition at line 473 of file newgrf.cpp.

References _string_to_grf_mapping, and GrfProcessingState::grffile.

Referenced by AddStringForMapping(), AirportChangeInfo(), CargoChangeInfo(), IndustriesChangeInfo(), ObjectChangeInfo(), RailTypeChangeInfo(), RoadTypeChangeInfo(), StationChangeInfo(), and TownHouseChangeInfo().

## ◆ AddStringForMapping() [2/2]

static void AddStringForMapping | ( | StringID | source,
|  | StringID * | target
| ) |  |
| static

Record a static StringID for getting translated later.

Parameters

  source | Source StringID (GRF local).
  target | Destination for the mapping result.

Definition at line 484 of file newgrf.cpp.

References AddStringForMapping().

## ◆ AfterLoadGRFs()

static void AfterLoadGRFs | ( |  | ) |
| static

Finish loading NewGRFs and execute needed post-processing.

Definition at line 9994 of file newgrf.cpp.

References _cached_callback_groups, _gted, _string_to_grf_mapping, ActivateOldShore(), ActivateOldTramDepot(), BindAirportSpecs(), BuildIndustriesLegend(), BuildLinkStatsLegend(), CalculateRefitMasks(), EngineInfo::climates, CommitVehicleListOrderChanges(), EF_ROAD_TRAM, FinaliseAirportsArray(), FinaliseCanals(), FinaliseCargoArray(), FinaliseEngineArray(), FinaliseHouseArray(), FinaliseIndustriesArray(), FinaliseObjectsArray(), FinalisePriceBaseMultipliers(), Engine::GetGRF(), GetRailTypeByLabel(), GetRoadTypeByLabel(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, InitGRFTownGeneratorNames(), InitializeSortedCargoSpecs(), InitRailTypes(), InitRoadTypes(), RailVehicleInfo::intended_railtype, INVALID_RAILTYPE, INVALID_ROADTYPE, Engine::IterateType(), MapGRFStringID(), RoadVehicleInfo::max_speed, EngineInfo::misc_flags, RailVehicleInfo::railtype, RoadVehicleInfo::roadtype, GRFFile::roadtype_list, ROADTYPE_ROAD, ROADTYPE_TRAM, SetYearEngineAgingStops(), SortIndustryTypes(), GRFFile::tramtype_list, VEH_ROAD, and VEH_TRAIN.

Referenced by LoadNewGRF().

## ◆ AircraftVehicleChangeInfo()

static ChangeInfoResult AircraftVehicleChangeInfo | ( | uint | engine,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for aircraft.

Parameters

  engine | Local ID of the aircraft.
  numinfo | Number of subsequent IDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 1764 of file newgrf.cpp.

References _gted, _loaded_newgrf_features, AlterVehicleListOrder(), AssignBit(), EngineInfo::base_intro, EngineInfo::callback_mask, EngineInfo::cargo_age_period, CIR_INVALID_ID, CIR_SUCCESS, CommonVehicleChangeInfo(), EF_USES_2CC, GetCargoTranslation(), GetNewEngine(), GetNewGRFSoundID(), GrfProcessingState::grffile, GRFLoadedFeatures::has_2CC, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsValidCargoID(), AircraftVehicleInfo::mail_capacity, AircraftVehicleInfo::max_range, AircraftVehicleInfo::max_speed, EngineInfo::misc_flags, AircraftVehicleInfo::passenger_capacity, PROP_AIRCRAFT_CARGO_AGE_PERIOD, PROP_AIRCRAFT_COST_FACTOR, PROP_AIRCRAFT_MAIL_CAPACITY, PROP_AIRCRAFT_PASSENGER_CAPACITY, PROP_AIRCRAFT_RANGE, PROP_AIRCRAFT_RUNNING_COST_FACTOR, PROP_AIRCRAFT_SPEED, EngineInfo::retire_early, SB(), SetBit(), AircraftVehicleInfo::subtype, TranslateRefitMask(), EngineInfo::variant_id, and VEH_AIRCRAFT.

## ◆ AirportChangeInfo()

static ChangeInfoResult AirportChangeInfo | ( | uint | airport,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for airports.

Parameters

  airport | Local ID of the airport.
  numinfo | Number of subsequent airport IDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 3935 of file newgrf.cpp.

References OverrideManagerBase::Add(), AddStringForMapping(), CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, Clamp(), DIR_E, DIR_W, AirportSpec::enabled, GB(), OverrideManagerBase::GetID(), AirportSpec::GetWithoutOverride(), GrfProcessingState::grffile, INVALID_AIRPORTTILE, MAX_CATCHMENT, TimerGameConst< struct Calendar >::MAX_YEAR, NEW_AIRPORT_OFFSET, and NUM_AIRPORTS_PER_GRF.

## ◆ AirportMapSpriteGroup()

static void AirportMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | idcount
| ) |  |
| static

Definition at line 6058 of file newgrf.cpp.

## ◆ AirportTileMapSpriteGroup()

static void AirportTileMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | idcount
| ) |  |
| static

Definition at line 6090 of file newgrf.cpp.

## ◆ AirportTilesChangeInfo()

static ChangeInfoResult AirportTilesChangeInfo | ( | uint | airtid,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Definition at line 4701 of file newgrf.cpp.

## ◆ BridgeChangeInfo()

static ChangeInfoResult BridgeChangeInfo | ( | uint | brid,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for bridges.

Parameters

  brid | BridgeID of the bridge.
  numinfo | Number of subsequent bridgeIDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 2251 of file newgrf.cpp.

References _bridge, BridgeSpec::avail_year, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, Clamp(), BridgeSpec::flags, GetGRFStringID(), GrfProcessingState::grffile, MapSpriteMappingRecolour(), BridgeSpec::material, MAX_BRIDGES, BridgeSpec::max_length, TimerGameConst< struct Calendar >::MAX_YEAR, BridgeSpec::min_length, TimerGameConst< struct Calendar >::MIN_YEAR, TimerGameConst< struct Calendar >::ORIGINAL_BASE_YEAR, PalSpriteID::pal, BridgeSpec::price, BridgeSpec::speed, PalSpriteID::sprite, BridgeSpec::sprite_table, SPRITES_PER_BRIDGE_PIECE, and BridgeSpec::transport_name.

## ◆ BuildCargoTranslationMap()

static void BuildCargoTranslationMap | ( |  | ) |
| static

Construct the Cargo Mapping.

Note
  This is the reverse of a cargo translation table

Definition at line 8941 of file newgrf.cpp.

References GRFFile::cargo_map, find_index(), GetCargoTranslationTable(), GrfProcessingState::grffile, and CargoSpec::Iterate().

Referenced by LoadNewGRF().

## ◆ CalculateRefitMasks()

static void CalculateRefitMasks | ( |  | ) |
| static

Precalculate refit masks from cargo classes for all vehicles.

< Set if the vehicle shall carry only the default cargo

Definition at line 9050 of file newgrf.cpp.

References _cargo_mask, _gted, _settings_game, _standard_cargo_mask, CALLBACK_FAILED, EngineInfo::callback_mask, RailVehicleInfo::capacity, GRFFile::cargo_list, GRFFile::cargo_map, CBID_VEHICLE_CUSTOM_REFIT, CBM_VEHICLE_CUSTOM_REFIT, CC_ARMOURED, CC_BULK, CC_EXPRESS, CC_LIQUID, CC_MAIL, CC_PASSENGERS, CC_PIECE_GOODS, CC_REFRIGERATED, EngineInfo::climates, ClrBit(), CT_INVALID, CT_PASSENGERS, ErrorUnknownCallbackResult(), FindFirstBit(), GameSettings::game_creation, GetActiveCargoLabel(), Engine::GetGRF(), GetVehicleCallback(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsDefaultCargo(), IsValidCargoID(), CargoSpec::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Iterate(), GameCreationSettings::landscape, GRFTempEngineData::NONEMPTY, NUM_CARGO, ShipVehicleInfo::old_refittable, RAILVEH_WAGON, SetBit(), Engine::type, VEH_AIRCRAFT, VEH_SHIP, and VEH_TRAIN.

Referenced by AfterLoadGRFs().

## ◆ CanalChangeInfo()

static ChangeInfoResult CanalChangeInfo | ( | uint | id,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for water features.

Parameters

  id | Type of the first water feature.
  numinfo | Number of subsequent water feature ids to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 2213 of file newgrf.cpp.

References CanalProperties::callback_mask, GRFFile::canal_local_properties, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, CanalProperties::flags, and GrfProcessingState::grffile.

## ◆ CanalMapSpriteGroup()

static void CanalMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | idcount
| ) |  |
| static

Definition at line 5724 of file newgrf.cpp.

## ◆ CargoChangeInfo()

static ChangeInfoResult CargoChangeInfo | ( | uint | cid,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for cargoes.

Parameters

  cid | Local ID of the cargo.
  numinfo | Number of subsequent IDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 3050 of file newgrf.cpp.

References _cargo_mask, CargoSpec::abbrev, AddStringForMapping(), CargoSpec::bitnum, BSWAP32(), BuildCargoLabelMap(), CargoSpec::callback_mask, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, CargoSpec::classes, ClrBit(), CargoSpec::Get(), CargoSpec::grffile, GrfProcessingState::grffile, CargoSpec::initial_payment, CargoSpec::is_freight, CargoSpec::IsValid(), CargoSpec::label, CargoSpec::multiplier, CargoSpec::name, CargoSpec::name_single, NUM_CARGO, CargoSpec::quantifier, SetBit(), CargoSpec::sprite, TAE_FOOD, TAE_GOODS, TAE_MAIL, TAE_NONE, TAE_PASSENGERS, TAE_WATER, CargoSpec::town_acceptance_effect, CargoSpec::town_production_effect, CargoSpec::town_production_multiplier, TPE_MAIL, TPE_NONE, TPE_PASSENGERS, CargoSpec::units_volume, and CargoSpec::weight.

## ◆ CargoMapSpriteGroup()

static void CargoMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | idcount
| ) |  |
| static

Definition at line 5905 of file newgrf.cpp.

## ◆ CfgApply()

static void CfgApply | ( | ByteReader & | buf | ) |
| static

Definition at line 6760 of file newgrf.cpp.

## ◆ ChangeGRFBlitter()

static bool ChangeGRFBlitter | ( | size_t | len,
|  | ByteReader & | buf
| ) |  |
| static

Callback function for 'INFO'->'BLTR' to set the blitter info.

Definition at line 8220 of file newgrf.cpp.

References GrfProcessingState::grfconfig, GRFP_BLT_32BPP, GRFP_BLT_UNSET, and GRFConfig::palette.

## ◆ ChangeGRFDescription()

static bool ChangeGRFDescription | ( | uint8_t | langid,
|  | std::string_view | str
| ) |  |
| static

Callback function for 'INFO'->'DESC' to add a translation to the newgrf description.

Definition at line 8168 of file newgrf.cpp.

References AddGRFTextToList(), GrfProcessingState::grfconfig, GRFIdentifier::grfid, GRFConfig::ident, and GRFConfig::info.

## ◆ ChangeGRFMinVersion()

static bool ChangeGRFMinVersion | ( | size_t | len,
|  | ByteReader & | buf
| ) |  |
| static

Callback function for 'INFO'->'MINV' to the minimum compatible version of the NewGRF.

Definition at line 8255 of file newgrf.cpp.

References GrfProcessingState::grfconfig, GRFConfig::min_loadable_version, and GRFConfig::version.

## ◆ ChangeGRFName()

static bool ChangeGRFName | ( | uint8_t | langid,
|  | std::string_view | str
| ) |  |
| static

Callback function for 'INFO'->'NAME' to add a translation to the newgrf name.

Definition at line 8161 of file newgrf.cpp.

References AddGRFTextToList(), GrfProcessingState::grfconfig, GRFIdentifier::grfid, GRFConfig::ident, and GRFConfig::name.

## ◆ ChangeGRFNumUsedParams()

static bool ChangeGRFNumUsedParams | ( | size_t | len,
|  | ByteReader & | buf
| ) |  |
| static

Callback function for 'INFO'->'NPAR' to set the number of valid parameters.

Definition at line 8182 of file newgrf.cpp.

References GrfProcessingState::grfconfig, and GRFConfig::num_valid_params.

## ◆ ChangeGRFPalette()

static bool ChangeGRFPalette | ( | size_t | len,
|  | ByteReader & | buf
| ) |  |
| static

Callback function for 'INFO'->'PALS' to set the number of valid parameters.

Definition at line 8194 of file newgrf.cpp.

References GrfProcessingState::grfconfig, GRFP_GRF_ANY, GRFP_GRF_DOS, GRFP_GRF_UNSET, GRFP_GRF_WINDOWS, and GRFConfig::palette.

## ◆ ChangeGRFParamDefault()

static bool ChangeGRFParamDefault | ( | size_t | len,
|  | ByteReader & | buf
| ) |  |
| static

Callback function for 'INFO'->'PARAM'->param_num->'DFLT' to set the default value.

Definition at line 8351 of file newgrf.cpp.

References _cur_parameter, GRFParameterInfo::def_value, GrfProcessingState::grfconfig, and GRFConfig::has_param_defaults.

## ◆ ChangeGRFParamDescription()

static bool ChangeGRFParamDescription | ( | uint8_t | langid,
|  | std::string_view | str
| ) |  |
| static

Callback function for 'INFO'->'PARAM'->param_num->'DESC' to set the description of a parameter.

Definition at line 8284 of file newgrf.cpp.

References _cur_parameter, AddGRFTextToList(), GRFParameterInfo::desc, GrfProcessingState::grfconfig, GRFIdentifier::grfid, and GRFConfig::ident.

## ◆ ChangeGRFParamLimits()

static bool ChangeGRFParamLimits | ( | size_t | len,
|  | ByteReader & | buf
| ) |  |
| static

Callback function for 'INFO'->'PARAM'->param_num->'LIMI' to set the min/max value of a parameter.

Definition at line 8308 of file newgrf.cpp.

References _cur_parameter, GRFParameterInfo::max_value, GRFParameterInfo::min_value, PTYPE_UINT_ENUM, and GRFParameterInfo::type.

## ◆ ChangeGRFParamMask()

static bool ChangeGRFParamMask | ( | size_t | len,
|  | ByteReader & | buf
| ) |  |
| static

Callback function for 'INFO'->'PARAM'->param_num->'MASK' to set the parameter and bits to use.

Definition at line 8330 of file newgrf.cpp.

References _cur_parameter, GRFParameterInfo::first_bit, GRFParameterInfo::num_bit, and GRFParameterInfo::param_nr.

## ◆ ChangeGRFParamName()

static bool ChangeGRFParamName | ( | uint8_t | langid,
|  | std::string_view | str
| ) |  |
| static

Callback function for 'INFO'->'PARAM'->param_num->'NAME' to set the name of a parameter.

Definition at line 8277 of file newgrf.cpp.

References _cur_parameter, AddGRFTextToList(), GrfProcessingState::grfconfig, GRFIdentifier::grfid, GRFConfig::ident, and GRFParameterInfo::name.

## ◆ ChangeGRFParamType()

static bool ChangeGRFParamType | ( | size_t | len,
|  | ByteReader & | buf
| ) |  |
| static

Callback function for 'INFO'->'PARAM'->param_num->'TYPE' to set the typeof a parameter.

Definition at line 8291 of file newgrf.cpp.

References _cur_parameter, PTYPE_END, and GRFParameterInfo::type.

## ◆ ChangeGRFParamValueNames()

static bool ChangeGRFParamValueNames | ( | ByteReader & | buf | ) |
| static

Callback function for 'INFO'->'PARA'->param_num->'VALU' to set the names of some parameter values (type uint/enum) or the names of some bits (type bitmask).

In both cases the format is the same: Each subnode should be a text node with the value/bit number as id.

Definition at line 8455 of file newgrf.cpp.

References _cur_parameter, AddGRFTextToList(), GrfProcessingState::grfconfig, GRFIdentifier::grfid, GRFConfig::ident, GRFParameterInfo::max_value, SkipUnknownInfo(), and GRFParameterInfo::value_names.

## ◆ ChangeGRFURL()

static bool ChangeGRFURL | ( | uint8_t | langid,
|  | std::string_view | str
| ) |  |
| static

Callback function for 'INFO'->'URL_' to set the newgrf url.

Definition at line 8175 of file newgrf.cpp.

References AddGRFTextToList(), GrfProcessingState::grfconfig, GRFIdentifier::grfid, GRFConfig::ident, and GRFConfig::url.

## ◆ ChangeGRFVersion()

static bool ChangeGRFVersion | ( | size_t | len,
|  | ByteReader & | buf
| ) |  |
| static

Callback function for 'INFO'->'VRSN' to the version of the NewGRF.

Definition at line 8242 of file newgrf.cpp.

References GrfProcessingState::grfconfig, GRFConfig::min_loadable_version, and GRFConfig::version.

## ◆ ClearTemporaryNewGRFData()

static void ClearTemporaryNewGRFData | ( | GRFFile * | gf | ) |
| static

Reset all NewGRFData that was used only while processing data.

Definition at line 422 of file newgrf.cpp.

References GRFFile::labels.

Referenced by DisableGrf(), and LoadNewGRF().

## ◆ CommonVehicleChangeInfo()

static ChangeInfoResult CommonVehicleChangeInfo | ( | EngineInfo * | ei,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties common to all vehicles.

Parameters

  ei | Engine info.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 1017 of file newgrf.cpp.

References EngineInfo::base_intro, EngineInfo::base_life, CIR_SUCCESS, CIR_UNKNOWN, EngineInfo::climates, TimerGameConst< struct Calendar >::DAYS_TILL_ORIGINAL_BASE_YEAR, EngineInfo::lifelength, and PROP_VEHICLE_LOAD_AMOUNT.

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

## ◆ ConvertTTDBasePrice()

static void ConvertTTDBasePrice | ( | uint32_t | base_pointer,
|  | const char * | error_location,
|  | Price * | index
| ) |  |
| static

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

Parameters

  | base_pointer | TTD(P) Base Price Pointer
  | error_location | Function name for grf error messages
  [out] | index | If 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 980 of file newgrf.cpp.

Referenced by RailVehicleChangeInfo(), and RoadVehicleChangeInfo().

## ◆ CreateGroupFromGroupID()

static const SpriteGroup * CreateGroupFromGroupID | ( | uint8_t | feature,
|  | uint8_t | setid,
|  | uint8_t | type,
|  | uint16_t | spriteid
| ) |  |
| static

Helper function to either create a callback or a result sprite group.

Parameters

  feature | GrfSpecFeature to define spritegroup for.
  setid | SetID of the currently being parsed Action2. (only for debug output)
  type | Type of the currently being parsed Action2. (only for debug output)
  spriteid | Raw value from the GRF for the new spritegroup; describes either the return value or the referenced spritegroup.

Returns
  Created spritegroup.

Definition at line 5201 of file newgrf.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_spritegroup_pool >::CanAllocateItem(), GrfProcessingState::GetNumEnts(), GrfProcessingState::GetSprite(), HasBit(), GrfProcessingState::IsValidSpriteSet(), and GrfProcessingState::spriteid.

## ◆ DecodeSpecialSprite()

static void DecodeSpecialSprite | ( | uint8_t * | buf,
|  | uint | num,
|  | GrfLoadingStage | stage
| ) |  |
| static

Definition at line 9618 of file newgrf.cpp.

## ◆ DefineGotoLabel()

static void DefineGotoLabel | ( | ByteReader & | buf | ) |
| static

Action 0x10 - Define goto label.

Definition at line 7881 of file newgrf.cpp.

References GrfProcessingState::file, RandomAccessFile::GetPos(), GrfProcessingState::grffile, GRFFile::labels, and GrfProcessingState::nfo_line.

## ◆ DisableGrf()

static GRFError * DisableGrf | ( | StringID | message = `STR_NULL`,
|  | GRFConfig * | config = `nullptr`
| ) |  |
| static

Disable a GRF.

Parameters

  message | Error message or STR_NULL.
  config | GRFConfig to disable, nullptr for current.

Returns
  Error message of the GRF for further customisation.

Definition at line 433 of file newgrf.cpp.

References ClearTemporaryNewGRFData(), GCS_DISABLED, GetFileByGRFID(), GrfProcessingState::grfconfig, GrfProcessingState::grffile, GrfProcessingState::nfo_line, and GrfProcessingState::skip_sprites.

Referenced by DisableStaticNewGRFInfluencingNonStaticNewGRFs(), FeatureTownName(), IndustriesChangeInfo(), IndustrytilesChangeInfo(), LoadNewGRFFileFromFile(), ParamSet(), ReadSpriteLayout(), ReadSpriteLayoutRegisters(), ReadSpriteLayoutSprite(), TownHouseChangeInfo(), and TranslateGRFStrings().

## ◆ DisableStaticNewGRFInfluencingNonStaticNewGRFs()

static void DisableStaticNewGRFInfluencingNonStaticNewGRFs | ( | GRFConfig * | c | ) |
| static

Disable a static NewGRF when it is influencing another (non-static) NewGRF as this could cause desyncs.

We could just tell the NewGRF querying that the file doesn't exist, but that might give unwanted results. Disabling the NewGRF gives the best result as no NewGRF author can complain about that.

Parameters

  c | The NewGRF to disable.

Definition at line 6862 of file newgrf.cpp.

References GRFError::data, DisableGrf(), GRFConfig::GetName(), and GrfProcessingState::grfconfig.

Referenced by ParamSet().

## ◆ EnsureEarlyHouse()

static void EnsureEarlyHouse | ( | HouseZones | bitmask | ) |
| static

Make sure there is at least one house available in the year 0 for the given climate / housezone combination.

Parameters

  bitmask | The climate and housezone to check for. Exactly one climate bit and one housezone bit should be set.

Definition at line 9400 of file newgrf.cpp.

References HouseSpec::building_availability, HouseSpec::enabled, TimerGameConst< struct Calendar >::MAX_YEAR, HouseSpec::min_year, and HouseSpec::Specs().

Referenced by FinaliseHouseArray().

## ◆ FeatureChangeInfo()

static void FeatureChangeInfo | ( | ByteReader & | buf | ) |
| static

Definition at line 4943 of file newgrf.cpp.

## ◆ FeatureMapSpriteGroup()

static void FeatureMapSpriteGroup | ( | ByteReader & | buf | ) |
| static

Definition at line 6181 of file newgrf.cpp.

## ◆ FeatureNewName()

static void FeatureNewName | ( | ByteReader & | buf | ) |
| static

Definition at line 6290 of file newgrf.cpp.

## ◆ FeatureTownName()

static void FeatureTownName | ( | ByteReader & | buf | ) |
| static

Action 0x0F - Define Town names.

Definition at line 7803 of file newgrf.cpp.

References AddGRFString(), NamePartList::bitcount, NamePartList::bitstart, ClrBit(), DisableGrf(), GB(), GrfProcessingState::grffile, HasBit(), NamePart::id, GRFTownName::MAX_LISTS, NamePartList::maxprob, GRFTownName::partlists, NamePartList::parts, NamePart::prob, GRFTownName::styles, NamePart::text, and TranslateTTDPatchCodes().

## ◆ FinaliseAirportsArray()

static void FinaliseAirportsArray | ( |  | ) |
| static

Add all new airports to the airport array.

Airport properties can be set at any time in the GRF file, so we can only add a airport spec to the airport array after the file has finished loading.

Definition at line 9595 of file newgrf.cpp.

References _grf_files, and AirportSpec::enabled.

Referenced by AfterLoadGRFs().

## ◆ FinaliseCanals()

static void FinaliseCanals | ( |  | ) |
| static

Set to use the correct action0 properties for each canal feature.

Definition at line 9246 of file newgrf.cpp.

References _water_feature, CanalProperties::callback_mask, WaterFeature::callback_mask, GRFFile::canal_local_properties, CanalProperties::flags, WaterFeature::flags, and WaterFeature::grffile.

Referenced by AfterLoadGRFs().

## ◆ FinaliseCargoArray()

void FinaliseCargoArray | ( |  | ) |

Check for invalid cargoes.

Definition at line 9324 of file newgrf.cpp.

Referenced by AfterLoadGRFs().

## ◆ FinaliseEngineArray()

static void FinaliseEngineArray | ( |  | ) |
| static

Check for invalid engines.

Definition at line 9257 of file newgrf.cpp.

References _loaded_newgrf_features, _settings_game, EngineInfo::climates, GameSettings::game_creation, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetEngineLiveryScheme(), Engine::GetGRF(), GetNewEngineID(), Engine::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), HasVariants, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_ENGINE, IsFolded, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Iterate(), GameCreationSettings::landscape, GRFFilePropsBase< Tcnt >::local_id, RAILVEH_WAGON, SetBit(), EngineInfo::string_id, Engine::type, GRFLoadedFeatures::used_liveries, EngineInfo::variant_id, and VEH_TRAIN.

Referenced by AfterLoadGRFs().

## ◆ FinaliseHouseArray()

static void FinaliseHouseArray | ( |  | ) |
| static

Add all new houses to the house array.

House properties can be set at any time in the GRF file, so we can only add a house spec to the house array after the file has finished loading. We also need to check the dates, due to the TTDPatch behaviour described below that we need to emulate.

Definition at line 9425 of file newgrf.cpp.

References _grf_files, _settings_game, HouseSpec::accepts_cargo, HouseSpec::accepts_cargo_label, HouseSpec::building_flags, HouseSpec::cargo_acceptance, EnsureEarlyHouse(), RandomAccessFile::filename, GameSettings::game_creation, HouseSpec::Get(), HZ_SUBARTC_ABOVE, HZ_ZON1, HZ_ZON5, IsHouseSpecValid(), IsValidCargoID(), GameCreationSettings::landscape, lengthof, NUM_HOUSES, HouseOverrideManager::SetEntitySpec(), and HouseSpec::Specs().

Referenced by AfterLoadGRFs().

## ◆ FinaliseIndustriesArray()

static void FinaliseIndustriesArray | ( |  | ) |
| static

Add all new industries to the industry array.

Industry properties can be set at any time in the GRF file, so we can only add a industry spec to the industry array after the file has finished loading.

Definition at line 9503 of file newgrf.cpp.

References _grf_files, IndustrySpec::accepts_cargo, IndustryTileSpec::accepts_cargo, IndustrySpec::accepts_cargo_label, IndustryTileSpec::accepts_cargo_label, IndustrySpec::closure_text, IndustrySpec::conflicting, IndustrySpec::enabled, GetActiveCargoLabel(), GetGRFStringID(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grfid, GRFFilePropsBase< Tcnt >::HasGrfFile(), IsValidCargoID(), MapNewGRFIndustryType(), IndustrySpec::name, IndustrySpec::new_industry_text, IndustrySpec::produced_cargo_label, IndustrySpec::production_down_text, IndustrySpec::production_up_text, IndustryOverrideManager::SetEntitySpec(), and IndustrySpec::station_name.

Referenced by AfterLoadGRFs().

## ◆ FinaliseObjectsArray()

static void FinaliseObjectsArray | ( |  | ) |
| static

Add all new objects to the object array.

Object properties can be set at any time in the GRF file, so we can only add an object spec to the object array after the file has finished loading.

Definition at line 9577 of file newgrf.cpp.

References _grf_files, ObjectSpec::BindToClasses(), and ObjectOverrideManager::SetEntitySpec().

Referenced by AfterLoadGRFs().

## ◆ FinalisePriceBaseMultipliers()

static void FinalisePriceBaseMultipliers | ( |  | ) |
| static

Decide whether price base multipliers of grfs shall apply globally or only to the grf specifying them.

Features, to which '_grf_id_overrides' applies. Currently vehicle features only.

Definition at line 9878 of file newgrf.cpp.

References _grf_files, Debug, PriceBaseSpec::fallback_price, RandomAccessFile::filename, find_index(), GetFileByGRFID(), PriceBaseSpec::grf_feature, GRFFile::grf_features, HasBit(), GRFFile::price_base_multipliers, and SetPriceBaseMultiplier().

Referenced by AfterLoadGRFs().

## ◆ GetAction5Types()

std::span< const Action5Type > GetAction5Types | ( |  | ) |

Get list of all action 5 types.

Returns
  Read-only span of action 5 type information.

Definition at line 6467 of file newgrf.cpp.

References _action5_types.

Referenced by SpriteAlignerWindow::SetStringParameters().

## ◆ GetActiveCargoLabel() [1/2]

static CargoLabel GetActiveCargoLabel | ( | const std::initializer_list< CargoLabel > & | labels | ) |
| static

Find first cargo label that exists and is active from a list of cargo labels.

Parameters

  labels | List of cargo labels.

Returns
  First cargo label in list that exists, or CT_INVALID if none exist.

Definition at line 9015 of file newgrf.cpp.

References CT_INVALID.

Referenced by CalculateRefitMasks(), FinaliseIndustriesArray(), and GetActiveCargoLabel().

## ◆ GetActiveCargoLabel() [2/2]

static CargoLabel GetActiveCargoLabel | ( | const std::variant< CargoLabel, MixedCargoType > & | label | ) |
| static

Get active cargo label from either a cargo label or climate-dependent mixed cargo type.

Parameters

  label | Cargo label or climate-dependent mixed cargo type.

Returns
  Active cargo label, or CT_INVALID if cargo label is not active.

Definition at line 9029 of file newgrf.cpp.

References GetActiveCargoLabel(), MCT_GRAIN_WHEAT_MAIZE, MCT_LIVESTOCK_FRUIT, and MCT_VALUABLES_GOLD_DIAMONDS.

## ◆ GetAllGRFFiles()

const std::vector< GRFFile * > & GetAllGRFFiles | ( |  | ) |

Definition at line 72 of file newgrf.cpp.

## ◆ GetCallbackResultGroup()

static const SpriteGroup * GetCallbackResultGroup | ( | uint16_t | value | ) |
| static

Definition at line 5158 of file newgrf.cpp.

## ◆ GetCargoTranslationTable()

std::span< const CargoLabel > GetCargoTranslationTable | ( | const GRFFile & | grffile | ) |

Get the cargo translation table to use for the given GRF file.

Parameters

  grffile | GRF file.

Returns
  Readonly cargo translation table to use.

Definition at line 5591 of file newgrf.cpp.

References GRFFile::cargo_list, GetClimateDependentCargoTranslationTable(), and GetClimateIndependentCargoTranslationTable().

Referenced by BuildCargoTranslationMap().

## ◆ GetCurrentGRFOverride()

static GRFFile * GetCurrentGRFOverride | ( |  | ) |
| static

Get overridden GRF for current GRF if present.

Returns
  Overridden GRFFile if present, or nullptr.

Definition at line 609 of file newgrf.cpp.

References GetFileByGRFID(), and GrfProcessingState::grffile.

Referenced by LoadTranslationTable().

## ◆ GetFileByFilename()

static GRFFile * GetFileByFilename | ( | const std::string & | filename | ) |
| static

Obtain a NewGRF file by its filename.

Parameters

  filename | The filename to obtain the file for.

Returns
  The file.

Definition at line 413 of file newgrf.cpp.

References _grf_files.

Referenced by InitNewGRFFile(), and LoadNewGRFFile().

## ◆ GetFileByGRFID()

static GRFFile * GetFileByGRFID | ( | uint32_t | grfid | ) |
| static

Obtain a NewGRF file by its grfID.

Parameters

  grfid | The grfID to obtain the file for

Returns
  The file.

Definition at line 400 of file newgrf.cpp.

References _grf_files.

Referenced by DisableGrf(), FinalisePriceBaseMultipliers(), GetCurrentGRFOverride(), LanguageMap::GetLanguageMap(), GetNewEngine(), ImportGRFSound(), LoadNewGRF(), and ParamSet().

## ◆ GetGlobalVariable()

bool GetGlobalVariable | ( | uint8_t | param,
|  | uint32_t * | value,
|  | const GRFFile * | grffile
| ) |  |

Reads a variable common to VarAction2 and Action7/9/D.

Returns VarAction2 variable 'param' resp. Action7/9/D variable '0x80 + param'. If a variable is not accessible from all four actions, it is handled in the action specific functions.

Parameters

  param | variable number (as for VarAction2, for Action7/9/D you have to subtract 0x80 first).
  value | returns the value of the variable.
  grffile | NewGRF querying the variable

Returns
  true iff the variable is known and the value is returned in 'value'.

Definition at line 6584 of file newgrf.cpp.

References _misc_grf_features, _settings_game, Clamp(), GameSettings::construction, TimerGameCalendar::ConvertDateToYMD(), TimerGameCalendar::ConvertYMDToDate(), TimerGameTick::counter, TimerGameCalendar::date, TimerGameCalendar::date_fract, TimerGameConst< struct Calendar >::DAYS_TILL_ORIGINAL_BASE_YEAR, VehicleSettings::disable_elrails, GameSettings::game_creation, GB(), GetRailTypeInfo(), GetSnowLine(), GMB_TRAIN_WIDTH_32_PIXELS, GrfProcessingState::grfconfig, GrfProcessingState::grffile, GRFP_USE_MASK, HasBit(), TimerGame< struct Calendar >::IsLeapYear(), GameCreationSettings::landscape, ConstructionSettings::map_height_limit, TimerGameConst< struct Calendar >::ORIGINAL_BASE_YEAR, TimerGameConst< struct Calendar >::ORIGINAL_MAX_YEAR, GRFConfig::palette, RAILTYPE_ELECTRIC, RAILTYPE_MAGLEV, RAILTYPE_MONO, RAILTYPE_RAIL, VehicleSettings::road_side, SB(), SetBit(), SP_CUSTOM, TILE_HEIGHT, GRFFile::traininfo_vehicle_pitch, GRFFile::traininfo_vehicle_width, GameSettings::vehicle, and TimerGameCalendar::year.

## ◆ GetGroupFromGroupID()

static const SpriteGroup * GetGroupFromGroupID | ( | uint8_t | setid,
|  | uint8_t | type,
|  | uint16_t | groupid
| ) |  |
| static

Definition at line 5181 of file newgrf.cpp.

## ◆ GetNewEngine()

static Engine * GetNewEngine | ( | const GRFFile * | file,
|  | VehicleType | type,
|  | uint16_t | internal_id,
|  | bool | static_access = `false`
| ) |  |
| static

Returns the engine associated to a certain internal_id, resp.

allocates it.

Parameters

  file | NewGRF that wants to change the engine.
  type | Vehicle type.
  internal_id | Engine ID inside the NewGRF.
  static_access | If 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 627 of file newgrf.cpp.

References _engine_counts, _gted, _settings_game, BSWAP32(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::CanAllocateItem(), VehicleSettings::dynamic_engines, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetFileByGRFID(), EngineOverrideManager::GetID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::GetPoolSize(), GetRailTypeInfo(), Engine::grf_prop, GRFFilePropsBase< Tcnt >::grffile, GRFFilePropsBase< Tcnt >::grfid, GRFFilePropsBase< Tcnt >::HasGrfFile(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_ENGINE, RailTypeInfo::label, RailVehicleInfo::railtype, EngineOverrideManager::UseUnreservedID(), VEH_TRAIN, and GameSettings::vehicle.

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

## ◆ GetNewEngineID()

EngineID GetNewEngineID | ( | const GRFFile * | file,
|  | VehicleType | type,
|  | uint16_t | internal_id
| ) |  |

Return the ID of a new engine.

Parameters

  file | The NewGRF file providing the engine.
  type | The Vehicle type.
  internal_id | NewGRF-internal ID of the engine.

Returns
  The new EngineID.

Note
  depending on the dynamic_engine setting and a possible override property the grfID may be unique or overwriting or partially re-defining properties of an existing engine.

Definition at line 711 of file newgrf.cpp.

References _settings_game, VehicleSettings::dynamic_engines, EngineOverrideManager::GetID(), and GameSettings::vehicle.

Referenced by FinaliseEngineArray(), and GetNextArticulatedPart().

## ◆ GetParamVal()

static uint32_t GetParamVal | ( | uint8_t | param,
|  | uint32_t * | cond_val
| ) |  |
| static

Definition at line 6715 of file newgrf.cpp.

## ◆ GetPatchVariable()

static uint32_t GetPatchVariable | ( | uint8_t | param | ) |
| static

Definition at line 7327 of file newgrf.cpp.

## ◆ GlobalVarChangeInfo()

static ChangeInfoResult GlobalVarChangeInfo | ( | uint | gvid,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for global variables.

Parameters

  gvid | ID of the global variable.
  numinfo | Number of subsequent IDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 2755 of file newgrf.cpp.

References _currency_specs, _settings_game, GRFFile::cargo_list, CIR_SUCCESS, CIR_UNKNOWN, GameSettings::construction, CURRENCY_END, GB(), LanguagePackHeader::GetCaseIndex(), LanguagePackHeader::GetGenderIndex(), GetGRFStringID(), GetLanguage(), GetNewgrfCurrencyIdConverted(), GrfProcessingState::grffile, IsSnowLineSet(), GRFFile::language_map, ConstructionSettings::map_height_limit, MAX_LANG, MAX_NUM_CASES, MAX_NUM_GENDERS, LanguageMap::Mapping::newgrf_id, NFO_UTF8_IDENTIFIER, LanguageMap::Mapping::openttd_id, GRFFile::price_base_multipliers, GRFFile::railtype_list, ReadDWordAsString(), GRFFile::roadtype_list, SetSnowLine(), SNOW_LINE_DAYS, SNOW_LINE_MONTHS, StrMakeValid(), GRFFile::tramtype_list, and Utf8Decode().

## ◆ GlobalVarReserveInfo()

static ChangeInfoResult GlobalVarReserveInfo | ( | uint | gvid,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Definition at line 2973 of file newgrf.cpp.

## ◆ GraphicsNew()

static void GraphicsNew | ( | ByteReader & | buf | ) |
| static

Definition at line 6473 of file newgrf.cpp.

## ◆ GRFComment()

static void GRFComment | ( | ByteReader & | buf | ) |
| static

Definition at line 7295 of file newgrf.cpp.

## ◆ GRFInfo()

static void GRFInfo | ( | ByteReader & | buf | ) |
| static

Definition at line 7079 of file newgrf.cpp.

## ◆ GRFInhibit()

static void GRFInhibit | ( | ByteReader & | buf | ) |
| static

Definition at line 7780 of file newgrf.cpp.

## ◆ GRFLoadError()

static void GRFLoadError | ( | ByteReader & | buf | ) |
| static

Definition at line 7187 of file newgrf.cpp.

## ◆ GrfMsgI()

void GrfMsgI | ( | int | severity,
|  | const std::string & | msg
| ) |  |

Debug() function dedicated to newGRF debugging messages Function is essentially the same as Debug(grf, severity, ...) with the addition of file:line information when parsing grf files.

NOTE: for the above reason(s) GrfMsg() should ONLY be used for loading/parsing grf files, not for runtime debug messages as there is no file information available during that time.

Parameters

  severity | debugging severity level, see debug.h
  msg | the message

Definition at line 390 of file newgrf.cpp.

References Debug, GRFConfig::filename, GrfProcessingState::grfconfig, and GrfProcessingState::nfo_line.

## ◆ GRFSound()

static void GRFSound | ( | ByteReader & | buf | ) |
| static

Definition at line 7946 of file newgrf.cpp.

## ◆ GRFUnsafe()

static void GRFUnsafe | ( | ByteReader & |  | ) |
| static

Set the current NewGRF as unsafe for static use.

Note
  Used during safety scan on unsafe actions.

Definition at line 8658 of file newgrf.cpp.

References GRFConfig::flags, GCF_UNSAFE, GrfProcessingState::grfconfig, SetBit(), and GrfProcessingState::skip_sprites.

## ◆ HandleChangeInfoResult()

static bool HandleChangeInfoResult | ( | const char * | caller,
|  | ChangeInfoResult | cir,
|  | uint8_t | feature,
|  | uint8_t | property
| ) |  |
| static

Definition at line 4913 of file newgrf.cpp.

## ◆ HandleNode()

static bool HandleNode | ( | uint8_t | type,
|  | uint32_t | id,
|  | ByteReader & | buf,
|  | AllowedSubtags | subtags[]
| ) |  |
| static

Handle the nodes of an Action14.

Parameters

  type | Type of node.
  id | ID.
  buf | Buffer.
  subtags | Allowed subtags.

Returns
  Whether all tags could be handled.

Definition at line 8595 of file newgrf.cpp.

References AllowedSubtags::branch, BSWAP32(), AllowedSubtags::call_handler, AllowedSubtags::data, AllowedSubtags::id, SkipUnknownInfo(), AllowedSubtags::subtags, AllowedSubtags::text, and AllowedSubtags::type.

Referenced by HandleNodes().

## ◆ HandleNodes()

static bool HandleNodes | ( | ByteReader & | buf,
|  | AllowedSubtags | subtags[]
| ) |  |
| static

Handle the contents of a 'C' choice of an Action14.

Parameters

  buf | Buffer.
  subtags | List of subtags.

Returns
  Whether the nodes could all be handled.

Definition at line 8633 of file newgrf.cpp.

References HandleNode().

## ◆ HandleParameterInfo()

static bool HandleParameterInfo | ( | ByteReader & | buf | ) |
| static

Callback function for 'INFO'->'PARA' to set extra information about the parameters.

Each subnode of 'INFO'->'PARA' should be a branch node with the parameter number as id. The first parameter has id 0. The maximum parameter that can be changed is set by 'INFO'->'NPAR' which defaults to 80.

Definition at line 8502 of file newgrf.cpp.

References _cur_parameter, _tags_parameters, GrfProcessingState::grfconfig, GRFConfig::num_valid_params, GRFConfig::param_info, and SkipUnknownInfo().

## ◆ IgnoreIndustryProperty()

static ChangeInfoResult IgnoreIndustryProperty | ( | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Ignore an industry property.

Parameters

  prop | The property to ignore.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 3438 of file newgrf.cpp.

References CIR_SUCCESS, CIR_UNKNOWN, and INDUSTRY_ORIGINAL_NUM_INPUTS.

Referenced by IndustriesChangeInfo().

## ◆ IgnoreIndustryTileProperty()

static ChangeInfoResult IgnoreIndustryTileProperty | ( | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Ignore an industry tile property.

Parameters

  prop | The property to ignore.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 3263 of file newgrf.cpp.

References CIR_SUCCESS, and CIR_UNKNOWN.

Referenced by IndustrytilesChangeInfo().

## ◆ IgnoreObjectProperty()

static ChangeInfoResult IgnoreObjectProperty | ( | uint | prop,
|  | ByteReader & | buf
| ) |  |
| static

Ignore properties for objects.

Parameters

  prop | The property to ignore.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 4088 of file newgrf.cpp.

References CIR_SUCCESS, and CIR_UNKNOWN.

Referenced by ObjectChangeInfo().

## ◆ IgnoreRoadStopProperty()

static ChangeInfoResult IgnoreRoadStopProperty | ( | uint | prop,
|  | ByteReader & | buf
| ) |  |
| static

Ignore properties for roadstops.

Parameters

  prop | The property to ignore.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 4792 of file newgrf.cpp.

References CIR_SUCCESS, and CIR_UNKNOWN.

## ◆ IgnoreTownHouseProperty()

static ChangeInfoResult IgnoreTownHouseProperty | ( | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Ignore a house property.

Parameters

  prop | Property to read.
  buf | Property value.

Returns
  ChangeInfoResult.

Definition at line 2362 of file newgrf.cpp.

References CIR_SUCCESS, and CIR_UNKNOWN.

Referenced by TownHouseChangeInfo().

## ◆ ImportGRFSound()

static void ImportGRFSound | ( | SoundEntry * | sound | ) |
| static

Process a sound import from another GRF file.

Parameters

  sound | Destination for sound.

Definition at line 7899 of file newgrf.cpp.

References GrfProcessingState::file, GetFileByGRFID(), RandomAccessFile::ReadDword(), and RandomAccessFile::ReadWord().

## ◆ IndustriesChangeInfo()

static ChangeInfoResult IndustriesChangeInfo | ( | uint | indid,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for industries.

Parameters

  indid | Local ID of the industry.
  numinfo | Number of subsequent industry IDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 3561 of file newgrf.cpp.

References _settings_game, OverrideManagerBase::Add(), AddStringForMapping(), CHECK_NOTHING, CIR_DISABLED, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, CT_INVALID, DisableGrf(), IndustrySpec::enabled, GameSettings::game_creation, GB(), GetCargoTranslation(), OverrideManagerBase::GetID(), GFX_WATERTILE_SPECIALCHECK, GrfProcessingState::grffile, IgnoreIndustryProperty(), INDUSTRY_ORIGINAL_NUM_INPUTS, INDUSTRY_ORIGINAL_NUM_OUTPUTS, INVALID_INDUSTRYTILE, GameCreationSettings::landscape, lengthof, NEW_INDUSTRYOFFSET, NUM_INDUSTRYTYPES_PER_GRF, GRFError::param_value, SB(), ValidateIndustryLayout(), TileIndexDiffC::x, and TileIndexDiffC::y.

## ◆ IndustryMapSpriteGroup()

static void IndustryMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | idcount
| ) |  |
| static

Definition at line 5841 of file newgrf.cpp.

## ◆ IndustrytileMapSpriteGroup()

static void IndustrytileMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | idcount
| ) |  |
| static

Definition at line 5873 of file newgrf.cpp.

## ◆ IndustrytilesChangeInfo()

static ChangeInfoResult IndustrytilesChangeInfo | ( | uint | indtid,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for industry tiles.

Parameters

  indtid | Local ID of the industry tile.
  numinfo | Number of subsequent industry tile IDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 3303 of file newgrf.cpp.

References OverrideManagerBase::Add(), OverrideManagerBase::AddEntityID(), CIR_DISABLED, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, Clamp(), CT_INVALID, DisableGrf(), GB(), GetCargoTranslation(), GrfProcessingState::grffile, IgnoreIndustryTileProperty(), INDUSTRYTILE_NOANIM, NEW_INDUSTRYTILEOFFSET, NUM_INDUSTRYTILES_PER_GRF, and GRFError::param_value.

## ◆ InitGRFTownGeneratorNames()

void InitGRFTownGeneratorNames | ( |  | ) |
| extern

Allocate memory for the NewGRF town names.

Definition at line 81 of file newgrf_townname.cpp.

References GRFTownName::styles.

Referenced by AfterLoadGRFs().

## ◆ InitializeGRFSpecial()

static void InitializeGRFSpecial | ( |  | ) |
| static

Initialize the TTDPatch flags.

Definition at line 8668 of file newgrf.cpp.

References _generating_world, _settings_game, _ttdpatch_flags, EconomySettings::allow_town_roads, ConstructionSettings::build_on_slopes, GameSettings::construction, VehicleSettings::disable_elrails, VehicleSettings::dynamic_engines, GameSettings::economy, VehicleSettings::freight_trains, OrderSettings::gradual_loading, OrderSettings::improved_load, EconomySettings::inflation, ConstructionSettings::max_bridge_length, StationSettings::never_expire_airports, VehicleSettings::never_expire_vehicles, GameSettings::order, GameSettings::station, EconomySettings::station_noise_level, ConstructionSettings::train_signal_side, GameSettings::vehicle, and VehicleSettings::wagon_speed_limits.

Referenced by LoadNewGRF().

## ◆ InitNewGRFFile()

static void InitNewGRFFile | ( | const GRFConfig * | config | ) |
| static

Prepare loading a NewGRF file with its config.

Parameters

  config | The NewGRF configuration struct with name, id, parameters and alike.

Definition at line 8960 of file newgrf.cpp.

References _grf_files, GRFConfig::filename, GetFileByFilename(), and GrfProcessingState::grffile.

Referenced by LoadNewGRF().

## ◆ IsGRMReservedSprite()

static bool IsGRMReservedSprite | ( | SpriteID | first_sprite,
|  | uint16_t | num_sprites
| ) |  |
| static

Check if a sprite ID range is within the GRM reversed range for the currently loading NewGRF.

Parameters

  first_sprite | First sprite of range.
  num_sprites | Number of sprites in the range.

Returns
  True iff the NewGRF has reserved a range equal to or greater than the provided range.

Definition at line 7115 of file newgrf.cpp.

References GrfProcessingState::grffile.

## ◆ IsHouseSpecValid()

static bool IsHouseSpecValid | ( | HouseSpec * | hs,
|  | const HouseSpec * | next1,
|  | const HouseSpec * | next2,
|  | const HouseSpec * | next3,
|  | const std::string & | filename
| ) |  |
| static

Check if a given housespec is valid and disable it if it's not.

The housespecs that follow it are used to check the validity of multitile houses.

Parameters

  hs | The housespec to check.
  next1 | The housespec that follows `hs`.
  next2 | The housespec that follows `next1`.
  next3 | The housespec that follows `next2`.
  filename | The filename of the newgrf this house was defined in.

Returns
  Whether the given housespec is valid.

Definition at line 9354 of file newgrf.cpp.

References HouseSpec::building_availability, HouseSpec::building_flags, Debug, HouseSpec::enabled, HouseSpec::Get(), HouseSpec::grf_prop, HZ_CLIMALL, HZ_ZONALL, GRFFilePropsBase< Tcnt >::local_id, and HouseSpec::population.

Referenced by FinaliseHouseArray().

## ◆ IsValidGroupID()

static bool IsValidGroupID | ( | uint16_t | groupid,
|  | const char * | function
| ) |  |
| static

Definition at line 5635 of file newgrf.cpp.

## ◆ IsValidNewGRFImageIndex()

template<VehicleType T>

static bool IsValidNewGRFImageIndex | ( | uint8_t | image_index | ) |
| inlinestatic

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

Template Parameters

  T | The type of vehicle.

Parameters

  image_index | The image index to check.

Returns
  True iff the image index is valid, or 0xFD (use new graphics).

Definition at line 208 of file newgrf.cpp.

## ◆ LoadFontGlyph()

static void LoadFontGlyph | ( | ByteReader & | buf | ) |
| static

Action 0x12.

Definition at line 8051 of file newgrf.cpp.

References GrfProcessingState::file, LoadNextSprite(), GrfProcessingState::nfo_line, SetUnicodeGlyph(), and GrfProcessingState::spriteid.

## ◆ LoadGRFSound()

static void LoadGRFSound | ( | size_t | offs,
|  | SoundEntry * | sound
| ) |  |
| static

Load a sound from a file.

Parameters

  offs | File offset to read sound from.
  sound | Destination for sound.

Definition at line 7930 of file newgrf.cpp.

References GrfProcessingState::file, SpriteFile::GetContainerVersion(), and SoundEntry::grf_container_ver.

## ◆ LoadNewGRF()

void LoadNewGRF | ( | SpriteID | load_index,
|  | uint | num_baseset
| ) |  |

Load all the NewGRFs.

Parameters

  load_index | The offset for the first sprite to add.
  num_baseset | Number of NewGRFs at the front of the list to look up in the baseset dir instead of the newgrf dir.

Definition at line 10117 of file newgrf.cpp.

References _display_opt, _grfconfig, _networking, _settings_game, AfterLoadGRFs(), BASESET_DIR, BSWAP32(), BuildCargoTranslationMap(), GrfProcessingState::ClearDataForNextFile(), ClearTemporaryNewGRFData(), ClrBit(), TimerGameCalendar::ConvertYMDToDate(), TimerGameEconomy::ConvertYMDToDate(), TimerGameTick::counter, TimerGameCalendar::date, TimerGameEconomy::date, TimerGameCalendar::date_fract, TimerGameEconomy::date_fract, Debug, GRFConfig::error, GRFConfig::filename, FioCheckFileExists(), GRFConfig::flags, GameSettings::game_creation, GCF_INIT_ONLY, GCF_RESERVED, GCF_STATIC, GCF_SYSTEM, GCS_ACTIVATED, GCS_DISABLED, GCS_INITIALISED, GCS_NOT_FOUND, GCS_UNKNOWN, GetFileByGRFID(), GrfProcessingState::grffile, GRFIdentifier::grfid, HasBit(), GRFConfig::ident, InitializeGRFSpecial(), InitNewGRFFile(), LoadNewGRFFile(), NETWORK_MAX_GRF_COUNT, NEWGRF_DIR, GRFConfig::next, ResetNewGRFData(), SetBit(), SetNewGRFOverride(), GrfProcessingState::spriteid, GrfProcessingState::stage, GameCreationSettings::starting_year, GRFConfig::status, TimerGameCalendar::year, and TimerGameEconomy::year.

## ◆ LoadNewGRFFile()

void LoadNewGRFFile | ( | GRFConfig * | config,
|  | GrfLoadingStage | stage,
|  | Subdirectory | subdir,
|  | bool | temporary
| ) |  |

Load a particular NewGRF.

Parameters

  config | The configuration of the to be loaded NewGRF.
  stage | The loading stage of the NewGRF.
  subdir | The sub directory to find the NewGRF in.
  temporary | The NewGRF/sprite file is to be loaded temporarily and should be closed immediately, contrary to loading the SpriteFile and having it cached by the SpriteCache.

Definition at line 9790 of file newgrf.cpp.

References GRFConfig::filename, GRFConfig::flags, GCF_RESERVED, GCS_INITIALISED, GetFileByFilename(), GrfProcessingState::grffile, GRFP_USE_MASK, HasBit(), LoadNewGRFFileFromFile(), OpenCachedSpriteFile(), GRFConfig::palette, and GRFConfig::status.

Referenced by FillGRFDetails(), and LoadNewGRF().

## ◆ LoadNewGRFFileFromFile()

static void LoadNewGRFFileFromFile | ( | GRFConfig * | config,
|  | GrfLoadingStage | stage,
|  | SpriteFile & | file
| ) |  |
| static

Load a particular NewGRF from a SpriteFile.

Parameters

  config | The configuration of the to be loaded NewGRF.
  stage | The loading stage of the NewGRF.
  file | The file to load the GRF data from.

Definition at line 9701 of file newgrf.cpp.

References ReusableBuffer< T >::Allocate(), GrfProcessingState::ClearDataForNextFile(), Debug, DisableGrf(), GrfProcessingState::file, GRFConfig::filename, SpriteFile::GetContainerVersion(), GrfProcessingState::grfconfig, GrfProcessingState::nfo_line, RandomAccessFile::ReadByte(), RandomAccessFile::ReadDword(), ReadGRFSpriteOffsets(), RandomAccessFile::ReadWord(), GrfProcessingState::skip_sprites, RandomAccessFile::SkipBytes(), and SkipSpriteData().

Referenced by LoadNewGRFFile().

## ◆ LoadTranslationTable()

template<typename T , typename TGetTableFunc >

static ChangeInfoResult LoadTranslationTable | ( | uint | gvid,
|  | int | numinfo,
|  | ByteReader & | buf,
|  | TGetTableFunc | gettable,
|  | std::string_view | name
| ) |  |
| static

Load a cargo- or railtype-translation table.

Parameters

  gvid | ID of the global variable. This is basically only checked for zerones.
  numinfo | Number of subsequent IDs to change the property for.
  buf | The property value.
  gettable | Function to get storage for the translation table.
  name | Name of the table for debug output.

Returns
  ChangeInfoResult.

Definition at line 2709 of file newgrf.cpp.

References BSWAP32(), CIR_INVALID_ID, CIR_SUCCESS, GetCurrentGRFOverride(), and GrfProcessingState::grffile.

## ◆ MapGRFStringID()

StringID MapGRFStringID | ( | uint32_t | grfid,
|  | StringID | str
| ) |  |

Used when setting an object's property to map to the GRF's strings while taking in consideration the "drift" between TTDPatch string system and OpenTTD's one.

Parameters

  grfid | Id of the grf file.
  str | StringID that we want to have the equivalent in OoenTTD.

Returns
  The properly adjusted StringID.

Definition at line 560 of file newgrf.cpp.

References GetGRFStringID(), IsInsideMM(), and TTDPStringIDToOTTDStringIDMapping().

Referenced by AfterLoadGRFs(), ChangeIndustryProduction(), RemapNewGRFStringControlCode(), and TranslateTTDPatchCodes().

## ◆ MapSpriteMappingRecolour()

static void MapSpriteMappingRecolour | ( | PalSpriteID * | grf_sprite | ) |
| static

Map the colour modifiers of TTDPatch to those that Open is using.

Parameters

  grf_sprite | Pointer to the structure been modified.

Definition at line 728 of file newgrf.cpp.

References ClrBit(), HasBit(), PalSpriteID::pal, PALETTE_MODIFIER_COLOUR, PALETTE_MODIFIER_TRANSPARENT, SetBit(), PalSpriteID::sprite, and SPRITE_MODIFIER_OPAQUE.

Referenced by BridgeChangeInfo(), and ReadSpriteLayoutSprite().

## ◆ NewSpriteGroup()

static void NewSpriteGroup | ( | ByteReader & | buf | ) |
| static

Definition at line 5221 of file newgrf.cpp.

## ◆ NewSpriteSet()

static void NewSpriteSet | ( | ByteReader & | buf | ) |
| static

Definition at line 5090 of file newgrf.cpp.

## ◆ ObjectChangeInfo()

static ChangeInfoResult ObjectChangeInfo | ( | uint | id,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for objects.

Parameters

  id | Local ID of the object.
  numinfo | Number of subsequent objectIDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 4135 of file newgrf.cpp.

References _loaded_newgrf_features, AddStringForMapping(), NewGRFClass< Tspec, Tindex, Tmax >::Allocate(), BSWAP32(), CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, GB(), GrfProcessingState::grffile, GRFLoadedFeatures::has_2CC, IgnoreObjectProperty(), NUM_OBJECTS_PER_GRF, OBJECT_FLAG_2CC_COLOUR, and OBJECT_SIZE_1X1.

## ◆ ObjectMapSpriteGroup()

static void ObjectMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | idcount
| ) |  |
| static

Definition at line 5932 of file newgrf.cpp.

## ◆ ParamSet()

static void ParamSet | ( | ByteReader & | buf | ) |
| static

Action 0x0D: Set parameter.

Definition at line 7453 of file newgrf.cpp.

References _engine_counts, _engine_offsets, _grm_cargoes, _grm_engines, _misc_grf_features, _networking, _settings_game, ClrBit(), RailTypeInfo::cost_multiplier, VehicleSettings::disable_elrails, DisableGrf(), DisableStaticNewGRFInfluencingNonStaticNewGRFs(), VehicleSettings::dynamic_engines, GRFConfig::flags, GB(), GCF_STATIC, GCS_DISABLED, GetFileByGRFID(), GetGRFConfig(), GRFFile::GetParam(), GMB_TRAIN_WIDTH_32_PIXELS, GrfProcessingState::grfconfig, GrfProcessingState::grffile, HasBit(), GrfProcessingState::nfo_line, NUM_CARGO, RAILTYPE_ELECTRIC, RAILTYPE_END, RAILTYPE_MAGLEV, RAILTYPE_MONO, RAILTYPE_RAIL, SetBit(), GrfProcessingState::skip_sprites, GrfProcessingState::spriteid, GrfProcessingState::stage, GRFConfig::status, GRFFile::traininfo_vehicle_pitch, GRFFile::traininfo_vehicle_width, GameSettings::vehicle, and GRFConfig::version.

## ◆ PerformGRM()

static uint32_t PerformGRM | ( | uint32_t * | grm,
|  | uint16_t | num_ids,
|  | uint16_t | count,
|  | uint8_t | op,
|  | uint8_t | target,
|  | const char * | type
| ) |  |
| static

Definition at line 7405 of file newgrf.cpp.

## ◆ RailTypeChangeInfo()

static ChangeInfoResult RailTypeChangeInfo | ( | uint | id,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for railtypes.

Parameters

  id | ID of the railtype.
  numinfo | Number of subsequent IDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 4265 of file newgrf.cpp.

References RailTypeInfo::acceleration_type, AddStringForMapping(), BSWAP32(), RailTypeInfo::build_caption, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, Clamp(), RailTypeInfo::compatible_railtypes, RailTypeInfo::cost_multiplier, RailTypeInfo::curve_speed, RailTypeInfo::fallback_railtype, RailTypeInfo::flags, GetRailTypeByLabel(), GrfProcessingState::grffile, RailTypeInfo::introduces_railtypes, RailTypeInfo::introduction_date, RailTypeInfo::introduction_required_railtypes, INVALID_RAILTYPE, RailTypeInfo::maintenance_multiplier, RailTypeInfo::map_colour, RailTypeInfo::max_speed, RailTypeInfo::menu_text, RailTypeInfo::name, RailTypeInfo::new_loco, RailTypeInfo::powered_railtypes, RAILTYPE_END, RailTypeInfo::replace_text, SetBit(), RailTypeInfo::sorting_order, RailTypeInfo::strings, and RailTypeInfo::toolbar_caption.

## ◆ RailTypeMapSpriteGroup()

static void RailTypeMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | idcount
| ) |  |
| static

Definition at line 5992 of file newgrf.cpp.

## ◆ RailTypeReserveInfo()

static ChangeInfoResult RailTypeReserveInfo | ( | uint | id,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Definition at line 4395 of file newgrf.cpp.

## ◆ RailVehicleChangeInfo()

static ChangeInfoResult RailVehicleChangeInfo | ( | uint | engine,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for rail vehicles.

Parameters

  engine | :ocal ID of the first vehicle.
  numinfo | Number of subsequent IDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 1060 of file newgrf.cpp.

References _gted, _loaded_newgrf_features, RailVehicleInfo::ai_passenger_only, RailVehicleInfo::air_drag, AlterVehicleListOrder(), EngineInfo::base_intro, EngineInfo::callback_mask, RailVehicleInfo::capacity, EngineInfo::cargo_age_period, CIR_INVALID_ID, CIR_SUCCESS, CommonVehicleChangeInfo(), ConvertTTDBasePrice(), RailVehicleInfo::cost_factor, CT_INVALID, RailVehicleInfo::curve_speed_mod, EC_DIESEL, EC_ELECTRIC, EC_MAGLEV, EC_MONORAIL, EC_STEAM, EF_USES_2CC, RailVehicleInfo::engclass, GetCargoTranslation(), GetNewEngine(), GrfProcessingState::grffile, GRFLoadedFeatures::has_2CC, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsValidCargoID(), RailVehicleInfo::max_speed, EngineInfo::misc_flags, RailVehicleInfo::pow_wag_power, RailVehicleInfo::pow_wag_weight, RailVehicleInfo::power, PROP_TRAIN_CARGO_AGE_PERIOD, PROP_TRAIN_CARGO_CAPACITY, PROP_TRAIN_COST_FACTOR, PROP_TRAIN_CURVE_SPEED_MOD, PROP_TRAIN_POWER, PROP_TRAIN_RUNNING_COST_FACTOR, PROP_TRAIN_SHORTEN_FACTOR, PROP_TRAIN_SPEED, PROP_TRAIN_TRACTIVE_EFFORT, PROP_TRAIN_USER_DATA, PROP_TRAIN_WEIGHT, GRFFile::railtype_list, RAILVEH_MULTIHEAD, RAILVEH_SINGLEHEAD, RAILVEH_WAGON, EngineInfo::retire_early, RailVehicleInfo::running_cost, SB(), SetBit(), RailVehicleInfo::shorten_factor, RailVehicleInfo::tractive_effort, TranslateRefitMask(), RailVehicleInfo::user_def_data, EngineInfo::variant_id, VE_DEFAULT, VE_DISABLE_EFFECT, VE_TYPE_COUNT, VE_TYPE_START, VEH_TRAIN, RailVehicleInfo::visual_effect, and RailVehicleInfo::weight.

## ◆ ReadDWordAsString()

static std::string ReadDWordAsString | ( | ByteReader & | reader | ) |
| static

Helper to read a DWord worth of bytes from the reader and to return it as a valid string.

Parameters

  reader | The source of the DWord.

Returns
  The read DWord as string.

Definition at line 2740 of file newgrf.cpp.

References StrMakeValid().

Referenced by GlobalVarChangeInfo().

## ◆ ReadSpriteLayout()

static bool ReadSpriteLayout | ( | ByteReader & | buf,
|  | uint | num_building_sprites,
|  | bool | use_cur_spritesets,
|  | uint8_t | feature,
|  | bool | allow_var10,
|  | bool | no_z_position,
|  | NewGRFSpriteLayout * | dts
| ) |  |
| static

Read a spritelayout from the GRF.

Parameters

  buf | Input
  num_building_sprites | Number of building sprites to read
  use_cur_spritesets | Whether to use currently referenceable action 1 sets.
  feature | GrfSpecFeature to use spritesets from.
  allow_var10 | Whether the spritelayout may specify var10 values for resolving multiple action-1-2-3 chains
  no_z_position | Whether bounding boxes have no Z offset
  dts | Layout container to output into

Returns
  True on error (GRF was disabled).

Definition at line 870 of file newgrf.cpp.

References NewGRFSpriteLayout::Allocate(), NewGRFSpriteLayout::AllocateRegisters(), ClrBit(), NewGRFSpriteLayout::consistent_max_offset, DrawTileSeqStruct::delta_x, DrawTileSeqStruct::delta_z, DisableGrf(), DrawTileSprites::ground, HasBit(), DrawTileSeqStruct::IsParentSprite(), TileLayoutRegisters::max_palette_offset, TileLayoutRegisters::max_sprite_offset, ReadSpriteLayoutRegisters(), ReadSpriteLayoutSprite(), DrawTileSprites::seq, GrfProcessingState::skip_sprites, TLF_KNOWN_FLAGS, and TLF_NON_GROUND_FLAGS.

Referenced by StationChangeInfo().

## ◆ ReadSpriteLayoutRegisters()

static void ReadSpriteLayoutRegisters | ( | ByteReader & | buf,
|  | TileLayoutFlags | flags,
|  | bool | is_parent,
|  | NewGRFSpriteLayout * | dts,
|  | uint | index
| ) |  |
| static

Preprocess the TileLayoutFlags and read register modifiers from the GRF.

Parameters

  buf | Input stream.
  flags | TileLayoutFlags to process.
  is_parent | Whether the sprite is a parentsprite with a bounding box.
  dts | Sprite layout to insert data into.
  index | Sprite index to process; 0 for ground sprite.

Definition at line 817 of file newgrf.cpp.

References NewGRFSpriteLayout::AllocateRegisters(), TileLayoutRegisters::child, DisableGrf(), TileLayoutRegisters::dodraw, TileLayoutRegisters::flags, TileLayoutRegisters::palette, TileLayoutRegisters::palette_var10, TileLayoutRegisters::parent, TileLayoutRegisters::sprite, TileLayoutRegisters::sprite_var10, TLF_BB_XY_OFFSET, TLF_BB_Z_OFFSET, TLF_CHILD_X_OFFSET, TLF_CHILD_Y_OFFSET, TLF_DODRAW, TLF_DRAWING_FLAGS, TLF_PALETTE, TLF_PALETTE_VAR10, TLF_SPRITE, TLF_SPRITE_VAR10, and TLR_MAX_VAR10.

Referenced by ReadSpriteLayout().

## ◆ ReadSpriteLayoutSprite()

static TileLayoutFlags ReadSpriteLayoutSprite | ( | ByteReader & | buf,
|  | bool | read_flags,
|  | bool | invert_action1_flag,
|  | bool | use_cur_spritesets,
|  | int | feature,
|  | PalSpriteID * | grf_sprite,
|  | uint16_t * | max_sprite_offset = `nullptr`,
|  | uint16_t * | max_palette_offset = `nullptr`
| ) |  |
| static

Read a sprite and a palette from the GRF and convert them into a format suitable to OpenTTD.

Parameters

  | buf | Input stream.
  | read_flags | Whether to read TileLayoutFlags.
  | invert_action1_flag | Set to true, if palette bit 15 means 'not from action 1'.
  | use_cur_spritesets | Whether to use currently referenceable action 1 sets.
  | feature | GrfSpecFeature to use spritesets from.
  [out] | grf_sprite | Read sprite and palette.
  [out] | max_sprite_offset | Optionally returns the number of sprites in the spriteset of the sprite. (0 if no spritset)
  [out] | max_palette_offset | Optionally returns the number of sprites in the spriteset of the palette. (0 if no spritset)

Returns
  Read TileLayoutFlags.

Definition at line 759 of file newgrf.cpp.

References ClrBit(), DisableGrf(), GB(), GrfProcessingState::GetNumEnts(), GrfProcessingState::GetSprite(), HasBit(), GrfProcessingState::IsValidSpriteSet(), MapSpriteMappingRecolour(), PalSpriteID::pal, SB(), SetBit(), PalSpriteID::sprite, SPRITE_MODIFIER_CUSTOM_SPRITE, SPRITE_WIDTH, TLF_CUSTOM_PALETTE, TLF_PALETTE_REG_FLAGS, TLF_PALETTE_VAR10, TLF_SPRITE_REG_FLAGS, and TLF_SPRITE_VAR10.

Referenced by ReadSpriteLayout(), and StationChangeInfo().

## ◆ ReserveChangeInfo()

static void ReserveChangeInfo | ( | ByteReader & | buf | ) |
| static

Definition at line 5048 of file newgrf.cpp.

## ◆ ResetCustomAirports()

static void ResetCustomAirports | ( |  | ) |
| static

Reset and clear all NewGRF airports.

Definition at line 8773 of file newgrf.cpp.

References _grf_files.

Referenced by ResetNewGRFData().

## ◆ ResetCustomHouses()

static void ResetCustomHouses | ( |  | ) |
| static

Reset and clear all NewGRF houses.

Definition at line 8765 of file newgrf.cpp.

References _grf_files.

Referenced by ResetNewGRFData().

## ◆ ResetCustomIndustries()

static void ResetCustomIndustries | ( |  | ) |
| static

Reset and clear all NewGRF industries.

Definition at line 8782 of file newgrf.cpp.

References _grf_files.

Referenced by ResetNewGRFData().

## ◆ ResetCustomObjects()

static void ResetCustomObjects | ( |  | ) |
| static

Reset and clear all NewObjects.

Definition at line 8791 of file newgrf.cpp.

References _grf_files.

Referenced by ResetNewGRFData().

## ◆ ResetCustomRoadStops()

static void ResetCustomRoadStops | ( |  | ) |
| static

Definition at line 8798 of file newgrf.cpp.

## ◆ ResetCustomStations()

static void ResetCustomStations | ( |  | ) |
| static

Reset and clear all NewGRF stations.

Definition at line 8757 of file newgrf.cpp.

References _grf_files.

Referenced by ResetNewGRFData().

## ◆ ResetNewGRF()

static void ResetNewGRF | ( |  | ) |
| static

Reset and clear all NewGRFs.

Definition at line 8806 of file newgrf.cpp.

References _grf_files, and GrfProcessingState::grffile.

Referenced by ResetNewGRFData().

## ◆ ResetNewGRFData()

void ResetNewGRFData | ( |  | ) |

Reset all NewGRF loaded data.

Definition at line 8827 of file newgrf.cpp.

References _cached_callback_groups, _grm_cargoes, _grm_engines, _gted, _loaded_newgrf_features, _misc_grf_features, _settings_game, _water_feature, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::CleanPool(), CleanUpStrings(), ClearSnowLine(), GameSettings::game_creation, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::GetPoolSize(), GetRailTypeInfo(), GRFLoadedFeatures::has_2CC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Engine::IterateType(), RailTypeInfo::label, GameCreationSettings::landscape, RailVehicleInfo::railtype, NewGRFClass< Tspec, Tindex, Tmax >::Reset(), AirportSpec::ResetAirports(), AirportTileSpec::ResetAirportTiles(), ResetBridges(), ResetCurrencies(), ResetCustomAirports(), ResetCustomHouses(), ResetCustomIndustries(), ResetCustomObjects(), ResetCustomStations(), ResetGenericCallbacks(), ResetIndustries(), ResetNewGRF(), ResetNewGRFErrors(), ResetObjects(), ResetPriceBaseMultipliers(), ResetRailTypes(), ResetRoadTypes(), SetupCargoForClimate(), SetupEngines(), GRFLoadedFeatures::shore, SHORE_REPLACE_NONE, GRFLoadedFeatures::tram, TRAMWAY_REPLACE_DEPOT_NONE, GRFLoadedFeatures::used_liveries, and VEH_TRAIN.

Referenced by LoadNewGRF(), and ShutdownGame().

## ◆ ResetNewGRFErrors()

static void ResetNewGRFErrors | ( |  | ) |
| static

Clear all NewGRF errors.

Definition at line 8817 of file newgrf.cpp.

References _grfconfig, GRFConfig::error, and GRFConfig::next.

Referenced by ResetNewGRFData().

## ◆ ResetPersistentNewGRFData()

void ResetPersistentNewGRFData | ( |  | ) |

Reset NewGRF data which is stored persistently in savegames.

Definition at line 8926 of file newgrf.cpp.

References OverrideManagerBase::ResetMapping(), and EngineOverrideManager::ResetToDefaultMapping().

## ◆ RoadStopChangeInfo()

static ChangeInfoResult RoadStopChangeInfo | ( | uint | id,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Definition at line 4826 of file newgrf.cpp.

## ◆ RoadStopMapSpriteGroup()

static void RoadStopMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | idcount
| ) |  |
| static

Definition at line 6122 of file newgrf.cpp.

## ◆ RoadTypeChangeInfo() [1/2]

static ChangeInfoResult RoadTypeChangeInfo | ( | uint | id,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Definition at line 4602 of file newgrf.cpp.

## ◆ RoadTypeChangeInfo() [2/2]

static ChangeInfoResult RoadTypeChangeInfo | ( | uint | id,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf,
|  | RoadTramType | rtt
| ) |  |
| static

Define properties for roadtypes.

Parameters

  id | ID of the roadtype.
  numinfo | Number of subsequent IDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 4483 of file newgrf.cpp.

References AddStringForMapping(), BSWAP32(), RoadTypeInfo::build_caption, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, RoadTypeInfo::cost_multiplier, RoadTypeInfo::flags, GetRoadTypeByLabel(), GrfProcessingState::grffile, RoadTypeInfo::introduces_roadtypes, RoadTypeInfo::introduction_date, RoadTypeInfo::introduction_required_roadtypes, INVALID_ROADTYPE, RoadTypeInfo::maintenance_multiplier, RoadTypeInfo::map_colour, RoadTypeInfo::max_speed, RoadTypeInfo::menu_text, RoadTypeInfo::name, RoadTypeInfo::new_engine, RoadTypeInfo::powered_roadtypes, RoadTypeInfo::replace_text, ROADTYPE_END, SetBit(), RoadTypeInfo::sorting_order, RoadTypeInfo::strings, and RoadTypeInfo::toolbar_caption.

## ◆ RoadTypeMapSpriteGroup()

static void RoadTypeMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | idcount,
|  | RoadTramType | rtt
| ) |  |
| static

Definition at line 6024 of file newgrf.cpp.

## ◆ RoadTypeReserveInfo() [1/2]

static ChangeInfoResult RoadTypeReserveInfo | ( | uint | id,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Definition at line 4691 of file newgrf.cpp.

## ◆ RoadTypeReserveInfo() [2/2]

static ChangeInfoResult RoadTypeReserveInfo | ( | uint | id,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf,
|  | RoadTramType | rtt
| ) |  |
| static

Definition at line 4613 of file newgrf.cpp.

## ◆ RoadVehicleChangeInfo()

static ChangeInfoResult RoadVehicleChangeInfo | ( | uint | engine,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for road vehicles.

Parameters

  engine | Local ID of the first vehicle.
  numinfo | Number of subsequent IDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 1368 of file newgrf.cpp.

References _gted, _loaded_newgrf_features, RoadVehicleInfo::air_drag, AlterVehicleListOrder(), EngineInfo::base_intro, EngineInfo::callback_mask, EngineInfo::cargo_age_period, CIR_INVALID_ID, CIR_SUCCESS, CommonVehicleChangeInfo(), ConvertTTDBasePrice(), CT_INVALID, EF_USES_2CC, GetCargoTranslation(), GetNewEngine(), GetNewGRFSoundID(), GrfProcessingState::grffile, GRFLoadedFeatures::has_2CC, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsValidCargoID(), RoadVehicleInfo::max_speed, EngineInfo::misc_flags, RoadVehicleInfo::power, PROP_ROADVEH_CARGO_AGE_PERIOD, PROP_ROADVEH_CARGO_CAPACITY, PROP_ROADVEH_COST_FACTOR, PROP_ROADVEH_POWER, PROP_ROADVEH_RUNNING_COST_FACTOR, PROP_ROADVEH_SHORTEN_FACTOR, PROP_ROADVEH_SPEED, PROP_ROADVEH_TRACTIVE_EFFORT, PROP_ROADVEH_WEIGHT, EngineInfo::retire_early, SB(), SetBit(), RoadVehicleInfo::shorten_factor, RoadVehicleInfo::tractive_effort, TranslateRefitMask(), EngineInfo::variant_id, VE_DEFAULT, VE_DISABLE_EFFECT, VE_TYPE_COUNT, VE_TYPE_START, VEH_ROAD, RoadVehicleInfo::visual_effect, and RoadVehicleInfo::weight.

## ◆ SafeChangeInfo()

static void SafeChangeInfo | ( | ByteReader & | buf | ) |
| static

Definition at line 5011 of file newgrf.cpp.

## ◆ SafeGRFInhibit()

static void SafeGRFInhibit | ( | ByteReader & | buf | ) |
| static

Definition at line 7755 of file newgrf.cpp.

## ◆ SafeParamSet()

static void SafeParamSet | ( | ByteReader & | buf | ) |
| static

Definition at line 7308 of file newgrf.cpp.

## ◆ SanitizeSpriteOffset()

static uint16_t SanitizeSpriteOffset | ( | uint16_t & | num,
|  | uint16_t | offset,
|  | int | max_sprites,
|  | const std::string_view | name
| ) |  |
| static

Sanitize incoming sprite offsets for Action 5 graphics replacements.

Parameters

  num | The number of sprites to load.
  offset | Offset from the base.
  max_sprites | The maximum number of sprites that can be loaded in this action 5.
  name | Used for error warnings.

Returns
  The number of sprites that is going to be skipped.

Definition at line 6411 of file newgrf.cpp.

## ◆ ScanInfo()

static void ScanInfo | ( | ByteReader & | buf | ) |
| static

Definition at line 7051 of file newgrf.cpp.

## ◆ SetNewGRFOverride()

static void SetNewGRFOverride | ( | uint32_t | source_grfid,
|  | uint32_t | target_grfid
| ) |  |
| static

Set the override for a NewGRF.

Parameters

  source_grfid | The grfID which wants to override another NewGRF.
  target_grfid | The grfID which is being overridden.

Definition at line 594 of file newgrf.cpp.

References BSWAP32().

Referenced by LoadNewGRF().

## ◆ ShipVehicleChangeInfo()

static ChangeInfoResult ShipVehicleChangeInfo | ( | uint | engine,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for ships.

Parameters

  engine | Local ID of the first vehicle.
  numinfo | Number of subsequent IDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 1573 of file newgrf.cpp.

References _gted, _loaded_newgrf_features, ShipVehicleInfo::acceleration, AlterVehicleListOrder(), EngineInfo::base_intro, EngineInfo::callback_mask, ShipVehicleInfo::canal_speed_frac, EngineInfo::cargo_age_period, CIR_INVALID_ID, CIR_SUCCESS, CommonVehicleChangeInfo(), CT_INVALID, EF_USES_2CC, GetCargoTranslation(), GetNewEngine(), GetNewGRFSoundID(), GrfProcessingState::grffile, GRFLoadedFeatures::has_2CC, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsValidCargoID(), ShipVehicleInfo::max_speed, EngineInfo::misc_flags, ShipVehicleInfo::ocean_speed_frac, ShipVehicleInfo::old_refittable, PROP_SHIP_CARGO_AGE_PERIOD, PROP_SHIP_CARGO_CAPACITY, PROP_SHIP_COST_FACTOR, PROP_SHIP_RUNNING_COST_FACTOR, PROP_SHIP_SPEED, EngineInfo::retire_early, SB(), SetBit(), TranslateRefitMask(), EngineInfo::variant_id, VE_DEFAULT, VE_DISABLE_EFFECT, VE_TYPE_COUNT, VE_TYPE_START, VEH_SHIP, and ShipVehicleInfo::visual_effect.

## ◆ SkipAct1()

static void SkipAct1 | ( | ByteReader & | buf | ) |
| static

Definition at line 5137 of file newgrf.cpp.

## ◆ SkipAct11()

static void SkipAct11 | ( | ByteReader & | buf | ) |
| static

Definition at line 8039 of file newgrf.cpp.

## ◆ SkipAct12()

static void SkipAct12 | ( | ByteReader & | buf | ) |
| static

Action 0x12 (SKIP)

Definition at line 8082 of file newgrf.cpp.

References GrfProcessingState::skip_sprites.

## ◆ SkipAct5()

static void SkipAct5 | ( | ByteReader & | buf | ) |
| static

Definition at line 6562 of file newgrf.cpp.

## ◆ SkipActA()

static void SkipActA | ( | ByteReader & | buf | ) |
| static

Definition at line 7172 of file newgrf.cpp.

## ◆ SkipIf()

static void SkipIf | ( | ByteReader & | buf | ) |
| static

Definition at line 6870 of file newgrf.cpp.

## ◆ SkipUnknownInfo()

static bool SkipUnknownInfo | ( | ByteReader & | buf,
|  | uint8_t | type
| ) |  |
| static

Try to skip the current node and all subnodes (if it's a branch node).

Parameters

  buf | Buffer.
  type | The node type to skip.

Returns
  True if we could skip the node, false if an error occurred.

Definition at line 8555 of file newgrf.cpp.

References SkipUnknownInfo().

Referenced by ChangeGRFParamValueNames(), HandleNode(), HandleParameterInfo(), and SkipUnknownInfo().

## ◆ SoundEffectChangeInfo()

static ChangeInfoResult SoundEffectChangeInfo | ( | uint | sid,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for sound effects.

Parameters

  sid | Local ID of the sound.
  numinfo | Number of subsequent IDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 3208 of file newgrf.cpp.

References CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, Clamp(), GrfProcessingState::grffile, and ORIGINAL_SAMPLE_COUNT.

## ◆ SpriteReplace()

static void SpriteReplace | ( | ByteReader & | buf | ) |
| static

Definition at line 7125 of file newgrf.cpp.

## ◆ StaticGRFInfo()

static void StaticGRFInfo | ( | ByteReader & | buf | ) |
| static

Handle Action 0x14.

Parameters

  buf | Buffer.

Definition at line 8648 of file newgrf.cpp.

References _tags_root.

## ◆ StationChangeInfo()

static ChangeInfoResult StationChangeInfo | ( | uint | stid,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for stations.

Parameters

  stid | StationID of the first station tile.
  numinfo | Number of subsequent station tiles to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 1933 of file newgrf.cpp.

References AddStringForMapping(), NewGRFClass< Tspec, Tindex, Tmax >::Allocate(), StationSpec::Blocked, BSWAP32(), StationSpec::cargo_triggers, CIR_DISABLED, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, NewGRFSpriteLayout::Clone(), NewGRFSpriteLayout::consistent_max_offset, DrawTileSeqStruct::delta_x, DrawTileSeqStruct::delta_z, AnimationInfo::frames, GetStationLayoutKey(), GrfProcessingState::grffile, DrawTileSprites::ground, HasBit(), DrawTileSeqStruct::IsTerminator(), StationSpec::layouts, MemSetT(), StationSpec::NoWires, NUM_STATIONS_PER_GRF, StationSpec::Pylons, ReadSpriteLayout(), ReadSpriteLayoutSprite(), StationSpec::renderdata, GrfProcessingState::skip_sprites, and TranslateRefitMask().

## ◆ StationMapSpriteGroup()

static void StationMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | idcount
| ) |  |
| static

Definition at line 5750 of file newgrf.cpp.

## ◆ TownHouseChangeInfo()

static ChangeInfoResult TownHouseChangeInfo | ( | uint | hid,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Define properties for houses.

Parameters

  hid | HouseID of the house.
  numinfo | Number of subsequent houseIDs to change the property for.
  prop | The property to change.
  buf | The property value.

Returns
  ChangeInfoResult.

Definition at line 2429 of file newgrf.cpp.

References _settings_game, abs(), OverrideManagerBase::Add(), AddStringForMapping(), CIR_DISABLED, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, Clamp(), CT_INVALID, DisableGrf(), HouseSpec::enabled, GameSettings::game_creation, GB(), HouseSpec::Get(), GetCargoTranslation(), GrfProcessingState::grffile, HOUSE_ORIGINAL_NUM_ACCEPTS, IgnoreTownHouseProperty(), IsValidCargoID(), GameCreationSettings::landscape, lengthof, TimerGameConst< struct Calendar >::MAX_YEAR, NEW_HOUSE_OFFSET, NUM_HOUSES_PER_GRF, TimerGameConst< struct Calendar >::ORIGINAL_BASE_YEAR, GRFError::param_value, SB(), and SetBit().

## ◆ TownHouseMapSpriteGroup()

static void TownHouseMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | idcount
| ) |  |
| static

Definition at line 5809 of file newgrf.cpp.

## ◆ TramTypeChangeInfo()

static ChangeInfoResult TramTypeChangeInfo | ( | uint | id,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Definition at line 4607 of file newgrf.cpp.

## ◆ TramTypeReserveInfo()

static ChangeInfoResult TramTypeReserveInfo | ( | uint | id,
|  | int | numinfo,
|  | int | prop,
|  | ByteReader & | buf
| ) |  |
| static

Definition at line 4696 of file newgrf.cpp.

## ◆ TranslateCargo()

static CargoID TranslateCargo | ( | uint8_t | feature,
|  | uint8_t | ctype
| ) |  |
| static

Definition at line 5603 of file newgrf.cpp.

## ◆ TranslateGRFStrings()

static void TranslateGRFStrings | ( | ByteReader & | buf | ) |
| static

Action 0x13.

Definition at line 8108 of file newgrf.cpp.

References AddGRFString(), BSWAP32(), GRFError::data, DisableGrf(), GCS_ACTIVATED, GCS_INITIALISED, GetGRFConfig(), GetString(), GrfProcessingState::grffile, and GRFConfig::status.

## ◆ TranslateRefitMask()

static CargoTypes TranslateRefitMask | ( | uint32_t | refit_mask | ) |
| static

Translate the refit mask.

refit_mask is uint32_t as it has not been mapped to CargoTypes.

Definition at line 963 of file newgrf.cpp.

References GetCargoTranslation(), GrfProcessingState::grffile, IsValidCargoID(), and SetBit().

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

## ◆ TTDPStringIDToOTTDStringIDMapping()

static StringID TTDPStringIDToOTTDStringIDMapping | ( | StringID | str | ) |
| static

Perform a mapping from TTDPatch's string IDs to OpenTTD's string IDs, but only for the ones we are aware off; the rest like likely unused and will show a warning.

Parameters

  str | the string ID to convert

Returns
  the converted string ID

Definition at line 496 of file newgrf.cpp.

References Debug, and IsInsideMM().

Referenced by MapGRFStringID().

## ◆ ValidateIndustryLayout()

static bool ValidateIndustryLayout | ( | const IndustryTileLayout & | layout | ) |
| static

Validate the industry layout; e.g.

to prevent duplicate tiles.

Parameters

  layout | The layout to check.

Returns
  True if the layout is deemed valid.

Definition at line 3528 of file newgrf.cpp.

References GFX_WATERTILE_SPECIALCHECK.

Referenced by IndustriesChangeInfo().

## ◆ VehicleMapSpriteGroup()

static void VehicleMapSpriteGroup | ( | ByteReader & | buf,
|  | uint8_t | feature,
|  | uint8_t | idcount
| ) |  |
| static

Definition at line 5645 of file newgrf.cpp.

## Variable Documentation

## ◆ _action5_types

constexpr auto _action5_types
| staticconstexpr

Initial value:
= std::to_array<Action5Type>({
{ A5BLOCK_INVALID, 0, 0, 0, "Type 0x00" },
{ A5BLOCK_INVALID, 0, 0, 0, "Type 0x01" },
{ A5BLOCK_INVALID, 0, 0, 0, "Type 0x02" },
{ A5BLOCK_INVALID, 0, 0, 0, "Type 0x03" },
{ A5BLOCK_ALLOW_OFFSET, SPR_SIGNALS_BASE, 1, PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT, "Signal graphics" },
{ A5BLOCK_ALLOW_OFFSET, SPR_ELRAIL_BASE, 1, ELRAIL_SPRITE_COUNT, "Rail catenary graphics" },
{ A5BLOCK_ALLOW_OFFSET, SPR_SLOPES_BASE, 1, NORMAL_AND_HALFTILE_FOUNDATION_SPRITE_COUNT, "Foundation graphics" },
{ A5BLOCK_INVALID, 0, 75, 0, "TTDP GUI graphics" },
{ A5BLOCK_ALLOW_OFFSET, SPR_CANALS_BASE, 1, CANALS_SPRITE_COUNT, "Canal graphics" },
{ A5BLOCK_ALLOW_OFFSET, SPR_ONEWAY_BASE, 1, ONEWAY_SPRITE_COUNT, "One way road graphics" },
{ A5BLOCK_ALLOW_OFFSET, SPR_2CCMAP_BASE, 1, TWOCCMAP_SPRITE_COUNT, "2CC colour maps" },
{ A5BLOCK_ALLOW_OFFSET, SPR_TRAMWAY_BASE, 1, TRAMWAY_SPRITE_COUNT, "Tramway graphics" },
{ A5BLOCK_INVALID, 0, 133, 0, "Snowy temperate tree" },
{ A5BLOCK_FIXED, SPR_SHORE_BASE, 16, SPR_SHORE_SPRITE_COUNT, "Shore graphics" },
{ A5BLOCK_INVALID, 0, 0, 0, "New Signals graphics" },
{ A5BLOCK_ALLOW_OFFSET, SPR_TRACKS_FOR_SLOPES_BASE, 1, TRACKS_FOR_SLOPES_SPRITE_COUNT, "Sloped rail track" },
{ A5BLOCK_ALLOW_OFFSET, SPR_AIRPORTX_BASE, 1, AIRPORTX_SPRITE_COUNT, "Airport graphics" },
{ A5BLOCK_ALLOW_OFFSET, SPR_ROADSTOP_BASE, 1, ROADSTOP_SPRITE_COUNT, "Road stop graphics" },
{ A5BLOCK_ALLOW_OFFSET, SPR_AQUEDUCT_BASE, 1, AQUEDUCT_SPRITE_COUNT, "Aqueduct graphics" },
{ A5BLOCK_ALLOW_OFFSET, SPR_AUTORAIL_BASE, 1, AUTORAIL_SPRITE_COUNT, "Autorail graphics" },
{ A5BLOCK_INVALID, 0, 1, 0, "Flag graphics" },
{ A5BLOCK_ALLOW_OFFSET, SPR_OPENTTD_BASE, 1, OPENTTD_SPRITE_COUNT, "OpenTTD GUI graphics" },
{ A5BLOCK_ALLOW_OFFSET, SPR_AIRPORT_PREVIEW_BASE, 1, SPR_AIRPORT_PREVIEW_COUNT, "Airport preview graphics" },
{ A5BLOCK_ALLOW_OFFSET, SPR_RAILTYPE_TUNNEL_BASE, 1, RAILTYPE_TUNNEL_BASE_COUNT, "Railtype tunnel base" },
{ A5BLOCK_ALLOW_OFFSET, SPR_PALETTE_BASE, 1, PALETTE_SPRITE_COUNT, "Palette" },
{ A5BLOCK_ALLOW_OFFSET, SPR_ROAD_WAYPOINTS_BASE, 1, ROAD_WAYPOINTS_SPRITE_COUNT, "Road waypoints" },
})
A5BLOCK_ALLOW_OFFSET
@ A5BLOCK_ALLOW_OFFSET
Allow replacing any subset by specifiing an offset.
Definition newgrf_act5.h:16
A5BLOCK_INVALID
@ A5BLOCK_INVALID
unknown/not-implemented type
Definition newgrf_act5.h:17
A5BLOCK_FIXED
@ A5BLOCK_FIXED
Only allow replacing a whole block of sprites. (TTDP compatible)
Definition newgrf_act5.h:15
SPR_AQUEDUCT_BASE
static const SpriteID SPR_AQUEDUCT_BASE
Sprites for the Aqueduct.
Definition sprites.h:186
SPR_OPENTTD_BASE
static const SpriteID SPR_OPENTTD_BASE
Extra graphic spritenumbers.
Definition sprites.h:56
SPR_TRACKS_FOR_SLOPES_BASE
static const SpriteID SPR_TRACKS_FOR_SLOPES_BASE
Sprites for 'highlighting' tracks on sloped land.
Definition sprites.h:198
SPR_ROAD_WAYPOINTS_BASE
static const SpriteID SPR_ROAD_WAYPOINTS_BASE
Road waypoint sprites.
Definition sprites.h:311
SPR_RAILTYPE_TUNNEL_BASE
static const SpriteID SPR_RAILTYPE_TUNNEL_BASE
Tunnel sprites with grass only for custom railtype tunnel.
Definition sprites.h:299
SPR_TRAMWAY_BASE
static const SpriteID SPR_TRAMWAY_BASE
Tramway sprites.
Definition sprites.h:272
SPR_AIRPORT_PREVIEW_BASE
static const SpriteID SPR_AIRPORT_PREVIEW_BASE
Airport preview sprites.
Definition sprites.h:248
SPR_ONEWAY_BASE
static const SpriteID SPR_ONEWAY_BASE
One way road sprites.
Definition sprites.h:293
SPR_SHORE_BASE
static const SpriteID SPR_SHORE_BASE
shore tiles - action 05-0D
Definition sprites.h:224

The information about action 5 types.

Definition at line 6433 of file newgrf.cpp.

Referenced by GetAction5Types().

## ◆ _cached_callback_groups

std::vector<CachedCallback> _cached_callback_groups
| static

Sorted list of cached callback result spritegroups.

Definition at line 5156 of file newgrf.cpp.

Referenced by AfterLoadGRFs(), and ResetNewGRFData().

## ◆ _cur

GrfProcessingState _cur
| static

Definition at line 198 of file newgrf.cpp.

## ◆ _cur_parameter

GRFParameterInfo* _cur_parameter
| static

The parameter which info is currently changed by the newgrf.

Definition at line 8274 of file newgrf.cpp.

Referenced by ChangeGRFParamDefault(), ChangeGRFParamDescription(), ChangeGRFParamLimits(), ChangeGRFParamMask(), ChangeGRFParamName(), ChangeGRFParamType(), ChangeGRFParamValueNames(), and HandleParameterInfo().

## ◆ _grf_files

std::vector<GRFFile *> _grf_files
| static

List of all loaded GRF files.

Definition at line 70 of file newgrf.cpp.

Referenced by FinaliseAirportsArray(), FinaliseHouseArray(), FinaliseIndustriesArray(), FinaliseObjectsArray(), FinalisePriceBaseMultipliers(), GetFileByFilename(), GetFileByGRFID(), InitNewGRFFile(), ResetCustomAirports(), ResetCustomHouses(), ResetCustomIndustries(), ResetCustomObjects(), ResetCustomStations(), and ResetNewGRF().

## ◆ _grf_id_overrides

std::map<uint32_t, uint32_t> _grf_id_overrides
| static

Definition at line 587 of file newgrf.cpp.

## ◆ _grf_line_to_action6_sprite_override

GRFLineToSpriteOverride _grf_line_to_action6_sprite_override
| static

Definition at line 378 of file newgrf.cpp.

## ◆ _grm_cargoes

uint32_t _grm_cargoes[NUM_CARGO *2]
| static

Contains the GRF ID of the owner of a cargo if it has been reserved.

Definition at line 357 of file newgrf.cpp.

Referenced by ParamSet(), and ResetNewGRFData().

## ◆ _grm_engines

uint32_t _grm_engines[256]
| static

Contains the GRF ID of the owner of a vehicle if it has been reserved.

GRM for vehicles is only used if dynamic engine allocation is disabled, so 256 is the number of original engines.

Definition at line 354 of file newgrf.cpp.

Referenced by ParamSet(), and ResetNewGRFData().

## ◆ _grm_sprites

std::map<GRFLocation, std::pair<SpriteID, uint16_t> > _grm_sprites
| static

Definition at line 376 of file newgrf.cpp.

## ◆ _gted

std::vector<GRFTempEngineData> _gted
| static

Temporary engine data used during NewGRF loading.

Definition at line 348 of file newgrf.cpp.

Referenced by AfterLoadGRFs(), AircraftVehicleChangeInfo(), CalculateRefitMasks(), GetNewEngine(), RailVehicleChangeInfo(), ResetNewGRFData(), RoadVehicleChangeInfo(), and ShipVehicleChangeInfo().

## ◆ _loaded_newgrf_features

GRFLoadedFeatures _loaded_newgrf_features

Indicates which are the newgrf features currently loaded ingame.

Definition at line 84 of file newgrf.cpp.

Referenced by ActivateOldShore(), ActivateOldTramDepot(), AircraftVehicleChangeInfo(), DrawRoadDepotSprite(), DrawTile_Road(), SelectCompanyLiveryWindow::DrawWidget(), FinaliseEngineArray(), ObjectChangeInfo(), SelectCompanyLiveryWindow::OnClick(), SelectCompanyLiveryWindow::OnDropdownSelect(), SelectCompanyLiveryWindow::OnInvalidateData(), RailVehicleChangeInfo(), ResetNewGRFData(), RoadVehicleChangeInfo(), ShipVehicleChangeInfo(), and SelectCompanyLiveryWindow::UpdateWidgetSize().

## ◆ _misc_grf_features

uint8_t _misc_grf_features = 0

Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E.

Definition at line 78 of file newgrf.cpp.

Referenced by GetGlobalVariable(), HasGrfMiscBit(), ParamSet(), and ResetNewGRFData().

## ◆ _string_to_grf_mapping

std::vector<StringIDMapping> _string_to_grf_mapping
| static

Strings to be mapped during load.

Definition at line 466 of file newgrf.cpp.

Referenced by AddStringForMapping(), and AfterLoadGRFs().

## ◆ _tags_info

AllowedSubtags _tags_info[]

Initial value:
= {
AllowedSubtags('NAME', ChangeGRFName),
AllowedSubtags('DESC', ChangeGRFDescription),
AllowedSubtags('URL_', ChangeGRFURL),
AllowedSubtags('NPAR', ChangeGRFNumUsedParams),
AllowedSubtags('PALS', ChangeGRFPalette),
AllowedSubtags('BLTR', ChangeGRFBlitter),
AllowedSubtags('VRSN', ChangeGRFVersion),
AllowedSubtags('MINV', ChangeGRFMinVersion),
AllowedSubtags('PARA', HandleParameterInfo),
AllowedSubtags()
}
ChangeGRFNumUsedParams
static bool ChangeGRFNumUsedParams(size_t len, ByteReader &buf)
Callback function for 'INFO'->'NPAR' to set the number of valid parameters.
Definition newgrf.cpp:8182
ChangeGRFURL
static bool ChangeGRFURL(uint8_t langid, std::string_view str)
Callback function for 'INFO'->'URL_' to set the newgrf url.
Definition newgrf.cpp:8175
ChangeGRFMinVersion
static bool ChangeGRFMinVersion(size_t len, ByteReader &buf)
Callback function for 'INFO'->'MINV' to the minimum compatible version of the NewGRF.
Definition newgrf.cpp:8255
HandleParameterInfo
static bool HandleParameterInfo(ByteReader &buf)
Callback function for 'INFO'->'PARA' to set extra information about the parameters.
Definition newgrf.cpp:8502
ChangeGRFName
static bool ChangeGRFName(uint8_t langid, std::string_view str)
Callback function for 'INFO'->'NAME' to add a translation to the newgrf name.
Definition newgrf.cpp:8161
ChangeGRFDescription
static bool ChangeGRFDescription(uint8_t langid, std::string_view str)
Callback function for 'INFO'->'DESC' to add a translation to the newgrf description.
Definition newgrf.cpp:8168
ChangeGRFPalette
static bool ChangeGRFPalette(size_t len, ByteReader &buf)
Callback function for 'INFO'->'PALS' to set the number of valid parameters.
Definition newgrf.cpp:8194
ChangeGRFVersion
static bool ChangeGRFVersion(size_t len, ByteReader &buf)
Callback function for 'INFO'->'VRSN' to the version of the NewGRF.
Definition newgrf.cpp:8242
ChangeGRFBlitter
static bool ChangeGRFBlitter(size_t len, ByteReader &buf)
Callback function for 'INFO'->'BLTR' to set the blitter info.
Definition newgrf.cpp:8220
AllowedSubtags
Data structure to store the allowed id/type combinations for action 14.
Definition newgrf.cpp:8374

Action14 tags for the INFO node.

Definition at line 8529 of file newgrf.cpp.

## ◆ _tags_parameters

AllowedSubtags _tags_parameters[]

Initial value:
= {
AllowedSubtags('NAME', ChangeGRFParamName),
AllowedSubtags('DESC', ChangeGRFParamDescription),
AllowedSubtags('TYPE', ChangeGRFParamType),
AllowedSubtags('LIMI', ChangeGRFParamLimits),
AllowedSubtags('MASK', ChangeGRFParamMask),
AllowedSubtags('VALU', ChangeGRFParamValueNames),
AllowedSubtags('DFLT', ChangeGRFParamDefault),
AllowedSubtags()
}
ChangeGRFParamType
static bool ChangeGRFParamType(size_t len, ByteReader &buf)
Callback function for 'INFO'->'PARAM'->param_num->'TYPE' to set the typeof a parameter.
Definition newgrf.cpp:8291
ChangeGRFParamLimits
static bool ChangeGRFParamLimits(size_t len, ByteReader &buf)
Callback function for 'INFO'->'PARAM'->param_num->'LIMI' to set the min/max value of a parameter.
Definition newgrf.cpp:8308
ChangeGRFParamDescription
static bool ChangeGRFParamDescription(uint8_t langid, std::string_view str)
Callback function for 'INFO'->'PARAM'->param_num->'DESC' to set the description of a parameter.
Definition newgrf.cpp:8284
ChangeGRFParamDefault
static bool ChangeGRFParamDefault(size_t len, ByteReader &buf)
Callback function for 'INFO'->'PARAM'->param_num->'DFLT' to set the default value.
Definition newgrf.cpp:8351
ChangeGRFParamValueNames
static bool ChangeGRFParamValueNames(ByteReader &buf)
Callback function for 'INFO'->'PARA'->param_num->'VALU' to set the names of some parameter values (ty...
Definition newgrf.cpp:8455
ChangeGRFParamMask
static bool ChangeGRFParamMask(size_t len, ByteReader &buf)
Callback function for 'INFO'->'PARAM'->param_num->'MASK' to set the parameter and bits to use.
Definition newgrf.cpp:8330
ChangeGRFParamName
static bool ChangeGRFParamName(uint8_t langid, std::string_view str)
Callback function for 'INFO'->'PARAM'->param_num->'NAME' to set the name of a parameter.
Definition newgrf.cpp:8277

Action14 parameter tags.

Definition at line 8485 of file newgrf.cpp.

Referenced by HandleParameterInfo().

## ◆ _tags_root

AllowedSubtags _tags_root[]

Initial value:
= {
AllowedSubtags('INFO', _tags_info),
AllowedSubtags()
}
_tags_info
AllowedSubtags _tags_info[]
Action14 tags for the INFO node.
Definition newgrf.cpp:8529

Action14 root tags.

Definition at line 8543 of file newgrf.cpp.

Referenced by StaticGRFInfo().

## ◆ _ttdpatch_flags

uint32_t _ttdpatch_flags[8]
| static

32 * 8 = 256 flags.

Apparently TTDPatch uses this many..

Definition at line 81 of file newgrf.cpp.

Referenced by InitializeGRFSpecial().

## ◆ MAX_SPRITEGROUP

const uint MAX_SPRITEGROUP = UINT8_MAX
| static

Maximum GRF-local ID for a spritegroup.

Definition at line 86 of file newgrf.cpp.

## ◆ NUM_STATIONS_PER_GRF

const uint NUM_STATIONS_PER_GRF = UINT16_MAX - 1
| static

The maximum amount of stations a single GRF is allowed to add.

Definition at line 312 of file newgrf.cpp.

Referenced by StationChangeInfo().