OpenTTD Source  20241121-master-g67a0fccfad
OverrideManagerBase Class Reference
Inheritance diagram for OverrideManagerBase:
AirportOverrideManager AirportTileOverrideManager HouseOverrideManager IndustryOverrideManager IndustryTileOverrideManager ObjectOverrideManager

Public Member Functions

 OverrideManagerBase (uint16_t offset, uint16_t maximum, uint16_t invalid)
 Constructor of generic class. More...
 
void ResetOverride ()
 Resets the override, which is used while initializing game.
 
void ResetMapping ()
 Resets the mapping, which is used while initializing game.
 
void Add (uint16_t local_id, uint32_t grfid, uint entity_type)
 Since the entity IDs defined by the GRF file does not necessarily correlate to those used by the game, the IDs used for overriding old entities must be translated when the entity spec is set. More...
 
virtual uint16_t AddEntityID (uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id)
 Reserves a place in the mapping array for an entity to be installed. More...
 
uint32_t GetGRFID (uint16_t entity_id) const
 Gives the GRFID of the file the entity belongs to. More...
 
uint16_t GetSubstituteID (uint16_t entity_id) const
 Gives the substitute of the entity, as specified by the grf file. More...
 
virtual uint16_t GetID (uint16_t grf_local_id, uint32_t grfid) const
 Return the ID (if ever available) of a previously inserted entity. More...
 
uint16_t GetMaxMapping () const
 
uint16_t GetMaxOffset () const
 

Data Fields

std::vector< EntityIDMappingmappings
 mapping of ids from grf files. Public out of convenience
 

Protected Member Functions

virtual bool CheckValidNewID ([[maybe_unused]] uint16_t testid)
 

Protected Attributes

std::vector< uint16_t > entity_overrides
 
std::vector< uint32_t > grfid_overrides
 
uint16_t max_offset
 what is the length of the original entity's array of specs
 
uint16_t max_entities
 what is the amount of entities, old and new summed
 
uint16_t invalid_id
 ID used to detected invalid entities.
 

Detailed Description

Definition at line 191 of file newgrf_commons.h.

Constructor & Destructor Documentation

◆ OverrideManagerBase()

OverrideManagerBase::OverrideManagerBase ( uint16_t  offset,
uint16_t  maximum,
uint16_t  invalid 
)

Constructor of generic class.

Parameters
offsetend of original data for this entity. i.e: houses = 110
maximumof entities this manager can deal with. i.e: houses = 512
invalidis the ID used to identify an invalid entity id

Definition at line 42 of file newgrf_commons.cpp.

Member Function Documentation

◆ Add()

void OverrideManagerBase::Add ( uint16_t  local_id,
uint32_t  grfid,
uint  entity_type 
)

Since the entity IDs defined by the GRF file does not necessarily correlate to those used by the game, the IDs used for overriding old entities must be translated when the entity spec is set.

Parameters
local_idID in grf file
grfidID of the grf file
entity_typeoriginal entity type

Definition at line 62 of file newgrf_commons.cpp.

◆ AddEntityID()

uint16_t OverrideManagerBase::AddEntityID ( uint16_t  grf_local_id,
uint32_t  grfid,
uint16_t  substitute_id 
)
virtual

Reserves a place in the mapping array for an entity to be installed.

Parameters
grf_local_idis an arbitrary id given by the grf's author. Also known as setid
grfidis the id of the grf file itself
substitute_idis the original entity from which data is copied for the new one
Returns
the proper usable slot id, or invalid marker if none is found

Reimplemented in IndustryOverrideManager.

Definition at line 109 of file newgrf_commons.cpp.

Referenced by HouseOverrideManager::SetEntitySpec(), and ObjectOverrideManager::SetEntitySpec().

◆ GetGRFID()

uint32_t OverrideManagerBase::GetGRFID ( uint16_t  entity_id) const

Gives the GRFID of the file the entity belongs to.

Parameters
entity_idID of the entity being queried.
Returns
GRFID.

Definition at line 139 of file newgrf_commons.cpp.

◆ GetID()

uint16_t OverrideManagerBase::GetID ( uint16_t  grf_local_id,
uint32_t  grfid 
) const
virtual

Return the ID (if ever available) of a previously inserted entity.

Parameters
grf_local_idID of this entity within the grfID
grfidID of the grf file
Returns
the ID of the candidate, of the Invalid flag item ID

Reimplemented in IndustryOverrideManager.

Definition at line 90 of file newgrf_commons.cpp.

Referenced by GetCountAndDistanceOfClosestInstance(), and ObjectOverrideManager::SetEntitySpec().

◆ GetSubstituteID()

uint16_t OverrideManagerBase::GetSubstituteID ( uint16_t  entity_id) const

Gives the substitute of the entity, as specified by the grf file.

Parameters
entity_idof the entity being queried
Returns
mapped id

Definition at line 149 of file newgrf_commons.cpp.


The documentation for this class was generated from the following files: