MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetRelativePosition

Function GetRelativePosition

src/newgrf_industrytiles.cpp:54–60  ·  view source on GitHub ↗

* 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 * @param tile TileIndex of the tile to evaluat

Source from the content-addressed store, hash-verified

52 * @param ind_tile northernmost tile of the industry
53 */
54uint32_t GetRelativePosition(TileIndex tile, TileIndex ind_tile)
55{
56 uint8_t x = TileX(tile) - TileX(ind_tile);
57 uint8_t y = TileY(tile) - TileY(ind_tile);
58
59 return ((y & 0xF) << 20) | ((x & 0xF) << 16) | (y << 8) | x;
60}
61
62/* virtual */ uint32_t IndustryTileScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const
63{

Callers 2

GetVariableMethod · 0.85
GetVariableMethod · 0.85

Calls 2

TileXFunction · 0.85
TileYFunction · 0.85

Tested by

no test coverage detected