* 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 */
| 526 | * @return The resulting TileIndex |
| 527 | */ |
| 528 | inline 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 |
no test coverage detected