diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 758103600b..7411f41770 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -3,6 +3,7 @@ - Feature: [#23166] Add Galician translation. - Improved: [#23051] Add large sloped turns and new inversions to the Twister, Vertical Drop, Hyper and Flying Roller Coasters. - Improved: [#23123] Improve sorting of roller coasters in build new ride menu. +- Fix: [#23206] Multiplayer desyncs when FPS is uncapped. 0.4.16 (2024-11-03) ------------------------------------------------------------------------ diff --git a/src/openrct2/entity/EntityRegistry.cpp b/src/openrct2/entity/EntityRegistry.cpp index b3a5f76991..4d7e883689 100644 --- a/src/openrct2/entity/EntityRegistry.cpp +++ b/src/openrct2/entity/EntityRegistry.cpp @@ -481,6 +481,16 @@ void EntityBase::SetLocation(const CoordsXYZ& newLocation) SpatialIndex |= kSpatialIndexDirtyMask; } +static void EntitySetCoordinates(const CoordsXYZ& entityPos, EntityBase* entity) +{ + auto screenCoords = Translate3DTo2DWithZ(GetCurrentRotation(), entityPos); + + entity->SpriteData.SpriteRect = ScreenRect( + screenCoords - ScreenCoordsXY{ entity->SpriteData.Width, entity->SpriteData.HeightMin }, + screenCoords + ScreenCoordsXY{ entity->SpriteData.Width, entity->SpriteData.HeightMax }); + entity->SetLocation(entityPos); +} + void EntityBase::MoveTo(const CoordsXYZ& newLocation) { if (x != kLocationNull) @@ -506,16 +516,6 @@ void EntityBase::MoveTo(const CoordsXYZ& newLocation) } } -void EntitySetCoordinates(const CoordsXYZ& entityPos, EntityBase* entity) -{ - auto screenCoords = Translate3DTo2DWithZ(GetCurrentRotation(), entityPos); - - entity->SpriteData.SpriteRect = ScreenRect( - screenCoords - ScreenCoordsXY{ entity->SpriteData.Width, entity->SpriteData.HeightMin }, - screenCoords + ScreenCoordsXY{ entity->SpriteData.Width, entity->SpriteData.HeightMax }); - entity->SetLocation(entityPos); -} - /** * Frees any dynamically attached memory to the entity, such as peep name. */ diff --git a/src/openrct2/entity/EntityRegistry.h b/src/openrct2/entity/EntityRegistry.h index b33230e710..a370f38f44 100644 --- a/src/openrct2/entity/EntityRegistry.h +++ b/src/openrct2/entity/EntityRegistry.h @@ -67,7 +67,6 @@ void ResetAllEntities(); void ResetEntitySpatialIndices(); void UpdateAllMiscEntities(); void UpdateMoneyEffect(); -void EntitySetCoordinates(const CoordsXYZ& entityPos, EntityBase* entity); void EntityRemove(EntityBase* entity); uint16_t RemoveFloatingEntities(); void UpdateEntitiesSpatialIndex(); diff --git a/src/openrct2/entity/EntityTweener.cpp b/src/openrct2/entity/EntityTweener.cpp index 52bc453237..acd5e38ccf 100644 --- a/src/openrct2/entity/EntityTweener.cpp +++ b/src/openrct2/entity/EntityTweener.cpp @@ -101,8 +101,6 @@ void EntityTweener::Tween(float alpha) static_cast(std::round(posB.y * alpha + posA.y * inv)), static_cast(std::round(posB.z * alpha + posA.z * inv)) }); } - - UpdateEntitiesSpatialIndex(); } void EntityTweener::Restore() @@ -113,9 +111,7 @@ void EntityTweener::Restore() if (ent == nullptr) continue; - ent->Invalidate(); - EntitySetCoordinates(PostPos[i], ent); - ent->Invalidate(); + ent->MoveTo(PostPos[i]); } }