Skip to content

Commit

Permalink
Add cvar sv_allowbunnyhopping to control whether the bunny hopping li…
Browse files Browse the repository at this point in the history
…miter is enabled
  • Loading branch information
SamVanheer committed Aug 14, 2023
1 parent 68bb362 commit a1cf2d3
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* Fixed hand grenade animations not playing correctly [#209](https://github.com/SamVanheer/halflife-updated/pull/209) (Thanks Toodles2You)
* Fixed out of bounds access in studiomodel renderer bone setup code (halflife issue [#3360](https://github.com/ValveSoftware/halflife/issues/3360))

### Features

* Added cvar `sv_allowbunnyhopping` to control whether the bunny hopping limiter is enabled (halflife issue [#11](https://github.com/ValveSoftware/halflife/issues/11))

## Changes in V1.0.0 Release Candidate 001

### Bug fixes
Expand Down
20 changes: 20 additions & 0 deletions dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ void ParmsChangeLevel()
pSaveData->connectionCount = BuildChangeList(pSaveData->levelList, MAX_LEVEL_CONNECTIONS);
}

static bool g_LastAllowBunnyHoppingState = false;

//
// GLOBALS ASSUMED SET: g_ulFrameCount
Expand All @@ -787,6 +788,25 @@ void StartFrame()

gpGlobals->teamplay = teamplay.value;
g_ulFrameCount++;

const bool allowBunnyHopping = sv_allowbunnyhopping.value != 0;

if (allowBunnyHopping != g_LastAllowBunnyHoppingState)
{
g_LastAllowBunnyHoppingState = allowBunnyHopping;

for (int i = 1; i <= gpGlobals->maxClients; ++i)
{
auto player = UTIL_PlayerByIndex(i);

if (!player)
{
continue;
}

g_engfuncs.pfnSetPhysicsKeyValue(player->edict(), "bj", UTIL_dtos1(allowBunnyHopping ? 1 : 0));
}
}
}


Expand Down
4 changes: 4 additions & 0 deletions dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ cvar_t allow_spectators = {"allow_spectators", "0.0", FCVAR_SERVER}; // 0 preven

cvar_t mp_chattime = {"mp_chattime", "10", FCVAR_SERVER};

cvar_t sv_allowbunnyhopping = {"sv_allowbunnyhopping", "0", FCVAR_SERVER};

//CVARS FOR SKILL LEVEL SETTINGS
// Agrunt
cvar_t sk_agrunt_health1 = {"sk_agrunt_health1", "0"};
Expand Down Expand Up @@ -493,6 +495,8 @@ void GameDLLInit()

CVAR_REGISTER(&mp_chattime);

CVAR_REGISTER(&sv_allowbunnyhopping);

// REGISTER CVARS FOR SKILL LEVEL STUFF
// Agrunt
CVAR_REGISTER(&sk_agrunt_health1); // {"sk_agrunt_health1","0"};
Expand Down
2 changes: 2 additions & 0 deletions dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ extern cvar_t allowmonsters;
extern cvar_t allow_spectators;
extern cvar_t mp_chattime;

extern cvar_t sv_allowbunnyhopping;

// Engine Cvars
inline cvar_t* g_psv_gravity;
inline cvar_t* g_psv_aim;
Expand Down
1 change: 1 addition & 0 deletions dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2806,6 +2806,7 @@ void CBasePlayer::Spawn()

g_engfuncs.pfnSetPhysicsKeyValue(edict(), "slj", "0");
g_engfuncs.pfnSetPhysicsKeyValue(edict(), "hl", "1");
g_engfuncs.pfnSetPhysicsKeyValue(edict(), "bj", UTIL_dtos1(sv_allowbunnyhopping.value != 0 ? 1 : 0));

m_iFOV = 0; // init field of view.
m_iClientFOV = -1; // make sure fov reset is sent
Expand Down
7 changes: 7 additions & 0 deletions pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2525,6 +2525,13 @@ void PM_NoClip()
//-----------------------------------------------------------------------------
void PM_PreventMegaBunnyJumping()
{
const bool allowBunnyHopping = atoi(pmove->PM_Info_ValueForKey(pmove->physinfo, "bj")) == 1;

if (allowBunnyHopping)
{
return;
}

// Current player speed
float spd;
// If we have to crop, apply this cropping fraction to velocity
Expand Down

0 comments on commit a1cf2d3

Please sign in to comment.