From 55aea7188b4a1307422524f3fef79703d5b11397 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Mon, 6 Nov 2017 21:21:08 +0000 Subject: [PATCH] Fix #6617. Maze deletion no longer costs 0x800000 for certain mazes. When a maze does not have a completely hollowed out hedge the game command would return 0x8000000 as it tries to remove an element that has already been deleted. As game actions no longer use 0x80000000 to indicate a failure this would get interpreted as the refund price and cause the issue. Fix was to introduce checks when adding up the refund price. This was done rather than changing the game action so that it can be properly fixed when get_refund_price is converted into a game action --- src/openrct2/network/network.h | 2 +- src/openrct2/ride/ride.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/openrct2/network/network.h b/src/openrct2/network/network.h index 88209ce2b6..87b6dd1556 100644 --- a/src/openrct2/network/network.h +++ b/src/openrct2/network/network.h @@ -51,7 +51,7 @@ typedef struct GameAction GameAction; // This define 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 "19" +#define NETWORK_STREAM_VERSION "20" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION #ifdef __cplusplus diff --git a/src/openrct2/ride/ride.c b/src/openrct2/ride/ride.c index acf60a7d9e..9c38eb8e06 100644 --- a/src/openrct2/ride/ride.c +++ b/src/openrct2/ride/ride.c @@ -5576,8 +5576,10 @@ sint32 ride_get_refund_price(sint32 ride_id) GAME_COMMAND_SET_MAZE_TRACK, z, 0); + // Above gamecommand may remove the tile element which will cause the next game command to + // return MONEY32_UNDEFINED as it does not need to be called. - refundPrice += game_do_command( + money32 removePrice = game_do_command( x, GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_2 | (1 << 8), y + 16, @@ -5586,7 +5588,16 @@ sint32 ride_get_refund_price(sint32 ride_id) z, 0); - refundPrice += game_do_command( + if (removePrice == MONEY32_UNDEFINED && + gGameCommandErrorText == 0) + { + tile_element_iterator_restart_for_tile(&it); + continue; + } + + refundPrice += removePrice; + + removePrice = game_do_command( x + 16, GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_2 | (2 << 8), y + 16, @@ -5594,8 +5605,16 @@ sint32 ride_get_refund_price(sint32 ride_id) GAME_COMMAND_SET_MAZE_TRACK, z, 0); + if (refundPrice == MONEY32_UNDEFINED && + gGameCommandErrorText == 0) + { + tile_element_iterator_restart_for_tile(&it); + continue; + } - refundPrice += game_do_command( + refundPrice += removePrice; + + removePrice = game_do_command( x + 16, GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_2 | (3 << 8), y, @@ -5603,6 +5622,11 @@ sint32 ride_get_refund_price(sint32 ride_id) GAME_COMMAND_SET_MAZE_TRACK, z, 0); + + if (removePrice != MONEY32_UNDEFINED) + { + refundPrice += removePrice; + } tile_element_iterator_restart_for_tile(&it); } gGamePaused = oldpaused;