From ef433df26acf9ae79da7678f2f04bd3064ef042e Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 2 May 2018 10:31:03 +0200 Subject: [PATCH] Clean up tile element usage, introduce struct methods --- src/openrct2-ui/windows/RideConstruction.cpp | 3 +- src/openrct2-ui/windows/Sign.cpp | 6 +-- src/openrct2-ui/windows/TileInspector.cpp | 14 ++--- src/openrct2-ui/windows/TopToolbar.cpp | 2 +- src/openrct2/actions/MazeSetTrackAction.hpp | 2 +- .../actions/PlaceParkEntranceAction.hpp | 4 +- .../paint/tile_element/SmallScenery.cpp | 6 +-- src/openrct2/ride/Ride.cpp | 6 +-- src/openrct2/ride/RideRatings.cpp | 4 +- src/openrct2/ride/Track.cpp | 6 +-- src/openrct2/ride/Track.h | 10 ++-- src/openrct2/ride/TrackDesign.cpp | 2 +- src/openrct2/world/Banner.cpp | 2 +- src/openrct2/world/Entrance.cpp | 7 +-- src/openrct2/world/SmallScenery.h | 5 ++ src/openrct2/world/TileElement.cpp | 51 ++++++++++++++++--- src/openrct2/world/TileElement.h | 28 +++++----- src/openrct2/world/TileInspector.cpp | 4 +- src/openrct2/world/Wall.h | 7 +++ test/testpaint/TestTrack.cpp | 4 +- 20 files changed, 112 insertions(+), 61 deletions(-) diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index bcd6e47fc8..2c59df4555 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2329,7 +2329,8 @@ static void sub_6CBCE2( map_set_tile_elements(tileX + 0, tileY - 1, &_tempSideTrackTileElement); // Set the temporary track element - _tempTrackTileElement.type = trackDirection | TILE_ELEMENT_TYPE_TRACK; + _tempTrackTileElement.setType(TILE_ELEMENT_TYPE_TRACK); + _tempTrackTileElement.setDirection(trackDirection); track_element_set_lift_hill(&_tempTrackTileElement, (edx & 0x10000) ? true : false); _tempTrackTileElement.flags = (bl & 0x0F) | TILE_ELEMENT_FLAG_LAST_TILE; _tempTrackTileElement.base_height = baseZ; diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index 6cb577b5d8..9aec34245a 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -249,7 +249,7 @@ static void window_sign_mouseup(rct_window *w, rct_widgetindex widgetIndex) } game_do_command( x, - 1 | ((tile_element->type & TILE_ELEMENT_DIRECTION_MASK) << 8), + 1 | (tile_element->getDirection() << 8), y, tile_element->base_height | (scenery_large_get_sequence(tile_element) << 8), GAME_COMMAND_REMOVE_LARGE_SCENERY, @@ -512,9 +512,9 @@ static void window_sign_small_mouseup(rct_window *w, rct_widgetindex widgetIndex gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; game_do_command( x, - 1 | ((tile_element->type & TILE_ELEMENT_DIRECTION_MASK) << 8), + 1 | (tile_element->getDirection() << 8), y, - (tile_element->base_height << 8) | (tile_element->type & TILE_ELEMENT_DIRECTION_MASK), + (tile_element->base_height << 8) | tile_element->getDirection(), GAME_COMMAND_REMOVE_WALL, 0, 0); diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index c2b4036975..4d4aeabba4 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -1234,7 +1234,7 @@ static void window_tile_inspector_mousedown(rct_window *w, rct_widgetindex widge // Set current value as checked rct_tile_element *const tileElement = window_tile_inspector_get_selected_element(w); - dropdown_set_checked((tileElement->type & 0xC0) >> 6, true); + dropdown_set_checked(tileElement->getSceneryQuadrant(), true); break; } break; @@ -1545,10 +1545,10 @@ static void window_tile_inspector_invalidate(rct_window *w) w->widgets[WIDX_SCENERY_CHECK_QUARTER_W].top = GBBT(propertiesAnchor, 1) - 5 + 7 * 1; w->widgets[WIDX_SCENERY_CHECK_QUARTER_W].bottom = w->widgets[WIDX_SCENERY_CHECK_QUARTER_W].top + 13; // This gets the relative rotation, by subtracting the camera's rotation, and wrapping it between 0-3 inclusive - bool N = (tileElement->type & TILE_ELEMENT_QUADRANT_MASK) == ((0 - get_current_rotation()) & 3) << 6; - bool E = (tileElement->type & TILE_ELEMENT_QUADRANT_MASK) == ((1 - get_current_rotation()) & 3) << 6; - bool S = (tileElement->type & TILE_ELEMENT_QUADRANT_MASK) == ((2 - get_current_rotation()) & 3) << 6; - bool W = (tileElement->type & TILE_ELEMENT_QUADRANT_MASK) == ((3 - get_current_rotation()) & 3) << 6; + bool N = tileElement->getSceneryQuadrant() == ((0 - get_current_rotation()) & 3); + bool E = tileElement->getSceneryQuadrant() == ((1 - get_current_rotation()) & 3); + bool S = tileElement->getSceneryQuadrant() == ((2 - get_current_rotation()) & 3); + bool W = tileElement->getSceneryQuadrant() == ((3 - get_current_rotation()) & 3); widget_set_checkbox_value(w, WIDX_SCENERY_CHECK_QUARTER_N, N); widget_set_checkbox_value(w, WIDX_SCENERY_CHECK_QUARTER_E, E); widget_set_checkbox_value(w, WIDX_SCENERY_CHECK_QUARTER_S, S); @@ -1593,7 +1593,7 @@ static void window_tile_inspector_invalidate(rct_window *w) w->widgets[WIDX_WALL_SPINNER_HEIGHT_DECREASE].bottom = GBBB(propertiesAnchor, 0) - 4; w->widgets[WIDX_WALL_DROPDOWN_SLOPE].top = GBBT(propertiesAnchor, 1) + 3; w->widgets[WIDX_WALL_DROPDOWN_SLOPE].bottom = GBBB(propertiesAnchor, 1) - 3; - w->widgets[WIDX_WALL_DROPDOWN_SLOPE].text = WallSlopeStringIds[(tileElement->type & 0xC0) >> 6]; + w->widgets[WIDX_WALL_DROPDOWN_SLOPE].text = WallSlopeStringIds[tileElement->getSceneryQuadrant()]; w->widgets[WIDX_WALL_DROPDOWN_SLOPE_BUTTON].top = GBBT(propertiesAnchor, 1) + 4; w->widgets[WIDX_WALL_DROPDOWN_SLOPE_BUTTON].bottom = GBBB(propertiesAnchor, 1) - 4; break; @@ -1794,7 +1794,7 @@ static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi) const rct_scenery_entry * sceneryEntry = get_small_scenery_entry(tileElement->properties.scenery.type); if (!(scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE))) { - sint16 quadrant = (tileElement->type & TILE_ELEMENT_QUADRANT_MASK) >> 6; + sint16 quadrant = tileElement->getSceneryQuadrant(); static rct_string_id quadrant_string_idx[] = { STR_TILE_INSPECTOR_SCENERY_QUADRANT_SW, STR_TILE_INSPECTOR_SCENERY_QUADRANT_NW, diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 3ef9879bdc..d7bb6fba87 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -1014,7 +1014,7 @@ static void repaint_scenery_tool_down(sint16 x, sint16 y, rct_widgetindex widget gGameCommandErrorTitle = STR_CANT_REPAINT_THIS; game_do_command( grid_x, - 1 | ((tile_element->type & TILE_ELEMENT_DIRECTION_MASK) << 8), + 1 | (tile_element->getDirection() << 8), grid_y, tile_element->base_height | (scenery_large_get_sequence(tile_element) << 8), GAME_COMMAND_SET_LARGE_SCENERY_COLOUR, diff --git a/src/openrct2/actions/MazeSetTrackAction.hpp b/src/openrct2/actions/MazeSetTrackAction.hpp index 0c2b10a9dd..c6ad854616 100644 --- a/src/openrct2/actions/MazeSetTrackAction.hpp +++ b/src/openrct2/actions/MazeSetTrackAction.hpp @@ -234,7 +234,7 @@ public: assert(tileElement != nullptr); tileElement->clearance_height = clearanceHeight; - tileElement->type = TILE_ELEMENT_TYPE_TRACK; + tileElement->setType(TILE_ELEMENT_TYPE_TRACK); track_element_set_type(tileElement, TRACK_ELEM_MAZE); track_element_set_ride_index(tileElement, _rideIndex); diff --git a/src/openrct2/actions/PlaceParkEntranceAction.hpp b/src/openrct2/actions/PlaceParkEntranceAction.hpp index 3c0e210ba6..43344372d5 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.hpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.hpp @@ -190,8 +190,8 @@ public: newElement->flags |= TILE_ELEMENT_FLAG_GHOST; } - newElement->type = TILE_ELEMENT_TYPE_ENTRANCE; - newElement->type |= _direction; + newElement->setType(TILE_ELEMENT_TYPE_ENTRANCE); + newElement->setDirection(_direction); newElement->properties.entrance.index = index; newElement->properties.entrance.type = ENTRANCE_TYPE_PARK_ENTRANCE; newElement->properties.entrance.path_type = gFootpathSelectedId; diff --git a/src/openrct2/paint/tile_element/SmallScenery.cpp b/src/openrct2/paint/tile_element/SmallScenery.cpp index ddf47064fa..4552656f85 100644 --- a/src/openrct2/paint/tile_element/SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/SmallScenery.cpp @@ -111,7 +111,7 @@ void scenery_paint(paint_session * session, uint8 direction, sint32 height, cons } } else { // 6DFFC2: - uint8 ecx = (tile_element_get_scenery_quadrant(tileElement) + rotation) & 3; + uint8 ecx = (tileElement->getSceneryQuadrant() + rotation) & 3; x_offset = ScenerySubTileOffsets[ecx].x; y_offset = ScenerySubTileOffsets[ecx].y; boxoffset.x = x_offset; @@ -340,7 +340,7 @@ void scenery_paint(paint_session * session, uint8 direction, sint32 height, cons } if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) { // 6E075C: - direction = (tile_element_get_scenery_quadrant(tileElement) + rotation) % 4; + direction = (tileElement->getSceneryQuadrant() + rotation) % 4; paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC, direction), height, 0x20); return; } @@ -354,7 +354,7 @@ void scenery_paint(paint_session * session, uint8 direction, sint32 height, cons return; } if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)) { - direction = (tile_element_get_scenery_quadrant(tileElement) + rotation) % 4; + direction = (tileElement->getSceneryQuadrant() + rotation) % 4; paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); return; } diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 049b71c729..6fec9ccb83 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1571,7 +1571,7 @@ void ride_construction_set_default_next_piece() // Set track slope and lift hill _currentTrackSlopeEnd = slope; _previousTrackSlopeEnd = slope; - _currentTrackLiftHill = ((tileElement->type & 0x80) && slope != TRACK_SLOPE_DOWN_25 && slope != TRACK_SLOPE_DOWN_60) != 0; + _currentTrackLiftHill = track_element_is_lift_hill(tileElement) && slope != TRACK_SLOPE_DOWN_25 && slope != TRACK_SLOPE_DOWN_60; break; case RIDE_CONSTRUCTION_STATE_BACK: rideIndex = _currentRideIndex; @@ -4163,7 +4163,7 @@ static sint32 ride_check_block_brakes(CoordsXYE *input, CoordsXYE *output) *output = it.current; return 0; } - if ((it.last.element->type & 0x80) && type != TRACK_ELEM_LEFT_CURVED_LIFT_HILL && type != TRACK_ELEM_RIGHT_CURVED_LIFT_HILL) { + if (track_element_is_lift_hill(it.last.element) && type != TRACK_ELEM_LEFT_CURVED_LIFT_HILL && type != TRACK_ELEM_RIGHT_CURVED_LIFT_HILL) { gGameCommandErrorText = STR_BLOCK_BRAKES_CANNOT_BE_USED_DIRECTLY_AFTER_THE_TOP_OF_THIS_LIFT_HILL; *output = it.current; return 0; @@ -4391,7 +4391,7 @@ static void ride_set_boat_hire_return_point(Ride * ride, CoordsXYE * startElemen trackType = track_element_get_type(returnTrackElement); sint32 elementReturnDirection = TrackCoordinates[trackType].rotation_begin; - ride->boat_hire_return_direction = (returnTrackElement->type + elementReturnDirection) & 3; + ride->boat_hire_return_direction = returnTrackElement->getDirectionWithOffset(elementReturnDirection); ride->boat_hire_return_position.x = returnX >> 5; ride->boat_hire_return_position.y = returnY >> 5; } diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index 083e45e931..dff25c0003 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -446,8 +446,8 @@ static void ride_ratings_score_close_proximity_loops_helper(rct_tile_element *in case TILE_ELEMENT_TYPE_TRACK: { - sint32 unk = (tileElement->type ^ inputTileElement->type) & 1; - if (unk != 0) + sint32 elementsAreAt90DegAngle = (tileElement->getDirection() ^ inputTileElement->getDirection()) & 1; + if (elementsAreAt90DegAngle != 0) { sint32 zDiff = (sint32)tileElement->base_height - (sint32)inputTileElement->base_height; if (zDiff >= 0 && zDiff <= 16) diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index cccccc5bbc..4f09b9d52a 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -2126,18 +2126,18 @@ void track_get_front(CoordsXYE * input, CoordsXYE * output) bool track_element_is_lift_hill(const rct_tile_element * trackElement) { - return trackElement->type & TRACK_ELEMENT_FLAG_CHAIN_LIFT; + return trackElement->type & TRACK_ELEMENT_TYPE_FLAG_CHAIN_LIFT; } void track_element_set_lift_hill(rct_tile_element * trackElement, bool on) { if (on) { - trackElement->type |= TRACK_ELEMENT_FLAG_CHAIN_LIFT; + trackElement->type |= TRACK_ELEMENT_TYPE_FLAG_CHAIN_LIFT; } else { - trackElement->type &= ~TRACK_ELEMENT_FLAG_CHAIN_LIFT; + trackElement->type &= ~TRACK_ELEMENT_TYPE_FLAG_CHAIN_LIFT; } } diff --git a/src/openrct2/ride/Track.h b/src/openrct2/ride/Track.h index 031b6fc321..2c8de16e1a 100644 --- a/src/openrct2/ride/Track.h +++ b/src/openrct2/ride/Track.h @@ -63,7 +63,11 @@ enum { TRACK_ELEMENT_FLAG_TERMINAL_STATION = 1 << 3, TRACK_ELEMENT_FLAG_INVERTED = 1 << 6, - TRACK_ELEMENT_FLAG_CHAIN_LIFT = 1 << 7, +}; + +enum +{ + TRACK_ELEMENT_TYPE_FLAG_CHAIN_LIFT = 1 << 7, }; enum @@ -72,10 +76,10 @@ enum // that field in the map element // Used for multi-dimension coaster - TRACK_ELEMENT_COLOUR_FLAG_INVERTED = (1 << 2), + TRACK_ELEMENT_COLOUR_FLAG_INVERTED = (1 << 2), // Used for giga coaster - TRACK_ELEMENT_COLOUR_FLAG_CABLE_LIFT = (1 << 3), + TRACK_ELEMENT_COLOUR_FLAG_CABLE_LIFT = (1 << 3), }; #define TRACK_ELEMENT_FLAG_MAGNITUDE_MASK 0x0F diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 19ebbf1b57..ba4ae33c42 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -1454,7 +1454,7 @@ static bool track_design_place_ride(rct_track_td6 * td6, sint16 x, sint16 y, sin (tempZ & 0xFFFF); sint32 edx = _currentRideIndex | (trackType << 8); - if (track->flags & TRACK_ELEMENT_FLAG_CHAIN_LIFT) + if (track->flags & TRACK_ELEMENT_TYPE_FLAG_CHAIN_LIFT) { edx |= 0x10000; } diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index 5dbfc9294e..4ccddae6e4 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -258,7 +258,7 @@ static money32 BannerPlace(sint16 x, sint16 y, uint8 pathBaseHeight, uint8 direc gBanners[*bannerIndex].colour = colour; gBanners[*bannerIndex].x = x / 32; gBanners[*bannerIndex].y = y / 32; - newTileElement->type = TILE_ELEMENT_TYPE_BANNER; + newTileElement->setType(TILE_ELEMENT_TYPE_BANNER); newTileElement->clearance_height = newTileElement->base_height + 2; newTileElement->properties.banner.position = direction; newTileElement->properties.banner.flags = 0xFF; diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index 4e70c2d6b4..94b14ffd8d 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -291,11 +291,12 @@ static money32 RideEntranceExitPlace(sint16 x, rct_tile_element* tileElement = tile_element_insert(x / 32, y / 32, z / 8, 0xF); assert(tileElement != nullptr); + tileElement->setType(TILE_ELEMENT_TYPE_ENTRANCE); + tileElement->setDirection(direction); tileElement->clearance_height = clear_z; tileElement->properties.entrance.type = isExit; tileElement->properties.entrance.index = stationNum << 4; tileElement->properties.entrance.ride_index = rideIndex; - tileElement->type = TILE_ELEMENT_TYPE_ENTRANCE | direction; if (flags & GAME_COMMAND_FLAG_GHOST) { @@ -639,7 +640,7 @@ void maze_entrance_hedge_replacement(sint32 x, sint32 y, rct_tile_element *tileE tileElement = map_get_first_element_at(x >> 5, y >> 5); do { - if (tileElement->type != TILE_ELEMENT_TYPE_TRACK) continue; + if (tileElement->getType() != TILE_ELEMENT_TYPE_TRACK) continue; if (track_element_get_ride_index(tileElement) != rideIndex) continue; if (tileElement->base_height != z) continue; if (track_element_get_type(tileElement) != TRACK_ELEM_MAZE) continue; @@ -670,7 +671,7 @@ void maze_entrance_hedge_removal(sint32 x, sint32 y, rct_tile_element *tileEleme tileElement = map_get_first_element_at(x >> 5, y >> 5); do { - if (tileElement->type != TILE_ELEMENT_TYPE_TRACK) continue; + if (tileElement->getType() != TILE_ELEMENT_TYPE_TRACK) continue; if (track_element_get_ride_index(tileElement) != rideIndex) continue; if (tileElement->base_height != z) continue; if (track_element_get_type(tileElement) != TRACK_ELEM_MAZE) continue; diff --git a/src/openrct2/world/SmallScenery.h b/src/openrct2/world/SmallScenery.h index 98b996670d..2eba7ca2f2 100644 --- a/src/openrct2/world/SmallScenery.h +++ b/src/openrct2/world/SmallScenery.h @@ -52,6 +52,11 @@ enum SMALL_SCENERY_FLAGS SMALL_SCENERY_FLAG27 = (1 << 27), // 0x8000000 }; +enum +{ + MAP_ELEM_SMALL_SCENERY_COLOUR_FLAG_NEEDS_SUPPORTS = (1 << 5), +}; + sint32 scenery_small_get_primary_colour(const rct_tile_element * tileElement); sint32 scenery_small_get_secondary_colour(const rct_tile_element * tileElement); void scenery_small_set_primary_colour(rct_tile_element * tileElement, uint32 colour); diff --git a/src/openrct2/world/TileElement.cpp b/src/openrct2/world/TileElement.cpp index 364853e944..a2f5fcab6f 100644 --- a/src/openrct2/world/TileElement.cpp +++ b/src/openrct2/world/TileElement.cpp @@ -23,29 +23,64 @@ #include "TileElement.h" #include "Scenery.h" -uint8 tile_element_get_scenery_quadrant(const rct_tile_element * element) +uint8 rct_tile_element::getType() const { - return (element->type & TILE_ELEMENT_QUADRANT_MASK) >> 6; + return this->type & TILE_ELEMENT_TYPE_MASK; +} + +void rct_tile_element::setType(uint8 newType) +{ + this->type |= (newType & TILE_ELEMENT_TYPE_MASK); +} + +uint8 rct_tile_element::getDirection() const +{ + return this->type & TILE_ELEMENT_DIRECTION_MASK; +} + +void rct_tile_element::setDirection(uint8 direction) +{ + this->type |= (direction & TILE_ELEMENT_DIRECTION_MASK); +} + +uint8 rct_tile_element::getDirectionWithOffset(uint8 offset) const +{ + return ((this->type & TILE_ELEMENT_DIRECTION_MASK) + offset) & TILE_ELEMENT_DIRECTION_MASK; +} + +bool rct_tile_element::isLastForTile() const +{ + return (this->flags & TILE_ELEMENT_FLAG_LAST_TILE) != 0; +} + +bool rct_tile_element::isGhost() const +{ + return (this->flags & TILE_ELEMENT_FLAG_GHOST) != 0; +} + +uint8 rct_tile_element::getSceneryQuadrant() const +{ + return (this->type & TILE_ELEMENT_QUADRANT_MASK) >> 6; } sint32 tile_element_get_type(const rct_tile_element * element) { - return element->type & TILE_ELEMENT_TYPE_MASK; + return element->getType(); } sint32 tile_element_get_direction(const rct_tile_element * element) { - return element->type & TILE_ELEMENT_DIRECTION_MASK; + return element->getDirection(); } sint32 tile_element_get_direction_with_offset(const rct_tile_element * element, uint8 offset) { - return ((element->type & TILE_ELEMENT_DIRECTION_MASK) + offset) & TILE_ELEMENT_DIRECTION_MASK; + return element->getDirectionWithOffset(offset); } bool tile_element_is_ghost(const rct_tile_element * element) { - return element->flags & TILE_ELEMENT_FLAG_GHOST; + return element->isGhost(); } bool tile_element_is_underground(rct_tile_element * tileElement) @@ -58,9 +93,9 @@ bool tile_element_is_underground(rct_tile_element * tileElement) return true; } -bool tile_element_is_last_for_tile(const rct_tile_element *element) +bool tile_element_is_last_for_tile(const rct_tile_element * element) { - return (element->flags & TILE_ELEMENT_FLAG_LAST_TILE) != 0; + return element->isLastForTile(); } sint32 tile_element_get_banner_index(rct_tile_element * tileElement) diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index f627f8ef8b..9d40cc2b08 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -125,6 +125,15 @@ struct rct_tile_element { uint8 base_height; //2 uint8 clearance_height; //3 rct_tile_element_properties properties; + + uint8 getType() const; + void setType(uint8 newType); + uint8 getDirection() const; + void setDirection(uint8 direction); + uint8 getDirectionWithOffset(uint8 offset) const; + bool isLastForTile() const; + bool isGhost() const; + uint8 getSceneryQuadrant() const; }; assert_struct_size(rct_tile_element, 8); #pragma pack(pop) @@ -169,13 +178,6 @@ enum { TILE_ELEMENT_FLAG_LAST_TILE = (1 << 7) }; -enum { - WALL_ANIMATION_FLAG_ACROSS_TRACK = (1 << 2), - // 3 - 6 animation frame number - WALL_ANIMATION_FLAG_DIRECTION_BACKWARD = (1 << 7), - WALL_ANIMATION_FLAG_ALL_FLAGS = WALL_ANIMATION_FLAG_ACROSS_TRACK | WALL_ANIMATION_FLAG_DIRECTION_BACKWARD -}; - enum { ENTRANCE_TYPE_RIDE_ENTRANCE, ENTRANCE_TYPE_RIDE_EXIT, @@ -193,14 +195,11 @@ enum MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT = (1 << 7), }; -enum -{ - MAP_ELEM_SMALL_SCENERY_COLOUR_FLAG_NEEDS_SUPPORTS = (1 << 5), -}; -#define TILE_ELEMENT_QUADRANT_MASK 0xC0 -#define TILE_ELEMENT_TYPE_MASK 0x3C -#define TILE_ELEMENT_DIRECTION_MASK 0x03 + +#define TILE_ELEMENT_QUADRANT_MASK 0xC0 // bits 6 + 7 +#define TILE_ELEMENT_TYPE_MASK 0x3C // bits 2 + 3 + 4 + 5 +#define TILE_ELEMENT_DIRECTION_MASK 0x03 // bits 0 + 1 #define TILE_ELEMENT_COLOUR_MASK 0x1F @@ -208,7 +207,6 @@ enum #define MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK 0x0F #define MAP_ELEM_TRACK_SEQUENCE_TAKING_PHOTO_MASK 0xF0 -uint8 tile_element_get_scenery_quadrant(const rct_tile_element * element); sint32 tile_element_get_type(const rct_tile_element * element); sint32 tile_element_get_direction(const rct_tile_element * element); sint32 tile_element_get_direction_with_offset(const rct_tile_element * element, uint8 offset); diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index f3645e66f3..200ba49972 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -870,7 +870,7 @@ sint32 tile_inspector_track_set_chain(sint32 x, sint32 y, sint32 elementIndex, b // Set chain for only the selected piece if (track_element_is_lift_hill(trackElement) != setChain) { - trackElement->type ^= TRACK_ELEMENT_FLAG_CHAIN_LIFT; + trackElement->type ^= TRACK_ELEMENT_TYPE_FLAG_CHAIN_LIFT; } return 0; @@ -977,7 +977,7 @@ sint32 tile_inspector_track_set_chain(sint32 x, sint32 y, sint32 elementIndex, b if (track_element_is_lift_hill(tileElement) != setChain) { - tileElement->type ^= TRACK_ELEMENT_FLAG_CHAIN_LIFT; + tileElement->type ^= TRACK_ELEMENT_TYPE_FLAG_CHAIN_LIFT; } } } diff --git a/src/openrct2/world/Wall.h b/src/openrct2/world/Wall.h index cf1cf99333..b7896a2a55 100644 --- a/src/openrct2/world/Wall.h +++ b/src/openrct2/world/Wall.h @@ -19,6 +19,13 @@ #include "../common.h" #include "TileElement.h" +enum { + WALL_ANIMATION_FLAG_ACROSS_TRACK = (1 << 2), + // 3 - 6 animation frame number + WALL_ANIMATION_FLAG_DIRECTION_BACKWARD = (1 << 7), + WALL_ANIMATION_FLAG_ALL_FLAGS = WALL_ANIMATION_FLAG_ACROSS_TRACK | WALL_ANIMATION_FLAG_DIRECTION_BACKWARD +}; + colour_t wall_get_primary_colour(const rct_tile_element * tileElement); colour_t wall_get_secondary_colour(const rct_tile_element * wallElement); colour_t wall_get_tertiary_colour(const rct_tile_element * tileElement); diff --git a/test/testpaint/TestTrack.cpp b/test/testpaint/TestTrack.cpp index 5705cabe40..75fc131f13 100644 --- a/test/testpaint/TestTrack.cpp +++ b/test/testpaint/TestTrack.cpp @@ -99,9 +99,9 @@ public: Ride *ride, rct_ride_entry *rideEntry ) override { if (variant == 0) { - tileElement->type &= ~TRACK_ELEMENT_FLAG_CHAIN_LIFT; + tileElement->type &= ~TRACK_ELEMENT_TYPE_FLAG_CHAIN_LIFT; } else { - tileElement->type |= TRACK_ELEMENT_FLAG_CHAIN_LIFT; + tileElement->type |= TRACK_ELEMENT_TYPE_FLAG_CHAIN_LIFT; } } };