OpenTTD Source
20241108-master-g80f628063a
|
Base for the NewGRF implementation. More...
#include "cargotype.h"
#include "rail_type.h"
#include "road_type.h"
#include "fileio_type.h"
#include "newgrf_text_type.h"
#include "core/bitmath_func.hpp"
#include "core/alloc_type.hpp"
#include "core/mem_func.hpp"
Go to the source code of this file.
Data Structures | |
struct | CanalProperties |
Canal properties local to the NewGRF. More... | |
struct | GRFLabel |
struct | GRFFile |
Dynamic data of a loaded NewGRF. More... | |
struct | GRFLoadedFeatures |
Macros | |
#define | GrfMsg(severity, format_string, ...) do { if ((severity) == 0 || _debug_grf_level >= (severity)) GrfMsgI(severity, fmt::format(FMT_STRING(format_string) __VA_OPT__(,) __VA_ARGS__)); } while (false) |
Enumerations | |
enum | CanalFeature { CF_WATERSLOPE , CF_LOCKS , CF_DIKES , CF_ICON , CF_DOCKS , CF_RIVER_SLOPE , CF_RIVER_EDGE , CF_RIVER_GUI , CF_BUOY , CF_END } |
List of different canal 'features'. More... | |
enum | GrfLoadingStage { GLS_FILESCAN , GLS_SAFETYSCAN , GLS_LABELSCAN , GLS_INIT , GLS_RESERVE , GLS_ACTIVATION , GLS_END } |
enum | GrfMiscBit { GMB_DESERT_TREES_FIELDS = 0 , GMB_DESERT_PAVED_ROADS = 1 , GMB_FIELD_BOUNDING_BOX = 2 , GMB_TRAIN_WIDTH_32_PIXELS = 3 , GMB_AMBIENT_SOUND_CALLBACK = 4 , GMB_CATENARY_ON_3RD_TRACK = 5 , GMB_SECOND_ROCKY_TILE_SET = 6 } |
enum | GrfSpecFeature { GSF_TRAINS , GSF_ROADVEHICLES , GSF_SHIPS , GSF_AIRCRAFT , GSF_STATIONS , GSF_CANALS , GSF_BRIDGES , GSF_HOUSES , GSF_GLOBALVAR , GSF_INDUSTRYTILES , GSF_INDUSTRIES , GSF_CARGOES , GSF_SOUNDFX , GSF_AIRPORTS , GSF_SIGNALS , GSF_OBJECTS , GSF_RAILTYPES , GSF_AIRPORTTILES , GSF_ROADTYPES , GSF_TRAMTYPES , GSF_ROADSTOPS , GSF_END , GSF_FAKE_TOWNS = GSF_END , GSF_FAKE_END , GSF_INVALID = 0xFF } |
enum | ShoreReplacement { SHORE_REPLACE_NONE , SHORE_REPLACE_ACTION_5 , SHORE_REPLACE_ACTION_A , SHORE_REPLACE_ONLY_NEW } |
enum | TramReplacement { TRAMWAY_REPLACE_DEPOT_NONE , TRAMWAY_REPLACE_DEPOT_WITH_TRACK , TRAMWAY_REPLACE_DEPOT_NO_TRACK } |
Functions | |
bool | HasGrfMiscBit (GrfMiscBit bit) |
Check for grf miscellaneous bits. More... | |
void | LoadNewGRFFile (struct GRFConfig *config, GrfLoadingStage stage, Subdirectory subdir, bool temporary) |
Load a particular NewGRF. More... | |
void | LoadNewGRF (SpriteID load_index, uint num_baseset) |
Load all the NewGRFs. More... | |
void | ReloadNewGRFData () |
Reload all NewGRF files during a running game. More... | |
void | ResetNewGRFData () |
Reset all NewGRF loaded data. | |
void | ResetPersistentNewGRFData () |
Reset NewGRF data which is stored persistently in savegames. | |
void | GrfMsgI (int severity, const std::string &msg) |
Debug() function dedicated to newGRF debugging messages Function is essentially the same as Debug(grf, severity, ...) with the addition of file:line information when parsing grf files. More... | |
bool | GetGlobalVariable (uint8_t param, uint32_t *value, const GRFFile *grffile) |
Reads a variable common to VarAction2 and Action7/9/D. More... | |
StringID | MapGRFStringID (uint32_t grfid, StringID str) |
Used when setting an object's property to map to the GRF's strings while taking in consideration the "drift" between TTDPatch string system and OpenTTD's one. More... | |
void | ShowNewGRFError () |
Show the first NewGRF error we can find. | |
Variables | |
static const uint32_t | INVALID_GRFID = 0xFFFFFFFF |
GRFLoadedFeatures | _loaded_newgrf_features |
Indicates which are the newgrf features currently loaded ingame. | |
Base for the NewGRF implementation.
Definition in file newgrf.h.
enum CanalFeature |
enum GrfMiscBit |
Enumerator | |
---|---|
GMB_TRAIN_WIDTH_32_PIXELS | Use 32 pixels per train vehicle in depot gui and vehicle details. Never set in the global variable;.
|
enum GrfSpecFeature |
enum ShoreReplacement |
enum TramReplacement |
bool GetGlobalVariable | ( | uint8_t | param, |
uint32_t * | value, | ||
const GRFFile * | grffile | ||
) |
Reads a variable common to VarAction2 and Action7/9/D.
Returns VarAction2 variable 'param' resp. Action7/9/D variable '0x80 + param'. If a variable is not accessible from all four actions, it is handled in the action specific functions.
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 |
Definition at line 6506 of file newgrf.cpp.
References _settings_game, Clamp(), TimerGameCalendar::ConvertDateToYMD(), TimerGameCalendar::ConvertYMDToDate(), TimerGameTick::counter, TimerGameCalendar::date, TimerGameCalendar::date_fract, TimerGameConst< struct Calendar >::DAYS_TILL_ORIGINAL_BASE_YEAR, GameSettings::game_creation, GB(), TimerGame< struct Calendar >::IsLeapYear(), GameCreationSettings::landscape, TimerGameConst< struct Calendar >::ORIGINAL_BASE_YEAR, TimerGameConst< struct Calendar >::ORIGINAL_MAX_YEAR, VehicleSettings::road_side, GameSettings::vehicle, and TimerGameCalendar::year.
void GrfMsgI | ( | int | severity, |
const std::string & | msg | ||
) |
Debug() function dedicated to newGRF debugging messages Function is essentially the same as Debug(grf, severity, ...) with the addition of file:line information when parsing grf files.
NOTE: for the above reason(s) GrfMsg() should ONLY be used for loading/parsing grf files, not for runtime debug messages as there is no file information available during that time.
severity | debugging severity level, see debug.h |
msg | the message |
Definition at line 389 of file newgrf.cpp.
References Debug.
|
inline |
Check for grf miscellaneous bits.
bit | The bit to check. |
Definition at line 189 of file newgrf.h.
References _misc_grf_features, and HasBit().
Referenced by AmbientSoundEffect().
void LoadNewGRF | ( | SpriteID | load_index, |
uint | num_baseset | ||
) |
Load all the NewGRFs.
load_index | The offset for the first sprite to add. |
num_baseset | Number of NewGRFs at the front of the list to look up in the baseset dir instead of the newgrf dir. |
Definition at line 10017 of file newgrf.cpp.
References _display_opt, _grfconfig, _networking, _settings_game, TimerGameCalendar::ConvertYMDToDate(), TimerGameEconomy::ConvertYMDToDate(), TimerGameTick::counter, TimerGameCalendar::date, TimerGameEconomy::date, TimerGameCalendar::date_fract, TimerGameEconomy::date_fract, GameSettings::game_creation, GCS_NOT_FOUND, GCS_UNKNOWN, InitializeGRFSpecial(), GRFConfig::next, ResetNewGRFData(), GameCreationSettings::starting_year, GRFConfig::status, TimerGameCalendar::year, and TimerGameEconomy::year.
void LoadNewGRFFile | ( | GRFConfig * | config, |
GrfLoadingStage | stage, | ||
Subdirectory | subdir, | ||
bool | temporary | ||
) |
Load a particular NewGRF.
config | The configuration of the to be loaded NewGRF. |
stage | The loading stage of the NewGRF. |
subdir | The sub directory to find the NewGRF in. |
temporary | The NewGRF/sprite file is to be loaded temporarily and should be closed immediately, contrary to loading the SpriteFile and having it cached by the SpriteCache. |
Definition at line 9694 of file newgrf.cpp.
References GRFConfig::filename.
Referenced by FillGRFDetails().
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.
grfid | Id of the grf file. |
str | StringID that we want to have the equivalent in OoenTTD. |
Definition at line 559 of file newgrf.cpp.
References GetGRFStringID(), IsInsideMM(), and TTDPStringIDToOTTDStringIDMapping().
Referenced by AfterLoadGRFs().
void ReloadNewGRFData | ( | ) |
Reload all NewGRF files during a running game.
This is a cut-down version of AfterLoadGame(). XXX - We need to reset the vehicle position hash because with a non-empty hash AfterLoadVehicles() will loop infinitely. We need AfterLoadVehicles() to recalculate vehicle data as some NewGRF vehicle sets could have been removed or added and changed statistics
Definition at line 3364 of file afterload.cpp.
References GfxLoadSprites(), LoadStringWidthTable(), and RecomputePrices().
Referenced by ClickChangeMaxHlCheat(), and NewGRFConfirmationCallback().