Skip to content

Commit

Permalink
Server: Call PM_SetBHopCapEnabled from CGameRules
Browse files Browse the repository at this point in the history
  • Loading branch information
tmp64 committed Oct 6, 2024
1 parent d92707c commit 3935cef
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/game/server/gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ extern int gmsgMOTD;
int g_teamplay = 0;
extern cvar_t sv_busters;

//=========================================================
//=========================================================
void CGameRules::Think(void)
{
PM_SetBHopCapEnabled(!bunnyhop.value);
}

//=========================================================
//=========================================================
BOOL CGameRules::CanHaveAmmo(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry)
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CGameRules
{
public:
virtual void RefreshSkillData(void); // fill skill data struct with proper values
virtual void Think(void) = 0; // GR_Think - runs every server frame, should handle any timer tasks, periodic events, etc.
virtual void Think(void); // GR_Think - runs every server frame, should handle any timer tasks, periodic events, etc.
virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity) = 0; // Can this item spawn (eg monsters don't spawn in deathmatch).

virtual BOOL FAllowFlashlight(void) = 0; // Are players allowed to switch on their flashlight?
Expand Down
3 changes: 1 addition & 2 deletions src/game/server/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,9 @@ void CHalfLifeMultiplay::RefreshSkillData(void)
//=========================================================
void CHalfLifeMultiplay ::Think(void)
{
CGameRules::Think();
g_VoiceGameMgr.Update(gpGlobals->frametime);

PM_SetBHopCapEnabled(!bunnyhop.value);

///// Check game rules /////
static int last_frags;
static int last_time;
Expand Down
4 changes: 3 additions & 1 deletion src/game/server/singleplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ CHalfLifeRules::CHalfLifeRules(void)
//=========================================================
void CHalfLifeRules::Think(void)
{
PM_SetBHopCapEnabled(!bunnyhop.value);
// Leaving this method just in case plugins hook it
// Originally CGameRules::Think was pure-virtual
CGameRules::Think();
}

//=========================================================
Expand Down
4 changes: 2 additions & 2 deletions src/game/server/teamplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ extern CVoiceGameMgr g_VoiceGameMgr;

void CHalfLifeTeamplay ::Think(void)
{
CGameRules::Think();

///// Check game rules /////
static int last_frags;
static int last_time;
Expand All @@ -101,8 +103,6 @@ void CHalfLifeTeamplay ::Think(void)

g_VoiceGameMgr.Update(gpGlobals->frametime);

PM_SetBHopCapEnabled(!bunnyhop.value);

if (g_fGameOver) // someone else quit the game already
{
CHalfLifeMultiplay::Think();
Expand Down

0 comments on commit 3935cef

Please sign in to comment.