OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

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

Base of all NewGRF support. More...

`#include "stdafx.h"`
`#include <stdarg.h>`
`#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.
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.
static GRFFile * | GetFileByGRFID (uint32 grfid)
| Obtain a NewGRF file by its grfID.
static GRFFile * | GetFileByFilename (const char *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=NULL)
| Disable a GRF.
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 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 source_grfid, uint32 target_grfid)
| Set the override for a NewGRF.
static Engine * | GetNewEngine (const GRFFile *file, VehicleType type, uint16 internal_id, bool static_access=false)
| Returns the engine associated to a certain internal_id, resp.
EngineID | GetNewEngineID (const GRFFile *file, VehicleType type, uint16 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 *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.
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, byte feature, bool allow_var10, bool no_z_position, NewGRFSpriteLayout *dts)
| Read a spritelayout from the GRF.
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.
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 >
static ChangeInfoResult | LoadTranslationTable (uint gvid, int numinfo, ByteReader *buf, T &translation_table, const char *name)
| Load a cargo- or railtype-translation table.
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 IndustryTileTable *layout, int size)
| Validate the industry layout; e.g.
static void | CleanIndustryTileTable (IndustrySpec *ind)
| Clean the tile table of the IndustrySpec if it's needed.
static ChangeInfoResult | IndustriesChangeInfo (uint indid, int numinfo, int prop, ByteReader *buf)
| Define properties for industries.
static void | DuplicateTileTable (AirportSpec *as)
| Create a copy of the tile table so it can be freed later without problems.
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 | 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 SpriteGroup * | GetGroupFromGroupID (byte setid, byte type, uint16 groupid)
static const SpriteGroup * | CreateGroupFromGroupID (byte feature, byte setid, byte type, uint16 spriteid)
| Helper function to either create a callback or a result sprite group.
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.
static void | GraphicsNew (ByteReader *buf)
static void | SkipAct5 (ByteReader *buf)
void | CheckForMissingSprites ()
| Check whether we are (obviously) missing some of the extra (Action 0x05) sprites that we like to use.
bool | GetGlobalVariable (byte param, uint32 *value, const GRFFile *grffile)
| Reads a variable common to VarAction2 and Action7/9/D.
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.
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.
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 (byte langid, const char *str)
| Callback function for 'INFO'->'NAME' to add a translation to the newgrf name.
static bool | ChangeGRFDescription (byte langid, const char *str)
| Callback function for 'INFO'->'DESC' to add a translation to the newgrf description.
static bool | ChangeGRFURL (byte langid, const char *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 (byte langid, const char *str)
| Callback function for 'INFO'->'PARAM'->param_num->'NAME' to set the name of a parameter.
static bool | ChangeGRFParamDescription (byte langid, const char *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, byte 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 (byte type, uint32 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 *buf)
| 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 | 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.
static void | InitNewGRFFile (const GRFConfig *config)
| Prepare loading a NewGRF file with its config.
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.
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.
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 (byte *buf, uint num, GrfLoadingStage stage)
byte | GetGRFContainerVersion ()
| Get the container version of the currently opened GRF file.
void | LoadNewGRFFile (GRFConfig *config, uint file_index, GrfLoadingStage stage, Subdirectory subdir)
| Load a particular NewGRF.
static void | ActivateOldShore ()
| Relocates the old shore sprites at new positions.
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 (uint load_index, uint file_index)
| Load all the NewGRFs.

## 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.
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.
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.
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.
static const CargoLabel | _default_refitmasks_rail []
| List of what cargo labels are refittable for the given the vehicle-type.
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.

## Detailed Description

Base of all NewGRF support.

Definition in file newgrf.cpp.

## Macro Definition Documentation

#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

enum 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 5565 of file newgrf.cpp.

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

## Function Documentation

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

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

Referenced by AfterLoadGRFs().

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

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

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

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

References AlterVehicleListOrder(), EngineInfo::base_intro, EngineInfo::callback_mask, EngineInfo::cargo_age_period, CIR_INVALID_ID, CIR_SUCCESS, CommonVehicleChangeInfo(), CT_INVALID, GRFTempEngineData::ctt_exclude_mask, GRFTempEngineData::ctt_include_mask, GRFTempEngineData::defaultcargo_grf, EF_USES_2CC, GetCargoTranslation(), GetNewEngine(), GetNewGRFSoundID(), GrfProcessingState::grffile, grfmsg(), GRFLoadedFeatures::has_2CC, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, 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(), GRFTempEngineData::UpdateRefittability(), and VEH_AIRCRAFT.

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

References OverrideManagerBase::Add(), AddStringForMapping(), AirportSpec::catchment, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, Clamp(), DIR_E, DIR_W, DuplicateTileTable(), AirportSpec::enabled, free(), GB(), OverrideManagerBase::GetID(), AirportSpec::GetWithoutOverride(), AirportTileTable::gfx, GrfProcessingState::grffile, grfmsg(), INVALID_AIRPORTTILE, AirportSpec::maintenance_cost, MAX_CATCHMENT, MAX_YEAR, AirportSpec::max_year, AirportSpec::min_year, AirportSpec::name, NEW_AIRPORT_OFFSET, AirportSpec::noise_level, NUM_AIRPORTS_PER_GRF, AirportSpec::num_table, AirportSpec::rotation, AirportSpec::size_x, AirportSpec::size_y, AirportSpec::table, AirportTileTable::ti, AirportSpec::ttd_airport_type, and TileIndexDiffC::x.

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 2132 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, BridgeSpec::sprite_table, and BridgeSpec::transport_name.

static void BuildCargoTranslationMap | ( |  | ) |
| static

Construct the Cargo Mapping.

Note
  This is the reverse of a cargo translation table

Definition at line 8161 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.

Referenced by LoadNewGRF().

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

References _cargo_mask, RailVehicleInfo::capacity, GRFFile::cargo_list, GRFFile::cargo_map, CargoSpec::classes, EngineInfo::climates, CT_INVALID, GRFTempEngineData::ctt_exclude_mask, GRFTempEngineData::ctt_include_mask, GRFTempEngineData::defaultcargo_grf, GRFTempEngineData::EMPTY, FindFirstBit(), GetCargoIDByLabel(), Engine::GetGRF(), HasBit(), CargoSpec::Index(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, SmallVector< T, S >::Length(), ShipVehicleInfo::old_refittable, RAILVEH_WAGON, GRFTempEngineData::refittability, SetBit(), Engine::type, GRFTempEngineData::UNSET, VEH_SHIP, and VEH_TRAIN.

Referenced by AfterLoadGRFs().

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

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

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

References _cargo_mask, CargoSpec::abbrev, AddStringForMapping(), CargoSpec::bitnum, BSWAP32(), CargoSpec::callback_mask, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, CargoSpec::classes, ClrBit(), CargoSpec::Get(), CargoSpec::grffile, GrfProcessingState::grffile, grfmsg(), CargoSpec::is_freight, CargoSpec::IsValid(), CargoSpec::label, CargoSpec::multiplier, CargoSpec::multipliertowngrowth, CargoSpec::name, CargoSpec::name_single, NUM_CARGO, CargoSpec::quantifier, SetBit(), CargoSpec::sprite, TE_FOOD, TE_GOODS, TE_MAIL, TE_NONE, TE_PASSENGERS, TE_WATER, CargoSpec::town_effect, CargoSpec::units_volume, and CargoSpec::weight.

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

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

Definition at line 7353 of file newgrf.cpp.

References GrfProcessingState::grfconfig, grfmsg(), GRFP_BLT_32BPP, GRFP_BLT_MASK, GRFP_BLT_UNSET, and GRFConfig::palette.

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

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

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

References GrfProcessingState::grfconfig, grfmsg(), GRFConfig::min_loadable_version, and GRFConfig::version.

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

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

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

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

Definition at line 7315 of file newgrf.cpp.

References GrfProcessingState::grfconfig, grfmsg(), lengthof, min(), GRFConfig::num_valid_params, and GRFConfig::param.

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

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

Definition at line 7327 of file newgrf.cpp.

References GrfProcessingState::grfconfig, grfmsg(), GRFP_GRF_ANY, GRFP_GRF_DOS, GRFP_GRF_MASK, GRFP_GRF_UNSET, GRFP_GRF_WINDOWS, and GRFConfig::palette.

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

References GRFParameterInfo::def_value, GrfProcessingState::grfconfig, grfmsg(), and GRFConfig::has_param_defaults.

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

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

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

References grfmsg(), GRFParameterInfo::max_value, GRFParameterInfo::min_value, PTYPE_UINT_ENUM, and GRFParameterInfo::type.

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

References GRFParameterInfo::first_bit, GrfProcessingState::grfconfig, grfmsg(), lengthof, min(), GRFParameterInfo::num_bit, GRFConfig::param, and GRFParameterInfo::param_nr.

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

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

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

References grfmsg(), PTYPE_END, and GRFParameterInfo::type.

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 7582 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.

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

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

Definition at line 7308 of file newgrf.cpp.

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

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

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

Definition at line 7375 of file newgrf.cpp.

References GrfProcessingState::grfconfig, grfmsg(), GRFConfig::min_loadable_version, and GRFConfig::version.

void CheckForMissingSprites | ( |  | ) |

Check whether we are (obviously) missing some of the extra (Action 0x05) sprites that we like to use.

When missing sprites are found a warning will be shown.

Definition at line 5701 of file newgrf.cpp.

References A5BLOCK_INVALID, Action5Type::block_type, DEBUG, INVALID_STRING_ID, lengthof, Action5Type::max_sprites, Action5Type::name, ShowErrorMessage(), Action5Type::sprite_base, and WL_CRITICAL.

Referenced by LoadIntroGame().

static void CleanIndustryTileTable | ( | IndustrySpec * | ind | ) |
| static

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

Definition at line 3311 of file newgrf.cpp.

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

Referenced by IndustriesChangeInfo(), and ResetCustomIndustries().

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 997 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.

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

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

References grfmsg().

Referenced by RailVehicleChangeInfo(), and RoadVehicleChangeInfo().

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

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

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

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

Disable a GRF.

Parameters

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

Returns
  Error message of the GRF for further customisation.

Definition at line 432 of file newgrf.cpp.

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

Referenced by DisableStaticNewGRFInfluencingNonStaticNewGRFs(), FeatureTownName(), LoadNewGRFFile(), ParamSet(), ReadSpriteLayout(), ReadSpriteLayoutRegisters(), ReadSpriteLayoutSprite(), and TranslateGRFStrings().

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

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

Referenced by ParamSet().

static void DuplicateTileTable | ( | AirportSpec * | as | ) |
| static

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

Parameters

  as | The AirportSpec to copy the arrays of.

Definition at line 3654 of file newgrf.cpp.

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

Referenced by AirportChangeInfo().

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

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

Referenced by FinaliseHouseArray().

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

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

Referenced by AfterLoadGRFs().

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

References _settings_game, SmallVector< T, S >::Begin(), HouseSpec::building_flags, SmallVector< T, S >::End(), EnsureEarlyHouse(), GameSettings::game_creation, HZ_SUBARTC_ABOVE, HZ_ZON1, HZ_ZON5, IsHouseSpecValid(), GameCreationSettings::landscape, NUM_HOUSES, NUM_HOUSES_PER_GRF, and HouseOverrideManager::SetEntitySpec().

Referenced by AfterLoadGRFs().

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

References SmallVector< T, S >::Begin(), IndustrySpec::closure_text, IndustrySpec::conflicting, IndustrySpec::enabled, SmallVector< T, S >::End(), GetGRFStringID(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, GRFLoadedFeatures::has_newindustries, MapNewGRFIndustryType(), IndustrySpec::name, IndustrySpec::new_industry_text, NUM_INDUSTRYTILES_PER_GRF, NUM_INDUSTRYTYPES, NUM_INDUSTRYTYPES_PER_GRF, IndustrySpec::production_down_text, IndustrySpec::production_up_text, IndustryOverrideManager::SetEntitySpec(), and IndustrySpec::station_name.

Referenced by AfterLoadGRFs().

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

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

Referenced by AfterLoadGRFs().

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

References AllocaM, SmallVector< T, S >::Begin(), DEBUG, SmallVector< T, S >::End(), PriceBaseSpec::fallback_price, SmallVector< T, S >::FindIndex(), GetFileByGRFID(), PriceBaseSpec::grf_feature, GRFFile::grf_features, HasBit(), SmallVector< T, S >::Length(), GRFFile::price_base_multipliers, and SetPriceBaseMultiplier().

Referenced by AfterLoadGRFs().

static GRFFile* GetFileByFilename | ( | const char * | filename | ) |
| static

Obtain a NewGRF file by its filename.

Parameters

  filename | The filename to obtain the file for.

Returns
  The file.

Definition at line 405 of file newgrf.cpp.

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

Referenced by InitNewGRFFile(), and LoadNewGRFFile().

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

Obtain a NewGRF file by its grfID.

Parameters

  grfid | The grfID to obtain the file for

Returns
  The file.

Definition at line 391 of file newgrf.cpp.

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

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

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

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

References _cur_year, _date, _date_fract, _misc_grf_features, _settings_game, _tick_counter, Clamp(), GameSettings::construction, ConvertDateToYMD(), ConvertYMDToDate(), YearMonthDay::day, DAYS_TILL_ORIGINAL_BASE_YEAR, VehicleSettings::disable_elrails, GameSettings::game_creation, GetRailTypeInfo(), GetSnowLine(), GMB_TRAIN_WIDTH_32_PIXELS, GrfProcessingState::grfconfig, GrfProcessingState::grffile, GRFP_USE_MASK, HasBit(), IsLeapYear(), GameCreationSettings::landscape, max(), ConstructionSettings::max_heightlevel, YearMonthDay::month, ORIGINAL_BASE_YEAR, 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 YearMonthDay::year.

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

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

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

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

  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 NULL instead of allocating a new engine. (Used for static Action 0x04).

Returns
  The requested engine.

Definition at line 594 of file newgrf.cpp.

References _engine_counts, _settings_game, SmallVector< T, S >::Append(), 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(), SmallVector< T, S >::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, EngineIDMapping::grfid, grfmsg(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_ENGINE, RailtypeInfo::label, SmallVector< T, S >::Length(), min(), ReallocT(), EngineIDMapping::type, VEH_TRAIN, and GameSettings::vehicle.

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

EngineID GetNewEngineID | ( | const GRFFile * | file,
|  | VehicleType | type,
|  | uint16 | 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 689 of file newgrf.cpp.

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

Referenced by GetNextArticulatedPart().

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

References _currency_specs, _settings_game, SmallVector< T, S >::Append(), GRFFile::cargo_list, LanguageMap::case_map, CIR_SUCCESS, CIR_UNKNOWN, GameSettings::construction, CURRENCY_END, GB(), LanguageMap::gender_map, LanguagePackHeader::GetCaseIndex(), LanguagePackHeader::GetGenderIndex(), GetGRFStringID(), GetLanguage(), GetNewgrfCurrencyIdConverted(), GrfProcessingState::grffile, grfmsg(), IsSnowLineSet(), GRFFile::language_map, LoadTranslationTable(), ConstructionSettings::max_heightlevel, MAX_LANG, MAX_NUM_CASES, MAX_NUM_GENDERS, LanguageMap::Mapping::newgrf_id, NFO_UTF8_IDENTIFIER, LanguageMap::Mapping::openttd_id, LanguageMap::plural_form, GRFFile::price_base_multipliers, GRFFile::railtype_list, SetSnowLine(), SNOW_LINE_DAYS, SNOW_LINE_MONTHS, CurrencySpec::symbol_pos, CurrencySpec::to_euro, and Utf8Decode().

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

  severity | debugging severity level, see debug.h
  str | message in printf() format

Definition at line 374 of file newgrf.cpp.

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

Referenced by AddGenericCallback(), AddGRFString(), AircraftVehicleChangeInfo(), AirportChangeInfo(), BridgeChangeInfo(), CanalChangeInfo(), CargoChangeInfo(), ChangeGRFBlitter(), ChangeGRFMinVersion(), ChangeGRFNumUsedParams(), ChangeGRFPalette(), ChangeGRFParamDefault(), ChangeGRFParamLimits(), ChangeGRFParamMask(), ChangeGRFParamType(), ChangeGRFParamValueNames(), ChangeGRFVersion(), ConvertTTDBasePrice(), CreateGroupFromGroupID(), DEFINE_NEWGRF_CLASS_METHOD(), DefineGotoLabel(), FeatureTownName(), UnmappedChoiceList::Flush(), GetNewEngine(), GlobalVarChangeInfo(), HandleNode(), HandleParameterInfo(), ImportGRFSound(), IndustriesChangeInfo(), IndustrytilesChangeInfo(), LoadFontGlyph(), LoadNewGRFFile(), LoadTranslationTable(), ObjectChangeInfo(), ParamSet(), RailTypeChangeInfo(), RailVehicleChangeInfo(), ReadSpriteLayout(), ReadSpriteLayoutRegisters(), ReadSpriteLayoutSprite(), RoadVehicleChangeInfo(), SanitizeSpriteOffset(), HouseOverrideManager::SetEntitySpec(), IndustryOverrideManager::SetEntitySpec(), ObjectOverrideManager::SetEntitySpec(), SetNewGRFOverride(), ShipVehicleChangeInfo(), SkipAct12(), SoundEffectChangeInfo(), StationChangeInfo(), TownHouseChangeInfo(), TranslateGRFStrings(), and TranslateTTDPatchCodes().

static void GRFUnsafe | ( | ByteReader * | buf | ) |
| static

Set the current NewGRF as unsafe for static use.

Parameters

  buf | Unused.

Note
  Used during safety scan on unsafe actions.

Definition at line 7788 of file newgrf.cpp.

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

static bool HandleNode | ( | byte | type,
|  | uint32 | 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 7724 of file newgrf.cpp.

References BSWAP32(), AllowedSubtags::call_handler, AllowedSubtags::data, grfmsg(), HandleNodes(), AllowedSubtags::id, SkipUnknownInfo(), AllowedSubtags::text, and AllowedSubtags::type.

Referenced by 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 7762 of file newgrf.cpp.

References HandleNode().

Referenced by HandleNode(), HandleParameterInfo(), and StaticGRFInfo().

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 7629 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().

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

References CIR_SUCCESS, and CIR_UNKNOWN.

Referenced by IndustriesChangeInfo().

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

References CIR_SUCCESS, and CIR_UNKNOWN.

Referenced by IndustrytilesChangeInfo().

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

References CIR_SUCCESS, and CIR_UNKNOWN.

Referenced by ObjectChangeInfo().

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

References CIR_SUCCESS, and CIR_UNKNOWN.

Referenced by TownHouseChangeInfo().

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

Process a sound import from another GRF file.

Parameters

  sound | Destination for sound.

Definition at line 7033 of file newgrf.cpp.

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

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

References _settings_game, IndustrySpec::accepts_cargo, OverrideManagerBase::Add(), AddStringForMapping(), IndustrySpec::appear_creation, IndustrySpec::appear_ingame, IndustrySpec::behaviour, IndustrySpec::callback_mask, CHECK_NOTHING, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, CLEAN_RANDOMSOUNDS, CLEAN_TILELAYOUT, CleanIndustryTileTable(), IndustrySpec::cleanup_flag, IndustrySpec::closure_text, IndustrySpec::conflicting, IndustrySpec::cost_multiplier, IndustrySpec::enabled, free(), GameSettings::game_creation, GB(), GetCargoTranslation(), OverrideManagerBase::GetID(), IndustrySpec::grf_prop, GrfProcessingState::grffile, grfmsg(), HasBit(), IgnoreIndustryProperty(), IndustrySpec::input_cargo_multiplier, INVALID_INDUSTRYTILE, GameCreationSettings::landscape, IndustrySpec::life_type, IndustrySpec::map_colour, IndustrySpec::minimal_cargo, IndustrySpec::name, IndustrySpec::new_industry_text, NEW_INDUSTRYOFFSET, NUM_INDUSTRYTYPES_PER_GRF, IndustrySpec::num_table, IndustrySpec::number_of_sounds, GRFFileProps::override, IndustrySpec::production_down_text, IndustrySpec::production_up_text, IndustrySpec::prospecting_chance, IndustrySpec::random_sounds, IndustrySpec::removal_cost_multiplier, SB(), SetBit(), IndustrySpec::station_name, IndustrySpec::table, ValidateIndustryLayout(), TileIndexDiffC::x, and TileIndexDiffC::y.

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

References IndustryTileSpec::acceptance, IndustryTileSpec::accepts_cargo, OverrideManagerBase::Add(), OverrideManagerBase::AddEntityID(), IndustryTileSpec::animation, IndustryTileSpec::callback_mask, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, AnimationInfo::frames, GB(), GetCargoTranslation(), GrfProcessingState::grffile, grfmsg(), IgnoreIndustryTileProperty(), INDUSTRYTILE_NOANIM, NEW_INDUSTRYTILEOFFSET, NUM_INDUSTRYTILES_PER_GRF, IndustryTileSpec::slopes_refused, IndustryTileSpec::special_flags, AnimationInfo::speed, AnimationInfo::status, and AnimationInfo::triggers.

void InitGRFTownGeneratorNames | ( |  | ) |

Allocate memory for the NewGRF town names.

Definition at line 76 of file settings_gui.cpp.

References _grf_names, _nb_grf_names, free(), and INVALID_STRING_ID.

Referenced by AfterLoadGRFs().

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

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

Referenced by LoadNewGRF().

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

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

References HouseSpec::building_availability, HouseSpec::building_flags, DEBUG, HouseSpec::enabled, HouseSpec::grf_prop, HZ_CLIMALL, HZ_ZONALL, GRFFilePropsBase< Tcnt >::local_id, and HouseSpec::population.

Referenced by FinaliseHouseArray().

template<VehicleType T>

static bool IsValidNewGRFImageIndex | ( | uint8 | image_index | ) |
| inline static

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

Parameters

  <T> | The type of vehicle.
  image_index | The image index to check.

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

Definition at line 201 of file newgrf.cpp.

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

References GrfProcessingState::file_index, SoundEntry::grf_container_ver, and GrfProcessingState::grf_container_ver.

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

Load all the NewGRFs.

Parameters

  load_index | The offset for the first sprite to add.
  file_index | The Fio index of the first NewGRF to load.

Definition at line 9208 of file newgrf.cpp.

References _cur_year, _date, _date_fract, _display_opt, _grfconfig, _networking, _settings_game, _tick_counter, AfterLoadGRFs(), BASESET_DIR, BSWAP32(), BuildCargoTranslationMap(), GrfProcessingState::ClearDataForNextFile(), ClearTemporaryNewGRFData(), ClrBit(), ConvertYMDToDate(), DEBUG, GRFConfig::filename, FioCheckFileExists(), GRFConfig::flags, GameSettings::game_creation, GCF_INIT_ONLY, GCF_RESERVED, GCS_ACTIVATED, GCS_DISABLED, GCS_INITIALISED, GCS_NOT_FOUND, GCS_UNKNOWN, GetFileByGRFID(), GrfProcessingState::grffile, GRFIdentifier::grfid, HasBit(), GRFConfig::ident, InitializeGRFSpecial(), InitNewGRFFile(), lengthof, LoadNewGRFFile(), NEWGRF_DIR, GRFConfig::next, ResetNewGRFData(), SetBit(), SetNewGRFOverride(), GrfProcessingState::spriteid, GrfProcessingState::stage, GameCreationSettings::starting_year, and GRFConfig::status.

Referenced by LoadSpriteTables().

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

Load a particular NewGRF.

Parameters

  config | The configuration of the to be loaded NewGRF.
  file_index | The Fio index of the first NewGRF to load.
  stage | The loading stage of the NewGRF.
  subdir | The sub directory to find the NewGRF in.

Definition at line 8843 of file newgrf.cpp.

References _palette_remap_grf, ReusableBuffer< T >::Allocate(), GrfProcessingState::ClearDataForNextFile(), DEBUG, DisableGrf(), GRFConfig::error, GrfProcessingState::file_index, GRFConfig::filename, FioOpenFile(), FioReadByte(), FioReadDword(), FioReadWord(), FioSkipBytes(), GRFConfig::flags, GCF_RESERVED, GCS_DISABLED, GCS_INITIALISED, GetFileByFilename(), GetGRFContainerVersion(), GrfProcessingState::grf_container_ver, GrfProcessingState::grfconfig, GrfProcessingState::grffile, grfmsg(), GRFP_USE_MASK, HasBit(), GRFConfig::IsOpenTTDBaseGRF(), LAST_GRF_SLOT, GrfProcessingState::nfo_line, GRFConfig::palette, ReadGRFSpriteOffsets(), GrfProcessingState::skip_sprites, SkipSpriteData(), GRFConfig::status, and usererror().

Referenced by FillGRFDetails(), and LoadNewGRF().

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

  | 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.
  [in,out] | translation_table | Storage location for the translation table.
  | name | Name of the table for debug output.

Returns
  ChangeInfoResult.

Definition at line 2554 of file newgrf.cpp.

References BSWAP32(), CIR_INVALID_ID, CIR_SUCCESS, and grfmsg().

Referenced by GlobalVarChangeInfo().

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

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

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

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

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 705 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().

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

References AddStringForMapping(), ObjectSpec::animation, BSWAP32(), ObjectSpec::build_cost_multiplier, ObjectSpec::callback_mask, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, ObjectSpec::clear_cost_multiplier, ObjectSpec::climate, ObjectSpec::cls_id, ObjectSpec::end_of_life_date, ObjectSpec::flags, AnimationInfo::frames, ObjectSpec::generate_amount, NewGRFClass< Tspec, Tid, Tmax >::Get(), GrfProcessingState::grffile, grfmsg(), GRFLoadedFeatures::has_2CC, ObjectSpec::height, IgnoreObjectProperty(), ObjectSpec::introduction_date, NewGRFClass< Tspec, Tid, Tmax >::name, ObjectSpec::name, NUM_OBJECTS_PER_GRF, OBJECT_FLAG_2CC_COLOUR, ObjectSpec::size, AnimationInfo::speed, AnimationInfo::status, AnimationInfo::triggers, and ObjectSpec::views.

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 4030 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, grfmsg(), 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.

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

References 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, GRFTempEngineData::ctt_exclude_mask, GRFTempEngineData::ctt_include_mask, GRFTempEngineData::defaultcargo_grf, EC_DIESEL, EC_ELECTRIC, EC_MAGLEV, EC_MONORAIL, EC_STEAM, EF_USES_2CC, RailVehicleInfo::engclass, GetCargoTranslation(), GetNewEngine(), GrfProcessingState::grffile, grfmsg(), GRFLoadedFeatures::has_2CC, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, SmallVector< T, S >::Length(), RailVehicleInfo::max_speed, EngineInfo::misc_flags, NUM_CARGO, RailVehicleInfo::pow_wag_power, RailVehicleInfo::pow_wag_weight, RailVehicleInfo::power, GRFTempEngineData::prop27_set, PROP_TRAIN_CARGO_AGE_PERIOD, PROP_TRAIN_CARGO_CAPACITY, PROP_TRAIN_COST_FACTOR, 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(), GRFTempEngineData::UpdateRefittability(), RailVehicleInfo::user_def_data, VE_DEFAULT, VE_DISABLE_EFFECT, VE_TYPE_COUNT, VE_TYPE_START, VEH_TRAIN, RailVehicleInfo::visual_effect, and RailVehicleInfo::weight.

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

  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 specifiy 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 847 of file newgrf.cpp.

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

Referenced by StationChangeInfo().

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 794 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().

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

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

References ClrBit(), DisableGrf(), GB(), GrfProcessingState::GetNumEnts(), GrfProcessingState::GetSprite(), grfmsg(), 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().

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

References RoadVehicleInfo::air_drag, AlterVehicleListOrder(), EngineInfo::base_intro, EngineInfo::callback_mask, EngineInfo::cargo_age_period, CIR_INVALID_ID, CIR_SUCCESS, CommonVehicleChangeInfo(), ConvertTTDBasePrice(), CT_INVALID, GRFTempEngineData::ctt_exclude_mask, GRFTempEngineData::ctt_include_mask, GRFTempEngineData::defaultcargo_grf, EF_USES_2CC, GetCargoTranslation(), GetNewEngine(), GetNewGRFSoundID(), GrfProcessingState::grffile, grfmsg(), GRFLoadedFeatures::has_2CC, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, RoadVehicleInfo::max_speed, EngineInfo::misc_flags, NUM_CARGO, 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, GRFTempEngineData::rv_max_speed, SB(), SetBit(), RoadVehicleInfo::shorten_factor, RoadVehicleInfo::tractive_effort, TranslateRefitMask(), GRFTempEngineData::UpdateRefittability(), VE_DEFAULT, VE_DISABLE_EFFECT, VE_TYPE_COUNT, VE_TYPE_START, VEH_ROAD, RoadVehicleInfo::visual_effect, and RoadVehicleInfo::weight.

static uint16 SanitizeSpriteOffset | ( | uint16 & | num,
|  | uint16 | offset,
|  | int | max_sprites,
|  | const char * | 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 5543 of file newgrf.cpp.

References grfmsg(), and max().

static void SetNewGRFOverride | ( | uint32 | source_grfid,
|  | uint32 | 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 580 of file newgrf.cpp.

References BSWAP32(), and grfmsg().

Referenced by LoadNewGRF().

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

References AlterVehicleListOrder(), EngineInfo::base_intro, EngineInfo::callback_mask, ShipVehicleInfo::canal_speed_frac, EngineInfo::cargo_age_period, CIR_INVALID_ID, CIR_SUCCESS, CommonVehicleChangeInfo(), CT_INVALID, GRFTempEngineData::ctt_exclude_mask, GRFTempEngineData::ctt_include_mask, GRFTempEngineData::defaultcargo_grf, EF_USES_2CC, GetCargoTranslation(), GetNewEngine(), GetNewGRFSoundID(), GrfProcessingState::grffile, grfmsg(), GRFLoadedFeatures::has_2CC, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, ShipVehicleInfo::max_speed, EngineInfo::misc_flags, NUM_CARGO, 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(), GRFTempEngineData::UpdateRefittability(), VE_DEFAULT, VE_DISABLE_EFFECT, VE_TYPE_COUNT, VE_TYPE_START, VEH_SHIP, and ShipVehicleInfo::visual_effect.

static bool SkipUnknownInfo | ( | ByteReader * | buf,
|  | byte | 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 7684 of file newgrf.cpp.

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

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

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

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

Handle Action 0x14.

Parameters

  buf | Buffer.

Definition at line 7777 of file newgrf.cpp.

References HandleNodes().

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

Define properties for stations.

Parameters

  stdid | 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 1848 of file newgrf.cpp.

References SmallVector< T, S >::Append(), SmallVector< T, S >::Begin(), StationSpec::blocked, BSWAP32(), StationSpec::callback_mask, StationSpec::cargo_threshold, StationSpec::cargo_triggers, CIR_DISABLED, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, SmallVector< T, S >::Clear(), NewGRFSpriteLayout::Clone(), NewGRFSpriteLayout::consistent_max_offset, DrawTileSeqStruct::delta_x, DrawTileSeqStruct::delta_z, StationSpec::disallowed_lengths, StationSpec::disallowed_platforms, StationSpec::flags, AnimationInfo::frames, free(), GrfProcessingState::grffile, grfmsg(), DrawTileSprites::ground, DrawTileSeqStruct::IsTerminator(), MemSetT(), NUM_STATIONS_PER_GRF, StationSpec::pylons, ReadSpriteLayout(), ReadSpriteLayoutSprite(), ReallocT(), StationSpec::renderdata, GrfProcessingState::skip_sprites, AnimationInfo::speed, AnimationInfo::status, StationSpec::tiles, TranslateRefitMask(), AnimationInfo::triggers, and StationSpec::wires.

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

References _settings_game, abs(), HouseSpec::accepts_cargo, OverrideManagerBase::Add(), AddStringForMapping(), HouseSpec::animation, HouseSpec::building_availability, HouseSpec::building_flags, HouseSpec::building_name, HouseSpec::callback_mask, HouseSpec::cargo_acceptance, CIR_INVALID_ID, CIR_SUCCESS, CIR_UNKNOWN, Clamp(), HouseSpec::class_id, CT_INVALID, HouseSpec::enabled, HouseSpec::extra_flags, AnimationInfo::frames, GameSettings::game_creation, GB(), CargoSpec::Get(), GetCargoTranslation(), GrfProcessingState::grffile, grfmsg(), GRFLoadedFeatures::has_newhouses, IgnoreTownHouseProperty(), CargoSpec::IsValid(), GameCreationSettings::landscape, HouseSpec::mail_generation, MAX_YEAR, HouseSpec::max_year, MemCpyT(), min(), HouseSpec::min_year, HouseSpec::minimum_life, NEW_HOUSE_OFFSET, NUM_HOUSES_PER_GRF, ORIGINAL_BASE_YEAR, HouseSpec::population, HouseSpec::probability, HouseSpec::processing_time, HouseSpec::random_colour, HouseSpec::removal_cost, HouseSpec::remove_rating_decrease, SB(), SetBit(), AnimationInfo::speed, AnimationInfo::status, and HouseSpec::watched_cargoes.

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

References DEBUG, and IsInsideMM().

Referenced by MapGRFStringID().

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

Validate the industry layout; e.g.

to prevent duplicate tiles.

Parameters

  layout | The layout to check.
  size | The size of the layout.

Returns
  True if the layout is deemed valid.

Definition at line 3297 of file newgrf.cpp.

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

Referenced by IndustriesChangeInfo().

## Variable Documentation

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" },
}

The information about action 5 types.

Definition at line 5580 of file newgrf.cpp.

const CargoLabel* const _default_refitmasks[]
| static

Initial value:
{
_default_refitmasks_rail,
_default_refitmasks_road,
_default_refitmasks_ships,
_default_refitmasks_aircraft,
}

Definition at line 8266 of file newgrf.cpp.

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

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

const CargoLabel _default_refitmasks_road[]
| static

Initial value:
{
0 }

Definition at line 8251 of file newgrf.cpp.

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

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

Signature of a container version 2 GRF.

Referenced by GRFGetSizeOfDataSection().

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

Referenced by ParamSet(), and ResetNewGRFData().

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()
}

Action14 tags for the INFO node.

Definition at line 7658 of file newgrf.cpp.

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()
}

Action14 parameter tags.

Definition at line 7612 of file newgrf.cpp.

AllowedSubtags _tags_root[]

Initial value:
{
AllowedSubtags('INFO', _tags_info),
AllowedSubtags()
}

Action14 root tags.

Definition at line 7672 of file newgrf.cpp.

uint32 _ttdpatch_flags[8]
| static

32 * 8 = 256 flags.

Apparently TTDPatch uses this many..

Definition at line 73 of file newgrf.cpp.

Referenced by InitializeGRFSpecial().