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

Function ReverseShipIntoTrackdir

src/ship_cmd.cpp:634–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632}
633
634static void ReverseShipIntoTrackdir(Ship *v, Trackdir trackdir)
635{
636 static constexpr Direction _trackdir_to_direction[] = {
637 DIR_NE, DIR_SE, DIR_E, DIR_E, DIR_S, DIR_S, INVALID_DIR, INVALID_DIR,
638 DIR_SW, DIR_NW, DIR_W, DIR_W, DIR_N, DIR_N, INVALID_DIR, INVALID_DIR,
639 };
640
641 v->direction = _trackdir_to_direction[trackdir];
642 assert(v->direction != INVALID_DIR);
643 v->state = TrackdirBitsToTrackBits(TrackdirToTrackdirBits(trackdir));
644
645 /* Remember our current location to avoid movement glitch */
646 v->rotation_x_pos = v->x_pos;
647 v->rotation_y_pos = v->y_pos;
648 v->cur_speed = 0;
649 v->path.clear();
650
651 v->UpdatePosition();
652 v->UpdateViewport(true, true);
653}
654
655static void ReverseShip(Ship *v)
656{

Callers 1

ShipControllerFunction · 0.85

Calls 5

TrackdirBitsToTrackBitsFunction · 0.85
TrackdirToTrackdirBitsFunction · 0.85
clearMethod · 0.45
UpdatePositionMethod · 0.45
UpdateViewportMethod · 0.45

Tested by

no test coverage detected