2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-29 08:05:36 +03:00

Implement RG_CBasePlayer_Observer_SetMode hook (#208)

* Implement RG_CBasePlayer_Observer_SetMode hook

* fixes

Co-authored-by: Lopol2010 <evgeniy7@gmail.com>
Co-authored-by: Sergey Shorokhov <wopox1337@ya.ru>
This commit is contained in:
Lopol2010 2021-09-02 17:35:58 +03:00 committed by GitHub
parent 6063144a31
commit 2c415638ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 0 deletions

View File

@ -37,6 +37,7 @@
#define RG_CBasePlayerWeapon_DefaultDeploy RG_CBaseWeapon_DefDeploy #define RG_CBasePlayerWeapon_DefaultDeploy RG_CBaseWeapon_DefDeploy
#define RG_CBasePlayerWeapon_DefaultReload RG_CBaseWeapon_DefReload #define RG_CBasePlayerWeapon_DefaultReload RG_CBaseWeapon_DefReload
#define RG_CBasePlayerWeapon_DefaultShotgunReload RG_CBaseWeapon_DefShotgunReload #define RG_CBasePlayerWeapon_DefaultShotgunReload RG_CBaseWeapon_DefShotgunReload
#define RG_CBasePlayer_Observer_SetMode RG_CBasePlayer_Observer_SetMod
#endif #endif
/** /**
@ -784,6 +785,12 @@ enum GamedllFunc_CBasePlayer
* Params: (const this, const reason[]) * Params: (const this, const reason[])
*/ */
RG_CBasePlayer_DropIdlePlayer, RG_CBasePlayer_DropIdlePlayer,
/*
* Description: Called when a client attempt to change the observer mode.
* Params: (const this, iMode)
*/
RG_CBasePlayer_Observer_SetMode,
/* /*
* Description: Called when a client emits a "pain sound" after received damage. * Description: Called when a client emits a "pain sound" after received damage.

View File

@ -501,6 +501,10 @@ typedef IHookChainRegistryClass<void, class CBaseEntity, ULONG, Vector &, Vector
typedef IHookChainClass<Vector &, class CBaseEntity, Vector &, Vector &, float, float, int, int, int, float, entvars_t *, bool, int> IReGameHook_CBaseEntity_FireBullets3; typedef IHookChainClass<Vector &, class CBaseEntity, Vector &, Vector &, float, float, int, int, int, float, entvars_t *, bool, int> IReGameHook_CBaseEntity_FireBullets3;
typedef IHookChainRegistryClass<Vector &, class CBaseEntity, Vector &, Vector &, float, float, int, int, int, float, entvars_t *, bool, int> IReGameHookRegistry_CBaseEntity_FireBullets3; typedef IHookChainRegistryClass<Vector &, class CBaseEntity, Vector &, Vector &, float, float, int, int, int, float, entvars_t *, bool, int> IReGameHookRegistry_CBaseEntity_FireBullets3;
// CBasePlayer::Observer_SetMode hook
typedef IHookChainClass<void, class CBasePlayer, int> IReGameHook_CBasePlayer_Observer_SetMode;
typedef IHookChainRegistryClass<void, class CBasePlayer, int> IReGameHookRegistry_CBasePlayer_Observer_SetMode;
// CBasePlayer::Pain hook // CBasePlayer::Pain hook
typedef IHookChainClass<void, class CBasePlayer, int, bool> IReGameHook_CBasePlayer_Pain; typedef IHookChainClass<void, class CBasePlayer, int, bool> IReGameHook_CBasePlayer_Pain;
typedef IHookChainRegistryClass<void, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Pain; typedef IHookChainRegistryClass<void, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Pain;
@ -639,6 +643,8 @@ public:
virtual IReGameHookRegistry_CBaseEntity_FireBullets *CBaseEntity_FireBullets() = 0; virtual IReGameHookRegistry_CBaseEntity_FireBullets *CBaseEntity_FireBullets() = 0;
virtual IReGameHookRegistry_CBaseEntity_FireBuckshots *CBaseEntity_FireBuckshots() = 0; virtual IReGameHookRegistry_CBaseEntity_FireBuckshots *CBaseEntity_FireBuckshots() = 0;
virtual IReGameHookRegistry_CBaseEntity_FireBullets3 *CBaseEntity_FireBullets3() = 0; virtual IReGameHookRegistry_CBaseEntity_FireBullets3 *CBaseEntity_FireBullets3() = 0;
virtual IReGameHookRegistry_CBasePlayer_Observer_SetMode *CBasePlayer_Observer_SetMode() = 0;
virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain() = 0; virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain() = 0;
virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound() = 0; virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound() = 0;

View File

@ -1237,6 +1237,16 @@ Vector &CBaseEntity_FireBullets3(IReGameHook_CBaseEntity_FireBullets3 *chain, CB
shared_rand); shared_rand);
} }
void CBasePlayer_Observer_SetMode(IReGameHook_CBasePlayer_Observer_SetMode *chain, CBasePlayer *pthis, int iMode)
{
auto original = [chain](int _pthis, int _iMode)
{
chain->callNext(getPrivate<CBasePlayer>(_pthis), _iMode);
};
callVoidForward(RG_CBasePlayer_Observer_SetMode, original, indexOfEdict(pthis->pev), iMode);
}
int g_iClientStartSpeak, g_iClientStopSpeak; int g_iClientStartSpeak, g_iClientStopSpeak;
void OnClientStartSpeak(size_t clientIndex) void OnClientStartSpeak(size_t clientIndex)

View File

@ -428,6 +428,7 @@ void CBasePlayer_RemoveSpawnProtection(IReGameHook_CBasePlayer_RemoveSpawnProtec
bool CBasePlayer_HintMessageEx(IReGameHook_CBasePlayer_HintMessageEx *chain, CBasePlayer *pthis, const char *pMessage, float duration, bool bDisplayIfPlayerDead, bool bOverride); 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 CBasePlayer_UseEmpty(IReGameHook_CBasePlayer_UseEmpty *chain, CBasePlayer *pthis);
void CBasePlayer_DropIdlePlayer(IReGameHook_CBasePlayer_DropIdlePlayer *chain, CBasePlayer *pthis, const char *reason); void CBasePlayer_DropIdlePlayer(IReGameHook_CBasePlayer_DropIdlePlayer *chain, CBasePlayer *pthis, const char *reason);
void CBasePlayer_Observer_SetMode(IReGameHook_CBasePlayer_Observer_SetMode *chain, CBasePlayer *pthis, int iMode);
void CBasePlayer_Pain(IReGameHook_CBasePlayer_Pain *chain, CBasePlayer *pthis, int iLastHitGroup, bool bHasArmour); void CBasePlayer_Pain(IReGameHook_CBasePlayer_Pain *chain, CBasePlayer *pthis, int iLastHitGroup, bool bHasArmour);
void CBasePlayer_DeathSound(IReGameHook_CBasePlayer_DeathSound *chain, CBasePlayer *pthis); void CBasePlayer_DeathSound(IReGameHook_CBasePlayer_DeathSound *chain, CBasePlayer *pthis);
void CBasePlayer_JoiningThink(IReGameHook_CBasePlayer_JoiningThink *chain, CBasePlayer *pthis); void CBasePlayer_JoiningThink(IReGameHook_CBasePlayer_JoiningThink *chain, CBasePlayer *pthis);

View File

@ -167,6 +167,9 @@ hook_t hooklist_player[] = {
DLL(CBasePlayer_HintMessageEx), DLL(CBasePlayer_HintMessageEx),
DLL(CBasePlayer_UseEmpty), DLL(CBasePlayer_UseEmpty),
DLL(CBasePlayer_DropIdlePlayer), DLL(CBasePlayer_DropIdlePlayer),
DLL(CBasePlayer_Observer_SetMode),
DLL(CBasePlayer_Pain), DLL(CBasePlayer_Pain),
DLL(CBasePlayer_DeathSound), DLL(CBasePlayer_DeathSound),
DLL(CBasePlayer_JoiningThink), DLL(CBasePlayer_JoiningThink),

View File

@ -192,6 +192,9 @@ enum GamedllFunc_CBasePlayer
RG_CBasePlayer_HintMessageEx, RG_CBasePlayer_HintMessageEx,
RG_CBasePlayer_UseEmpty, RG_CBasePlayer_UseEmpty,
RG_CBasePlayer_DropIdlePlayer, RG_CBasePlayer_DropIdlePlayer,
RG_CBasePlayer_Observer_SetMode,
RG_CBasePlayer_Pain, RG_CBasePlayer_Pain,
RG_CBasePlayer_DeathSound, RG_CBasePlayer_DeathSound,
RG_CBasePlayer_JoiningThink, RG_CBasePlayer_JoiningThink,