mirror of https://github.com/OpenRCT2/OpenRCT2.git
Use TileElementsView for guest code
This commit is contained in:
parent
9dde45fb05
commit
ee3a36dc0f
|
@ -36,6 +36,7 @@
|
||||||
#include "../world/Scenery.h"
|
#include "../world/Scenery.h"
|
||||||
#include "../world/Sprite.h"
|
#include "../world/Sprite.h"
|
||||||
#include "../world/Surface.h"
|
#include "../world/Surface.h"
|
||||||
|
#include "../world/TileElementsView.h"
|
||||||
#include "GuestPathfinding.h"
|
#include "GuestPathfinding.h"
|
||||||
#include "Peep.h"
|
#include "Peep.h"
|
||||||
#include "Staff.h"
|
#include "Staff.h"
|
||||||
|
@ -43,6 +44,8 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
// Locations of the spiral slide platform that a peep walks from the entrance of the ride to the
|
// Locations of the spiral slide platform that a peep walks from the entrance of the ride to the
|
||||||
// entrance of the slide. Up to 4 waypoints for each 4 sides that an ride entrance can be located
|
// entrance of the slide. Up to 4 waypoints for each 4 sides that an ride entrance can be located
|
||||||
// and 4 different rotations of the ride. 4 * 4 * 4 = 64 locations.
|
// and 4 different rotations of the ride. 4 * 4 * 4 = 64 locations.
|
||||||
|
@ -944,29 +947,24 @@ void Guest::Tick128UpdateGuest(int32_t index)
|
||||||
{
|
{
|
||||||
/* Peep happiness is affected once the peep has been waiting
|
/* Peep happiness is affected once the peep has been waiting
|
||||||
* too long in a queue. */
|
* too long in a queue. */
|
||||||
TileElement* tileElement = map_get_first_element_at(NextLoc);
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
do
|
for (auto* pathElement : TileElementsView<PathElement>(NextLoc))
|
||||||
{
|
{
|
||||||
if (tileElement == nullptr)
|
if (pathElement->GetBaseZ() != NextLoc.z)
|
||||||
break;
|
|
||||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
|
|
||||||
continue;
|
|
||||||
if (tileElement->GetBaseZ() != NextLoc.z)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Check if the footpath has a queue line TV monitor on it
|
// Check if the footpath has a queue line TV monitor on it
|
||||||
if (tileElement->AsPath()->HasAddition() && !tileElement->AsPath()->AdditionIsGhost())
|
if (pathElement->HasAddition() && !pathElement->AdditionIsGhost())
|
||||||
{
|
{
|
||||||
auto pathSceneryIndex = tileElement->AsPath()->GetAdditionEntryIndex();
|
auto pathSceneryIndex = pathElement->GetAdditionEntryIndex();
|
||||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(pathSceneryIndex);
|
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(pathSceneryIndex);
|
||||||
if (sceneryEntry != nullptr && sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_QUEUE_SCREEN)
|
if (sceneryEntry != nullptr && (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_QUEUE_SCREEN))
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} while (!(tileElement++)->IsLastForTile());
|
}
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
|
@ -1678,20 +1676,14 @@ std::bitset<MAX_RIDES> Guest::FindRidesToGoOn()
|
||||||
{
|
{
|
||||||
for (int32_t tileY = cy - radius; tileY <= cy + radius; tileY += COORDS_XY_STEP)
|
for (int32_t tileY = cy - radius; tileY <= cy + radius; tileY += COORDS_XY_STEP)
|
||||||
{
|
{
|
||||||
if (map_is_location_valid({ tileX, tileY }))
|
auto location = CoordsXY{ tileX, tileY };
|
||||||
|
if (!map_is_location_valid(location))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (auto* trackElement : TileElementsView<TrackElement>(location))
|
||||||
{
|
{
|
||||||
auto tileElement = map_get_first_element_at({ tileX, tileY });
|
auto rideIndex = trackElement->GetRideIndex();
|
||||||
if (tileElement != nullptr)
|
rideConsideration[rideIndex] = true;
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK)
|
|
||||||
{
|
|
||||||
auto rideIndex = tileElement->AsTrack()->GetRideIndex();
|
|
||||||
rideConsideration[rideIndex] = true;
|
|
||||||
}
|
|
||||||
} while (!(tileElement++)->IsLastForTile());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2705,10 +2697,7 @@ static PeepThoughtType peep_assess_surroundings(int16_t centre_x, int16_t centre
|
||||||
{
|
{
|
||||||
for (int16_t y = initial_y; y < final_y; y += COORDS_XY_STEP)
|
for (int16_t y = initial_y; y < final_y; y += COORDS_XY_STEP)
|
||||||
{
|
{
|
||||||
TileElement* tileElement = map_get_first_element_at({ x, y });
|
for (auto* tileElement : TileElementsView({ x, y }))
|
||||||
if (tileElement == nullptr)
|
|
||||||
continue;
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
Ride* ride;
|
Ride* ride;
|
||||||
rct_scenery_entry* scenery;
|
rct_scenery_entry* scenery;
|
||||||
|
@ -2770,7 +2759,7 @@ static PeepThoughtType peep_assess_surroundings(int16_t centre_x, int16_t centre
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (!(tileElement++)->IsLastForTile());
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2939,24 +2928,21 @@ template<typename T> static void peep_head_for_nearest_ride(Guest* peep, bool co
|
||||||
{
|
{
|
||||||
for (auto y = cy - searchRadius; y <= cy + searchRadius; y += COORDS_XY_STEP)
|
for (auto y = cy - searchRadius; y <= cy + searchRadius; y += COORDS_XY_STEP)
|
||||||
{
|
{
|
||||||
if (map_is_location_valid({ x, y }))
|
auto location = CoordsXY{ x, y };
|
||||||
|
if (!map_is_location_valid(location))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (auto* trackElement : TileElementsView<TrackElement>(location))
|
||||||
{
|
{
|
||||||
auto tileElement = map_get_first_element_at({ x, y });
|
auto rideIndex = trackElement->GetRideIndex();
|
||||||
if (tileElement != nullptr)
|
auto ride = get_ride(rideIndex);
|
||||||
{
|
if (ride == nullptr)
|
||||||
do
|
continue;
|
||||||
{
|
|
||||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK)
|
if (!predicate(*ride))
|
||||||
{
|
continue;
|
||||||
auto rideIndex = tileElement->AsTrack()->GetRideIndex();
|
|
||||||
auto ride = get_ride(rideIndex);
|
rideConsideration[rideIndex] = true;
|
||||||
if (ride != nullptr && predicate(*ride))
|
|
||||||
{
|
|
||||||
rideConsideration[rideIndex] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (!(tileElement++)->IsLastForTile());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3936,19 +3922,20 @@ void Guest::UpdateRideLeaveVehicle()
|
||||||
if (trackType == TrackElemType::Flat || trackType > TrackElemType::MiddleStation)
|
if (trackType == TrackElemType::Flat || trackType > TrackElemType::MiddleStation)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
TileElement* inner_map = map_get_first_element_at(vehicle->TrackLocation);
|
bool foundStation = false;
|
||||||
if (inner_map == nullptr)
|
for (auto* trackElement : TileElementsView<TrackElement>(vehicle->TrackLocation))
|
||||||
continue;
|
|
||||||
for (;; inner_map++)
|
|
||||||
{
|
{
|
||||||
if (inner_map->GetType() != TILE_ELEMENT_TYPE_TRACK)
|
if (trackElement->GetBaseZ() != vehicle->TrackLocation.z)
|
||||||
continue;
|
continue;
|
||||||
if (inner_map->GetBaseZ() == vehicle->TrackLocation.z)
|
|
||||||
break;
|
if (trackElement->GetStationIndex() != CurrentRideStation)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foundStation = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto stationIndex = inner_map->AsTrack()->GetStationIndex();
|
if (foundStation)
|
||||||
if (stationIndex == CurrentRideStation)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4773,17 +4760,10 @@ void Guest::UpdateRideLeaveExit()
|
||||||
CoordsXY targetLoc = { x, y };
|
CoordsXY targetLoc = { x, y };
|
||||||
|
|
||||||
// Find the station track element
|
// Find the station track element
|
||||||
TileElement* tileElement = map_get_first_element_at(targetLoc);
|
for (auto* pathElement : TileElementsView<PathElement>(targetLoc))
|
||||||
if (tileElement == nullptr)
|
|
||||||
return;
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
|
int16_t height = map_height_from_slope(targetLoc, pathElement->GetSlopeDirection(), pathElement->IsSloped());
|
||||||
continue;
|
height += pathElement->GetBaseZ();
|
||||||
|
|
||||||
int16_t height = map_height_from_slope(
|
|
||||||
targetLoc, tileElement->AsPath()->GetSlopeDirection(), tileElement->AsPath()->IsSloped());
|
|
||||||
height += tileElement->GetBaseZ();
|
|
||||||
|
|
||||||
int16_t z_diff = z - height;
|
int16_t z_diff = z - height;
|
||||||
if (z_diff > 0 || z_diff < -16)
|
if (z_diff > 0 || z_diff < -16)
|
||||||
|
@ -4791,7 +4771,7 @@ void Guest::UpdateRideLeaveExit()
|
||||||
|
|
||||||
MoveTo({ x, y, height });
|
MoveTo({ x, y, height });
|
||||||
return;
|
return;
|
||||||
} while (!(tileElement++)->IsLastForTile());
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5598,51 +5578,30 @@ void Guest::UpdateUsingBin()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileElement* tileElement = map_get_first_element_at(NextLoc);
|
PathElement* foundElement = nullptr;
|
||||||
if (tileElement == nullptr)
|
for (auto* pathElement : TileElementsView<PathElement>(NextLoc))
|
||||||
return;
|
|
||||||
|
|
||||||
bool found = false;
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
|
if (pathElement->GetBaseZ() != NextLoc.z)
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (tileElement->GetBaseZ() == NextLoc.z)
|
if (!pathElement->HasAddition())
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
} while (!(tileElement++)->IsLastForTile());
|
|
||||||
|
|
||||||
if (!found)
|
rct_scenery_entry* sceneryEntry = pathElement->GetAdditionEntry();
|
||||||
{
|
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN))
|
||||||
StateReset();
|
break;
|
||||||
return;
|
|
||||||
|
if (pathElement->IsBroken())
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (pathElement->AdditionIsGhost())
|
||||||
|
break;
|
||||||
|
|
||||||
|
foundElement = pathElement;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tileElement->AsPath()->HasAddition())
|
if (foundElement == nullptr)
|
||||||
{
|
|
||||||
StateReset();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rct_scenery_entry* sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
|
|
||||||
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN))
|
|
||||||
{
|
|
||||||
StateReset();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tileElement->AsPath()->IsBroken())
|
|
||||||
{
|
|
||||||
StateReset();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tileElement->AsPath()->AdditionIsGhost())
|
|
||||||
{
|
{
|
||||||
StateReset();
|
StateReset();
|
||||||
return;
|
return;
|
||||||
|
@ -5652,7 +5611,7 @@ void Guest::UpdateUsingBin()
|
||||||
uint8_t selectedBin = Var37 * 2;
|
uint8_t selectedBin = Var37 * 2;
|
||||||
|
|
||||||
// This counts down 2 = No rubbish, 0 = full
|
// This counts down 2 = No rubbish, 0 = full
|
||||||
uint8_t spaceLeftInBin = 0x3 & (tileElement->AsPath()->GetAdditionStatus() >> selectedBin);
|
uint8_t spaceLeftInBin = 0x3 & (foundElement->GetAdditionStatus() >> selectedBin);
|
||||||
uint64_t emptyContainers = GetEmptyContainerFlags();
|
uint64_t emptyContainers = GetEmptyContainerFlags();
|
||||||
|
|
||||||
for (uint8_t curContainer = 0; curContainer < 64; curContainer++)
|
for (uint8_t curContainer = 0; curContainer < 64; curContainer++)
|
||||||
|
@ -5686,14 +5645,14 @@ void Guest::UpdateUsingBin()
|
||||||
UpdateSpriteType();
|
UpdateSpriteType();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t additionStatus = tileElement->AsPath()->GetAdditionStatus();
|
uint8_t additionStatus = foundElement->GetAdditionStatus();
|
||||||
// Place new amount in bin by first clearing the value
|
// Place new amount in bin by first clearing the value
|
||||||
additionStatus &= ~(3 << selectedBin);
|
additionStatus &= ~(3 << selectedBin);
|
||||||
// Then placing the new value.
|
// Then placing the new value.
|
||||||
additionStatus |= spaceLeftInBin << selectedBin;
|
additionStatus |= spaceLeftInBin << selectedBin;
|
||||||
tileElement->AsPath()->SetAdditionStatus(additionStatus);
|
foundElement->SetAdditionStatus(additionStatus);
|
||||||
|
|
||||||
map_invalidate_tile_zoom0({ NextLoc, tileElement->GetBaseZ(), tileElement->GetClearanceZ() });
|
map_invalidate_tile_zoom0({ NextLoc, foundElement->GetBaseZ(), foundElement->GetClearanceZ() });
|
||||||
StateReset();
|
StateReset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5730,6 +5689,32 @@ bool Guest::ShouldFindBench()
|
||||||
return !GetNextIsSurface() && !GetNextIsSloped();
|
return !GetNextIsSurface() && !GetNextIsSloped();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PathElement* FindBench(const CoordsXYZ& loc)
|
||||||
|
{
|
||||||
|
for (auto* pathElement : TileElementsView<PathElement>(loc))
|
||||||
|
{
|
||||||
|
if (pathElement->GetBaseZ() != loc.z)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!pathElement->HasAddition())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
rct_scenery_entry* sceneryEntry = pathElement->GetAdditionEntry();
|
||||||
|
if (sceneryEntry == nullptr || !(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BENCH))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (pathElement->IsBroken())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (pathElement->AdditionIsGhost())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return pathElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* rct2: 0x00690582
|
* rct2: 0x00690582
|
||||||
|
@ -5740,40 +5725,13 @@ bool Guest::UpdateWalkingFindBench()
|
||||||
if (!ShouldFindBench())
|
if (!ShouldFindBench())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TileElement* tileElement = map_get_first_element_at(NextLoc);
|
auto* pathElement = FindBench(NextLoc);
|
||||||
if (tileElement == nullptr)
|
if (pathElement == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (;; tileElement++)
|
int32_t edges = pathElement->GetEdges() ^ 0xF;
|
||||||
{
|
|
||||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)
|
|
||||||
{
|
|
||||||
if (NextLoc.z == tileElement->GetBaseZ())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (tileElement->IsLastForTile())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tileElement->AsPath()->HasAddition())
|
|
||||||
return false;
|
|
||||||
rct_scenery_entry* sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
|
|
||||||
|
|
||||||
if (sceneryEntry == nullptr || !(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BENCH))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (tileElement->AsPath()->IsBroken())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (tileElement->AsPath()->AdditionIsGhost())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int32_t edges = (tileElement->AsPath()->GetEdges()) ^ 0xF;
|
|
||||||
if (edges == 0)
|
if (edges == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint8_t chosen_edge = scenario_rand() & 0x3;
|
uint8_t chosen_edge = scenario_rand() & 0x3;
|
||||||
|
|
||||||
for (; !(edges & (1 << chosen_edge));)
|
for (; !(edges & (1 << chosen_edge));)
|
||||||
|
@ -5822,6 +5780,32 @@ bool Guest::UpdateWalkingFindBench()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PathElement* FindBin(const CoordsXYZ& loc)
|
||||||
|
{
|
||||||
|
for (auto* pathElement : TileElementsView<PathElement>(loc))
|
||||||
|
{
|
||||||
|
if (pathElement->GetBaseZ() != loc.z)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!pathElement->HasAddition())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
rct_scenery_entry* sceneryEntry = pathElement->GetAdditionEntry();
|
||||||
|
if (sceneryEntry == nullptr || !(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (pathElement->IsBroken())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (pathElement->AdditionIsGhost())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return pathElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool Guest::UpdateWalkingFindBin()
|
bool Guest::UpdateWalkingFindBin()
|
||||||
{
|
{
|
||||||
auto peep = this;
|
auto peep = this;
|
||||||
|
@ -5831,48 +5815,18 @@ bool Guest::UpdateWalkingFindBin()
|
||||||
if (peep->GetNextIsSurface())
|
if (peep->GetNextIsSurface())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TileElement* tileElement = map_get_first_element_at(peep->NextLoc);
|
auto* pathElement = FindBin(peep->NextLoc);
|
||||||
if (tileElement == nullptr)
|
if (pathElement == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (;; tileElement++)
|
int32_t edges = (pathElement->GetEdges()) ^ 0xF;
|
||||||
{
|
|
||||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)
|
|
||||||
{
|
|
||||||
if (peep->NextLoc.z == tileElement->GetBaseZ())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (tileElement->IsLastForTile())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tileElement->AsPath()->HasAddition())
|
|
||||||
return false;
|
|
||||||
rct_scenery_entry* sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
|
|
||||||
if (sceneryEntry == nullptr)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (tileElement->AsPath()->IsBroken())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (tileElement->AsPath()->AdditionIsGhost())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int32_t edges = (tileElement->AsPath()->GetEdges()) ^ 0xF;
|
|
||||||
if (edges == 0)
|
if (edges == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint8_t chosen_edge = scenario_rand() & 0x3;
|
uint8_t chosen_edge = scenario_rand() & 0x3;
|
||||||
|
|
||||||
// Note: Bin quantity is inverted 0 = full, 3 = empty
|
// Note: Bin quantity is inverted 0 = full, 3 = empty
|
||||||
uint8_t bin_quantities = tileElement->AsPath()->GetAdditionStatus();
|
uint8_t bin_quantities = pathElement->GetAdditionStatus();
|
||||||
|
|
||||||
// Rotate the bin to the correct edge. Makes it easier for next calc.
|
// Rotate the bin to the correct edge. Makes it easier for next calc.
|
||||||
bin_quantities = ror8(ror8(bin_quantities, chosen_edge), chosen_edge);
|
bin_quantities = ror8(ror8(bin_quantities, chosen_edge), chosen_edge);
|
||||||
|
@ -5906,6 +5860,32 @@ bool Guest::UpdateWalkingFindBin()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PathElement* FindBreakableElement(const CoordsXYZ& loc)
|
||||||
|
{
|
||||||
|
for (auto* pathElement : TileElementsView<PathElement>(loc))
|
||||||
|
{
|
||||||
|
if (pathElement->GetBaseZ() != loc.z)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!pathElement->HasAddition())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
rct_scenery_entry* sceneryEntry = pathElement->GetAdditionEntry();
|
||||||
|
if (sceneryEntry == nullptr || !(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_BREAKABLE))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (pathElement->IsBroken())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (pathElement->AdditionIsGhost())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return pathElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* rct2: 0x00690848
|
* rct2: 0x00690848
|
||||||
|
@ -5934,37 +5914,11 @@ static void peep_update_walking_break_scenery(Peep* peep)
|
||||||
if (peep->GetNextIsSurface())
|
if (peep->GetNextIsSurface())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TileElement* tileElement = map_get_first_element_at(peep->NextLoc);
|
auto* tileElement = FindBreakableElement(peep->NextLoc);
|
||||||
if (tileElement == nullptr)
|
if (tileElement == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (;; tileElement++)
|
int32_t edges = tileElement->GetEdges();
|
||||||
{
|
|
||||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)
|
|
||||||
{
|
|
||||||
if (peep->NextLoc.z == tileElement->GetBaseZ())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (tileElement->IsLastForTile())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tileElement->AsPath()->HasAddition())
|
|
||||||
return;
|
|
||||||
rct_scenery_entry* sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
|
|
||||||
|
|
||||||
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_BREAKABLE))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (tileElement->AsPath()->IsBroken())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (tileElement->AsPath()->AdditionIsGhost())
|
|
||||||
return;
|
|
||||||
|
|
||||||
int32_t edges = tileElement->AsPath()->GetEdges();
|
|
||||||
if (edges == 0xF)
|
if (edges == 0xF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -5994,7 +5948,7 @@ static void peep_update_walking_break_scenery(Peep* peep)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tileElement->AsPath()->SetIsBroken(true);
|
tileElement->SetIsBroken(true);
|
||||||
|
|
||||||
map_invalidate_tile_zoom1({ peep->NextLoc, tileElement->GetBaseZ(), tileElement->GetBaseZ() + 32 });
|
map_invalidate_tile_zoom1({ peep->NextLoc, tileElement->GetBaseZ(), tileElement->GetBaseZ() + 32 });
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue