From d51b4d3191ac3f1e5e4bbcf84bc9ba646c64077a Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 25 Jan 2023 19:25:33 +0000 Subject: [PATCH] Split off SmallSceneryEntry into dedicated file (#19115) * Split off small scenery entry to new file * Move flags to new file --- .../interface/ViewportInteraction.cpp | 1 + src/openrct2-ui/windows/Scenery.cpp | 1 + src/openrct2-ui/windows/TileInspector.cpp | 1 + src/openrct2-ui/windows/TopToolbar.cpp | 1 + src/openrct2/actions/LandSetHeightAction.cpp | 1 + .../actions/SmallSceneryPlaceAction.cpp | 1 + .../actions/SmallSceneryRemoveAction.cpp | 1 + src/openrct2/actions/WallPlaceAction.cpp | 1 + src/openrct2/entity/Staff.cpp | 1 + src/openrct2/interface/Viewport.cpp | 1 + src/openrct2/libopenrct2.vcxproj | 3 +- src/openrct2/object/SmallSceneryEntry.h | 73 +++++++++++++++++++ src/openrct2/object/SmallSceneryObject.h | 1 + .../paint/tile_element/Paint.SmallScenery.cpp | 1 + src/openrct2/ride/TrackDesign.cpp | 1 + src/openrct2/ride/Vehicle.cpp | 1 + src/openrct2/world/ConstructionClearance.cpp | 1 + src/openrct2/world/Map.cpp | 1 + src/openrct2/world/MapAnimation.cpp | 1 + src/openrct2/world/MapGen.cpp | 1 + src/openrct2/world/Scenery.cpp | 18 ++--- src/openrct2/world/Scenery.h | 19 ----- src/openrct2/world/SmallScenery.cpp | 1 + src/openrct2/world/SmallScenery.h | 37 +--------- 24 files changed, 104 insertions(+), 65 deletions(-) create mode 100644 src/openrct2/object/SmallSceneryEntry.h diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 6d41295d7e..0c6c88bcea 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index 9111009a95..4c429c3972 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 613e2c701d..4a743ac5ec 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 258ac6764a..6ec150978f 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include diff --git a/src/openrct2/actions/LandSetHeightAction.cpp b/src/openrct2/actions/LandSetHeightAction.cpp index 9ab3d59da1..2188ff35f5 100644 --- a/src/openrct2/actions/LandSetHeightAction.cpp +++ b/src/openrct2/actions/LandSetHeightAction.cpp @@ -15,6 +15,7 @@ #include "../localisation/Localisation.h" #include "../localisation/StringIds.h" #include "../management/Finance.h" +#include "../object/SmallSceneryEntry.h" #include "../ride/RideData.h" #include "../windows/Intent.h" #include "../world/ConstructionClearance.h" diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/SmallSceneryPlaceAction.cpp index 88470d3a23..f6b62bcfe2 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.cpp @@ -17,6 +17,7 @@ #include "../localisation/Localisation.h" #include "../localisation/StringIds.h" #include "../management/Finance.h" +#include "../object/SmallSceneryEntry.h" #include "../ride/Ride.h" #include "../ride/TrackDesign.h" #include "../world/ConstructionClearance.h" diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.cpp b/src/openrct2/actions/SmallSceneryRemoveAction.cpp index 3692610a46..9d56920788 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.cpp +++ b/src/openrct2/actions/SmallSceneryRemoveAction.cpp @@ -17,6 +17,7 @@ #include "../localisation/Localisation.h" #include "../localisation/StringIds.h" #include "../management/Finance.h" +#include "../object/SmallSceneryEntry.h" #include "../ride/Ride.h" #include "../world/Park.h" #include "../world/SmallScenery.h" diff --git a/src/openrct2/actions/WallPlaceAction.cpp b/src/openrct2/actions/WallPlaceAction.cpp index c481c5ae12..f407acad72 100644 --- a/src/openrct2/actions/WallPlaceAction.cpp +++ b/src/openrct2/actions/WallPlaceAction.cpp @@ -11,6 +11,7 @@ #include "../OpenRCT2.h" #include "../management/Finance.h" +#include "../object/SmallSceneryEntry.h" #include "../ride/Track.h" #include "../ride/TrackDesign.h" #include "../world/Banner.h" diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index 8798a60051..c74bdd172f 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -25,6 +25,7 @@ #include "../network/network.h" #include "../object/ObjectList.h" #include "../object/ObjectManager.h" +#include "../object/SmallSceneryEntry.h" #include "../object/TerrainSurfaceObject.h" #include "../paint/tile_element/Paint.TileElement.h" #include "../peep/GuestPathfinding.h" diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index bb09c347b3..3d5863b565 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -22,6 +22,7 @@ #include "../entity/Guest.h" #include "../entity/PatrolArea.h" #include "../entity/Staff.h" +#include "../object/SmallSceneryEntry.h" #include "../paint/Paint.h" #include "../profiling/Profiling.h" #include "../ride/Ride.h" diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index f4a2c4ad0d..1e5587325f 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -315,6 +315,7 @@ + @@ -1016,4 +1017,4 @@ - + \ No newline at end of file diff --git a/src/openrct2/object/SmallSceneryEntry.h b/src/openrct2/object/SmallSceneryEntry.h new file mode 100644 index 0000000000..a9f6f570f2 --- /dev/null +++ b/src/openrct2/object/SmallSceneryEntry.h @@ -0,0 +1,73 @@ +/***************************************************************************** + * Copyright (c) 2014-2023 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../common.h" +#include "../interface/Cursors.h" + +using ObjectEntryIndex = uint16_t; + +enum SMALL_SCENERY_FLAGS : uint32_t +{ + SMALL_SCENERY_FLAG_FULL_TILE = (1 << 0), // 0x1 + SMALL_SCENERY_FLAG_VOFFSET_CENTRE = (1 << 1), // 0x2 + SMALL_SCENERY_FLAG_REQUIRE_FLAT_SURFACE = (1 << 2), // 0x4 + SMALL_SCENERY_FLAG_ROTATABLE = (1 << 3), // 0x8; when set, user can set rotation, otherwise rotation is automatic + SMALL_SCENERY_FLAG_ANIMATED = (1 << 4), // 0x10 + SMALL_SCENERY_FLAG_CAN_WITHER = (1 << 5), // 0x20 + SMALL_SCENERY_FLAG_CAN_BE_WATERED = (1 << 6), // 0x40 + SMALL_SCENERY_FLAG_ANIMATED_FG = (1 << 7), // 0x80 + SMALL_SCENERY_FLAG_DIAGONAL = (1 << 8), // 0x100 + SMALL_SCENERY_FLAG_HAS_GLASS = (1 << 9), // 0x200 + SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR = (1 << 10), // 0x400 + SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_1 = (1 << 11), // 0x800 + SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_4 = (1 << 12), // 0x1000 + SMALL_SCENERY_FLAG_IS_CLOCK = (1 << 13), // 0x2000 + SMALL_SCENERY_FLAG_SWAMP_GOO = (1 << 14), // 0x4000 + SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS = (1 << 15), // 0x8000 + SMALL_SCENERY_FLAG17 = (1 << 16), // 0x10000 + SMALL_SCENERY_FLAG_STACKABLE = (1 << 17), // 0x20000; means scenery item can be placed in the air and over water + SMALL_SCENERY_FLAG_NO_WALLS = (1 << 18), // 0x40000 + SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR = (1 << 19), // 0x80000 + SMALL_SCENERY_FLAG_NO_SUPPORTS = (1 << 20), // 0x100000 + SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED = (1 << 21), // 0x200000 + SMALL_SCENERY_FLAG_COG = (1 << 22), // 0x400000 + SMALL_SCENERY_FLAG_BUILD_DIRECTLY_ONTOP = (1 << 23), // 0x800000; means supports can be built on this object. Used for base + // blocks. + SMALL_SCENERY_FLAG_HALF_SPACE = (1 << 24), // 0x1000000 + 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 + + // Added by OpenRCT2: + SMALL_SCENERY_FLAG_IS_TREE = (1 << 28), + SMALL_SCENERY_FLAG_HAS_TERTIARY_COLOUR = (1 << 29), +}; + +struct SmallSceneryEntry +{ + StringId name; + uint32_t image; + uint32_t flags; + uint8_t height; + CursorID tool_id; + money32 price; + money32 removal_price; + uint8_t* frame_offsets; + uint16_t animation_delay; + uint16_t animation_mask; + uint16_t num_frames; + ObjectEntryIndex scenery_tab_id; + + constexpr bool HasFlag(const uint32_t _flags) const + { + return (flags & _flags) != 0; + } +}; diff --git a/src/openrct2/object/SmallSceneryObject.h b/src/openrct2/object/SmallSceneryObject.h index 95073cdcc0..230f89383e 100644 --- a/src/openrct2/object/SmallSceneryObject.h +++ b/src/openrct2/object/SmallSceneryObject.h @@ -11,6 +11,7 @@ #include "../world/Scenery.h" #include "SceneryObject.h" +#include "SmallSceneryEntry.h" #include diff --git a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp index a50275980e..0e9c6c848f 100644 --- a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp @@ -13,6 +13,7 @@ #include "../../config/Config.h" #include "../../interface/Viewport.h" #include "../../localisation/Date.h" +#include "../../object/SmallSceneryEntry.h" #include "../../profiling/Profiling.h" #include "../../ride/TrackDesign.h" #include "../../util/Util.h" diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index b29fe70798..0b0b698254 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -43,6 +43,7 @@ #include "../object/ObjectList.h" #include "../object/ObjectManager.h" #include "../object/ObjectRepository.h" +#include "../object/SmallSceneryEntry.h" #include "../object/StationObject.h" #include "../rct1/RCT1.h" #include "../rct1/Tables.h" diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 8ac45057b9..75a239a0c4 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -26,6 +26,7 @@ #include "../localisation/Formatter.h" #include "../localisation/Localisation.h" #include "../management/NewsItem.h" +#include "../object/SmallSceneryEntry.h" #include "../platform/Platform.h" #include "../profiling/Profiling.h" #include "../rct12/RCT12.h" diff --git a/src/openrct2/world/ConstructionClearance.cpp b/src/openrct2/world/ConstructionClearance.cpp index 36fa0745f7..a9c917a2aa 100644 --- a/src/openrct2/world/ConstructionClearance.cpp +++ b/src/openrct2/world/ConstructionClearance.cpp @@ -11,6 +11,7 @@ #include "../Game.h" #include "../localisation/Formatter.h" +#include "../object/SmallSceneryEntry.h" #include "../openrct2/Cheats.h" #include "../ride/Ride.h" #include "../ride/RideData.h" diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 1ef5c50b13..1b2697b0a6 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -28,6 +28,7 @@ #include "../management/Finance.h" #include "../network/network.h" #include "../object/ObjectManager.h" +#include "../object/SmallSceneryEntry.h" #include "../object/TerrainSurfaceObject.h" #include "../profiling/Profiling.h" #include "../ride/RideConstruction.h" diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index 81bcbd8248..33926f2e38 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -14,6 +14,7 @@ #include "../entity/EntityList.h" #include "../entity/Peep.h" #include "../interface/Viewport.h" +#include "../object/SmallSceneryEntry.h" #include "../object/StationObject.h" #include "../profiling/Profiling.h" #include "../ride/Ride.h" diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index 1beb634977..a55b72e714 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -19,6 +19,7 @@ #include "../localisation/StringIds.h" #include "../object/Object.h" #include "../object/ObjectManager.h" +#include "../object/SmallSceneryEntry.h" #include "../object/TerrainEdgeObject.h" #include "../object/TerrainSurfaceObject.h" #include "../platform/Platform.h" diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index d862d5b696..9e0a5a8ac0 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -25,6 +25,7 @@ #include "../network/network.h" #include "../object/ObjectList.h" #include "../object/ObjectManager.h" +#include "../object/SmallSceneryEntry.h" #include "../scenario/Scenario.h" #include "Climate.h" #include "Footpath.h" @@ -394,22 +395,22 @@ static size_t GetMaxObjectsForSceneryType(const uint8_t sceneryType) } } -static SceneryEntryBase* GetSceneryEntry(const ScenerySelection& item) +static bool IsSceneryEntryValid(const ScenerySelection& item) { switch (item.SceneryType) { case SCENERY_TYPE_SMALL: - return GetSmallSceneryEntry(item.EntryIndex); + return GetSmallSceneryEntry(item.EntryIndex) != nullptr; case SCENERY_TYPE_PATH_ITEM: - return GetFootpathItemEntry(item.EntryIndex); + return GetFootpathItemEntry(item.EntryIndex) != nullptr; case SCENERY_TYPE_WALL: - return GetWallEntry(item.EntryIndex); + return GetWallEntry(item.EntryIndex) != nullptr; case SCENERY_TYPE_LARGE: - return GetLargeSceneryEntry(item.EntryIndex); + return GetLargeSceneryEntry(item.EntryIndex) != nullptr; case SCENERY_TYPE_BANNER: - return GetBannerEntry(item.EntryIndex); + return GetBannerEntry(item.EntryIndex) != nullptr; default: - return nullptr; + return false; } } @@ -446,8 +447,7 @@ static std::vector GetAllMiscScenery() for (ObjectEntryIndex i = 0; i < maxObjects; i++) { const ScenerySelection sceneryItem = { sceneryType, i }; - const auto* sceneryEntry = GetSceneryEntry(sceneryItem); - if (sceneryEntry != nullptr) + if (IsSceneryEntryValid(sceneryItem)) { if (std::find(std::begin(nonMiscScenery), std::end(nonMiscScenery), sceneryItem) == std::end(nonMiscScenery)) { diff --git a/src/openrct2/world/Scenery.h b/src/openrct2/world/Scenery.h index 1da6aa0b90..d046513087 100644 --- a/src/openrct2/world/Scenery.h +++ b/src/openrct2/world/Scenery.h @@ -119,25 +119,6 @@ enum WALL_SCENERY_2_FLAGS WALL_SCENERY_2_ANIMATED = (1 << 4), // 0x10 }; -struct SmallSceneryEntry : SceneryEntryBase -{ - uint32_t flags; - uint8_t height; - CursorID tool_id; - money32 price; - money32 removal_price; - uint8_t* frame_offsets; - uint16_t animation_delay; - uint16_t animation_mask; - uint16_t num_frames; - ObjectEntryIndex scenery_tab_id; - - constexpr bool HasFlag(const uint32_t _flags) const - { - return (flags & _flags) != 0; - } -}; - struct WallSceneryEntry : SceneryEntryBase { CursorID tool_id; diff --git a/src/openrct2/world/SmallScenery.cpp b/src/openrct2/world/SmallScenery.cpp index 491e81b0a1..4444ad2329 100644 --- a/src/openrct2/world/SmallScenery.cpp +++ b/src/openrct2/world/SmallScenery.cpp @@ -16,6 +16,7 @@ #include "../management/Finance.h" #include "../network/network.h" #include "../object/ObjectManager.h" +#include "../object/SmallSceneryEntry.h" #include "../ride/TrackDesign.h" #include "Footpath.h" #include "Map.h" diff --git a/src/openrct2/world/SmallScenery.h b/src/openrct2/world/SmallScenery.h index 84b9310cfe..8c44ad06ff 100644 --- a/src/openrct2/world/SmallScenery.h +++ b/src/openrct2/world/SmallScenery.h @@ -13,42 +13,7 @@ #include "Map.h" #include "Scenery.h" -enum SMALL_SCENERY_FLAGS : uint32_t -{ - SMALL_SCENERY_FLAG_FULL_TILE = (1 << 0), // 0x1 - SMALL_SCENERY_FLAG_VOFFSET_CENTRE = (1 << 1), // 0x2 - SMALL_SCENERY_FLAG_REQUIRE_FLAT_SURFACE = (1 << 2), // 0x4 - SMALL_SCENERY_FLAG_ROTATABLE = (1 << 3), // 0x8; when set, user can set rotation, otherwise rotation is automatic - SMALL_SCENERY_FLAG_ANIMATED = (1 << 4), // 0x10 - SMALL_SCENERY_FLAG_CAN_WITHER = (1 << 5), // 0x20 - SMALL_SCENERY_FLAG_CAN_BE_WATERED = (1 << 6), // 0x40 - SMALL_SCENERY_FLAG_ANIMATED_FG = (1 << 7), // 0x80 - SMALL_SCENERY_FLAG_DIAGONAL = (1 << 8), // 0x100 - SMALL_SCENERY_FLAG_HAS_GLASS = (1 << 9), // 0x200 - SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR = (1 << 10), // 0x400 - SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_1 = (1 << 11), // 0x800 - SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_4 = (1 << 12), // 0x1000 - SMALL_SCENERY_FLAG_IS_CLOCK = (1 << 13), // 0x2000 - SMALL_SCENERY_FLAG_SWAMP_GOO = (1 << 14), // 0x4000 - SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS = (1 << 15), // 0x8000 - SMALL_SCENERY_FLAG17 = (1 << 16), // 0x10000 - SMALL_SCENERY_FLAG_STACKABLE = (1 << 17), // 0x20000; means scenery item can be placed in the air and over water - SMALL_SCENERY_FLAG_NO_WALLS = (1 << 18), // 0x40000 - SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR = (1 << 19), // 0x80000 - SMALL_SCENERY_FLAG_NO_SUPPORTS = (1 << 20), // 0x100000 - SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED = (1 << 21), // 0x200000 - SMALL_SCENERY_FLAG_COG = (1 << 22), // 0x400000 - SMALL_SCENERY_FLAG_BUILD_DIRECTLY_ONTOP = (1 << 23), // 0x800000; means supports can be built on this object. Used for base - // blocks. - SMALL_SCENERY_FLAG_HALF_SPACE = (1 << 24), // 0x1000000 - 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 - - // Added by OpenRCT2: - SMALL_SCENERY_FLAG_IS_TREE = (1 << 28), - SMALL_SCENERY_FLAG_HAS_TERTIARY_COLOUR = (1 << 29), -}; +struct SmallSceneryEntry; enum {