30static uint16_t
SanitizeSpriteOffset(uint16_t &num, uint16_t offset,
int max_sprites, std::string_view name)
33 if (offset >= max_sprites) {
34 GrfMsg(1,
"GraphicsNew: {} sprite offset must be less than {}, skipping", name, max_sprites);
40 if (offset + num > max_sprites) {
41 GrfMsg(4,
"GraphicsNew: {} sprite overflow, truncating...", name);
43 num = std::max(max_sprites - offset, 0);
44 return orig_num - num;
110 GrfMsg(2,
"GraphicsNew: Loading 10 missing shore sprites from extra grf.");
127 GrfMsg(2,
"GraphicsNew: Custom graphics (type 0x{:02X}) sprite block of length {} (unimplemented, ignoring)", type, num);
128 _cur_gps.skip_sprites = num;
138 GrfMsg(1,
"GraphicsNew: {} (type 0x{:02X}) do not allow an <offset> field. Ignoring offset.", action5_type->
name, type);
145 GrfMsg(1,
"GraphicsNew: {} (type 0x{:02X}) count must be at least {}. Only {} were specified. Skipping.", action5_type->
name, type, action5_type->
min_sprites, num);
146 _cur_gps.skip_sprites = num;
155 GrfMsg(2,
"GraphicsNew: Replacing sprites {} to {} of {} (type 0x{:02X}) at SpriteID 0x{:04X}", offset, offset + num - 1, action5_type->
name, type, replace);
169 for (; num > 0; num--) {
171 SpriteID load_index = (replace == 0 ? _cur_gps.spriteid++ : replace++);
173 if (dup_oneway_sprites) {
179 _cur_gps.skip_sprites = skip_num;
191 GrfMsg(3,
"SkipAct5: Skipping {} sprites", _cur_gps.skip_sprites);
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
Class to read from a NewGRF file.
uint16_t ReadExtendedByte()
Read a single Extended Byte (8 or 16 bits).
uint8_t ReadByte()
Read a single byte (8 bits).
Functions related to debugging.
Types related to the graphics and/or input devices.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
GRFLoadedFeatures _loaded_newgrf_features
Indicates which are the newgrf features currently loaded ingame.
@ None
No shore sprites were replaced.
@ Action5
Shore sprites were replaced by Action5.
@ OnlyNew
Only corner-shores were loaded by Action5 (openttd(w/d).grf only).
@ WithTrack
Electrified depot graphics with tram track were loaded.
@ WithoutTrack
Electrified depot graphics without tram track were loaded.
std::span< const Action5Type > GetAction5Types()
Get list of all action 5 types.
static constexpr auto _action5_types
The information about action 5 types.
static uint16_t SanitizeSpriteOffset(uint16_t &num, uint16_t offset, int max_sprites, std::string_view name)
Sanitize incoming sprite offsets for Action 5 graphics replacements.
Information about NewGRF Action 5.
@ AllowOffset
Allow replacing any subset by specifying an offset.
@ Fixed
Only allow replacing a whole block of sprites. (TTDP compatible).
@ Invalid
unknown/not-implemented type
NewGRF buffer reader definition.
@ System
GRF file is an openttd-internal system grf.
NewGRF internal processing state.
A number of safeguards to prevent using unsafe methods.
bool LoadNextSprite(SpriteID load_index, SpriteFile &file, uint file_sprite_id)
Load a real or recolour sprite.
Functions to cache sprites in memory.
This file contains all sprite-related enums and defines.
static const uint16_t ROAD_WAYPOINTS_SPRITE_COUNT
static constexpr SpriteID SPR_BRIDGE_DECKS_BASE
static const uint16_t RAILTYPE_TUNNEL_BASE_COUNT
static constexpr uint16_t OVERLAY_ROCKS_SPRITE_COUNT
Rock overlays: plain, snow 1, snow 2, snow 3 and full snow.
static constexpr SpriteID SPR_OVERLAY_ROCKS_BASE
static const SpriteID SPR_AQUEDUCT_BASE
static const uint16_t TRAMWAY_SPRITE_COUNT
static const SpriteID SPR_ROADSTOP_BASE
static const uint16_t PALETTE_SPRITE_COUNT
static const SpriteID SPR_TRAMWAY_DEPOT_WITH_TRACK
static const SpriteID SPR_OPENTTD_BASE
static const uint16_t SHORE_SPRITE_COUNT
static const SpriteID SPR_PALETTE_BASE
static const uint16_t AIRPORT_PREVIEW_SPRITE_COUNT
static constexpr uint16_t BRIDGE_DECKS_SPRITE_COUNT
Bridge deck sprites: 6 directions * (3 track types + 1 road type).
static const SpriteID SPR_AIRPORTX_BASE
static const uint16_t ONEWAY_SLOPE_N_OFFSET
static const SpriteID SPR_TRACKS_FOR_SLOPES_BASE
static const uint16_t OPENTTD_SPRITE_COUNT
static const SpriteID SPR_ROAD_WAYPOINTS_BASE
static const SpriteID SPR_TRAMWAY_DEPOT_NO_TRACK
static const uint16_t ONEWAY_SPRITE_COUNT
static const uint16_t ROADSTOP_SPRITE_COUNT
static const SpriteID SPR_RAILTYPE_TUNNEL_BASE
static const SpriteID SPR_TRAMWAY_BASE
static const uint16_t ONEWAY_SLOPE_S_OFFSET
static const SpriteID SPR_AIRPORT_PREVIEW_BASE
static const uint16_t TRACKS_FOR_SLOPES_SPRITE_COUNT
static const uint16_t AQUEDUCT_SPRITE_COUNT
static const uint16_t AIRPORTX_SPRITE_COUNT
static const SpriteID SPR_ONEWAY_BASE
static const SpriteID SPR_SHORE_BASE
Definition of base types and functions in a cross-platform compatible way.
Information about a single action 5 type.
Action5BlockType block_type
How is this Action5 type processed?
uint16_t max_sprites
If the Action5 contains more sprites, only the first max_sprites sprites will be used.
uint16_t min_sprites
If the Action5 contains less sprites, the whole block will be ignored.
SpriteID sprite_base
Load the sprites starting from this sprite.
const std::string_view name
Name for error messages.
static void FileScan(ByteReader &buf)
Implementation of the GrfLoadingStage::FileScan stage of this action.
static void SafetyScan(ByteReader &buf)
Implementation of the GrfLoadingStage::SafetyScan stage of this action.
static void Reserve(ByteReader &buf)
Implementation of the GrfLoadingStage::Reserve stage of this action.
static void Activation(ByteReader &buf)
Implementation of the GrfLoadingStage::Activation stage of this action.
static void Init(ByteReader &buf)
Implementation of the GrfLoadingStage::Init stage of this action.
static void LabelScan(ByteReader &buf)
Implementation of the GrfLoadingStage::LabelScan stage of this action.