From df263eb1f6c08aa4f693a57b5a0fbdd4034d5c2f Mon Sep 17 00:00:00 2001 From: aw20368 Date: Tue, 4 Jun 2019 17:27:36 -0400 Subject: [PATCH] Fix #5896 Fences not always removed when building a tracked ride through (#9341) Fence removal did not account for track direction. Added the rotation for the track/fence intersection test. --- distribution/changelog.txt | 1 + src/openrct2/actions/TrackPlaceAction.hpp | 1 + src/openrct2/core/Numerics.hpp | 24 +++++++++++++++++++++++ src/openrct2/network/Network.cpp | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 421d6fadca..ecee6c3e2b 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -16,6 +16,7 @@ - Change: [#8427] Ghost elements now show up as white on the mini-map. - Change: [#8688] Move common actions from debug menu into cheats menu. - Fix: [#2294] Clients crashing the server with invalid object selection. +- Fix: [#4568, #5896] Incorrect fences removed when building a tracked ride through - Fix: [#5103] OpenGL: ride track preview not rendered. - Fix: [#5889] Giant screenshot does not work while using OpenGL renderer. - Fix: [#5579] Network desync immediately after connecting. diff --git a/src/openrct2/actions/TrackPlaceAction.hpp b/src/openrct2/actions/TrackPlaceAction.hpp index d55e38745f..ef8e7c9443 100644 --- a/src/openrct2/actions/TrackPlaceAction.hpp +++ b/src/openrct2/actions/TrackPlaceAction.hpp @@ -491,6 +491,7 @@ public: // Remove walls in the directions this track intersects uint8_t intersectingDirections = (*wallEdges)[blockIndex]; intersectingDirections ^= 0x0F; + intersectingDirections = rol4(intersectingDirections, _origin.direction); for (int32_t i = 0; i < 4; i++) { if (intersectingDirections & (1 << i)) diff --git a/src/openrct2/core/Numerics.hpp b/src/openrct2/core/Numerics.hpp index 4de93adfd8..e699e0c8a0 100644 --- a/src/openrct2/core/Numerics.hpp +++ b/src/openrct2/core/Numerics.hpp @@ -30,6 +30,18 @@ namespace Numerics return (((_UIntType)(x) << shift) | ((_UIntType)(x) >> (limits::digits - shift))); } + /** + * Bitwise left rotate of lowest 4 bits + * @param x unsigned 8-bit integer value + * @param shift positions to shift + * @return rotated value + */ + [[maybe_unused]] static constexpr uint8_t rol4(uint8_t x, size_t shift) + { + x &= 0x0F; + return (x << shift | x >> (4 - shift)) & 0x0F; + } + /** * Bitwise right rotate * @tparam _UIntType unsigned integral type @@ -44,4 +56,16 @@ namespace Numerics return (((_UIntType)(x) >> shift) | ((_UIntType)(x) << (limits::digits - shift))); } + /** + * Bitwise right rotate of lowest 4 bits + * @param x unsigned 8-bit integer value + * @param shift positions to shift + * @return rotated value + */ + [[maybe_unused]] static constexpr uint8_t ror4(uint8_t x, size_t shift) + { + x &= 0x0F; + return (x >> shift | x << (4 - shift)) & 0x0F; + } + } // namespace Numerics diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index 4bc9502f69..cdb314d5c9 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 "36" +#define NETWORK_STREAM_VERSION "37" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr;