From d9fb3b1c7d46cae6849e29c3f4acadb8cf756794 Mon Sep 17 00:00:00 2001 From: znajder Date: Sat, 13 Jan 2024 11:13:55 +0100 Subject: [PATCH] Verify bitstream for remote players --- Client/mods/deathmatch/logic/rpc/CPlayerRPCs.cpp | 3 +++ Server/mods/deathmatch/logic/CRPCFunctions.cpp | 4 +++- Shared/sdk/net/bitstream.h | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/rpc/CPlayerRPCs.cpp b/Client/mods/deathmatch/logic/rpc/CPlayerRPCs.cpp index b438b02bf0..5ed38cfbad 100644 --- a/Client/mods/deathmatch/logic/rpc/CPlayerRPCs.cpp +++ b/Client/mods/deathmatch/logic/rpc/CPlayerRPCs.cpp @@ -172,6 +172,9 @@ void CPlayerRPCs::TakePlayerScreenShot(NetBitStreamInterface& bitStream) void CPlayerRPCs::RemotePlayerSwitchWeapon(CClientEntity* pSource, NetBitStreamInterface& bitStream) { + if (!bitStream.Can(eBitStreamVersion::OnPlayerWeaponSwitch_Remote)) + return; + uint lastSlot, currentSlot; if (bitStream.Read(lastSlot) && bitStream.Read(currentSlot)) { diff --git a/Server/mods/deathmatch/logic/CRPCFunctions.cpp b/Server/mods/deathmatch/logic/CRPCFunctions.cpp index 7eb1636602..f64e66ed5a 100644 --- a/Server/mods/deathmatch/logic/CRPCFunctions.cpp +++ b/Server/mods/deathmatch/logic/CRPCFunctions.cpp @@ -181,6 +181,7 @@ void CRPCFunctions::PlayerWeapon(NetBitStreamInterface& bitStream) m_pSourcePlayer->CallEvent("onPlayerWeaponSwitch", Arguments); SViewerMapType& nearList = m_pSourcePlayer->GetNearPlayerList(); + if (!nearList.empty()) { static std::vector playersInNearList; @@ -188,7 +189,8 @@ void CRPCFunctions::PlayerWeapon(NetBitStreamInterface& bitStream) playersInNearList.clear(); for (const auto& player : nearList) - playersInNearList.push_back(player.first); + if (player.first->CanBitStream(eBitStreamVersion::OnPlayerWeaponSwitch_Remote)) + playersInNearList.push_back(player.first); if (!playersInNearList.empty()) { diff --git a/Shared/sdk/net/bitstream.h b/Shared/sdk/net/bitstream.h index 3924ebbf16..faa8b6d9d9 100644 --- a/Shared/sdk/net/bitstream.h +++ b/Shared/sdk/net/bitstream.h @@ -540,6 +540,10 @@ enum class eBitStreamVersion : unsigned short // 2023-10-12 CPlayerJoinCompletePacket_ServerName, + // Send weapon switch for other players + // 2023-01-13 + OnPlayerWeaponSwitch_Remote, + // This allows us to automatically increment the BitStreamVersion when things are added to this enum. // Make sure you only add things above this comment. Next,