|
OpenTTD Source 20251117-master-g7398d2e290
|
NewGRF Action 0x02 handler. More...
#include "../stdafx.h"#include <ranges>#include "../debug.h"#include "../newgrf_engine.h"#include "../newgrf_cargo.h"#include "../error.h"#include "../vehicle_base.h"#include "../road.h"#include "newgrf_bytereader.h"#include "newgrf_internal.h"#include "table/strings.h"#include "../safeguards.h"Go to the source code of this file.
Typedefs | |
| using | CachedCallback = std::pair< uint16_t, SpriteGroupID > |
Functions | |
| 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, GrfSpecFeature 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. | |
| static void | ReadSpriteLayoutRegisters (ByteReader &buf, TileLayoutFlags flags, bool is_parent, NewGRFSpriteLayout *dts, uint index) |
| Preprocess the TileLayoutFlags and read register modifiers from the GRF. | |
| bool | ReadSpriteLayout (ByteReader &buf, uint num_building_sprites, bool use_cur_spritesets, GrfSpecFeature feature, bool allow_var10, bool no_z_position, NewGRFSpriteLayout *dts) |
| Read a spritelayout from the GRF. | |
| void | ResetCallbacks (bool final) |
| static const SpriteGroup * | GetCallbackResultGroup (uint16_t value) |
| static const SpriteGroup * | GetGroupFromGroupID (uint8_t setid, uint8_t type, uint16_t groupid) |
| static const SpriteGroup * | CreateGroupFromGroupID (GrfSpecFeature feature, uint8_t setid, uint8_t type, uint16_t spriteid) |
| Helper function to either create a callback or a result sprite group. | |
| static void | NewSpriteGroup (ByteReader &buf) |
Variables | |
| constexpr uint16_t | GROUPID_CALLBACK_FAILED = 0x7FFF |
| Explicit "failure" result. | |
| constexpr uint16_t | GROUPID_CALCULATED_RESULT = 0x7FFE |
| Return calculated result from VarAction2. | |
| static std::vector< CachedCallback > | _cached_callback_groups |
| Sorted list of cached callback result spritegroups. | |
NewGRF Action 0x02 handler.
Definition in file newgrf_act2.cpp.
| using CachedCallback = std::pair<uint16_t, SpriteGroupID> |
Definition at line 264 of file newgrf_act2.cpp.
|
static |
Helper function to either create a callback or a result sprite group.
| 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. |
Definition at line 317 of file newgrf_act2.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_spritegroup_pool >::CanAllocateItem(), GrfProcessingState::GetNumEnts(), GrfProcessingState::GetSprite(), HasBit(), GrfProcessingState::IsValidSpriteSet(), and GrfProcessingState::spriteid.
|
static |
Definition at line 273 of file newgrf_act2.cpp.
|
static |
Definition at line 296 of file newgrf_act2.cpp.
| 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 32 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().
|
static |
Definition at line 337 of file newgrf_act2.cpp.
| bool ReadSpriteLayout | ( | ByteReader & | buf, |
| uint | num_building_sprites, | ||
| bool | use_cur_spritesets, | ||
| GrfSpecFeature | 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 174 of file newgrf_act2.cpp.
References NewGRFSpriteLayout::Allocate(), NewGRFSpriteLayout::AllocateRegisters(), ClrBit(), NewGRFSpriteLayout::consistent_max_offset, DisableGrf(), SpriteBounds::extent, DrawTileSprites::ground, HasBit(), DrawTileSeqStruct::IsParentSprite(), TileLayoutRegisters::max_palette_offset, TileLayoutRegisters::max_sprite_offset, SpriteBounds::origin, ByteReader::ReadByte(), ReadSpriteLayoutRegisters(), ReadSpriteLayoutSprite(), GrfProcessingState::skip_sprites, TLF_KNOWN_FLAGS, TLF_NON_GROUND_FLAGS, Coord3D< T >::x, Coord3D< T >::y, and Coord3D< T >::z.
Referenced by StationChangeInfo().
|
static |
Preprocess the TileLayoutFlags and read register modifiers from the GRF.
| 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 121 of file newgrf_act2.cpp.
References NewGRFSpriteLayout::AllocateRegisters(), TileLayoutRegisters::child, DisableGrf(), TileLayoutRegisters::dodraw, TileLayoutRegisters::flags, TileLayoutRegisters::palette, TileLayoutRegisters::palette_var10, TileLayoutRegisters::parent, ByteReader::ReadByte(), 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().
| TileLayoutFlags ReadSpriteLayoutSprite | ( | ByteReader & | buf, |
| bool | read_flags, | ||
| bool | invert_action1_flag, | ||
| bool | use_cur_spritesets, | ||
| GrfSpecFeature | 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 63 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 ResetCallbacks | ( | bool | final | ) |
Definition at line 267 of file newgrf_act2.cpp.
|
static |
Sorted list of cached callback result spritegroups.
Definition at line 265 of file newgrf_act2.cpp.
|
constexpr |
Return calculated result from VarAction2.
Definition at line 26 of file newgrf_act2.cpp.
|
constexpr |
Explicit "failure" result.
Definition at line 25 of file newgrf_act2.cpp.