OpenTTD Source: src/industry_map.h File Reference

OpenTTD Source 15.3

Enumerations | Functions
industry_map.h File Reference

Accessors for industries. More...

`#include "industrytype.h"`
`#include "water_map.h"`

Go to the source code of this file.

## Enumerations
enum | IndustryGraphics : uint8_t { GFX_COAL_MINE_TOWER_NOT_ANIMATED = 0 , GFX_COAL_MINE_TOWER_ANIMATED = 1 , GFX_POWERPLANT_CHIMNEY = 8 , GFX_POWERPLANT_SPARKS = 10 , GFX_OILRIG_1 = 24 , GFX_OILRIG_2 = 25 , GFX_OILRIG_3 = 26 , GFX_OILRIG_4 = 27 , GFX_OILRIG_5 = 28 , GFX_OILWELL_NOT_ANIMATED = 29 , GFX_OILWELL_ANIMATED_1 = 30 , GFX_OILWELL_ANIMATED_2 = 31 , GFX_OILWELL_ANIMATED_3 = 32 , GFX_COPPER_MINE_TOWER_NOT_ANIMATED = 47 , GFX_COPPER_MINE_TOWER_ANIMATED = 48 , GFX_COPPER_MINE_CHIMNEY = 49 , GFX_GOLD_MINE_TOWER_NOT_ANIMATED = 79 , GFX_GOLD_MINE_TOWER_ANIMATED = 88 , GFX_TOY_FACTORY = 143 , GFX_PLASTIC_FOUNTAIN_ANIMATED_1 = 148 , GFX_PLASTIC_FOUNTAIN_ANIMATED_2 = 149 , GFX_PLASTIC_FOUNTAIN_ANIMATED_3 = 150 , GFX_PLASTIC_FOUNTAIN_ANIMATED_4 = 151 , GFX_PLASTIC_FOUNTAIN_ANIMATED_5 = 152 , GFX_PLASTIC_FOUNTAIN_ANIMATED_6 = 153 , GFX_PLASTIC_FOUNTAIN_ANIMATED_7 = 154 , GFX_PLASTIC_FOUNTAIN_ANIMATED_8 = 155 , GFX_BUBBLE_GENERATOR = 161 , GFX_BUBBLE_CATCHER = 162 , GFX_TOFFEE_QUARRY = 165 , GFX_SUGAR_MINE_SIEVE = 174 , GFX_WATERTILE_SPECIALCHECK = 255 }
| The following enums are indices used to know what to draw for this industry tile. More...

## Functions
IndustryID | GetIndustryIndex (Tile t)
| Get the industry ID of the given tile.
bool | IsIndustryCompleted (Tile t)
| Is this industry tile fully built?
IndustryType | GetIndustryType (Tile tile)
| Retrieve the type for this industry.
void | SetIndustryCompleted (Tile tile)
| Set if the industry that owns the tile as under construction or not.
uint8_t | GetIndustryConstructionStage (Tile tile)
| Returns the industry construction stage of the specified tile.
void | SetIndustryConstructionStage (Tile tile, uint8_t value)
| Sets the industry construction stage of the specified tile.
IndustryGfx | GetCleanIndustryGfx (Tile t)
| Get the industry graphics ID for the given industry tile as stored in the without translation.
IndustryGfx | GetIndustryGfx (Tile t)
| Get the industry graphics ID for the given industry tile.
void | SetIndustryGfx (Tile t, IndustryGfx gfx)
| Set the industry graphics ID for the given industry tile.
uint8_t | GetIndustryConstructionCounter (Tile tile)
| Returns this industry tile's construction counter value.
void | SetIndustryConstructionCounter (Tile tile, uint8_t value)
| Sets this industry tile's construction counter value.
void | ResetIndustryConstructionStage (Tile tile)
| Reset the construction stage counter of the industry, as well as the completion bit.
uint8_t | GetIndustryAnimationLoop (Tile tile)
| Get the animation loop number.
void | SetIndustryAnimationLoop (Tile tile, uint8_t count)
| Set the animation loop number.
uint8_t | GetIndustryRandomBits (Tile tile)
| Get the random bits for this tile.
void | SetIndustryRandomBits (Tile tile, uint8_t bits)
| Set the random bits for this tile.
IndustryRandomTriggers | GetIndustryRandomTriggers (Tile tile)
| Get the activated triggers bits for this industry tile Used for grf callbacks.
void | SetIndustryRandomTriggers (Tile tile, IndustryRandomTriggers triggers)
| Set the activated triggers bits for this industry tile Used for grf callbacks.
void | MakeIndustry (Tile t, IndustryID index, IndustryGfx gfx, uint8_t random, WaterClass wc)
| Make the given tile an industry tile.

