Go to the documentation of this file.
13 #ifndef NEWGRF_COMMONS_H
14 #define NEWGRF_COMMONS_H
77 assert(num_sprites > 0);
78 if (num_sprites > 4) num_sprites = 4;
79 switch (construction_stage) {
81 case 1:
return num_sprites > 2 ? 1 : 0;
82 case 2:
return num_sprites > 2 ? num_sprites - 2 : 0;
83 case 3:
return num_sprites - 1;
84 default: NOT_REACHED();
133 assert(source !=
nullptr &&
this != source);
141 free(this->registers);
152 return this->registers !=
nullptr;
155 uint32
PrepareLayout(uint32 orig_offset, uint32 newgrf_ground_offset, uint32 newgrf_offset, uint constr_stage,
bool separate_ground)
const;
156 void ProcessRegisters(uint8 resolved_var10, uint32 resolved_sprite,
bool separate_ground)
const;
194 uint16 *entity_overrides;
195 uint32 *grfid_overrides;
201 virtual bool CheckValidNewID(uint16 testid) {
return true; }
212 void Add(uint8 local_id, uint32 grfid, uint entity_type);
213 virtual uint16
AddEntityID(
byte grf_local_id, uint32 grfid,
byte substitute_id);
215 uint32
GetGRFID(uint16 entity_id)
const;
217 virtual uint16
GetID(uint8 grf_local_id, uint32 grfid)
const;
220 inline uint16 GetMaxOffset()
const {
return max_offset; }
240 uint16
AddEntityID(
byte grf_local_id, uint32 grfid,
byte substitute_id)
override;
241 uint16
GetID(uint8 grf_local_id, uint32 grfid)
const override;
250 virtual bool CheckValidNewID(uint16 testid) {
return testid != 0xFF; }
270 virtual bool CheckValidNewID(uint16 testid) {
return testid != 0xFF; }
281 virtual bool CheckValidNewID(uint16 testid) {
return testid != 0xFF; }
310 template <
size_t Tcnt>
@ TCX_UPPER_HALFTILE
Querying information about the upper part of a tile with halftile foundation.
uint32 TileIndex
The index/ID of a Tile.
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFile *grffile, StringID default_error)
Get the error message from a shape/location/slope check callback result.
uint16 override
id of the entity been replaced by
GRFFileProps(uint16 subst_id=0)
Set all default data constructor for the props.
uint8 substitute_id
The (original) entity ID to use if this GRF is not available.
@ TLF_DODRAW
Only draw sprite if value of register TileLayoutRegisters::dodraw is non-zero.
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.
Allow incrementing of ObjectClassID variables.
@ TLF_CHILD_X_OFFSET
Add signed offset to child sprite X positions from register TileLayoutRegisters::delta....
uint8 sprite
Register specifying a signed offset for the sprite.
void AllocateRegisters()
Allocate memory for register modifiers.
virtual ~OverrideManagerBase()
Destructor of the generic class.
uint8 parent[3]
Registers for signed offsets for the bounding box position of parent sprites.
uint8 palette_var10
Value for variable 10 when resolving the palette.
void ProcessRegisters(uint8 resolved_var10, uint32 resolved_sprite, bool separate_ground) const
Evaluates the register modifiers and integrates them into the preprocessed sprite layout.
@ TLF_CUSTOM_PALETTE
Palette is from Action 1 (moved to SPRITE_MODIFIER_CUSTOM_SPRITE in palette during loading).
virtual uint16 GetID(uint8 grf_local_id, uint32 grfid) const
Return the ID (if ever available) of a previously inserted entity.
void Add(uint8 local_id, uint32 grfid, uint entity_type)
Since the entity IDs defined by the GRF file does not necessarily correlate to those used by the game...
void Clone(const DrawTileSprites *source)
Clone a spritelayout.
bool ConvertBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
Owner
Enum for all companies/owners.
@ TLF_BB_Z_OFFSET
Add signed offset to bounding box Z positions from register TileLayoutRegisters::delta....
Defines the data structure for an airport.
Additional modifiers for items in sprite layouts.
uint8 dodraw
Register deciding whether the sprite shall be drawn at all. Non-zero means drawing.
uint16 GetID(uint8 grf_local_id, uint32 grfid) const override
Return the ID (if ever available) of a previously inserted entity.
uint32 grfid
The GRF ID of the file the entity belongs to.
@ TLF_KNOWN_FLAGS
Known flags. Any unknown set flag will disable the GRF.
PalSpriteID ground
Palette and sprite for the ground.
Defines the data structure of each individual tile of an airport.
OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid)
Constructor of generic class.
Common return value for all commands.
@ TLF_BB_XY_OFFSET
Add signed offset to bounding box X and Y positions from register TileLayoutRegisters::delta....
void ResetMapping()
Resets the mapping, which is used while initializing game.
@ TLF_CHILD_Y_OFFSET
Add signed offset to child sprite Y positions from register TileLayoutRegisters::delta....
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
Base class that provides memory initialization on dynamically created objects.
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
Data related to the handling of grf files.
TileContext
Context for tile accesses.
uint8 child[2]
Registers for signed offsets for the position of child sprites.
NewGRF supplied spritelayout.
void SetEntitySpec(ObjectSpec *spec)
Method to install the new object data in its proper slot The slot assignment is internal of this meth...
bool NeedsPreprocessing() const
Tests whether this spritelayout needs preprocessing by PrepareLayout() and ProcessRegisters(),...
static const uint TLR_MAX_VAR10
Maximum value for var 10.
Ground palette sprite of a tile, together with its sprite layout.
@ TCX_NORMAL
Nothing special.
static uint GetConstructionStageOffset(uint construction_stage, uint num_sprites)
Determines which sprite to use from a spriteset for a specific construction stage.
Maps an entity id stored on the map to a GRF file.
@ TLF_NON_GROUND_FLAGS
Flags which do not work for the (first) ground sprite.
Defines the data structure for constructing industry.
uint8 sprite_var10
Value for variable 10 when resolving the sprite.
uint8 entity_id
The entity ID within the GRF file.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
const struct SpriteGroup * spritegroup[Tcnt]
pointer to the different sprites of the entity
@ TLF_VAR10_FLAGS
Flags which refer to using multiple action-1-2-3 chains.
uint16 max_new_entities
what is the amount of entities, old and new summed
uint8 palette
Register specifying a signed offset for the palette.
uint16 max_palette_offset
Maximum offset to add to the palette. (limited by size of the spriteset)
uint16 GetSubstituteID(uint16 entity_id) const
Gives the substitute of the entity, as specified by the grf file.
@ TCX_ON_BRIDGE
Querying information about stuff on the bridge (via some bridgehead).
uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id) override
Method to find an entity ID and to mark it as reserved for the Industry to be included.
uint consistent_max_offset
Number of sprites in all referenced spritesets.
void ResetOverride()
Resets the override, which is used while initializing game.
TileLayoutFlags
Flags to enable register usage in sprite layouts.
Combination of a palette sprite and a 'real' sprite.
EntityIDMapping * mapping_ID
mapping of ids from grf files. Public out of convenience
uint32 GetTerrainType(TileIndex tile, TileContext context=TCX_NORMAL)
Function used by houses (and soon industries) to get information on type of "terrain" the tile it is ...
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets=true, Axis axis=INVALID_AXIS)
Get the tile at the given offset.
void Clone(const DrawTileSeqStruct *source)
Clone the building sprites of a spritelayout.
uint32 GetCompanyInfo(CompanyID owner, const Livery *l)
Returns company information like in vehicle var 43 or station var 43.
const DrawTileSeqStruct * seq
Array of child sprites. Terminated with a terminator entry.
TileLayoutFlags flags
Flags defining which members are valid and to be used.
uint16 max_offset
what is the length of the original entity's array of specs
Axis
Allow incrementing of DiagDirDiff variables.
const DrawTileSeqStruct * GetLayout(PalSpriteID *ground) const
Returns the result spritelayout after preprocessing.
virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id)
Reserves a place in the mapping array for an entity to be installed.
ObjectOverrideManager _object_mngr
The override manager for our objects.
uint32 GetGRFID(uint16 entity_id) const
Gives the GRFID of the file the entity belongs to.
uint16 local_id
id defined by the grf file for this entity
@ TLF_PALETTE_REG_FLAGS
Flags which require resolving the action-1-2-3 chain for the palette, even if it is no action-1 palet...
@ TLF_SPRITE
Add signed offset to sprite from register TileLayoutRegisters::sprite.
@ TLF_PALETTE
Add signed offset to palette from register TileLayoutRegisters::palette.
const struct GRFFile * grffile
grf file that introduced this entity
@ INVALID_AXIS
Flag for an invalid Axis.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
void SetEntitySpec(IndustrySpec *inds)
Method to install the new industry data in its proper slot The slot assignment is internal of this me...
Defines the data structure of each individual tile of an industry.
@ TLF_DRAWING_FLAGS
Flags which are still required after loading the GRF.
@ TLF_PALETTE_VAR10
Resolve palette with a specific value in variable 10.
@ TLF_SPRITE_REG_FLAGS
Flags which require resolving the action-1-2-3 chain for the sprite, even if it is no action-1 sprite...
@ TLF_SPRITE_VAR10
Resolve sprite with a specific value in variable 10.
Data related to the handling of grf files.
Information about a particular livery.
static std::vector< DrawTileSeqStruct > result_seq
Temporary storage when preprocessing spritelayouts.
void Allocate(uint num_sprites)
Allocate a spritelayout for num_sprites building sprites.
Dynamic data of a loaded NewGRF.
uint16 invalid_ID
ID used to detected invalid entities;.
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8)
Common part of station var 0x67, house var 0x62, indtile var 0x60, industry var 0x62.
uint16 max_sprite_offset
Maximum offset to add to the sprite. (limited by size of the spriteset)
A tile child sprite and palette to draw for stations etc, with 3D bounding box.
void SetEntitySpec(const HouseSpec *hs)
Install the specs into the HouseSpecs array It will find itself the proper slot on which it will go.