diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 2088f61e2a..1eaaf10e7c 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2454,7 +2454,7 @@ static void sub_6CBCE2( _tempTrackTileElement.SetDirection(trackDirection); _tempTrackTileElement.AsTrack()->SetHasChain((edx & 0x10000) != 0); _tempTrackTileElement.flags = quarterTile.GetBaseQuarterOccupied(); - _tempTrackTileElement.SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, true); + _tempTrackTileElement.SetLastForTile(true); _tempTrackTileElement.base_height = baseZ; _tempTrackTileElement.clearance_height = clearanceZ; _tempTrackTileElement.AsTrack()->SetTrackType(trackType); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index c506723857..73e6450338 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2694,7 +2694,7 @@ private: for (int32_t y = 0; y < RCT1_MAX_MAP_SIZE; y++) { nextFreeTileElement->ClearAs(TILE_ELEMENT_TYPE_SURFACE); - nextFreeTileElement->SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, true); + nextFreeTileElement->SetLastForTile(true); nextFreeTileElement->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); nextFreeTileElement->AsSurface()->SetSurfaceStyle(TERRAIN_GRASS); nextFreeTileElement->AsSurface()->SetEdgeStyle(TERRAIN_EDGE_ROCK); @@ -2708,7 +2708,7 @@ private: for (int32_t y = 0; y < 128 * 256; y++) { nextFreeTileElement->ClearAs(TILE_ELEMENT_TYPE_SURFACE); - nextFreeTileElement->SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, true); + nextFreeTileElement->SetLastForTile(true); nextFreeTileElement->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); nextFreeTileElement->AsSurface()->SetSurfaceStyle(TERRAIN_GRASS); nextFreeTileElement->AsSurface()->SetEdgeStyle(TERRAIN_EDGE_ROCK); diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index a4ef65e500..b60d97f6dd 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -2411,7 +2411,7 @@ static void track_design_preview_clear_map() { TileElement* tile_element = &gTileElements[i]; tile_element->ClearAs(TILE_ELEMENT_TYPE_SURFACE); - tile_element->SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, true); + tile_element->SetLastForTile(true); tile_element->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); tile_element->AsSurface()->SetWaterHeight(0); tile_element->AsSurface()->SetSurfaceStyle(TERRAIN_GRASS); diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 436fe2cbb4..8e3f6c2a74 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -310,7 +310,7 @@ void map_init(int32_t size) { TileElement* tile_element = &gTileElements[i]; tile_element->ClearAs(TILE_ELEMENT_TYPE_SURFACE); - tile_element->SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, true); + tile_element->SetLastForTile(true); tile_element->base_height = 14; tile_element->clearance_height = 14; tile_element->AsSurface()->SetWaterHeight(0); @@ -957,7 +957,7 @@ void tile_element_remove(TileElement* tileElement) } // Mark the latest element with the last element flag. - (tileElement - 1)->SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, true); + (tileElement - 1)->SetLastForTile(true); tileElement->base_height = 0xFF; if ((tileElement + 1) == gNextFreeTileElement) @@ -1181,8 +1181,7 @@ TileElement* tile_element_insert(const TileCoordsXYZ& loc, int32_t flags) if ((newTileElement - 1)->IsLastForTile()) { // No more elements above the insert element - (newTileElement - 1)->SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, false); - ; + (newTileElement - 1)->SetLastForTile(false); flags |= TILE_ELEMENT_FLAG_LAST_TILE; break; } diff --git a/src/openrct2/world/TileElement.cpp b/src/openrct2/world/TileElement.cpp index 3efd7d3e48..7324e3d4de 100644 --- a/src/openrct2/world/TileElement.cpp +++ b/src/openrct2/world/TileElement.cpp @@ -49,6 +49,14 @@ bool TileElementBase::IsLastForTile() const return (this->flags & TILE_ELEMENT_FLAG_LAST_TILE) != 0; } +void TileElementBase::SetLastForTile(bool on) +{ + if (on) + flags |= TILE_ELEMENT_FLAG_LAST_TILE; + else + flags &= ~TILE_ELEMENT_FLAG_LAST_TILE; +} + bool TileElementBase::IsGhost() const { return (this->flags & TILE_ELEMENT_FLAG_GHOST) != 0; @@ -205,16 +213,3 @@ const QuarterTile QuarterTile::Rotate(uint8_t amount) const return QuarterTile{ 0 }; } } - -bool TileElementBase::HasFlag(uint8_t flag) const -{ - return (flags & flag); -} - -void TileElementBase::SetFlag(uint8_t flag, bool on) -{ - if (on) - flags |= flag; - else - flags &= ~flag; -} diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index a1fe1cdcb9..d10c188763 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -71,12 +71,10 @@ struct TileElementBase void SetDirection(uint8_t direction); uint8_t GetDirectionWithOffset(uint8_t offset) const; bool IsLastForTile() const; + void SetLastForTile(bool on); bool IsGhost() const; void SetGhost(bool isGhost); void Remove(); - - bool HasFlag(uint8_t flag) const; - void SetFlag(uint8_t flag, bool on); }; /** diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 80bc7eb025..a782d4ee95 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -65,8 +65,8 @@ static bool map_swap_elements_at(CoordsXY loc, int16_t first, int16_t second) // Swap the 'last map element for tile' flag if either one of them was last if ((firstElement)->IsLastForTile() || (secondElement)->IsLastForTile()) { - firstElement->SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, !firstElement->IsLastForTile()); - secondElement->SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, !secondElement->IsLastForTile()); + firstElement->SetLastForTile(!firstElement->IsLastForTile()); + secondElement->SetLastForTile(!secondElement->IsLastForTile()); } return true; @@ -324,7 +324,7 @@ GameActionResult::Ptr tile_inspector_paste_element_at(CoordsXY loc, TileElement bool lastForTile = pastedElement->IsLastForTile(); *pastedElement = element; - pastedElement->SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, lastForTile); + pastedElement->SetLastForTile(lastForTile); map_invalidate_tile_full(loc.x, loc.y); diff --git a/test/testpaint/Compat.cpp b/test/testpaint/Compat.cpp index 61eb2a01ca..3f6647a253 100644 --- a/test/testpaint/Compat.cpp +++ b/test/testpaint/Compat.cpp @@ -155,24 +155,19 @@ rct_sprite* get_sprite(size_t sprite_idx) return &sprite_list[sprite_idx]; } -bool TileElementBase::HasFlag(uint8_t flag) const -{ - return (flags & flag); -} - -void TileElementBase::SetFlag(uint8_t flag, bool on) -{ - if (on) - flags |= flag; - else - flags &= ~flag; -} - bool TileElementBase::IsLastForTile() const { return (this->flags & TILE_ELEMENT_FLAG_LAST_TILE) != 0; } +void TileElementBase::SetLastForTile(bool on) +{ + if (on) + flags |= TILE_ELEMENT_FLAG_LAST_TILE; + else + flags &= ~TILE_ELEMENT_FLAG_LAST_TILE; +} + uint8_t TileElementBase::GetType() const { return this->type & TILE_ELEMENT_TYPE_MASK; diff --git a/test/testpaint/TestTrack.cpp b/test/testpaint/TestTrack.cpp index ff26a725c9..a97cd823dc 100644 --- a/test/testpaint/TestTrack.cpp +++ b/test/testpaint/TestTrack.cpp @@ -262,7 +262,7 @@ static uint8_t TestTrackElementPaintCalls(uint8_t rideType, uint8_t trackType, u TileElement tileElement = {}; tileElement.SetType(TILE_ELEMENT_TYPE_TRACK); - tileElement.SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, true); + tileElement.SetLastForTile(true); tileElement.AsTrack()->SetTrackType(trackType); tileElement.base_height = height / 16; g_currently_drawn_item = &tileElement; @@ -425,7 +425,7 @@ static uint8_t TestTrackElementSegmentSupportHeight( TileElement tileElement = {}; tileElement.SetType(TILE_ELEMENT_TYPE_TRACK); - tileElement.SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, true); + tileElement.SetLastForTile(true); tileElement.AsTrack()->SetTrackType(trackType); tileElement.base_height = height / 16; g_currently_drawn_item = &tileElement; @@ -512,7 +512,7 @@ static uint8_t TestTrackElementGeneralSupportHeight( TileElement tileElement = {}; tileElement.SetType(TILE_ELEMENT_TYPE_TRACK); - tileElement.SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, true); + tileElement.SetLastForTile(true); tileElement.AsTrack()->SetTrackType(trackType); tileElement.base_height = height / 16; g_currently_drawn_item = &tileElement; @@ -613,7 +613,7 @@ static uint8_t TestTrackElementSideTunnels(uint8_t rideType, uint8_t trackType, TileElement tileElement = {}; tileElement.SetType(TILE_ELEMENT_TYPE_TRACK); - tileElement.SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, true); + tileElement.SetLastForTile(true); tileElement.AsTrack()->SetTrackType(trackType); tileElement.base_height = height / 16; g_currently_drawn_item = &tileElement; @@ -741,7 +741,7 @@ static uint8_t TestTrackElementVerticalTunnels(uint8_t rideType, uint8_t trackTy TileElement tileElement = {}; tileElement.SetType(TILE_ELEMENT_TYPE_TRACK); - tileElement.SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, true); + tileElement.SetLastForTile(true); tileElement.AsTrack()->SetTrackType(trackType); tileElement.base_height = height / 16; g_currently_drawn_item = &tileElement; diff --git a/test/testpaint/generate.cpp b/test/testpaint/generate.cpp index bf5ca86faa..1ef2cf8ba9 100644 --- a/test/testpaint/generate.cpp +++ b/test/testpaint/generate.cpp @@ -446,7 +446,7 @@ private: { TileElement tileElement = {}; tileElement.SetType(TILE_ELEMENT_TYPE_TRACK); - tileElement.SetFlag(TILE_ELEMENT_FLAG_LAST_TILE, true); + tileElement.SetLastForTile(true); tileElement.AsTrack()->SetTrackType(trackType); tileElement.base_height = 3; if (_invertedTrack)