mirror of
https://github.com/rehlds/reapi.git
synced 2025-01-16 00:28:17 +03:00
Fix crash rg_find_item_bpack_by_name
This commit is contained in:
parent
272b2fc709
commit
6cf5c99ded
@ -297,7 +297,7 @@ native rg_find_ent_by_owner(&start_index, const classname[], owner);
|
||||
* @return Entity-index of item, 0 otherwise
|
||||
*
|
||||
*/
|
||||
native rg_find_bpack_item_by_name(const index, const item[]);
|
||||
native rg_find_item_bpack_by_name(const index, const item[]);
|
||||
|
||||
/*
|
||||
* Returns some information about a weapon.
|
||||
|
@ -88,6 +88,14 @@ enum WpnInfo
|
||||
*/
|
||||
WI_AMMO_TYPE,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Return type: -
|
||||
* Get params: rg_get_weapon_info(const weapon_id, WI_AMMO_NAME, const output[], maxlenght);
|
||||
* Set params: -
|
||||
*/
|
||||
WI_AMMO_NAME,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Return type: -
|
||||
|
@ -547,7 +547,7 @@ cell AMX_NATIVE_CALL rg_find_ent_by_owner(AMX *amx, cell *params)
|
||||
*
|
||||
* @return Entity-index of item, 0 otherwise
|
||||
*
|
||||
* native rg_find_bpack_item_by_name(const index, const item[]);
|
||||
* native rg_find_item_bpack_by_name(const index, const item[]);
|
||||
*/
|
||||
cell AMX_NATIVE_CALL rg_find_item_bpack_by_name(AMX *amx, cell *params)
|
||||
{
|
||||
@ -563,8 +563,11 @@ cell AMX_NATIVE_CALL rg_find_item_bpack_by_name(AMX *amx, cell *params)
|
||||
|
||||
const char *itemName = getAmxString(amx, params[arg_item]);
|
||||
auto pInfo = g_ReGameApi->GetWeaponSlot(itemName);
|
||||
auto pItem = pPlayer->m_rgpPlayerItems[ pInfo->slot ];
|
||||
if (pInfo == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto pItem = pPlayer->m_rgpPlayerItems[ pInfo->slot ];
|
||||
while (pItem) {
|
||||
if (FClassnameIs(pItem->pev, itemName)) {
|
||||
return indexOfEdict(pItem->pev);
|
||||
@ -626,6 +629,25 @@ cell AMX_NATIVE_CALL rg_get_weapon_info(AMX *amx, cell *params)
|
||||
return info->maxRounds;
|
||||
case WI_AMMO_TYPE:
|
||||
return info->ammoType;
|
||||
case WI_AMMO_NAME:
|
||||
{
|
||||
if (PARAMS_COUNT != arg_4) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: bad parameter count, got %i, expected %i", __FUNCTION__, PARAMS_COUNT, arg_4);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// native rg_get_weapon_info(id, WI_AMMO_NAME, output[], maxlength);
|
||||
cell* dest = getAmxAddr(amx, params[arg_3]);
|
||||
size_t length = *getAmxAddr(amx, params[arg_4]);
|
||||
|
||||
if (info->ammoName == nullptr) {
|
||||
setAmxString(dest, "", 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
setAmxString(dest, info->ammoName, length);
|
||||
return 1;
|
||||
}
|
||||
case WI_NAME:
|
||||
{
|
||||
if (PARAMS_COUNT != arg_4) {
|
||||
@ -688,8 +710,9 @@ cell AMX_NATIVE_CALL rg_set_weapon_info(AMX *amx, cell *params)
|
||||
case WI_GUN_CLIP_SIZE:
|
||||
case WI_MAX_ROUNDS:
|
||||
case WI_AMMO_TYPE:
|
||||
case WI_AMMO_NAME:
|
||||
case WI_NAME:
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: this change will have no effect", __FUNCTION__);
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: this change will have no effect, type statement %i", __FUNCTION__, info_type);
|
||||
return 0;
|
||||
default:
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown type statement %i, params count %i", __FUNCTION__, info_type, PARAMS_COUNT);
|
||||
|
@ -9,7 +9,8 @@ enum WpnInfo
|
||||
WI_GUN_CLIP_SIZE,
|
||||
WI_MAX_ROUNDS,
|
||||
WI_AMMO_TYPE,
|
||||
WI_NAME
|
||||
WI_AMMO_NAME,
|
||||
WI_NAME,
|
||||
};
|
||||
|
||||
void RegisterNatives_Misc();
|
||||
|
Loading…
x
Reference in New Issue
Block a user