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

Function PlaceRoadStop

src/road_gui.cpp:229–249  ·  view source on GitHub ↗

* Place a new road stop. * @param start_tile First tile of the area. * @param end_tile Last tile of the area. * @param stop_type Type of stop (bus/truck). * @param adjacent Allow stations directly adjacent to other stations. * @param rt The roadtypes. * @param err_msg Error message to show. * @see CcRoadStop() */

Source from the content-addressed store, hash-verified

227 * @see CcRoadStop()
228 */
229static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg)
230{
231 TileArea ta(start_tile, end_tile);
232 DiagDirection ddir = _roadstop_gui.orientation;
233 bool drive_through = ddir >= DIAGDIR_END;
234 if (drive_through) ddir = static_cast<DiagDirection>(ddir - DIAGDIR_END); // Adjust picker result to actual direction.
235 RoadStopClassID spec_class = _roadstop_gui.sel_class;
236 uint16_t spec_index = _roadstop_gui.sel_type;
237
238 auto proc = [=](bool test, StationID to_join) -> bool {
239 if (test) {
240 return Command<CMD_BUILD_ROAD_STOP>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_ROAD_STOP>()), ta.tile, ta.w, ta.h, stop_type, drive_through,
241 ddir, rt, spec_class, spec_index, StationID::Invalid(), adjacent).Succeeded();
242 } else {
243 return Command<CMD_BUILD_ROAD_STOP>::Post(err_msg, CcRoadStop, ta.tile, ta.w, ta.h, stop_type, drive_through,
244 ddir, rt, spec_class, spec_index, to_join, adjacent);
245 }
246 };
247
248 ShowSelectStationIfNeeded(ta, proc);
249}
250
251/**
252 * Place a road waypoint.

Callers 1

OnPlaceMouseUpMethod · 0.85

Calls 4

CommandFlagsToDCFlagsFunction · 0.85
InvalidFunction · 0.85
SucceededMethod · 0.80

Tested by

no test coverage detected