Skip to content

Commit

Permalink
Fix setServerConfigSetting crash (#3886)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNormalnij authored Dec 16, 2024
1 parent da7af8f commit 7b24d02
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 7b24d02

Please sign in to comment.