Fix #7568: Demolish button causes hang

Fixed by adding the standard infinite loop check. Also makes the save button save the entire track again. Affects cost of refurbishing.
This commit is contained in:
jensj12 2018-06-01 10:34:32 +02:00 committed by Michael Steenbeek
parent e60b7b3716
commit b94f5ea9d8
2 changed files with 34 additions and 6 deletions

View File

@ -34,7 +34,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "17"
#define NETWORK_STREAM_VERSION "18"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static rct_peep* _pickup_peep = nullptr;

View File

@ -5489,8 +5489,11 @@ void ride_get_start_of_track(CoordsXYE * output)
{
track_begin_end trackBeginEnd;
CoordsXYE trackElement = *output;
if (track_block_get_previous(trackElement.x, trackElement.y, trackElement.element, &trackBeginEnd)) {
if (track_block_get_previous(trackElement.x, trackElement.y, trackElement.element, &trackBeginEnd))
{
rct_tile_element* initial_map = trackElement.element;
track_begin_end slowIt = trackBeginEnd;
bool moveSlowIt = true;
do {
CoordsXYE lastGood = {
/* .x = */ trackBeginEnd.begin_x,
@ -5498,13 +5501,24 @@ void ride_get_start_of_track(CoordsXYE * output)
/* .element = */ trackBeginEnd.begin_element
};
if (!track_block_get_previous(trackBeginEnd.end_x, trackBeginEnd.end_y, trackBeginEnd.begin_element, &trackBeginEnd)) {
if (!track_block_get_previous(trackBeginEnd.end_x, trackBeginEnd.end_y, trackBeginEnd.begin_element, &trackBeginEnd))
{
trackElement = lastGood;
break;
}
moveSlowIt = !moveSlowIt;
if (moveSlowIt)
{
if (!track_block_get_previous(slowIt.end_x, slowIt.end_y, slowIt.begin_element, &slowIt) ||
slowIt.begin_element == trackBeginEnd.begin_element)
{
break;
}
}
} while (initial_map != trackBeginEnd.begin_element);
}
output = &trackElement;
*output = trackElement;
}
/**
@ -5516,7 +5530,8 @@ sint32 ride_get_refund_price(sint32 ride_id)
CoordsXYE trackElement;
money32 addedcost, cost = 0;
if (!ride_try_get_origin_element(ride_id, &trackElement)) {
if (!ride_try_get_origin_element(ride_id, &trackElement))
{
gGameCommandErrorText = STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY;
return MONEY32_UNDEFINED;
}
@ -5530,6 +5545,8 @@ sint32 ride_get_refund_price(sint32 ride_id)
// completed all of the elements and are back at the
// start.
rct_tile_element *initial_map = trackElement.element;
CoordsXYE slowIt = trackElement;
bool moveSlowIt = true;
do {
addedcost = game_do_command(
@ -5544,8 +5561,19 @@ sint32 ride_get_refund_price(sint32 ride_id)
cost += (addedcost == MONEY32_UNDEFINED) ? 0 : addedcost;
if (!track_block_get_next(&trackElement, &trackElement, NULL, NULL))
if (!track_block_get_next(&trackElement, &trackElement, nullptr, nullptr))
{
break;
}
moveSlowIt = !moveSlowIt;
if (moveSlowIt)
{
if (!track_block_get_next(&slowIt, &slowIt, nullptr, nullptr) || slowIt.element == trackElement.element)
{
break;
}
}
direction = tile_element_get_direction(trackElement.element);