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

Function AddTileIndexDiffCWrap

src/map_func.h:528–535  ·  view source on GitHub ↗

* Add a TileIndexDiffC to a TileIndex and returns the new one. * * Returns tile + the diff given in diff. If the result tile would end up * outside of the map, INVALID_TILE is returned instead. * * @param tile The base tile to add the offset on * @param diff The offset to add on the tile * @return The resulting TileIndex */

Source from the content-addressed store, hash-verified

526 * @return The resulting TileIndex
527 */
528inline TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff)
529{
530 int x = TileX(tile) + diff.x;
531 int y = TileY(tile) + diff.y;
532 /* Negative value will become big positive value after cast */
533 if ((uint)x >= Map::SizeX() || (uint)y >= Map::SizeY()) return INVALID_TILE;
534 return TileXY(x, y);
535}
536
537/**
538 * Returns the diff between two tiles

Callers 6

TileLoop_WaterFunction · 0.85
CreateDesertOrRainForestFunction · 0.85
CalculateCoverageLineFunction · 0.85
AdvanceSignalAutoFillFunction · 0.85
TerraformTileHeightFunction · 0.85
InvalidateWaterRegionFunction · 0.85

Calls 3

TileXFunction · 0.85
TileYFunction · 0.85
TileXYFunction · 0.85

Tested by

no test coverage detected