mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Fix #23289: Dodgems and Flying Saucers can spawn on top of each other
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
- Fix: [#5269] Font bugs when using the Russian release of RCT2 as the base game.
|
||||
- Fix: [#11071, #22958] The virtual floor does not always draw correctly.
|
||||
- Fix: [#20158] Custom animated scenery .DATs with frame offsets draw a random sprite at the end of their animation.
|
||||
- Fix: [#23289] Dodgems and Flying Saucer cars can spawn on top of each other when the ride is opened.
|
||||
- Fix: [#24332] Banner font renders differently when using RCT Classic as the base game.
|
||||
- Fix: [#24346] Possible crash during line drawing in OpenGL mode.
|
||||
- Fix: [#24353] ‘Show dirty visuals’ is off by one pixel and does not work correctly with higher framerates.
|
||||
|
||||
@@ -54,6 +54,8 @@ struct EntityBase
|
||||
*/
|
||||
void MoveTo(const CoordsXYZ& newLocation);
|
||||
|
||||
void MoveToAndUpdateSpatialIndex(const CoordsXYZ& newLocation);
|
||||
|
||||
/**
|
||||
* Sets the entity location without screen invalidation.
|
||||
*/
|
||||
|
||||
@@ -448,6 +448,18 @@ static void EntitySpatialRemove(EntityBase& entity)
|
||||
entity.SpatialIndex = kInvalidSpatialIndex;
|
||||
}
|
||||
|
||||
static void UpdateEntitySpatialIndex(EntityBase& entity)
|
||||
{
|
||||
if (entity.SpatialIndex & kSpatialIndexDirtyMask)
|
||||
{
|
||||
if (entity.SpatialIndex != kInvalidSpatialIndex)
|
||||
{
|
||||
EntitySpatialRemove(entity);
|
||||
}
|
||||
EntitySpatialInsert(entity, { entity.x, entity.y });
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateEntitiesSpatialIndex()
|
||||
{
|
||||
for (auto& entityList : gEntityLists)
|
||||
@@ -455,16 +467,9 @@ void UpdateEntitiesSpatialIndex()
|
||||
for (auto& entityId : entityList)
|
||||
{
|
||||
auto* entity = TryGetEntity(entityId);
|
||||
if (entity == nullptr || entity->Type == EntityType::Null)
|
||||
continue;
|
||||
|
||||
if (entity->SpatialIndex & kSpatialIndexDirtyMask)
|
||||
if (entity != nullptr && entity->Type != EntityType::Null)
|
||||
{
|
||||
if (entity->SpatialIndex != kInvalidSpatialIndex)
|
||||
{
|
||||
EntitySpatialRemove(*entity);
|
||||
}
|
||||
EntitySpatialInsert(*entity, { entity->x, entity->y });
|
||||
UpdateEntitySpatialIndex(*entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -538,6 +543,12 @@ void EntityBase::MoveTo(const CoordsXYZ& newLocation)
|
||||
}
|
||||
}
|
||||
|
||||
void EntityBase::MoveToAndUpdateSpatialIndex(const CoordsXYZ& newLocation)
|
||||
{
|
||||
MoveTo(newLocation);
|
||||
UpdateEntitySpatialIndex(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees any dynamically attached memory to the entity, such as peep name.
|
||||
*/
|
||||
|
||||
@@ -3308,7 +3308,7 @@ static Vehicle* VehicleCreateCar(
|
||||
chosenLoc.x = dodgemPos.x + (ScenarioRand() & 0xFF);
|
||||
} while (vehicle->DodgemsCarWouldCollideAt(chosenLoc).has_value());
|
||||
|
||||
vehicle->MoveTo({ chosenLoc, dodgemPos.z });
|
||||
vehicle->MoveToAndUpdateSpatialIndex({ chosenLoc, dodgemPos.z });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user