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

Function HandleViewportClicked

src/viewport.cpp:2495–2525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2493
2494
2495bool HandleViewportClicked(const Viewport &vp, int x, int y)
2496{
2497 const Vehicle *v = CheckClickOnVehicle(vp, x, y);
2498
2499 if (_thd.place_mode & HT_VEHICLE) {
2500 if (v != nullptr && VehicleClicked(v)) return true;
2501 }
2502
2503 /* Vehicle placement mode already handled above. */
2504 if ((_thd.place_mode & HT_DRAG_MASK) != HT_NONE) {
2505 PlaceObject();
2506 return true;
2507 }
2508
2509 if (CheckClickOnViewportSign(vp, x, y)) return true;
2510 bool result = CheckClickOnLandscape(vp, x, y);
2511
2512 if (v != nullptr) {
2513 Debug(misc, 2, "Vehicle {} (index {}) at {}", v->unitnumber, v->index, fmt::ptr(v));
2514 if (IsCompanyBuildableVehicleType(v)) {
2515 v = v->First();
2516 if (_ctrl_pressed && v->owner == _local_company) {
2517 StartStopVehicle(v, true);
2518 } else {
2519 ShowVehicleViewWindow(v);
2520 }
2521 }
2522 return true;
2523 }
2524 return result;
2525}
2526
2527void RebuildViewportOverlay(Window *w)
2528{

Callers 1

MouseLoopFunction · 0.85

Calls 10

CheckClickOnVehicleFunction · 0.85
VehicleClickedFunction · 0.85
PlaceObjectFunction · 0.85
CheckClickOnViewportSignFunction · 0.85
CheckClickOnLandscapeFunction · 0.85
StartStopVehicleFunction · 0.85
ShowVehicleViewWindowFunction · 0.85
ptrFunction · 0.50
FirstMethod · 0.45

Tested by

no test coverage detected