Skip to content

Commit

Permalink
PrecacheItemInfo hook
Browse files Browse the repository at this point in the history
  • Loading branch information
aleeperezz16 committed Jan 4, 2024
1 parent c8639e7 commit 82f3861
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ GAMEHOOK_REGISTRY(CSGameRules_SendDeathMessage);
GAMEHOOK_REGISTRY(CBasePlayer_PlayerDeathThink);
GAMEHOOK_REGISTRY(CBasePlayer_Observer_Think);

GAMEHOOK_REGISTRY(PrecacheItemInfo);

int CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR;
}
Expand Down
8 changes: 8 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,10 @@ typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBase
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_Observer_Think;
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_Observer_Think;

// PrecacheItemInfo hook
typedef IHookChainImpl<void, ItemInfo *> CReGameHook_PrecacheItemInfo;
typedef IHookChainRegistryImpl<void, ItemInfo *> CReGameHookRegistry_PrecacheItemInfo;

class CReGameHookchains: public IReGameHookchains {
public:
// CBasePlayer virtual
Expand Down Expand Up @@ -906,6 +910,8 @@ class CReGameHookchains: public IReGameHookchains {
CReGameHookRegistry_CBasePlayer_PlayerDeathThink m_CBasePlayer_PlayerDeathThink;
CReGameHookRegistry_CBasePlayer_Observer_Think m_CBasePlayer_Observer_Think;

CReGameHookRegistry_PrecacheItemInfo m_PrecacheItemInfo;

public:
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
virtual IReGameHookRegistry_CBasePlayer_Precache *CBasePlayer_Precache();
Expand Down Expand Up @@ -1064,6 +1070,8 @@ class CReGameHookchains: public IReGameHookchains {

virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink();
virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think();

virtual IReGameHookRegistry_PrecacheItemInfo* PrecacheItemInfo();
};

extern CReGameHookchains g_ReGameHookchains;
Expand Down
6 changes: 6 additions & 0 deletions regamedll/dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname)
return giAmmoIndex;
}

void EXT_FUNC PrecacheItemInfo(ItemInfo *info)
{

}

// Precaches the weapon and queues the weapon info for sending to clients
void UTIL_PrecacheOtherWeapon(const char *szClassname)
{
Expand All @@ -281,6 +286,7 @@ void UTIL_PrecacheOtherWeapon(const char *szClassname)
pItem->Precache();
if (pItem->GetItemInfo(&info))
{
g_ReGameHookchains.m_PrecacheItemInfo.callChain(PrecacheItemInfo, &info);
CBasePlayerItem::m_ItemInfoArray[info.iId] = info;

AddAmmoNameToAmmoRegistry(info.pszAmmo1);
Expand Down
6 changes: 6 additions & 0 deletions regamedll/public/regamedll/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@ typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBa
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Observer_Think;
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_Observer_Think;

// PrecacheItemInfo hook
typedef IHookChain<void, ItemInfo *> IReGameHook_PrecacheItemInfo;
typedef IHookChainRegistry<void, ItemInfo *> IReGameHookRegistry_PrecacheItemInfo;

class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
Expand Down Expand Up @@ -785,6 +789,8 @@ class IReGameHookchains {

virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0;
virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think() = 0;

virtual IReGameHookRegistry_PrecacheItemInfo* PrecacheItemInfo() = 0;
};

struct ReGameFuncs_t {
Expand Down

0 comments on commit 82f3861

Please sign in to comment.