Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes

# OverrideManagerBase Class Reference

Inheritance diagram for OverrideManagerBase:

## Public Member Functions
| OverrideManagerBase (uint16 offset, uint16 maximum, uint16 invalid)
| Constructor of generic class.
virtual | ~OverrideManagerBase ()
| Destructor of the generic class.
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.
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.
uint32 | GetGRFID (uint16 entity_id) const
| Gives the GRFID of the file the entity belongs to.
uint16 | GetSubstituteID (uint16 entity_id) const
| Gives the substitute of the entity, as specified by the grf file.
virtual uint16 | GetID (uint8 grf_local_id, uint32 grfid) const
| Return the ID (if ever available) of a previously inserted entity.
uint16 | GetMaxMapping () const
uint16 | GetMaxOffset () const
## Data Fields
EntityIDMapping * | mapping_ID
| mapping of ids from grf files. Public out of convenience
## Protected Member Functions
virtual bool | CheckValidNewID (uint16 testid)
## Protected Attributes
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 dected invalid entities;.

## Detailed Description

Definition at line 194 of file newgrf_commons.h.

## Constructor & Destructor Documentation

OverrideManagerBase::OverrideManagerBase | ( | uint16 | offset,
|  | uint16 | maximum,
|  | uint16 | invalid |
| ) |  |  |

Constructor of generic class.

Parameters:

  | offset | end of original data for this entity. i.e: houses = 110
  | maximum | of entities this manager can deal with. i.e: houses = 512
  | invalid | is the ID used to identify an invalid entity id

Definition at line 41 of file newgrf_commons.cpp.

References invalid_ID, mapping_ID, max_new_entities, and max_offset.

OverrideManagerBase::~OverrideManagerBase | ( |  | ) | `[virtual]`

Destructor of the generic class.

Frees allocated memory of constructor

Definition at line 57 of file newgrf_commons.cpp.

References free(), and mapping_ID.

## Member Function Documentation

void OverrideManagerBase::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.

Parameters:

  | local_id | ID in grf file
  | grfid | ID of the grf file
  | entity_type | original entity type

Definition at line 72 of file newgrf_commons.cpp.

References invalid_ID, and max_offset.

Referenced by AirportChangeInfo(), IndustriesChangeInfo(), IndustrytilesChangeInfo(), and TownHouseChangeInfo().

uint16 OverrideManagerBase::AddEntityID | ( | byte | grf_local_id,
|  | uint32 | grfid,
|  | byte | substitute_id |
| ) |  |  | `[virtual]`

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

Parameters:

  | grf_local_id | is an arbitrary id given by the grf's author. Also known as setid
  | grfid | is the id of the grf file itself
  | substitute_id | is 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 123 of file newgrf_commons.cpp.

References EntityIDMapping::entity_id, GetID(), EntityIDMapping::grfid, invalid_ID, mapping_ID, max_new_entities, max_offset, and EntityIDMapping::substitute_id.

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

uint32 OverrideManagerBase::GetGRFID | ( | uint16 | entity_id | ) | const

Gives the GRFID of the file the entity belongs to.

Parameters:

  | entity_id | ID of the entity being queried.

Returns:
  GRFID.

Definition at line 156 of file newgrf_commons.cpp.

References EntityIDMapping::grfid, and mapping_ID.

Referenced by AfterLoadGame(), and HouseScopeResolver::GetVariable().

uint16 OverrideManagerBase::GetID | ( | uint8 | grf_local_id,
|  | uint32 | grfid |
| ) |  |  | const`[virtual]`

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

Parameters:

  | grf_local_id | ID of this enity withing the grfID
  | grfid | ID of the grf file

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

Reimplemented in IndustryOverrideManager.

Definition at line 102 of file newgrf_commons.cpp.

References EntityIDMapping::entity_id, EntityIDMapping::grfid, invalid_ID, mapping_ID, and max_new_entities.

Referenced by AddEntityID(), AirportChangeInfo(), GetCountAndDistanceOfClosestInstance(), HouseScopeResolver::GetVariable(), IndustriesChangeInfo(), and ObjectOverrideManager::SetEntitySpec().

uint16 OverrideManagerBase::GetSubstituteID | ( | uint16 | entity_id | ) | const

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

Parameters:

  | entity_id | of the entity being queried

Returns:
  mapped id

Definition at line 166 of file newgrf_commons.cpp.

References mapping_ID, and EntityIDMapping::substitute_id.

Referenced by AirportSpec::Get(), and UpdateHousesAndTowns().

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

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