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

Fix long standing jump bug & movement lag based on FPS #755

Closed
wants to merge 13 commits into from
Closed
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| sv_autobunnyhopping | 0 | 0 | 1 | Players automatically re-jump while holding jump button.<br/>`0` disabled <br/>`1` enabled |
| sv_enablebunnyhopping | 0 | 0 | 1 | Allow player speed to exceed maximum running speed.<br/>`0` disabled <br/>`1` enabled |
| mp_plant_c4_anywhere | 0 | 0 | 1 | When set, players can plant anywhere, not only in bombsites.<br/>`0` disabled <br/>`1` enabled |
| sv_legacy_movement | 0 | 0 | 1 | Legacy movement. The new one fixes FPS based jump and movement.<br/>`0` Legacy behaviour <br/>`1` New behaviour |
</details>

## How to install zBot for CS 1.6?
Expand Down
7 changes: 7 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,10 @@ sv_enablebunnyhopping 0
//
// Default value: "0"
mp_plant_c4_anywhere 0

// Legacy movement. The new one fixes FPS based jump and movement.
// 0 - Legacy behavior
// 1 - New behavior
//
// Default value: "0"
sv_legacy_movement 0
ShadowsAdi marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ cvar_t allchat = { "sv_allchat", "0", 0, 0.0f, nullptr
cvar_t sv_autobunnyhopping = { "sv_autobunnyhopping", "0", 0, 0.0f, nullptr };
cvar_t sv_enablebunnyhopping = { "sv_enablebunnyhopping", "0", 0, 0.0f, nullptr };
cvar_t plant_c4_anywhere = { "mp_plant_c4_anywhere", "0", 0, 0.0f, nullptr };
cvar_t sv_legacy_movement = { "sv_legacy_movement", "0", FCVAR_SERVER, 0.0f, nullptr };
ShadowsAdi marked this conversation as resolved.
Show resolved Hide resolved

void GameDLL_Version_f()
{
Expand Down Expand Up @@ -393,6 +394,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&sv_autobunnyhopping);
CVAR_REGISTER(&sv_enablebunnyhopping);
CVAR_REGISTER(&plant_c4_anywhere);
CVAR_REGISTER(&sv_legacy_movement);

// print version
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ extern cvar_t allchat;
extern cvar_t sv_autobunnyhopping;
extern cvar_t sv_enablebunnyhopping;
extern cvar_t plant_c4_anywhere;
extern cvar_t sv_legacy_movement;

#endif

Expand Down
40 changes: 26 additions & 14 deletions regamedll/pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2773,43 +2773,55 @@ void PM_CheckParameters()

void PM_ReduceTimers()
{
if (pmove->flTimeStepSound > 0)
float frame_msec = pmove->cmd.msec;

#ifdef REGAMEDLL_ADD
if(sv_legacy_movement.value > 0.0)
{
pmove->flTimeStepSound -= pmove->cmd.msec;
if(frame_msec < 10.0)
{
frame_msec *= 1.65f;
}
}
#endif

if (pmove->flTimeStepSound > 0.0)
{
pmove->flTimeStepSound -= frame_msec;

if (pmove->flTimeStepSound < 0)
if (pmove->flTimeStepSound < 0.0)
{
pmove->flTimeStepSound = 0;
pmove->flTimeStepSound = 0.0;
}
}

if (pmove->flDuckTime > 0)
if (pmove->flDuckTime > 0.0)
{
pmove->flDuckTime -= pmove->cmd.msec;
pmove->flDuckTime -= frame_msec;

if (pmove->flDuckTime < 0)
if (pmove->flDuckTime < 0.0)
{
pmove->flDuckTime = 0;
pmove->flDuckTime = 0.0;
}
}

if (pmove->flSwimTime > 0)
if (pmove->flSwimTime > 0.0)
{
pmove->flSwimTime -= pmove->cmd.msec;
pmove->flSwimTime -= frame_msec;

if (pmove->flSwimTime < 0)
if (pmove->flSwimTime < 0.0)
{
pmove->flSwimTime = 0;
pmove->flSwimTime = 0.0;
}
}

if (pmove->fuser2 > 0.0)
{
pmove->fuser2 -= pmove->cmd.msec;
pmove->fuser2 -= frame_msec;

if (pmove->fuser2 < 0.0)
{
pmove->fuser2 = 0;
pmove->fuser2 = 0.0;
}
}
}
Expand Down