OpenTTD Source  20241108-master-g80f628063a
IndustryOverrideManager Class Reference
Inheritance diagram for IndustryOverrideManager:
OverrideManagerBase

Public Member Functions

 IndustryOverrideManager (uint16_t offset, uint16_t maximum, uint16_t invalid)
 
uint16_t AddEntityID (uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id) override
 Method to find an entity ID and to mark it as reserved for the Industry to be included. More...
 
uint16_t GetID (uint16_t grf_local_id, uint32_t grfid) const override
 Return the ID (if ever available) of a previously inserted entity. More...
 
void SetEntitySpec (IndustrySpec *inds)
 Method to install the new industry data in its proper slot The slot assignment is internal of this method, since it requires checking what is available. More...
 
- Public Member Functions inherited from OverrideManagerBase
 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...
 
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...
 
uint16_t GetMaxMapping () const
 
uint16_t GetMaxOffset () const
 

Additional Inherited Members

- Data Fields inherited from OverrideManagerBase
std::vector< EntityIDMappingmappings
 mapping of ids from grf files. Public out of convenience
 
- Protected Member Functions inherited from OverrideManagerBase
virtual bool CheckValidNewID ([[maybe_unused]] uint16_t testid)
 
- Protected Attributes inherited from OverrideManagerBase
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 234 of file newgrf_commons.h.

Member Function Documentation

◆ AddEntityID()

uint16_t IndustryOverrideManager::AddEntityID ( uint16_t  grf_local_id,
uint32_t  grfid,
uint16_t  substitute_id 
)
overridevirtual

Method to find an entity ID and to mark it as reserved for the Industry to be included.

Parameters
grf_local_idID used by the grf file for pre-installation work (equivalent of TTDPatch's setid
grfidID of the current grf file
substitute_idindustry from which data has been copied
Returns
a free entity id (slotid) if ever one has been found, or Invalid_ID marker otherwise

Reimplemented from OverrideManagerBase.

Definition at line 212 of file newgrf_commons.cpp.

Referenced by SetEntitySpec().

◆ GetID()

uint16_t IndustryOverrideManager::GetID ( uint16_t  grf_local_id,
uint32_t  grfid 
) const
overridevirtual

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 from OverrideManagerBase.

Definition at line 192 of file newgrf_commons.cpp.

Referenced by SetEntitySpec().

◆ SetEntitySpec()

void IndustryOverrideManager::SetEntitySpec ( IndustrySpec inds)

Method to install the new industry data in its proper slot The slot assignment is internal of this method, since it requires checking what is available.

Parameters
indsIndustryspec that comes from the grf decoding process

Definition at line 247 of file newgrf_commons.cpp.

References AddEntityID(), GetID(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, OverrideManagerBase::invalid_id, GRFFilePropsBase< Tcnt >::local_id, and GRFFileProps::override.


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