From 5bb276219062a380995f2d360acc3a6c68cff30e Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Mon, 14 Oct 2024 00:12:36 +0500 Subject: [PATCH 1/7] Merge full player movement unstuck code from HL25 Update. --- pm_shared/pm_shared.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index 922c7ca6d2..2396c9cd97 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -946,7 +946,10 @@ int PM_FlyMove( void ) // modify original_velocity so it parallels all of the clip planes // - if( pmove->movetype == MOVETYPE_WALK && ( ( pmove->onground == -1 ) || ( pmove->friction != 1 ) ) ) // relfect player velocity + // reflect player velocity + // Only give this a try for first impact plane because you can get yourself stuck in an acute corner by jumping in place + // and pressing forward and nobody was really using this bounce/reflection feature anyway... + if( numplanes == 1 && pmove->movetype == MOVETYPE_WALK && ( ( pmove->onground == -1 ) || ( pmove->friction != 1 ))) { for( i = 0; i < numplanes; i++ ) { @@ -2860,6 +2863,15 @@ void PM_CheckParamters( void ) pmove->maxspeed = min( maxspeed, pmove->maxspeed ); } + // Slow down, I'm pulling it! (a box maybe) but only when I'm standing on ground + // + // JoshA: Moved this to CheckParamters rather than working on the velocity, + // as otherwise it affects every integration step incorrectly. + if( ( pmove->onground != -1 ) && ( pmove->cmd.buttons & IN_USE )) + { + pmove->maxspeed *= 1.0f / 3.0f; + } + if( ( spd != 0.0f ) && ( spd > pmove->maxspeed ) ) { float fRatio = pmove->maxspeed / spd; @@ -2980,7 +2992,11 @@ void PM_PlayerMove( qboolean server ) { if( PM_CheckStuck() ) { - return; // Can't move, we're stuck + // Let the user try to duck to get unstuck + PM_Duck(); + + if( PM_CheckStuck() ) + return; // Can't move, we're stuck } } @@ -3026,12 +3042,6 @@ void PM_PlayerMove( qboolean server ) } } - // Slow down, I'm pulling it! (a box maybe) but only when I'm standing on ground - if( ( pmove->onground != -1 ) && ( pmove->cmd.buttons & IN_USE ) ) - { - VectorScale( pmove->velocity, 0.3, pmove->velocity ); - } - // Handle movement switch( pmove->movetype ) { From 73ac4def87360fd68cd4027896e64917fc8f5361 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Mon, 14 Oct 2024 00:18:16 +0500 Subject: [PATCH 2/7] ITEM_FLAG_NOCHOICE->ITEM_FLAG_NOAUTOSWITCHTO. --- dlls/rpg.cpp | 2 +- dlls/singleplay_gamerules.cpp | 2 +- dlls/weapons.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 4e39ec2c50..86ae6d2c86 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -400,7 +400,7 @@ int CRpg::GetItemInfo( ItemInfo *p ) p->iSlot = 3; p->iPosition = 0; p->iId = m_iId = WEAPON_RPG; - p->iFlags = ITEM_FLAG_NOCHOICE; + p->iFlags = ITEM_FLAG_NOAUTOSWITCHTO; p->iWeight = RPG_WEIGHT; return 1; diff --git a/dlls/singleplay_gamerules.cpp b/dlls/singleplay_gamerules.cpp index 06ad417c3b..2dc9336da7 100644 --- a/dlls/singleplay_gamerules.cpp +++ b/dlls/singleplay_gamerules.cpp @@ -119,7 +119,7 @@ BOOL HLGetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) while( pCheck ) { - if( !FBitSet( pCheck->iFlags(), ITEM_FLAG_NOCHOICE )) + if( !FBitSet( pCheck->iFlags(), ITEM_FLAG_NOAUTOSWITCHTO )) { if( pCheck->iWeight() > -1 && pCheck->iWeight() == pCurrentWeapon->iWeight() && pCheck != pCurrentWeapon ) { diff --git a/dlls/weapons.h b/dlls/weapons.h index 4db8381f31..aea4a62822 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -183,7 +183,7 @@ typedef enum #define ITEM_FLAG_NOAUTOSWITCHEMPTY 4 #define ITEM_FLAG_LIMITINWORLD 8 #define ITEM_FLAG_EXHAUSTIBLE 16 // A player can totally exhaust their ammo supply and lose this weapon -#define ITEM_FLAG_NOCHOICE 32 +#define ITEM_FLAG_NOAUTOSWITCHTO 32 #define WEAPON_IS_ONTARGET 0x40 From 253a3cb8d4873ced7090b13ef97de04fe8b48276 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Mon, 14 Oct 2024 00:41:38 +0500 Subject: [PATCH 3/7] Better spawn spot randomization from HL25 update. --- dlls/player.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index bd508e3de5..fe348abf14 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -2794,6 +2794,8 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) CBaseEntity *pSpot; edict_t *player; + int nNumRandomSpawnsToTry = 10; + player = pPlayer->edict(); // choose a info_player_deathmatch point @@ -2808,9 +2810,18 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) } else if( g_pGameRules->IsDeathmatch() ) { + if( !g_pLastSpawn ) + { + nNumRandomSpawnsToTry = 0; + CBaseEntity* pEnt = 0; + + while( ( pEnt = UTIL_FindEntityByClassname( 0, "info_player_deathmatch" ))) + nNumRandomSpawnsToTry++; + } + pSpot = g_pLastSpawn; // Randomize the start spot - for( int i = RANDOM_LONG( 1, 9 ); i > 0; i-- ) + for( int i = RANDOM_LONG( 1, nNumRandomSpawnsToTry - 1 ); i > 0; i-- ) pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_deathmatch" ); if( FNullEnt( pSpot ) ) // skip over the null point pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_deathmatch" ); From c2bd17f9c23ca3921170bfc16eea742e60c8ce51 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Mon, 14 Oct 2024 00:50:08 +0500 Subject: [PATCH 4/7] Send correct death notice. --- dlls/multiplay_gamerules.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index ef2db2d5c5..f1de0ffbb2 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -580,11 +580,6 @@ int CHalfLifeMultiplay::IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKi //========================================================= void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ) { - DeathNotice( pVictim, pKiller, pInflictor ); - - pVictim->m_iDeaths += 1; - - FireTargets( "game_playerdie", pVictim, pVictim, USE_TOGGLE, 0 ); CBasePlayer *peKiller = NULL; CBaseEntity *ktmp = CBaseEntity::Instance( pKiller ); if( ktmp && (ktmp->Classify() == CLASS_PLAYER ) ) @@ -600,6 +595,12 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, } } + DeathNotice( pVictim, pKiller, pInflictor ); + + pVictim->m_iDeaths += 1; + + FireTargets( "game_playerdie", pVictim, pVictim, USE_TOGGLE, 0 ); + if( pVictim->pev == pKiller ) { // killed self From 22f4f3b7e06c36a52fd179b7ad679fdd78972640 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Mon, 14 Oct 2024 03:41:09 +0500 Subject: [PATCH 5/7] Make cl_bob cvar archive. --- cl_dll/view.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index 4138929640..7cc08208d1 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -1611,7 +1611,7 @@ void V_Init( void ) v_centerspeed = gEngfuncs.pfnRegisterVariable( "v_centerspeed","500", 0 ); cl_bobcycle = gEngfuncs.pfnRegisterVariable( "cl_bobcycle","0.8", 0 );// best default for my experimental gun wag (sjb) - cl_bob = gEngfuncs.pfnRegisterVariable( "cl_bob","0.01", 0 );// best default for my experimental gun wag (sjb) + cl_bob = gEngfuncs.pfnRegisterVariable( "cl_bob","0.01", FCVAR_ARCHIVE );// best default for my experimental gun wag (sjb) cl_bobup = gEngfuncs.pfnRegisterVariable( "cl_bobup","0.5", 0 ); cl_waterdist = gEngfuncs.pfnRegisterVariable( "cl_waterdist","4", 0 ); cl_chasedist = gEngfuncs.pfnRegisterVariable( "cl_chasedist","112", 0 ); From 006d8308c36825d836ee8f3c5f78d0b70060024e Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Mon, 14 Oct 2024 03:54:41 +0500 Subject: [PATCH 6/7] Protect sensitivity cvar. --- cl_dll/input_goldsource.cpp | 2 +- cl_dll/input_xash3d.cpp | 2 +- common/cvardef.h | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 80a0ab5e34..d3517b2881 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -1592,7 +1592,7 @@ void GoldSourceInput::IN_Init (void) { ignoreNextDelta = false; m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE ); - sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. + sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE | FCVAR_FILTERSTUFFTEXT ); // user mouse sensitivity setting. in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick","0", FCVAR_ARCHIVE ); joy_name = gEngfuncs.pfnRegisterVariable ( "joyname", "joystick", 0 ); diff --git a/cl_dll/input_xash3d.cpp b/cl_dll/input_xash3d.cpp index ba5b14fd99..4f2ea39f14 100644 --- a/cl_dll/input_xash3d.cpp +++ b/cl_dll/input_xash3d.cpp @@ -280,7 +280,7 @@ void FWGSInput::IN_Shutdown( void ) // Register cvars and reset data void FWGSInput::IN_Init( void ) { - sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity", "3", FCVAR_ARCHIVE ); + sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity", "3", FCVAR_ARCHIVE | FCVAR_FILTERSTUFFTEXT ); in_joystick = gEngfuncs.pfnRegisterVariable( "joystick", "0", FCVAR_ARCHIVE ); cl_laddermode = gEngfuncs.pfnRegisterVariable( "cl_laddermode", "2", FCVAR_ARCHIVE ); ac_forwardmove = ac_sidemove = rel_yaw = rel_pitch = 0; diff --git a/common/cvardef.h b/common/cvardef.h index 1d55f7ca89..4ab46a5057 100644 --- a/common/cvardef.h +++ b/common/cvardef.h @@ -26,6 +26,10 @@ #define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). #define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log #define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar +#define FCVAR_PRIVILEGED (1<<10) // Not queryable/settable by unprivileged sources +#define FCVAR_FILTERSTUFFTEXT (1<<11) // Not queryable/settable if unprivileged and filterstufftext is enabled +#define FCVAR_FILTERCHARS (1<<12) // This cvar's string will be filtered for 'bad' characters (e.g. ';', '\n') +#define FCVAR_NOBADPATHS (1<<13) // This cvar's string cannot contain file paths that are above the current directory typedef struct cvar_s { From 13086d3b5d7ab24b246160237ebc03bcc3ad0669 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 17 Oct 2024 20:08:11 +0300 Subject: [PATCH 7/7] server: fix infinite loop while trying to look for spawn spot for deathmatch Fixes: 253a3cb8d487 ("Better spawn spot randomization from HL25 update.") --- dlls/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index fe348abf14..f2714d08af 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -2815,7 +2815,7 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) nNumRandomSpawnsToTry = 0; CBaseEntity* pEnt = 0; - while( ( pEnt = UTIL_FindEntityByClassname( 0, "info_player_deathmatch" ))) + while( ( pEnt = UTIL_FindEntityByClassname( pEnt, "info_player_deathmatch" ))) nNumRandomSpawnsToTry++; }