OpenTTD Source 20250331-master-g3c15e0c889
|
NewGRF internal processing state. More...
#include "../newgrf.h"
#include "../newgrf_commons.h"
#include "../newgrf_config.h"
#include "../spriteloader/sprite_file_type.hpp"
#include "newgrf_bytereader.h"
Go to the source code of this file.
Data Structures | |
struct | GrfChangeInfoHandler< TFeature > |
GRF feature handler. More... | |
struct | GrfActionHandler< TAction > |
GRF action handler. More... | |
struct | GrfProcessingState |
Temporary data during loading of GRFs. More... | |
struct | GrfProcessingState::SpriteSet |
Definition of a single Action1 spriteset. More... | |
struct | GRFLocation |
Typedefs | |
using | GRFLineToSpriteOverride = std::map< GRFLocation, std::vector< uint8_t > > |
Enumerations | |
enum | ChangeInfoResult : uint8_t { CIR_SUCCESS , CIR_DISABLED , CIR_UNHANDLED , CIR_UNKNOWN , CIR_INVALID_ID } |
Possible return values for the GrfChangeInfoHandler functions. More... | |
Functions | |
void | SetNewGRFOverride (uint32_t source_grfid, uint32_t target_grfid) |
Set the override for a NewGRF. | |
GRFFile * | GetCurrentGRFOverride () |
Get overridden GRF for current GRF if present. | |
std::span< const CargoLabel > | GetCargoTranslationTable (const GRFFile &grffile) |
Get the cargo translation table to use for the given GRF file. | |
CargoTypes | TranslateRefitMask (uint32_t refit_mask) |
Translate the refit mask. | |
void | SkipBadgeList (ByteReader &buf) |
Skip a list of badges. | |
std::vector< BadgeID > | ReadBadgeList (ByteReader &buf, GrfSpecFeature feature) |
Read a list of badges. | |
void | MapSpriteMappingRecolour (PalSpriteID *grf_sprite) |
Map the colour modifiers of TTDPatch to those that Open is using. | |
TileLayoutFlags | ReadSpriteLayoutSprite (ByteReader &buf, bool read_flags, bool invert_action1_flag, bool use_cur_spritesets, int feature, PalSpriteID *grf_sprite, uint16_t *max_sprite_offset=nullptr, uint16_t *max_palette_offset=nullptr) |
Read a sprite and a palette from the GRF and convert them into a format suitable to OpenTTD. | |
bool | ReadSpriteLayout (ByteReader &buf, uint num_building_sprites, bool use_cur_spritesets, uint8_t feature, bool allow_var10, bool no_z_position, NewGRFSpriteLayout *dts) |
Read a spritelayout from the GRF. | |
GRFFile * | GetFileByGRFID (uint32_t grfid) |
Obtain a NewGRF file by its grfID. | |
GRFError * | DisableGrf (StringID message={}, GRFConfig *config=nullptr) |
Disable a GRF. | |
void | DisableStaticNewGRFInfluencingNonStaticNewGRFs (GRFConfig &c) |
Disable a static NewGRF when it is influencing another (non-static) NewGRF as this could cause desyncs. | |
bool | HandleChangeInfoResult (const char *caller, ChangeInfoResult cir, uint8_t feature, uint8_t property) |
uint32_t | GetParamVal (uint8_t param, uint32_t *cond_val) |
void | GRFUnsafe (ByteReader &) |
Set the current NewGRF as unsafe for static use. | |
void | InitializePatchFlags () |
Initialize the TTDPatch flags. | |
Variables | |
static constexpr uint | MAX_SPRITEGROUP = UINT8_MAX |
Maximum GRF-local ID for a spritegroup. | |
GrfProcessingState | _cur |
std::map< GRFLocation, std::pair< SpriteID, uint16_t > > | _grm_sprites |
GRFLineToSpriteOverride | _grf_line_to_action6_sprite_override |
GrfMiscBits | _misc_grf_features |
Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E. | |
NewGRF internal processing state.
Definition in file newgrf_internal.h.
using GRFLineToSpriteOverride = std::map<GRFLocation, std::vector<uint8_t> > |
Definition at line 177 of file newgrf_internal.h.
enum ChangeInfoResult : uint8_t |
Possible return values for the GrfChangeInfoHandler functions.
Definition at line 20 of file newgrf_internal.h.
Disable a GRF.
message | Error message or STR_NULL. |
config | GRFConfig to disable, nullptr for current. |
Definition at line 131 of file newgrf.cpp.
References ClearTemporaryNewGRFData(), GRFConfig::error, GCS_DISABLED, GetFileByGRFID(), GrfProcessingState::grfconfig, GrfProcessingState::grffile, GRFIdentifier::grfid, GRFConfig::ident, GrfProcessingState::nfo_line, GrfProcessingState::skip_sprites, and GRFConfig::status.
Referenced by DisableStaticNewGRFInfluencingNonStaticNewGRFs(), FeatureTownName(), IndustriesChangeInfo(), IndustrytilesChangeInfo(), LoadNewGRFFileFromFile(), ParamSet(), ReadSpriteLayout(), ReadSpriteLayoutRegisters(), ReadSpriteLayoutSprite(), TownHouseChangeInfo(), and TranslateGRFStrings().
void DisableStaticNewGRFInfluencingNonStaticNewGRFs | ( | GRFConfig & | c | ) |
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.
c | The NewGRF to disable. |
Definition at line 161 of file newgrf.cpp.
References GRFError::data, DisableGrf(), GRFConfig::GetName(), and GrfProcessingState::grfconfig.
Referenced by ParamSet().
std::span< const CargoLabel > GetCargoTranslationTable | ( | const GRFFile & | grffile | ) |
Get the cargo translation table to use for the given GRF file.
grffile | GRF file. |
Definition at line 508 of file newgrf.cpp.
References GRFFile::cargo_list, GetClimateDependentCargoTranslationTable(), and GetClimateIndependentCargoTranslationTable().
Referenced by BuildCargoTranslationMap().
GRFFile * GetCurrentGRFOverride | ( | ) |
Get overridden GRF for current GRF if present.
Definition at line 189 of file newgrf.cpp.
References GetFileByGRFID(), and GrfProcessingState::grffile.
Referenced by LoadTranslationTable().
GRFFile * GetFileByGRFID | ( | uint32_t | grfid | ) |
Obtain a NewGRF file by its grfID.
grfid | The grfID to obtain the file for |
Definition at line 98 of file newgrf.cpp.
References _grf_files.
Referenced by DisableGrf(), FinalisePriceBaseMultipliers(), GetCurrentGRFOverride(), LanguageMap::GetLanguageMap(), GetNewEngine(), ImportGRFSound(), LoadNewGRF(), and ParamSet().
uint32_t GetParamVal | ( | uint8_t | param, |
uint32_t * | cond_val | ||
) |
Definition at line 116 of file newgrf_act7_9.cpp.
void GRFUnsafe | ( | ByteReader & | ) |
Set the current NewGRF as unsafe for static use.
Definition at line 365 of file newgrf.cpp.
References GRFConfig::flags, GrfProcessingState::grfconfig, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), GrfProcessingState::skip_sprites, and Unsafe.
bool HandleChangeInfoResult | ( | const char * | caller, |
ChangeInfoResult | cir, | ||
uint8_t | feature, | ||
uint8_t | property | ||
) |
Definition at line 112 of file newgrf_act0.cpp.
void InitializePatchFlags | ( | ) |
Initialize the TTDPatch flags.
Definition at line 28 of file newgrf_act7_9.cpp.
References _generating_world, _settings_game, _ttdpatch_flags, EconomySettings::allow_town_roads, ConstructionSettings::build_on_slopes, GameSettings::construction, VehicleSettings::disable_elrails, VehicleSettings::dynamic_engines, GameSettings::economy, VehicleSettings::freight_trains, OrderSettings::gradual_loading, OrderSettings::improved_load, EconomySettings::inflation, ConstructionSettings::max_bridge_length, StationSettings::never_expire_airports, VehicleSettings::never_expire_vehicles, GameSettings::order, GameSettings::station, EconomySettings::station_noise_level, ConstructionSettings::train_signal_side, GameSettings::vehicle, and VehicleSettings::wagon_speed_limits.
Referenced by LoadNewGRF().
void MapSpriteMappingRecolour | ( | PalSpriteID * | grf_sprite | ) |
Map the colour modifiers of TTDPatch to those that Open is using.
grf_sprite | Pointer to the structure been modified. |
Definition at line 29 of file newgrf_act2.cpp.
References ClrBit(), HasBit(), PalSpriteID::pal, PALETTE_MODIFIER_COLOUR, PALETTE_MODIFIER_TRANSPARENT, SetBit(), PalSpriteID::sprite, and SPRITE_MODIFIER_OPAQUE.
Referenced by ReadSpriteLayoutSprite().
std::vector< BadgeID > ReadBadgeList | ( | ByteReader & | buf, |
GrfSpecFeature | feature | ||
) |
Read a list of badges.
buf | Buffer reader containing list of badges to read. |
feature | The feature of the badge list. |
Definition at line 86 of file newgrf_act0.cpp.
References GRFFile::badge_list, GrfProcessingState::grffile, MarkBadgeSeen(), and ByteReader::ReadWord().
Referenced by AircraftVehicleChangeInfo(), AirportChangeInfo(), IndustriesChangeInfo(), IndustrytilesChangeInfo(), ObjectChangeInfo(), RailTypeChangeInfo(), RailVehicleChangeInfo(), RoadTypeChangeInfo(), RoadVehicleChangeInfo(), ShipVehicleChangeInfo(), StationChangeInfo(), and TownHouseChangeInfo().
bool ReadSpriteLayout | ( | ByteReader & | buf, |
uint | num_building_sprites, | ||
bool | use_cur_spritesets, | ||
uint8_t | feature, | ||
bool | allow_var10, | ||
bool | no_z_position, | ||
NewGRFSpriteLayout * | dts | ||
) |
Read a spritelayout from the GRF.
buf | Input |
num_building_sprites | Number of building sprites to read |
use_cur_spritesets | Whether to use currently referenceable action 1 sets. |
feature | GrfSpecFeature to use spritesets from. |
allow_var10 | Whether the spritelayout may specify var10 values for resolving multiple action-1-2-3 chains |
no_z_position | Whether bounding boxes have no Z offset |
dts | Layout container to output into |
Definition at line 171 of file newgrf_act2.cpp.
References NewGRFSpriteLayout::Allocate(), NewGRFSpriteLayout::AllocateRegisters(), ClrBit(), NewGRFSpriteLayout::consistent_max_offset, DrawTileSeqStruct::delta_z, DisableGrf(), DrawTileSprites::ground, HasBit(), DrawTileSeqStruct::IsParentSprite(), TileLayoutRegisters::max_palette_offset, TileLayoutRegisters::max_sprite_offset, ByteReader::ReadByte(), ReadSpriteLayoutRegisters(), ReadSpriteLayoutSprite(), GrfProcessingState::skip_sprites, TLF_KNOWN_FLAGS, and TLF_NON_GROUND_FLAGS.
Referenced by StationChangeInfo().
TileLayoutFlags ReadSpriteLayoutSprite | ( | ByteReader & | buf, |
bool | read_flags, | ||
bool | invert_action1_flag, | ||
bool | use_cur_spritesets, | ||
int | feature, | ||
PalSpriteID * | grf_sprite, | ||
uint16_t * | max_sprite_offset, | ||
uint16_t * | max_palette_offset | ||
) |
Read a sprite and a palette from the GRF and convert them into a format suitable to OpenTTD.
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) |
Definition at line 60 of file newgrf_act2.cpp.
References ClrBit(), DisableGrf(), GB(), GrfProcessingState::GetNumEnts(), GrfProcessingState::GetSprite(), HasBit(), GrfProcessingState::IsValidSpriteSet(), MapSpriteMappingRecolour(), PalSpriteID::pal, ByteReader::ReadWord(), 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().
void SetNewGRFOverride | ( | uint32_t | source_grfid, |
uint32_t | target_grfid | ||
) |
Set the override for a NewGRF.
source_grfid | The grfID which wants to override another NewGRF. |
target_grfid | The grfID which is being overridden. |
Definition at line 174 of file newgrf.cpp.
Referenced by LoadNewGRF().
void SkipBadgeList | ( | ByteReader & | buf | ) |
Skip a list of badges.
buf | Buffer reader containing list of badges to skip. |
Definition at line 72 of file newgrf_act0.cpp.
References ByteReader::ReadWord().
Referenced by IgnoreIndustryProperty(), IgnoreObjectProperty(), and IgnoreRoadStopProperty().
CargoTypes TranslateRefitMask | ( | uint32_t | refit_mask | ) |
Translate the refit mask.
refit_mask is uint32_t as it has not been mapped to CargoTypes.
Definition at line 307 of file newgrf.cpp.
References GetCargoTranslation(), GrfProcessingState::grffile, IsValidCargoType(), and SetBit().
Referenced by AircraftVehicleChangeInfo(), RailVehicleChangeInfo(), RoadVehicleChangeInfo(), ShipVehicleChangeInfo(), and StationChangeInfo().
|
extern |
Definition at line 74 of file newgrf.cpp.
|
extern |
Definition at line 18 of file newgrf_act6.cpp.
|
extern |
Definition at line 17 of file newgrf_act6.cpp.
|
extern |
Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E.
Definition at line 69 of file newgrf.cpp.
Referenced by GetGlobalVariable(), HasGrfMiscBit(), ParamSet(), and ResetNewGRFData().
|
staticconstexpr |
Maximum GRF-local ID for a spritegroup.
Definition at line 46 of file newgrf_internal.h.