Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow get WEAPON_C4 & WEAPON_KNIFE info #52

Merged
merged 2 commits into from
Mar 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ cell AMX_NATIVE_CALL rg_get_weapon_info(AMX *amx, cell *params)
WeaponIdType weaponID = static_cast<WeaponIdType>(*getAmxAddr(amx, params[arg_weapon_id]));
WpnInfo info_type = static_cast<WpnInfo>(*getAmxAddr(amx, params[arg_type]));

if (!GetWeaponInfoRange(weaponID) && info_type != WI_ID && weaponID != WEAPON_KNIFE)
if (!GetWeaponInfoRange(weaponID, false) && info_type != WI_ID)
{
MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid weapon id %i", __FUNCTION__, weaponID);
return 0;
Expand Down Expand Up @@ -752,7 +752,7 @@ cell AMX_NATIVE_CALL rg_set_weapon_info(AMX *amx, cell *params)
enum args_e { arg_count, arg_weapon_id, arg_type, arg_value };

WeaponIdType weaponID = static_cast<WeaponIdType>(params[arg_weapon_id]);
if (!GetWeaponInfoRange(weaponID))
if (!GetWeaponInfoRange(weaponID, true))
{
MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid weapon id %i", __FUNCTION__, weaponID);
return 0;
Expand Down
7 changes: 5 additions & 2 deletions reapi/src/reapi_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ inline void EWRITE_ENTITY(int iValue) { (*g_pengfuncsTable->pfnWriteEntity)(iVal
#define _strlwr(p) for (int i = 0; p[i] != 0; i++) p[i] = tolower(p[i]);
#endif

inline bool GetWeaponInfoRange(WeaponIdType wpnid)
inline bool GetWeaponInfoRange(WeaponIdType wpnid, bool set_info)
{
if (wpnid == WEAPON_SHIELDGUN)
return true;

if (set_info && (wpnid == WEAPON_KNIFE || wpnid == WEAPON_C4))
return false;

if (wpnid > WEAPON_NONE && wpnid != WEAPON_C4 && wpnid != WEAPON_KNIFE && wpnid <= WEAPON_P90)
if (WEAPON_NONE < wpnid && wpnid <= WEAPON_P90)
return true;

return false;
Expand Down