diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 563d355a57..14ddfb57fb 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -1877,7 +1877,7 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi) gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_SCENERY_AGE, &age, COLOUR_DARK_GREEN, x, y); // Quadrant value - const rct_scenery_entry* sceneryEntry = get_small_scenery_entry(tileElement->properties.scenery.type); + const rct_scenery_entry* sceneryEntry = get_small_scenery_entry(tileElement->AsSmallScenery()->GetEntryIndex()); if (!(scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE))) { int16_t quadrant = tileElement->AsSmallScenery()->GetSceneryQuadrant(); @@ -1890,7 +1890,7 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi) } // Scenery ID - int16_t idx = tileElement->properties.scenery.type; + int16_t idx = tileElement->AsSmallScenery()->GetEntryIndex(); gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_SCENERY_ENTRY_IDX, &idx, COLOUR_DARK_GREEN, x, y + 22); // Properties @@ -2148,7 +2148,7 @@ static void window_tile_inspector_scrollpaint(rct_window* w, rct_drawpixelinfo* case TILE_ELEMENT_TYPE_SMALL_SCENERY: snprintf( buffer, sizeof(buffer), "%s (%s)", language_get_string(STR_OBJECT_SELECTION_SMALL_SCENERY), - language_get_string(get_small_scenery_entry(tileElement->properties.scenery.type)->name)); + language_get_string(get_small_scenery_entry(tileElement->AsSmallScenery()->GetEntryIndex())->name)); typeName = buffer; break; case TILE_ELEMENT_TYPE_ENTRANCE: @@ -2157,7 +2157,7 @@ static void window_tile_inspector_scrollpaint(rct_window* w, rct_drawpixelinfo* case TILE_ELEMENT_TYPE_WALL: snprintf( buffer, sizeof(buffer), "%s (%s)", language_get_string(STR_TILE_INSPECTOR_WALL), - language_get_string(get_wall_entry(tileElement->properties.scenery.type)->name)); + language_get_string(get_wall_entry(tileElement->AsSmallScenery()->GetEntryIndex())->name)); typeName = buffer; break; case TILE_ELEMENT_TYPE_LARGE_SCENERY: diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index 922460b42c..b6fe39f8cd 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -143,7 +143,7 @@ void setup_in_use_selection_flags() } break; case TILE_ELEMENT_TYPE_SMALL_SCENERY: - type = iter.element->properties.scenery.type; + type = iter.element->AsSmallScenery()->GetEntryIndex(); assert(type < object_entry_group_counts[OBJECT_TYPE_SMALL_SCENERY]); Editor::SetSelectedObject(OBJECT_TYPE_SMALL_SCENERY, type, OBJECT_SELECTION_FLAG_SELECTED); break; diff --git a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp index 2bf474d9ee..78711da702 100644 --- a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp @@ -59,7 +59,7 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co } uint32_t dword_F64EB0 = baseImageid; - rct_scenery_entry* entry = get_small_scenery_entry(tileElement->properties.scenery.type); + rct_scenery_entry* entry = get_small_scenery_entry(tileElement->AsSmallScenery()->GetEntryIndex()); if (entry == nullptr) { diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index a20217d4cf..f9c0da89e2 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -1738,7 +1738,7 @@ void rct_peep::UpdateWatering() if (abs(((int32_t)next_z) - tile_element->base_height) > 4) continue; - rct_scenery_entry* scenery_entry = get_small_scenery_entry(tile_element->properties.scenery.type); + rct_scenery_entry* scenery_entry = get_small_scenery_entry(tile_element->AsSmallScenery()->GetEntryIndex()); if (!scenery_small_entry_has_flag(scenery_entry, SMALL_SCENERY_FLAG_CAN_BE_WATERED)) continue; @@ -2152,7 +2152,7 @@ static int32_t peep_update_patrolling_find_watering(rct_peep* peep) continue; } - rct_scenery_entry* sceneryEntry = get_small_scenery_entry(tile_element->properties.scenery.type); + rct_scenery_entry* sceneryEntry = get_small_scenery_entry(tile_element->AsSmallScenery()->GetEntryIndex()); if (sceneryEntry == nullptr || !scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_CAN_BE_WATERED)) { diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index ae8bc40b8d..605248921f 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -490,7 +490,7 @@ private: break; } case TILE_ELEMENT_TYPE_SMALL_SCENERY: - AddEntryForSmallScenery(tileElement->properties.scenery.type); + AddEntryForSmallScenery(tileElement->AsSmallScenery()->GetEntryIndex()); break; case TILE_ELEMENT_TYPE_LARGE_SCENERY: AddEntryForLargeScenery(scenery_large_get_type(tileElement)); @@ -2451,7 +2451,7 @@ private: scenery_small_set_primary_colour(tileElement, colour); // Copied from [rct2: 0x006A2956] - switch (tileElement->properties.scenery.type) + switch (tileElement->AsSmallScenery()->GetEntryIndex()) { case RCT1_SCENERY_GEOMETRIC_SCULPTURE_1: case RCT1_SCENERY_GEOMETRIC_SCULPTURE_2: @@ -2729,7 +2729,7 @@ private: switch (tileElement->GetType()) { case TILE_ELEMENT_TYPE_SMALL_SCENERY: - tileElement->properties.scenery.type = _smallSceneryTypeToEntryMap[tileElement->properties.scenery.type]; + tileElement->properties.scenery.type = _smallSceneryTypeToEntryMap[tileElement->AsSmallScenery()->GetEntryIndex()]; break; case TILE_ELEMENT_TYPE_LARGE_SCENERY: { diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index a025e8c9fc..c4c347eb8c 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -291,7 +291,7 @@ static void track_design_save_push_tile_element_desc( static void track_design_save_add_scenery(int32_t x, int32_t y, rct_tile_element* tileElement) { - int32_t entryType = tileElement->properties.scenery.type; + int32_t entryType = tileElement->AsSmallScenery()->GetEntryIndex(); auto entry = object_entry_get_entry(OBJECT_TYPE_SMALL_SCENERY, entryType); uint8_t flags = 0; @@ -485,7 +485,7 @@ static void track_design_save_pop_tile_element_desc( static void track_design_save_remove_scenery(int32_t x, int32_t y, rct_tile_element* tileElement) { - int32_t entryType = tileElement->properties.scenery.type; + int32_t entryType = tileElement->AsSmallScenery()->GetEntryIndex(); auto entry = object_entry_get_entry(OBJECT_TYPE_SMALL_SCENERY, entryType); uint8_t flags = 0; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index a7acb5e92b..fa133f1d29 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -1842,7 +1842,7 @@ static void vehicle_update_measurements(rct_vehicle* vehicle) if (tile_element->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) continue; - rct_scenery_entry* scenery = get_small_scenery_entry(tile_element->properties.scenery.type); + rct_scenery_entry* scenery = get_small_scenery_entry(tile_element->AsSmallScenery()->GetEntryIndex()); if (scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_FULL_TILE)) { cover_found = true; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 5d448e6a3e..8ed907b070 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1098,7 +1098,7 @@ restart_from_beginning: int32_t eax = x * 32; int32_t ebx = (tileElement->type << 8) | flags; int32_t ecx = y * 32; - int32_t edx = (tileElement->properties.scenery.type << 8) | (tileElement->base_height); + int32_t edx = (tileElement->AsSmallScenery()->GetEntryIndex() << 8) | (tileElement->base_height); int32_t edi = 0, ebp = 0; cost = game_do_command(eax, ebx, ecx, edx, GAME_COMMAND_REMOVE_SCENERY, edi, ebp); @@ -1601,7 +1601,7 @@ static money32 map_set_land_height(int32_t flags, int32_t x, int32_t y, int32_t continue; if (height + 4 < tileElement->base_height) continue; - rct_scenery_entry* sceneryEntry = get_small_scenery_entry(tileElement->properties.scenery.type); + rct_scenery_entry* sceneryEntry = get_small_scenery_entry(tileElement->AsSmallScenery()->GetEntryIndex()); if (sceneryEntry->small_scenery.height > 64 && gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL) { map_obstruction_set_error_text(tileElement); @@ -3440,7 +3440,7 @@ void map_obstruction_set_error_text(rct_tile_element* tileElement) set_format_arg(2, uint32_t, ride->name_arguments); break; case TILE_ELEMENT_TYPE_SMALL_SCENERY: - sceneryEntry = get_small_scenery_entry(tileElement->properties.scenery.type); + sceneryEntry = get_small_scenery_entry(tileElement->AsSmallScenery()->GetEntryIndex()); errorStringId = STR_X_IN_THE_WAY; set_format_arg(0, rct_string_id, sceneryEntry->name); break; @@ -3459,7 +3459,7 @@ void map_obstruction_set_error_text(rct_tile_element* tileElement) } break; case TILE_ELEMENT_TYPE_WALL: - sceneryEntry = get_wall_entry(tileElement->properties.scenery.type); + sceneryEntry = get_wall_entry(tileElement->AsSmallScenery()->GetEntryIndex()); errorStringId = STR_X_IN_THE_WAY; set_format_arg(0, rct_string_id, sceneryEntry->name); break; @@ -4174,7 +4174,7 @@ rct_tile_element* map_get_small_scenery_element_at(int32_t x, int32_t y, int32_t continue; if (tileElement->base_height != z) continue; - if (tileElement->properties.scenery.type != type) + if (tileElement->AsSmallScenery()->GetEntryIndex() != type) continue; return tileElement; @@ -4461,7 +4461,7 @@ bool map_surface_is_blocked(int16_t x, int16_t y) if (tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) return true; - rct_scenery_entry* scenery = get_small_scenery_entry(tileElement->properties.scenery.type); + rct_scenery_entry* scenery = get_small_scenery_entry(tileElement->AsSmallScenery()->GetEntryIndex()); if (scenery == nullptr) { return false; diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index 7f9b181eb4..a71b3ffdc6 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -118,7 +118,7 @@ void scenery_update_age(int32_t x, int32_t y, rct_tile_element* tileElement) rct_tile_element* tileElementAbove; rct_scenery_entry* sceneryEntry; - sceneryEntry = get_small_scenery_entry(tileElement->properties.scenery.type); + sceneryEntry = get_small_scenery_entry(tileElement->AsSmallScenery()->GetEntryIndex()); if (sceneryEntry == nullptr) { return; @@ -156,7 +156,7 @@ void scenery_update_age(int32_t x, int32_t y, rct_tile_element* tileElement) scenery_increase_age(x, y, tileElement); return; case TILE_ELEMENT_TYPE_SMALL_SCENERY: - sceneryEntry = get_small_scenery_entry(tileElementAbove->properties.scenery.type); + sceneryEntry = get_small_scenery_entry(tileElementAbove->AsSmallScenery()->GetEntryIndex()); if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) { scenery_increase_age(x, y, tileElement); @@ -183,7 +183,7 @@ void scenery_increase_age(int32_t x, int32_t y, rct_tile_element* tileElement) // Only invalidate tiles when scenery crosses the withering threshholds, and can be withered. if (newAge == SCENERY_WITHER_AGE_THRESHOLD_1 || newAge == SCENERY_WITHER_AGE_THRESHOLD_2) { - rct_scenery_entry* entry = get_small_scenery_entry(tileElement->properties.scenery.type); + rct_scenery_entry* entry = get_small_scenery_entry(tileElement->AsSmallScenery()->GetEntryIndex()); if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_CAN_WITHER)) { diff --git a/src/openrct2/world/SmallScenery.cpp b/src/openrct2/world/SmallScenery.cpp index dd8983be34..63eadd4e95 100644 --- a/src/openrct2/world/SmallScenery.cpp +++ b/src/openrct2/world/SmallScenery.cpp @@ -78,7 +78,7 @@ static money32 SmallSceneryRemove( continue; if (tileElement->base_height != baseHeight) continue; - if (tileElement->properties.scenery.type != sceneryType) + if (tileElement->AsSmallScenery()->GetEntryIndex() != sceneryType) continue; if ((flags & GAME_COMMAND_FLAG_GHOST) && !(tileElement->flags & TILE_ELEMENT_FLAG_GHOST)) continue; @@ -446,7 +446,7 @@ int32_t map_place_scenery_clear_func(rct_tile_element** tile_element, int32_t x, if (!(flags & GAME_COMMAND_FLAG_PATH_SCENERY)) return 1; - rct_scenery_entry* scenery = get_small_scenery_entry((*tile_element)->properties.scenery.type); + rct_scenery_entry* scenery = get_small_scenery_entry((*tile_element)->AsSmallScenery()->GetEntryIndex()); if (gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL) { @@ -480,7 +480,7 @@ int32_t map_place_non_scenery_clear_func(rct_tile_element** tile_element, int32_ if ((*tile_element)->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) return 1; - rct_scenery_entry* scenery = get_small_scenery_entry((*tile_element)->properties.scenery.type); + rct_scenery_entry* scenery = get_small_scenery_entry((*tile_element)->AsSmallScenery()->GetEntryIndex()); if (gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL) { @@ -555,3 +555,13 @@ bool scenery_small_entry_has_flag(const rct_scenery_entry* sceneryEntry, uint32_ { return (bool)(sceneryEntry->small_scenery.flags & flags); } + +uint8_t SmallSceneryElement::GetSceneryQuadrant() const +{ + return (this->type & TILE_ELEMENT_QUADRANT_MASK) >> 6; +} + +uint8_t SmallSceneryElement::GetEntryIndex() const +{ + return this->type; +} \ No newline at end of file diff --git a/src/openrct2/world/TileElement.cpp b/src/openrct2/world/TileElement.cpp index 41b06ce4ea..1cefdb2659 100644 --- a/src/openrct2/world/TileElement.cpp +++ b/src/openrct2/world/TileElement.cpp @@ -54,11 +54,6 @@ bool TileElementBase::IsGhost() const return (this->flags & TILE_ELEMENT_FLAG_GHOST) != 0; } -uint8_t SmallSceneryElement::GetSceneryQuadrant() const -{ - return (this->type & TILE_ELEMENT_QUADRANT_MASK) >> 6; -} - uint8_t WallElement::GetSlope() const { return (this->type & TILE_ELEMENT_QUADRANT_MASK) >> 6; diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index 64ccaca4ef..98ffcd9157 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -224,8 +224,12 @@ assert_struct_size(TrackElement, 8); struct SmallSceneryElement : TileElementBase { - rct_tile_element_scenery_properties temp; + uint8_t type; // 4 + uint8_t age; // 5 + uint8_t colour_1; // 6 + uint8_t colour_2; // 7 public: + uint8_t GetEntryIndex() const; uint8_t GetSceneryQuadrant() const; }; assert_struct_size(SmallSceneryElement, 8); diff --git a/src/openrct2/world/Wall.cpp b/src/openrct2/world/Wall.cpp index b14432a7a1..c9e8a204c8 100644 --- a/src/openrct2/world/Wall.cpp +++ b/src/openrct2/world/Wall.cpp @@ -221,7 +221,7 @@ static bool WallCheckObstruction( } break; case TILE_ELEMENT_TYPE_SMALL_SCENERY: - entryType = tileElement->properties.scenery.type; + entryType = tileElement->AsSmallScenery()->GetEntryIndex(); entry = get_small_scenery_entry(entryType); if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_NO_WALLS)) {