From 68aa5122fac691daeea83a0b695397be6acddb7e Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Mon, 18 Mar 2019 22:56:14 +0100 Subject: [PATCH] Fix #6006: Objects higher than 6 metres are considered trees --- distribution/changelog.txt | 1 + src/openrct2/actions/LandSetHeightAction.hpp | 7 ++++--- src/openrct2/actions/SmallSceneryRemoveAction.hpp | 2 +- src/openrct2/network/Network.cpp | 2 +- src/openrct2/object/SmallSceneryObject.cpp | 6 ++++++ src/openrct2/world/SmallScenery.cpp | 4 ++-- src/openrct2/world/SmallScenery.h | 2 ++ 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 9c4cf75fec..dfdbf2b9af 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -2,6 +2,7 @@ ------------------------------------------------------------------------ - Change: [#8688] Move common actions from debug menu into cheats menu. - Fix: [#5579] Network desync immediately after connecting. +- Fix: [#6006] Objects higher than 6 metres are considered trees (original bug). - Fix: [#7884] Unfinished preserved rides can be demolished with quick demolish. - Fix: [#8873] Potential crash when placing footpaths. - Fix: [#8900] Peep tracking is not synchronized. diff --git a/src/openrct2/actions/LandSetHeightAction.hpp b/src/openrct2/actions/LandSetHeightAction.hpp index 535cde1322..ab8eab6f79 100644 --- a/src/openrct2/actions/LandSetHeightAction.hpp +++ b/src/openrct2/actions/LandSetHeightAction.hpp @@ -19,6 +19,7 @@ #include "../windows/Intent.h" #include "../world/Park.h" #include "../world/Scenery.h" +#include "../world/SmallScenery.h" #include "../world/Sprite.h" #include "../world/Surface.h" #include "GameAction.h" @@ -80,7 +81,7 @@ public: if (gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL) { // Check for obstructing large trees - TileElement* tileElement = CheckTallTreeObstructions(); + TileElement* tileElement = CheckTreeObstructions(); if (tileElement != nullptr) { map_obstruction_set_error_text(tileElement); @@ -195,7 +196,7 @@ private: return STR_NONE; } - TileElement* CheckTallTreeObstructions() const + TileElement* CheckTreeObstructions() const { TileElement* tileElement = map_get_first_element_at(_coords.x / 32, _coords.y / 32); do @@ -207,7 +208,7 @@ private: if (_height + 4 < tileElement->base_height) continue; rct_scenery_entry* sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); - if (sceneryEntry->small_scenery.height > 64) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_IS_TREE)) { return tileElement; } diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.hpp b/src/openrct2/actions/SmallSceneryRemoveAction.hpp index c4cd06c141..60344bf39a 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.hpp +++ b/src/openrct2/actions/SmallSceneryRemoveAction.hpp @@ -82,7 +82,7 @@ public: // Check if allowed to remove item if (gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL) { - if (entry->small_scenery.height > 64) + if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_IS_TREE)) { res->Error = GA_ERROR::NO_CLEARANCE; res->ErrorTitle = STR_CANT_REMOVE_THIS; diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index e48d011737..9d5e4b85d4 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -31,7 +31,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 "5" +#define NETWORK_STREAM_VERSION "6" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr; diff --git a/src/openrct2/object/SmallSceneryObject.cpp b/src/openrct2/object/SmallSceneryObject.cpp index 7d6e12eb40..754d65295a 100644 --- a/src/openrct2/object/SmallSceneryObject.cpp +++ b/src/openrct2/object/SmallSceneryObject.cpp @@ -46,6 +46,11 @@ void SmallSceneryObject::ReadLegacy(IReadObjectContext* context, IStream* stream { _frameOffsets = ReadFrameOffsets(stream); } + // This crude method was used by RCT2. JSON objects have a flag for this property. + if (_legacyType.small_scenery.height > 64) + { + _legacyType.small_scenery.flags |= SMALL_SCENERY_FLAG_IS_TREE; + } GetImageTable().Read(context, stream); @@ -270,6 +275,7 @@ void SmallSceneryObject::ReadJson(IReadObjectContext* context, const json_t* roo { "allowSupportsAbove", SMALL_SCENERY_FLAG_BUILD_DIRECTLY_ONTOP }, { "supportsHavePrimaryColour", SMALL_SCENERY_FLAG_PAINT_SUPPORTS }, { "SMALL_SCENERY_FLAG27", SMALL_SCENERY_FLAG27 }, + { "isTree", SMALL_SCENERY_FLAG_IS_TREE }, }); // Determine shape flags from a shape string diff --git a/src/openrct2/world/SmallScenery.cpp b/src/openrct2/world/SmallScenery.cpp index 06e4649c55..2958c533ba 100644 --- a/src/openrct2/world/SmallScenery.cpp +++ b/src/openrct2/world/SmallScenery.cpp @@ -94,7 +94,7 @@ int32_t map_place_scenery_clear_func(TileElement** tile_element, int32_t x, int3 if (gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL) { - if (scenery->small_scenery.height > 64) + if (scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_IS_TREE)) return 1; } @@ -128,7 +128,7 @@ int32_t map_place_non_scenery_clear_func(TileElement** tile_element, int32_t x, if (gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL) { - if (scenery->small_scenery.height > 64) + if (scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_IS_TREE)) return 1; } diff --git a/src/openrct2/world/SmallScenery.h b/src/openrct2/world/SmallScenery.h index 078df1c096..870269d67d 100644 --- a/src/openrct2/world/SmallScenery.h +++ b/src/openrct2/world/SmallScenery.h @@ -44,6 +44,8 @@ enum SMALL_SCENERY_FLAGS SMALL_SCENERY_FLAG_THREE_QUARTERS = (1 << 25), // 0x2000000 SMALL_SCENERY_FLAG_PAINT_SUPPORTS = (1 << 26), // 0x4000000; used for scenery items which are support structures SMALL_SCENERY_FLAG27 = (1 << 27), // 0x8000000 + + SMALL_SCENERY_FLAG_IS_TREE = (1 << 28), // Added by OpenRCT2 }; enum