From f6670a5691171da8ed99286292de538b98a4f9e4 Mon Sep 17 00:00:00 2001 From: Uladzislau Nikalayevich <thenormalnij@gmail.com> Date: Sun, 15 Dec 2024 15:31:53 +0300 Subject: [PATCH] Fix setServerConfigSetting crash --- .../logic/CStaticFunctionDefinitions.cpp | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 24c9ff6edc..ce44a7d79a 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -10852,26 +10852,35 @@ bool CStaticFunctionDefinitions::ResetMoonSize() bool CStaticFunctionDefinitions::SendSyncIntervals(CPlayer* pPlayer) { - CBitStream BitStream; - BitStream.pBitStream->Write(g_TickRateSettings.iPureSync); - BitStream.pBitStream->Write(g_TickRateSettings.iLightSync); - BitStream.pBitStream->Write(g_TickRateSettings.iCamSync); - BitStream.pBitStream->Write(g_TickRateSettings.iPedSync); - BitStream.pBitStream->Write(g_TickRateSettings.iUnoccupiedVehicle); - BitStream.pBitStream->Write(g_TickRateSettings.iObjectSync); - BitStream.pBitStream->Write(g_TickRateSettings.iKeySyncRotation); - BitStream.pBitStream->Write(g_TickRateSettings.iKeySyncAnalogMove); - - if (pPlayer->CanBitStream(eBitStreamVersion::FixSyncerDistance)) + auto sendSyncIntervalPatket = [](CPlayer* pPlayer) { - BitStream.pBitStream->Write(g_TickRateSettings.iPedSyncerDistance); - BitStream.pBitStream->Write(g_TickRateSettings.iUnoccupiedVehicleSyncerDistance); - } + CBitStream BitStream; + BitStream.pBitStream->Write(g_TickRateSettings.iPureSync); + BitStream.pBitStream->Write(g_TickRateSettings.iLightSync); + BitStream.pBitStream->Write(g_TickRateSettings.iCamSync); + BitStream.pBitStream->Write(g_TickRateSettings.iPedSync); + BitStream.pBitStream->Write(g_TickRateSettings.iUnoccupiedVehicle); + BitStream.pBitStream->Write(g_TickRateSettings.iObjectSync); + BitStream.pBitStream->Write(g_TickRateSettings.iKeySyncRotation); + BitStream.pBitStream->Write(g_TickRateSettings.iKeySyncAnalogMove); + + if (pPlayer->CanBitStream(eBitStreamVersion::FixSyncerDistance)) + { + BitStream.pBitStream->Write(g_TickRateSettings.iPedSyncerDistance); + BitStream.pBitStream->Write(g_TickRateSettings.iUnoccupiedVehicleSyncerDistance); + } - if (pPlayer) pPlayer->Send(CLuaPacket(SET_SYNC_INTERVALS, *BitStream.pBitStream)); + }; + + + if (pPlayer) + sendSyncIntervalPatket(pPlayer); else - m_pPlayerManager->BroadcastOnlyJoined(CLuaPacket(SET_SYNC_INTERVALS, *BitStream.pBitStream)); + { + for (auto iter = m_pPlayerManager->IterBegin(); iter != m_pPlayerManager->IterEnd(); ++iter) + sendSyncIntervalPatket(*iter); + } return true; }