## Detailed Description

Accessors for industries.

Definition in file industry_map.h.

## Enumeration Type Documentation

## ◆ IndustryGraphics

enum IndustryGraphics : uint8_t

The following enums are indices used to know what to draw for this industry tile.

They all are pointing toward array _industry_draw_tile_data, in table/industry_land.h How to calculate the correct position ? GFXid << 2 | IndustryStage (0 to 3)

Enumerator
GFX_WATERTILE_SPECIALCHECK | not really a tile, but rather a very special check

Definition at line 22 of file industry_map.h.

## Function Documentation

## ◆ GetCleanIndustryGfx()

IndustryGfx GetCleanIndustryGfx | ( | Tile | t | ) |
| inline

Get the industry graphics ID for the given industry tile as stored in the without translation.

Parameters

  t | the tile to get the gfx for

Precondition
  IsTileType(t, MP_INDUSTRY)

Returns
  the gfx ID

Definition at line 125 of file industry_map.h.

References GB(), IsTileType(), Tile::m5(), Tile::m6(), and MP_INDUSTRY.

Referenced by GetIndustryGfx(), and GetIndustryIDAtOffset().

## ◆ GetIndustryAnimationLoop()

uint8_t GetIndustryAnimationLoop | ( | Tile | tile | ) |
| inline

Get the animation loop number.

Parameters

  tile | the tile to get the animation loop number of

Precondition
  IsTileType(tile, MP_INDUSTRY)

Definition at line 199 of file industry_map.h.

References IsTileType(), Tile::m4(), and MP_INDUSTRY.

## ◆ GetIndustryConstructionCounter()

uint8_t GetIndustryConstructionCounter | ( | Tile | tile | ) |
| inline

Returns this industry tile's construction counter value.

Parameters

  tile | the tile to query

Precondition
  IsTileType(tile, MP_INDUSTRY)

Returns
  the construction counter

Definition at line 162 of file industry_map.h.

References GB(), IsTileType(), Tile::m1(), and MP_INDUSTRY.

## ◆ GetIndustryConstructionStage()

uint8_t GetIndustryConstructionStage | ( | Tile | tile | ) |
| inline

Returns the industry construction stage of the specified tile.

Parameters

  tile | the tile to query

Precondition
  IsTileType(tile, MP_INDUSTRY)

Returns
  the construction stage

Definition at line 100 of file industry_map.h.

References GB(), INDUSTRY_COMPLETED, IsIndustryCompleted(), IsTileType(), Tile::m1(), and MP_INDUSTRY.

Referenced by IndustryTileScopeResolver::GetVariable().

## ◆ GetIndustryGfx()

IndustryGfx GetIndustryGfx | ( | Tile | t | ) |
| inline

Get the industry graphics ID for the given industry tile.

Parameters

  t | the tile to get the gfx for

Precondition
  IsTileType(t, MP_INDUSTRY)

Returns
  the gfx ID

Definition at line 137 of file industry_map.h.

References GetCleanIndustryGfx(), GetTranslatedIndustryTileID(), IsTileType(), and MP_INDUSTRY.

Referenced by AfterLoadGame(), DoTriggerIndustryTileRandomisation(), NIHIndustryTile::GetBadges(), NIHIndustryTile::GetGRFID(), NIHIndustryTile::GetSpec(), IndustryTileScopeResolver::GetVariable(), NIHIndustryTile::IsInspectable(), and NIHIndustryTile::Resolve().

