Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement PlayerDeathThink hook #885

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ GAMEHOOK_REGISTRY(CBasePlayerWeapon_KickBack);
GAMEHOOK_REGISTRY(CBasePlayerWeapon_SendWeaponAnim);
GAMEHOOK_REGISTRY(CSGameRules_SendDeathMessage);

GAMEHOOK_REGISTRY(CBasePlayer_PlayerDeathThink);

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 @@ -737,6 +737,10 @@ typedef IHookChainRegistryClassImpl<void, CBasePlayerWeapon, float, float, float
typedef IHookChainClassImpl<void, CBasePlayerWeapon, int, int> CReGameHook_CBasePlayerWeapon_SendWeaponAnim;
typedef IHookChainRegistryClassImpl<void, CBasePlayerWeapon, int, int> CReGameHookRegistry_CBasePlayerWeapon_SendWeaponAnim;

// CBasePlayer::PlayerDeathThink hook
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_PlayerDeathThink;
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_PlayerDeathThink;

class CReGameHookchains: public IReGameHookchains {
public:
// CBasePlayer virtual
Expand Down Expand Up @@ -895,6 +899,8 @@ class CReGameHookchains: public IReGameHookchains {
CReGameHookRegistry_CBasePlayerWeapon_SendWeaponAnim m_CBasePlayerWeapon_SendWeaponAnim;
CReGameHookRegistry_CSGameRules_SendDeathMessage m_CSGameRules_SendDeathMessage;

CReGameHookRegistry_CBasePlayer_PlayerDeathThink m_CBasePlayer_PlayerDeathThink;

public:
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
virtual IReGameHookRegistry_CBasePlayer_Precache *CBasePlayer_Precache();
Expand Down Expand Up @@ -1050,6 +1056,8 @@ class CReGameHookchains: public IReGameHookchains {
virtual IReGameHookRegistry_CBasePlayerWeapon_KickBack *CBasePlayerWeapon_KickBack();
virtual IReGameHookRegistry_CBasePlayerWeapon_SendWeaponAnim *CBasePlayerWeapon_SendWeaponAnim();
virtual IReGameHookRegistry_CSGameRules_SendDeathMessage *CSGameRules_SendDeathMessage();

virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink();
};

extern CReGameHookchains g_ReGameHookchains;
Expand Down
4 changes: 3 additions & 1 deletion regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3784,7 +3784,9 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Disappear)()
pev->angles.z = 0;
}

void CBasePlayer::PlayerDeathThink()
LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, PlayerDeathThink)

void EXT_FUNC CBasePlayer::__API_HOOK(PlayerDeathThink)()
{
if (m_iJoiningState != JOINED)
return;
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ class CBasePlayer: public CBaseMonster {
void JoiningThink_OrigFunc();
void CheckTimeBasedDamage_OrigFunc();
edict_t *EntSelectSpawnPoint_OrigFunc();
void PlayerDeathThink_OrigFunc();

CCSPlayer *CSPlayer() const;
#endif // REGAMEDLL_API
Expand Down
8 changes: 7 additions & 1 deletion regamedll/public/regamedll/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <API/CSInterfaces.h>

#define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 25
#define REGAMEDLL_API_VERSION_MINOR 26

// CBasePlayer::Spawn hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
Expand Down Expand Up @@ -616,6 +616,10 @@ typedef IHookChainRegistryClass<void, CBasePlayerWeapon, float, float, float, fl
typedef IHookChainClass<void, CBasePlayerWeapon, int, int> IReGameHook_CBasePlayerWeapon_SendWeaponAnim;
typedef IHookChainRegistryClass<void, CBasePlayerWeapon, int, int> IReGameHookRegistry_CBasePlayerWeapon_SendWeaponAnim;

// CBasePlayer::PlayerDeathThink hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_PlayerDeathThink;
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_PlayerDeathThink;

class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
Expand Down Expand Up @@ -774,6 +778,8 @@ class IReGameHookchains {
virtual IReGameHookRegistry_CBasePlayerWeapon_KickBack *CBasePlayerWeapon_KickBack() = 0;
virtual IReGameHookRegistry_CBasePlayerWeapon_SendWeaponAnim *CBasePlayerWeapon_SendWeaponAnim() = 0;
virtual IReGameHookRegistry_CSGameRules_SendDeathMessage *CSGameRules_SendDeathMessage() = 0;

virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0;
};

struct ReGameFuncs_t {
Expand Down
2 changes: 1 addition & 1 deletion regamedll/version/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
#pragma once

#define VERSION_MAJOR 5
#define VERSION_MINOR 25
#define VERSION_MINOR 26
#define VERSION_MAINTENANCE 0