1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Fix #24260: Optimize the lookup for nearby guests by entertainers (#24263)

This commit is contained in:
Matt
2025-04-21 20:09:30 +03:00
committed by GitHub
parent bc20f5f922
commit bb41d0022f
2 changed files with 35 additions and 24 deletions

View File

@@ -4,6 +4,7 @@
- Improved: [#23590] Title bars are now drawn bigger when “Enlarged UI” is enabled.
- Improved: [#23626] Add small, medium and large flat and sloped turns, S-bends and diagonal track to the Go-Karts.
- Improved: [#23982] The scenario objective window has been merged into the scenario options window.
- Improved: [#24260] Better performance on parks that have a lot of Guests and Entertainers.
- Change: [#23803] Lightning strikes and thunder happen at the same frequency independently of the game speed.
- Change: [#23857] Replace display options tab with custom sprites.
- Change: [#24069] [Plugin] Plugins are now available in the scenario editor and track designer.

View File

@@ -866,32 +866,42 @@ bool Staff::IsMechanicHeadingToFixRideBlockingPath()
*/
void Staff::EntertainerUpdateNearbyPeeps() const
{
for (auto guest : EntityList<Guest>())
// Iterate over tiles within a 3-tile radius (96 units)
constexpr auto kTileRadius = 3;
constexpr auto kLookupRadius = kCoordsXYStep * kTileRadius;
for (int32_t tileX = x - kLookupRadius; tileX <= x + kLookupRadius; tileX += kCoordsXYStep)
{
if (guest->x == kLocationNull)
continue;
int16_t z_dist = abs(z - guest->z);
if (z_dist > 48)
continue;
int16_t x_dist = abs(x - guest->x);
int16_t y_dist = abs(y - guest->y);
if (x_dist > 96)
continue;
if (y_dist > 96)
continue;
if (guest->State == PeepState::Walking)
for (int32_t tileY = y - kLookupRadius; tileY <= y + kLookupRadius; tileY += kCoordsXYStep)
{
guest->HappinessTarget = std::min(guest->HappinessTarget + 4, kPeepMaxHappiness);
}
else if (guest->State == PeepState::Queuing)
{
guest->TimeInQueue = std::max(0, guest->TimeInQueue - 200);
guest->HappinessTarget = std::min(guest->HappinessTarget + 3, kPeepMaxHappiness);
for (auto* guest : EntityTileList<Guest>({ tileX, tileY }))
{
if (guest->x == kLocationNull)
continue;
int16_t z_dist = std::abs(z - guest->z);
if (z_dist > 48)
continue;
int16_t x_dist = std::abs(x - guest->x);
int16_t y_dist = std::abs(y - guest->y);
if (x_dist > kLookupRadius)
continue;
if (y_dist > kLookupRadius)
continue;
if (guest->State == PeepState::Walking)
{
guest->HappinessTarget = std::min(guest->HappinessTarget + 4, kPeepMaxHappiness);
}
else if (guest->State == PeepState::Queuing)
{
guest->TimeInQueue = std::max(0, guest->TimeInQueue - 200);
guest->HappinessTarget = std::min(guest->HappinessTarget + 3, kPeepMaxHappiness);
}
}
}
}
}