OpenTTD Source
12.0-beta2
|
NewGRF supplied spritelayout. More...
#include <newgrf_commons.h>
Public Member Functions | |
void | Allocate (uint num_sprites) |
Allocate a spritelayout for num_sprites building sprites. More... | |
void | AllocateRegisters () |
Allocate memory for register modifiers. | |
void | Clone (const DrawTileSeqStruct *source) |
Clone the building sprites of a spritelayout. More... | |
void | Clone (const NewGRFSpriteLayout *source) |
Clone a spritelayout. More... | |
void | Clone (const DrawTileSprites *source) |
Clone a spritelayout. More... | |
bool | NeedsPreprocessing () const |
Tests whether this spritelayout needs preprocessing by PrepareLayout() and ProcessRegisters(), or whether it can be used directly. More... | |
uint32 | PrepareLayout (uint32 orig_offset, uint32 newgrf_ground_offset, uint32 newgrf_offset, uint constr_stage, bool separate_ground) const |
Prepares a sprite layout before resolving action-1-2-3 chains. More... | |
void | ProcessRegisters (uint8 resolved_var10, uint32 resolved_sprite, bool separate_ground) const |
Evaluates the register modifiers and integrates them into the preprocessed sprite layout. More... | |
const DrawTileSeqStruct * | GetLayout (PalSpriteID *ground) const |
Returns the result spritelayout after preprocessing. More... | |
![]() | |
void * | operator new (size_t size) |
Memory allocator for a single class instance. More... | |
void * | operator new[] (size_t size) |
Memory allocator for an array of class instances. More... | |
void | operator delete (void *ptr) |
Memory release for a single class instance. More... | |
void | operator delete[] (void *ptr) |
Memory release for an array of class instances. More... | |
Data Fields | |
const TileLayoutRegisters * | registers |
uint | consistent_max_offset |
Number of sprites in all referenced spritesets. More... | |
![]() | |
PalSpriteID | ground |
Palette and sprite for the ground. | |
const DrawTileSeqStruct * | seq |
Array of child sprites. Terminated with a terminator entry. | |
Static Private Attributes | |
static std::vector< DrawTileSeqStruct > | result_seq |
Temporary storage when preprocessing spritelayouts. | |
NewGRF supplied spritelayout.
In contrast to DrawTileSprites this struct is for allocated layouts on the heap. It allocates data and frees them on destruction.
Definition at line 113 of file newgrf_commons.h.
void NewGRFSpriteLayout::Allocate | ( | uint | num_sprites | ) |
Allocate a spritelayout for num_sprites building sprites.
num_sprites | Number of building sprites to allocate memory for. (not counting the terminator) |
Definition at line 624 of file newgrf_commons.cpp.
References DrawTileSeqStruct::MakeTerminator(), and DrawTileSprites::seq.
Referenced by ReadSpriteLayout().
void NewGRFSpriteLayout::Clone | ( | const DrawTileSeqStruct * | source | ) |
Clone the building sprites of a spritelayout.
source | The building sprites to copy. |
Definition at line 586 of file newgrf_commons.cpp.
References foreach_draw_tile_seq, MemCpyT(), and DrawTileSprites::seq.
Referenced by Clone().
|
inline |
Clone a spritelayout.
source | The spritelayout to copy. |
Definition at line 131 of file newgrf_commons.h.
References Clone(), DrawTileSprites::ground, and DrawTileSprites::seq.
void NewGRFSpriteLayout::Clone | ( | const NewGRFSpriteLayout * | source | ) |
Clone a spritelayout.
source | The spritelayout to copy. |
Definition at line 604 of file newgrf_commons.cpp.
References Clone(), foreach_draw_tile_seq, MemCpyT(), and DrawTileSprites::seq.
|
inline |
Returns the result spritelayout after preprocessing.
Definition at line 163 of file newgrf_commons.h.
References DrawTileSprites::ground, and result_seq.
Referenced by TileLayoutSpriteGroup::ProcessRegisters().
|
inline |
Tests whether this spritelayout needs preprocessing by PrepareLayout() and ProcessRegisters(), or whether it can be used directly.
Definition at line 150 of file newgrf_commons.h.
Referenced by TileLayoutSpriteGroup::ProcessRegisters().
uint32 NewGRFSpriteLayout::PrepareLayout | ( | uint32 | orig_offset, |
uint32 | newgrf_ground_offset, | ||
uint32 | newgrf_offset, | ||
uint | constr_stage, | ||
bool | separate_ground | ||
) | const |
Prepares a sprite layout before resolving action-1-2-3 chains.
Integrates offsets into the layout and determines which chains to resolve.
orig_offset | Offset to apply to non-action-1 sprites. |
newgrf_ground_offset | Offset to apply to action-1 ground sprites. |
newgrf_offset | Offset to apply to action-1 non-ground sprites. |
constr_stage | Construction stage (0-3) to apply to all action-1 sprites. |
separate_ground | Whether the ground sprite shall be resolved by a separate action-1-2-3 chain by default. |
Definition at line 660 of file newgrf_commons.cpp.
References DrawTileSeqStruct::delta_x, DrawTileSeqStruct::delta_z, DrawTileSprites::ground, and result_seq.
Referenced by TileLayoutSpriteGroup::ProcessRegisters().
void NewGRFSpriteLayout::ProcessRegisters | ( | uint8 | resolved_var10, |
uint32 | resolved_sprite, | ||
bool | separate_ground | ||
) | const |
Evaluates the register modifiers and integrates them into the preprocessed sprite layout.
resolved_var10 | The value of var10 the action-1-2-3 chain was evaluated for. |
resolved_sprite | Result sprite of the action-1-2-3 chain. |
separate_ground | Whether the ground sprite is resolved by a separate action-1-2-3 chain. |
Definition at line 731 of file newgrf_commons.cpp.
References foreach_draw_tile_seq, DrawTileSprites::ground, and result_seq.
Referenced by TileLayoutSpriteGroup::ProcessRegisters().
uint NewGRFSpriteLayout::consistent_max_offset |
Number of sprites in all referenced spritesets.
If these numbers are inconsistent, then this is 0 and the real values are in registers
.
Definition at line 120 of file newgrf_commons.h.
Referenced by TileLayoutSpriteGroup::ProcessRegisters().