Skip to content

Commit

Permalink
WeaponsPrecache hook
Browse files Browse the repository at this point in the history
  • Loading branch information
aleeperezz16 committed Jan 3, 2024
1 parent 0141284 commit 8c70f4f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions regamedll/dlls/API/CAPI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ GAMEHOOK_REGISTRY(ClearMultiDamage);
GAMEHOOK_REGISTRY(AddMultiDamage);
GAMEHOOK_REGISTRY(ApplyMultiDamage);
GAMEHOOK_REGISTRY(BuyItem);
GAMEHOOK_REGISTRY(WeaponsPrecache);
GAMEHOOK_REGISTRY(CSGameRules_Think);
GAMEHOOK_REGISTRY(CSGameRules_TeamFull);
GAMEHOOK_REGISTRY(CSGameRules_TeamStacked);
Expand Down
6 changes: 6 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,10 @@ typedef IHookChainRegistryImpl<void, entvars_t *, entvars_t *> CReGameHookRegist
typedef IHookChainImpl<void, CBasePlayer *, int> CReGameHook_BuyItem;
typedef IHookChainRegistryImpl<void, CBasePlayer *, int> CReGameHookRegistry_BuyItem;

// WeaponsPrecache hook
typedef IHookChainImpl<void> CReGameHook_WeaponsPrecache;
typedef IHookChainRegistryImpl<void> CReGameHookRegistry_WeaponsPrecache;

// CHalfLifeMultiplay::Think hook
typedef IHookChainClassImpl<void, class CHalfLifeMultiplay> CReGameHook_CSGameRules_Think;
typedef IHookChainRegistryClassEmptyImpl<void, class CHalfLifeMultiplay> CReGameHookRegistry_CSGameRules_Think;
Expand Down Expand Up @@ -891,6 +895,7 @@ class CReGameHookchains: public IReGameHookchains {
CReGameHookRegistry_AddMultiDamage m_AddMultiDamage;
CReGameHookRegistry_ApplyMultiDamage m_ApplyMultiDamage;
CReGameHookRegistry_BuyItem m_BuyItem;
CReGameHookRegistry_WeaponsPrecache m_WeaponsPrecache;
CReGameHookRegistry_CSGameRules_Think m_CSGameRules_Think;
CReGameHookRegistry_CSGameRules_TeamFull m_CSGameRules_TeamFull;
CReGameHookRegistry_CSGameRules_TeamStacked m_CSGameRules_TeamStacked;
Expand Down Expand Up @@ -1050,6 +1055,7 @@ class CReGameHookchains: public IReGameHookchains {
virtual IReGameHookRegistry_AddMultiDamage *AddMultiDamage();
virtual IReGameHookRegistry_ApplyMultiDamage *ApplyMultiDamage();
virtual IReGameHookRegistry_BuyItem *BuyItem();
virtual IReGameHookRegistry_WeaponsPrecache* WeaponsPrecache();
virtual IReGameHookRegistry_CSGameRules_Think *CSGameRules_Think();
virtual IReGameHookRegistry_CSGameRules_TeamFull *CSGameRules_TeamFull();
virtual IReGameHookRegistry_CSGameRules_TeamStacked *CSGameRules_TeamStacked();
Expand Down
3 changes: 2 additions & 1 deletion regamedll/dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,10 @@ void UTIL_PrecacheOtherWeapon(const char *szClassname)
// Called by worldspawn
void WeaponsPrecache()
{
#ifndef REGAMEDLL_ADD
Q_memset(CBasePlayerItem::m_ItemInfoArray, 0, sizeof(CBasePlayerItem::m_ItemInfoArray));
Q_memset(CBasePlayerItem::m_AmmoInfoArray, 0, sizeof(CBasePlayerItem::m_AmmoInfoArray));

#endif
giAmmoIndex = 0;

// custom items...
Expand Down
7 changes: 7 additions & 0 deletions regamedll/dlls/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,14 @@ void CWorld::Precache()
// player precaches
// get weapon precaches

#ifdef REGAMEDLL_ADD
Q_memset(CBasePlayerItem::m_ItemInfoArray, 0, sizeof(CBasePlayerItem::m_ItemInfoArray));
Q_memset(CBasePlayerItem::m_AmmoInfoArray, 0, sizeof(CBasePlayerItem::m_AmmoInfoArray));

g_ReGameHookchains.m_WeaponsPrecache.callChain(WeaponsPrecache);
#else
WeaponsPrecache();
#endif
ClientPrecache();
BotPrecache();

Expand Down
5 changes: 5 additions & 0 deletions regamedll/public/regamedll/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ typedef IHookChainRegistry<void, entvars_t *, entvars_t *> IReGameHookRegistry_A
typedef IHookChain<void, CBasePlayer *, int> IReGameHook_BuyItem;
typedef IHookChainRegistry<void, CBasePlayer *, int> IReGameHookRegistry_BuyItem;

// WeaponsPrecache hook
typedef IHookChain<void> IReGameHook_WeaponsPrecache;
typedef IHookChainRegistry<void> IReGameHookRegistry_WeaponsPrecache;

// CHalfLifeMultiplay::Think hook
typedef IHookChain<void> IReGameHook_CSGameRules_Think;
typedef IHookChainRegistry<void> IReGameHookRegistry_CSGameRules_Think;
Expand Down Expand Up @@ -771,6 +775,7 @@ class IReGameHookchains {
virtual IReGameHookRegistry_AddMultiDamage *AddMultiDamage() = 0;
virtual IReGameHookRegistry_ApplyMultiDamage *ApplyMultiDamage() = 0;
virtual IReGameHookRegistry_BuyItem *BuyItem() = 0;
virtual IReGameHookRegistry_WeaponsPrecache* WeaponsPrecache() = 0;
virtual IReGameHookRegistry_CSGameRules_Think *CSGameRules_Think() = 0;
virtual IReGameHookRegistry_CSGameRules_TeamFull *CSGameRules_TeamFull() = 0;
virtual IReGameHookRegistry_CSGameRules_TeamStacked *CSGameRules_TeamStacked() = 0;
Expand Down

0 comments on commit 8c70f4f

Please sign in to comment.