OpenTTD Source: IndustryOverrideManager Class Reference

OpenTTD Source 13.1

Public Member Functions
IndustryOverrideManager Class Reference
Inheritance diagram for IndustryOverrideManager:

## Public Member Functions
| IndustryOverrideManager (uint16 offset, uint16 maximum, uint16 invalid)
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. More...
uint16 | GetID (uint8 grf_local_id, uint32 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 offset, uint16 maximum, uint16 invalid)
| Constructor of generic class. More...
virtual | ~OverrideManagerBase ()
| Destructor of the 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 (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, the IDs used for overriding old entities must be translated when the entity spec is set. More...
uint32 | GetGRFID (uint16 entity_id) const
| Gives the GRFID of the file the entity belongs to. More...
uint16 | GetSubstituteID (uint16 entity_id) const
| Gives the substitute of the entity, as specified by the grf file. More...
uint16 | GetMaxMapping () const
uint16 | GetMaxOffset () const

## Additional Inherited Members
Data Fields inherited from OverrideManagerBase
EntityIDMapping * | mapping_ID
| mapping of ids from grf files. Public out of convenience
Protected Member Functions inherited from OverrideManagerBase
virtual bool | CheckValidNewID (uint16 testid)
Protected Attributes inherited from OverrideManagerBase
uint16 * | entity_overrides
uint32 * | grfid_overrides
uint16 | max_offset
| what is the length of the original entity's array of specs
uint16 | max_new_entities
| what is the amount of entities, old and new summed
uint16 | invalid_ID
| ID used to detected invalid entities;.

## Detailed Description

Definition at line 235 of file newgrf_commons.h.

## Member Function Documentation

## ◆ AddEntityID()

uint16 IndustryOverrideManager::AddEntityID | ( | byte | grf_local_id,
|  | uint32 | grfid,
|  | byte | substitute_id
| ) |  |
| overridevirtual

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

Parameters

  grf_local_id | ID used by the grf file for pre-installation work (equivalent of TTDPatch's setid
  grfid | ID of the current grf file
  substitute_id | industry 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 225 of file newgrf_commons.cpp.

References IndustrySpec::enabled, EntityIDMapping::entity_id, GetIndustrySpec(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, EntityIDMapping::grfid, OverrideManagerBase::invalid_ID, OverrideManagerBase::mapping_ID, OverrideManagerBase::max_new_entities, OverrideManagerBase::max_offset, and EntityIDMapping::substitute_id.

Referenced by SetEntitySpec().

## ◆ GetID()

uint16 IndustryOverrideManager::GetID | ( | uint8 | grf_local_id,
|  | uint32 | grfid
| ) |  | const
| overridevirtual

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

Parameters

  grf_local_id | ID of this entity within the grfID
  grfid | ID of the grf file

Returns
  the ID of the candidate, of the Invalid flag item ID

Reimplemented from OverrideManagerBase.

Definition at line 205 of file newgrf_commons.cpp.

References OverrideManagerBase::GetID(), OverrideManagerBase::invalid_ID, and OverrideManagerBase::max_offset.

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

  inds | Industryspec that comes from the grf decoding process

Definition at line 260 of file newgrf_commons.cpp.

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

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

- src/newgrf_commons.h
- src/newgrf_commons.cpp