From 593d1e14506fbbbe5b6d679d956a482e918e1aaf Mon Sep 17 00:00:00 2001 From: s1lent Date: Wed, 12 Feb 2020 18:34:40 +0700 Subject: [PATCH] Enhanced CCSPlayerItem::GetItemInfo --- regamedll/dlls/API/CSPlayerItem.cpp | 6 ++++++ regamedll/dlls/client.cpp | 13 ++++++++++++- regamedll/dlls/player.cpp | 4 ++++ regamedll/public/regamedll/API/CSPlayerItem.h | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/API/CSPlayerItem.cpp b/regamedll/dlls/API/CSPlayerItem.cpp index 2cd0ec35..68523ef6 100644 --- a/regamedll/dlls/API/CSPlayerItem.cpp +++ b/regamedll/dlls/API/CSPlayerItem.cpp @@ -32,3 +32,9 @@ EXT_FUNC void CCSPlayerItem::SetItemInfo(ItemInfo *pInfo) { Q_memcpy(&m_ItemInfo, pInfo, sizeof(m_ItemInfo)); } + +EXT_FUNC int CCSPlayerItem::GetItemInfo(ItemInfo *pInfo) +{ + Q_memcpy(pInfo, &m_ItemInfo, sizeof(*pInfo)); + return 1; +} diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index f20e1885..c9b803eb 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -4783,7 +4783,12 @@ int EXT_FUNC GetWeaponData(edict_t *pEdict, struct weapon_data_s *info) // Get The ID ItemInfo II; Q_memset(&II, 0, sizeof(II)); + +#ifdef REGAMEDLL_API + pPlayerItem->CSPlayerItem()->GetItemInfo(&II); +#else weapon->GetItemInfo(&II); +#endif 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)); 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; diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index a78afef7..94d56575 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -1383,7 +1383,11 @@ void CBasePlayer::PackDeadPlayerItems() ItemInfo info; if (pPlayerItem->iItemSlot() < KNIFE_SLOT && !bShieldDropped) { +#ifdef REGAMEDLL_API + if (pPlayerItem->CSPlayerItem()->GetItemInfo(&info)) +#else if (pPlayerItem->GetItemInfo(&info)) +#endif { if (info.iWeight > nBestWeight) { diff --git a/regamedll/public/regamedll/API/CSPlayerItem.h b/regamedll/public/regamedll/API/CSPlayerItem.h index 8c47d6e5..50b56a5c 100644 --- a/regamedll/public/regamedll/API/CSPlayerItem.h +++ b/regamedll/public/regamedll/API/CSPlayerItem.h @@ -38,6 +38,7 @@ public: } virtual void SetItemInfo(ItemInfo *pInfo); + virtual int GetItemInfo(ItemInfo *pInfo); CBasePlayerItem *BasePlayerItem() const;