Use ride_get_start_of_track in TrackDesignSave

This commit is contained in:
jensj12 2018-04-03 16:39:05 +02:00 committed by Aaron van Geffen
parent ce0bf28cb5
commit 56fcd2ec94
3 changed files with 8 additions and 24 deletions

View File

@ -5476,6 +5476,10 @@ sint32 ride_is_valid_for_open(sint32 rideIndex, sint32 goingToBeOpen, sint32 isA
return 1; return 1;
} }
/**
* 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.
*/
void ride_get_start_of_track(CoordsXYE * output) void ride_get_start_of_track(CoordsXYE * output)
{ {
track_begin_end trackBeginEnd; track_begin_end trackBeginEnd;
@ -5515,8 +5519,6 @@ sint32 ride_get_refund_price(sint32 ride_id)
// Find the start in case it is not a complete circuit // Find the start in case it is not a complete circuit
ride_get_start_of_track(&trackElement); ride_get_start_of_track(&trackElement);
int z = trackElement.element->base_height * 8;
uint8 track_type = track_element_get_type(trackElement.element);
uint8 direction = tile_element_get_direction(trackElement.element); uint8 direction = tile_element_get_direction(trackElement.element);
// Used in the following loop to know when we have // Used in the following loop to know when we have
@ -5540,9 +5542,7 @@ sint32 ride_get_refund_price(sint32 ride_id)
if (!track_block_get_next(&trackElement, &trackElement, NULL, NULL)) if (!track_block_get_next(&trackElement, &trackElement, NULL, NULL))
break; break;
z = trackElement.element->base_height * 8;
direction = tile_element_get_direction(trackElement.element); direction = tile_element_get_direction(trackElement.element);
track_type = track_element_get_type(trackElement.element);
} while (trackElement.element != initial_map); } while (trackElement.element != initial_map);

View File

@ -1064,6 +1064,8 @@ bool track_block_get_next_from_zero(sint16 x, sint16 y, sint16 z_start, uint8 ri
bool track_block_get_previous(sint32 x, sint32 y, rct_tile_element *tileElement, track_begin_end *outTrackBeginEnd); bool track_block_get_previous(sint32 x, sint32 y, rct_tile_element *tileElement, track_begin_end *outTrackBeginEnd);
bool track_block_get_previous_from_zero(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint8 direction, track_begin_end *outTrackBeginEnd); bool track_block_get_previous_from_zero(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint8 direction, track_begin_end *outTrackBeginEnd);
void ride_get_start_of_track(CoordsXYE * output);
void window_ride_construction_update_active_elements(); void window_ride_construction_update_active_elements();
void ride_construction_remove_ghosts(); void ride_construction_remove_ghosts();
money32 ride_entrance_exit_place_ghost(sint32 rideIndex, sint32 x, sint32 y, sint32 direction, sint32 placeType, sint32 stationNum); money32 ride_entrance_exit_place_ghost(sint32 rideIndex, sint32 x, sint32 y, sint32 direction, sint32 placeType, sint32 stationNum);

View File

@ -935,33 +935,15 @@ static bool track_design_save_to_td6_for_tracked_ride(uint8 rideIndex, rct_track
{ {
Ride *ride = get_ride(rideIndex); Ride *ride = get_ride(rideIndex);
CoordsXYE trackElement; CoordsXYE trackElement;
track_begin_end trackBeginEnd;
if (!ride_try_get_origin_element(rideIndex, &trackElement)) { if (!ride_try_get_origin_element(rideIndex, &trackElement)) {
gGameCommandErrorText = STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY; gGameCommandErrorText = STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY;
return false; return false;
} }
sint32 z = 0; ride_get_start_of_track(&trackElement);
// Find the start of the track.
// It has to do this as a backwards loop in case this is an incomplete track.
if (track_block_get_previous(trackElement.x, trackElement.y, trackElement.element, &trackBeginEnd)) {
rct_tile_element* initial_map = trackElement.element;
do {
CoordsXYE lastGood = {
/* .x = */ trackBeginEnd.begin_x,
/* .y = */ trackBeginEnd.begin_y,
/* .element = */ trackBeginEnd.begin_element
};
if (!track_block_get_previous(trackBeginEnd.end_x, trackBeginEnd.end_y, trackBeginEnd.begin_element, &trackBeginEnd)) { sint32 z = trackElement.element->base_height * 8;
trackElement = lastGood;
break;
}
} while (initial_map != trackBeginEnd.begin_element);
}
z = trackElement.element->base_height * 8;
uint8 track_type = track_element_get_type(trackElement.element); uint8 track_type = track_element_get_type(trackElement.element);
uint8 direction = tile_element_get_direction(trackElement.element); uint8 direction = tile_element_get_direction(trackElement.element);
_trackSaveDirection = direction; _trackSaveDirection = direction;