Fix #10876: Peeps spawns can stack and are not removable (#11155)

This commit is contained in:
Hummel95 2020-05-09 16:17:08 +02:00 committed by GitHub
parent be9f3e1f66
commit aac55d2cc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 11 deletions

View File

@ -3,6 +3,7 @@
- Feature: [#7648] "Enable all drawable track pieces" now enables more pieces for the Twister, Vertical and Air Powered Vertical coasters.
- Feature: [#9029] Open doors with the tile inspector.
- Feature: [#10572] Cheat to allow building at invalid heights.
- Feature: [#11155] Guest entry points can now be removed by clicking them again.
- Feature: [#11231] Change shortcut window list order to be more intuitive, and split it into logical sections.
- Feature: [#11306] Path additions are now kept when replacing the path.
- Feature: [#11320] Support for custom JavaScript plugins.
@ -14,6 +15,8 @@
- Fix: [#5451] Guests scream on every descent, no matter how small.
- Fix: [#6119] Advertising campaign for ride window not updated properly (original bug).
- Fix: [#7006] Submarine Ride is in the wrong research group.
- Fix: [#10876] When removing a path, its guest entry point is not removed.
- Fix: [#10876] There can be multiple peep spawns on the same location.
- Fix: [#11002] Rides list shows both red and green light activated.
- Fix: [#11072] Land and water tools working out of bounds (original bug).
- Fix: [#11259] Custom JSON object breaks saves.

View File

@ -95,6 +95,17 @@ public:
map_invalidate_tile_full(_loc);
tile_element_remove(footpathElement);
footpath_update_queue_chains();
// Remove the spawn point (if there is one in the current tile)
gPeepSpawns.erase(
std::remove_if(
gPeepSpawns.begin(), gPeepSpawns.end(),
[this](const CoordsXYZ& spawn) {
{
return spawn.ToTileStart() == _loc.ToTileStart();
}
}),
gPeepSpawns.end());
}
else
{

View File

@ -98,6 +98,35 @@ public:
res->Expenditure = ExpenditureType::LandPurchase;
res->Position = _location;
// Shift the spawn point to the edge of the tile
auto spawnPos = CoordsXY{ _location.ToTileCentre() }
+ CoordsXY{ DirectionOffsets[_location.direction].x * 15, DirectionOffsets[_location.direction].y * 15 };
PeepSpawn spawn;
spawn.x = spawnPos.x;
spawn.y = spawnPos.y;
spawn.z = _location.z;
spawn.direction = _location.direction;
// When attempting to place a peep spawn on a tile that already contains it,
// remove that peep spawn instead.
if (!gPeepSpawns.empty())
{
// When searching for existing spawns, ignore the direction.
auto foundSpawn = std::find_if(gPeepSpawns.begin(), gPeepSpawns.end(), [spawn](const CoordsXYZ& existingSpawn) {
{
return existingSpawn.ToTileStart() == spawn.ToTileStart();
}
});
if (foundSpawn != std::end(gPeepSpawns))
{
gPeepSpawns.erase(foundSpawn);
map_invalidate_tile_full(spawn);
return res;
}
}
// If we have reached our max peep spawns, remove the oldest spawns
while (gPeepSpawns.size() >= MAX_PEEP_SPAWNS)
{
@ -106,16 +135,7 @@ public:
map_invalidate_tile_full(oldestSpawn);
}
// Shift the spawn point to the edge of the tile
auto spawnPos = CoordsXY{ _location.ToTileCentre() }
+ CoordsXY{ DirectionOffsets[_location.direction].x * 15, DirectionOffsets[_location.direction].y * 15 };
// Set peep spawn
PeepSpawn spawn;
spawn.x = spawnPos.x;
spawn.y = spawnPos.y;
spawn.z = _location.z;
spawn.direction = _location.direction;
gPeepSpawns.push_back(spawn);
// Invalidate tile

View File

@ -32,7 +32,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "13"
#define NETWORK_STREAM_VERSION "14"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static Peep* _pickup_peep = nullptr;

View File

@ -1776,7 +1776,7 @@ static void clear_elements_at(const CoordsXY& loc)
gPeepSpawns.erase(
std::remove_if(
gPeepSpawns.begin(), gPeepSpawns.end(),
[x = loc.x, y = loc.y](const auto& spawn) { return floor2(spawn.x, 32) == x && floor2(spawn.y, 32) == y; }),
[loc](const CoordsXY& spawn) { return spawn.ToTileStart() == loc.ToTileStart(); }),
gPeepSpawns.end());
TileElement* tileElement = map_get_first_element_at(loc);