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

Function VpSetPresizeRange

src/viewport.cpp:2853–2869  ·  view source on GitHub ↗

* Highlights all tiles between a set of two tiles. Used in dock and tunnel placement * @param from TileIndex of the first tile to highlight * @param to TileIndex of the last tile to highlight */

Source from the content-addressed store, hash-verified

2851 * @param to TileIndex of the last tile to highlight
2852 */
2853void VpSetPresizeRange(TileIndex from, TileIndex to)
2854{
2855 uint64_t distance = DistanceManhattan(from, to) + 1;
2856
2857 _thd.selend.x = TileX(to) * TILE_SIZE;
2858 _thd.selend.y = TileY(to) * TILE_SIZE;
2859 _thd.selstart.x = TileX(from) * TILE_SIZE;
2860 _thd.selstart.y = TileY(from) * TILE_SIZE;
2861 _thd.next_drawstyle = HT_RECT;
2862
2863 /* show measurement only if there is any length to speak of */
2864 if (distance > 1) {
2865 ShowMeasurementTooltips(GetEncodedString(STR_MEASURE_LENGTH, distance));
2866 } else {
2867 HideMeasurementTooltips();
2868 }
2869}
2870
2871static void VpStartPreSizing()
2872{

Callers 3

OnPlacePresizeMethod · 0.85
OnPlacePresizeMethod · 0.85
OnPlacePresizeMethod · 0.85

Calls 6

DistanceManhattanFunction · 0.85
TileXFunction · 0.85
TileYFunction · 0.85
ShowMeasurementTooltipsFunction · 0.85
HideMeasurementTooltipsFunction · 0.85
GetEncodedStringFunction · 0.70

Tested by

no test coverage detected