Enhanced CCSPlayerItem::GetItemInfo

This commit is contained in:
s1lent 2020-02-12 18:34:40 +07:00
parent 3f6d9db420
commit 593d1e1450
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
4 changed files with 23 additions and 1 deletions

View File

@ -32,3 +32,9 @@ EXT_FUNC void CCSPlayerItem::SetItemInfo(ItemInfo *pInfo)
{ {
Q_memcpy(&m_ItemInfo, pInfo, sizeof(m_ItemInfo)); Q_memcpy(&m_ItemInfo, pInfo, sizeof(m_ItemInfo));
} }
EXT_FUNC int CCSPlayerItem::GetItemInfo(ItemInfo *pInfo)
{
Q_memcpy(pInfo, &m_ItemInfo, sizeof(*pInfo));
return 1;
}

View File

@ -4783,7 +4783,12 @@ int EXT_FUNC GetWeaponData(edict_t *pEdict, struct weapon_data_s *info)
// Get The ID // Get The ID
ItemInfo II; ItemInfo II;
Q_memset(&II, 0, sizeof(II)); Q_memset(&II, 0, sizeof(II));
#ifdef REGAMEDLL_API
pPlayerItem->CSPlayerItem()->GetItemInfo(&II);
#else
weapon->GetItemInfo(&II); weapon->GetItemInfo(&II);
#endif
if (II.iId >= 0 && II.iId < MAX_WEAPONS) if (II.iId >= 0 && II.iId < MAX_WEAPONS)
{ {
@ -4916,7 +4921,13 @@ void EXT_FUNC UpdateClientData(const edict_t *ent, int sendweapons, struct clien
Q_memset(&II, 0, sizeof(II)); Q_memset(&II, 0, sizeof(II));
CBasePlayerWeapon *weapon = (CBasePlayerWeapon *)pPlayer->m_pActiveItem->GetWeaponPtr(); CBasePlayerWeapon *weapon = (CBasePlayerWeapon *)pPlayer->m_pActiveItem->GetWeaponPtr();
if (weapon && weapon->UseDecrement() && weapon->GetItemInfo(&II)) if (weapon && weapon->UseDecrement() &&
#ifdef REGAMEDLL_API
weapon->CSPlayerItem()->GetItemInfo(&II)
#else
weapon->GetItemInfo(&II)
#endif
)
{ {
cd->m_iId = II.iId; cd->m_iId = II.iId;

View File

@ -1383,7 +1383,11 @@ void CBasePlayer::PackDeadPlayerItems()
ItemInfo info; ItemInfo info;
if (pPlayerItem->iItemSlot() < KNIFE_SLOT && !bShieldDropped) if (pPlayerItem->iItemSlot() < KNIFE_SLOT && !bShieldDropped)
{ {
#ifdef REGAMEDLL_API
if (pPlayerItem->CSPlayerItem()->GetItemInfo(&info))
#else
if (pPlayerItem->GetItemInfo(&info)) if (pPlayerItem->GetItemInfo(&info))
#endif
{ {
if (info.iWeight > nBestWeight) if (info.iWeight > nBestWeight)
{ {

View File

@ -38,6 +38,7 @@ public:
} }
virtual void SetItemInfo(ItemInfo *pInfo); virtual void SetItemInfo(ItemInfo *pInfo);
virtual int GetItemInfo(ItemInfo *pInfo);
CBasePlayerItem *BasePlayerItem() const; CBasePlayerItem *BasePlayerItem() const;