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

Base of all NewGRF support. More...

#include "stdafx.h"
#include <stdarg.h>
#include <algorithm>
#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 "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 "date_func.h"
#include "string_func.h"
#include "network/network.h"
#include <map>
#include "smallmap_gui.h"
#include "genworld.h"
#include "error.h"
#include "vehicle_func.h"
#include "language.h"
#include "vehicle_base.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  Action5Type
 Information about a single action 5 type. 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, byte * > GRFLineToSpriteOverride
 
typedef SmallVector< StringIDMapping, 16 > StringIDMappingVector
 
typedef ChangeInfoResult(* VCI_Handler) (uint engine, int numinfo, int prop, ByteReader *buf)
 
typedef bool(* DataHandler) (size_t, ByteReader *)
 Type of callback function for binary nodes.
 
typedef bool(* TextHandler) (byte, const char *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...
 
enum  Action5BlockType { A5BLOCK_FIXED, A5BLOCK_ALLOW_OFFSET, A5BLOCK_INVALID }
 The type of action 5 type. More...
 

Functions

template<VehicleType T>
static bool IsValidNewGRFImageIndex (uint8 image_index)
 Helper to check whether an image index is valid for a particular NewGRF vehicle. More...
 
void CDECL grfmsg (int severity, const char *str,...)
 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. More...
 
static GRFFileGetFileByGRFID (uint32 grfid)
 Obtain a NewGRF file by its grfID. More...
 
static GRFFileGetFileByFilename (const char *filename)
 Obtain a NewGRF file by its filename. More...
 
static void ClearTemporaryNewGRFData (GRFFile *gf)
 Reset all NewGRFData that was used only while processing data.
 
static GRFErrorDisableGrf (StringID message=STR_NULL, GRFConfig *config=NULL)
 Disable a GRF. More...
 
static void AddStringForMapping (StringID source, StringID *target)
 Record a static StringID for getting translated later. More...
 
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. More...
 
StringID MapGRFStringID (uint32 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. More...
 
static void SetNewGRFOverride (uint32 source_grfid, uint32 target_grfid)
 Set the override for a NewGRF. More...
 
static EngineGetNewEngine (const GRFFile *file, VehicleType type, uint16 internal_id, bool static_access=false)
 Returns the engine associated to a certain internal_id, resp. More...
 
EngineID GetNewEngineID (const GRFFile *file, VehicleType type, uint16 internal_id)
 Return the ID of a new engine. More...
 
static void MapSpriteMappingRecolour (PalSpriteID *grf_sprite)
 Map the colour modifiers of TTDPatch to those that Open is using. More...
 
static TileLayoutFlags ReadSpriteLayoutSprite (ByteReader *buf, bool read_flags, bool invert_action1_flag, bool use_cur_spritesets, int feature, PalSpriteID *grf_sprite, uint16 *max_sprite_offset=NULL, uint16 *max_palette_offset=NULL)
 Read a sprite and a palette from the GRF and convert them into a format suitable to OpenTTD. More...
 
static void ReadSpriteLayoutRegisters (ByteReader *buf, TileLayoutFlags flags, bool is_parent, NewGRFSpriteLayout *dts, uint index)
 Preprocess the TileLayoutFlags and read register modifiers from the GRF. More...
 
static bool ReadSpriteLayout (ByteReader *buf, uint num_building_sprites, bool use_cur_spritesets, byte feature, bool allow_var10, bool no_z_position, NewGRFSpriteLayout *dts)
 Read a spritelayout from the GRF. More...
 
static uint32 TranslateRefitMask (uint32 refit_mask)
 Translate the refit mask.
 
static void ConvertTTDBasePrice (uint32 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. More...
 
static ChangeInfoResult CommonVehicleChangeInfo (EngineInfo *ei, int prop, ByteReader *buf)
 Define properties common to all vehicles. More...
 
static ChangeInfoResult RailVehicleChangeInfo (uint engine, int numinfo, int prop, ByteReader *buf)
 Define properties for rail vehicles. More...
 
static ChangeInfoResult RoadVehicleChangeInfo (uint engine, int numinfo, int prop, ByteReader *buf)
 Define properties for road vehicles. More...
 
static ChangeInfoResult ShipVehicleChangeInfo (uint engine, int numinfo, int prop, ByteReader *buf)
 Define properties for ships. More...
 
static ChangeInfoResult AircraftVehicleChangeInfo (uint engine, int numinfo, int prop, ByteReader *buf)
 Define properties for aircraft. More...
 
static ChangeInfoResult StationChangeInfo (uint stid, int numinfo, int prop, ByteReader *buf)
 Define properties for stations. More...
 
static ChangeInfoResult CanalChangeInfo (uint id, int numinfo, int prop, ByteReader *buf)
 Define properties for water features. More...
 
static ChangeInfoResult BridgeChangeInfo (uint brid, int numinfo, int prop, ByteReader *buf)
 Define properties for bridges. More...
 
static ChangeInfoResult IgnoreTownHouseProperty (int prop, ByteReader *buf)
 Ignore a house property. More...
 
static ChangeInfoResult TownHouseChangeInfo (uint hid, int numinfo, int prop, ByteReader *buf)
 Define properties for houses. More...
 
template<typename T >
static ChangeInfoResult LoadTranslationTable (uint gvid, int numinfo, ByteReader *buf, T &translation_table, const char *name)
 Load a cargo- or railtype-translation table. More...
 
static ChangeInfoResult GlobalVarChangeInfo (uint gvid, int numinfo, int prop, ByteReader *buf)
 Define properties for global variables. More...
 
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. More...
 
static ChangeInfoResult SoundEffectChangeInfo (uint sid, int numinfo, int prop, ByteReader *buf)
 Define properties for sound effects. More...
 
static ChangeInfoResult IgnoreIndustryTileProperty (int prop, ByteReader *buf)
 Ignore an industry tile property. More...
 
static ChangeInfoResult IndustrytilesChangeInfo (uint indtid, int numinfo, int prop, ByteReader *buf)
 Define properties for industry tiles. More...
 
static ChangeInfoResult IgnoreIndustryProperty (int prop, ByteReader *buf)
 Ignore an industry property. More...
 
static bool ValidateIndustryLayout (const IndustryTileTable *layout, int size)
 Validate the industry layout; e.g. More...
 
static void CleanIndustryTileTable (IndustrySpec *ind)
 Clean the tile table of the IndustrySpec if it's needed. More...
 
static ChangeInfoResult IndustriesChangeInfo (uint indid, int numinfo, int prop, ByteReader *buf)
 Define properties for industries. More...
 
static void DuplicateTileTable (AirportSpec *as)
 Create a copy of the tile table so it can be freed later without problems. More...
 
static ChangeInfoResult AirportChangeInfo (uint airport, int numinfo, int prop, ByteReader *buf)
 Define properties for airports. More...
 
static ChangeInfoResult IgnoreObjectProperty (uint prop, ByteReader *buf)
 Ignore properties for objects. More...
 
static ChangeInfoResult ObjectChangeInfo (uint id, int numinfo, int prop, ByteReader *buf)
 Define properties for objects. More...
 
static ChangeInfoResult RailTypeChangeInfo (uint id, int numinfo, int prop, ByteReader *buf)
 Define properties for railtypes. More...
 
static ChangeInfoResult RailTypeReserveInfo (uint id, int numinfo, int prop, ByteReader *buf)
 
static ChangeInfoResult AirportTilesChangeInfo (uint airtid, int numinfo, int prop, ByteReader *buf)
 
static bool HandleChangeInfoResult (const char *caller, ChangeInfoResult cir, uint8 feature, uint8 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 SpriteGroupGetGroupFromGroupID (byte setid, byte type, uint16 groupid)
 
static const SpriteGroupCreateGroupFromGroupID (byte feature, byte setid, byte type, uint16 spriteid)
 Helper function to either create a callback or a result sprite group. More...
 
static void NewSpriteGroup (ByteReader *buf)
 
static CargoID TranslateCargo (uint8 feature, uint8 ctype)
 
static bool IsValidGroupID (uint16 groupid, const char *function)
 
static void VehicleMapSpriteGroup (ByteReader *buf, byte feature, uint8 idcount)
 
static void CanalMapSpriteGroup (ByteReader *buf, uint8 idcount)
 
static void StationMapSpriteGroup (ByteReader *buf, uint8 idcount)
 
static void TownHouseMapSpriteGroup (ByteReader *buf, uint8 idcount)
 
static void IndustryMapSpriteGroup (ByteReader *buf, uint8 idcount)
 
static void IndustrytileMapSpriteGroup (ByteReader *buf, uint8 idcount)
 
static void CargoMapSpriteGroup (ByteReader *buf, uint8 idcount)
 
static void ObjectMapSpriteGroup (ByteReader *buf, uint8 idcount)
 
static void RailTypeMapSpriteGroup (ByteReader *buf, uint8 idcount)
 
static void AirportMapSpriteGroup (ByteReader *buf, uint8 idcount)
 
static void AirportTileMapSpriteGroup (ByteReader *buf, uint8 idcount)
 
static void FeatureMapSpriteGroup (ByteReader *buf)
 
static void FeatureNewName (ByteReader *buf)
 
static uint16 SanitizeSpriteOffset (uint16 &num, uint16 offset, int max_sprites, const char *name)
 Sanitize incoming sprite offsets for Action 5 graphics replacements. More...
 
static void GraphicsNew (ByteReader *buf)
 
static void SkipAct5 (ByteReader *buf)
 
bool GetGlobalVariable (byte param, uint32 *value, const GRFFile *grffile)
 Reads a variable common to VarAction2 and Action7/9/D. More...
 
static uint32 GetParamVal (byte param, uint32 *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. More...
 
static void SkipIf (ByteReader *buf)
 
static void ScanInfo (ByteReader *buf)
 
static void GRFInfo (ByteReader *buf)
 
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 GetPatchVariable (uint8 param)
 
static uint32 PerformGRM (uint32 *grm, uint16 num_ids, uint16 count, uint8 op, uint8 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. More...
 
static void LoadGRFSound (size_t offs, SoundEntry *sound)
 Load a sound from a file. More...
 
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 (byte langid, const char *str)
 Callback function for 'INFO'->'NAME' to add a translation to the newgrf name. More...
 
static bool ChangeGRFDescription (byte langid, const char *str)
 Callback function for 'INFO'->'DESC' to add a translation to the newgrf description. More...
 
static bool ChangeGRFURL (byte langid, const char *str)
 Callback function for 'INFO'->'URL_' to set the newgrf url. More...
 
static bool ChangeGRFNumUsedParams (size_t len, ByteReader *buf)
 Callback function for 'INFO'->'NPAR' to set the number of valid parameters. More...
 
static bool ChangeGRFPalette (size_t len, ByteReader *buf)
 Callback function for 'INFO'->'PALS' to set the number of valid parameters. More...
 
static bool ChangeGRFBlitter (size_t len, ByteReader *buf)
 Callback function for 'INFO'->'BLTR' to set the blitter info. More...
 
static bool ChangeGRFVersion (size_t len, ByteReader *buf)
 Callback function for 'INFO'->'VRSN' to the version of the NewGRF. More...
 
static bool ChangeGRFMinVersion (size_t len, ByteReader *buf)
 Callback function for 'INFO'->'MINV' to the minimum compatible version of the NewGRF. More...
 
static bool ChangeGRFParamName (byte langid, const char *str)
 Callback function for 'INFO'->'PARAM'->param_num->'NAME' to set the name of a parameter. More...
 
static bool ChangeGRFParamDescription (byte langid, const char *str)
 Callback function for 'INFO'->'PARAM'->param_num->'DESC' to set the description of a parameter. More...
 
static bool ChangeGRFParamType (size_t len, ByteReader *buf)
 Callback function for 'INFO'->'PARAM'->param_num->'TYPE' to set the typeof a parameter. More...
 
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. More...
 
static bool ChangeGRFParamMask (size_t len, ByteReader *buf)
 Callback function for 'INFO'->'PARAM'->param_num->'MASK' to set the parameter and bits to use. More...
 
static bool ChangeGRFParamDefault (size_t len, ByteReader *buf)
 Callback function for 'INFO'->'PARAM'->param_num->'DFLT' to set the default value. More...
 
static bool SkipUnknownInfo (ByteReader *buf, byte type)
 Try to skip the current node and all subnodes (if it's a branch node). More...
 
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). More...
 
static bool HandleParameterInfo (ByteReader *buf)
 Callback function for 'INFO'->'PARA' to set extra information about the parameters. More...
 
static bool HandleNode (byte type, uint32 id, ByteReader *buf, AllowedSubtags subtags[])
 Handle the nodes of an Action14. More...
 
static bool HandleNodes (ByteReader *buf, AllowedSubtags subtags[])
 Handle the contents of a 'C' choice of an Action14. More...
 
static void StaticGRFInfo (ByteReader *buf)
 Handle Action 0x14. More...
 
static void GRFUnsafe (ByteReader *buf)
 Set the current NewGRF as unsafe for static use. More...
 
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 ResetNewGRF ()
 Reset and clear all NewGRFs.
 
static void ResetNewGRFErrors ()
 Clear all NewGRF errors.
 
void ResetNewGRFData ()
 Reset all NewGRF loaded data TODO.
 
void ResetPersistentNewGRFData ()
 Reset NewGRF data which is stored persistently in savegames.
 
static void BuildCargoTranslationMap ()
 Construct the Cargo Mapping. More...
 
static void InitNewGRFFile (const GRFConfig *config)
 Prepare loading a NewGRF file with its config. More...
 
static void CalculateRefitMasks ()
 Precalculate refit masks from cargo classes for all vehicles. More...
 
static void FinaliseCanals ()
 Set to use the correct action0 properties for each canal feature.
 
static void FinaliseEngineArray ()
 Check for invalid engines.
 
static void FinaliseCargoArray ()
 Check for invalid cargoes.
 
static bool IsHouseSpecValid (HouseSpec *hs, const HouseSpec *next1, const HouseSpec *next2, const HouseSpec *next3, const char *filename)
 Check if a given housespec is valid and disable it if it's not. More...
 
static void EnsureEarlyHouse (HouseZones bitmask)
 Make sure there is at least one house available in the year 0 for the given climate / housezone combination. More...
 
static void FinaliseHouseArray ()
 Add all new houses to the house array. More...
 
static void FinaliseIndustriesArray ()
 Add all new industries to the industry array. More...
 
static void FinaliseObjectsArray ()
 Add all new objects to the object array. More...
 
static void FinaliseAirportsArray ()
 Add all new airports to the airport array. More...
 
static void DecodeSpecialSprite (byte *buf, uint num, GrfLoadingStage stage)
 
byte GetGRFContainerVersion ()
 Get the container version of the currently opened GRF file. More...
 
void LoadNewGRFFile (GRFConfig *config, uint file_index, GrfLoadingStage stage, Subdirectory subdir)
 Load a particular NewGRF. More...
 
static void ActivateOldShore ()
 Relocates the old shore sprites at new positions. More...
 
static void FinalisePriceBaseMultipliers ()
 Decide whether price base multipliers of grfs shall apply globally or only to the grf specifying them. More...
 
void InitGRFTownGeneratorNames ()
 Allocate memory for the NewGRF town names. More...
 
static void AfterLoadGRFs ()
 Finish loading NewGRFs and execute needed post-processing.
 
void LoadNewGRF (uint load_index, uint file_index, uint num_baseset)
 Load all the NewGRFs. More...
 

Variables

static SmallVector< GRFFile *, 16 > _grf_files
 List of all loaded GRF files.
 
byte _misc_grf_features = 0
 Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E.
 
static uint32 _ttdpatch_flags [8]
 32 * 8 = 256 flags. More...
 
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 = 255
 Number of StationSpecs per NewGRF; limited to 255 to allow extending Action3 with an extended byte later on.
 
static GRFTempEngineData_gted
 Temporary engine data used during NewGRF loading.
 
static uint32 _grm_engines [256]
 Contains the GRF ID of the owner of a vehicle if it has been reserved. More...
 
static uint32 _grm_cargoes [NUM_CARGO *2]
 Contains the GRF ID of the owner of a cargo if it has been reserved.
 
static std::map< GRFLocation, SpriteID_grm_sprites
 
static GRFLineToSpriteOverride _grf_line_to_action6_sprite_override
 
static StringIDMappingVector _string_to_grf_mapping
 
static std::map< uint32, uint32 > _grf_id_overrides
 
static const Action5Type _action5_types []
 The information about action 5 types. More...
 
static GRFParameterInfo_cur_parameter
 The parameter which info is currently changed by the newgrf.
 
AllowedSubtags _tags_parameters []
 Action14 parameter tags. More...
 
AllowedSubtags _tags_info []
 Action14 tags for the INFO node. More...
 
AllowedSubtags _tags_root []
 Action14 root tags. More...
 
static const CargoLabel _default_refitmasks_rail []
 List of what cargo labels are refittable for the given the vehicle-type. More...
 
static const CargoLabel _default_refitmasks_road []
 
static const CargoLabel _default_refitmasks_ships []
 
static const CargoLabel _default_refitmasks_aircraft []
 
static const CargoLabel *const _default_refitmasks []
 
const byte _grf_cont_v2_sig [8] = {'G', 'R', 'F', 0x82, 0x0D, 0x0A, 0x1A, 0x0A}
 Signature of a container version 2 GRF. More...
 

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:
assert_compile(stringend - stringid == end - begin); \
if (str >= begin && str <= end) return str + (stringid - begin)

Enumeration Type Documentation

◆ Action5BlockType

The type of action 5 type.

Enumerator
A5BLOCK_FIXED 

Only allow replacing a whole block of sprites. (TTDP compatible)

A5BLOCK_ALLOW_OFFSET 

Allow replacing any subset by specifiing an offset.

A5BLOCK_INVALID 

unknown/not-implemented type

Definition at line 5613 of file newgrf.cpp.

◆ 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 986 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 8979 of file newgrf.cpp.

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

◆ AddStringForMapping()

static void AddStringForMapping ( StringID  source,
StringID target 
)
static

Record a static StringID for getting translated later.

Parameters
sourceSource StringID (GRF local).
targetDestination for the mapping result.

Definition at line 472 of file newgrf.cpp.

References SmallVector< T, S >::Append(), GrfProcessingState::grffile, StringIDMapping::grfid, StringIDMapping::source, and StringIDMapping::target.

Referenced by CargoChangeInfo(), and ObjectChangeInfo().

◆ AircraftVehicleChangeInfo()

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

Define properties for aircraft.

Parameters
engineLocal ID of the aircraft.
numinfoNumber of subsequent IDs to change the property for.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 1700 of file newgrf.cpp.

References CIR_INVALID_ID, CIR_SUCCESS, GetNewEngine(), GrfProcessingState::grffile, grfmsg(), GrfProcessingState::spriteid, AircraftVehicleInfo::subtype, and VEH_AIRCRAFT.

◆ AirportChangeInfo()

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

Define properties for airports.

Parameters
airportLocal ID of the airport.
numinfoNumber of subsequent airport IDs to change the property for.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 3689 of file newgrf.cpp.

References CIR_INVALID_ID, CIR_SUCCESS, AirportSpec::enabled, AirportSpec::GetWithoutOverride(), GrfProcessingState::grffile, grfmsg(), NEW_AIRPORT_OFFSET, and NUM_AIRPORTS_PER_GRF.

◆ BridgeChangeInfo()

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

Define properties for bridges.

Parameters
bridBridgeID of the bridge.
numinfoNumber of subsequent bridgeIDs to change the property for.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 2138 of file newgrf.cpp.

References _bridge, BridgeSpec::avail_year, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, Clamp(), BridgeSpec::flags, GetGRFStringID(), GrfProcessingState::grffile, grfmsg(), MapSpriteMappingRecolour(), BridgeSpec::material, MAX_BRIDGES, BridgeSpec::max_length, MAX_YEAR, BridgeSpec::min_length, MIN_YEAR, ORIGINAL_BASE_YEAR, PalSpriteID::pal, BridgeSpec::price, BridgeSpec::speed, PalSpriteID::sprite, GrfProcessingState::SpriteSet::sprite, BridgeSpec::sprite_table, 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 8181 of file newgrf.cpp.

References CargoSpec::bitnum, GRFFile::cargo_list, GRFFile::cargo_map, SmallVector< T, S >::FindIndex(), CargoSpec::Get(), GrfProcessingState::grffile, CargoSpec::IsValid(), CargoSpec::label, SmallVector< T, S >::Length(), and NUM_CARGO.

◆ 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 8297 of file newgrf.cpp.

◆ CanalChangeInfo()

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

Define properties for water features.

Parameters
idType of the first water feature.
numinfoNumber of subsequent water feature ids to change the property for.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 2100 of file newgrf.cpp.

References CIR_SUCCESS.

◆ CargoChangeInfo()

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

◆ ChangeGRFBlitter()

static bool ChangeGRFBlitter ( size_t  len,
ByteReader buf 
)
static

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

Definition at line 7372 of file newgrf.cpp.

References grfmsg().

◆ ChangeGRFDescription()

static bool ChangeGRFDescription ( byte  langid,
const char *  str 
)
static

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

Definition at line 7320 of file newgrf.cpp.

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

◆ 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 7407 of file newgrf.cpp.

References grfmsg().

◆ ChangeGRFName()

static bool ChangeGRFName ( byte  langid,
const char *  str 
)
static

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

Definition at line 7313 of file newgrf.cpp.

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

◆ 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 7334 of file newgrf.cpp.

References grfmsg().

◆ 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 7346 of file newgrf.cpp.

References grfmsg().

◆ 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 7497 of file newgrf.cpp.

References grfmsg().

◆ ChangeGRFParamDescription()

static bool ChangeGRFParamDescription ( byte  langid,
const char *  str 
)
static

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

Definition at line 7436 of file newgrf.cpp.

References 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 7460 of file newgrf.cpp.

References grfmsg(), 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 7476 of file newgrf.cpp.

References grfmsg().

◆ ChangeGRFParamName()

static bool ChangeGRFParamName ( byte  langid,
const char *  str 
)
static

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

Definition at line 7429 of file newgrf.cpp.

References 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 7443 of file newgrf.cpp.

References grfmsg().

◆ 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 7601 of file newgrf.cpp.

References AddGRFTextToList(), SmallVector< T, S >::End(), SmallMap< T, U, S >::Find(), GrfProcessingState::grfconfig, GRFIdentifier::grfid, grfmsg(), GRFConfig::ident, SmallMap< T, U, S >::Insert(), GRFParameterInfo::max_value, SkipUnknownInfo(), and GRFParameterInfo::value_names.

◆ ChangeGRFURL()

static bool ChangeGRFURL ( byte  langid,
const char *  str 
)
static

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

Definition at line 7327 of file newgrf.cpp.

References AddGRFTextToList(), GrfProcessingState::grfconfig, GRFIdentifier::grfid, GRFConfig::ident, GRFTextWrapper::text, 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 7394 of file newgrf.cpp.

References grfmsg().

◆ CleanIndustryTileTable()

static void CleanIndustryTileTable ( IndustrySpec ind)
static

Clean the tile table of the IndustrySpec if it's needed.

Definition at line 3317 of file newgrf.cpp.

References CLEAN_TILELAYOUT, IndustrySpec::cleanup_flag, free(), HasBit(), IndustrySpec::num_table, and IndustrySpec::table.

Referenced by ResetCustomIndustries().

◆ CommonVehicleChangeInfo()

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

Define properties common to all vehicles.

Parameters
eiEngine info.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 1003 of file newgrf.cpp.

References EngineInfo::base_intro, EngineInfo::base_life, CIR_SUCCESS, CIR_UNKNOWN, EngineInfo::climates, DAYS_TILL_ORIGINAL_BASE_YEAR, EngineInfo::lifelength, and PROP_VEHICLE_LOAD_AMOUNT.

◆ ConvertTTDBasePrice()

static void ConvertTTDBasePrice ( uint32  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_pointerTTD(P) Base Price Pointer
error_locationFunction name for grf error messages
[out]indexIf base_pointer is valid, index is assigned to the matching price; else it is left unchanged

< Position of first base price

< Size of each base price record

Definition at line 966 of file newgrf.cpp.

Referenced by RoadVehicleChangeInfo().

◆ CreateGroupFromGroupID()

static const SpriteGroup* CreateGroupFromGroupID ( byte  feature,
byte  setid,
byte  type,
uint16  spriteid 
)
static

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

Parameters
featureGrfSpecFeature to define spritegroup for.
setidSetID of the currently being parsed Action2. (only for debug output)
typeType of the currently being parsed Action2. (only for debug output)
spriteidRaw value from the GRF for the new spritegroup; describes either the return value or the referenced spritegroup.
Returns
Created spritegroup.

Definition at line 4584 of file newgrf.cpp.

References HasBit().

◆ DisableGrf()

static GRFError* DisableGrf ( StringID  message = STR_NULL,
GRFConfig config = NULL 
)
static

Disable a GRF.

Parameters
messageError message or STR_NULL.
configGRFConfig to disable, NULL 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(), ReadSpriteLayout(), ReadSpriteLayoutRegisters(), 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
cThe NewGRF to disable.

Definition at line 6035 of file newgrf.cpp.

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

◆ DuplicateTileTable()

static void DuplicateTileTable ( AirportSpec as)
static

Create a copy of the tile table so it can be freed later without problems.

Parameters
asThe AirportSpec to copy the arrays of.

Definition at line 3660 of file newgrf.cpp.

References AirportSpec::depot_table, MemCpyT(), AirportSpec::nof_depots, AirportSpec::num_table, AirportSpec::rotation, and AirportSpec::table.

◆ 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
bitmaskThe climate and housezone to check for. Exactly one climate bit and one housezone bit should be set.

Definition at line 8531 of file newgrf.cpp.

References HouseSpec::building_availability, HouseSpec::enabled, MAX_YEAR, HouseSpec::min_year, and NUM_HOUSES.

◆ 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 8721 of file newgrf.cpp.

References SmallVector< T, S >::Begin(), SmallVector< T, S >::End(), and NUM_AIRPORTS_PER_GRF.

◆ 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 8558 of file newgrf.cpp.

References SmallVector< T, S >::Begin(), SmallVector< T, S >::End(), IsHouseSpecValid(), and NUM_HOUSES_PER_GRF.

◆ 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 8630 of file newgrf.cpp.

References SmallVector< T, S >::Begin(), IndustrySpec::closure_text, IndustrySpec::enabled, SmallVector< T, S >::End(), GetGRFStringID(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, IndustrySpec::name, IndustrySpec::new_industry_text, NUM_INDUSTRYTYPES_PER_GRF, IndustrySpec::production_down_text, IndustrySpec::production_up_text, and IndustrySpec::station_name.

◆ 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 8701 of file newgrf.cpp.

References _object_mngr, SmallVector< T, S >::Begin(), ObjectSpec::enabled, SmallVector< T, S >::End(), NUM_OBJECTS_PER_GRF, and ObjectOverrideManager::SetEntitySpec().

◆ 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 9016 of file newgrf.cpp.

◆ GetFileByFilename()

static GRFFile* GetFileByFilename ( const char *  filename)
static

Obtain a NewGRF file by its filename.

Parameters
filenameThe filename to obtain the file for.
Returns
The file.

Definition at line 406 of file newgrf.cpp.

References SmallVector< T, S >::Begin(), and SmallVector< T, S >::End().

Referenced by InitNewGRFFile().

◆ GetFileByGRFID()

static GRFFile* GetFileByGRFID ( uint32  grfid)
static

Obtain a NewGRF file by its grfID.

Parameters
grfidThe grfID to obtain the file for
Returns
The file.

Definition at line 392 of file newgrf.cpp.

References SmallVector< T, S >::Begin(), and SmallVector< T, S >::End().

Referenced by DisableGrf(), LanguageMap::GetLanguageMap(), and ImportGRFSound().

◆ GetGlobalVariable()

bool GetGlobalVariable ( byte  param,
uint32 *  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
paramvariable number (as for VarAction2, for Action7/9/D you have to subtract 0x80 first).
valuereturns the value of the variable.
grffileNewGRF querying the variable
Returns
true iff the variable is known and the value is returned in 'value'.

Definition at line 5755 of file newgrf.cpp.

References _cur_year, _date, _date_fract, _settings_game, _tick_counter, Clamp(), ConvertDateToYMD(), ConvertYMDToDate(), YearMonthDay::day, DAYS_TILL_ORIGINAL_BASE_YEAR, VehicleSettings::disable_elrails, GameSettings::game_creation, GetRailTypeInfo(), GrfProcessingState::grfconfig, GrfProcessingState::grffile, GRFP_USE_MASK, IsLeapYear(), GameCreationSettings::landscape, max(), YearMonthDay::month, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR, GRFConfig::palette, RAILTYPE_ELECTRIC, RAILTYPE_MAGLEV, RAILTYPE_MONO, RAILTYPE_RAIL, VehicleSettings::road_side, SB(), GRFFile::traininfo_vehicle_pitch, GameSettings::vehicle, and YearMonthDay::year.

Referenced by HasGrfMiscBit().

◆ GetGRFContainerVersion()

byte GetGRFContainerVersion ( )

Get the container version of the currently opened GRF file.

Returns
Container version of the GRF file or 0 if the file is corrupt/no GRF file.

Definition at line 8837 of file newgrf.cpp.

References _grf_cont_v2_sig, FioGetPos(), FioReadByte(), FioReadWord(), FioSeekTo(), and lengthof.

Referenced by HasGrfMiscBit(), LoadGrfFile(), and LoadGrfFileIndexed().

◆ GetNewEngine()

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

Returns the engine associated to a certain internal_id, resp.

allocates it.

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

Definition at line 600 of file newgrf.cpp.

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

◆ GetNewEngineID()

EngineID GetNewEngineID ( const GRFFile file,
VehicleType  type,
uint16  internal_id 
)

Return the ID of a new engine.

Parameters
fileThe NewGRF file providing the engine.
typeThe Vehicle type.
internal_idNewGRF-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 695 of file newgrf.cpp.

◆ GlobalVarChangeInfo()

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

Define properties for global variables.

Parameters
gvidID of the global variable.
numinfoNumber of subsequent IDs to change the property for.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 2584 of file newgrf.cpp.

References GRFFile::cargo_list, CIR_SUCCESS, GrfProcessingState::grffile, LoadTranslationTable(), and GRFFile::railtype_list.

◆ grfmsg()

void CDECL grfmsg ( int  severity,
const char *  str,
  ... 
)

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
severitydebugging severity level, see debug.h
strmessage in printf() format

Definition at line 375 of file newgrf.cpp.

References DEBUG, GRFConfig::filename, GrfProcessingState::grfconfig, lastof, GrfProcessingState::nfo_line, and vseprintf().

Referenced by AircraftVehicleChangeInfo(), AirportChangeInfo(), BindAirportSpecs(), BridgeChangeInfo(), CargoChangeInfo(), ChangeGRFBlitter(), ChangeGRFMinVersion(), ChangeGRFNumUsedParams(), ChangeGRFPalette(), ChangeGRFParamDefault(), ChangeGRFParamLimits(), ChangeGRFParamMask(), ChangeGRFParamType(), ChangeGRFParamValueNames(), ChangeGRFVersion(), DEFINE_NEWGRF_CLASS_METHOD(), DefineGotoLabel(), UnmappedChoiceList::Flush(), HandleParameterInfo(), HasGrfMiscBit(), ImportGRFSound(), IndustriesChangeInfo(), IndustrytilesChangeInfo(), ObjectChangeInfo(), ParamSet(), ReadSpriteLayout(), ReadSpriteLayoutRegisters(), RoadVehicleChangeInfo(), SanitizeSpriteOffset(), HouseOverrideManager::SetEntitySpec(), IndustryOverrideManager::SetEntitySpec(), ObjectOverrideManager::SetEntitySpec(), ShipVehicleChangeInfo(), SkipAct12(), SoundEffectChangeInfo(), StationChangeInfo(), TownHouseChangeInfo(), and TranslateGRFStrings().

◆ GRFUnsafe()

static void GRFUnsafe ( ByteReader buf)
static

Set the current NewGRF as unsafe for static use.

Parameters
bufUnused.
Note
Used during safety scan on unsafe actions.

Definition at line 7807 of file newgrf.cpp.

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

◆ HandleNode()

static bool HandleNode ( byte  type,
uint32  id,
ByteReader buf,
AllowedSubtags  subtags[] 
)
static

Handle the nodes of an Action14.

Parameters
typeType of node.
idID.
bufBuffer.
subtagsAllowed subtags.
Returns
Whether all tags could be handled.

Definition at line 7743 of file newgrf.cpp.

References BSWAP32(), AllowedSubtags::id, 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
bufBuffer.
subtagsList of subtags.
Returns
Whether the nodes could all be handled.

Definition at line 7781 of file newgrf.cpp.

References HandleNode().

Referenced by HandleParameterInfo(), and StaticGRFInfo().

◆ 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 7648 of file newgrf.cpp.

References SmallVector< T, S >::Append(), GrfProcessingState::grfconfig, grfmsg(), HandleNodes(), SmallVector< T, S >::Length(), GRFConfig::num_valid_params, GRFConfig::param_info, and SkipUnknownInfo().

◆ IgnoreIndustryProperty()

static ChangeInfoResult IgnoreIndustryProperty ( int  prop,
ByteReader buf 
)
static

Ignore an industry property.

Parameters
propThe property to ignore.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 3218 of file newgrf.cpp.

References CIR_SUCCESS.

Referenced by IndustriesChangeInfo().

◆ IgnoreIndustryTileProperty()

static ChangeInfoResult IgnoreIndustryTileProperty ( int  prop,
ByteReader buf 
)
static

Ignore an industry tile property.

Parameters
propThe property to ignore.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 3064 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
propThe property to ignore.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 3863 of file newgrf.cpp.

References CIR_SUCCESS, and CIR_UNKNOWN.

Referenced by ObjectChangeInfo().

◆ IgnoreTownHouseProperty()

static ChangeInfoResult IgnoreTownHouseProperty ( int  prop,
ByteReader buf 
)
static

Ignore a house property.

Parameters
propProperty to read.
bufProperty value.
Returns
ChangeInfoResult.

Definition at line 2248 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
soundDestination for sound.

Definition at line 7052 of file newgrf.cpp.

References FioReadDword(), FioReadWord(), GetFileByGRFID(), and grfmsg().

◆ IndustriesChangeInfo()

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

Define properties for industries.

Parameters
indidLocal ID of the industry.
numinfoNumber of subsequent industry IDs to change the property for.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 3338 of file newgrf.cpp.

References CIR_INVALID_ID, CIR_SUCCESS, GrfProcessingState::grffile, grfmsg(), IgnoreIndustryProperty(), and NUM_INDUSTRYTYPES_PER_GRF.

◆ IndustrytilesChangeInfo()

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

Define properties for industry tiles.

Parameters
indtidLocal ID of the industry tile.
numinfoNumber of subsequent industry tile IDs to change the property for.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 3100 of file newgrf.cpp.

References CIR_INVALID_ID, CIR_SUCCESS, GrfProcessingState::grffile, grfmsg(), IgnoreIndustryTileProperty(), NEW_INDUSTRYTILEOFFSET, and NUM_INDUSTRYTILES_PER_GRF.

◆ InitGRFTownGeneratorNames()

void InitGRFTownGeneratorNames ( )

Allocate memory for the NewGRF town names.

Definition at line 76 of file settings_gui.cpp.

References _grf_names, and free().

◆ InitNewGRFFile()

static void InitNewGRFFile ( const GRFConfig config)
static

Prepare loading a NewGRF file with its config.

Parameters
configThe NewGRF configuration struct with name, id, parameters and alike.

Definition at line 8204 of file newgrf.cpp.

References SmallVector< T, S >::Append(), GRFConfig::filename, GetFileByFilename(), and GrfProcessingState::grffile.

◆ IsHouseSpecValid()

static bool IsHouseSpecValid ( HouseSpec hs,
const HouseSpec next1,
const HouseSpec next2,
const HouseSpec next3,
const char *  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
hsThe housespec to check.
next1The housespec that follows hs.
next2The housespec that follows next1.
next3The housespec that follows next2.
filenameThe filename of the newgrf this house was defined in.
Returns
Whether the given housespec is valid.

Definition at line 8485 of file newgrf.cpp.

References HouseSpec::building_flags.

Referenced by FinaliseHouseArray().

◆ IsValidNewGRFImageIndex()

template<VehicleType T>
static bool IsValidNewGRFImageIndex ( uint8  image_index)
inlinestatic

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

Parameters
<T>The type of vehicle.
image_indexThe image index to check.
Returns
True iff the image index is valid, or 0xFD (use new graphics).

Definition at line 202 of file newgrf.cpp.

◆ LoadGRFSound()

static void LoadGRFSound ( size_t  offs,
SoundEntry sound 
)
static

Load a sound from a file.

Parameters
offsFile offset to read sound from.
soundDestination for sound.

Definition at line 7083 of file newgrf.cpp.

◆ LoadNewGRF()

void LoadNewGRF ( uint  load_index,
uint  file_index,
uint  num_baseset 
)

Load all the NewGRFs.

Parameters
load_indexThe offset for the first sprite to add.
file_indexThe Fio index of the first NewGRF to load.
num_basesetNumber of NewGRFs at the front of the list to look up in the baseset dir instead of the newgrf dir.

Definition at line 9228 of file newgrf.cpp.

References _cur_year, _date, _date_fract, _display_opt, _grfconfig, _networking, _settings_game, _tick_counter, ConvertYMDToDate(), GameSettings::game_creation, GCS_NOT_FOUND, GCS_UNKNOWN, InitializeGRFSpecial(), GRFConfig::next, ResetNewGRFData(), GrfProcessingState::spriteid, GrfProcessingState::stage, and GameCreationSettings::starting_year.

Referenced by HasGrfMiscBit().

◆ LoadNewGRFFile()

void LoadNewGRFFile ( GRFConfig config,
uint  file_index,
GrfLoadingStage  stage,
Subdirectory  subdir 
)

Load a particular NewGRF.

Parameters
configThe configuration of the to be loaded NewGRF.
file_indexThe Fio index of the first NewGRF to load.
stageThe loading stage of the NewGRF.
subdirThe sub directory to find the NewGRF in.

Definition at line 8863 of file newgrf.cpp.

References GRFConfig::filename.

Referenced by FillGRFDetails(), and HasGrfMiscBit().

◆ LoadTranslationTable()

template<typename T >
static ChangeInfoResult LoadTranslationTable ( uint  gvid,
int  numinfo,
ByteReader buf,
T &  translation_table,
const char *  name 
)
static

Load a cargo- or railtype-translation table.

Parameters
gvidID of the global variable. This is basically only checked for zerones.
numinfoNumber of subsequent IDs to change the property for.
bufThe property value.
[in,out]translation_tableStorage location for the translation table.
nameName of the table for debug output.
Returns
ChangeInfoResult.

Definition at line 2560 of file newgrf.cpp.

Referenced by GlobalVarChangeInfo().

◆ MapGRFStringID()

StringID MapGRFStringID ( uint32  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
grfidId of the grf file.
strStringID that we want to have the equivalent in OoenTTD.
Returns
The properly adjusted StringID.

Definition at line 552 of file newgrf.cpp.

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

Referenced by AfterLoadGRFs(), and HasGrfMiscBit().

◆ MapSpriteMappingRecolour()

static void MapSpriteMappingRecolour ( PalSpriteID grf_sprite)
static

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

Parameters
grf_spritePointer to the structure been modified.

Definition at line 711 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().

◆ ObjectChangeInfo()

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

◆ RailTypeChangeInfo()

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

Define properties for railtypes.

Parameters
idID of the railtype.
numinfoNumber of subsequent IDs to change the property for.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 4040 of file newgrf.cpp.

References CIR_SUCCESS.

◆ 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.
numinfoNumber of subsequent IDs to change the property for.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 1046 of file newgrf.cpp.

References CIR_INVALID_ID, CIR_SUCCESS, RailVehicleInfo::engclass, GetNewEngine(), GrfProcessingState::grffile, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, GRFFile::railtype_list, and VEH_TRAIN.

◆ ReadSpriteLayout()

static bool ReadSpriteLayout ( ByteReader buf,
uint  num_building_sprites,
bool  use_cur_spritesets,
byte  feature,
bool  allow_var10,
bool  no_z_position,
NewGRFSpriteLayout dts 
)
static

Read a spritelayout from the GRF.

Parameters
bufInput
num_building_spritesNumber of building sprites to read
use_cur_spritesetsWhether to use currently referenceable action 1 sets.
featureGrfSpecFeature to use spritesets from.
allow_var10Whether the spritelayout may specifiy var10 values for resolving multiple action-1-2-3 chains
no_z_positionWhether bounding boxes have no Z offset
dtsLayout container to output into
Returns
True on error (GRF was disabled).

Definition at line 853 of file newgrf.cpp.

References AllocaM, NewGRFSpriteLayout::Allocate(), ClrBit(), NewGRFSpriteLayout::consistent_max_offset, DrawTileSeqStruct::delta_x, DrawTileSeqStruct::delta_z, DisableGrf(), grfmsg(), DrawTileSprites::ground, HasBit(), DrawTileSeqStruct::IsParentSprite(), MemSetT(), ReadSpriteLayoutRegisters(), ReadSpriteLayoutSprite(), DrawTileSprites::seq, GrfProcessingState::skip_sprites, TLF_KNOWN_FLAGS, TLF_NON_GROUND_FLAGS, and TLF_VAR10_FLAGS.

◆ 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
bufInput stream.
flagsTileLayoutFlags to process.
is_parentWhether the sprite is a parentsprite with a bounding box.
dtsSprite layout to insert data into.
indexSprite index to process; 0 for ground sprite.

Definition at line 800 of file newgrf.cpp.

References NewGRFSpriteLayout::AllocateRegisters(), TileLayoutRegisters::child, DisableGrf(), TileLayoutRegisters::dodraw, TileLayoutRegisters::flags, grfmsg(), 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 *  max_sprite_offset = NULL,
uint16 *  max_palette_offset = NULL 
)
static

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

Parameters
bufInput stream.
read_flagsWhether to read TileLayoutFlags.
invert_action1_flagSet to true, if palette bit 15 means 'not from action 1'.
use_cur_spritesetsWhether to use currently referenceable action 1 sets.
featureGrfSpecFeature to use spritesets from.
[out]grf_spriteRead sprite and palette.
[out]max_sprite_offsetOptionally returns the number of sprites in the spriteset of the sprite. (0 if no spritset)
[out]max_palette_offsetOptionally returns the number of sprites in the spriteset of the palette. (0 if no spritset)
Returns
Read TileLayoutFlags.

Definition at line 742 of file newgrf.cpp.

References PalSpriteID::pal, and PalSpriteID::sprite.

Referenced by ReadSpriteLayout().

◆ RoadVehicleChangeInfo()

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

◆ SanitizeSpriteOffset()

static uint16 SanitizeSpriteOffset ( uint16 &  num,
uint16  offset,
int  max_sprites,
const char *  name 
)
static

Sanitize incoming sprite offsets for Action 5 graphics replacements.

Parameters
numThe number of sprites to load.
offsetOffset from the base.
max_spritesThe maximum number of sprites that can be loaded in this action 5.
nameUsed for error warnings.
Returns
The number of sprites that is going to be skipped.

Definition at line 5591 of file newgrf.cpp.

References grfmsg(), and max().

◆ SetNewGRFOverride()

static void SetNewGRFOverride ( uint32  source_grfid,
uint32  target_grfid 
)
static

Set the override for a NewGRF.

Parameters
source_grfidThe grfID which wants to override another NewGRF.
target_grfidThe grfID which is being overridden.

Definition at line 586 of file newgrf.cpp.

◆ ShipVehicleChangeInfo()

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

◆ SkipUnknownInfo()

static bool SkipUnknownInfo ( ByteReader buf,
byte  type 
)
static

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

Parameters
bufBuffer.
typeThe node type to skip.
Returns
True if we could skip the node, false if an error occurred.

Definition at line 7703 of file newgrf.cpp.

Referenced by ChangeGRFParamValueNames(), and HandleParameterInfo().

◆ SoundEffectChangeInfo()

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

Define properties for sound effects.

Parameters
sidLocal ID of the sound.
numinfoNumber of subsequent IDs to change the property for.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 3009 of file newgrf.cpp.

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

◆ StaticGRFInfo()

static void StaticGRFInfo ( ByteReader buf)
static

Handle Action 0x14.

Parameters
bufBuffer.

Definition at line 7796 of file newgrf.cpp.

References HandleNodes().

◆ StationChangeInfo()

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

Define properties for stations.

Parameters
stdidStationID of the first station tile.
numinfoNumber of subsequent station tiles to change the property for.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 1854 of file newgrf.cpp.

References BSWAP32(), CIR_INVALID_ID, CIR_SUCCESS, NewGRFSpriteLayout::consistent_max_offset, GrfProcessingState::grffile, grfmsg(), NUM_STATIONS_PER_GRF, StationSpec::renderdata, and StationSpec::tiles.

◆ TownHouseChangeInfo()

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

Define properties for houses.

Parameters
hidHouseID of the house.
numinfoNumber of subsequent houseIDs to change the property for.
propThe property to change.
bufThe property value.
Returns
ChangeInfoResult.

Definition at line 2311 of file newgrf.cpp.

References HouseSpec::building_flags, CIR_INVALID_ID, CIR_SUCCESS, HouseSpec::enabled, CargoSpec::Get(), GrfProcessingState::grffile, grfmsg(), GRFLoadedFeatures::has_newhouses, IgnoreTownHouseProperty(), CargoSpec::IsValid(), MemCpyT(), NEW_HOUSE_OFFSET, and NUM_HOUSES_PER_GRF.

◆ 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
strthe string ID to convert
Returns
the converted string ID

Definition at line 488 of file newgrf.cpp.

Referenced by MapGRFStringID().

◆ ValidateIndustryLayout()

static bool ValidateIndustryLayout ( const IndustryTileTable layout,
int  size 
)
static

Validate the industry layout; e.g.

to prevent duplicate tiles.

Parameters
layoutThe layout to check.
sizeThe size of the layout.
Returns
True if the layout is deemed valid.

Definition at line 3303 of file newgrf.cpp.

References TileIndexDiffC::x, and TileIndexDiffC::y.

Variable Documentation

◆ _action5_types

const Action5Type _action5_types[]
static
Initial value:
= {
{ 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_ALLOW_OFFSET, SPR_FLAGS_BASE, 1, FLAGS_SPRITE_COUNT, "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" },
}
static const SpriteID SPR_SHORE_BASE
shore tiles - action 05-0D
Definition: sprites.h:213
static const SpriteID SPR_TRACKS_FOR_SLOPES_BASE
Sprites for &#39;highlighting&#39; tracks on sloped land.
Definition: sprites.h:187
static const SpriteID SPR_ONEWAY_BASE
One way road sprites.
Definition: sprites.h:280
Allow replacing any subset by specifiing an offset.
Definition: newgrf.cpp:5615
static const SpriteID SPR_AQUEDUCT_BASE
Sprites for the Aqueduct.
Definition: sprites.h:175
unknown/not-implemented type
Definition: newgrf.cpp:5616
static const SpriteID SPR_RAILTYPE_TUNNEL_BASE
Tunnel sprites with grass only for custom railtype tunnel.
Definition: sprites.h:288
static const SpriteID SPR_AIRPORT_PREVIEW_BASE
Airport preview sprites.
Definition: sprites.h:237
static const SpriteID SPR_OPENTTD_BASE
Extra graphic spritenumbers.
Definition: sprites.h:58
static const SpriteID SPR_TRAMWAY_BASE
Tramway sprites.
Definition: sprites.h:261
Only allow replacing a whole block of sprites. (TTDP compatible)
Definition: newgrf.cpp:5614
static const SpriteID SPR_FLAGS_BASE
Flags sprites (in same order as enum NetworkLanguage)
Definition: sprites.h:284

The information about action 5 types.

Definition at line 5628 of file newgrf.cpp.

◆ _default_refitmasks

const CargoLabel* const _default_refitmasks[]
static
Initial value:
= {
_default_refitmasks_road,
_default_refitmasks_ships,
_default_refitmasks_aircraft,
}
static const CargoLabel _default_refitmasks_rail[]
List of what cargo labels are refittable for the given the vehicle-type.
Definition: newgrf.cpp:8264

Definition at line 8286 of file newgrf.cpp.

◆ _default_refitmasks_aircraft

const CargoLabel _default_refitmasks_aircraft[]
static
Initial value:
= {
'PASS', 'MAIL', 'GOOD', 'VALU', 'GOLD', 'DIAM', 'FOOD', 'FRUT', 'SUGR',
'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', 'PLST', 'FZDR',
0 }

Definition at line 8281 of file newgrf.cpp.

◆ _default_refitmasks_rail

const CargoLabel _default_refitmasks_rail[]
static
Initial value:
= {
'PASS', 'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD',
'IORE', 'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE',
'WATR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL',
'PLST', 'FZDR',
0 }

List of what cargo labels are refittable for the given the vehicle-type.

Only currently active labels are applied.

Definition at line 8264 of file newgrf.cpp.

◆ _default_refitmasks_road

const CargoLabel _default_refitmasks_road[]
static
Initial value:
= {
0 }

Definition at line 8271 of file newgrf.cpp.

◆ _default_refitmasks_ships

const CargoLabel _default_refitmasks_ships[]
static
Initial value:
= {
'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD', 'IORE',
'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE', 'WATR',
'RUBR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL',
'PLST', 'FZDR',
0 }

Definition at line 8274 of file newgrf.cpp.

◆ _grf_cont_v2_sig

const byte _grf_cont_v2_sig[8] = {'G', 'R', 'F', 0x82, 0x0D, 0x0A, 0x1A, 0x0A}

Signature of a container version 2 GRF.

Referenced by GetGRFContainerVersion(), and GRFGetSizeOfDataSection().

◆ _grm_engines

uint32 _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 339 of file newgrf.cpp.

◆ _tags_info

AllowedSubtags _tags_info[]
Initial value:
= {
}
static bool ChangeGRFPalette(size_t len, ByteReader *buf)
Callback function for &#39;INFO&#39;->&#39;PALS&#39; to set the number of valid parameters.
Definition: newgrf.cpp:7346
static bool ChangeGRFDescription(byte langid, const char *str)
Callback function for &#39;INFO&#39;->&#39;DESC&#39; to add a translation to the newgrf description.
Definition: newgrf.cpp:7320
static bool ChangeGRFURL(byte langid, const char *str)
Callback function for &#39;INFO&#39;->&#39;URL_&#39; to set the newgrf url.
Definition: newgrf.cpp:7327
static bool ChangeGRFVersion(size_t len, ByteReader *buf)
Callback function for &#39;INFO&#39;->&#39;VRSN&#39; to the version of the NewGRF.
Definition: newgrf.cpp:7394
static bool ChangeGRFMinVersion(size_t len, ByteReader *buf)
Callback function for &#39;INFO&#39;->&#39;MINV&#39; to the minimum compatible version of the NewGRF.
Definition: newgrf.cpp:7407
static bool ChangeGRFBlitter(size_t len, ByteReader *buf)
Callback function for &#39;INFO&#39;->&#39;BLTR&#39; to set the blitter info.
Definition: newgrf.cpp:7372
static bool ChangeGRFNumUsedParams(size_t len, ByteReader *buf)
Callback function for &#39;INFO&#39;->&#39;NPAR&#39; to set the number of valid parameters.
Definition: newgrf.cpp:7334
Data structure to store the allowed id/type combinations for action 14.
Definition: newgrf.cpp:7520
static bool ChangeGRFName(byte langid, const char *str)
Callback function for &#39;INFO&#39;->&#39;NAME&#39; to add a translation to the newgrf name.
Definition: newgrf.cpp:7313
static bool HandleParameterInfo(ByteReader *buf)
Callback function for &#39;INFO&#39;->&#39;PARA&#39; to set extra information about the parameters.
Definition: newgrf.cpp:7648

Action14 tags for the INFO node.

Definition at line 7677 of file newgrf.cpp.

◆ _tags_parameters

AllowedSubtags _tags_parameters[]
Initial value:
= {
}
static bool ChangeGRFParamMask(size_t len, ByteReader *buf)
Callback function for &#39;INFO&#39;->&#39;PARAM&#39;->param_num->&#39;MASK&#39; to set the parameter and bits to use...
Definition: newgrf.cpp:7476
static bool ChangeGRFParamLimits(size_t len, ByteReader *buf)
Callback function for &#39;INFO&#39;->&#39;PARAM&#39;->param_num->&#39;LIMI&#39; to set the min/max value of a parameter...
Definition: newgrf.cpp:7460
static bool ChangeGRFParamName(byte langid, const char *str)
Callback function for &#39;INFO&#39;->&#39;PARAM&#39;->param_num->&#39;NAME&#39; to set the name of a parameter.
Definition: newgrf.cpp:7429
static bool ChangeGRFParamValueNames(ByteReader *buf)
Callback function for &#39;INFO&#39;->&#39;PARA&#39;->param_num->&#39;VALU&#39; to set the names of some parameter values (ty...
Definition: newgrf.cpp:7601
static bool ChangeGRFParamDefault(size_t len, ByteReader *buf)
Callback function for &#39;INFO&#39;->&#39;PARAM&#39;->param_num->&#39;DFLT&#39; to set the default value.
Definition: newgrf.cpp:7497
Data structure to store the allowed id/type combinations for action 14.
Definition: newgrf.cpp:7520
static bool ChangeGRFParamType(size_t len, ByteReader *buf)
Callback function for &#39;INFO&#39;->&#39;PARAM&#39;->param_num->&#39;TYPE&#39; to set the typeof a parameter.
Definition: newgrf.cpp:7443
static bool ChangeGRFParamDescription(byte langid, const char *str)
Callback function for &#39;INFO&#39;->&#39;PARAM&#39;->param_num->&#39;DESC&#39; to set the description of a parameter...
Definition: newgrf.cpp:7436

Action14 parameter tags.

Definition at line 7631 of file newgrf.cpp.

◆ _tags_root

AllowedSubtags _tags_root[]
Initial value:
= {
}
AllowedSubtags _tags_info[]
Action14 tags for the INFO node.
Definition: newgrf.cpp:7677
Data structure to store the allowed id/type combinations for action 14.
Definition: newgrf.cpp:7520

Action14 root tags.

Definition at line 7691 of file newgrf.cpp.

◆ _ttdpatch_flags

uint32 _ttdpatch_flags[8]
static

32 * 8 = 256 flags.

Apparently TTDPatch uses this many..

Definition at line 74 of file newgrf.cpp.

Referenced by InitializeGRFSpecial().