* Given a track element of the ride, find the start of the track. * It has to do this as a backwards loop in case this is an incomplete track. */
| 3923 | * It has to do this as a backwards loop in case this is an incomplete track. |
| 3924 | */ |
| 3925 | void RideGetStartOfTrack(CoordsXYE* output) |
| 3926 | { |
| 3927 | TrackBeginEnd trackBeginEnd; |
| 3928 | CoordsXYE trackElement = *output; |
| 3929 | if (trackBlockGetPrevious(trackElement, &trackBeginEnd)) |
| 3930 | { |
| 3931 | TileElement* initial_map = trackElement.element; |
| 3932 | TrackBeginEnd slowIt = trackBeginEnd; |
| 3933 | bool moveSlowIt = true; |
| 3934 | do |
| 3935 | { |
| 3936 | // Because we are working backwards, begin_element is the section at the end of a piece of track, whereas |
| 3937 | // begin_x and begin_y are the coordinates at the start of a piece of track, so we need to pass end_x and |
| 3938 | // end_y |
| 3939 | CoordsXYE lastGood = { |
| 3940 | /* .x = */ trackBeginEnd.end_x, |
| 3941 | /* .y = */ trackBeginEnd.end_y, |
| 3942 | /* .element = */ trackBeginEnd.begin_element, |
| 3943 | }; |
| 3944 | |
| 3945 | if (!trackBlockGetPrevious( |
| 3946 | { trackBeginEnd.end_x, trackBeginEnd.end_y, trackBeginEnd.begin_element }, &trackBeginEnd)) |
| 3947 | { |
| 3948 | trackElement = lastGood; |
| 3949 | break; |
| 3950 | } |
| 3951 | |
| 3952 | moveSlowIt = !moveSlowIt; |
| 3953 | if (moveSlowIt) |
| 3954 | { |
| 3955 | if (!trackBlockGetPrevious({ slowIt.end_x, slowIt.end_y, slowIt.begin_element }, &slowIt) |
| 3956 | || slowIt.begin_element == trackBeginEnd.begin_element) |
| 3957 | { |
| 3958 | break; |
| 3959 | } |
| 3960 | } |
| 3961 | } while (initial_map != trackBeginEnd.begin_element); |
| 3962 | } |
| 3963 | *output = trackElement; |
| 3964 | } |
| 3965 | |
| 3966 | /** |
| 3967 | * |
no test coverage detected