## ◆ GetIndustryIndex()

IndustryID GetIndustryIndex | ( | Tile | t | ) |
| inline

Get the industry ID of the given tile.

Parameters

  t | the tile to get the industry ID from

Precondition
  IsTileType(t, MP_INDUSTRY)

Returns
  the industry ID

Definition at line 63 of file industry_map.h.

References IsTileType(), Tile::m2(), and MP_INDUSTRY.

Referenced by DisasterTick_Aircraft(), Industry::GetByTile(), NIHIndustryTile::GetName(), GetNearbyIndustryTileInformation(), NIHIndustryTile::GetParent(), GetProductionAroundTiles(), IsWateredTile(), Station::RecomputeCatchment(), Station::RemoveFromAllNearbyLists(), and Industry::TileBelongsToIndustry().

## ◆ GetIndustryRandomBits()

uint8_t GetIndustryRandomBits | ( | Tile | tile | ) |
| inline

Get the random bits for this tile.

Used for grf callbacks

Parameters

  tile | the tile to query

Precondition
  IsTileType(tile, MP_INDUSTRY)

Returns
  requested bits

Definition at line 224 of file industry_map.h.

References IsTileType(), Tile::m3(), and MP_INDUSTRY.

Referenced by DoTriggerIndustryTileRandomisation(), IndustryTileScopeResolver::GetRandomBits(), and IndustriesScopeResolver::GetVariable().

## ◆ GetIndustryRandomTriggers()

IndustryRandomTriggers GetIndustryRandomTriggers | ( | Tile | tile | ) |
| inline

Get the activated triggers bits for this industry tile Used for grf callbacks.

Parameters

  tile | the tile to query

Precondition
  IsTileType(tile, MP_INDUSTRY)

Returns
  requested triggers

Definition at line 250 of file industry_map.h.

References GB(), IsTileType(), Tile::m6(), and MP_INDUSTRY.

Referenced by DoTriggerIndustryTileRandomisation(), and IndustryTileScopeResolver::GetRandomTriggers().

## ◆ GetIndustryType()

IndustryType GetIndustryType | ( | Tile | tile | ) |

Retrieve the type for this industry.

Although it is accessed by a tile, it will return the general type of industry, and not the sprite index as would do GetIndustryGfx.

Parameters

  tile | that is queried

Precondition
  IsTileType(tile, MP_INDUSTRY)

Returns
  general type for this industry, as defined in industry.h

Definition at line 109 of file industry_cmd.cpp.

References Industry::GetByTile(), IsTileType(), MP_INDUSTRY, and Industry::type.

Referenced by AfterLoadGame(), and GenerateStationName().

## ◆ IsIndustryCompleted()

bool IsIndustryCompleted | ( | Tile | t | ) |
| inline

Is this industry tile fully built?

Parameters

  t | the tile to analyze

Precondition
  IsTileType(t, MP_INDUSTRY)

Returns
  true if and only if the industry tile is fully built

Definition at line 75 of file industry_map.h.

References HasBit(), IsTileType(), Tile::m1(), and MP_INDUSTRY.

Referenced by ChopLumberMillTrees(), and GetIndustryConstructionStage().

## ◆ MakeIndustry()

void MakeIndustry | ( | Tile | t,
|  | IndustryID | index,
|  | IndustryGfx | gfx,
|  | uint8_t | random,
|  | WaterClass | wc
| ) |  |
| inline

Make the given tile an industry tile.

Parameters

  t | the tile to make an industry tile
  index | the industry this tile belongs to
  gfx | the graphics to use for the tile
  random | the random value
  wc | the water class for this industry; only useful when build on water

Definition at line 278 of file industry_map.h.

References Tile::m1(), Tile::m2(), Tile::m4(), Tile::m6(), Tile::m7(), Tile::m8(), MP_INDUSTRY, SB(), SetIndustryGfx(), SetIndustryRandomBits(), SetIndustryRandomTriggers(), SetTileType(), and SetWaterClass().

Referenced by DoCreateNewIndustry().

## ◆ ResetIndustryConstructionStage()

