| 632 | } |
| 633 | |
| 634 | static 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 | |
| 655 | static void ReverseShip(Ship *v) |
| 656 | { |
no test coverage detected