Skip to content

Commit

Permalink
Verify bitstream for remote players
Browse files Browse the repository at this point in the history
  • Loading branch information
znvjder committed Jan 13, 2024
1 parent d0a0bc1 commit d9fb3b1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Client/mods/deathmatch/logic/rpc/CPlayerRPCs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
4 changes: 3 additions & 1 deletion Server/mods/deathmatch/logic/CRPCFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,16 @@ void CRPCFunctions::PlayerWeapon(NetBitStreamInterface& bitStream)
m_pSourcePlayer->CallEvent("onPlayerWeaponSwitch", Arguments);

SViewerMapType& nearList = m_pSourcePlayer->GetNearPlayerList();

if (!nearList.empty())
{
static std::vector<CPlayer*> playersInNearList;
playersInNearList.reserve(nearList.size());
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())
{
Expand Down
4 changes: 4 additions & 0 deletions Shared/sdk/net/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d9fb3b1

Please sign in to comment.