Fix incorrect behaviour in SDKHooks_DropWeapon's "bypassHooks" parameter (#1877)
This commit is contained in:
parent
775d4f04f2
commit
51bba0b894
@ -244,9 +244,12 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
|||||||
if (params[1] != hndl.GetEntryIndex())
|
if (params[1] != hndl.GetEntryIndex())
|
||||||
return pContext->ThrowNativeError("Weapon %d is not owned by client %d", params[2], params[1]);
|
return pContext->ThrowNativeError("Weapon %d is not owned by client %d", params[2], params[1]);
|
||||||
|
|
||||||
Vector vecTarget;
|
|
||||||
cell_t *addr;
|
cell_t *addr;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
Vector vecTarget;
|
||||||
|
Vector *pVecTarget = nullptr;
|
||||||
|
|
||||||
if ((err = pContext->LocalToPhysAddr(params[3], &addr)) != SP_ERROR_NONE)
|
if ((err = pContext->LocalToPhysAddr(params[3], &addr)) != SP_ERROR_NONE)
|
||||||
{
|
{
|
||||||
return pContext->ThrowNativeError("Could not read vecTarget vector");
|
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[0]),
|
||||||
sp_ctof(addr[1]),
|
sp_ctof(addr[1]),
|
||||||
sp_ctof(addr[2]));
|
sp_ctof(addr[2]));
|
||||||
}
|
pVecTarget = &vecTarget;
|
||||||
else
|
|
||||||
{
|
|
||||||
SH_MCALL(pPlayer, Weapon_Drop)((CBaseCombatWeapon *)pWeapon, NULL, NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector vecVelocity;
|
Vector vecVelocity;
|
||||||
Vector *pVecVelocity = nullptr;
|
Vector *pVecVelocity = nullptr;
|
||||||
|
|
||||||
if ((err = pContext->LocalToPhysAddr(params[4], &addr)) != SP_ERROR_NONE)
|
if ((err = pContext->LocalToPhysAddr(params[4], &addr)) != SP_ERROR_NONE)
|
||||||
{
|
{
|
||||||
return pContext->ThrowNativeError("Could not read vecVelocity vector");
|
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)
|
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
|
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 = 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;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user