From 082f969fabfe20559b8fd72395dab1e976fc5cb9 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Tue, 11 Jun 2019 18:40:41 +0100 Subject: [PATCH 1/4] Fix #9396. Pass the ghost flag to banner remove to prevent invalid removal. Previously this would never have happened because the old code would do a scenery ghost removal before calling anything else. I think this is a better way of handling it though and don't want to revert to the old method --- src/openrct2/actions/FootpathRemoveAction.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/openrct2/actions/FootpathRemoveAction.hpp b/src/openrct2/actions/FootpathRemoveAction.hpp index 34d8fce962..afac55edc2 100644 --- a/src/openrct2/actions/FootpathRemoveAction.hpp +++ b/src/openrct2/actions/FootpathRemoveAction.hpp @@ -157,7 +157,8 @@ private: auto bannerRemoveAction = BannerRemoveAction( { x, y, tileElement->base_height * 8, tileElement->AsBanner()->GetPosition() }); - bannerRemoveAction.SetFlags(GetFlags()); + auto bannerFlags = GetFlags() | (tileElement->IsGhost() ? static_cast(GAME_COMMAND_FLAG_GHOST) : 0); + bannerRemoveAction.SetFlags(bannerFlags); GameActions::ExecuteNested(&bannerRemoveAction); tileElement--; } From 501e4ba3f9ed9bb3305a1dfa68877dd65aeb92e6 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 12 Jun 2019 19:18:07 +0100 Subject: [PATCH 2/4] Increment network version --- src/openrct2/network/Network.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index aa1f25d998..cdb9d41643 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -33,7 +33,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 "41" +#define NETWORK_STREAM_VERSION "42" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr; From 357273fe7d407d19ab87b382b25a97e712ba9451 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 13 Jun 2019 19:31:49 +0100 Subject: [PATCH 3/4] Refund the removal cost of banners on paths. Found a small bug in the banner removal on paths code --- src/openrct2/actions/FootpathRemoveAction.hpp | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/openrct2/actions/FootpathRemoveAction.hpp b/src/openrct2/actions/FootpathRemoveAction.hpp index afac55edc2..eb29c3f215 100644 --- a/src/openrct2/actions/FootpathRemoveAction.hpp +++ b/src/openrct2/actions/FootpathRemoveAction.hpp @@ -90,7 +90,11 @@ public: if (footpathElement != nullptr) { footpath_queue_chain_reset(); - RemoveBannersAtElement(_x, _y, footpathElement); + auto bannerRes = RemoveBannersAtElement(_x, _y, footpathElement); + if (bannerRes->Error == GA_ERROR::OK) + { + res->Cost += bannerRes->Cost; + } footpath_remove_edges_at(_x, _y, footpathElement); map_invalidate_tile_full(_x, _y); tile_element_remove(footpathElement); @@ -101,7 +105,7 @@ public: return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_FOOTPATH_FROM_HERE); } - res->Cost = GetRefundPrice(footpathElement); + res->Cost += GetRefundPrice(footpathElement); return res; } @@ -146,8 +150,9 @@ private: * * rct2: 0x006BA23E */ - void RemoveBannersAtElement(int32_t x, int32_t y, TileElement * tileElement) const + GameActionResult::Ptr RemoveBannersAtElement(int32_t x, int32_t y, TileElement * tileElement) const { + auto result = MakeResult(); while (!(tileElement++)->IsLastForTile()) { if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH) @@ -157,9 +162,15 @@ private: auto bannerRemoveAction = BannerRemoveAction( { x, y, tileElement->base_height * 8, tileElement->AsBanner()->GetPosition() }); - auto bannerFlags = GetFlags() | (tileElement->IsGhost() ? static_cast(GAME_COMMAND_FLAG_GHOST) : 0); + bool isGhost = tileElement->IsGhost(); + auto bannerFlags = GetFlags() | (isGhost ? static_cast(GAME_COMMAND_FLAG_GHOST) : 0); bannerRemoveAction.SetFlags(bannerFlags); - GameActions::ExecuteNested(&bannerRemoveAction); + auto res = GameActions::ExecuteNested(&bannerRemoveAction); + // Ghost removal is free + if (res->Error == GA_ERROR::OK && !isGhost) + { + result->Cost += res->Cost; + } tileElement--; } } From a0b77c4bffe78707e3c6a14f1ccadbdb391f9137 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 13 Jun 2019 19:33:37 +0100 Subject: [PATCH 4/4] return the value --- src/openrct2/actions/FootpathRemoveAction.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/openrct2/actions/FootpathRemoveAction.hpp b/src/openrct2/actions/FootpathRemoveAction.hpp index eb29c3f215..7f7adb7858 100644 --- a/src/openrct2/actions/FootpathRemoveAction.hpp +++ b/src/openrct2/actions/FootpathRemoveAction.hpp @@ -156,7 +156,7 @@ private: while (!(tileElement++)->IsLastForTile()) { if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH) - return; + return result; else if (tileElement->GetType() != TILE_ELEMENT_TYPE_BANNER) continue; @@ -173,5 +173,6 @@ private: } tileElement--; } + return result; } };