Port entrance station index and sequence lookup

This commit is contained in:
Michael Steenbeek authored and Gymnasiast committed 2018-09-27 22:15:04 +02:00
1 parent c7eaa1ba80
commit 3c93aca727
15 files changed
+41 -29

No files matched your search

@@ -523,7 +523,7 @@ static void viewport_interaction_remove_footpath_item(rct_tile_element* tileElem
void viewport_interaction_remove_park_entrance(rct_tile_element* tileElement, int32_t x, int32_t y)
{
int32_t rotation = tileElement->GetDirectionWithOffset(1);
switch (tileElement->properties.entrance.index & 0x0F)
switch (tileElement->AsEntrance()->GetSequenceIndex())
{
case 1:
x += CoordsDirectionDelta[rotation].x;
+2 -3
View File
@@ -1933,8 +1933,7 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
}
else
{
int16_t rideEntranceIndex = (tileElement->properties.entrance.index & 0x30)
>> 4; // TODO: use mask or function
int16_t rideEntranceIndex = tileElement->AsEntrance()->GetStationIndex();
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE)
{
// Ride entrance ID
@@ -1952,7 +1951,7 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE)
{
// Entrance part
rct_string_id entrancePart = ParkEntrancePartStringIds[tileElement->properties.entrance.index & 0x0F];
rct_string_id entrancePart = ParkEntrancePartStringIds[tileElement->AsEntrance()->GetSequenceIndex()];
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_ENTRANCE_PART, &entrancePart, COLOUR_DARK_GREEN, x, y + 22);
}
else
@@ -151,7 +151,7 @@ void setup_in_use_selection_flags()
if (iter.element->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE)
break;
// Skip if not the middle part
if (iter.element->properties.entrance.index != 0)
if (iter.element->AsEntrance()->GetSequenceIndex() != 0)
break;
Editor::SetSelectedObject(OBJECT_TYPE_PARK_ENTRANCE, 0, OBJECT_SELECTION_FLAG_SELECTED);
@@ -192,7 +192,7 @@ public:
newElement->SetType(TILE_ELEMENT_TYPE_ENTRANCE);
newElement->SetDirection(_direction);
newElement->properties.entrance.index = index;
newElement->AsEntrance()->SetSequenceIndex(index);
newElement->AsEntrance()->SetEntranceType(ENTRANCE_TYPE_PARK_ENTRANCE);
newElement->properties.entrance.path_type = gFootpathSelectedId;
@@ -231,7 +231,7 @@ static void park_entrance_paint(paint_session* session, uint8_t direction, int32
// Index to which part of the entrance
// Middle, left, right
uint8_t part_index = tile_element->properties.entrance.index & 0xF;
uint8_t part_index = tile_element->AsEntrance()->GetSequenceIndex();
rct_footpath_entry* path_entry = nullptr;
// The left and right of the park entrance often have this set to 127.
+2 -2
View File
@@ -2486,7 +2486,7 @@ static void peep_interact_with_entrance(
}
peep->time_lost = 0;
uint8_t stationNum = (tile_element->properties.entrance.index >> 4) & 0x7;
uint8_t stationNum = tile_element->AsEntrance()->GetStationIndex();
// Guest walks up to the ride for the first time since entering
// the path tile or since considering another ride attached to
// the path tile.
@@ -2538,7 +2538,7 @@ static void peep_interact_with_entrance(
}
// If not the centre of the entrance arch
if (tile_element->properties.entrance.index & 0xF)
if (tile_element->AsEntrance()->GetSequenceIndex() != 0)
{
peep_return_to_centre_of_tile(peep);
return;
+2 -2
View File
@@ -1938,7 +1938,7 @@ void rct_peep::UpdateHeadingToInspect()
if (current_ride != rideEntranceExitElement->AsEntrance()->GetRideIndex())
return;
uint8_t exit_index = ((rideEntranceExitElement->properties.entrance.index & 0x70) >> 4);
uint8_t exit_index = rideEntranceExitElement->AsEntrance()->GetStationIndex();
if (current_ride_station != exit_index)
return;
@@ -2056,7 +2056,7 @@ void rct_peep::UpdateAnswering()
if (current_ride != rideEntranceExitElement->AsEntrance()->GetRideIndex())
return;
uint8_t exit_index = ((rideEntranceExitElement->properties.entrance.index & 0x70) >> 4);
uint8_t exit_index = rideEntranceExitElement->AsEntrance()->GetStationIndex();
if (current_ride_station != exit_index)
return;
+1 -1
View File
@@ -2710,7 +2710,7 @@ private:
continue;
if (element->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE)
continue;
if ((element->properties.entrance.index & 0x0F) != 0)
if ((element->AsEntrance()->GetSequenceIndex()) != 0)
continue;
gParkEntrances[entranceIndex].x = it.x * 32;
+4 -5
View File
@@ -1880,7 +1880,7 @@ static int32_t ride_modify_entrance_or_exit(rct_tile_element* tileElement, int32
if (entranceType != ENTRANCE_TYPE_RIDE_ENTRANCE && entranceType != ENTRANCE_TYPE_RIDE_EXIT)
return 0;
int32_t bl = (tileElement->properties.entrance.index & 0x70) >> 4;
int32_t stationIndex = tileElement->AsEntrance()->GetStationIndex();
// Get or create construction window for ride
constructionWindow = window_find_by_class(WC_RIDE_CONSTRUCTION);
@@ -1905,7 +1905,7 @@ static int32_t ride_modify_entrance_or_exit(rct_tile_element* tileElement, int32
TOOL_CROSSHAIR);
gRideEntranceExitPlaceType = entranceType;
gRideEntranceExitPlaceRideIndex = rideIndex;
gRideEntranceExitPlaceStationIndex = bl;
gRideEntranceExitPlaceStationIndex = stationIndex;
input_set_flag(INPUT_FLAG_6, true);
if (_rideConstructionState != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT)
{
@@ -1921,7 +1921,7 @@ static int32_t ride_modify_entrance_or_exit(rct_tile_element* tileElement, int32
// Remove entrance / exit
game_do_command(
x, (GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_APPLY), y, rideIndex,
GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, bl, 0);
GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, stationIndex, 0);
gCurrentToolWidget.widget_index = entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE ? WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE
: WC_RIDE_CONSTRUCTION__WIDX_EXIT;
gRideEntranceExitPlaceType = entranceType;
@@ -8205,8 +8205,7 @@ void sub_6CB945(int32_t rideIndex)
ride_set_entrance_location(ride, stationId, entranceLocation);
}
tileElement->properties.entrance.index &= 0x8F;
tileElement->properties.entrance.index |= stationId << 4;
tileElement->AsEntrance()->SetStationIndex(stationId);
shouldRemove = false;
} while (!(trackElement++)->IsLastForTile());
+12 -1
View File
@@ -268,7 +268,7 @@ static money32 RideEntranceExitPlace(
tileElement->SetDirection(direction);
tileElement->clearance_height = clear_z;
tileElement->AsEntrance()->SetEntranceType(isExit ? ENTRANCE_TYPE_RIDE_EXIT : ENTRANCE_TYPE_RIDE_ENTRANCE);
tileElement->properties.entrance.index = stationNum << 4;
tileElement->AsEntrance()->SetStationIndex(stationNum);
tileElement->AsEntrance()->SetRideIndex(rideIndex);
if (flags & GAME_COMMAND_FLAG_GHOST)
@@ -661,3 +661,14 @@ void EntranceElement::SetRideIndex(uint8_t newRideIndex)
{
rideIndex = newRideIndex;
}
uint8_t EntranceElement::GetSequenceIndex() const
{
return index & 0xF;
}
void EntranceElement::SetSequenceIndex(uint8_t newSequenceIndex)
{
index &= ~0xF;
index |= (newSequenceIndex & 0xF);
}
+6 -6
View File
@@ -99,7 +99,7 @@ static constexpr const uint8_t connected_path_count[] = {
int32_t entrance_get_directions(const rct_tile_element* tileElement)
{
uint8_t entranceType = tileElement->AsEntrance()->GetEntranceType();
uint8_t sequence = tileElement->properties.entrance.index & 0x0F;
uint8_t sequence = tileElement->AsEntrance()->GetSequenceIndex();
return EntranceDirections[(entranceType * 8) + sequence];
}
@@ -218,7 +218,7 @@ static money32 footpath_element_insert(
entranceElement = map_get_park_entrance_element_at(x, y, z, false);
// Make sure the entrance part is the middle
if (entranceElement != nullptr && (entranceElement->properties.entrance.index & 0x0F) == 0)
if (entranceElement != nullptr && (entranceElement->AsEntrance()->GetSequenceIndex()) == 0)
{
entrancePath = true;
// Make the price the same as replacing a path
@@ -589,7 +589,7 @@ static money32 footpath_place_from_track(
entranceElement = map_get_park_entrance_element_at(x, y, z, false);
// Make sure the entrance part is the middle
if (entranceElement != nullptr && (entranceElement->properties.entrance.index & 0x0F) == 0)
if (entranceElement != nullptr && (entranceElement->AsEntrance()->GetSequenceIndex()) == 0)
{
entrancePath = true;
// Make the price the same as replacing a path
@@ -1397,7 +1397,7 @@ static void loc_6A6D7E(
{
neighbour_list_push(
neighbourList, 8, direction, tileElement->AsEntrance()->GetRideIndex(),
tileElement->properties.entrance.index);
tileElement->AsEntrance()->GetStationIndex());
}
else
{
@@ -1427,7 +1427,7 @@ static void loc_6A6D7E(
{
neighbour_list_push(
neighbourList, 4, direction, tileElement->properties.path.ride_index,
tileElement->properties.entrance.index);
tileElement->properties.path.additions);
}
else
{
@@ -1438,7 +1438,7 @@ static void loc_6A6D7E(
{
neighbour_list_push(
neighbourList, 3, direction, tileElement->properties.path.ride_index,
tileElement->properties.entrance.index);
tileElement->properties.path.additions);
}
}
}
+1 -1
View File
@@ -3848,7 +3848,7 @@ static void clear_element_at(int32_t x, int32_t y, rct_tile_element** elementPtr
case TILE_ELEMENT_TYPE_ENTRANCE:
{
int32_t rotation = element->GetDirectionWithOffset(1);
switch (element->properties.entrance.index & 0x0F)
switch (element->AsEntrance()->GetSequenceIndex())
{
case 1:
x += CoordsDirectionDelta[rotation].x;
+1 -1
View File
@@ -248,7 +248,7 @@ static bool map_animation_invalidate_park_entrance(int32_t x, int32_t y, int32_t
continue;
if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE)
continue;
if (tileElement->properties.entrance.index & 0x0F)
if (tileElement->AsEntrance()->GetSequenceIndex())
continue;
baseZ = tileElement->base_height * 8;
+3
View File
@@ -389,6 +389,9 @@ public:
uint8_t GetStationIndex() const;
void SetStationIndex(uint8_t stationIndex);
uint8_t GetSequenceIndex() const;
void SetSequenceIndex(uint8_t newSequenceIndex);
};
assert_struct_size(EntranceElement, 8);
+3 -3
View File
@@ -242,7 +242,7 @@ int32_t tile_inspector_rotate_element_at(int32_t x, int32_t y, int32_t elementIn
// Update ride's known entrance/exit rotation
Ride* ride = get_ride(tileElement->AsEntrance()->GetRideIndex());
uint8_t stationIndex = tileElement->properties.entrance.index;
uint8_t stationIndex = tileElement->AsEntrance()->GetStationIndex();
auto entrance = ride_get_entrance_location(ride, stationIndex);
auto exit = ride_get_exit_location(ride, stationIndex);
uint8_t entranceType = tileElement->AsEntrance()->GetEntranceType();
@@ -442,7 +442,7 @@ int32_t tile_inspector_any_base_height_offset(int32_t x, int32_t y, int16_t elem
{
// Update the ride's known entrance or exit height
Ride* ride = get_ride(tileElement->AsEntrance()->GetRideIndex());
uint8_t entranceIndex = tileElement->properties.entrance.index;
uint8_t entranceIndex = tileElement->AsEntrance()->GetStationIndex();
auto entrance = ride_get_entrance_location(ride, entranceIndex);
auto exit = ride_get_exit_location(ride, entranceIndex);
uint8_t z = tileElement->base_height;
@@ -671,7 +671,7 @@ int32_t tile_inspector_entrance_make_usable(int32_t x, int32_t y, int32_t elemen
if (flags & GAME_COMMAND_FLAG_APPLY)
{
uint8_t stationIndex = entranceElement->properties.entrance.index >> 6;
uint8_t stationIndex = entranceElement->AsEntrance()->GetStationIndex();
switch (entranceElement->AsEntrance()->GetEntranceType())
{