Fix incorrect behaviour in SDKHooks_DropWeapon's "bypassHooks" parameter (#1877)

This commit is contained in:
Rain 2022-12-27 21:31:02 +02:00 committed by GitHub
parent 775d4f04f2
commit 51bba0b894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<CBaseEntity *, CBaseEntity *, Vector *, Vector *>(pPlayer, pWeapon, &vecTarget, pVecVelocity), nullptr);
pCall->Execute(ArgBuffer<CBaseEntity *, CBaseEntity *, Vector *, Vector *>(pPlayer, pWeapon, pVecTarget, pVecVelocity), nullptr);
}
return 0;