2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-01-14 15:48:03 +03:00

Implement RG_CBasePlayer_UseEmpty hook (#140)

* Implement RG_CBasePlayer_UseEmpty
This commit is contained in:
fant1kua 2019-08-29 21:49:53 +03:00 committed by Dmitry Novikov
parent 1b89757c7f
commit 8bef6ebff4
8 changed files with 28 additions and 3 deletions

View File

@ -1,3 +1,3 @@
majorVersion=5
minorVersion=9
minorVersion=10
maintenanceVersion=0

View File

@ -754,6 +754,13 @@ enum GamedllFunc_CBasePlayer
* Params: (const this, const message[], Float:duration, bool:bDisplayIfPlayerDead, bool:bOverride)
*/
RG_CBasePlayer_HintMessageEx,
/*
* Description: Called when a player press use and if a suitable candidate is not found.
* Return type: void
* Params: (const this)
*/
RG_CBasePlayer_UseEmpty,
};
/**

View File

@ -80,7 +80,7 @@ public:
virtual void ResetSequenceInfo();
virtual void StartDeathCam();
virtual bool RemovePlayerItemEx(const char* pszItemName, bool bRemoveAmmo);
virtual void SetSpawnProtection(float flProtectionTime);
virtual void SetSpawnProtection(float flProtectionTime);
virtual void RemoveSpawnProtection();
virtual bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false);

View File

@ -38,7 +38,7 @@
#include <API/CSInterfaces.h>
#define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 9
#define REGAMEDLL_API_VERSION_MINOR 10
// CBasePlayer::Spawn hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
@ -440,6 +440,10 @@ typedef IHookChainRegistry<bool, Vector &, Vector &, entvars_t *, edict_t *> IRe
typedef IHookChainClass<bool, class CBasePlayer, const char *, float, bool, bool> IReGameHook_CBasePlayer_HintMessageEx;
typedef IHookChainRegistryClass<bool, class CBasePlayer, const char *, float, bool, bool> IReGameHookRegistry_CBasePlayer_HintMessageEx;
// CBasePlayer::UseEmpty hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_UseEmpty;
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_UseEmpty;
class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
@ -549,6 +553,7 @@ public:
virtual IReGameHookRegistry_CBasePlayer_SetSpawnProtection *CBasePlayer_SetSpawnProtection() = 0;
virtual IReGameHookRegistry_IsPenetrableEntity *IsPenetrableEntity() = 0;
virtual IReGameHookRegistry_CBasePlayer_HintMessageEx *CBasePlayer_HintMessageEx() = 0;
virtual IReGameHookRegistry_CBasePlayer_UseEmpty *CBasePlayer_UseEmpty() = 0;
};
struct ReGameFuncs_t {

View File

@ -542,6 +542,16 @@ bool CBasePlayer_HintMessageEx(IReGameHook_CBasePlayer_HintMessageEx *chain, CBa
return callForward<bool>(RG_CBasePlayer_HintMessageEx, original, indexOfEdict(pthis->pev), pMessage, duration, bDisplayIfPlayerDead, bOverride);
}
void CBasePlayer_UseEmpty(IReGameHook_CBasePlayer_UseEmpty *chain, CBasePlayer *pthis)
{
auto original = [chain](int _pthis)
{
return chain->callNext(getPrivate<CBasePlayer>(_pthis));
};
callVoidForward(RG_CBasePlayer_UseEmpty, original, indexOfEdict(pthis->pev));
}
void CBaseAnimating_ResetSequenceInfo(IReGameHook_CBaseAnimating_ResetSequenceInfo *chain, CBaseAnimating *pthis)
{
auto original = [chain](int _pthis)

View File

@ -376,6 +376,7 @@ CGrenade *CBasePlayer_ThrowGrenade(IReGameHook_CBasePlayer_ThrowGrenade *chain,
void CBasePlayer_SetSpawnProtection(IReGameHook_CBasePlayer_SetSpawnProtection *chain, CBasePlayer *pthis, float flProtectionTime);
void CBasePlayer_RemoveSpawnProtection(IReGameHook_CBasePlayer_RemoveSpawnProtection *chain, CBasePlayer *pthis);
bool CBasePlayer_HintMessageEx(IReGameHook_CBasePlayer_HintMessageEx *chain, CBasePlayer *pthis, const char *pMessage, float duration, bool bDisplayIfPlayerDead, bool bOverride);
void CBasePlayer_UseEmpty(IReGameHook_CBasePlayer_UseEmpty *chain, CBasePlayer *pthis);
void CBaseAnimating_ResetSequenceInfo(IReGameHook_CBaseAnimating_ResetSequenceInfo *chain, CBaseAnimating *pthis);

View File

@ -154,6 +154,7 @@ hook_t hooklist_player[] = {
DLL(CBasePlayer_SetSpawnProtection),
DLL(CBasePlayer_RemoveSpawnProtection),
DLL(CBasePlayer_HintMessageEx),
DLL(CBasePlayer_UseEmpty),
};
hook_t hooklist_gamerules[] = {

View File

@ -176,6 +176,7 @@ enum GamedllFunc_CBasePlayer
RG_CBasePlayer_SetSpawnProtection,
RG_CBasePlayer_RemoveSpawnProtection,
RG_CBasePlayer_HintMessageEx,
RG_CBasePlayer_UseEmpty,
// [...]
};