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

Function PlaceObject

src/viewport.cpp:2474–2492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2472}
2473
2474static void PlaceObject()
2475{
2476 Point pt;
2477 Window *w;
2478
2479 pt = GetTileBelowCursor();
2480 if (pt.x == -1) return;
2481
2482 if ((_thd.place_mode & HT_DRAG_MASK) == HT_POINT) {
2483 pt.x += TILE_SIZE / 2;
2484 pt.y += TILE_SIZE / 2;
2485 }
2486
2487 _tile_fract_coords.x = pt.x & TILE_UNIT_MASK;
2488 _tile_fract_coords.y = pt.y & TILE_UNIT_MASK;
2489
2490 w = _thd.GetCallbackWnd();
2491 if (w != nullptr) w->OnPlaceObject(pt, TileVirtXY(pt.x, pt.y));
2492}
2493
2494
2495bool HandleViewportClicked(const Viewport &vp, int x, int y)

Callers 1

HandleViewportClickedFunction · 0.85

Calls 4

GetTileBelowCursorFunction · 0.85
TileVirtXYFunction · 0.85
GetCallbackWndMethod · 0.80
OnPlaceObjectMethod · 0.45

Tested by

no test coverage detected