Replace residual access to path element entry index field

This commit is contained in:
Michael Steenbeek committed 2018-10-31 13:09:29 +01:00
1 parent 66cde65f87
commit 0f4560598e
11 files changed
+86 -68

No files matched your search

@@ -504,16 +504,16 @@ static void viewport_interaction_remove_footpath(rct_tile_element* tileElement,
*/
static void viewport_interaction_remove_footpath_item(rct_tile_element* tileElement, int32_t x, int32_t y)
{
int32_t type;
type = tileElement->AsPath()->GetEntryIndex();
int32_t type = tileElement->AsPath()->GetEntryIndex();
if (tileElement->AsPath()->IsQueue())
type |= 0x80;
int32_t slopeData = tileElement->AsPath()->GetSlopeDirection();
if (tileElement->AsPath()->IsSloped())
slopeData |= FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
gGameCommandErrorTitle = STR_CANT_REMOVE_THIS;
game_do_command(
x, ((tileElement->properties.path.type & 7) << 8) | 1, y, (type << 8) | tileElement->base_height,
GAME_COMMAND_PLACE_PATH, 0, 0);
game_do_command(x, (slopeData << 8) | 1, y, (type << 8) | tileElement->base_height, GAME_COMMAND_PLACE_PATH, 0, 0);
}
/**
+14 -14
View File
@@ -758,8 +758,9 @@ static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y)
slope = DefaultPathSlope[tileElement->AsSurface()->GetSlope() & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK];
break;
case VIEWPORT_INTERACTION_ITEM_FOOTPATH:
slope = tileElement->properties.path.type
& (FOOTPATH_PROPERTIES_FLAG_IS_SLOPED | FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
slope = tileElement->AsPath()->GetSlopeDirection();
if (tileElement->AsPath()->IsSloped())
slope |= FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
break;
}
int32_t pathType = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF);
@@ -854,7 +855,7 @@ static void window_footpath_place_path_at_point(int32_t x, int32_t y)
currentType = DefaultPathSlope[tileElement->AsSurface()->GetSlope() & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK];
break;
case VIEWPORT_INTERACTION_ITEM_FOOTPATH:
currentType = tileElement->properties.path.type & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
currentType = tileElement->AsPath()->GetSlopeDirection();
if (tileElement->AsPath()->IsSloped())
{
currentType |= FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
@@ -918,9 +919,9 @@ static void window_footpath_start_bridge_at_point(int32_t screenX, int32_t scree
z = tileElement->base_height;
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)
{
if (tileElement->properties.path.type & 4)
if (tileElement->AsPath()->IsSloped())
{
if (direction == (tileElement->properties.path.type & 3))
if (direction == (tileElement->AsPath()->GetSlopeDirection()))
{
z += 2;
}
@@ -1002,12 +1003,11 @@ static void footpath_remove_tile_element(rct_tile_element* tileElement)
int32_t x, y, z;
z = tileElement->base_height;
int32_t pathType = tileElement->properties.path.type;
if (pathType & 4)
if (tileElement->AsPath()->IsSloped())
{
pathType &= 3;
pathType ^= 2;
if (pathType == gFootpathConstructDirection)
uint8_t slopeDirection = tileElement->AsPath()->GetSlopeDirection();
slopeDirection ^= 2;
if (slopeDirection == gFootpathConstructDirection)
{
z += 2;
}
@@ -1073,9 +1073,9 @@ static rct_tile_element* footpath_get_tile_element_to_remove()
{
if (tileElement->base_height == z)
{
if (tileElement->properties.path.type & 4)
if (tileElement->AsPath()->IsSloped())
{
if (((tileElement->properties.path.type & 3) ^ 2) != gFootpathConstructDirection)
if (((tileElement->AsPath()->GetSlopeDirection()) ^ 2) != gFootpathConstructDirection)
{
continue;
}
@@ -1085,9 +1085,9 @@ static rct_tile_element* footpath_get_tile_element_to_remove()
}
else if (tileElement->base_height == zLow)
{
if (!(tileElement->properties.path.type & 4))
if (!tileElement->AsPath()->IsSloped())
{
if ((tileElement->properties.path.type & 3) == gFootpathConstructDirection)
if ((tileElement->AsPath()->GetSlopeDirection()) == gFootpathConstructDirection)
{
continue;
}
+5 -5
View File
@@ -1450,9 +1450,9 @@ static void sub_6E1F34(
return;
}
*parameter_1 = (tile_element->properties.path.type
& (FOOTPATH_PROPERTIES_FLAG_IS_SLOPED | FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK))
<< 8;
*parameter_1 = tile_element->AsPath()->GetSlopeDirection() << 8;
if (tile_element->AsPath()->IsSloped())
*parameter_1 |= FOOTPATH_PROPERTIES_FLAG_IS_SLOPED << 8;
*parameter_2 = tile_element->base_height;
*parameter_2 |= (tile_element->AsPath()->GetEntryIndex() << 8);
if (tile_element->AsPath()->IsQueue())
@@ -1606,9 +1606,9 @@ static void sub_6E1F34(
int16_t z = tile_element->base_height;
if (tile_element->properties.path.type & (1 << 2))
if (tile_element->AsPath()->IsSloped())
{
if (rotation != ((tile_element->properties.path.type & 3) ^ 2))
if (rotation != ((tile_element->AsPath()->GetSlopeDirection()) ^ 2))
{
z += 2;
}
@@ -131,8 +131,7 @@ void setup_in_use_selection_flags()
case TILE_ELEMENT_TYPE_TRACK:
break;
case TILE_ELEMENT_TYPE_PATH:
type = iter.element->properties.path.type;
type >>= 4;
type = iter.element->AsPath()->GetEntryIndex();
assert(type < object_entry_group_counts[OBJECT_TYPE_PATHS]);
Editor::SetSelectedObject(OBJECT_TYPE_PATHS, type, OBJECT_SELECTION_FLAG_SELECTED);
+2 -1
View File
@@ -4913,7 +4913,8 @@ void rct_peep::UpdateRideLeaveExit()
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
continue;
int16_t height = map_height_from_slope({ x, y }, tileElement->properties.path.type, tileElement->AsPath()->IsSloped());
int16_t height = map_height_from_slope(
{ x, y }, tileElement->AsPath()->GetSlopeDirection(), tileElement->AsPath()->IsSloped());
height += tileElement->base_height * 8;
int16_t z_diff = z - height;
+4 -4
View File
@@ -1022,7 +1022,7 @@ void rct_peep::UpdateFalling()
if (tile_element->GetType() == TILE_ELEMENT_TYPE_PATH)
{
int32_t height = map_height_from_slope(
{ x, y }, tile_element->properties.path.type, tile_element->AsPath()->IsSloped())
{ x, y }, tile_element->AsPath()->GetSlopeDirection(), tile_element->AsPath()->IsSloped())
+ tile_element->base_height * 8;
if (height < z - 1 || height > z + 4)
@@ -1099,7 +1099,7 @@ void rct_peep::UpdateFalling()
}
else
{
SetNextFlags(saved_map->properties.path.type & 0x3, saved_map->properties.path.type & 0x4, false);
SetNextFlags(saved_map->AsPath()->GetSlopeDirection(), saved_map->AsPath()->IsSloped(), false);
}
SetState(PEEP_STATE_1);
}
@@ -2731,7 +2731,7 @@ static void peep_footpath_move_forward(rct_peep* peep, int16_t x, int16_t y, rct
peep->next_x = (x & 0xFFE0);
peep->next_y = (y & 0xFFE0);
peep->next_z = tile_element->base_height;
peep->SetNextFlags(tile_element->properties.path.type & 3, tile_element->properties.path.type & 4, false);
peep->SetNextFlags(tile_element->AsPath()->GetSlopeDirection(), tile_element->AsPath()->IsSloped(), false);
int16_t z = peep->GetZOnSlope(x, y);
@@ -2926,7 +2926,7 @@ static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, rct_ti
peep->time_lost = 0;
uint8_t stationNum = tile_element->AsPath()->GetStationIndex();
if ((tile_element->properties.path.type & (1 << 3)) // Queue has the ride sign on it
if ((tile_element->AsPath()->HasQueueBanner())
&& (tile_element->AsPath()->GetQueueBannerDirection()
== ((peep->direction) ^ 2)) // Ride sign is facing the direction the peep is walking
)
+6 -5
View File
@@ -370,12 +370,12 @@ static void track_design_save_add_wall(int32_t x, int32_t y, rct_tile_element* t
static void track_design_save_add_footpath(int32_t x, int32_t y, rct_tile_element* tileElement)
{
int32_t entryType = tileElement->properties.path.type >> 4;
int32_t entryType = tileElement->AsPath()->GetEntryIndex();
auto entry = object_entry_get_entry(OBJECT_TYPE_PATHS, entryType);
uint8_t flags = 0;
flags |= tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK;
flags |= (tileElement->properties.path.type & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK) << 5;
flags |= (tileElement->AsPath()->GetSlopeDirection()) << 5;
if (tileElement->AsPath()->IsSloped())
flags |= 0b00010000;
if (tileElement->AsPath()->IsQueue())
@@ -557,13 +557,14 @@ static void track_design_save_remove_wall(int32_t x, int32_t y, rct_tile_element
static void track_design_save_remove_footpath(int32_t x, int32_t y, rct_tile_element* tileElement)
{
int32_t entryType = tileElement->properties.path.type >> 4;
int32_t entryType = tileElement->AsPath()->GetEntryIndex();
auto entry = object_entry_get_entry(OBJECT_TYPE_PATHS, entryType);
uint8_t flags = 0;
flags |= tileElement->properties.path.edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK;
flags |= (tileElement->properties.path.type & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED) << 2;
flags |= (tileElement->properties.path.type & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK) << 5;
if (tileElement->AsPath()->IsSloped())
flags |= (1 << 4);
flags |= (tileElement->AsPath()->GetSlopeDirection()) << 5;
if (tileElement->AsPath()->IsQueue())
flags |= (1 << 7);
+42 -21
View File
@@ -154,14 +154,14 @@ rct_tile_element* map_get_footpath_element(int32_t x, int32_t y, int32_t z)
static rct_tile_element* map_get_footpath_element_slope(int32_t x, int32_t y, int32_t z, int32_t slope)
{
rct_tile_element* tileElement;
bool isSloped = slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
tileElement = map_get_first_element_at(x, y);
do
{
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && tileElement->base_height == z
&& (tileElement->properties.path.type
& (FOOTPATH_PROPERTIES_FLAG_IS_SLOPED | FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK))
== slope)
&& (tileElement->AsPath()->IsSloped() == isSloped)
&& (tileElement->AsPath()->GetSlopeDirection() == (slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK)))
{
return tileElement;
}
@@ -265,17 +265,20 @@ static money32 footpath_element_insert(
{
tileElement = tile_element_insert(x / 32, y / 32, z, 0x0F);
assert(tileElement != nullptr);
tileElement->type = TILE_ELEMENT_TYPE_PATH;
tileElement->clearance_height = z + 4 + ((slope & TILE_ELEMENT_SLOPE_NE_SIDE_UP) ? 2 : 0);
tileElement->AsPath()->SetEntryIndex(type);
tileElement->properties.path.type |= (slope & TILE_ELEMENT_SLOPE_W_CORNER_DN);
tileElement->SetType(TILE_ELEMENT_TYPE_PATH);
PathElement* pathElement = tileElement->AsPath();
pathElement->clearance_height = z + 4 + ((slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK) ? 2 : 0);
pathElement->SetEntryIndex(type);
pathElement->SetSlopeDirection(slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
if (slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
pathElement->SetSloped(true);
if (type & FOOTPATH_ELEMENT_INSERT_QUEUE)
tileElement->AsPath()->SetIsQueue(true);
tileElement->AsPath()->SetAddition(pathItemType);
pathElement->SetIsQueue(true);
pathElement->SetAddition(pathItemType);
tileElement->properties.path.addition_status = 255;
tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
pathElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
if (flags & GAME_COMMAND_FLAG_GHOST)
tileElement->flags |= TILE_ELEMENT_FLAG_GHOST;
pathElement->flags |= TILE_ELEMENT_FLAG_GHOST;
footpath_queue_chain_reset();
@@ -646,16 +649,27 @@ static money32 footpath_place_from_track(
{
tileElement = tile_element_insert(x / 32, y / 32, z, 0x0F);
assert(tileElement != nullptr);
tileElement->type = TILE_ELEMENT_TYPE_PATH;
tileElement->clearance_height = z + 4 + ((slope & TILE_ELEMENT_SLOPE_S_CORNER_UP) ? 2 : 0);
tileElement->properties.path.type = (type << 4) | (slope & TILE_ELEMENT_SLOPE_W_CORNER_DN);
tileElement->SetType(TILE_ELEMENT_TYPE_PATH);
PathElement* pathElement = tileElement->AsPath();
// This can NEVER happen, but GCC does not want to believe that...
if (pathElement == nullptr)
{
assert(false);
return MONEY32_UNDEFINED;
}
pathElement->clearance_height = z + 4 + ((slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED) ? 2 : 0);
pathElement->SetEntryIndex(type & 0xF);
pathElement->SetSlopeDirection(slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
if (slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
pathElement->SetSloped(true);
tileElement->type |= type >> 7;
tileElement->AsPath()->SetAddition(0);
pathElement->SetAddition(0);
tileElement->properties.path.addition_status = 255;
tileElement->properties.path.edges = edges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK;
tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
pathElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
if (flags & (1 << 6))
tileElement->flags |= TILE_ELEMENT_FLAG_GHOST;
pathElement->flags |= TILE_ELEMENT_FLAG_GHOST;
map_invalidate_tile_full(x, y);
}
@@ -1266,13 +1280,13 @@ static bool sub_footpath_disconnect_queue_from_path(
rct_tile_element* otherTileElement = footpath_get_element(x1, y1, z - 2, z, direction);
if (otherTileElement != nullptr && !otherTileElement->AsPath()->IsQueue())
{
tileElement->properties.path.type &= ~FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
tileElement->AsPath()->SetSlopeDirection(0);
if (action > 0)
{
tileElement->properties.path.edges &= ~(1 << direction);
otherTileElement->properties.path.edges &= ~(1 << ((direction + 2) & 3));
if (action >= 2)
tileElement->properties.path.type |= direction;
tileElement->AsPath()->SetSlopeDirection(direction);
}
else if (action < 0)
{
@@ -1667,7 +1681,7 @@ void footpath_chain_ride_queue(
}
}
tileElement->properties.path.type &= ~FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER;
tileElement->AsPath()->SetHasQueueBanner(false);
tileElement->properties.path.edges |= (1 << (direction ^ 2));
tileElement->properties.path.ride_index = rideIndex;
tileElement->AsPath()->SetStationIndex(entranceIndex);
@@ -1697,7 +1711,7 @@ void footpath_chain_ride_queue(
{
if (lastPathElement->AsPath()->IsQueue())
{
lastPathElement->properties.path.type |= FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER;
lastPathElement->AsPath()->SetHasQueueBanner(true);
lastPathElement->AsPath()->SetQueueBannerDirection(lastPathDirection); // set the ride sign direction
map_animation_create(MAP_ANIMATION_TYPE_QUEUE_BANNER, lastPathX, lastPathY, lastPathElement->base_height);
@@ -1993,6 +2007,13 @@ bool PathElement::HasQueueBanner() const
return (entryIndex & FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER) != 0;
}
void PathElement::SetHasQueueBanner(bool hasQueueBanner)
{
entryIndex &= ~FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER;
if (hasQueueBanner)
entryIndex |= FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER;
}
uint8_t PathElement::GetStationIndex() const
{
return (additions & FOOTPATH_PROPERTIES_ADDITIONS_STATION_INDEX_MASK) >> 4;
+4 -5
View File
@@ -629,17 +629,16 @@ bool map_coord_is_connected(int32_t x, int32_t y, int32_t z, uint8_t faceDirecti
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
continue;
rct_tile_element_path_properties props = tileElement->properties.path;
uint8_t pathDirection = props.type & 3;
uint8_t slopeDirection = tileElement->AsPath()->GetSlopeDirection();
if (tileElement->AsPath()->IsSloped())
{
if (pathDirection == faceDirection)
if (slopeDirection == faceDirection)
{
if (z == tileElement->base_height + 2)
return true;
}
else if ((pathDirection ^ 2) == faceDirection && z == tileElement->base_height)
else if ((slopeDirection ^ 2) == faceDirection && z == tileElement->base_height)
{
return true;
}
@@ -3139,7 +3138,7 @@ void map_remove_all_rides()
case TILE_ELEMENT_TYPE_PATH:
if (it.element->AsPath()->IsQueue())
{
it.element->properties.path.type &= ~8;
it.element->AsPath()->SetHasQueueBanner(false);
it.element->properties.path.addition_status = 255;
}
break;
+1
View File
@@ -220,6 +220,7 @@ public:
bool IsQueue() const;
void SetIsQueue(bool isQueue);
bool HasQueueBanner() const;
void SetHasQueueBanner(bool hasQueueBanner);
bool HasAddition() const;
uint8_t GetAddition() const;
+1 -5
View File
@@ -611,11 +611,7 @@ int32_t tile_inspector_path_set_sloped(int32_t x, int32_t y, int32_t elementInde
if (flags & GAME_COMMAND_FLAG_APPLY)
{
pathElement->properties.path.type &= ~(1 << 2);
if (sloped)
{
pathElement->properties.path.type |= (1 << 2);
}
pathElement->AsPath()->SetSloped(sloped);
map_invalidate_tile_full(x << 5, y << 5);