From fb6dd4bfad869a5d5b2ac648f780b2032513571e Mon Sep 17 00:00:00 2001 From: ifimfree Date: Mon, 20 Apr 2020 04:39:26 -0400 Subject: [PATCH] Create constants for a few flags --- src/openrct2/EditorObjectSelectionSession.cpp | 8 +++--- src/openrct2/EditorObjectSelectionSession.h | 7 +++++ src/openrct2/paint/Supports.cpp | 4 +-- src/openrct2/paint/Supports.h | 5 ++++ src/openrct2/ride/Ride.cpp | 26 +++++++++---------- src/openrct2/ride/Ride.h | 17 +++++++++++- src/openrct2/world/Footpath.cpp | 8 +++--- src/openrct2/world/Footpath.h | 7 +++++ 8 files changed, 58 insertions(+), 24 deletions(-) diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index b03a3f179f..dbfbf5c0e9 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -433,7 +433,7 @@ int32_t window_editor_object_selection_select_object(uint8_t bh, int32_t flags, } uint8_t objectType = item->ObjectEntry.GetType(); - if (objectType == OBJECT_TYPE_SCENERY_GROUP && (flags & (1 << 2))) + if (objectType == OBJECT_TYPE_SCENERY_GROUP && (flags & INPUT_FLAG_EDITOR_OBJECT_2)) { for (const auto& sgEntry : item->SceneryGroupInfo.Entries) { @@ -449,7 +449,7 @@ int32_t window_editor_object_selection_select_object(uint8_t bh, int32_t flags, { if (bh == 0) { - if (flags & (1 << 3)) + if (flags & INPUT_FLAG_EDITOR_OBJECT_ALWAYS_REQUIRED) { *selectionFlags |= OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED; } @@ -472,7 +472,7 @@ int32_t window_editor_object_selection_select_object(uint8_t bh, int32_t flags, return 0; } - if (objectType == OBJECT_TYPE_SCENERY_GROUP && (flags & (1 << 2))) + if (objectType == OBJECT_TYPE_SCENERY_GROUP && (flags & INPUT_FLAG_EDITOR_OBJECT_2)) { for (const auto& sgEntry : item->SceneryGroupInfo.Entries) { @@ -483,7 +483,7 @@ int32_t window_editor_object_selection_select_object(uint8_t bh, int32_t flags, } } - if (bh != 0 && !(flags & (1 << 1))) + if (bh != 0 && !(flags & INPUT_FLAG_EDITOR_OBJECT_1)) { char objectName[64]; object_create_identifier_name(objectName, 64, &item->ObjectEntry); diff --git a/src/openrct2/EditorObjectSelectionSession.h b/src/openrct2/EditorObjectSelectionSession.h index 0b6f94fb11..913a22a560 100644 --- a/src/openrct2/EditorObjectSelectionSession.h +++ b/src/openrct2/EditorObjectSelectionSession.h @@ -14,6 +14,13 @@ #include +enum INPUT_FLAGS +{ + INPUT_FLAG_EDITOR_OBJECT_1 = (1 << 1), + INPUT_FLAG_EDITOR_OBJECT_2 = (1 << 2), + INPUT_FLAG_EDITOR_OBJECT_ALWAYS_REQUIRED = (1 << 3) +}; + extern bool _maxObjectsWasHit; extern std::vector _objectSelectionFlags; extern int32_t _numSelectedObjectsForType[OBJECT_TYPE_COUNT]; diff --git a/src/openrct2/paint/Supports.cpp b/src/openrct2/paint/Supports.cpp index 542e221b07..b82f84304d 100644 --- a/src/openrct2/paint/Supports.cpp +++ b/src/openrct2/paint/Supports.cpp @@ -371,7 +371,7 @@ bool wooden_a_supports_paint_setup( // Draw base support (usually shaped to the slope) int32_t slope = session->Support.slope; - if (slope & (1 << 5)) + if (slope & SUPPORTS_SLOPE_5) { // Above scenery (just put a base piece above it) drawFlatPiece = true; @@ -765,7 +765,7 @@ bool metal_a_supports_paint_setup( segment = newSegment; } int16_t si = height; - if (supportSegments[segment].slope & (1 << 5) || height - supportSegments[segment].height < 6 + if (supportSegments[segment].slope & SUPPORTS_SLOPE_5 || height - supportSegments[segment].height < 6 || _97B15C[supportType].base_id == 0) { height = supportSegments[segment].height; diff --git a/src/openrct2/paint/Supports.h b/src/openrct2/paint/Supports.h index 7f19ba795a..5aee80090d 100644 --- a/src/openrct2/paint/Supports.h +++ b/src/openrct2/paint/Supports.h @@ -48,4 +48,9 @@ enum METAL_SUPPORTS_BOXED_COATED // Does not seem to be used in RCT2, but it was used in RCT1 for one of the path support types. }; +enum +{ + SUPPORTS_SLOPE_5 = 1 << 5 +}; + #endif diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 306abf37e6..946f70b2f3 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -438,7 +438,7 @@ bool track_block_get_next_from_zero( int16_t x, int16_t y, int16_t z_start, Ride* ride, uint8_t direction_start, CoordsXYE* output, int32_t* z, int32_t* direction, bool isGhost) { - if (!(direction_start & (1 << 2))) + if (!(direction_start & TRACK_BLOCK_2)) { x += CoordsDirectionDelta[direction_start].x; y += CoordsDirectionDelta[direction_start].y; @@ -476,7 +476,7 @@ bool track_block_get_next_from_zero( continue; uint8_t nextRotation = tileElement->GetDirectionWithOffset(nextTrackCoordinate->rotation_begin) - | (nextTrackCoordinate->rotation_begin & (1 << 2)); + | (nextTrackCoordinate->rotation_begin & TRACK_BLOCK_2); if (nextRotation != direction_start) continue; @@ -546,7 +546,7 @@ bool track_block_get_next(CoordsXYE* input, CoordsXYE* output, int32_t* z, int32 OriginZ += trackCoordinate->z_end; uint8_t directionStart = ((trackCoordinate->rotation_end + rotation) & TILE_ELEMENT_DIRECTION_MASK) - | (trackCoordinate->rotation_end & (1 << 2)); + | (trackCoordinate->rotation_end & TRACK_BLOCK_2); return track_block_get_next_from_zero(coords.x, coords.y, OriginZ, ride, directionStart, output, z, direction, false); } @@ -565,7 +565,7 @@ bool track_block_get_previous_from_zero( uint8_t directionStart = direction; direction = direction_reverse(direction); - if (!(direction & (1 << 2))) + if (!(direction & TRACK_BLOCK_2)) { x += CoordsDirectionDelta[direction].x; y += CoordsDirectionDelta[direction].y; @@ -603,7 +603,7 @@ bool track_block_get_previous_from_zero( continue; uint8_t nextRotation = tileElement->GetDirectionWithOffset(nextTrackCoordinate->rotation_end) - | (nextTrackCoordinate->rotation_end & (1 << 2)); + | (nextTrackCoordinate->rotation_end & TRACK_BLOCK_2); if (nextRotation != directionStart) continue; @@ -613,7 +613,7 @@ bool track_block_get_previous_from_zero( continue; nextRotation = tileElement->GetDirectionWithOffset(nextTrackCoordinate->rotation_begin) - | (nextTrackCoordinate->rotation_begin & (1 << 2)); + | (nextTrackCoordinate->rotation_begin & TRACK_BLOCK_2); outTrackBeginEnd->begin_element = tileElement; outTrackBeginEnd->begin_x = x; outTrackBeginEnd->begin_y = y; @@ -689,7 +689,7 @@ bool track_block_get_previous(int32_t x, int32_t y, TileElement* tileElement, tr z += trackCoordinate->z_begin; rotation = ((trackCoordinate->rotation_begin + rotation) & TILE_ELEMENT_DIRECTION_MASK) - | (trackCoordinate->rotation_begin & (1 << 2)); + | (trackCoordinate->rotation_begin & TRACK_BLOCK_2); return track_block_get_previous_from_zero(coords.x, coords.y, z, ride, rotation, outTrackBeginEnd); } @@ -1196,27 +1196,27 @@ int32_t sub_6C683D( { *output_element = reinterpret_cast(trackElement); } - if (flags & (1 << 0)) + if (flags & TRACK_ELEMENT_SET_HIGHLIGHT_FALSE) { trackElement->SetHighlight(false); } - if (flags & (1 << 1)) + if (flags & TRACK_ELEMENT_SET_HIGHLIGHT_TRUE) { trackElement->SetHighlight(true); } - if (flags & (1 << 2)) + if (flags & TRACK_ELEMENT_SET_COLOUR_SCHEME) { trackElement->SetColourScheme(static_cast(extra_params & 0xFF)); } - if (flags & (1 << 5)) + if (flags & TRACK_ELEMENT_SET_SEAT_ROTATION) { trackElement->SetSeatRotation(static_cast(extra_params & 0xFF)); } - if (flags & (1 << 3)) + if (flags & TRACK_ELEMENT_SET_HAS_CABLE_LIFT_TRUE) { trackElement->SetHasCableLift(true); } - if (flags & (1 << 4)) + if (flags & TRACK_ELEMENT_SET_HAS_CABLE_LIFT_FALSE) { trackElement->SetHasCableLift(false); } diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index d0184c0290..cc34126dfb 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -904,7 +904,7 @@ enum enum { RIDE_MODIFY_DEMOLISH, - RIDE_MODIFY_RENEW + RIDE_MODIFY_RENEW, }; enum @@ -913,6 +913,21 @@ enum RIDE_ISSUE_GUESTS_STUCK = (1 << 0), }; +enum +{ + TRACK_BLOCK_2 = (1 << 2) +}; + +enum +{ + TRACK_ELEMENT_SET_HIGHLIGHT_FALSE = (1 << 0), + TRACK_ELEMENT_SET_HIGHLIGHT_TRUE = (1 << 1), + TRACK_ELEMENT_SET_COLOUR_SCHEME = (1 << 2), + TRACK_ELEMENT_SET_HAS_CABLE_LIFT_TRUE = (1 << 3), + TRACK_ELEMENT_SET_HAS_CABLE_LIFT_FALSE = (1 << 4), + TRACK_ELEMENT_SET_SEAT_ROTATION = (1 << 5) +}; + struct rct_ride_properties { uint8_t min_value; diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 2894ed502c..b29edbb77b 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -1315,7 +1315,7 @@ static int32_t footpath_is_connected_to_map_edge_recurse( continue; } - if (!(flags & (1 << 0))) + if (!(flags & FOOTPATH_CONNECTED_MAP_EDGE_IGNORE_QUEUES)) { if (tileElement->AsPath()->IsQueue()) { @@ -1323,13 +1323,13 @@ static int32_t footpath_is_connected_to_map_edge_recurse( } } - if (flags & (1 << 5)) + if (flags & FOOTPATH_CONNECTED_MAP_EDGE_UNOWN) { footpath_fix_ownership(targetPos); } edges = tileElement->AsPath()->GetEdges(); direction = direction_reverse(direction); - if (!(flags & (1 << 7))) + if (!(flags & FOOTPATH_CONNECTED_MAP_EDGE_IGNORE_NO_ENTRY)) { if (tileElement[1].GetType() == TILE_ELEMENT_TYPE_BANNER) { @@ -1418,7 +1418,7 @@ searchFromFootpath: // TODO: Use GAME_COMMAND_FLAGS int32_t footpath_is_connected_to_map_edge(const CoordsXYZ& footpathPos, int32_t direction, int32_t flags) { - flags |= (1 << 0); + flags |= FOOTPATH_CONNECTED_MAP_EDGE_IGNORE_QUEUES; return footpath_is_connected_to_map_edge_recurse(footpathPos, direction, flags, 0, 0, 16); } diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index d4e72d4aba..39d4340620 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -151,6 +151,13 @@ enum FOOTPATH_CONNECTION_NW = (1 << 7), }; +enum +{ + FOOTPATH_CONNECTED_MAP_EDGE_IGNORE_QUEUES = (1 << 0), + FOOTPATH_CONNECTED_MAP_EDGE_UNOWN = (1 << 5), + FOOTPATH_CONNECTED_MAP_EDGE_IGNORE_NO_ENTRY = (1 << 7) +}; + extern uint8_t gFootpathProvisionalFlags; extern CoordsXYZ gFootpathProvisionalPosition; extern uint8_t gFootpathProvisionalType;