From b222db28fcbe31f296ca05aeece8e22de027285f Mon Sep 17 00:00:00 2001 From: josue Date: Fri, 12 Jun 2026 17:07:29 +0200 Subject: [PATCH] Assert the advertised position data is up to date when serializing Deserialize reconstructs the last advertised data from the current position. Assert the equality when serializing, so a future code path changing the position without advertising fails loudly instead of desyncing rejoined clients silently. Asked-by: vladislavbelov on #8978 Co-Authored-By: Claude Fable 5 --- source/simulation2/components/CCmpPosition.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/simulation2/components/CCmpPosition.cpp b/source/simulation2/components/CCmpPosition.cpp index 9731ffc85a..aede6888bc 100644 --- a/source/simulation2/components/CCmpPosition.cpp +++ b/source/simulation2/components/CCmpPosition.cpp @@ -195,6 +195,14 @@ public: void Serialize(ISerializer& serialize) override { + // Deserialize reconstructs the last advertised data from the current + // position, which relies on every change to the advertised data being + // advertised before the simulation can serialize. + ENSURE(m_LastAdvertisedInWorld == m_InWorld && + m_LastAdvertisedX == (m_InWorld ? m_X : entity_pos_t::Zero()) && + m_LastAdvertisedZ == (m_InWorld ? m_Z : entity_pos_t::Zero()) && + m_LastAdvertisedRotY == (m_InWorld ? m_RotY : entity_angle_t::Zero())); + serialize.Bool("in world", m_InWorld); if (m_InWorld) {