OpenTTD AI API: Identifying game object

OpenTTD AI API 15.0-RC1

Identifying game object

IDs are used to identify certain objects.

They are only unique within the object type, so for example a vehicle may have VehicleID 2009, while a station has StationID 2009 at the same time. Also IDs are assigned arbitrary, you cannot assume them to be consecutive. Also note that some IDs are static and never change, while others are allocated dynamically and might be reused for other objects once they are released. So be careful, which IDs you store for which purpose and whether they stay valid all the time.

type | object | acquired | released | reused
--- | --- | --- | --- | ---
BridgeType | bridge type | introduction (1) | never (1) | no (1)
CargoType | cargo type | game start (1) | never (1) | no (1)
ClientID | network client (player) | joining server | leaving server | no
CompanyID | company | launch | merger, bankruptcy | yes
EngineID | engine type | introduction, preview (2) | engines retires (2) | no (2)
GoalID | goal | creation | deletion | yes
GroupID | vehicle group | creation | deletion | yes
IndustryID | industry | construction | closure | yes
IndustryType | industry type | game start (1) | never (1) | no
LeagueTableID | league table | creation | deletion | yes
LeagueTableElementID | element of a league table | creation | deletion | yes
ObjectType | NewGRF object type | game start (1) | never (1) | no
ScriptErrorType | error message | OpenTTD start (3) | OpenTTD exit | no
SignID | sign | construction | deletion | yes
StationID | station | construction | expiration of 'grey' station sign after deletion | yes
StringID | translatable text | OpenTTD start (3) | OpenTTD exit | no
SubsidyID | subsidy | offer announcement | (offer) expiration | yes
StoryPageID | story page | creation | deletion | yes
StoryPageElementID | story page element | creation | deletion | yes
TileIndex | tile on map | game start | never | no
TownID | town | game start | never | no
VehicleID | vehicle | construction, autorenew, autoreplace | destruction, autorenew, autoreplace | yes

Remarks
  - (1) in-game changes of newgrfs may reassign/invalidate IDs (will also cause other trouble though).
  - (2) engine IDs are reassigned/invalidated on changing 'allow multiple newgrf engine sets' (only allowed as long as no vehicles are built).
  - (3) string/error IDs are only valid during a session, and may be reassigned/invalidated when loading savegames (so you cannot store them).