From 58baa85a275fcaf3b14e82021d83a925aec32d25 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Tue, 9 May 2023 21:08:25 +0200 Subject: [PATCH] Small path additions cleanup (#20076) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Split off path addition paint calls * Replace occurences of “path bit” with “path addition” * Replace occurences of “footpath item“ with “path addition” --- .../interface/ViewportInteraction.cpp | 12 +- src/openrct2-ui/scripting/CustomMenu.cpp | 2 +- .../windows/EditorObjectSelection.cpp | 2 +- src/openrct2-ui/windows/ObjectLoadError.cpp | 2 +- src/openrct2-ui/windows/Scenery.cpp | 15 +- src/openrct2-ui/windows/TileInspector.cpp | 10 +- src/openrct2-ui/windows/TopToolbar.cpp | 14 +- src/openrct2/EditorObjectSelectionSession.cpp | 2 +- src/openrct2/actions/CheatSetAction.cpp | 6 +- .../actions/FootpathAdditionPlaceAction.cpp | 28 +- src/openrct2/actions/FootpathPlaceAction.cpp | 6 +- .../command_line/ParkInfoCommands.cpp | 2 +- src/openrct2/entity/Fountain.cpp | 10 +- src/openrct2/entity/Guest.cpp | 17 +- src/openrct2/entity/Staff.cpp | 6 +- src/openrct2/interface/Viewport.cpp | 2 +- src/openrct2/interface/Viewport.h | 2 +- src/openrct2/libopenrct2.vcxproj | 10 +- src/openrct2/management/Research.cpp | 2 +- src/openrct2/object/ObjectFactory.cpp | 8 +- src/openrct2/object/ObjectList.cpp | 2 +- src/openrct2/object/ObjectManager.cpp | 4 +- src/openrct2/object/ObjectTypes.h | 6 +- ...ootpathItemEntry.h => PathAdditionEntry.h} | 26 +- ...hItemObject.cpp => PathAdditionObject.cpp} | 48 +-- ...tpathItemObject.h => PathAdditionObject.h} | 6 +- src/openrct2/object/SceneryGroupObject.cpp | 2 +- .../paint/tile_element/Paint.Path.cpp | 272 +--------------- .../paint/tile_element/Paint.PathAddition.cpp | 295 ++++++++++++++++++ .../paint/tile_element/Paint.PathAddition.h | 20 ++ src/openrct2/rct1/S4Importer.cpp | 6 +- src/openrct2/world/Footpath.cpp | 6 +- src/openrct2/world/Scenery.cpp | 12 +- src/openrct2/world/TileElement.h | 4 +- 34 files changed, 459 insertions(+), 408 deletions(-) rename src/openrct2/object/{FootpathItemEntry.h => PathAdditionEntry.h} (55%) rename src/openrct2/object/{FootpathItemObject.cpp => PathAdditionObject.cpp} (64%) rename src/openrct2/object/{FootpathItemObject.h => PathAdditionObject.h} (87%) create mode 100644 src/openrct2/paint/tile_element/Paint.PathAddition.cpp create mode 100644 src/openrct2/paint/tile_element/Paint.PathAddition.h diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 9039a4923e..2b468f70ac 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -32,9 +32,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -54,7 +54,7 @@ static void ViewportInteractionRemoveScenery(TileElement* tileElement, const CoordsXY& mapCoords); static void ViewportInteractionRemoveFootpath(TileElement* tileElement, const CoordsXY& mapCoords); -static void ViewportInteractionRemoveFootpathItem(TileElement* tileElement, const CoordsXY& mapCoords); +static void ViewportInteractionRemovePathAddition(TileElement* tileElement, const CoordsXY& mapCoords); static void ViewportInteractionRemoveParkWall(TileElement* tileElement, const CoordsXY& mapCoords); static void ViewportInteractionRemoveLargeScenery(TileElement* tileElement, const CoordsXY& mapCoords); static void ViewportInteractionRemoveParkEntrance(TileElement* tileElement, CoordsXY mapCoords); @@ -478,7 +478,7 @@ InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoor SetMapTooltip(ft); return info; - case ViewportInteractionItem::FootpathItem: + case ViewportInteractionItem::PathAddition: { auto* pathAddEntry = tileElement->AsPath()->GetAdditionEntry(); ft.Add(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE); @@ -578,8 +578,8 @@ bool ViewportInteractionRightClick(const ScreenCoordsXY& screenCoords) case ViewportInteractionItem::Footpath: ViewportInteractionRemoveFootpath(info.Element, info.Loc); break; - case ViewportInteractionItem::FootpathItem: - ViewportInteractionRemoveFootpathItem(info.Element, info.Loc); + case ViewportInteractionItem::PathAddition: + ViewportInteractionRemovePathAddition(info.Element, info.Loc); break; case ViewportInteractionItem::ParkEntrance: ViewportInteractionRemoveParkEntrance(info.Element, info.Loc); @@ -644,7 +644,7 @@ static void ViewportInteractionRemoveFootpath(TileElement* tileElement, const Co * * rct2: 0x006A61AB */ -static void ViewportInteractionRemoveFootpathItem(TileElement* tileElement, const CoordsXY& mapCoords) +static void ViewportInteractionRemovePathAddition(TileElement* tileElement, const CoordsXY& mapCoords) { auto footpathAdditionRemoveAction = FootpathAdditionRemoveAction({ mapCoords.x, mapCoords.y, tileElement->GetBaseZ() }); GameActions::Execute(&footpathAdditionRemoveAction); diff --git a/src/openrct2-ui/scripting/CustomMenu.cpp b/src/openrct2-ui/scripting/CustomMenu.cpp index 73557bec04..f011e8aa17 100644 --- a/src/openrct2-ui/scripting/CustomMenu.cpp +++ b/src/openrct2-ui/scripting/CustomMenu.cpp @@ -71,7 +71,7 @@ namespace OpenRCT2::Scripting { "water", ViewportInteractionItem::Water }, { "scenery", ViewportInteractionItem::Scenery }, { "footpath", ViewportInteractionItem::Footpath }, - { "footpath_item", ViewportInteractionItem::FootpathItem }, + { "footpath_item", ViewportInteractionItem::PathAddition }, { "park_entrance", ViewportInteractionItem::ParkEntrance }, { "wall", ViewportInteractionItem::Wall }, { "large_scenery", ViewportInteractionItem::LargeScenery }, diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 8e26c47626..2699254c6a 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -153,7 +153,7 @@ ObjectType static TabOrder[] = { ObjectType::Ride, ObjectType::Station, ObjectType::Music, ObjectType::SceneryGroup, ObjectType::SmallScenery, ObjectType::LargeScenery, ObjectType::Walls, ObjectType::FootpathSurface, ObjectType::FootpathRailings, - ObjectType::Paths, ObjectType::PathBits, ObjectType::Banners, + ObjectType::Paths, ObjectType::PathAdditions, ObjectType::Banners, ObjectType::ParkEntrance, ObjectType::TerrainSurface, ObjectType::TerrainEdge, ObjectType::Water, }; diff --git a/src/openrct2-ui/windows/ObjectLoadError.cpp b/src/openrct2-ui/windows/ObjectLoadError.cpp index d3867ec937..0848748d3e 100644 --- a/src/openrct2-ui/windows/ObjectLoadError.cpp +++ b/src/openrct2-ui/windows/ObjectLoadError.cpp @@ -311,7 +311,7 @@ static constexpr StringId GetStringFromObjectType(const ObjectType type) return STR_OBJECT_SELECTION_PATH_SIGNS; case ObjectType::Paths: return STR_OBJECT_SELECTION_FOOTPATHS; - case ObjectType::PathBits: + case ObjectType::PathAdditions: return STR_OBJECT_SELECTION_PATH_EXTRAS; case ObjectType::SceneryGroup: return STR_OBJECT_SELECTION_SCENERY_GROUPS; diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index 6ead14eacc..aed048b69a 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -22,12 +22,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -486,9 +486,9 @@ public: OpenRCT2::ObjectManager::GetObjectEntry(tabSelectedScenery.EntryIndex)->tool_id); } else if (tabSelectedScenery.SceneryType == SCENERY_TYPE_PATH_ITEM) - { // path bit + { gCurrentToolId = static_cast( - OpenRCT2::ObjectManager::GetObjectEntry(tabSelectedScenery.EntryIndex)->tool_id); + OpenRCT2::ObjectManager::GetObjectEntry(tabSelectedScenery.EntryIndex)->tool_id); } else { // small scenery @@ -932,10 +932,9 @@ public: } } - // path bits for (ObjectEntryIndex sceneryId = 0; sceneryId < MAX_PATH_ADDITION_OBJECTS; sceneryId++) { - const auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry(sceneryId); + const auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry(sceneryId); if (sceneryEntry != nullptr) { InitSceneryEntry({ SCENERY_TYPE_PATH_ITEM, sceneryId }, sceneryEntry->scenery_tab_id); @@ -1412,7 +1411,7 @@ private: } case SCENERY_TYPE_PATH_ITEM: { - auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry(selectedScenery.EntryIndex); + auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry(selectedScenery.EntryIndex); if (sceneryEntry != nullptr) { price = sceneryEntry->price; @@ -1530,8 +1529,8 @@ private: } else if (scenerySelection.SceneryType == SCENERY_TYPE_PATH_ITEM) { - auto* pathBitEntry = OpenRCT2::ObjectManager::GetObjectEntry(scenerySelection.EntryIndex); - auto imageId = ImageId(pathBitEntry->image); + auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry(scenerySelection.EntryIndex); + auto imageId = ImageId(pathAdditionEntry->image); GfxDrawSprite(dpi, imageId, { 11, 16 }); } else diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index a5d7889bfd..0cb5aac216 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -20,12 +20,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -441,7 +441,7 @@ static constexpr TileInspectorGroupboxSettings PageGroupBoxSettings[] = { static constexpr int32_t ViewportInteractionFlags = EnumsToFlags( ViewportInteractionItem::Terrain, ViewportInteractionItem::Entity, ViewportInteractionItem::Ride, - ViewportInteractionItem::Scenery, ViewportInteractionItem::Footpath, ViewportInteractionItem::FootpathItem, + ViewportInteractionItem::Scenery, ViewportInteractionItem::Footpath, ViewportInteractionItem::PathAddition, ViewportInteractionItem::ParkEntrance, ViewportInteractionItem::Wall, ViewportInteractionItem::LargeScenery, ViewportInteractionItem::Banner); // clang-format off @@ -1152,9 +1152,9 @@ public: // Path addition if (tileElement->AsPath()->HasAddition()) { - const auto pathBitEntry = tileElement->AsPath()->GetAdditionEntry(); - StringId additionNameId = pathBitEntry != nullptr ? pathBitEntry->name - : static_cast(STR_UNKNOWN_OBJECT_TYPE); + const auto pathAdditionEntry = tileElement->AsPath()->GetAdditionEntry(); + StringId additionNameId = pathAdditionEntry != nullptr ? pathAdditionEntry->name + : static_cast(STR_UNKNOWN_OBJECT_TYPE); auto ft = Formatter(); ft.Add(additionNameId); DrawTextBasic( diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index ee0d6092a9..581e682c2a 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -54,9 +54,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -1537,7 +1537,7 @@ private: { auto flag = EnumsToFlags( ViewportInteractionItem::Scenery, ViewportInteractionItem::Wall, ViewportInteractionItem::LargeScenery, - ViewportInteractionItem::Banner, ViewportInteractionItem::FootpathItem); + ViewportInteractionItem::Banner, ViewportInteractionItem::PathAddition); auto info = GetMapCoordinatesFromPos(screenCoords, flag); switch (info.SpriteType) { @@ -1595,11 +1595,11 @@ private: } break; } - case ViewportInteractionItem::FootpathItem: + case ViewportInteractionItem::PathAddition: { auto entryIndex = info.Element->AsPath()->GetAdditionEntryIndex(); - auto* pathBitEntry = OpenRCT2::ObjectManager::GetObjectEntry(entryIndex); - if (pathBitEntry != nullptr) + auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry(entryIndex); + if (pathAdditionEntry != nullptr) { WindowScenerySetSelectedItem( { SCENERY_TYPE_PATH_ITEM, entryIndex }, std::nullopt, std::nullopt, std::nullopt, std::nullopt); @@ -1897,7 +1897,7 @@ private: Sub6E1F34UpdateScreenCoordsAndButtonsPressed(false, screenPos); // Path bits - constexpr auto flag = EnumsToFlags(ViewportInteractionItem::Footpath, ViewportInteractionItem::FootpathItem); + constexpr auto flag = EnumsToFlags(ViewportInteractionItem::Footpath, ViewportInteractionItem::PathAddition); auto info = GetMapCoordinatesFromPos(screenPos, flag); gridPos = info.Loc; @@ -2121,7 +2121,7 @@ private: Sub6E1F34UpdateScreenCoordsAndButtonsPressed(false, screenPos); // Banner - constexpr auto flag = EnumsToFlags(ViewportInteractionItem::Footpath, ViewportInteractionItem::FootpathItem); + constexpr auto flag = EnumsToFlags(ViewportInteractionItem::Footpath, ViewportInteractionItem::PathAddition); auto info = GetMapCoordinatesFromPos(screenPos, flag); gridPos = info.Loc; diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index 4cbd84ddc8..73904d02ed 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -179,7 +179,7 @@ void SetupInUseSelectionFlags() if (footpathEl->HasAddition()) { auto pathAdditionEntryIndex = footpathEl->GetAdditionEntryIndex(); - Editor::SetSelectedObject(ObjectType::PathBits, pathAdditionEntryIndex, ObjectSelectionFlags::InUse); + Editor::SetSelectedObject(ObjectType::PathAdditions, pathAdditionEntryIndex, ObjectSelectionFlags::InUse); } break; } diff --git a/src/openrct2/actions/CheatSetAction.cpp b/src/openrct2/actions/CheatSetAction.cpp index 259615b1c0..55706bb284 100644 --- a/src/openrct2/actions/CheatSetAction.cpp +++ b/src/openrct2/actions/CheatSetAction.cpp @@ -21,7 +21,7 @@ #include "../localisation/Localisation.h" #include "../localisation/StringIds.h" #include "../network/network.h" -#include "../object/FootpathItemEntry.h" +#include "../object/PathAdditionEntry.h" #include "../ride/Ride.h" #include "../ride/Vehicle.h" #include "../scenario/Scenario.h" @@ -439,8 +439,8 @@ void CheatSetAction::RemoveLitter() const if (!path->HasAddition()) continue; - auto* pathBitEntry = path->GetAdditionEntry(); - if (pathBitEntry != nullptr && pathBitEntry->flags & PATH_BIT_FLAG_IS_BIN) + auto* pathAdditionEntry = path->GetAdditionEntry(); + if (pathAdditionEntry != nullptr && pathAdditionEntry->flags & PATH_ADDITION_FLAG_IS_BIN) path->SetAdditionStatus(0xFF); } while (TileElementIteratorNext(&it)); diff --git a/src/openrct2/actions/FootpathAdditionPlaceAction.cpp b/src/openrct2/actions/FootpathAdditionPlaceAction.cpp index d22eb3a30a..950a77fb0b 100644 --- a/src/openrct2/actions/FootpathAdditionPlaceAction.cpp +++ b/src/openrct2/actions/FootpathAdditionPlaceAction.cpp @@ -15,8 +15,8 @@ #include "../interface/Window.h" #include "../localisation/StringIds.h" #include "../management/Finance.h" -#include "../object/FootpathItemEntry.h" #include "../object/ObjectEntryManager.h" +#include "../object/PathAdditionEntry.h" #include "../world/Footpath.h" #include "../world/Location.hpp" #include "../world/Park.h" @@ -95,38 +95,38 @@ GameActions::Result FootpathAdditionPlaceAction::Query() const if (_pathItemType != 0) { - auto* pathBitEntry = OpenRCT2::ObjectManager::GetObjectEntry(_pathItemType - 1); - if (pathBitEntry == nullptr) + auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry(_pathItemType - 1); + if (pathAdditionEntry == nullptr) { return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_NONE); } - uint16_t sceneryFlags = pathBitEntry->flags; + uint16_t sceneryFlags = pathAdditionEntry->flags; - if ((sceneryFlags & PATH_BIT_FLAG_DONT_ALLOW_ON_SLOPE) && pathElement->IsSloped()) + if ((sceneryFlags & PATH_ADDITION_FLAG_DONT_ALLOW_ON_SLOPE) && pathElement->IsSloped()) { return GameActions::Result( GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CANT_BUILD_THIS_ON_SLOPED_FOOTPATH); } - if ((sceneryFlags & PATH_BIT_FLAG_DONT_ALLOW_ON_QUEUE) && pathElement->IsQueue()) + if ((sceneryFlags & PATH_ADDITION_FLAG_DONT_ALLOW_ON_QUEUE) && pathElement->IsQueue()) { return GameActions::Result( GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CANNOT_PLACE_THESE_ON_QUEUE_LINE_AREA); } - if (!(sceneryFlags & (PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER | PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW)) + if (!(sceneryFlags & (PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER | PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW)) && (pathElement->GetEdges()) == 0x0F) { return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_NONE); } - if ((sceneryFlags & PATH_BIT_FLAG_IS_QUEUE_SCREEN) && !pathElement->IsQueue()) + if ((sceneryFlags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN) && !pathElement->IsQueue()) { return GameActions::Result( GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_PLACE_THESE_ON_QUEUE_AREA); } - res.Cost = pathBitEntry->price; + res.Cost = pathAdditionEntry->price; } // Should place a ghost? @@ -165,13 +165,13 @@ GameActions::Result FootpathAdditionPlaceAction::Execute() const if (_pathItemType != 0) { - auto* pathBitEntry = OpenRCT2::ObjectManager::GetObjectEntry(_pathItemType - 1); - if (pathBitEntry == nullptr) + auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry(_pathItemType - 1); + if (pathAdditionEntry == nullptr) { return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_NONE); } - res.Cost = pathBitEntry->price; + res.Cost = pathAdditionEntry->price; } if (GetFlags() & GAME_COMMAND_FLAG_GHOST) @@ -193,8 +193,8 @@ GameActions::Result FootpathAdditionPlaceAction::Execute() const pathElement->SetIsBroken(false); if (_pathItemType != 0) { - auto* pathBitEntry = OpenRCT2::ObjectManager::GetObjectEntry(_pathItemType - 1); - if (pathBitEntry != nullptr && pathBitEntry->flags & PATH_BIT_FLAG_IS_BIN) + auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry(_pathItemType - 1); + if (pathAdditionEntry != nullptr && pathAdditionEntry->flags & PATH_ADDITION_FLAG_IS_BIN) { pathElement->SetAdditionStatus(255); } diff --git a/src/openrct2/actions/FootpathPlaceAction.cpp b/src/openrct2/actions/FootpathPlaceAction.cpp index 93f7f319c4..8b0216d16a 100644 --- a/src/openrct2/actions/FootpathPlaceAction.cpp +++ b/src/openrct2/actions/FootpathPlaceAction.cpp @@ -15,7 +15,7 @@ #include "../interface/Window.h" #include "../localisation/StringIds.h" #include "../management/Finance.h" -#include "../object/FootpathItemEntry.h" +#include "../object/PathAdditionEntry.h" #include "../ride/RideConstruction.h" #include "../world/ConstructionClearance.h" #include "../world/Footpath.h" @@ -244,7 +244,7 @@ GameActions::Result FootpathPlaceAction::ElementUpdateExecute(PathElement* pathE if (_constructFlags & PathConstructFlag::IsQueue) { // remove any addition that isn't a TV or a lamp - if ((elem->flags & PATH_BIT_FLAG_IS_QUEUE_SCREEN) == 0 && (elem->flags & PATH_BIT_FLAG_LAMP) == 0) + if ((elem->flags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN) == 0 && (elem->flags & PATH_ADDITION_FLAG_LAMP) == 0) { pathElement->SetIsBroken(false); pathElement->SetAddition(0); @@ -253,7 +253,7 @@ GameActions::Result FootpathPlaceAction::ElementUpdateExecute(PathElement* pathE else { // remove all TVs - if ((elem->flags & PATH_BIT_FLAG_IS_QUEUE_SCREEN) != 0) + if ((elem->flags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN) != 0) { pathElement->SetIsBroken(false); pathElement->SetAddition(0); diff --git a/src/openrct2/command_line/ParkInfoCommands.cpp b/src/openrct2/command_line/ParkInfoCommands.cpp index b03c003bd6..f636113f57 100644 --- a/src/openrct2/command_line/ParkInfoCommands.cpp +++ b/src/openrct2/command_line/ParkInfoCommands.cpp @@ -104,7 +104,7 @@ static exitcode_t HandleObjectsInfo(CommandLineArgEnumerator* argEnumerator) ObjectType::Walls, ObjectType::Banners, ObjectType::Paths, - ObjectType::PathBits, + ObjectType::PathAdditions, ObjectType::SceneryGroup, ObjectType::ParkEntrance, ObjectType::Water, diff --git a/src/openrct2/entity/Fountain.cpp b/src/openrct2/entity/Fountain.cpp index 813f627d17..e0d2c90f7a 100644 --- a/src/openrct2/entity/Fountain.cpp +++ b/src/openrct2/entity/Fountain.cpp @@ -11,7 +11,7 @@ #include "../Game.h" #include "../core/DataSerialiser.h" -#include "../object/FootpathItemEntry.h" +#include "../object/PathAdditionEntry.h" #include "../paint/Paint.h" #include "../profiling/Profiling.h" #include "../scenario/Scenario.h" @@ -249,8 +249,8 @@ void JumpingFountain::AdvanceAnimation() bool JumpingFountain::IsJumpingFountain(const JumpingFountainType newType, const CoordsXYZ& newLoc) { - const int32_t pathBitFlagMask = newType == JumpingFountainType::Snow ? PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW - : PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER; + const int32_t pathAdditionFlagMask = newType == JumpingFountainType::Snow ? PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW + : PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER; TileElement* tileElement = MapGetFirstElementAt(newLoc); if (tileElement == nullptr) @@ -266,8 +266,8 @@ bool JumpingFountain::IsJumpingFountain(const JumpingFountainType newType, const if (!tileElement->AsPath()->HasAddition()) continue; - auto* pathBitEntry = tileElement->AsPath()->GetAdditionEntry(); - if (pathBitEntry != nullptr && pathBitEntry->flags & pathBitFlagMask) + auto* pathAdditionEntry = tileElement->AsPath()->GetAdditionEntry(); + if (pathAdditionEntry != nullptr && pathAdditionEntry->flags & pathAdditionFlagMask) { return true; } diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index a53e996631..cf1da8ddf7 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -29,9 +29,9 @@ #include "../management/Marketing.h" #include "../management/NewsItem.h" #include "../network/network.h" -#include "../object/FootpathItemEntry.h" #include "../object/LargeSceneryEntry.h" #include "../object/MusicObject.h" +#include "../object/PathAdditionEntry.h" #include "../object/WallSceneryEntry.h" #include "../peep/GuestPathfinding.h" #include "../peep/RideUseSystem.h" @@ -1169,7 +1169,7 @@ void Guest::Tick128UpdateGuest(int32_t index) if (pathElement->HasAddition() && !pathElement->AdditionIsGhost()) { auto* pathAddEntry = pathElement->GetAdditionEntry(); - if (pathAddEntry != nullptr && (pathAddEntry->flags & PATH_BIT_FLAG_IS_QUEUE_SCREEN)) + if (pathAddEntry != nullptr && (pathAddEntry->flags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN)) { found = true; } @@ -2939,7 +2939,8 @@ static PeepThoughtType PeepAssessSurroundings(int16_t centre_x, int16_t centre_y if (tileElement->AsPath()->AdditionIsGhost()) break; - if (pathAddEntry->flags & (PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER | PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW)) + if (pathAddEntry->flags + & (PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER | PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW)) { num_fountains++; break; @@ -5448,7 +5449,7 @@ void Guest::UpdateWalking() return; } - if (!(pathAddEntry->flags & PATH_BIT_FLAG_IS_BENCH)) + if (!(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BENCH)) positions_free = 9; } } @@ -5872,7 +5873,7 @@ void Guest::UpdateUsingBin() break; auto* pathAddEntry = pathElement->GetAdditionEntry(); - if (!(pathAddEntry->flags & PATH_BIT_FLAG_IS_BIN)) + if (!(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BIN)) break; if (pathElement->IsBroken()) @@ -5984,7 +5985,7 @@ static PathElement* FindBench(const CoordsXYZ& loc) continue; auto* pathAddEntry = pathElement->GetAdditionEntry(); - if (pathAddEntry == nullptr || !(pathAddEntry->flags & PATH_BIT_FLAG_IS_BENCH)) + if (pathAddEntry == nullptr || !(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BENCH)) continue; if (pathElement->IsBroken()) @@ -6073,7 +6074,7 @@ static PathElement* FindBin(const CoordsXYZ& loc) continue; auto* pathAddEntry = pathElement->GetAdditionEntry(); - if (pathAddEntry == nullptr || !(pathAddEntry->flags & PATH_BIT_FLAG_IS_BIN)) + if (pathAddEntry == nullptr || !(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BIN)) continue; if (pathElement->IsBroken()) @@ -6151,7 +6152,7 @@ static PathElement* FindBreakableElement(const CoordsXYZ& loc) continue; auto* pathAddEntry = pathElement->GetAdditionEntry(); - if (pathAddEntry == nullptr || !(pathAddEntry->flags & PATH_BIT_FLAG_BREAKABLE)) + if (pathAddEntry == nullptr || !(pathAddEntry->flags & PATH_ADDITION_FLAG_BREAKABLE)) continue; if (pathElement->IsBroken()) diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index a281f4c528..ca841e62c3 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -23,10 +23,10 @@ #include "../localisation/StringIds.h" #include "../management/Finance.h" #include "../network/network.h" -#include "../object/FootpathItemEntry.h" #include "../object/ObjectEntryManager.h" #include "../object/ObjectList.h" #include "../object/ObjectManager.h" +#include "../object/PathAdditionEntry.h" #include "../object/SceneryGroupEntry.h" #include "../object/SmallSceneryEntry.h" #include "../object/TerrainSurfaceObject.h" @@ -1243,7 +1243,7 @@ void Staff::UpdateEmptyingBin() } auto* pathAddEntry = tile_element->AsPath()->GetAdditionEntry(); - if (!(pathAddEntry->flags & PATH_BIT_FLAG_IS_BIN) || tile_element->AsPath()->IsBroken() + if (!(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BIN) || tile_element->AsPath()->IsBroken() || tile_element->AsPath()->AdditionIsGhost()) { StateReset(); @@ -1616,7 +1616,7 @@ bool Staff::UpdatePatrollingFindBin() if (pathAddEntry == nullptr) return false; - if (!(pathAddEntry->flags & PATH_BIT_FLAG_IS_BIN)) + if (!(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BIN)) return false; if (tileElement->AsPath()->IsBroken()) diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 3b257b9545..5e68b99c2f 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -1471,7 +1471,7 @@ VisibilityKind GetPaintStructVisibility(const PaintStruct* ps, uint32_t viewFlag } break; case ViewportInteractionItem::Footpath: - case ViewportInteractionItem::FootpathItem: + case ViewportInteractionItem::PathAddition: case ViewportInteractionItem::Banner: if (viewFlags & VIEWPORT_FLAG_HIDE_PATHS) { diff --git a/src/openrct2/interface/Viewport.h b/src/openrct2/interface/Viewport.h index 084314cc6e..2313e6e595 100644 --- a/src/openrct2/interface/Viewport.h +++ b/src/openrct2/interface/Viewport.h @@ -81,7 +81,7 @@ enum class ViewportInteractionItem : uint8_t Water, Scenery, Footpath, - FootpathItem, + PathAddition, ParkEntrance, Wall, LargeScenery, diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 90fe33c23f..1a6fa46dd2 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -316,8 +316,8 @@ - - + + @@ -358,6 +358,7 @@ + @@ -819,7 +820,7 @@ - + @@ -856,6 +857,7 @@ + @@ -1052,4 +1054,4 @@ - \ No newline at end of file + diff --git a/src/openrct2/management/Research.cpp b/src/openrct2/management/Research.cpp index 8177c9bcd8..2f86673429 100644 --- a/src/openrct2/management/Research.cpp +++ b/src/openrct2/management/Research.cpp @@ -540,7 +540,7 @@ bool ResearchIsInvented(ObjectType objectType, ObjectEntryIndex index) case ObjectType::LargeScenery: case ObjectType::Walls: case ObjectType::Banners: - case ObjectType::PathBits: + case ObjectType::PathAdditions: return SceneryIsInvented({ static_cast(objectType), index }); default: return true; diff --git a/src/openrct2/object/ObjectFactory.cpp b/src/openrct2/object/ObjectFactory.cpp index d48fd9289a..db7a4ecfaa 100644 --- a/src/openrct2/object/ObjectFactory.cpp +++ b/src/openrct2/object/ObjectFactory.cpp @@ -24,7 +24,6 @@ #include "AudioObject.h" #include "BannerObject.h" #include "EntranceObject.h" -#include "FootpathItemObject.h" #include "FootpathObject.h" #include "FootpathRailingsObject.h" #include "FootpathSurfaceObject.h" @@ -33,6 +32,7 @@ #include "Object.h" #include "ObjectLimits.h" #include "ObjectList.h" +#include "PathAdditionObject.h" #include "RideObject.h" #include "SceneryGroupObject.h" #include "SmallSceneryObject.h" @@ -345,8 +345,8 @@ namespace ObjectFactory case ObjectType::Paths: result = std::make_unique(); break; - case ObjectType::PathBits: - result = std::make_unique(); + case ObjectType::PathAdditions: + result = std::make_unique(); break; case ObjectType::SceneryGroup: result = std::make_unique(); @@ -393,7 +393,7 @@ namespace ObjectFactory if (s == "footpath_banner") return ObjectType::Banners; if (s == "footpath_item") - return ObjectType::PathBits; + return ObjectType::PathAdditions; if (s == "scenery_small") return ObjectType::SmallScenery; if (s == "scenery_large") diff --git a/src/openrct2/object/ObjectList.cpp b/src/openrct2/object/ObjectList.cpp index 11559f9c7b..1def7d83c0 100644 --- a/src/openrct2/object/ObjectList.cpp +++ b/src/openrct2/object/ObjectList.cpp @@ -29,7 +29,7 @@ int32_t object_entry_group_counts[] = { MAX_WALL_SCENERY_OBJECTS, // walls MAX_BANNER_OBJECTS, // banners MAX_PATH_OBJECTS, // paths - MAX_PATH_ADDITION_OBJECTS, // path bits + MAX_PATH_ADDITION_OBJECTS, // path additions MAX_SCENERY_GROUP_OBJECTS, // scenery sets MAX_PARK_ENTRANCE_OBJECTS, // park entrance MAX_WATER_OBJECTS, // water diff --git a/src/openrct2/object/ObjectManager.cpp b/src/openrct2/object/ObjectManager.cpp index fd79b209a7..5da40499b9 100644 --- a/src/openrct2/object/ObjectManager.cpp +++ b/src/openrct2/object/ObjectManager.cpp @@ -19,11 +19,11 @@ #include "../ride/RideAudio.h" #include "../util/Util.h" #include "BannerSceneryEntry.h" -#include "FootpathItemObject.h" #include "LargeSceneryObject.h" #include "Object.h" #include "ObjectList.h" #include "ObjectRepository.h" +#include "PathAdditionObject.h" #include "RideObject.h" #include "SceneryGroupObject.h" #include "SmallSceneryObject.h" @@ -479,7 +479,7 @@ private: UpdateSceneryGroupIndexes(ObjectType::LargeScenery); UpdateSceneryGroupIndexes(ObjectType::Walls); UpdateSceneryGroupIndexes(ObjectType::Banners); - UpdateSceneryGroupIndexes(ObjectType::PathBits); + UpdateSceneryGroupIndexes(ObjectType::PathAdditions); auto& list = GetObjectList(ObjectType::SceneryGroup); for (auto* loadedObject : list) diff --git a/src/openrct2/object/ObjectTypes.h b/src/openrct2/object/ObjectTypes.h index 05444663a9..71d772b943 100644 --- a/src/openrct2/object/ObjectTypes.h +++ b/src/openrct2/object/ObjectTypes.h @@ -25,7 +25,7 @@ enum class ObjectType : uint8_t Walls, Banners, Paths, - PathBits, + PathAdditions, SceneryGroup, ParkEntrance, Water, @@ -49,7 +49,7 @@ constexpr std::array ObjectTypes = { ObjectType::Walls, ObjectType::Banners, ObjectType::Paths, - ObjectType::PathBits, + ObjectType::PathAdditions, ObjectType::SceneryGroup, ObjectType::ParkEntrance, ObjectType::Water, @@ -68,7 +68,7 @@ static_assert(ObjectTypes.size() == static_cast(ObjectType::Count)); // Object types that can be saved in a park file. constexpr std::array TransientObjectTypes = { ObjectType::Ride, ObjectType::SmallScenery, ObjectType::LargeScenery, ObjectType::Walls, - ObjectType::Banners, ObjectType::Paths, ObjectType::PathBits, ObjectType::SceneryGroup, + ObjectType::Banners, ObjectType::Paths, ObjectType::PathAdditions, ObjectType::SceneryGroup, ObjectType::ParkEntrance, ObjectType::Water, ObjectType::TerrainSurface, ObjectType::TerrainEdge, ObjectType::Station, ObjectType::Music, ObjectType::FootpathSurface, ObjectType::FootpathRailings, }; diff --git a/src/openrct2/object/FootpathItemEntry.h b/src/openrct2/object/PathAdditionEntry.h similarity index 55% rename from src/openrct2/object/FootpathItemEntry.h rename to src/openrct2/object/PathAdditionEntry.h index 0dd00f3645..3b28c8db96 100644 --- a/src/openrct2/object/FootpathItemEntry.h +++ b/src/openrct2/object/PathAdditionEntry.h @@ -13,7 +13,7 @@ #include "../interface/Cursors.h" #include "ObjectTypes.h" -enum class PathBitDrawType : uint8_t +enum class PathAdditionDrawType : uint8_t { Light, Bin, @@ -23,25 +23,25 @@ enum class PathBitDrawType : uint8_t enum { - PATH_BIT_FLAG_IS_BIN = 1 << 0, - PATH_BIT_FLAG_IS_BENCH = 1 << 1, - PATH_BIT_FLAG_BREAKABLE = 1 << 2, - PATH_BIT_FLAG_LAMP = 1 << 3, - PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER = 1 << 4, - PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW = 1 << 5, - PATH_BIT_FLAG_DONT_ALLOW_ON_QUEUE = 1 << 6, - PATH_BIT_FLAG_DONT_ALLOW_ON_SLOPE = 1 << 7, - PATH_BIT_FLAG_IS_QUEUE_SCREEN = 1 << 8 + PATH_ADDITION_FLAG_IS_BIN = 1 << 0, + PATH_ADDITION_FLAG_IS_BENCH = 1 << 1, + PATH_ADDITION_FLAG_BREAKABLE = 1 << 2, + PATH_ADDITION_FLAG_LAMP = 1 << 3, + PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER = 1 << 4, + PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW = 1 << 5, + PATH_ADDITION_FLAG_DONT_ALLOW_ON_QUEUE = 1 << 6, + PATH_ADDITION_FLAG_DONT_ALLOW_ON_SLOPE = 1 << 7, + PATH_ADDITION_FLAG_IS_QUEUE_SCREEN = 1 << 8 }; -struct PathBitEntry +struct PathAdditionEntry { - static constexpr auto kObjectType = ObjectType::PathBits; + static constexpr auto kObjectType = ObjectType::PathAdditions; StringId name; uint32_t image; uint16_t flags; - PathBitDrawType draw_type; + PathAdditionDrawType draw_type; CursorID tool_id; money64 price; ObjectEntryIndex scenery_tab_id; diff --git a/src/openrct2/object/FootpathItemObject.cpp b/src/openrct2/object/PathAdditionObject.cpp similarity index 64% rename from src/openrct2/object/FootpathItemObject.cpp rename to src/openrct2/object/PathAdditionObject.cpp index b0a327d82e..8230d01863 100644 --- a/src/openrct2/object/FootpathItemObject.cpp +++ b/src/openrct2/object/PathAdditionObject.cpp @@ -7,7 +7,7 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "FootpathItemObject.h" +#include "PathAdditionObject.h" #include "../core/IStream.hpp" #include "../core/Json.hpp" @@ -20,11 +20,11 @@ #include -void FootpathItemObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStream* stream) +void PathAdditionObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStream* stream) { stream->Seek(6, OpenRCT2::STREAM_SEEK_CURRENT); _legacyType.flags = stream->ReadValue(); - _legacyType.draw_type = static_cast(stream->ReadValue()); + _legacyType.draw_type = static_cast(stream->ReadValue()); _legacyType.tool_id = static_cast(stream->ReadValue()); _legacyType.price = stream->ReadValue(); _legacyType.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL; @@ -43,7 +43,7 @@ void FootpathItemObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStre context->LogError(ObjectError::InvalidProperty, "Price can not be free or negative."); } - // Add path bits to 'Signs and items for footpaths' group, rather than lumping them in the Miscellaneous tab. + // Add path additions to 'Signs and items for footpaths' group, rather than lumping them in the Miscellaneous tab. // Since this is already done the other way round for original items, avoid adding those to prevent duplicates. auto identifier = GetLegacyIdentifier(); @@ -61,7 +61,7 @@ void FootpathItemObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStre } } -void FootpathItemObject::Load() +void PathAdditionObject::Load() { GetStringTable().Sort(); _legacyType.name = LanguageAllocateObjectString(GetName()); @@ -70,7 +70,7 @@ void FootpathItemObject::Load() _legacyType.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL; } -void FootpathItemObject::Unload() +void PathAdditionObject::Unload() { LanguageFreeObjectString(_legacyType.name); UnloadImages(); @@ -79,28 +79,28 @@ void FootpathItemObject::Unload() _legacyType.image = 0; } -void FootpathItemObject::DrawPreview(DrawPixelInfo& dpi, int32_t width, int32_t height) const +void PathAdditionObject::DrawPreview(DrawPixelInfo& dpi, int32_t width, int32_t height) const { auto screenCoords = ScreenCoordsXY{ width / 2, height / 2 }; GfxDrawSprite(dpi, ImageId(_legacyType.image), screenCoords - ScreenCoordsXY{ 22, 24 }); } -static PathBitDrawType ParseDrawType(const std::string& s) +static PathAdditionDrawType ParseDrawType(const std::string& s) { if (s == "lamp") - return PathBitDrawType::Light; + return PathAdditionDrawType::Light; if (s == "bin") - return PathBitDrawType::Bin; + return PathAdditionDrawType::Bin; if (s == "bench") - return PathBitDrawType::Bench; + return PathAdditionDrawType::Bench; if (s == "fountain") - return PathBitDrawType::JumpingFountain; - return PathBitDrawType::Light; + return PathAdditionDrawType::JumpingFountain; + return PathAdditionDrawType::Light; } -void FootpathItemObject::ReadJson(IReadObjectContext* context, json_t& root) +void PathAdditionObject::ReadJson(IReadObjectContext* context, json_t& root) { - Guard::Assert(root.is_object(), "FootpathItemObject::ReadJson expects parameter root to be object"); + Guard::Assert(root.is_object(), "PathAdditionObject::ReadJson expects parameter root to be object"); json_t properties = root["properties"]; @@ -116,15 +116,15 @@ void FootpathItemObject::ReadJson(IReadObjectContext* context, json_t& root) _legacyType.flags = Json::GetFlags( properties, { - { "isBin", PATH_BIT_FLAG_IS_BIN, Json::FlagType::Normal }, - { "isBench", PATH_BIT_FLAG_IS_BENCH, Json::FlagType::Normal }, - { "isBreakable", PATH_BIT_FLAG_BREAKABLE, Json::FlagType::Normal }, - { "isLamp", PATH_BIT_FLAG_LAMP, Json::FlagType::Normal }, - { "isJumpingFountainWater", PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER, Json::FlagType::Normal }, - { "isJumpingFountainSnow", PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW, Json::FlagType::Normal }, - { "isAllowedOnQueue", PATH_BIT_FLAG_DONT_ALLOW_ON_QUEUE, Json::FlagType::Inverted }, - { "isAllowedOnSlope", PATH_BIT_FLAG_DONT_ALLOW_ON_SLOPE, Json::FlagType::Inverted }, - { "isTelevision", PATH_BIT_FLAG_IS_QUEUE_SCREEN, Json::FlagType::Normal }, + { "isBin", PATH_ADDITION_FLAG_IS_BIN, Json::FlagType::Normal }, + { "isBench", PATH_ADDITION_FLAG_IS_BENCH, Json::FlagType::Normal }, + { "isBreakable", PATH_ADDITION_FLAG_BREAKABLE, Json::FlagType::Normal }, + { "isLamp", PATH_ADDITION_FLAG_LAMP, Json::FlagType::Normal }, + { "isJumpingFountainWater", PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER, Json::FlagType::Normal }, + { "isJumpingFountainSnow", PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW, Json::FlagType::Normal }, + { "isAllowedOnQueue", PATH_ADDITION_FLAG_DONT_ALLOW_ON_QUEUE, Json::FlagType::Inverted }, + { "isAllowedOnSlope", PATH_ADDITION_FLAG_DONT_ALLOW_ON_SLOPE, Json::FlagType::Inverted }, + { "isTelevision", PATH_ADDITION_FLAG_IS_QUEUE_SCREEN, Json::FlagType::Normal }, }); // clang-format on } diff --git a/src/openrct2/object/FootpathItemObject.h b/src/openrct2/object/PathAdditionObject.h similarity index 87% rename from src/openrct2/object/FootpathItemObject.h rename to src/openrct2/object/PathAdditionObject.h index 2287b9e8aa..18e9721fb7 100644 --- a/src/openrct2/object/FootpathItemObject.h +++ b/src/openrct2/object/PathAdditionObject.h @@ -9,13 +9,13 @@ #pragma once -#include "FootpathItemEntry.h" +#include "PathAdditionEntry.h" #include "SceneryObject.h" -class FootpathItemObject final : public SceneryObject +class PathAdditionObject final : public SceneryObject { private: - PathBitEntry _legacyType = {}; + PathAdditionEntry _legacyType = {}; public: void* GetLegacyData() override diff --git a/src/openrct2/object/SceneryGroupObject.cpp b/src/openrct2/object/SceneryGroupObject.cpp index 7a6d32ca66..db9c7f775d 100644 --- a/src/openrct2/object/SceneryGroupObject.cpp +++ b/src/openrct2/object/SceneryGroupObject.cpp @@ -90,7 +90,7 @@ static std::optional GetSceneryType(const ObjectType type) return SCENERY_TYPE_WALL; case ObjectType::Banners: return SCENERY_TYPE_BANNER; - case ObjectType::PathBits: + case ObjectType::PathAdditions: return SCENERY_TYPE_PATH_ITEM; default: return std::nullopt; diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 27a66498a0..df56af5840 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -22,12 +22,12 @@ #include "../../localisation/Formatter.h" #include "../../localisation/Formatting.h" #include "../../localisation/Localisation.h" -#include "../../object/FootpathItemEntry.h" #include "../../object/FootpathObject.h" #include "../../object/FootpathRailingsObject.h" #include "../../object/FootpathSurfaceObject.h" #include "../../object/ObjectList.h" #include "../../object/ObjectManager.h" +#include "../../object/PathAdditionEntry.h" #include "../../profiling/Profiling.h" #include "../../ride/Ride.h" #include "../../ride/Track.h" @@ -41,6 +41,7 @@ #include "../Boundbox.h" #include "../Paint.SessionFlags.h" #include "../Supports.h" +#include "Paint.PathAddition.h" #include "Paint.Surface.h" #include "Paint.TileElement.h" @@ -98,194 +99,6 @@ void PathPaintPoleSupport( PaintSession& session, const PathElement& pathElement, int16_t height, const FootpathPaintInfo& pathPaintInfo, bool hasSupports, ImageId imageTemplate, ImageId sceneryImageTemplate); -static ImageIndex GetEdgeImageOffset(edge_t edge) -{ - switch (edge) - { - case EDGE_NE: - return 1; - case EDGE_SE: - return 2; - case EDGE_SW: - return 3; - case EDGE_NW: - return 4; - default: - return 0; - } -} - -static ImageIndex GetFootpathLampImage(const PathBitEntry& pathBitEntry, edge_t edge, bool isBroken) -{ - auto offset = GetEdgeImageOffset(edge); - if (offset == 0) - return ImageIndexUndefined; - return pathBitEntry.image + offset + (isBroken ? 4 : 0); -} - -static ImageIndex GetFootpathBinImage(const PathBitEntry& pathBitEntry, edge_t edge, bool isBroken, bool isFull) -{ - auto offset = GetEdgeImageOffset(edge); - if (offset == 0) - return ImageIndexUndefined; - - auto stateOffset = isBroken ? 4 : (isFull ? 8 : 0); - return pathBitEntry.image + offset + stateOffset; -} - -static ImageIndex GetFootpathBenchImage(const PathBitEntry& pathBitEntry, edge_t edge, bool isBroken) -{ - auto offset = GetEdgeImageOffset(edge); - if (offset == 0) - return ImageIndexUndefined; - return pathBitEntry.image + offset + (isBroken ? 4 : 0); -} - -/* rct2: 0x006A5AE5 */ -static void PathBitLightsPaint( - PaintSession& session, const PathBitEntry& pathBitEntry, const PathElement& pathElement, int32_t height, uint8_t edges, - ImageId imageTemplate) -{ - if (pathElement.IsSloped()) - height += 8; - - auto isBroken = pathElement.IsBroken(); - if (!(edges & EDGE_NE)) - { - auto imageIndex = GetFootpathLampImage(pathBitEntry, EDGE_NE, isBroken); - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 2, 16, height }, { { 6, 8, height + 2 }, { 0, 16, 23 } }); - } - if (!(edges & EDGE_SE)) - { - auto imageIndex = GetFootpathLampImage(pathBitEntry, EDGE_SE, isBroken); - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 16, 30, height }, { { 8, 23, height + 2 }, { 16, 0, 23 } }); - } - if (!(edges & EDGE_SW)) - { - auto imageIndex = GetFootpathLampImage(pathBitEntry, EDGE_SW, isBroken); - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 30, 16, height }, { { 23, 8, height + 2 }, { 0, 16, 23 } }); - } - if (!(edges & EDGE_NW)) - { - auto imageIndex = GetFootpathLampImage(pathBitEntry, EDGE_NW, isBroken); - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 16, 2, height }, { { 8, 6, height + 2 }, { 16, 0, 23 } }); - } -} - -static bool IsBinFull(PaintSession& session, const PathElement& pathElement, edge_t edge) -{ - switch (edge) - { - case EDGE_NE: - return !(pathElement.GetAdditionStatus() & Numerics::ror8(0x03, (2 * session.CurrentRotation))); - case EDGE_SE: - return !(pathElement.GetAdditionStatus() & Numerics::ror8(0x0C, (2 * session.CurrentRotation))); - case EDGE_SW: - return !(pathElement.GetAdditionStatus() & Numerics::ror8(0x30, (2 * session.CurrentRotation))); - case EDGE_NW: - return !(pathElement.GetAdditionStatus() & Numerics::ror8(0xC0, (2 * session.CurrentRotation))); - default: - return false; - } -} - -/* rct2: 0x006A5C94 */ -static void PathBitBinsPaint( - PaintSession& session, const PathBitEntry& pathBitEntry, const PathElement& pathElement, int32_t height, uint8_t edges, - ImageId imageTemplate) -{ - if (pathElement.IsSloped()) - height += 8; - - bool binsAreVandalised = pathElement.IsBroken(); - auto highlightPathIssues = (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES) != 0; - - if (!(edges & EDGE_NE)) - { - auto binIsFull = IsBinFull(session, pathElement, EDGE_NE); - auto imageIndex = GetFootpathBinImage(pathBitEntry, EDGE_NE, binsAreVandalised, binIsFull); - if (!highlightPathIssues || binIsFull || binsAreVandalised) - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 7, 16, height }, { { 6, 8, height + 2 }, { 0, 16, 7 } }); - } - if (!(edges & EDGE_SE)) - { - auto binIsFull = IsBinFull(session, pathElement, EDGE_SE); - auto imageIndex = GetFootpathBinImage(pathBitEntry, EDGE_SE, binsAreVandalised, binIsFull); - if (!highlightPathIssues || binIsFull || binsAreVandalised) - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 16, 25, height }, { { 8, 23, height + 2 }, { 16, 0, 7 } }); - } - if (!(edges & EDGE_SW)) - { - auto binIsFull = IsBinFull(session, pathElement, EDGE_SW); - auto imageIndex = GetFootpathBinImage(pathBitEntry, EDGE_SW, binsAreVandalised, binIsFull); - if (!highlightPathIssues || binIsFull || binsAreVandalised) - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 25, 16, height }, { { 23, 8, height + 2 }, { 0, 16, 7 } }); - } - if (!(edges & EDGE_NW)) - { - auto binIsFull = IsBinFull(session, pathElement, EDGE_NW); - auto imageIndex = GetFootpathBinImage(pathBitEntry, EDGE_NW, binsAreVandalised, binIsFull); - if (!highlightPathIssues || binIsFull || binsAreVandalised) - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 16, 7, height }, { { 8, 6, height + 2 }, { 16, 0, 7 } }); - } -} - -/* rct2: 0x006A5E81 */ -static void PathBitBenchesPaint( - PaintSession& session, const PathBitEntry& pathBitEntry, const PathElement& pathElement, int32_t height, uint8_t edges, - ImageId imageTemplate) -{ - auto isBroken = pathElement.IsBroken(); - if (!(edges & EDGE_NE)) - { - auto imageIndex = GetFootpathBenchImage(pathBitEntry, EDGE_NE, isBroken); - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 7, 16, height }, { { 6, 8, height + 2 }, { 0, 16, 7 } }); - } - if (!(edges & EDGE_SE)) - { - auto imageIndex = GetFootpathBenchImage(pathBitEntry, EDGE_SE, isBroken); - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 16, 25, height }, { { 8, 23, height + 2 }, { 16, 0, 7 } }); - } - - if (!(edges & EDGE_SW)) - { - auto imageIndex = GetFootpathBenchImage(pathBitEntry, EDGE_SW, isBroken); - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 25, 16, height }, { { 23, 8, height + 2 }, { 0, 16, 7 } }); - } - - if (!(edges & EDGE_NW)) - { - auto imageIndex = GetFootpathBenchImage(pathBitEntry, EDGE_NW, isBroken); - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 16, 7, height }, { { 8, 6, height + 2 }, { 16, 0, 7 } }); - } -} - -/* rct2: 0x006A6008 */ -static void PathBitJumpingFountainsPaint( - PaintSession& session, const PathBitEntry& pathBitEntry, int32_t height, ImageId imageTemplate, DrawPixelInfo& dpi) -{ - if (dpi.zoom_level > ZoomLevel{ 0 }) - return; - - auto imageId = imageTemplate.WithIndex(pathBitEntry.image); - PaintAddImageAsParent(session, imageId.WithIndexOffset(1), { 0, 0, height }, { { 6, 8, height + 2 }, { 1, 1, 2 } }); - PaintAddImageAsParent(session, imageId.WithIndexOffset(2), { 0, 0, height }, { { 8, 23, height + 2 }, { 1, 1, 2 } }); - PaintAddImageAsParent(session, imageId.WithIndexOffset(3), { 0, 0, height }, { { 23, 8, height + 2 }, { 1, 1, 2 } }); - PaintAddImageAsParent(session, imageId.WithIndexOffset(4), { 0, 0, height }, { { 8, 6, height + 2 }, { 1, 1, 2 } }); -} - /** * rct2: 0x006A4101 * @param tile_element (esi) @@ -787,54 +600,7 @@ static void Sub6A3F61( { if (pathElement.HasAddition()) { - session.InteractionType = ViewportInteractionItem::FootpathItem; - if (sceneryImageTemplate.IsRemap()) - { - session.InteractionType = ViewportInteractionItem::None; - } - - // Draw additional path bits (bins, benches, lamps, queue screens) - auto* pathAddEntry = pathElement.GetAdditionEntry(); - bool drawAddition = true; - // Can be null if the object is not loaded. - if (pathAddEntry == nullptr - || ((session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES) && !(pathElement.IsBroken()) - && pathAddEntry->draw_type != PathBitDrawType::Bin)) - { - drawAddition = false; - } - - if (drawAddition) - { - switch (pathAddEntry->draw_type) - { - case PathBitDrawType::Light: - PathBitLightsPaint( - session, *pathAddEntry, pathElement, height, static_cast(connectedEdges), - sceneryImageTemplate); - break; - case PathBitDrawType::Bin: - PathBitBinsPaint( - session, *pathAddEntry, pathElement, height, static_cast(connectedEdges), - sceneryImageTemplate); - break; - case PathBitDrawType::Bench: - PathBitBenchesPaint( - session, *pathAddEntry, pathElement, height, static_cast(connectedEdges), - sceneryImageTemplate); - break; - case PathBitDrawType::JumpingFountain: - PathBitJumpingFountainsPaint(session, *pathAddEntry, height, sceneryImageTemplate, session.DPI); - break; - } - - session.InteractionType = ViewportInteractionItem::Footpath; - - if (sceneryImageTemplate.IsRemap()) - { - session.InteractionType = ViewportInteractionItem::None; - } - } + Sub6A3F61PathAddition(session, pathElement, height, sceneryImageTemplate); } } @@ -984,38 +750,6 @@ static void PaintHeightMarkers(PaintSession& session, const PathElement& pathEl) } } -static void PaintLampLightEffects(PaintSession& session, const PathElement& pathEl, uint16_t height) -{ - PROFILED_FUNCTION(); - - if (LightFXIsAvailable()) - { - if (pathEl.HasAddition() && !(pathEl.IsBroken())) - { - auto* pathAddEntry = pathEl.GetAdditionEntry(); - if (pathAddEntry != nullptr && pathAddEntry->flags & PATH_BIT_FLAG_LAMP) - { - if (!(pathEl.GetEdges() & EDGE_NE)) - { - LightFXAdd3DLightMagicFromDrawingTile(session.MapPosition, -16, 0, height + 23, LightType::Lantern3); - } - if (!(pathEl.GetEdges() & EDGE_SE)) - { - LightFXAdd3DLightMagicFromDrawingTile(session.MapPosition, 0, 16, height + 23, LightType::Lantern3); - } - if (!(pathEl.GetEdges() & EDGE_SW)) - { - LightFXAdd3DLightMagicFromDrawingTile(session.MapPosition, 16, 0, height + 23, LightType::Lantern3); - } - if (!(pathEl.GetEdges() & EDGE_NW)) - { - LightFXAdd3DLightMagicFromDrawingTile(session.MapPosition, 0, -16, height + 23, LightType::Lantern3); - } - } - } - } -} - /** * rct2: 0x0006A3590 */ diff --git a/src/openrct2/paint/tile_element/Paint.PathAddition.cpp b/src/openrct2/paint/tile_element/Paint.PathAddition.cpp new file mode 100644 index 0000000000..dc4e3e324d --- /dev/null +++ b/src/openrct2/paint/tile_element/Paint.PathAddition.cpp @@ -0,0 +1,295 @@ +/***************************************************************************** + * 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. + *****************************************************************************/ + +#include "Paint.PathAddition.h" + +#include "../../core/Numerics.hpp" +#include "../../drawing/LightFX.h" +#include "../../object/PathAdditionEntry.h" +#include "../../profiling/Profiling.h" +#include "Paint.TileElement.h" + +static ImageIndex GetEdgeImageOffset(edge_t edge) +{ + switch (edge) + { + case EDGE_NE: + return 1; + case EDGE_SE: + return 2; + case EDGE_SW: + return 3; + case EDGE_NW: + return 4; + default: + return 0; + } +} + +static ImageIndex GetFootpathLampImage(const PathAdditionEntry& pathAdditionEntry, edge_t edge, bool isBroken) +{ + auto offset = GetEdgeImageOffset(edge); + if (offset == 0) + return ImageIndexUndefined; + return pathAdditionEntry.image + offset + (isBroken ? 4 : 0); +} + +static ImageIndex GetFootpathBinImage(const PathAdditionEntry& pathAdditionEntry, edge_t edge, bool isBroken, bool isFull) +{ + auto offset = GetEdgeImageOffset(edge); + if (offset == 0) + return ImageIndexUndefined; + + auto stateOffset = isBroken ? 4 : (isFull ? 8 : 0); + return pathAdditionEntry.image + offset + stateOffset; +} + +static ImageIndex GetFootpathBenchImage(const PathAdditionEntry& pathAdditionEntry, edge_t edge, bool isBroken) +{ + auto offset = GetEdgeImageOffset(edge); + if (offset == 0) + return ImageIndexUndefined; + return pathAdditionEntry.image + offset + (isBroken ? 4 : 0); +} + +/* rct2: 0x006A5AE5 */ +static void PathAdditionLightsPaint( + PaintSession& session, const PathAdditionEntry& pathAdditionEntry, const PathElement& pathElement, int32_t height, + uint8_t edges, ImageId imageTemplate) +{ + if (pathElement.IsSloped()) + height += 8; + + auto isBroken = pathElement.IsBroken(); + if (edges & EDGE_NE) + { + auto imageIndex = GetFootpathLampImage(pathAdditionEntry, EDGE_NE, isBroken); + PaintAddImageAsParent( + session, imageTemplate.WithIndex(imageIndex), { 2, 16, height }, { { 6, 8, height + 2 }, { 0, 16, 23 } }); + } + if (edges & EDGE_SE) + { + auto imageIndex = GetFootpathLampImage(pathAdditionEntry, EDGE_SE, isBroken); + PaintAddImageAsParent( + session, imageTemplate.WithIndex(imageIndex), { 16, 30, height }, { { 8, 23, height + 2 }, { 16, 0, 23 } }); + } + if (edges & EDGE_SW) + { + auto imageIndex = GetFootpathLampImage(pathAdditionEntry, EDGE_SW, isBroken); + PaintAddImageAsParent( + session, imageTemplate.WithIndex(imageIndex), { 30, 16, height }, { { 23, 8, height + 2 }, { 0, 16, 23 } }); + } + if (edges & EDGE_NW) + { + auto imageIndex = GetFootpathLampImage(pathAdditionEntry, EDGE_NW, isBroken); + PaintAddImageAsParent( + session, imageTemplate.WithIndex(imageIndex), { 16, 2, height }, { { 8, 6, height + 2 }, { 16, 0, 23 } }); + } +} + +static bool IsBinFull(PaintSession& session, const PathElement& pathElement, edge_t edge) +{ + switch (edge) + { + case EDGE_NE: + return !(pathElement.GetAdditionStatus() & Numerics::ror8(0x03, (2 * session.CurrentRotation))); + case EDGE_SE: + return !(pathElement.GetAdditionStatus() & Numerics::ror8(0x0C, (2 * session.CurrentRotation))); + case EDGE_SW: + return !(pathElement.GetAdditionStatus() & Numerics::ror8(0x30, (2 * session.CurrentRotation))); + case EDGE_NW: + return !(pathElement.GetAdditionStatus() & Numerics::ror8(0xC0, (2 * session.CurrentRotation))); + default: + return false; + } +} + +/* rct2: 0x006A5C94 */ +static void PathAdditionBinsPaint( + PaintSession& session, const PathAdditionEntry& pathAdditionEntry, const PathElement& pathElement, int32_t height, + uint8_t edges, ImageId imageTemplate) +{ + if (pathElement.IsSloped()) + height += 8; + + bool binsAreVandalised = pathElement.IsBroken(); + auto highlightPathIssues = (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES) != 0; + + if (edges & EDGE_NE) + { + auto binIsFull = IsBinFull(session, pathElement, EDGE_NE); + auto imageIndex = GetFootpathBinImage(pathAdditionEntry, EDGE_NE, binsAreVandalised, binIsFull); + if (!highlightPathIssues || binIsFull || binsAreVandalised) + PaintAddImageAsParent( + session, imageTemplate.WithIndex(imageIndex), { 7, 16, height }, { { 6, 8, height + 2 }, { 0, 16, 7 } }); + } + if (edges & EDGE_SE) + { + auto binIsFull = IsBinFull(session, pathElement, EDGE_SE); + auto imageIndex = GetFootpathBinImage(pathAdditionEntry, EDGE_SE, binsAreVandalised, binIsFull); + if (!highlightPathIssues || binIsFull || binsAreVandalised) + PaintAddImageAsParent( + session, imageTemplate.WithIndex(imageIndex), { 16, 25, height }, { { 8, 23, height + 2 }, { 16, 0, 7 } }); + } + if (edges & EDGE_SW) + { + auto binIsFull = IsBinFull(session, pathElement, EDGE_SW); + auto imageIndex = GetFootpathBinImage(pathAdditionEntry, EDGE_SW, binsAreVandalised, binIsFull); + if (!highlightPathIssues || binIsFull || binsAreVandalised) + PaintAddImageAsParent( + session, imageTemplate.WithIndex(imageIndex), { 25, 16, height }, { { 23, 8, height + 2 }, { 0, 16, 7 } }); + } + if (edges & EDGE_NW) + { + auto binIsFull = IsBinFull(session, pathElement, EDGE_NW); + auto imageIndex = GetFootpathBinImage(pathAdditionEntry, EDGE_NW, binsAreVandalised, binIsFull); + if (!highlightPathIssues || binIsFull || binsAreVandalised) + PaintAddImageAsParent( + session, imageTemplate.WithIndex(imageIndex), { 16, 7, height }, { { 8, 6, height + 2 }, { 16, 0, 7 } }); + } +} + +/* rct2: 0x006A5E81 */ +static void PathAdditionBenchesPaint( + PaintSession& session, const PathAdditionEntry& pathAdditionEntry, const PathElement& pathElement, int32_t height, + uint8_t edges, ImageId imageTemplate) +{ + auto isBroken = pathElement.IsBroken(); + if (edges & EDGE_NE) + { + auto imageIndex = GetFootpathBenchImage(pathAdditionEntry, EDGE_NE, isBroken); + PaintAddImageAsParent( + session, imageTemplate.WithIndex(imageIndex), { 7, 16, height }, { { 6, 8, height + 2 }, { 0, 16, 7 } }); + } + if (edges & EDGE_SE) + { + auto imageIndex = GetFootpathBenchImage(pathAdditionEntry, EDGE_SE, isBroken); + PaintAddImageAsParent( + session, imageTemplate.WithIndex(imageIndex), { 16, 25, height }, { { 8, 23, height + 2 }, { 16, 0, 7 } }); + } + + if (edges & EDGE_SW) + { + auto imageIndex = GetFootpathBenchImage(pathAdditionEntry, EDGE_SW, isBroken); + PaintAddImageAsParent( + session, imageTemplate.WithIndex(imageIndex), { 25, 16, height }, { { 23, 8, height + 2 }, { 0, 16, 7 } }); + } + + if (edges & EDGE_NW) + { + auto imageIndex = GetFootpathBenchImage(pathAdditionEntry, EDGE_NW, isBroken); + PaintAddImageAsParent( + session, imageTemplate.WithIndex(imageIndex), { 16, 7, height }, { { 8, 6, height + 2 }, { 16, 0, 7 } }); + } +} + +/* rct2: 0x006A6008 */ +static void PathAdditionJumpingFountainsPaint( + PaintSession& session, const PathAdditionEntry& pathAdditionEntry, int32_t height, ImageId imageTemplate, + DrawPixelInfo& dpi) +{ + if (dpi.zoom_level > ZoomLevel{ 0 }) + return; + + auto imageId = imageTemplate.WithIndex(pathAdditionEntry.image); + PaintAddImageAsParent(session, imageId.WithIndexOffset(1), { 0, 0, height }, { { 6, 8, height + 2 }, { 1, 1, 2 } }); + PaintAddImageAsParent(session, imageId.WithIndexOffset(2), { 0, 0, height }, { { 8, 23, height + 2 }, { 1, 1, 2 } }); + PaintAddImageAsParent(session, imageId.WithIndexOffset(3), { 0, 0, height }, { { 23, 8, height + 2 }, { 1, 1, 2 } }); + PaintAddImageAsParent(session, imageId.WithIndexOffset(4), { 0, 0, height }, { { 8, 6, height + 2 }, { 1, 1, 2 } }); +} + +inline bool PathAdditionIsVisible(uint32_t viewFlags, const PathAdditionEntry& pathAdditionEntry, bool isBroken) +{ + if (!(viewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES)) + return true; + + if (isBroken) + return true; + + if (pathAdditionEntry.draw_type == PathAdditionDrawType::Bin) + return true; + + return false; +} + +void Sub6A3F61PathAddition(PaintSession& session, const PathElement& pathElement, uint16_t height, ImageId sceneryImageTemplate) +{ + // Path additions get drawn on edges that are not connected, so we need to flip them. + const auto edges = pathElement.GetEdges() ^ 0b1111; + const auto rotatedEdges = ((edges << session.CurrentRotation) & 0xF) | (((edges) << session.CurrentRotation) >> 4); + + session.InteractionType = ViewportInteractionItem::PathAddition; + if (sceneryImageTemplate.IsRemap()) + { + session.InteractionType = ViewportInteractionItem::None; + } + + auto* pathAddEntry = pathElement.GetAdditionEntry(); + // Can be null if the object is not loaded. + if (pathAddEntry == nullptr || !PathAdditionIsVisible(session.ViewFlags, *pathAddEntry, pathElement.IsBroken())) + { + return; + } + + switch (pathAddEntry->draw_type) + { + case PathAdditionDrawType::Light: + PathAdditionLightsPaint(session, *pathAddEntry, pathElement, height, rotatedEdges, sceneryImageTemplate); + break; + case PathAdditionDrawType::Bin: + PathAdditionBinsPaint(session, *pathAddEntry, pathElement, height, rotatedEdges, sceneryImageTemplate); + break; + case PathAdditionDrawType::Bench: + PathAdditionBenchesPaint(session, *pathAddEntry, pathElement, height, rotatedEdges, sceneryImageTemplate); + break; + case PathAdditionDrawType::JumpingFountain: + PathAdditionJumpingFountainsPaint(session, *pathAddEntry, height, sceneryImageTemplate, session.DPI); + break; + } + + session.InteractionType = ViewportInteractionItem::Footpath; + + // Set when the path addition is a ghost. + if (sceneryImageTemplate.IsRemap()) + { + session.InteractionType = ViewportInteractionItem::None; + } +} + +void PaintLampLightEffects(PaintSession& session, const PathElement& pathEl, uint16_t height) +{ + PROFILED_FUNCTION(); + + if (LightFXIsAvailable()) + { + if (pathEl.HasAddition() && !(pathEl.IsBroken())) + { + auto* pathAddEntry = pathEl.GetAdditionEntry(); + if (pathAddEntry != nullptr && pathAddEntry->flags & PATH_ADDITION_FLAG_LAMP) + { + if (!(pathEl.GetEdges() & EDGE_NE)) + { + LightFXAdd3DLightMagicFromDrawingTile(session.MapPosition, -16, 0, height + 23, LightType::Lantern3); + } + if (!(pathEl.GetEdges() & EDGE_SE)) + { + LightFXAdd3DLightMagicFromDrawingTile(session.MapPosition, 0, 16, height + 23, LightType::Lantern3); + } + if (!(pathEl.GetEdges() & EDGE_SW)) + { + LightFXAdd3DLightMagicFromDrawingTile(session.MapPosition, 16, 0, height + 23, LightType::Lantern3); + } + if (!(pathEl.GetEdges() & EDGE_NW)) + { + LightFXAdd3DLightMagicFromDrawingTile(session.MapPosition, 0, -16, height + 23, LightType::Lantern3); + } + } + } + } +} diff --git a/src/openrct2/paint/tile_element/Paint.PathAddition.h b/src/openrct2/paint/tile_element/Paint.PathAddition.h new file mode 100644 index 0000000000..7d42ad04bf --- /dev/null +++ b/src/openrct2/paint/tile_element/Paint.PathAddition.h @@ -0,0 +1,20 @@ +/***************************************************************************** + * 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 "../../drawing/ImageId.hpp" +#include "../../world/TileElement.h" +#include "../Paint.h" + +#include + +void Sub6A3F61PathAddition( + PaintSession& session, const PathElement& pathElement, uint16_t height, ImageId sceneryImageTemplate); +void PaintLampLightEffects(PaintSession& session, const PathElement& pathEl, uint16_t height); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 0d46740fd2..bc54385eb7 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -560,7 +560,7 @@ namespace RCT1 case ObjectType::LargeScenery: case ObjectType::Walls: case ObjectType::Paths: - case ObjectType::PathBits: + case ObjectType::PathAdditions: { RCT12::EntryList* entries = GetEntryList(objectType); @@ -1473,7 +1473,7 @@ namespace RCT1 AppendRequiredObjects(result, ObjectType::LargeScenery, _largeSceneryEntries); AppendRequiredObjects(result, ObjectType::Walls, _wallEntries); AppendRequiredObjects(result, ObjectType::Paths, _pathEntries); - AppendRequiredObjects(result, ObjectType::PathBits, _pathAdditionEntries); + AppendRequiredObjects(result, ObjectType::PathAdditions, _pathAdditionEntries); AppendRequiredObjects(result, ObjectType::SceneryGroup, _sceneryGroupEntries); AppendRequiredObjects( result, ObjectType::Banners, @@ -2443,7 +2443,7 @@ namespace RCT1 return &_wallEntries; case ObjectType::Paths: return &_pathEntries; - case ObjectType::PathBits: + case ObjectType::PathAdditions: return &_pathAdditionEntries; case ObjectType::SceneryGroup: return &_sceneryGroupEntries; diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index a38966c0d9..8dde2f288e 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -22,13 +22,13 @@ #include "../localisation/Localisation.h" #include "../management/Finance.h" #include "../network/network.h" -#include "../object/FootpathItemEntry.h" #include "../object/FootpathObject.h" #include "../object/FootpathRailingsObject.h" #include "../object/FootpathSurfaceObject.h" #include "../object/ObjectEntryManager.h" #include "../object/ObjectList.h" #include "../object/ObjectManager.h" +#include "../object/PathAdditionEntry.h" #include "../paint/VirtualFloor.h" #include "../ride/RideData.h" #include "../ride/Station.h" @@ -1631,11 +1631,11 @@ ObjectEntryIndex PathElement::GetAdditionEntryIndex() const return GetAddition() - 1; } -const PathBitEntry* PathElement::GetAdditionEntry() const +const PathAdditionEntry* PathElement::GetAdditionEntry() const { if (!HasAddition()) return nullptr; - return OpenRCT2::ObjectManager::GetObjectEntry(GetAdditionEntryIndex()); + return OpenRCT2::ObjectManager::GetObjectEntry(GetAdditionEntryIndex()); } void PathElement::SetAddition(uint8_t newAddition) diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index 3c42d31931..44db7b49fd 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -24,11 +24,11 @@ #include "../localisation/Localisation.h" #include "../network/network.h" #include "../object/BannerSceneryEntry.h" -#include "../object/FootpathItemEntry.h" #include "../object/LargeSceneryEntry.h" #include "../object/ObjectEntryManager.h" #include "../object/ObjectList.h" #include "../object/ObjectManager.h" +#include "../object/PathAdditionEntry.h" #include "../object/SceneryGroupEntry.h" #include "../object/SmallSceneryEntry.h" #include "../object/WallSceneryEntry.h" @@ -153,11 +153,11 @@ void SceneryUpdateTile(const CoordsXY& sceneryPos) auto* pathAddEntry = tileElement->AsPath()->GetAdditionEntry(); if (pathAddEntry != nullptr) { - if (pathAddEntry->flags & PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER) + if (pathAddEntry->flags & PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER) { JumpingFountain::StartAnimation(JumpingFountainType::Water, sceneryPos, tileElement); } - else if (pathAddEntry->flags & PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW) + else if (pathAddEntry->flags & PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW) { JumpingFountain::StartAnimation(JumpingFountainType::Snow, sceneryPos, tileElement); } @@ -358,7 +358,7 @@ static bool IsSceneryEntryValid(const ScenerySelection& item) case SCENERY_TYPE_SMALL: return OpenRCT2::ObjectManager::GetObjectEntry(item.EntryIndex) != nullptr; case SCENERY_TYPE_PATH_ITEM: - return OpenRCT2::ObjectManager::GetObjectEntry(item.EntryIndex) != nullptr; + return OpenRCT2::ObjectManager::GetObjectEntry(item.EntryIndex) != nullptr; case SCENERY_TYPE_WALL: return OpenRCT2::ObjectManager::GetObjectEntry(item.EntryIndex) != nullptr; case SCENERY_TYPE_LARGE: @@ -440,7 +440,7 @@ ObjectType GetObjectTypeFromSceneryType(uint8_t type) case SCENERY_TYPE_SMALL: return ObjectType::SmallScenery; case SCENERY_TYPE_PATH_ITEM: - return ObjectType::PathBits; + return ObjectType::PathAdditions; case SCENERY_TYPE_WALL: return ObjectType::Walls; case SCENERY_TYPE_LARGE: @@ -458,7 +458,7 @@ uint8_t GetSceneryTypeFromObjectType(ObjectType type) { case ObjectType::SmallScenery: return SCENERY_TYPE_SMALL; - case ObjectType::PathBits: + case ObjectType::PathAdditions: return SCENERY_TYPE_PATH_ITEM; case ObjectType::Walls: return SCENERY_TYPE_WALL; diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index fb852d15ac..b9cb7308c3 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -22,7 +22,7 @@ struct CoordsXY; struct LargeSceneryEntry; struct SmallSceneryEntry; struct WallSceneryEntry; -struct PathBitEntry; +struct PathAdditionEntry; struct BannerSceneryEntry; struct FootpathEntry; class LargeSceneryObject; @@ -309,7 +309,7 @@ public: bool HasAddition() const; uint8_t GetAddition() const; ObjectEntryIndex GetAdditionEntryIndex() const; - const PathBitEntry* GetAdditionEntry() const; + const PathAdditionEntry* GetAdditionEntry() const; void SetAddition(uint8_t newAddition); bool AdditionIsGhost() const;