From 1c80e4bbcda6a6088701852ff4bb17adb2b71929 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Fri, 25 Nov 2022 12:41:42 +0300 Subject: [PATCH 1/2] Add a cvar fixing pushable excessive acceleration (#343) --- dlls/func_break.cpp | 28 ++++++++++++++++++++++++---- dlls/game.cpp | 2 ++ dlls/game.h | 1 + 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index 916913f2..0c5e0114 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -26,6 +26,7 @@ #include "func_break.h" #include "decals.h" #include "explode.h" +#include "game.h" extern DLL_GLOBAL Vector g_vecAttackDir; @@ -925,12 +926,24 @@ void CPushable::Move( CBaseEntity *pOther, int push ) return; } - // g-cont. fix pushable acceleration bug (reverted as it used in mods) if( pOther->IsPlayer() ) { - // Don't push unless the player is pushing forward and NOT use (pull) - if( push && !( pevToucher->button & ( IN_FORWARD | IN_USE ) ) ) - return; + // g-cont. fix pushable acceleration bug (now implemented as cvar) + if (pushablemode.value == 1) + { + // Allow player push when moving right, left and back too + if ( push && !(pevToucher->button & (IN_FORWARD|IN_MOVERIGHT|IN_MOVELEFT|IN_BACK)) ) + return; + // Require player walking back when applying '+use' on pushable + if ( !push && !(pevToucher->button & (IN_BACK)) ) + return; + } + else + { + // Don't push unless the player is pushing forward and NOT use (pull) + if( push && !( pevToucher->button & ( IN_FORWARD | IN_USE ) ) ) + return; + } playerTouch = 1; } @@ -951,6 +964,13 @@ void CPushable::Move( CBaseEntity *pOther, int push ) else factor = 0.25f; + // Spirit fix for pushable acceleration + if (pushablemode.value == 2) + { + if (!push) + factor *= 0.5f; + } + pev->velocity.x += pevToucher->velocity.x * factor; pev->velocity.y += pevToucher->velocity.y * factor; diff --git a/dlls/game.cpp b/dlls/game.cpp index 690256c2..c648c796 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -38,6 +38,7 @@ cvar_t satchelfix = { "satchelfix", "0", FCVAR_SERVER }; cvar_t explosionfix = { "explosionfix", "0", FCVAR_SERVER }; cvar_t monsteryawspeedfix = { "monsteryawspeedfix", "1", FCVAR_SERVER }; cvar_t corpsephysics = { "corpsephysics", "0", FCVAR_SERVER }; +cvar_t pushablemode = { "pushablemode", "0", FCVAR_SERVER }; cvar_t forcerespawn = { "mp_forcerespawn","1", FCVAR_SERVER }; cvar_t flashlight = { "mp_flashlight","0", FCVAR_SERVER }; cvar_t aimcrosshair = { "mp_autocrosshair","1", FCVAR_SERVER }; @@ -491,6 +492,7 @@ void GameDLLInit( void ) CVAR_REGISTER( &explosionfix ); CVAR_REGISTER( &monsteryawspeedfix ); CVAR_REGISTER( &corpsephysics ); + CVAR_REGISTER( &pushablemode ); CVAR_REGISTER( &forcerespawn ); CVAR_REGISTER( &flashlight ); CVAR_REGISTER( &aimcrosshair ); diff --git a/dlls/game.h b/dlls/game.h index 54e3281d..fee1a71b 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -33,6 +33,7 @@ extern cvar_t satchelfix; extern cvar_t explosionfix; extern cvar_t monsteryawspeedfix; extern cvar_t corpsephysics; +extern cvar_t pushablemode; extern cvar_t forcerespawn; extern cvar_t flashlight; extern cvar_t aimcrosshair; From 63e3769c46ba7f502b53abdfdd55597e4130c0dd Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Sat, 26 Nov 2022 02:27:38 +0500 Subject: [PATCH 2/2] Fix animation code accessing invalid sequence descriptor. https://github.com/ValveSoftware/halflife/issues/3308 --- dlls/animation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/animation.cpp b/dlls/animation.cpp index c7d38e71..c66d49cd 100644 --- a/dlls/animation.cpp +++ b/dlls/animation.cpp @@ -238,7 +238,7 @@ void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float * mstudioseqdesc_t *pseqdesc; - if( pev->sequence >= pstudiohdr->numseq ) + if( pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq ) { *pflFrameRate = 0.0f; *pflGroundSpeed = 0.0f; @@ -265,7 +265,7 @@ int GetSequenceFlags( void *pmodel, entvars_t *pev ) studiohdr_t *pstudiohdr; pstudiohdr = (studiohdr_t *)pmodel; - if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq ) + if( !pstudiohdr || pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq ) return 0; mstudioseqdesc_t *pseqdesc; @@ -279,7 +279,7 @@ int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEve studiohdr_t *pstudiohdr; pstudiohdr = (studiohdr_t *)pmodel; - if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent ) + if( !pstudiohdr || pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent ) return 0; mstudioseqdesc_t *pseqdesc; @@ -379,7 +379,7 @@ float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ) studiohdr_t *pstudiohdr; pstudiohdr = (studiohdr_t *)pmodel; - if( !pstudiohdr ) + if( !pstudiohdr || pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq ) return flValue; mstudioseqdesc_t *pseqdesc;