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

Function HandleStationPlacement

src/rail_gui.cpp:937–958  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

935 * --pasky */
936
937static void HandleStationPlacement(TileIndex start, TileIndex end)
938{
939 TileArea ta(start, end);
940 uint numtracks = ta.w;
941 uint platlength = ta.h;
942
943 if (_station_gui.axis == AXIS_X) std::swap(numtracks, platlength);
944
945 StationPickerSelection params = _station_gui;
946 RailType rt = _cur_railtype;
947 bool adjacent = _ctrl_pressed;
948
949 auto proc = [=](bool test, StationID to_join) -> bool {
950 if (test) {
951 return Command<CMD_BUILD_RAIL_STATION>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_RAIL_STATION>()), ta.tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, StationID::Invalid(), adjacent).Succeeded();
952 } else {
953 return Command<CMD_BUILD_RAIL_STATION>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, ta.tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, to_join, adjacent);
954 }
955 };
956
957 ShowSelectStationIfNeeded(ta, proc);
958}
959
960/**
961 * Test if a station/waypoint uses the default graphics.

Callers 1

OnPlaceMouseUpMethod · 0.85

Calls 5

swapFunction · 0.85
CommandFlagsToDCFlagsFunction · 0.85
InvalidFunction · 0.85
SucceededMethod · 0.80

Tested by

no test coverage detected