Skip to content

Commit

Permalink
Refactoring API functions
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Dec 12, 2023
1 parent 1f2f913 commit b998d98
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
21 changes: 19 additions & 2 deletions regamedll/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class CBasePlayer: public CBaseMonster {
edict_t *EntSelectSpawnPoint_OrigFunc();
void PlayerDeathThink_OrigFunc();
void Observer_Think_OrigFunc();

CCSPlayer *CSPlayer() const;
#endif // REGAMEDLL_API

Expand Down Expand Up @@ -955,7 +955,24 @@ inline bool CBasePlayer::HasTimePassedSinceDeath(float duration) const
inline CCSPlayer *CBasePlayer::CSPlayer() const {
return reinterpret_cast<CCSPlayer *>(this->m_pEntity);
}
#endif
#else // !REGAMEDLL_API

// Determine whether player can be gibbed or not
inline bool CBasePlayer::ShouldGibPlayer(int iGib)
{
// Always gib the player regardless of incoming damage
if (iGib == GIB_ALWAYS)
return true;

// Gib the player if health is below the gib damage threshold
if (pev->health < GIB_PLAYER_THRESHOLD && iGib != GIB_NEVER)
return true;

// do not gib the player
return false;
}

#endif // !REGAMEDLL_API

#ifdef REGAMEDLL_FIXES

Expand Down
19 changes: 13 additions & 6 deletions regamedll/public/regamedll/API/CSPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,19 @@ inline void CCSPlayer::SetPlayerDominated(CBasePlayer *pPlayer, bool bDominated)
m_bPlayerDominated[iPlayerIndex - 1] = bDominated;
}

#ifdef REGAMEDLL_API
// Determine whether player can be gibbed or not
inline bool CBasePlayer::ShouldGibPlayer(int iGib)
{
#ifdef REGAMEDLL_API
int threshold = CSPlayer()->m_iGibDamageThreshold;
#else
int threshold = GIB_PLAYER_THRESHOLD;
#endif
return ((pev->health < threshold && iGib != GIB_NEVER) || iGib == GIB_ALWAYS);
// Always gib the player regardless of incoming damage
if (iGib == GIB_ALWAYS)
return true;

// Gib the player if health is below the gib damage threshold
if (pev->health < CSPlayer()->m_iGibDamageThreshold && iGib != GIB_NEVER)
return true;

// do not gib the player
return false;
}
#endif

0 comments on commit b998d98

Please sign in to comment.