OpenTTD Source: src/newgrf_industrytiles.cpp File Reference

OpenTTD Source 15.3

Data Structures | Functions
newgrf_industrytiles.cpp File Reference

NewGRF handling of industry tiles. More...

`#include "stdafx.h"`
`#include "debug.h"`
`#include "landscape.h"`
`#include "newgrf_badge.h"`
`#include "newgrf_industrytiles.h"`
`#include "newgrf_sound.h"`
`#include "industry.h"`
`#include "town.h"`
`#include "command_func.h"`
`#include "water.h"`
`#include "newgrf_animation_base.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | IndustryAnimationBase
| Helper class for animation control. More...

## Functions
uint32_t | GetNearbyIndustryTileInformation (uint8_t parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8)
| Based on newhouses equivalent, but adapted for newindustries.
uint32_t | GetRelativePosition (TileIndex tile, TileIndex ind_tile)
| This is the position of the tile relative to the northernmost tile of the industry.
static const GRFFile * | GetIndTileGrffile (IndustryGfx gfx)
| Get the associated NewGRF file from the industry graphics.
static void | IndustryDrawTileLayout (const TileInfo *ti, const DrawTileSpriteSpan &dts, Colours rnd_colour, uint8_t stage)
uint16_t | GetIndustryTileCallback (CallbackID callback, uint32_t param1, uint32_t param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile, std::span< int32_t > regs100)
bool | DrawNewIndustryTile (TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds)
bool | IsSlopeRefused (Slope current, Slope refused)
CommandCost | PerformIndustryTileSlopeCheck (TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, size_t layout_index, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type)
| Check the slope of a tile of a new industry.
uint16_t | GetSimpleIndustryCallback (CallbackID callback, uint32_t param1, uint32_t param2, const IndustryTileSpec *spec, Industry *ind, TileIndex tile, int)
void | AnimateNewIndustryTile (TileIndex tile)
static bool | DoTriggerIndustryTileAnimation (TileIndex tile, IndustryAnimationTrigger iat, uint32_t random, uint32_t var18_extra=0)
bool | TriggerIndustryTileAnimation_ConstructionStageChanged (TileIndex tile, bool first_call)
bool | TriggerIndustryTileAnimation (TileIndex tile, IndustryAnimationTrigger iat)
bool | TriggerIndustryAnimation (const Industry *ind, IndustryAnimationTrigger iat)
static void | DoTriggerIndustryTileRandomisation (TileIndex tile, IndustryRandomTrigger trigger, Industry *ind, uint32_t &reseed_industry)
| Trigger random triggers for an industry tile and reseed its random bits.
static void | DoReseedIndustry (Industry *ind, uint32_t reseed)
| Reseeds the random bits of an industry.
void | TriggerIndustryTileRandomisation (TileIndex tile, IndustryRandomTrigger trigger)
| Trigger a random trigger for a single industry tile.
void | TriggerIndustryRandomisation (Industry *ind, IndustryRandomTrigger trigger)
| Trigger a random trigger for all industry tiles.

## Detailed Description

NewGRF handling of industry tiles.

Definition in file newgrf_industrytiles.cpp.

## Function Documentation

## ◆ AnimateNewIndustryTile()

void AnimateNewIndustryTile | ( | TileIndex | tile | ) |

Definition at line 271 of file newgrf_industrytiles.cpp.

## ◆ DoReseedIndustry()

static void DoReseedIndustry | ( | Industry * | ind,
|  | uint32_t | reseed
| ) |  |
| static

Reseeds the random bits of an industry.

Parameters

  ind | Industry.
  reseed | Bits to reseed.

Definition at line 361 of file newgrf_industrytiles.cpp.

References Industry::random, and Random.

Referenced by TriggerIndustryRandomisation(), and TriggerIndustryTileRandomisation().

## ◆ DoTriggerIndustryTileAnimation()

static bool DoTriggerIndustryTileAnimation | ( | TileIndex | tile,
|  | IndustryAnimationTrigger | iat,
|  | uint32_t | random,
|  | uint32_t | var18_extra = `0`
| ) |  |
| static

Definition at line 279 of file newgrf_industrytiles.cpp.

## ◆ DoTriggerIndustryTileRandomisation()

static void DoTriggerIndustryTileRandomisation | ( | TileIndex | tile,
|  | IndustryRandomTrigger | trigger,
|  | Industry * | ind,
|  | uint32_t & | reseed_industry
| ) |  |
| static

Trigger random triggers for an industry tile and reseed its random bits.

Parameters

  | tile | Industry tile to trigger.
  | trigger | Trigger to trigger.
  | ind | Industry of the tile.
  [in,out] | reseed_industry | Collects bits to reseed for the industry.

Definition at line 324 of file newgrf_industrytiles.cpp.

References CBID_RANDOM_TRIGGER, GetIndustryGfx(), GetIndustryRandomBits(), GetIndustryRandomTriggers(), GetIndustryTileSpec(), IndustryTileSpec::grf_prop, StandardGRFFileProps::HasSpriteGroups(), IsTileType(), IsValidTile(), MarkTileDirtyByTile(), MP_INDUSTRY, Random, SetIndustryRandomBits(), SetIndustryRandomTriggers(), VSG_SCOPE_PARENT, and VSG_SCOPE_SELF.

Referenced by TriggerIndustryRandomisation(), and TriggerIndustryTileRandomisation().

## ◆ DrawNewIndustryTile()

bool DrawNewIndustryTile | ( | TileInfo * | ti,
|  | Industry * | i,
|  | IndustryGfx | gfx,
|  | const IndustryTileSpec * | inds
| ) |  |

Definition at line 191 of file newgrf_industrytiles.cpp.

## ◆ GetIndTileGrffile()

static const GRFFile * GetIndTileGrffile | ( | IndustryGfx | gfx | ) |
| static

Get the associated NewGRF file from the industry graphics.

Parameters

  gfx | Graphics to query.

Returns
  Grf file associated with the graphics, if any.

Definition at line 126 of file newgrf_industrytiles.cpp.

References GetIndustryTileSpec(), IndustryTileSpec::grf_prop, and GRFFilePropsBase::grffile.

## ◆ GetIndustryTileCallback()

uint16_t GetIndustryTileCallback | ( | CallbackID | callback,
|  | uint32_t | param1,
|  | uint32_t | param2,
|  | IndustryGfx | gfx_id,
|  | Industry * | industry,
|  | TileIndex | tile,
|  | std::span< int32_t > | regs100
| ) |  |

Definition at line 182 of file newgrf_industrytiles.cpp.

## ◆ GetNearbyIndustryTileInformation()

uint32_t GetNearbyIndustryTileInformation | ( | uint8_t | parameter,
|  | TileIndex | tile,
|  | IndustryID | index,
|  | bool | signed_offsets,
|  | bool | grf_version8
| ) |  |

Based on newhouses equivalent, but adapted for newindustries.

Parameters

  parameter | from callback. It's in fact a pair of coordinates
  tile | TileIndex from which the callback was initiated
  index | of the industry been queried for
  signed_offsets | Are the x and y offset encoded in parameter signed?
  grf_version8 | True, if we are dealing with a new NewGRF which uses GRF version >= 8.

Returns
  a construction of bits obeying the newgrf format

Definition at line 35 of file newgrf_industrytiles.cpp.

References GetIndustryIndex(), GetNearbyTile(), GetNearbyTileInformation(), IsTileType(), and MP_INDUSTRY.

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

## ◆ GetRelativePosition()

uint32_t GetRelativePosition | ( | TileIndex | tile,
|  | TileIndex | ind_tile
| ) |  |

This is the position of the tile relative to the northernmost tile of the industry.

Format: 00yxYYXX Variable Content x the x offset from the northernmost tile XX same, but stored in a byte instead of a nibble y the y offset from the northernmost tile YY same, but stored in a byte instead of a nibble

Parameters

  tile | TileIndex of the tile to evaluate
  ind_tile | northernmost tile of the industry

Definition at line 54 of file newgrf_industrytiles.cpp.

References TileX(), and TileY().

Referenced by AirportTileScopeResolver::GetVariable(), and IndustryTileScopeResolver::GetVariable().

## ◆ GetSimpleIndustryCallback()

uint16_t GetSimpleIndustryCallback | ( | CallbackID | callback,
|  | uint32_t | param1,
|  | uint32_t | param2,
|  | const IndustryTileSpec * | spec,
|  | Industry * | ind,
|  | TileIndex | tile,
|  | int |
| ) |  |

Definition at line 257 of file newgrf_industrytiles.cpp.

## ◆ IndustryDrawTileLayout()

static void IndustryDrawTileLayout | ( | const TileInfo * | ti,
|  | const DrawTileSpriteSpan & | dts,
|  | Colours | rnd_colour,
|  | uint8_t | stage
| ) |  |
| static

Definition at line 161 of file newgrf_industrytiles.cpp.

## ◆ IsSlopeRefused()

bool IsSlopeRefused | ( | Slope | current,
|  | Slope | refused
| ) |  |
| extern

Definition at line 1448 of file industry_cmd.cpp.

## ◆ PerformIndustryTileSlopeCheck()

CommandCost PerformIndustryTileSlopeCheck | ( | TileIndex | ind_base_tile,
|  | TileIndex | ind_tile,
|  | const IndustryTileSpec * | its,
|  | IndustryType | type,
|  | IndustryGfx | gfx,
|  | size_t | layout_index,
|  | uint16_t | initial_random_bits,
|  | Owner | founder,
|  | IndustryAvailabilityCallType | creation_type
| ) |  |

Check the slope of a tile of a new industry.

Parameters

  ind_base_tile | Base tile of the industry.
  ind_tile | Tile to check.
  its | Tile specification.
  type | Industry type.
  gfx | Gfx of the tile.
  layout_index | Layout.
  initial_random_bits | Random bits of industry after construction
  founder | Industry founder
  creation_type | The circumstances the industry is created under.

Returns
  Succeeded or failed command.

Definition at line 232 of file newgrf_industrytiles.cpp.

References CALLBACK_FAILED, CBID_INDTILE_SHAPE_CHECK, Industry::founder, GetErrorMessageFromLocationCallbackResult(), GetTileSlope(), IndustryTileSpec::grf_prop, GRFFilePropsBase::grffile, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Industry::location, Industry::random, IndustryTileSpec::slopes_refused, OrthogonalTileArea::tile, Industry::type, and OrthogonalTileArea::w.

Referenced by CheckIfIndustryTileSlopes().

## ◆ TriggerIndustryAnimation()

bool TriggerIndustryAnimation | ( | const Industry * | ind,
|  | IndustryAnimationTrigger | iat
| ) |  |

Definition at line 300 of file newgrf_industrytiles.cpp.

## ◆ TriggerIndustryRandomisation()

void TriggerIndustryRandomisation | ( | Industry * | ind,
|  | IndustryRandomTrigger | trigger
| ) |  |

Trigger a random trigger for all industry tiles.

Parameters

  ind | Industry to trigger.
  trigger | Trigger to trigger.

Definition at line 388 of file newgrf_industrytiles.cpp.

References DoReseedIndustry(), DoTriggerIndustryTileRandomisation(), Industry::location, and Industry::TileBelongsToIndustry().

Referenced by TriggerIndustryProduction().

## ◆ TriggerIndustryTileAnimation()

bool TriggerIndustryTileAnimation | ( | TileIndex | tile,
|  | IndustryAnimationTrigger | iat
| ) |  |

Definition at line 294 of file newgrf_industrytiles.cpp.

## ◆ TriggerIndustryTileAnimation_ConstructionStageChanged()

bool TriggerIndustryTileAnimation_ConstructionStageChanged | ( | TileIndex | tile,
|  | bool | first_call
| ) |  |

Definition at line 288 of file newgrf_industrytiles.cpp.

## ◆ TriggerIndustryTileRandomisation()

void TriggerIndustryTileRandomisation | ( | TileIndex | tile,
|  | IndustryRandomTrigger | trigger
| ) |  |

Trigger a random trigger for a single industry tile.

Parameters

  tile | Industry tile to trigger.
  trigger | Trigger to trigger.

Definition at line 375 of file newgrf_industrytiles.cpp.

References DoReseedIndustry(), DoTriggerIndustryTileRandomisation(), and Industry::GetByTile().