From 50c0080da84fed51bfbdd8ca32e8a8e1a00190f4 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Fri, 10 Dec 2021 22:58:27 +0100 Subject: [PATCH] Update calls to ClearAs() --- src/openrct2/rct1/S4Importer.cpp | 4 ++-- src/openrct2/rct2/S6Importer.cpp | 4 ++-- src/openrct2/ride/TrackDesign.cpp | 2 +- src/openrct2/world/Map.cpp | 4 ++-- src/openrct2/world/TileElement.cpp | 5 +++-- src/openrct2/world/TileElement.h | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 0906c30625..dfece1242d 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1533,7 +1533,7 @@ namespace RCT1 { // Add a default surface element, we always need at least one element per tile auto& dstElement = tileElements.emplace_back(); - dstElement.ClearAs(TILE_ELEMENT_TYPE_SURFACE); + dstElement.ClearAs(TileElementTypeN::Surface); dstElement.SetLastForTile(true); } @@ -1553,7 +1553,7 @@ namespace RCT1 { // Todo: allow for changing definition of OpenRCT2 tile element types - replace with a map uint8_t tileElementType = src->GetType(); - dst->ClearAs(tileElementType); + dst->ClearAs(static_cast(tileElementType >> 2)); dst->SetDirection(src->GetDirection()); // All saved in "flags" diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 91e09c9ad5..0aa8a040e5 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1167,7 +1167,7 @@ namespace RCT2 { // Add a default surface element, we always need at least one element per tile auto& dstElement = tileElements.emplace_back(); - dstElement.ClearAs(TILE_ELEMENT_TYPE_SURFACE); + dstElement.ClearAs(TileElementTypeN::Surface); dstElement.SetLastForTile(true); } @@ -1185,7 +1185,7 @@ namespace RCT2 { // Todo: allow for changing definition of OpenRCT2 tile element types - replace with a map uint8_t tileElementType = src->GetType(); - dst->ClearAs(tileElementType); + dst->ClearAs(static_cast(tileElementType >> 2)); dst->SetDirection(src->GetDirection()); dst->SetBaseZ(src->base_height * COORDS_Z_STEP); dst->SetClearanceZ(src->clearance_height * COORDS_Z_STEP); diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 51cfcaa3de..3977579ea7 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -2160,7 +2160,7 @@ static void TrackDesignPreviewClearMap() for (int32_t i = 0; i < numTiles; i++) { auto* element = &tileElements.emplace_back(); - element->ClearAs(TILE_ELEMENT_TYPE_SURFACE); + element->ClearAs(TileElementTypeN::Surface); element->SetLastForTile(true); element->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); element->AsSurface()->SetWaterHeight(0); diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 5286656cd1..76839dce67 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -154,7 +154,7 @@ void SetTileElements(std::vector&& tileElements) static TileElement GetDefaultSurfaceElement() { TileElement el; - el.ClearAs(TILE_ELEMENT_TYPE_SURFACE); + el.ClearAs(TileElementTypeN::Surface); el.SetLastForTile(true); el.base_height = 14; el.clearance_height = 14; @@ -433,7 +433,7 @@ void map_init(int32_t size) for (int32_t i = 0; i < numTiles; i++) { auto* element = &tileElements[i]; - element->ClearAs(TILE_ELEMENT_TYPE_SURFACE); + element->ClearAs(TileElementTypeN::Surface); element->SetLastForTile(true); element->base_height = 14; element->clearance_height = 14; diff --git a/src/openrct2/world/TileElement.cpp b/src/openrct2/world/TileElement.cpp index 8599c899aa..c0ac600f60 100644 --- a/src/openrct2/world/TileElement.cpp +++ b/src/openrct2/world/TileElement.cpp @@ -101,9 +101,10 @@ ride_id_t TileElement::GetRideIndex() const } } -void TileElement::ClearAs(uint8_t newType) +void TileElement::ClearAs(TileElementTypeN newType) { - type = newType; + type = 0; + SetTypeN(newType); Flags = 0; base_height = MINIMUM_LAND_HEIGHT; clearance_height = MINIMUM_LAND_HEIGHT; diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index 463f53edb2..c3bab553ed 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -199,7 +199,7 @@ struct TileElement : public TileElementBase uint8_t pad_05[3]; uint8_t pad_08[8]; - void ClearAs(uint8_t newType); + void ClearAs(TileElementTypeN newType); ride_id_t GetRideIndex() const;