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

Method OnPlaceObject

src/road_gui.cpp:605–665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

603 }
604
605 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
606 {
607 _remove_button_clicked = this->IsWidgetLowered(WID_ROT_REMOVE);
608 _one_way_button_clicked = RoadTypeIsRoad(this->roadtype) ? this->IsWidgetLowered(WID_ROT_ONE_WAY) : false;
609 switch (this->last_started_action) {
610 case WID_ROT_ROAD_X:
611 _place_road_dir = AXIS_X;
612 _place_road_start_half_x = _tile_fract_coords.x >= 8;
613 VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_ROAD_X_DIR);
614 break;
615
616 case WID_ROT_ROAD_Y:
617 _place_road_dir = AXIS_Y;
618 _place_road_start_half_y = _tile_fract_coords.y >= 8;
619 VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_ROAD_Y_DIR);
620 break;
621
622 case WID_ROT_AUTOROAD:
623 _place_road_dir = INVALID_AXIS;
624 _place_road_start_half_x = _tile_fract_coords.x >= 8;
625 _place_road_start_half_y = _tile_fract_coords.y >= 8;
626 VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_PLACE_AUTOROAD);
627 break;
628
629 case WID_ROT_DEMOLISH:
630 PlaceProc_DemolishArea(tile);
631 break;
632
633 case WID_ROT_DEPOT:
634 Command<CMD_BUILD_ROAD_DEPOT>::Post(GetRoadTypeInfo(this->roadtype)->strings.err_depot, CcRoadDepot,
635 tile, _cur_roadtype, _road_depot_orientation);
636 break;
637
638 case WID_ROT_BUILD_WAYPOINT:
639 PlaceRoad_Waypoint(tile);
640 break;
641
642 case WID_ROT_BUS_STATION:
643 PlaceRoad_BusStation(tile);
644 break;
645
646 case WID_ROT_TRUCK_STATION:
647 PlaceRoad_TruckStation(tile);
648 break;
649
650 case WID_ROT_BUILD_BRIDGE:
651 PlaceRoad_Bridge(tile, this);
652 break;
653
654 case WID_ROT_BUILD_TUNNEL:
655 Command<CMD_BUILD_TUNNEL>::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRoadTunnel,
656 tile, TRANSPORT_ROAD, _cur_roadtype);
657 break;
658
659 case WID_ROT_CONVERT_ROAD:
660 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CONVERT_ROAD);
661 break;
662

Callers

nothing calls this directly

Calls 10

RoadTypeIsRoadFunction · 0.85
VpStartPlaceSizingFunction · 0.85
PlaceProc_DemolishAreaFunction · 0.85
GetRoadTypeInfoFunction · 0.85
PlaceRoad_WaypointFunction · 0.85
PlaceRoad_BusStationFunction · 0.85
PlaceRoad_TruckStationFunction · 0.85
PlaceRoad_BridgeFunction · 0.85
NOT_REACHEDFunction · 0.85
IsWidgetLoweredMethod · 0.80

Tested by

no test coverage detected