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

Method GetStationMiddle

src/smallmap_gui.cpp:1496–1507  ·  view source on GitHub ↗

* Get the center of the given station as point on the screen in the smallmap window. * @param st Station to find in the smallmap. * @return Point with coordinates of the station. */

Source from the content-addressed store, hash-verified

1494 * @return Point with coordinates of the station.
1495 */
1496 Point GetStationMiddle(const Station *st) const
1497 {
1498 int x = CentreBounds(st->rect.left, st->rect.right, 0);
1499 int y = CentreBounds(st->rect.top, st->rect.bottom, 0);
1500 Point ret = this->RemapTile(x, y);
1501
1502 /* Same magic 3 as in DrawVehicles; that's where I got it from.
1503 * No idea what it is, but without it the result looks bad.
1504 */
1505 ret.x -= 3 + this->subscroll;
1506 return ret;
1507 }
1508
1509 void Close([[maybe_unused]] int data) override
1510 {

Callers 1

GetSmallMapStationMiddleFunction · 0.45

Calls 2

RemapTileMethod · 0.95
CentreBoundsFunction · 0.85

Tested by

no test coverage detected