diff --git a/Server/mods/deathmatch/logic/CMainConfig.cpp b/Server/mods/deathmatch/logic/CMainConfig.cpp index 418af9aee3..f524dc4abc 100644 --- a/Server/mods/deathmatch/logic/CMainConfig.cpp +++ b/Server/mods/deathmatch/logic/CMainConfig.cpp @@ -1455,6 +1455,7 @@ const std::vector& CMainConfig::GetIntSettingList() {true, true, 10, 50, 1000, "update_cycle_messages_limit", &m_iUpdateCycleMessagesLimit, &CMainConfig::ApplyNetOptions}, {true, true, 50, 100, 400, "ped_syncer_distance", &g_TickRateSettings.iPedSyncerDistance, &CMainConfig::OnTickRateChange}, {true, true, 50, 130, 400, "unoccupied_vehicle_syncer_distance", &g_TickRateSettings.iUnoccupiedVehicleSyncerDistance, &CMainConfig::OnTickRateChange}, + {true, true, 0, 30, 130, "vehicle_contact_sync_radius", &g_TickRateSettings.iVehicleContactSyncRadius, &CMainConfig::OnTickRateChange}, {false, false, 0, 1, 2, "compact_internal_databases", &m_iCompactInternalDatabases, NULL}, {true, true, 0, 1, 2, "minclientversion_auto_update", &m_iMinClientVersionAutoUpdate, NULL}, {true, true, 0, 0, 100, "server_logic_fps_limit", &m_iServerLogicFpsLimit, NULL}, diff --git a/Server/mods/deathmatch/logic/CUnoccupiedVehicleSync.cpp b/Server/mods/deathmatch/logic/CUnoccupiedVehicleSync.cpp index 1bbcb69569..4159cd11b0 100644 --- a/Server/mods/deathmatch/logic/CUnoccupiedVehicleSync.cpp +++ b/Server/mods/deathmatch/logic/CUnoccupiedVehicleSync.cpp @@ -487,7 +487,9 @@ void CUnoccupiedVehicleSync::Packet_UnoccupiedVehiclePushSync(CUnoccupiedVehicle CVehicle* pVehicle = static_cast(pVehicleElement); // Is the player syncing this vehicle and there is no driver? Also only process // this packet if the time context matches. - if (pVehicle->GetSyncer() != pPlayer && pVehicle->GetTimeSinceLastPush() >= MIN_PUSH_ANTISPAM_RATE) + if (pVehicle->GetSyncer() != pPlayer && pVehicle->GetTimeSinceLastPush() >= MIN_PUSH_ANTISPAM_RATE && + IsPointNearPoint3D(pVehicle->GetPosition(), pPlayer->GetPosition(), g_TickRateSettings.iVehicleContactSyncRadius) + && pVehicle->GetDimension() == pPlayer->GetDimension()) { // Is there no player driver? CPed* pOccupant = pVehicle->GetOccupant(0); diff --git a/Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp b/Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp index 54c63e49ff..a68f7b31a1 100644 --- a/Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp +++ b/Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp @@ -14,6 +14,7 @@ #include "CElementIDs.h" #include "CWeaponNames.h" #include "Utils.h" +#include "CTickRateSettings.h" #include extern CGame* g_pGame; @@ -70,6 +71,21 @@ bool CPlayerPuresyncPacket::Read(NetBitStreamInterface& BitStream) return false; pContactElement = CElementIDs::GetElement(Temp); } + + // Player position + SPositionSync position(false); + if (!BitStream.Read(&position)) + return false; + + if (pContactElement != nullptr && + (!IsPointNearPoint3D(pSourcePlayer->GetPosition(), pContactElement->GetPosition(), g_TickRateSettings.iVehicleContactSyncRadius) || + pSourcePlayer->GetDimension() != pContactElement->GetDimension())) + { + pContactElement = nullptr; + // Use current player position. They are not reporting their absolute position so we have to disregard it. + position.data.vecPosition = pSourcePlayer->GetPosition(); + } + CElement* pPreviousContactElement = pSourcePlayer->GetContactElement(); pSourcePlayer->SetContactElement(pContactElement); @@ -89,11 +105,6 @@ bool CPlayerPuresyncPacket::Read(NetBitStreamInterface& BitStream) pSourcePlayer->CallEvent("onPlayerContact", Arguments); } - // Player position - SPositionSync position(false); - if (!BitStream.Read(&position)) - return false; - if (pContactElement) { pSourcePlayer->SetContactPosition(position.data.vecPosition); @@ -102,6 +113,7 @@ bool CPlayerPuresyncPacket::Read(NetBitStreamInterface& BitStream) CVector vecTempPos = pContactElement->GetPosition(); position.data.vecPosition += vecTempPos; } + pSourcePlayer->SetPosition(position.data.vecPosition); // Player rotation diff --git a/Server/mods/deathmatch/mtaserver.conf b/Server/mods/deathmatch/mtaserver.conf index 36532e0a1b..19fe4a05d8 100644 --- a/Server/mods/deathmatch/mtaserver.conf +++ b/Server/mods/deathmatch/mtaserver.conf @@ -135,6 +135,10 @@ Values: 0 - disabled , 1 - enabled ; default value: 1. --> 1 + + 30 + 1 + + 30 +