From 1ea1d24f0015f2227b94b3c9c55bc4735cd78fc4 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 10 Jun 2020 23:18:26 +0200 Subject: [PATCH] Use constant for 255 tile element height (#11928) --- src/openrct2/peep/GuestPathfinding.cpp | 2 +- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/rct12/RCT12.h | 2 ++ src/openrct2/rct2/S6Exporter.cpp | 2 +- src/openrct2/rct2/S6Importer.cpp | 2 +- src/openrct2/world/Map.cpp | 6 +++--- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 36cad9cf14..1caafead68 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -1825,7 +1825,7 @@ static void get_ride_queue_end(TileCoordsXYZ& loc) break; } - if (loc.z == 0xFF) + if (loc.z == MAX_ELEMENT_HEIGHT) return; tileElement = lastPathElement; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index d0a9bfb7c4..f8d997e995 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1976,7 +1976,7 @@ private: { auto src = &_s4.tile_elements[index]; auto dst = &gTileElements[index + dstOffset]; - if (src->base_height == 0xFF) + if (src->base_height == RCT12_MAX_ELEMENT_HEIGHT) { std::memcpy(dst, src, sizeof(*src)); } diff --git a/src/openrct2/rct12/RCT12.h b/src/openrct2/rct12/RCT12.h index 0028a93bfe..d04e3113d2 100644 --- a/src/openrct2/rct12/RCT12.h +++ b/src/openrct2/rct12/RCT12.h @@ -67,6 +67,8 @@ constexpr const uint32_t RCT12_RESEARCHED_ITEMS_END = 0xFFFFFFFE; // Extra end of list entry. Leftover from RCT1. constexpr const uint32_t RCT12_RESEARCHED_ITEMS_END_2 = 0xFFFFFFFD; +constexpr const uint8_t RCT12_MAX_ELEMENT_HEIGHT = 255; + enum class RCT12TrackDesignVersion : uint8_t { TD4, diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 5609e70021..9ab5d4ec16 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -1413,7 +1413,7 @@ void S6Exporter::ExportTileElements() { auto src = &gTileElements[index]; auto dst = &_s6.tile_elements[index]; - if (src->base_height == 0xFF) + if (src->base_height == MAX_ELEMENT_HEIGHT) { std::memcpy(dst, src, sizeof(*dst)); } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index abc5f6610e..0ab01c42de 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1013,7 +1013,7 @@ public: { auto src = &_s6.tile_elements[index]; auto dst = &gTileElements[index]; - if (src->base_height == 0xFF) + if (src->base_height == RCT12_MAX_ELEMENT_HEIGHT) { std::memcpy(dst, src, sizeof(*src)); } diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index b9dd90769b..5217a81aab 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -955,7 +955,7 @@ void tile_element_remove(TileElement* tileElement) // Mark the latest element with the last element flag. (tileElement - 1)->SetLastForTile(true); - tileElement->base_height = 0xFF; + tileElement->base_height = MAX_ELEMENT_HEIGHT; if ((tileElement + 1) == gNextFreeTileElement) { @@ -1178,7 +1178,7 @@ TileElement* tile_element_insert(const CoordsXYZ& loc, int32_t occupiedQuadrants { // Copy over map element *newTileElement = *originalTileElement; - originalTileElement->base_height = 255; + originalTileElement->base_height = MAX_ELEMENT_HEIGHT; originalTileElement++; newTileElement++; @@ -1211,7 +1211,7 @@ TileElement* tile_element_insert(const CoordsXYZ& loc, int32_t occupiedQuadrants { // Copy over map element *newTileElement = *originalTileElement; - originalTileElement->base_height = 255; + originalTileElement->base_height = MAX_ELEMENT_HEIGHT; originalTileElement++; newTileElement++; } while (!((newTileElement - 1)->IsLastForTile()));