From bfdaa16d9926c7537e3ca5a2101a2526aefe4ae0 Mon Sep 17 00:00:00 2001 From: Bob Date: Sun, 17 Dec 2023 00:12:43 +0100 Subject: [PATCH 1/3] Added checks to make sure players are able to fire guns they're firing, and don't send potentially incorrect weapon data --- Server/mods/deathmatch/logic/CGame.cpp | 4 ++++ Server/mods/deathmatch/logic/CPed.cpp | 11 +++++++++++ Server/mods/deathmatch/logic/CPed.h | 1 + .../logic/packets/CPlayerPuresyncPacket.cpp | 6 ++++++ 4 files changed, 22 insertions(+) diff --git a/Server/mods/deathmatch/logic/CGame.cpp b/Server/mods/deathmatch/logic/CGame.cpp index b8468395c0..c2c8485562 100644 --- a/Server/mods/deathmatch/logic/CGame.cpp +++ b/Server/mods/deathmatch/logic/CGame.cpp @@ -2443,6 +2443,10 @@ void CGame::Packet_Bulletsync(CBulletsyncPacket& Packet) CPlayer* pPlayer = Packet.GetSourcePlayer(); if (pPlayer && pPlayer->IsJoined()) { + // Early return when the player attempts to fire a weapon they do not have + if (!pPlayer->HasWeaponType(Packet.m_WeaponType)) + return; + // Relay to other players RelayNearbyPacket(Packet); diff --git a/Server/mods/deathmatch/logic/CPed.cpp b/Server/mods/deathmatch/logic/CPed.cpp index 0b2ba04d0d..e3b7e0128c 100644 --- a/Server/mods/deathmatch/logic/CPed.cpp +++ b/Server/mods/deathmatch/logic/CPed.cpp @@ -356,6 +356,17 @@ void CPed::SetWeaponTotalAmmo(unsigned short usTotalAmmo, unsigned char ucSlot) } } +bool CPed::HasWeaponType(unsigned char ucWeaponType) +{ + for (unsigned char slot = 0; slot < WEAPON_SLOTS; slot++) + { + if (GetWeaponType(slot) == ucWeaponType) + return true; + } + + return false; +} + float CPed::GetMaxHealth() { // TODO: Verify this formula diff --git a/Server/mods/deathmatch/logic/CPed.h b/Server/mods/deathmatch/logic/CPed.h index 00eee811ae..47e70e7189 100644 --- a/Server/mods/deathmatch/logic/CPed.h +++ b/Server/mods/deathmatch/logic/CPed.h @@ -168,6 +168,7 @@ class CPed : public CElement void SetWeaponAmmoInClip(unsigned short uscAmmoInClip, unsigned char ucSlot = 0xFF); unsigned short GetWeaponTotalAmmo(unsigned char ucSlot = 0xFF); void SetWeaponTotalAmmo(unsigned short usTotalAmmo, unsigned char ucSlot = 0xFF); + bool HasWeaponType(unsigned char ucWeaponType); float GetMaxHealth(); float GetHealth() { return m_fHealth; } diff --git a/Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp b/Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp index 3765f22980..54c63e49ff 100644 --- a/Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp +++ b/Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp @@ -175,6 +175,12 @@ bool CPlayerPuresyncPacket::Read(NetBitStreamInterface& BitStream) // Set weapon slot if (bWeaponCorrect) pSourcePlayer->SetWeaponSlot(uiSlot); + else + { + // remove invalid weapon data to prevent this from being relayed to other players + ucClientWeaponType = 0; + slot.data.uiSlot = 0; + } if (CWeaponNames::DoesSlotHaveAmmo(uiSlot)) { From 21b705fd34feb1314cd1f10a94cc3d37bdca2c46 Mon Sep 17 00:00:00 2001 From: Lpsd <40902730+Lpsd@users.noreply.github.com> Date: Sat, 16 Dec 2023 23:44:18 +0000 Subject: [PATCH 2/3] Re-run pipeline From 8cf40e094ffb5e7cb9b5b23622b5755d1e2045fd Mon Sep 17 00:00:00 2001 From: Bob Date: Sun, 17 Dec 2023 01:12:43 +0100 Subject: [PATCH 3/3] Specify artifact upload version to hopefully fix build issue --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 93d108e723..d452cef7fb 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -45,7 +45,7 @@ jobs: - name: Create build artifacts run: utils\premake5 compose_files - - uses: actions/upload-artifact@master + - uses: actions/upload-artifact@v3 with: name: InstallFiles path: InstallFiles/