diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index c5b4c89a63..3252a57f03 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -242,7 +242,6 @@ bool ViewportInteractionLeftClick(const ScreenCoordsXY& screenCoords) */ InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoords) { - rct_scenery_entry* sceneryEntry; Ride* ride; int32_t i, stationIndex; InteractionInfo info{}; @@ -402,7 +401,8 @@ InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoor break; } case ViewportInteractionItem::LargeScenery: - sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); + { + auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); if (sceneryEntry->large_scenery.scrolling_mode != SCROLLING_MODE_NONE) { auto banner = tileElement->AsLargeScenery()->GetBanner(); @@ -418,7 +418,7 @@ InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoor } } break; - + } case ViewportInteractionItem::Banner: { auto banner = tileElement->AsBanner()->GetBanner(); @@ -449,12 +449,13 @@ InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoor switch (info.SpriteType) { case ViewportInteractionItem::Scenery: - sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); + { + auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); ft.Add(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE); ft.Add(sceneryEntry->name); SetMapTooltip(ft); return info; - + } case ViewportInteractionItem::Footpath: ft.Add(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE); if (tileElement->AsPath()->IsQueue()) @@ -497,11 +498,13 @@ InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoor return info; } case ViewportInteractionItem::LargeScenery: - sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); + { + auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); ft.Add(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE); ft.Add(sceneryEntry->name); SetMapTooltip(ft); return info; + } default: break; } diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index 8a4b6e6d65..0df9909a0a 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -266,11 +266,11 @@ void window_scenery_init() // small scenery for (ObjectEntryIndex sceneryId = 0; sceneryId < MAX_SMALL_SCENERY_OBJECTS; sceneryId++) { - rct_scenery_entry* sceneryEntry = get_small_scenery_entry(sceneryId); + auto* sceneryEntry = get_small_scenery_entry(sceneryId); if (sceneryEntry == nullptr) continue; - init_scenery_entry({ SCENERY_TYPE_SMALL, sceneryId }, sceneryEntry->small_scenery.scenery_tab_id); + init_scenery_entry({ SCENERY_TYPE_SMALL, sceneryId }, sceneryEntry->scenery_tab_id); } // large scenery @@ -832,8 +832,7 @@ static void window_scenery_update(rct_window* w) } else { // small scenery - gCurrentToolId = static_cast( - get_small_scenery_entry(tabSelectedScenery.EntryIndex)->small_scenery.tool_id); + gCurrentToolId = static_cast(get_small_scenery_entry(tabSelectedScenery.EntryIndex)->tool_id); } } } @@ -988,7 +987,7 @@ void window_scenery_invalidate(rct_window* w) window_scenery_widgets[WIDX_SCENERY_BUILD_CLUSTER_BUTTON].type = WindowWidgetType::FlatBtn; } - rct_scenery_entry* sceneryEntry = get_small_scenery_entry(tabSelectedScenery.EntryIndex); + auto* sceneryEntry = get_small_scenery_entry(tabSelectedScenery.EntryIndex); if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_ROTATABLE)) { window_scenery_widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type = WindowWidgetType::FlatBtn; @@ -1021,8 +1020,6 @@ void window_scenery_invalidate(rct_window* w) } else if (!tabSelectedScenery.IsUndefined()) { - rct_scenery_entry* sceneryEntry = nullptr; - if (tabSelectedScenery.SceneryType == SCENERY_TYPE_BANNER) { auto* bannerEntry = get_banner_entry(tabSelectedScenery.EntryIndex); @@ -1033,7 +1030,7 @@ void window_scenery_invalidate(rct_window* w) } else if (tabSelectedScenery.SceneryType == SCENERY_TYPE_LARGE) { - sceneryEntry = get_large_scenery_entry(tabSelectedScenery.EntryIndex); + auto* sceneryEntry = get_large_scenery_entry(tabSelectedScenery.EntryIndex); if (sceneryEntry->large_scenery.flags & LARGE_SCENERY_FLAG_HAS_PRIMARY_COLOUR) window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WindowWidgetType::ColourBtn; @@ -1060,7 +1057,7 @@ void window_scenery_invalidate(rct_window* w) } else if (tabSelectedScenery.SceneryType == SCENERY_TYPE_SMALL) { - sceneryEntry = get_small_scenery_entry(tabSelectedScenery.EntryIndex); + auto* sceneryEntry = get_small_scenery_entry(tabSelectedScenery.EntryIndex); if (scenery_small_entry_has_flag( sceneryEntry, SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR | SMALL_SCENERY_FLAG_HAS_GLASS)) @@ -1134,14 +1131,15 @@ void window_scenery_paint(rct_window* w, rct_drawpixelinfo* dpi) uint32_t price = 0; rct_string_id name = STR_UNKNOWN_OBJECT_TYPE; - rct_scenery_entry* sceneryEntry = nullptr; switch (selectedSceneryEntry.SceneryType) { case SCENERY_TYPE_SMALL: - sceneryEntry = get_small_scenery_entry(selectedSceneryEntry.EntryIndex); - price = sceneryEntry->small_scenery.price * 10; + { + auto* sceneryEntry = get_small_scenery_entry(selectedSceneryEntry.EntryIndex); + price = sceneryEntry->price * 10; name = sceneryEntry->name; break; + } case SCENERY_TYPE_PATH_ITEM: { auto* pathBitEntry = get_footpath_item_entry(selectedSceneryEntry.EntryIndex); @@ -1157,10 +1155,12 @@ void window_scenery_paint(rct_window* w, rct_drawpixelinfo* dpi) break; } case SCENERY_TYPE_LARGE: - sceneryEntry = get_large_scenery_entry(selectedSceneryEntry.EntryIndex); + { + auto* sceneryEntry = get_large_scenery_entry(selectedSceneryEntry.EntryIndex); price = sceneryEntry->large_scenery.price * 10; name = sceneryEntry->name; break; + } case SCENERY_TYPE_BANNER: { auto* bannerEntry = get_banner_entry(selectedSceneryEntry.EntryIndex); @@ -1236,7 +1236,6 @@ void window_scenery_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t s } } - rct_scenery_entry* sceneryEntry; rct_drawpixelinfo clipdpi; if (clip_drawpixelinfo( &clipdpi, dpi, topLeft + ScreenCoordsXY{ 1, 1 }, SCENERY_BUTTON_WIDTH - 2, SCENERY_BUTTON_HEIGHT - 2)) @@ -1252,7 +1251,7 @@ void window_scenery_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t s } else if (currentSceneryGlobal.SceneryType == SCENERY_TYPE_LARGE) { - sceneryEntry = get_large_scenery_entry(currentSceneryGlobal.EntryIndex); + auto* sceneryEntry = get_large_scenery_entry(currentSceneryGlobal.EntryIndex); uint32_t imageId = sceneryEntry->image + gWindowSceneryRotation; imageId |= (gWindowSceneryPrimaryColour << 19) | IMAGE_TYPE_REMAP; imageId |= (gWindowScenerySecondaryColour << 24) | IMAGE_TYPE_REMAP_2_PLUS; @@ -1310,7 +1309,7 @@ void window_scenery_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t s } else { - sceneryEntry = get_small_scenery_entry(currentSceneryGlobal.EntryIndex); + auto* sceneryEntry = get_small_scenery_entry(currentSceneryGlobal.EntryIndex); uint32_t imageId = sceneryEntry->image + gWindowSceneryRotation; if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR)) @@ -1323,7 +1322,7 @@ void window_scenery_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t s } } - uint16_t spriteTop = (sceneryEntry->small_scenery.height / 4) + 0x2B; + uint16_t spriteTop = (sceneryEntry->height / 4) + 0x2B; if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE) && scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 84fced5682..798b0df010 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -1974,7 +1974,7 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi) DrawTextBasic(dpi, screenCoords, STR_TILE_INSPECTOR_SCENERY_AGE, &age, { COLOUR_WHITE }); // Quadrant value - const rct_scenery_entry* sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); + const auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); if (sceneryEntry != nullptr && !(scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE))) { int16_t quadrant = tileElement->AsSmallScenery()->GetSceneryQuadrant(); @@ -2294,10 +2294,10 @@ static void window_tile_inspector_scrollpaint(rct_window* w, rct_drawpixelinfo* break; case TILE_ELEMENT_TYPE_SMALL_SCENERY: { - const auto* entry = tileElement->AsSmallScenery()->GetEntry(); + const auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); snprintf( buffer, sizeof(buffer), "%s (%s)", language_get_string(STR_OBJECT_SELECTION_SMALL_SCENERY), - entry != nullptr ? language_get_string(entry->name) : ""); + sceneryEntry != nullptr ? language_get_string(sceneryEntry->name) : ""); typeName = buffer; break; } diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 73b2907eb9..9edc606f64 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -995,11 +995,11 @@ static void repaint_scenery_tool_down(const ScreenCoordsXY& windowPos, rct_widge { case ViewportInteractionItem::Scenery: { - rct_scenery_entry* scenery_entry = info.Element->AsSmallScenery()->GetEntry(); + auto* sceneryEntry = info.Element->AsSmallScenery()->GetEntry(); // If can't repaint if (!scenery_small_entry_has_flag( - scenery_entry, SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR | SMALL_SCENERY_FLAG_HAS_GLASS)) + sceneryEntry, SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR | SMALL_SCENERY_FLAG_HAS_GLASS)) return; uint8_t quadrant = info.Element->AsSmallScenery()->GetSceneryQuadrant(); @@ -1074,7 +1074,7 @@ static void scenery_eyedropper_tool_down(const ScreenCoordsXY& windowPos, rct_wi { SmallSceneryElement* sceneryElement = info.Element->AsSmallScenery(); auto entryIndex = sceneryElement->GetEntryIndex(); - rct_scenery_entry* sceneryEntry = get_small_scenery_entry(entryIndex); + auto* sceneryEntry = get_small_scenery_entry(entryIndex); if (sceneryEntry != nullptr) { if (window_scenery_set_selected_item({ SCENERY_TYPE_SMALL, entryIndex })) @@ -1241,9 +1241,9 @@ static void sub_6E1F34_small_scenery( uint16_t maxPossibleHeight = (std::numeric_limits::max() - 32) * ZoomLevel::max(); bool can_raise_item = false; - rct_scenery_entry* scenery = get_small_scenery_entry(sceneryIndex); - maxPossibleHeight -= scenery->small_scenery.height; - if (scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_STACKABLE)) + auto* sceneryEntry = get_small_scenery_entry(sceneryIndex); + maxPossibleHeight -= sceneryEntry->height; + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_STACKABLE)) { can_raise_item = true; } @@ -1251,7 +1251,7 @@ static void sub_6E1F34_small_scenery( sub_6E1F34_update_screen_coords_and_buttons_pressed(can_raise_item, screenPos); // Small scenery - if (!scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_FULL_TILE)) + if (!scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE)) { uint8_t quadrant = 0; @@ -1315,7 +1315,7 @@ static void sub_6E1F34_small_scenery( uint8_t rotation = gWindowSceneryRotation; - if (!scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_ROTATABLE)) + if (!scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_ROTATABLE)) { rotation = util_rand() & 0xFF; } @@ -1399,7 +1399,7 @@ static void sub_6E1F34_small_scenery( gridPos = gridPos.ToTileStart(); uint8_t rotation = gWindowSceneryRotation; - if (!scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_ROTATABLE)) + if (!scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_ROTATABLE)) { rotation = util_rand() & 0xFF; } @@ -1750,14 +1750,14 @@ static void window_top_toolbar_scenery_tool_down(const ScreenCoordsXY& windowPos for (int32_t q = 0; q < quantity; q++) { int32_t zCoordinate = gSceneryPlaceZ; - rct_scenery_entry* scenery = get_small_scenery_entry(selectedScenery); + auto* sceneryEntry = get_small_scenery_entry(selectedScenery); int16_t cur_grid_x = gridPos.x; int16_t cur_grid_y = gridPos.y; if (isCluster) { - if (!scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_FULL_TILE)) + if (!scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE)) { quadrant = util_rand() & 3; } @@ -1772,7 +1772,7 @@ static void window_top_toolbar_scenery_tool_down(const ScreenCoordsXY& windowPos cur_grid_x += grid_x_offset * COORDS_XY_STEP; cur_grid_y += grid_y_offset * COORDS_XY_STEP; - if (!scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_ROTATABLE)) + if (!scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_ROTATABLE)) { gSceneryPlaceRotation = (gSceneryPlaceRotation + 1) & 3; } @@ -2662,10 +2662,10 @@ static void top_toolbar_tool_update_scenery(const ScreenCoordsXY& screenPos) gMapSelectPositionB.y = mapTile.y; } - rct_scenery_entry* scenery = get_small_scenery_entry(selection.EntryIndex); + auto* sceneryEntry = get_small_scenery_entry(selection.EntryIndex); gMapSelectType = MAP_SELECT_TYPE_FULL; - if (!scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_FULL_TILE) && !gWindowSceneryScatterEnabled) + if (!scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE) && !gWindowSceneryScatterEnabled) { gMapSelectType = MAP_SELECT_TYPE_QUARTER_0 + (quadrant ^ 2); } diff --git a/src/openrct2/actions/LandSetHeightAction.cpp b/src/openrct2/actions/LandSetHeightAction.cpp index a88b76edda..43144fcfe0 100644 --- a/src/openrct2/actions/LandSetHeightAction.cpp +++ b/src/openrct2/actions/LandSetHeightAction.cpp @@ -220,7 +220,7 @@ TileElement* LandSetHeightAction::CheckTreeObstructions() const if (_height + 4 < sceneryElement->base_height) continue; - rct_scenery_entry* sceneryEntry = sceneryElement->GetEntry(); + auto* sceneryEntry = sceneryElement->GetEntry(); if (!scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_IS_TREE)) continue; @@ -240,11 +240,11 @@ money32 LandSetHeightAction::GetSmallSceneryRemovalCost() const if (_height + 4 < sceneryElement->base_height) continue; - rct_scenery_entry* sceneryEntry = sceneryElement->GetEntry(); + auto* sceneryEntry = sceneryElement->GetEntry(); if (sceneryEntry == nullptr) continue; - cost += MONEY(sceneryEntry->small_scenery.removal_price, 0); + cost += MONEY(sceneryEntry->removal_price, 0); } return cost; diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/SmallSceneryPlaceAction.cpp index 33babf8b1c..169dd77ae1 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.cpp @@ -126,7 +126,7 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Query() const return std::make_unique(GameActions::Status::InvalidParameters); } - rct_scenery_entry* sceneryEntry = get_small_scenery_entry(_sceneryType); + auto* sceneryEntry = get_small_scenery_entry(_sceneryType); if (sceneryEntry == nullptr) { return std::make_unique(GameActions::Status::InvalidParameters); @@ -239,7 +239,7 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Query() const } int32_t zLow = targetHeight; - int32_t zHigh = zLow + ceil2(sceneryEntry->small_scenery.height, COORDS_Z_STEP); + int32_t zHigh = zLow + ceil2(sceneryEntry->height, COORDS_Z_STEP); uint8_t collisionQuadrants = 0b1111; auto quadRotation{ 0 }; if (!(scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE))) @@ -289,7 +289,7 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Query() const res->GroundFlags = gMapGroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); res->Expenditure = ExpenditureType::Landscaping; - res->Cost = (sceneryEntry->small_scenery.price * 10) + clearCost; + res->Cost = (sceneryEntry->price * 10) + clearCost; return res; } @@ -321,7 +321,7 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Execute() const res->Position.z = surfaceHeight; } - rct_scenery_entry* sceneryEntry = get_small_scenery_entry(_sceneryType); + auto* sceneryEntry = get_small_scenery_entry(_sceneryType); if (sceneryEntry == nullptr) { return std::make_unique(GameActions::Status::InvalidParameters); @@ -372,12 +372,12 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Execute() const footpath_remove_litter({ _loc, targetHeight }); if (!gCheatsDisableClearanceChecks && (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_NO_WALLS))) { - wall_remove_at({ _loc, targetHeight, targetHeight + sceneryEntry->small_scenery.height }); + wall_remove_at({ _loc, targetHeight, targetHeight + sceneryEntry->height }); } } int32_t zLow = targetHeight; - int32_t zHigh = zLow + ceil2(sceneryEntry->small_scenery.height, 8); + int32_t zHigh = zLow + ceil2(sceneryEntry->height, 8); uint8_t collisionQuadrants = 0b1111; auto quadRotation{ 0 }; if (!(scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE))) @@ -427,7 +427,7 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Execute() const res->GroundFlags = gMapGroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); res->Expenditure = ExpenditureType::Landscaping; - res->Cost = (sceneryEntry->small_scenery.price * 10) + clearCost; + res->Cost = (sceneryEntry->price * 10) + clearCost; auto* sceneryElement = TileElementInsert( CoordsXYZ{ _loc, zLow }, quarterTile.GetBaseQuarterOccupied()); @@ -439,7 +439,7 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Execute() const sceneryElement->SetAge(0); sceneryElement->SetPrimaryColour(_primaryColour); sceneryElement->SetSecondaryColour(_secondaryColour); - sceneryElement->SetClearanceZ(sceneryElement->GetBaseZ() + sceneryEntry->small_scenery.height + 7); + sceneryElement->SetClearanceZ(sceneryElement->GetBaseZ() + sceneryEntry->height + 7); sceneryElement->SetGhost(GetFlags() & GAME_COMMAND_FLAG_GHOST); if (supportsRequired) { diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.cpp b/src/openrct2/actions/SmallSceneryRemoveAction.cpp index 816fcf6e5f..e7fcb83290 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.cpp +++ b/src/openrct2/actions/SmallSceneryRemoveAction.cpp @@ -61,13 +61,13 @@ GameActions::Result::Ptr SmallSceneryRemoveAction::Query() const return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } - rct_scenery_entry* entry = get_small_scenery_entry(_sceneryType); + auto* entry = get_small_scenery_entry(_sceneryType); if (entry == nullptr) { return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); } - res->Cost = entry->small_scenery.removal_price * 10; + res->Cost = entry->removal_price * 10; res->Expenditure = ExpenditureType::Landscaping; res->Position = _loc; @@ -108,13 +108,13 @@ GameActions::Result::Ptr SmallSceneryRemoveAction::Execute() const { GameActions::Result::Ptr res = std::make_unique(); - rct_scenery_entry* entry = get_small_scenery_entry(_sceneryType); + auto* entry = get_small_scenery_entry(_sceneryType); if (entry == nullptr) { return MakeResult(GameActions::Status::InvalidParameters, STR_INVALID_SELECTION_OF_OBJECTS); } - res->Cost = entry->small_scenery.removal_price * 10; + res->Cost = entry->removal_price * 10; res->Expenditure = ExpenditureType::Landscaping; res->Position = _loc; diff --git a/src/openrct2/actions/WallPlaceAction.cpp b/src/openrct2/actions/WallPlaceAction.cpp index 3e819a6a2d..dfc05101dc 100644 --- a/src/openrct2/actions/WallPlaceAction.cpp +++ b/src/openrct2/actions/WallPlaceAction.cpp @@ -596,13 +596,15 @@ GameActions::Result::Ptr WallPlaceAction::WallCheckObstruction( } break; case TILE_ELEMENT_TYPE_SMALL_SCENERY: - entry = tileElement->AsSmallScenery()->GetEntry(); - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_NO_WALLS)) + { + auto sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_NO_WALLS)) { map_obstruction_set_error_text(tileElement, *res); return res; } break; + } case TILE_ELEMENT_TYPE_TRACK: if (!WallCheckObstructionWithTrack(wall, z0, tileElement->AsTrack(), wallAcrossTrack)) { diff --git a/src/openrct2/object/ObjectManager.cpp b/src/openrct2/object/ObjectManager.cpp index 58290cad00..2589a0cd56 100644 --- a/src/openrct2/object/ObjectManager.cpp +++ b/src/openrct2/object/ObjectManager.cpp @@ -480,18 +480,17 @@ private: { if (loadedObject != nullptr) { - rct_scenery_entry* sceneryEntry; switch (loadedObject->GetObjectType()) { case ObjectType::SmallScenery: { - sceneryEntry = static_cast(loadedObject->GetLegacyData()); - sceneryEntry->small_scenery.scenery_tab_id = GetPrimarySceneryGroupEntryIndex(loadedObject.get()); + auto* sceneryEntry = static_cast(loadedObject->GetLegacyData()); + sceneryEntry->scenery_tab_id = GetPrimarySceneryGroupEntryIndex(loadedObject.get()); break; } case ObjectType::LargeScenery: { - sceneryEntry = static_cast(loadedObject->GetLegacyData()); + auto* sceneryEntry = static_cast(loadedObject->GetLegacyData()); sceneryEntry->large_scenery.scenery_tab_id = GetPrimarySceneryGroupEntryIndex(loadedObject.get()); break; } diff --git a/src/openrct2/object/SmallSceneryObject.cpp b/src/openrct2/object/SmallSceneryObject.cpp index 8ef813df5f..a9aa6d30fd 100644 --- a/src/openrct2/object/SmallSceneryObject.cpp +++ b/src/openrct2/object/SmallSceneryObject.cpp @@ -26,16 +26,16 @@ void SmallSceneryObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStream* stream) { stream->Seek(6, OpenRCT2::STREAM_SEEK_CURRENT); - _legacyType.small_scenery.flags = stream->ReadValue(); - _legacyType.small_scenery.height = stream->ReadValue(); - _legacyType.small_scenery.tool_id = static_cast(stream->ReadValue()); - _legacyType.small_scenery.price = stream->ReadValue(); - _legacyType.small_scenery.removal_price = stream->ReadValue(); + _legacyType.flags = stream->ReadValue(); + _legacyType.height = stream->ReadValue(); + _legacyType.tool_id = static_cast(stream->ReadValue()); + _legacyType.price = stream->ReadValue(); + _legacyType.removal_price = stream->ReadValue(); stream->Seek(4, OpenRCT2::STREAM_SEEK_CURRENT); - _legacyType.small_scenery.animation_delay = stream->ReadValue(); - _legacyType.small_scenery.animation_mask = stream->ReadValue(); - _legacyType.small_scenery.num_frames = stream->ReadValue(); - _legacyType.small_scenery.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL; + _legacyType.animation_delay = stream->ReadValue(); + _legacyType.animation_mask = stream->ReadValue(); + _legacyType.num_frames = stream->ReadValue(); + _legacyType.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL; GetStringTable().Read(context, stream, ObjectStringID::NAME); @@ -47,23 +47,23 @@ void SmallSceneryObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStre _frameOffsets = ReadFrameOffsets(stream); } // This crude method was used by RCT2. JSON objects have a flag for this property. - if (_legacyType.small_scenery.height > 64) + if (_legacyType.height > 64) { - _legacyType.small_scenery.flags |= SMALL_SCENERY_FLAG_IS_TREE; + _legacyType.flags |= SMALL_SCENERY_FLAG_IS_TREE; } GetImageTable().Read(context, stream); // Validate properties - if (_legacyType.small_scenery.price <= 0) + if (_legacyType.price <= 0) { context->LogError(ObjectError::InvalidProperty, "Price can not be free or negative."); } - if (_legacyType.small_scenery.removal_price <= 0) + if (_legacyType.removal_price <= 0) { // Make sure you don't make a profit when placing then removing. - money16 reimbursement = _legacyType.small_scenery.removal_price; - if (reimbursement > _legacyType.small_scenery.price) + money16 reimbursement = _legacyType.removal_price; + if (reimbursement > _legacyType.price) { context->LogError(ObjectError::InvalidProperty, "Sell price can not be more than buy price."); } @@ -76,11 +76,11 @@ void SmallSceneryObject::Load() _legacyType.name = language_allocate_object_string(GetName()); _legacyType.image = gfx_object_allocate_images(GetImageTable().GetImages(), GetImageTable().GetCount()); - _legacyType.small_scenery.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL; + _legacyType.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL; if (scenery_small_entry_has_flag(&_legacyType, SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS)) { - _legacyType.small_scenery.frame_offsets = _frameOffsets.data(); + _legacyType.frame_offsets = _frameOffsets.data(); } PerformFixes(); @@ -107,7 +107,7 @@ void SmallSceneryObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int3 } } - auto screenCoords = ScreenCoordsXY{ width / 2, (height / 2) + (_legacyType.small_scenery.height / 2) }; + auto screenCoords = ScreenCoordsXY{ width / 2, (height / 2) + (_legacyType.height / 2) }; screenCoords.y = std::min(screenCoords.y, height - 16); if ((scenery_small_entry_has_flag(&_legacyType, SMALL_SCENERY_FLAG_FULL_TILE)) @@ -165,7 +165,7 @@ void SmallSceneryObject::PerformFixes() { SetPrimarySceneryGroup(scgWalls); - _legacyType.small_scenery.flags |= SMALL_SCENERY_FLAG_BUILD_DIRECTLY_ONTOP; + _legacyType.flags |= SMALL_SCENERY_FLAG_BUILD_DIRECTLY_ONTOP; } // ToonTowner's Pirate roofs. Make them show up in the Pirate Theming. @@ -231,15 +231,15 @@ void SmallSceneryObject::ReadJson(IReadObjectContext* context, json_t& root) if (properties.is_object()) { - _legacyType.small_scenery.height = Json::GetNumber(properties["height"]); - _legacyType.small_scenery.tool_id = Cursor::FromString(Json::GetString(properties["cursor"]), CursorID::StatueDown); - _legacyType.small_scenery.price = Json::GetNumber(properties["price"]); - _legacyType.small_scenery.removal_price = Json::GetNumber(properties["removalPrice"]); - _legacyType.small_scenery.animation_delay = Json::GetNumber(properties["animationDelay"]); - _legacyType.small_scenery.animation_mask = Json::GetNumber(properties["animationMask"]); - _legacyType.small_scenery.num_frames = Json::GetNumber(properties["numFrames"]); + _legacyType.height = Json::GetNumber(properties["height"]); + _legacyType.tool_id = Cursor::FromString(Json::GetString(properties["cursor"]), CursorID::StatueDown); + _legacyType.price = Json::GetNumber(properties["price"]); + _legacyType.removal_price = Json::GetNumber(properties["removalPrice"]); + _legacyType.animation_delay = Json::GetNumber(properties["animationDelay"]); + _legacyType.animation_mask = Json::GetNumber(properties["animationMask"]); + _legacyType.num_frames = Json::GetNumber(properties["numFrames"]); - _legacyType.small_scenery.flags = Json::GetFlags( + _legacyType.flags = Json::GetFlags( properties, { { "SMALL_SCENERY_FLAG_VOFFSET_CENTRE", SMALL_SCENERY_FLAG_VOFFSET_CENTRE }, @@ -275,21 +275,21 @@ void SmallSceneryObject::ReadJson(IReadObjectContext* context, json_t& root) auto quarters = shape.substr(0, 3); if (quarters == "2/4") { - _legacyType.small_scenery.flags |= SMALL_SCENERY_FLAG_FULL_TILE | SMALL_SCENERY_FLAG_HALF_SPACE; + _legacyType.flags |= SMALL_SCENERY_FLAG_FULL_TILE | SMALL_SCENERY_FLAG_HALF_SPACE; } else if (quarters == "3/4") { - _legacyType.small_scenery.flags |= SMALL_SCENERY_FLAG_FULL_TILE | SMALL_SCENERY_FLAG_THREE_QUARTERS; + _legacyType.flags |= SMALL_SCENERY_FLAG_FULL_TILE | SMALL_SCENERY_FLAG_THREE_QUARTERS; } else if (quarters == "4/4") { - _legacyType.small_scenery.flags |= SMALL_SCENERY_FLAG_FULL_TILE; + _legacyType.flags |= SMALL_SCENERY_FLAG_FULL_TILE; } if (shape.size() >= 5) { if ((shape.substr(3) == "+D")) { - _legacyType.small_scenery.flags |= SMALL_SCENERY_FLAG_DIAGONAL; + _legacyType.flags |= SMALL_SCENERY_FLAG_DIAGONAL; } } } @@ -298,7 +298,7 @@ void SmallSceneryObject::ReadJson(IReadObjectContext* context, json_t& root) if (jFrameOffsets.is_array()) { _frameOffsets = ReadJsonFrameOffsets(jFrameOffsets); - _legacyType.small_scenery.flags |= SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS; + _legacyType.flags |= SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS; } SetPrimarySceneryGroup(ObjectEntryDescriptor(Json::GetString(properties["sceneryGroup"]))); diff --git a/src/openrct2/object/SmallSceneryObject.h b/src/openrct2/object/SmallSceneryObject.h index 94289e14f5..48c8bdb2d7 100644 --- a/src/openrct2/object/SmallSceneryObject.h +++ b/src/openrct2/object/SmallSceneryObject.h @@ -17,7 +17,7 @@ class SmallSceneryObject final : public SceneryObject { private: - rct_scenery_entry _legacyType = {}; + SmallSceneryEntry _legacyType = {}; std::vector _frameOffsets; public: diff --git a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp index 8fa089c548..cd6602da12 100644 --- a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp @@ -59,21 +59,21 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co marker = CONSTRUCTION_MARKER; } - rct_scenery_entry* entry = tileElement->AsSmallScenery()->GetEntry(); + auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); - if (entry == nullptr) + if (sceneryEntry == nullptr) { return; } - int32_t baseImageid = entry->image + direction; + int32_t baseImageid = sceneryEntry->image + direction; boxlength.x = 2; boxlength.y = 2; int8_t x_offset = 0; int8_t y_offset = 0; - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_FULL_TILE)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE)) { - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_HALF_SPACE)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_HALF_SPACE)) { // 6DFFE3: static constexpr const LocationXY16 scenery_half_tile_offsets[] = { @@ -93,13 +93,13 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co { x_offset = 15; y_offset = 15; - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) { x_offset = 3; y_offset = 3; boxlength.x = 26; boxlength.y = 26; - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_NO_WALLS)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_NO_WALLS)) { x_offset = 1; y_offset = 1; @@ -121,12 +121,12 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co boxoffset.y = y_offset; } // 6E007F: - boxlength.z = entry->small_scenery.height - 4; + boxlength.z = sceneryEntry->height - 4; if (boxlength.z > 128 || boxlength.z < 0) { boxlength.z = 128; } - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_CAN_WITHER)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_CAN_WITHER)) { if (tileElement->AsSmallScenery()->GetAge() >= SCENERY_WITHER_AGE_THRESHOLD_1) { @@ -137,9 +137,9 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co baseImageid += 4; } } - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR)) { - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR)) { baseImageid |= SPRITE_ID_PALETTE_COLOUR_2(sceneryElement->GetPrimaryColour(), sceneryElement->GetSecondaryColour()); } @@ -152,14 +152,14 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co { baseImageid = (baseImageid & 0x7FFFF) | marker; } - if (!(scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED))) + if (!(scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED))) { PaintAddImageAsParent( session, baseImageid, x_offset, y_offset, boxlength.x, boxlength.y, boxlength.z - 1, height, boxoffset.x, boxoffset.y, boxoffset.z); } - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_HAS_GLASS)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_HAS_GLASS)) { if (marker == 0) { @@ -173,16 +173,16 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co } } - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_ANIMATED)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_ANIMATED)) { rct_drawpixelinfo* dpi = &session->DPI; - if ((scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED)) || (dpi->zoom_level <= 1)) + if ((scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED)) || (dpi->zoom_level <= 1)) { // 6E01A9: - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_1)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_1)) { // 6E0512: - int32_t image_id = ((gCurrentTicks / 2) & 0xF) + entry->image + 4; + int32_t image_id = ((gCurrentTicks / 2) & 0xF) + sceneryEntry->image + 4; if (marker != 0) { image_id = (image_id & 0x7FFFF) | marker; @@ -191,10 +191,10 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co session, image_id, x_offset, y_offset, boxlength.x, boxlength.y, boxlength.z - 1, height, boxoffset.x, boxoffset.y, boxoffset.z); } - else if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_4)) + else if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_4)) { // 6E043B: - int32_t image_id = ((gCurrentTicks / 2) & 0xF) + entry->image + 8; + int32_t image_id = ((gCurrentTicks / 2) & 0xF) + sceneryEntry->image + 8; if (marker != 0) { image_id = (image_id & 0x7FFFF) | marker; @@ -203,7 +203,7 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co session, image_id, x_offset, y_offset, boxlength.x, boxlength.y, boxlength.z - 1, height, boxoffset.x, boxoffset.y, boxoffset.z); - image_id = direction + entry->image + 4; + image_id = direction + sceneryEntry->image + 4; if (marker != 0) { image_id = (image_id & 0x7FFFF) | marker; @@ -212,7 +212,7 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co session, image_id, x_offset, y_offset, boxlength.x, boxlength.y, boxlength.z - 1, height, boxoffset.x, boxoffset.y, boxoffset.z); - image_id = ((gCurrentTicks / 2) & 0xF) + entry->image + 24; + image_id = ((gCurrentTicks / 2) & 0xF) + sceneryEntry->image + 24; if (marker != 0) { image_id = (image_id & 0x7FFFF) | marker; @@ -221,7 +221,7 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co session, image_id, x_offset, y_offset, boxlength.x, boxlength.y, boxlength.z - 1, height, boxoffset.x, boxoffset.y, boxoffset.z); } - else if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_IS_CLOCK)) + else if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_IS_CLOCK)) { // 6E035C: int32_t minuteImageOffset = ((gRealTimeOfDay.minute + 6) * 17) / 256; @@ -241,7 +241,7 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co image_id -= 48; } - image_id = image_id + entry->image + 68; + image_id = image_id + sceneryEntry->image + 68; if (marker != 0) { image_id = (image_id & 0x7FFFF) | marker; @@ -255,7 +255,7 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co { image_id -= 60; } - image_id = image_id + entry->image + 8; + image_id = image_id + sceneryEntry->image + 8; if (marker != 0) { image_id = (image_id & 0x7FFFF) | marker; @@ -264,14 +264,14 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co session, image_id, x_offset, y_offset, boxlength.x, boxlength.y, boxlength.z - 1, height, boxoffset.x, boxoffset.y, boxoffset.z); } - else if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_SWAMP_GOO)) + else if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_SWAMP_GOO)) { // 6E02F6: int32_t image_id = gCurrentTicks; image_id += session->SpritePosition.x / 4; image_id += session->SpritePosition.y / 4; image_id = (image_id / 4) & 15; - image_id += entry->image; + image_id += sceneryEntry->image; if (marker != 0) { image_id = (image_id & 0x7FFFF) | marker; @@ -280,32 +280,32 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co session, image_id, x_offset, y_offset, boxlength.x, boxlength.y, boxlength.z - 1, height, boxoffset.x, boxoffset.y, boxoffset.z); } - else if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS)) + else if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS)) { int32_t frame = gCurrentTicks; - if (!(scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_COG))) + if (!(scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_COG))) { // 6E01F8: frame += ((session->SpritePosition.x / 4) + (session->SpritePosition.y / 4)); frame += tileElement->AsSmallScenery()->GetSceneryQuadrant() << 2; } // 6E0222: - uint16_t delay = entry->small_scenery.animation_delay & 0xFF; + uint16_t delay = sceneryEntry->animation_delay & 0xFF; frame >>= delay; - frame &= entry->small_scenery.animation_mask; + frame &= sceneryEntry->animation_mask; int32_t image_id = 0; - if (frame < entry->small_scenery.num_frames) + if (frame < sceneryEntry->num_frames) { - image_id = entry->small_scenery.frame_offsets[frame]; + image_id = sceneryEntry->frame_offsets[frame]; } - image_id = (image_id * 4) + direction + entry->image; - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED | SMALL_SCENERY_FLAG17)) + image_id = (image_id * 4) + direction + sceneryEntry->image; + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED | SMALL_SCENERY_FLAG17)) { image_id += 4; } - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR)) { - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR)) { image_id |= SPRITE_ID_PALETTE_COLOUR_2( sceneryElement->GetPrimaryColour(), sceneryElement->GetSecondaryColour()); @@ -319,7 +319,7 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co { image_id = (image_id & 0x7FFFF) | marker; } - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED)) { PaintAddImageAsParent( session, image_id, x_offset, y_offset, boxlength.x, boxlength.y, boxlength.z - 1, height, boxoffset.x, @@ -337,7 +337,7 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co // 6E0556: Draw supports: if (sceneryElement->NeedsSupports()) { - if (!(scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_NO_SUPPORTS))) + if (!(scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_NO_SUPPORTS))) { int32_t ax = 0; int32_t supportHeight = height; @@ -347,7 +347,7 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co ax = 49; } uint32_t supportImageColourFlags = IMAGE_TYPE_REMAP; - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_PAINT_SUPPORTS)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_PAINT_SUPPORTS)) { supportImageColourFlags = SPRITE_ID_PALETTE_COLOUR_1(sceneryElement->GetPrimaryColour()); } @@ -366,23 +366,23 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co } } // 6E05D1: - height += entry->small_scenery.height; + height += sceneryEntry->height; paint_util_set_general_support_height(session, ceil2(height, 8), 0x20); // 6E05FF: - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_BUILD_DIRECTLY_ONTOP)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_BUILD_DIRECTLY_ONTOP)) { - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_FULL_TILE)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE)) { // 6E0825: paint_util_set_segment_support_height(session, SEGMENT_C4, height, 0x20); - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) { paint_util_set_segment_support_height(session, SEGMENTS_ALL & ~SEGMENT_C4, height, 0x20); } return; } - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) { // 6E075C: direction = (tileElement->AsSmallScenery()->GetSceneryQuadrant() + rotation) % 4; @@ -392,16 +392,16 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co } return; } - if (scenery_small_entry_has_flag(entry, (SMALL_SCENERY_FLAG27 | SMALL_SCENERY_FLAG_FULL_TILE))) + if (scenery_small_entry_has_flag(sceneryEntry, (SMALL_SCENERY_FLAG27 | SMALL_SCENERY_FLAG_FULL_TILE))) { paint_util_set_segment_support_height(session, SEGMENT_C4, 0xFFFF, 0); - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) { paint_util_set_segment_support_height(session, SEGMENTS_ALL & ~SEGMENT_C4, 0xFFFF, 0); } return; } - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) { direction = (tileElement->AsSmallScenery()->GetSceneryQuadrant() + rotation) % 4; paint_util_set_segment_support_height( diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index bc19d73d71..c981d22b5e 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -1235,9 +1235,9 @@ void Staff::UpdateWatering() if (abs(NextLoc.z - tile_element->GetBaseZ()) > 4 * COORDS_Z_STEP) continue; - rct_scenery_entry* scenery_entry = tile_element->AsSmallScenery()->GetEntry(); + auto* sceneryEntry = tile_element->AsSmallScenery()->GetEntry(); - if (!scenery_small_entry_has_flag(scenery_entry, SMALL_SCENERY_FLAG_CAN_BE_WATERED)) + if (!scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_CAN_BE_WATERED)) continue; tile_element->AsSmallScenery()->SetAge(0); @@ -1622,7 +1622,7 @@ bool Staff::UpdatePatrollingFindWatering() continue; } - rct_scenery_entry* sceneryEntry = tile_element->AsSmallScenery()->GetEntry(); + auto* sceneryEntry = tile_element->AsSmallScenery()->GetEntry(); if (sceneryEntry == nullptr || !scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_CAN_BE_WATERED)) { diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index b47bcd08e8..9679b2246e 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -677,11 +677,12 @@ static void track_design_mirror_scenery(TrackDesign* td6) entryIndex = 0; } - rct_scenery_entry* scenery_entry = static_cast(object_entry_get_chunk(entry_type, entryIndex)); switch (entry_type) { case ObjectType::LargeScenery: { + rct_scenery_entry* scenery_entry = static_cast( + object_entry_get_chunk(entry_type, entryIndex)); int16_t x1 = 0, x2 = 0, y1 = 0, y2 = 0; for (rct_large_scenery_tile* tile = scenery_entry->large_scenery.tiles; tile->x_offset != -1; tile++) { @@ -726,12 +727,13 @@ static void track_design_mirror_scenery(TrackDesign* td6) } case ObjectType::SmallScenery: { + auto* sceneryEntry = static_cast(object_entry_get_chunk(entry_type, entryIndex)); scenery.y = -scenery.y; - if (scenery_small_entry_has_flag(scenery_entry, SMALL_SCENERY_FLAG_DIAGONAL)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_DIAGONAL)) { scenery.flags ^= (1 << 0); - if (!scenery_small_entry_has_flag(scenery_entry, SMALL_SCENERY_FLAG_FULL_TILE)) + if (!scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE)) { scenery.flags ^= (1 << 2); } @@ -935,11 +937,11 @@ static bool TrackDesignPlaceSceneryElementRemoveGhost( uint8_t quadrant = (scenery.flags >> 2) + _currentTrackPieceDirection; quadrant &= 3; - rct_scenery_entry* small_scenery = get_small_scenery_entry(entry_index); - if (!(!scenery_small_entry_has_flag(small_scenery, SMALL_SCENERY_FLAG_FULL_TILE) - && scenery_small_entry_has_flag(small_scenery, SMALL_SCENERY_FLAG_DIAGONAL)) + auto* sceneryEntry = get_small_scenery_entry(entry_index); + if (!(!scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE) + && scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_DIAGONAL)) && scenery_small_entry_has_flag( - small_scenery, + sceneryEntry, SMALL_SCENERY_FLAG_DIAGONAL | SMALL_SCENERY_FLAG_HALF_SPACE | SMALL_SCENERY_FLAG_THREE_QUARTERS)) { quadrant = 0; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 1eb3039e78..352b649bf5 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -1887,11 +1887,11 @@ void Vehicle::UpdateMeasurements() if (tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) continue; - rct_scenery_entry* scenery = tileElement->AsSmallScenery()->GetEntry(); - if (scenery == nullptr) + auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); + if (sceneryEntry == nullptr) continue; - if (scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_FULL_TILE)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE)) { coverFound = true; break; diff --git a/src/openrct2/scripting/ScObject.hpp b/src/openrct2/scripting/ScObject.hpp index 4b23e7f84e..dfa3e0c457 100644 --- a/src/openrct2/scripting/ScObject.hpp +++ b/src/openrct2/scripting/ScObject.hpp @@ -942,7 +942,7 @@ namespace OpenRCT2::Scripting auto sceneryEntry = GetLegacyData(); if (sceneryEntry != nullptr) { - return sceneryEntry->small_scenery.flags; + return sceneryEntry->flags; } return 0; } @@ -952,7 +952,7 @@ namespace OpenRCT2::Scripting auto sceneryEntry = GetLegacyData(); if (sceneryEntry != nullptr) { - return sceneryEntry->small_scenery.height; + return sceneryEntry->height; } return 0; } @@ -962,7 +962,7 @@ namespace OpenRCT2::Scripting auto sceneryEntry = GetLegacyData(); if (sceneryEntry != nullptr) { - return sceneryEntry->small_scenery.price; + return sceneryEntry->price; } return 0; } @@ -972,18 +972,18 @@ namespace OpenRCT2::Scripting auto sceneryEntry = GetLegacyData(); if (sceneryEntry != nullptr) { - return sceneryEntry->small_scenery.removal_price; + return sceneryEntry->removal_price; } return 0; } protected: - rct_scenery_entry* GetLegacyData() const + SmallSceneryEntry* GetLegacyData() const { auto obj = GetObject(); if (obj != nullptr) { - return static_cast(obj->GetLegacyData()); + return static_cast(obj->GetLegacyData()); } return nullptr; } diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 5e9b3ae206..e435212363 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1189,7 +1189,6 @@ TileElement* tile_element_insert(const CoordsXYZ& loc, int32_t occupiedQuadrants void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Result& res) { Ride* ride; - rct_scenery_entry* sceneryEntry; res.ErrorMessage = STR_OBJECT_IN_THE_WAY; switch (tileElement->GetType()) @@ -1212,7 +1211,7 @@ void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Resul break; case TILE_ELEMENT_TYPE_SMALL_SCENERY: { - sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); + auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); res.ErrorMessage = STR_X_IN_THE_WAY; auto ft = Formatter(res.ErrorMessageArgs.data()); rct_string_id stringId = sceneryEntry != nullptr ? sceneryEntry->name : static_cast(STR_EMPTY); @@ -1244,7 +1243,7 @@ void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Resul } case TILE_ELEMENT_TYPE_LARGE_SCENERY: { - sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); + auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); res.ErrorMessage = STR_X_IN_THE_WAY; auto ft = Formatter(res.ErrorMessageArgs.data()); rct_string_id stringId = sceneryEntry != nullptr ? sceneryEntry->name : static_cast(STR_EMPTY); @@ -2133,12 +2132,12 @@ bool map_surface_is_blocked(const CoordsXY& mapCoords) if (tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) return true; - rct_scenery_entry* scenery = tileElement->AsSmallScenery()->GetEntry(); - if (scenery == nullptr) + auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); + if (sceneryEntry == nullptr) { return false; } - if (scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_FULL_TILE)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE)) return true; } return false; diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index f7b4886f92..af9b538291 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -173,7 +173,7 @@ static bool map_animation_invalidate_small_scenery(const CoordsXYZ& loc) if (tileElement->IsGhost()) continue; - auto sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); + auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); if (sceneryEntry == nullptr) continue; @@ -640,8 +640,8 @@ void AutoCreateMapAnimations() case TILE_ELEMENT_TYPE_SMALL_SCENERY: { auto sceneryEl = el->AsSmallScenery(); - auto entry = sceneryEl->GetEntry(); - if (entry != nullptr && scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_ANIMATED)) + auto* sceneryEntry = sceneryEl->GetEntry(); + if (sceneryEntry != nullptr && scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_ANIMATED)) { map_animation_create(MAP_ANIMATION_TYPE_SMALL_SCENERY, loc); } diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index 7a8794d635..d6753302c8 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -237,7 +237,7 @@ void mapgen_generate(mapgen_settings* settings) static void mapgen_place_tree(int32_t type, const CoordsXY& loc) { - rct_scenery_entry* sceneryEntry = get_small_scenery_entry(type); + auto* sceneryEntry = get_small_scenery_entry(type); if (sceneryEntry == nullptr) { return; @@ -248,7 +248,7 @@ static void mapgen_place_tree(int32_t type, const CoordsXY& loc) auto* sceneryElement = TileElementInsert({ loc, surfaceZ }, 0b1111); Guard::Assert(sceneryElement != nullptr); - sceneryElement->SetClearanceZ(surfaceZ + sceneryEntry->small_scenery.height); + sceneryElement->SetClearanceZ(surfaceZ + sceneryEntry->height); sceneryElement->SetDirection(util_rand() & 3); sceneryElement->SetEntryIndex(type); sceneryElement->SetAge(0); @@ -284,7 +284,7 @@ static void mapgen_place_trees() for (int32_t i = 0; i < object_entry_group_counts[EnumValue(ObjectType::SmallScenery)]; i++) { - auto sceneryEntry = get_small_scenery_entry(i); + auto* sceneryEntry = get_small_scenery_entry(i); auto entry = object_entry_get_object(ObjectType::SmallScenery, i); if (sceneryEntry == nullptr) diff --git a/src/openrct2/world/Scenery.h b/src/openrct2/world/Scenery.h index 3cd0fc2d3f..f802819f32 100644 --- a/src/openrct2/world/Scenery.h +++ b/src/openrct2/world/Scenery.h @@ -21,19 +21,6 @@ #define SCENERY_WITHER_AGE_THRESHOLD_2 0x37 #pragma pack(push, 1) -struct rct_small_scenery_entry -{ - uint32_t flags; // 0x06 - uint8_t height; // 0x0A - CursorID tool_id; // 0x0B - int16_t price; // 0x0C - int16_t removal_price; // 0x0E - uint8_t* frame_offsets; // 0x10 - uint16_t animation_delay; // 0x14 - uint16_t animation_mask; // 0x16 - uint16_t num_frames; // 0x18 - ObjectEntryIndex scenery_tab_id; // 0x1A -}; struct rct_large_scenery_tile { @@ -131,11 +118,21 @@ struct rct_scenery_entry { rct_string_id name; // 0x00 uint32_t image; // 0x02 - union - { - rct_small_scenery_entry small_scenery; - rct_large_scenery_entry large_scenery; - }; + rct_large_scenery_entry large_scenery; +}; + +struct SmallSceneryEntry : SceneryEntryBase +{ + uint32_t flags; + uint8_t height; + CursorID tool_id; + int16_t price; + int16_t removal_price; + uint8_t* frame_offsets; + uint16_t animation_delay; + uint16_t animation_mask; + uint16_t num_frames; + ObjectEntryIndex scenery_tab_id; }; struct WallSceneryEntry : SceneryEntryBase diff --git a/src/openrct2/world/SmallScenery.cpp b/src/openrct2/world/SmallScenery.cpp index 637169cbfc..c71fc753f4 100644 --- a/src/openrct2/world/SmallScenery.cpp +++ b/src/openrct2/world/SmallScenery.cpp @@ -33,7 +33,7 @@ static int32_t map_place_clear_func( if (is_scenery && !(flags & GAME_COMMAND_FLAG_PATH_SCENERY)) return 1; - rct_scenery_entry* scenery = (*tile_element)->AsSmallScenery()->GetEntry(); + auto* scenery = (*tile_element)->AsSmallScenery()->GetEntry(); if (gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL) { @@ -42,7 +42,7 @@ static int32_t map_place_clear_func( } if (!(gParkFlags & PARK_FLAGS_NO_MONEY)) - *price += scenery->small_scenery.removal_price * 10; + *price += scenery->removal_price * 10; if (flags & GAME_COMMAND_FLAG_GHOST) return 0; @@ -76,9 +76,9 @@ int32_t map_place_non_scenery_clear_func(TileElement** tile_element, const Coord return map_place_clear_func(tile_element, coords, flags, price, /*is_scenery=*/false); } -bool scenery_small_entry_has_flag(const rct_scenery_entry* sceneryEntry, uint32_t flags) +bool scenery_small_entry_has_flag(const SmallSceneryEntry* sceneryEntry, uint32_t flags) { - return static_cast(sceneryEntry->small_scenery.flags & flags); + return static_cast(sceneryEntry->flags & flags); } uint8_t SmallSceneryElement::GetSceneryQuadrant() const @@ -124,9 +124,9 @@ void SmallSceneryElement::IncreaseAge(const CoordsXY& sceneryPos) // Only invalidate tiles when scenery crosses the withering thresholds, and can be withered. if (newAge == SCENERY_WITHER_AGE_THRESHOLD_1 || newAge == SCENERY_WITHER_AGE_THRESHOLD_2) { - rct_scenery_entry* entry = GetEntry(); + auto* sceneryEntry = GetEntry(); - if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_CAN_WITHER)) + if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_CAN_WITHER)) { map_invalidate_tile_zoom1({ sceneryPos, GetBaseZ(), GetClearanceZ() }); } @@ -168,19 +168,19 @@ void SmallSceneryElement::SetNeedsSupports() colour_1 |= MAP_ELEM_SMALL_SCENERY_COLOUR_FLAG_NEEDS_SUPPORTS; } -rct_scenery_entry* SmallSceneryElement::GetEntry() const +SmallSceneryEntry* SmallSceneryElement::GetEntry() const { return get_small_scenery_entry(entryIndex); } -rct_scenery_entry* get_small_scenery_entry(ObjectEntryIndex entryIndex) +SmallSceneryEntry* get_small_scenery_entry(ObjectEntryIndex entryIndex) { - rct_scenery_entry* result = nullptr; + SmallSceneryEntry* result = nullptr; auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); auto obj = objMgr.GetLoadedObject(ObjectType::SmallScenery, entryIndex); if (obj != nullptr) { - result = static_cast(obj->GetLegacyData()); + result = static_cast(obj->GetLegacyData()); } return result; } diff --git a/src/openrct2/world/SmallScenery.h b/src/openrct2/world/SmallScenery.h index 09275bd75d..5094dcf8b8 100644 --- a/src/openrct2/world/SmallScenery.h +++ b/src/openrct2/world/SmallScenery.h @@ -53,5 +53,5 @@ enum MAP_ELEM_SMALL_SCENERY_COLOUR_FLAG_NEEDS_SUPPORTS = (1 << 5), }; -bool scenery_small_entry_has_flag(const rct_scenery_entry* sceneryEntry, uint32_t flags); -rct_scenery_entry* get_small_scenery_entry(ObjectEntryIndex entryIndex); +bool scenery_small_entry_has_flag(const SmallSceneryEntry* sceneryEntry, uint32_t flags); +SmallSceneryEntry* get_small_scenery_entry(ObjectEntryIndex entryIndex); diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index db6036f37b..abb1791706 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -18,6 +18,7 @@ struct Banner; struct CoordsXY; struct rct_scenery_entry; +struct SmallSceneryEntry; struct WallSceneryEntry; struct PathBitEntry; struct BannerSceneryEntry; @@ -461,7 +462,7 @@ private: public: ObjectEntryIndex GetEntryIndex() const; void SetEntryIndex(ObjectEntryIndex newIndex); - rct_scenery_entry* GetEntry() const; + SmallSceneryEntry* GetEntry() const; uint8_t GetAge() const; void SetAge(uint8_t newAge); void IncreaseAge(const CoordsXY& sceneryPos);