void ResetIndustryConstructionStage | ( | Tile | tile | ) |
| inline

Reset the construction stage counter of the industry, as well as the completion bit.

In fact, it is the same as restarting construction from the ground up.

Parameters

  tile | the tile to query

Precondition
  IsTileType(tile, MP_INDUSTRY)

Definition at line 187 of file industry_map.h.

References IsTileType(), Tile::m1(), MP_INDUSTRY, and SB().

## ◆ SetIndustryAnimationLoop()

void SetIndustryAnimationLoop | ( | Tile | tile,
|  | uint8_t | count
| ) |  |
| inline

Set the animation loop number.

Parameters

  tile | the tile to set the animation loop number of
  count | the new animation frame number

Precondition
  IsTileType(tile, MP_INDUSTRY)

Definition at line 211 of file industry_map.h.

References IsTileType(), Tile::m4(), and MP_INDUSTRY.

## ◆ SetIndustryCompleted()

void SetIndustryCompleted | ( | Tile | tile | ) |
| inline

Set if the industry that owns the tile as under construction or not.

Parameters

  tile | the tile to query

Precondition
  IsTileType(tile, MP_INDUSTRY)

Definition at line 88 of file industry_map.h.

References IsTileType(), Tile::m1(), MP_INDUSTRY, and SetBit().

## ◆ SetIndustryConstructionCounter()

void SetIndustryConstructionCounter | ( | Tile | tile,
|  | uint8_t | value
| ) |  |
| inline

Sets this industry tile's construction counter value.

Parameters

  tile | the tile to query
  value | the new value for the construction counter

Precondition
  IsTileType(tile, MP_INDUSTRY)

Definition at line 174 of file industry_map.h.

References IsTileType(), Tile::m1(), MP_INDUSTRY, and SB().

Referenced by DoCreateNewIndustry().

## ◆ SetIndustryConstructionStage()

void SetIndustryConstructionStage | ( | Tile | tile,
|  | uint8_t | value
| ) |  |
| inline

Sets the industry construction stage of the specified tile.

Parameters

  tile | the tile to query
  value | the new construction stage

Precondition
  IsTileType(tile, MP_INDUSTRY)

Definition at line 112 of file industry_map.h.

References IsTileType(), Tile::m1(), MP_INDUSTRY, and SB().

Referenced by DoCreateNewIndustry().

## ◆ SetIndustryGfx()

void SetIndustryGfx | ( | Tile | t,
|  | IndustryGfx | gfx
| ) |  |
| inline

Set the industry graphics ID for the given industry tile.

Parameters

  t | the tile to set the gfx for

Precondition
  IsTileType(t, MP_INDUSTRY)

Parameters

  gfx | the graphics ID

Definition at line 149 of file industry_map.h.

References GB(), IsTileType(), Tile::m5(), Tile::m6(), MP_INDUSTRY, and SB().

Referenced by MakeIndustry().

## ◆ SetIndustryRandomBits()

void SetIndustryRandomBits | ( | Tile | tile,
|  | uint8_t | bits
| ) |  |
| inline

Set the random bits for this tile.

Used for grf callbacks

Parameters

  tile | the tile to query
  bits | the random bits

Precondition
  IsTileType(tile, MP_INDUSTRY)

Definition at line 237 of file industry_map.h.

References IsTileType(), Tile::m3(), and MP_INDUSTRY.

Referenced by DoTriggerIndustryTileRandomisation(), and MakeIndustry().

## ◆ SetIndustryRandomTriggers()

void SetIndustryRandomTriggers | ( | Tile | tile,
|  | IndustryRandomTriggers | triggers
| ) |  |
| inline

Set the activated triggers bits for this industry tile Used for grf callbacks.

Parameters

  tile | the tile to query
  triggers | the triggers to set

Precondition
  IsTileType(tile, MP_INDUSTRY)

Definition at line 264 of file industry_map.h.

References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), IsTileType(), Tile::m6(), MP_INDUSTRY, and SB().

Referenced by DoTriggerIndustryTileRandomisation(), and MakeIndustry().