From 3c4721d0144be65324a02a99ab3462b378748ea1 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Mon, 13 Jul 2020 22:03:06 +0200 Subject: [PATCH 1/2] Move some constants to RCT12.h --- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/rct12/RCT12.cpp | 12 ++++++------ src/openrct2/rct12/RCT12.h | 4 ++++ src/openrct2/rct2/S6Exporter.cpp | 2 +- src/openrct2/rct2/S6Importer.cpp | 6 +++--- src/openrct2/world/Map.h | 3 --- src/openrct2/world/TileElement.h | 1 - 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 173e07b61c..a3882ea2b6 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1765,7 +1765,7 @@ private: gPeepSpawns.clear(); for (size_t i = 0; i < RCT12_MAX_PEEP_SPAWNS; i++) { - if (_s4.peep_spawn[i].x != PEEP_SPAWN_UNDEFINED) + if (_s4.peep_spawn[i].x != RCT12_PEEP_SPAWN_UNDEFINED) { PeepSpawn spawn = { _s4.peep_spawn[i].x, _s4.peep_spawn[i].y, _s4.peep_spawn[i].z * 16, _s4.peep_spawn[i].direction }; diff --git a/src/openrct2/rct12/RCT12.cpp b/src/openrct2/rct12/RCT12.cpp index 5144c4a053..b6444bf1d5 100644 --- a/src/openrct2/rct12/RCT12.cpp +++ b/src/openrct2/rct12/RCT12.cpp @@ -339,7 +339,7 @@ bool RCT12SmallSceneryElement::NeedsSupports() const uint32_t RCT12LargeSceneryElement::GetEntryIndex() const { - return entryIndex & TILE_ELEMENT_LARGE_TYPE_MASK; + return entryIndex & RCT12_TILE_ELEMENT_LARGE_TYPE_MASK; } uint16_t RCT12LargeSceneryElement::GetSequenceIndex() const @@ -448,7 +448,7 @@ uint8_t RCT12EntranceElement::GetRideIndex() const uint8_t RCT12EntranceElement::GetStationIndex() const { - return (index & MAP_ELEM_TRACK_SEQUENCE_STATION_INDEX_MASK) >> 4; + return (index & RCT12_TRACK_ELEMENT_SEQUENCE_STATION_INDEX_MASK) >> 4; } uint8_t RCT12EntranceElement::GetSequenceIndex() const @@ -523,13 +523,13 @@ void RCT12TileElement::ClearAs(uint8_t newType) void RCT12LargeSceneryElement::SetEntryIndex(uint32_t newIndex) { - entryIndex &= ~TILE_ELEMENT_LARGE_TYPE_MASK; - entryIndex |= (newIndex & TILE_ELEMENT_LARGE_TYPE_MASK); + entryIndex &= ~RCT12_TILE_ELEMENT_LARGE_TYPE_MASK; + entryIndex |= (newIndex & RCT12_TILE_ELEMENT_LARGE_TYPE_MASK); } void RCT12LargeSceneryElement::SetSequenceIndex(uint16_t sequence) { - entryIndex &= TILE_ELEMENT_LARGE_TYPE_MASK; + entryIndex &= RCT12_TILE_ELEMENT_LARGE_TYPE_MASK; entryIndex |= (sequence << 10); } @@ -974,7 +974,7 @@ void RCT12EntranceElement::SetSequenceIndex(uint8_t newSequenceIndex) void RCT12EntranceElement::SetStationIndex(uint8_t stationIndex) { - index &= ~MAP_ELEM_TRACK_SEQUENCE_STATION_INDEX_MASK; + index &= ~RCT12_TRACK_ELEMENT_SEQUENCE_STATION_INDEX_MASK; index |= (stationIndex << 4); } diff --git a/src/openrct2/rct12/RCT12.h b/src/openrct2/rct12/RCT12.h index b9a7a83f6d..6cbd536d15 100644 --- a/src/openrct2/rct12/RCT12.h +++ b/src/openrct2/rct12/RCT12.h @@ -54,6 +54,8 @@ constexpr const uint8_t RCT12_TILE_ELEMENT_SURFACE_EDGE_STYLE_MASK = 0xE0; // constexpr const uint8_t RCT12_TILE_ELEMENT_SURFACE_WATER_HEIGHT_MASK = 0x1F; // in RCT12TileElement.properties.surface.terrain constexpr const uint8_t RCT12_TILE_ELEMENT_SURFACE_TERRAIN_MASK = 0xE0; // in RCT12TileElement.properties.surface.terrain +constexpr const uint16_t RCT12_TILE_ELEMENT_LARGE_TYPE_MASK = 0x3FF; + constexpr uint16_t const RCT12_XY8_UNDEFINED = 0xFFFF; using RCT12ObjectEntryIndex = uint8_t; @@ -68,6 +70,8 @@ constexpr const uint32_t RCT12_RESEARCHED_ITEMS_END_2 = 0xFFFFFFFD; constexpr const uint8_t RCT12_MAX_ELEMENT_HEIGHT = 255; +constexpr const uint16_t RCT12_PEEP_SPAWN_UNDEFINED = 0xFFFF; + enum class RCT12TrackDesignVersion : uint8_t { TD4, diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index ae35d2d8bf..408886bcbe 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -439,7 +439,7 @@ void S6Exporter::ExportPeepSpawns() } else { - _s6.peep_spawns[i] = { PEEP_SPAWN_UNDEFINED, PEEP_SPAWN_UNDEFINED, 0, 0 }; + _s6.peep_spawns[i] = { RCT12_PEEP_SPAWN_UNDEFINED, RCT12_PEEP_SPAWN_UNDEFINED, 0, 0 }; } } } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 38aa04da81..e0692e0355 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -967,14 +967,14 @@ public: || String::Equals(_s6.scenario_filename, "South America - Rio Carnival.SC6")) { _s6.peep_spawns[0] = { 2160, 3167, 6, 1 }; - _s6.peep_spawns[1].x = PEEP_SPAWN_UNDEFINED; + _s6.peep_spawns[1].x = RCT12_PEEP_SPAWN_UNDEFINED; } // In this park, peep_spawns[0] is correct. Just clear the other. else if ( String::Equals(_s6.scenario_filename, "Great Wall of China Tourism Enhancement.SC6") || String::Equals(_s6.scenario_filename, "Asia - Great Wall of China Tourism Enhancement.SC6")) { - _s6.peep_spawns[1].x = PEEP_SPAWN_UNDEFINED; + _s6.peep_spawns[1].x = RCT12_PEEP_SPAWN_UNDEFINED; } // Amity Airfield has peeps entering from the corner of the tile, instead of the middle. else if (String::Equals(_s6.scenario_filename, "Amity Airfield.SC6")) @@ -991,7 +991,7 @@ public: gPeepSpawns.clear(); for (size_t i = 0; i < RCT12_MAX_PEEP_SPAWNS; i++) { - if (_s6.peep_spawns[i].x != PEEP_SPAWN_UNDEFINED) + if (_s6.peep_spawns[i].x != RCT12_PEEP_SPAWN_UNDEFINED) { PeepSpawn spawn = { _s6.peep_spawns[i].x, _s6.peep_spawns[i].y, _s6.peep_spawns[i].z * 16, _s6.peep_spawns[i].direction }; diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 8a731c5c08..3bfdb32e66 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -37,9 +37,6 @@ constexpr const uint32_t MAX_TILE_ELEMENTS_WITH_SPARE_ROOM = 0x30000; constexpr const uint32_t MAX_TILE_ELEMENTS = MAX_TILE_ELEMENTS_WITH_SPARE_ROOM - 512; #define MAX_TILE_TILE_ELEMENT_POINTERS (MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL) #define MAX_PEEP_SPAWNS 2 -#define PEEP_SPAWN_UNDEFINED 0xFFFF - -#define TILE_ELEMENT_LARGE_TYPE_MASK 0x3FF #define TILE_UNDEFINED_TILE_ELEMENT NULL diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index a45d656834..715968564d 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -638,7 +638,6 @@ enum #define TILE_ELEMENT_COLOUR_MASK 0b00011111 -#define MAP_ELEM_TRACK_SEQUENCE_STATION_INDEX_MASK 0b01110000 #define MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK 0b00001111 #define MAP_ELEM_TRACK_SEQUENCE_TAKING_PHOTO_MASK 0b11110000 From 88a5e4cd2a8c8f2efecad4f91e2057ff7cace5dc Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Mon, 13 Jul 2020 22:09:28 +0200 Subject: [PATCH 2/2] Remove some unused constants --- src/openrct2/world/TileElement.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index 715968564d..48c86c6037 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -638,9 +638,6 @@ enum #define TILE_ELEMENT_COLOUR_MASK 0b00011111 -#define MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK 0b00001111 -#define MAP_ELEM_TRACK_SEQUENCE_TAKING_PHOTO_MASK 0b11110000 - BannerIndex tile_element_get_banner_index(TileElement* tileElement); bool tile_element_is_underground(TileElement* tileElement);