From 51bba0b8942faef8366b426057f64d10c798a62b Mon Sep 17 00:00:00 2001 From: Rain Date: Tue, 27 Dec 2022 21:31:02 +0200 Subject: [PATCH] Fix incorrect behaviour in SDKHooks_DropWeapon's "bypassHooks" parameter (#1877) --- extensions/sdkhooks/natives.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/extensions/sdkhooks/natives.cpp b/extensions/sdkhooks/natives.cpp index 25aa5c6a..e801747b 100644 --- a/extensions/sdkhooks/natives.cpp +++ b/extensions/sdkhooks/natives.cpp @@ -244,9 +244,12 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params) if (params[1] != hndl.GetEntryIndex()) return pContext->ThrowNativeError("Weapon %d is not owned by client %d", params[2], params[1]); - Vector vecTarget; cell_t *addr; int err; + + Vector vecTarget; + Vector *pVecTarget = nullptr; + if ((err = pContext->LocalToPhysAddr(params[3], &addr)) != SP_ERROR_NONE) { return pContext->ThrowNativeError("Could not read vecTarget vector"); @@ -258,15 +261,12 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params) sp_ctof(addr[0]), sp_ctof(addr[1]), sp_ctof(addr[2])); - } - else - { - SH_MCALL(pPlayer, Weapon_Drop)((CBaseCombatWeapon *)pWeapon, NULL, NULL); - return 0; + pVecTarget = &vecTarget; } Vector vecVelocity; Vector *pVecVelocity = nullptr; + if ((err = pContext->LocalToPhysAddr(params[4], &addr)) != SP_ERROR_NONE) { return pContext->ThrowNativeError("Could not read vecVelocity vector"); @@ -283,7 +283,7 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params) if (params[0] < 5 || params[5] != 0) { - SH_MCALL(pPlayer, Weapon_Drop)((CBaseCombatWeapon*)pWeapon, &vecTarget, pVecVelocity); + SH_MCALL(pPlayer, Weapon_Drop)((CBaseCombatWeapon*)pWeapon, pVecTarget, pVecVelocity); } else { @@ -310,7 +310,7 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params) pCall = g_pBinTools->CreateVCall(offset, 0, 0, nullptr, pass, 3); } - pCall->Execute(ArgBuffer(pPlayer, pWeapon, &vecTarget, pVecVelocity), nullptr); + pCall->Execute(ArgBuffer(pPlayer, pWeapon, pVecTarget, pVecVelocity), nullptr); } return 0;