From c4e8a135809a1909b680d95cedda2564c5f315df Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Tue, 26 Oct 2021 00:51:50 -0400 Subject: [PATCH 01/12] add gameplay cvars that override multiplayer overrides, allowing you to once again have control over damage values --- dlls/game.cpp | 37 +++++++++++++++++++++++++++++++ dlls/multiplay_gamerules.cpp | 42 +++++++++++++++++++++++------------- 2 files changed, 64 insertions(+), 15 deletions(-) diff --git a/dlls/game.cpp b/dlls/game.cpp index 1207a08945..85ef977600 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -451,6 +451,23 @@ cvar_t sk_player_leg1 = { "sk_player_leg1","1" }; cvar_t sk_player_leg2 = { "sk_player_leg2","1" }; cvar_t sk_player_leg3 = { "sk_player_leg3","1" }; +// multiplayer override overrides. +cvar_t sk_mp_suitcharger = {"sk_mp_suitcharger","0"}; +cvar_t sk_mp_plr_crowbar = {"sk_mp_plr_crowbar","0"}; +cvar_t sk_mp_plr_9mm_bullet = {"sk_mp_plr_9mm_bullet","0"}; +cvar_t sk_mp_plr_357_bullet = {"sk_mp_plr_357_bullet","0"}; +cvar_t sk_mp_plr_9mmAR_bullet = {"sk_mp_plr_9mmAR_bullet","0"}; +cvar_t sk_mp_plr_9mmAR_grenade = {"sk_mp_plr_9mmAR_grenade","0"}; +cvar_t sk_mp_plr_buckshot = {"sk_mp_plr_buckshot","0"}; +cvar_t sk_mp_plr_xbow_bolt_client = {"sk_mp_plr_xbow_bolt_client","0"}; +cvar_t sk_mp_plr_rpg = {"sk_mp_plr_rpg","0"}; +cvar_t sk_mp_plr_egon_wide = {"sk_mp_plr_egon_wide","0"}; +cvar_t sk_mp_plr_egon_narrow = {"sk_mp_plr_egon_narrow","0"}; +cvar_t sk_mp_plr_hand_grenade = {"sk_mp_plr_hand_grenade","0"}; +cvar_t sk_mp_plr_satchel = {"sk_mp_plr_satchel","0"}; +cvar_t sk_mp_plr_tripmine = {"sk_mp_plr_tripmine","0"}; +cvar_t sk_mp_plr_hornet = {"sk_mp_plr_hornet","0"}; + // END Cvars for Skill Level settings // Register your console variables here @@ -870,6 +887,26 @@ void GameDLLInit( void ) CVAR_REGISTER( &sk_player_leg1 ); CVAR_REGISTER( &sk_player_leg2 ); CVAR_REGISTER( &sk_player_leg3 ); + + + // multiplayer override overrides + + CVAR_REGISTER( &sk_mp_suitcharger ); + CVAR_REGISTER( &sk_mp_plr_crowbar ); + CVAR_REGISTER( &sk_mp_plr_9mm_bullet ); + CVAR_REGISTER( &sk_mp_plr_357_bullet ); + CVAR_REGISTER( &sk_mp_plr_9mmAR_bullet ); + CVAR_REGISTER( &sk_mp_plr_9mmAR_grenade ); + CVAR_REGISTER( &sk_mp_plr_buckshot ); + CVAR_REGISTER( &sk_mp_plr_xbow_bolt_client ); + CVAR_REGISTER( &sk_mp_plr_rpg ); + CVAR_REGISTER( &sk_mp_plr_egon_wide ); + CVAR_REGISTER( &sk_mp_plr_egon_narrow ); + CVAR_REGISTER( &sk_mp_plr_hand_grenade ); + CVAR_REGISTER( &sk_mp_plr_satchel ); + CVAR_REGISTER( &sk_mp_plr_tripmine ); + CVAR_REGISTER( &sk_mp_plr_hornet ); + // END REGISTER CVARS FOR SKILL LEVEL STUFF SERVER_COMMAND( "exec skill.cfg\n" ); diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index da199271d4..4ec8c26a98 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -130,6 +130,18 @@ BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) return CGameRules::ClientCommand( pPlayer, pcmd ); } + +float GetMPSkillCvarOrElse(const char *skill_name, const float otherwise) +{ + float skill_value = CVAR_GET_FLOAT( skill_name ); + if( skill_value <= 0 ) + { + skill_value = otherwise; + } + return skill_value; +} + + //========================================================= //========================================================= void CHalfLifeMultiplay::RefreshSkillData( void ) @@ -140,47 +152,47 @@ void CHalfLifeMultiplay::RefreshSkillData( void ) // override some values for multiplay. // suitcharger - gSkillData.suitchargerCapacity = 30; + gSkillData.suitchargerCapacity = GetMPSkillCvarOrElse( "sk_mp_suitcharger", 30 ); // Crowbar whack - gSkillData.plrDmgCrowbar = 25; + gSkillData.plrDmgCrowbar = GetMPSkillCvarOrElse( "sk_mp_plr_crowbar", 25 ); // Glock Round - gSkillData.plrDmg9MM = 12; + gSkillData.plrDmg9MM = GetMPSkillCvarOrElse( "sk_mp_plr_9mm_bullet", 12 ); // 357 Round - gSkillData.plrDmg357 = 40; + gSkillData.plrDmg357 = GetMPSkillCvarOrElse( "sk_mp_plr_357_bullet", 40 ); // MP5 Round - gSkillData.plrDmgMP5 = 12; + gSkillData.plrDmgMP5 = GetMPSkillCvarOrElse( "sk_mp_plr_9mmAR_bullet", 12 ); // M203 grenade - gSkillData.plrDmgM203Grenade = 100; + gSkillData.plrDmgM203Grenade = GetMPSkillCvarOrElse( "sk_mp_plr_9mmAR_grenade", 100 ); // Shotgun buckshot - gSkillData.plrDmgBuckshot = 20;// fewer pellets in deathmatch + gSkillData.plrDmgBuckshot = GetMPSkillCvarOrElse( "sk_mp_plr_buckshot", 20 );// fewer pellets in deathmatch // Crossbow - gSkillData.plrDmgCrossbowClient = 20; + gSkillData.plrDmgCrossbowClient = GetMPSkillCvarOrElse( "sk_mp_plr_xbow_bolt_client", 20 ); // RPG - gSkillData.plrDmgRPG = 120; + gSkillData.plrDmgRPG = GetMPSkillCvarOrElse( "sk_mp_plr_rpg", 120 ); // Egon - gSkillData.plrDmgEgonWide = 20; - gSkillData.plrDmgEgonNarrow = 10; + gSkillData.plrDmgEgonWide = GetMPSkillCvarOrElse( "sk_mp_plr_egon_wide" , 20 ); + gSkillData.plrDmgEgonNarrow = GetMPSkillCvarOrElse( "sk_mp_plr_egon_narrow", 10 ); // Hand Grendade - gSkillData.plrDmgHandGrenade = 100; + gSkillData.plrDmgHandGrenade = GetMPSkillCvarOrElse( "sk_mp_plr_hand_grenade", 100 ); // Satchel Charge - gSkillData.plrDmgSatchel = 120; + gSkillData.plrDmgSatchel = GetMPSkillCvarOrElse( "sk_mp_plr_satchel", 120 ); // Tripmine - gSkillData.plrDmgTripmine = 150; + gSkillData.plrDmgTripmine = GetMPSkillCvarOrElse( "sk_mp_plr_tripmine" , 150 ); // hornet - gSkillData.plrDmgHornet = 10; + gSkillData.plrDmgHornet = GetMPSkillCvarOrElse( "sk_mp_plr_hornet" , 10 ); } // longest the intermission can last, in seconds From dfbfb83d90495d828d2b44c4d159d97e9eb991bd Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Tue, 26 Oct 2021 01:47:03 -0400 Subject: [PATCH 02/12] have cheats auto-update (send notif to client, use updated value in server) --- dlls/client.cpp | 8 ++++---- dlls/game.cpp | 7 +++++++ dlls/game.h | 1 + dlls/player.cpp | 4 ++-- dlls/world.cpp | 4 ---- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 142b5de833..82b8e7e762 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -468,7 +468,7 @@ ClientCommand called each time a player uses a "cmd" command ============ */ -extern float g_flWeaponCheat; +extern cvar_t *g_enable_cheats; // Use CMD_ARGV, CMD_ARGV, and CMD_ARGC to get pointers the character string command. void ClientCommand( edict_t *pEntity ) @@ -496,7 +496,7 @@ void ClientCommand( edict_t *pEntity ) } else if( FStrEq(pcmd, "give" ) ) { - if( g_flWeaponCheat != 0.0f ) + if( g_enable_cheats->value != 0 ) { int iszItem = ALLOC_STRING( CMD_ARGV( 1 ) ); // Make a copy of the classname GetClassPtr( (CBasePlayer *)pev )->GiveNamedItem( STRING( iszItem ) ); @@ -504,7 +504,7 @@ void ClientCommand( edict_t *pEntity ) } else if( FStrEq( pcmd, "fire" ) ) { - if( g_flWeaponCheat != 0.0f ) + if( g_enable_cheats->value != 0 ) { CBaseEntity *pPlayer = CBaseEntity::Instance( pEntity ); if( CMD_ARGC() > 1 ) @@ -540,7 +540,7 @@ void ClientCommand( edict_t *pEntity ) } else if( FStrEq( pcmd, "fov" ) ) { - if( g_flWeaponCheat && CMD_ARGC() > 1 ) + if( g_enable_cheats->value != 0 && CMD_ARGC() > 1 ) { GetClassPtr( (CBasePlayer *)pev )->m_iFOV = atoi( CMD_ARGV( 1 ) ); } diff --git a/dlls/game.cpp b/dlls/game.cpp index 85ef977600..d618a1bdc2 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -51,10 +51,13 @@ cvar_t multibyte_only = { "mp_multibyte_only", "0", FCVAR_SERVER }; cvar_t mp_chattime = { "mp_chattime","10", FCVAR_SERVER }; +cvar_t sv_cheats = {"sv_cheats", "0", FCVAR_SERVER}; + // Engine Cvars cvar_t *g_psv_gravity = NULL; cvar_t *g_psv_aim = NULL; cvar_t *g_footsteps = NULL; +cvar_t *g_enable_cheats = NULL; cvar_t *g_psv_developer; @@ -484,6 +487,8 @@ void GameDLLInit( void ) g_psv_developer = CVAR_GET_POINTER( "developer" ); + g_enable_cheats = CVAR_GET_POINTER( "sv_cheats" ); + CVAR_REGISTER( &displaysoundlist ); CVAR_REGISTER( &allow_spectators ); @@ -514,6 +519,8 @@ void GameDLLInit( void ) CVAR_REGISTER( &mp_chattime ); + CVAR_REGISTER( &sv_cheats ); + // REGISTER CVARS FOR SKILL LEVEL STUFF // Agrunt CVAR_REGISTER( &sk_agrunt_health1 );// {"sk_agrunt_health1","0"}; diff --git a/dlls/game.h b/dlls/game.h index 77502e7659..3119351aaf 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -44,6 +44,7 @@ extern cvar_t allowmonsters; extern cvar_t *g_psv_gravity; extern cvar_t *g_psv_aim; extern cvar_t *g_footsteps; +extern cvar_t *g_enable_cheats; extern cvar_t *g_psv_developer; #endif // GAME_H diff --git a/dlls/player.cpp b/dlls/player.cpp index 002635c042..cce57d02e3 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3355,7 +3355,7 @@ void CBasePlayer::ForceClientDllUpdate( void ) ImpulseCommands ============ */ -extern float g_flWeaponCheat; +extern cvar_t *g_enable_cheats; void CBasePlayer::ImpulseCommands() { @@ -3434,7 +3434,7 @@ void CBasePlayer::ImpulseCommands() void CBasePlayer::CheatImpulseCommands( int iImpulse ) { #if !HLDEMO_BUILD - if( g_flWeaponCheat == 0.0f ) + if( g_enable_cheats->value == 0 ) { return; } diff --git a/dlls/world.cpp b/dlls/world.cpp index 0d7db511fd..3f4bda0b5d 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -449,7 +449,6 @@ LINK_ENTITY_TO_CLASS( worldspawn, CWorld ) #define SF_WORLD_FORCETEAM 0x0004 // Force teams extern DLL_GLOBAL BOOL g_fGameOver; -float g_flWeaponCheat; void CWorld::Spawn( void ) { @@ -652,9 +651,6 @@ void CWorld::Precache( void ) { CVAR_SET_FLOAT( "mp_defaultteam", 0.0f ); } - - // g-cont. moved here so cheats will working on restore level - g_flWeaponCheat = CVAR_GET_FLOAT( "sv_cheats" ); // Is the impulse 101 command allowed? } // From ad280e3b1692ac399a40531fc5b8f45c18437831 Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Tue, 26 Oct 2021 02:13:22 -0400 Subject: [PATCH 03/12] add longjump disable multiplayer var --- dlls/game.cpp | 4 ++++ dlls/game.h | 1 + dlls/items.cpp | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dlls/game.cpp b/dlls/game.cpp index d618a1bdc2..b8dfb5b5b2 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -51,6 +51,8 @@ cvar_t multibyte_only = { "mp_multibyte_only", "0", FCVAR_SERVER }; cvar_t mp_chattime = { "mp_chattime","10", FCVAR_SERVER }; +cvar_t mp_disable_longjump = {"mp_disable_longjump", "0", FCVAR_SERVER}; + cvar_t sv_cheats = {"sv_cheats", "0", FCVAR_SERVER}; // Engine Cvars @@ -519,6 +521,8 @@ void GameDLLInit( void ) CVAR_REGISTER( &mp_chattime ); + CVAR_REGISTER( &mp_disable_longjump ); + CVAR_REGISTER( &sv_cheats ); // REGISTER CVARS FOR SKILL LEVEL STUFF diff --git a/dlls/game.h b/dlls/game.h index 3119351aaf..21cf4aa97d 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -32,6 +32,7 @@ extern cvar_t chargerfix; extern cvar_t satchelfix; extern cvar_t monsteryawspeedfix; extern cvar_t forcerespawn; +extern cvar_t mp_disable_longjump; extern cvar_t flashlight; extern cvar_t aimcrosshair; extern cvar_t decalfrequency; diff --git a/dlls/items.cpp b/dlls/items.cpp index 08a13711b4..3c86099678 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -30,6 +30,7 @@ #include "gamerules.h" extern int gmsgItemPickup; +extern cvar_t mp_disable_longjump; class CWorldItem : public CBaseEntity { @@ -312,7 +313,7 @@ class CItemLongJump : public CItem } BOOL MyTouch( CBasePlayer *pPlayer ) { - if( pPlayer->m_fLongJump ) + if( pPlayer->m_fLongJump || (g_pGameRules->IsMultiplayer() && mp_disable_longjump.value > 0) ) { return FALSE; } From 83207567f10caa5e2c3f88f2519e15e28573281d Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Tue, 26 Oct 2021 10:15:04 -0400 Subject: [PATCH 04/12] cheats did not need to be registered here as it's registered by the engine --- dlls/game.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/dlls/game.cpp b/dlls/game.cpp index b8dfb5b5b2..e282fdc29f 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -523,8 +523,6 @@ void GameDLLInit( void ) CVAR_REGISTER( &mp_disable_longjump ); - CVAR_REGISTER( &sv_cheats ); - // REGISTER CVARS FOR SKILL LEVEL STUFF // Agrunt CVAR_REGISTER( &sk_agrunt_health1 );// {"sk_agrunt_health1","0"}; From 1f8a4b8b2d6b857d08f9836813859bfd489fec66 Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Tue, 26 Oct 2021 17:05:32 -0400 Subject: [PATCH 05/12] refactor based on recommendations from @nekonomicon. --- dlls/game.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/dlls/game.cpp b/dlls/game.cpp index e282fdc29f..98fa9cf2fc 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -457,21 +457,22 @@ cvar_t sk_player_leg2 = { "sk_player_leg2","1" }; cvar_t sk_player_leg3 = { "sk_player_leg3","1" }; // multiplayer override overrides. -cvar_t sk_mp_suitcharger = {"sk_mp_suitcharger","0"}; -cvar_t sk_mp_plr_crowbar = {"sk_mp_plr_crowbar","0"}; -cvar_t sk_mp_plr_9mm_bullet = {"sk_mp_plr_9mm_bullet","0"}; -cvar_t sk_mp_plr_357_bullet = {"sk_mp_plr_357_bullet","0"}; -cvar_t sk_mp_plr_9mmAR_bullet = {"sk_mp_plr_9mmAR_bullet","0"}; -cvar_t sk_mp_plr_9mmAR_grenade = {"sk_mp_plr_9mmAR_grenade","0"}; -cvar_t sk_mp_plr_buckshot = {"sk_mp_plr_buckshot","0"}; -cvar_t sk_mp_plr_xbow_bolt_client = {"sk_mp_plr_xbow_bolt_client","0"}; -cvar_t sk_mp_plr_rpg = {"sk_mp_plr_rpg","0"}; -cvar_t sk_mp_plr_egon_wide = {"sk_mp_plr_egon_wide","0"}; -cvar_t sk_mp_plr_egon_narrow = {"sk_mp_plr_egon_narrow","0"}; -cvar_t sk_mp_plr_hand_grenade = {"sk_mp_plr_hand_grenade","0"}; -cvar_t sk_mp_plr_satchel = {"sk_mp_plr_satchel","0"}; -cvar_t sk_mp_plr_tripmine = {"sk_mp_plr_tripmine","0"}; -cvar_t sk_mp_plr_hornet = {"sk_mp_plr_hornet","0"}; +// The default values are Valve's original overrides. +cvar_t sk_mp_suitcharger = {"sk_mp_suitcharger","30"}; +cvar_t sk_mp_plr_crowbar = {"sk_mp_plr_crowbar","25"}; +cvar_t sk_mp_plr_9mm_bullet = {"sk_mp_plr_9mm_bullet","12"}; +cvar_t sk_mp_plr_357_bullet = {"sk_mp_plr_357_bullet","40"}; +cvar_t sk_mp_plr_9mmAR_bullet = {"sk_mp_plr_9mmAR_bullet","12"}; +cvar_t sk_mp_plr_9mmAR_grenade = {"sk_mp_plr_9mmAR_grenade","100"}; +cvar_t sk_mp_plr_buckshot = {"sk_mp_plr_buckshot","20"}; // fewer pellets in deathmatch +cvar_t sk_mp_plr_xbow_bolt_client = {"sk_mp_plr_xbow_bolt_client","20"}; +cvar_t sk_mp_plr_rpg = {"sk_mp_plr_rpg","120"}; +cvar_t sk_mp_plr_egon_wide = {"sk_mp_plr_egon_wide","20"}; +cvar_t sk_mp_plr_egon_narrow = {"sk_mp_plr_egon_narrow","10"}; +cvar_t sk_mp_plr_hand_grenade = {"sk_mp_plr_hand_grenade","100"}; +cvar_t sk_mp_plr_satchel = {"sk_mp_plr_satchel","120"}; +cvar_t sk_mp_plr_tripmine = {"sk_mp_plr_tripmine","150"}; +cvar_t sk_mp_plr_hornet = {"sk_mp_plr_hornet","10"}; // END Cvars for Skill Level settings From db657ccb043349a06e92744ac15f1128d308f1a7 Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Tue, 26 Oct 2021 17:05:46 -0400 Subject: [PATCH 06/12] no longer needed per refactor --- dlls/multiplay_gamerules.cpp | 42 +++++++++++++----------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 4ec8c26a98..f77610836a 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -130,18 +130,6 @@ BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) return CGameRules::ClientCommand( pPlayer, pcmd ); } - -float GetMPSkillCvarOrElse(const char *skill_name, const float otherwise) -{ - float skill_value = CVAR_GET_FLOAT( skill_name ); - if( skill_value <= 0 ) - { - skill_value = otherwise; - } - return skill_value; -} - - //========================================================= //========================================================= void CHalfLifeMultiplay::RefreshSkillData( void ) @@ -152,47 +140,47 @@ void CHalfLifeMultiplay::RefreshSkillData( void ) // override some values for multiplay. // suitcharger - gSkillData.suitchargerCapacity = GetMPSkillCvarOrElse( "sk_mp_suitcharger", 30 ); + gSkillData.suitchargerCapacity = CVAR_GET_FLOAT( "sk_mp_suitcharger" ); // Crowbar whack - gSkillData.plrDmgCrowbar = GetMPSkillCvarOrElse( "sk_mp_plr_crowbar", 25 ); + gSkillData.plrDmgCrowbar = CVAR_GET_FLOAT( "sk_mp_plr_crowbar" ); // Glock Round - gSkillData.plrDmg9MM = GetMPSkillCvarOrElse( "sk_mp_plr_9mm_bullet", 12 ); + gSkillData.plrDmg9MM = CVAR_GET_FLOAT( "sk_mp_plr_9mm_bullet" ); // 357 Round - gSkillData.plrDmg357 = GetMPSkillCvarOrElse( "sk_mp_plr_357_bullet", 40 ); + gSkillData.plrDmg357 = CVAR_GET_FLOAT( "sk_mp_plr_357_bullet" ); // MP5 Round - gSkillData.plrDmgMP5 = GetMPSkillCvarOrElse( "sk_mp_plr_9mmAR_bullet", 12 ); + gSkillData.plrDmgMP5 = CVAR_GET_FLOAT( "sk_mp_plr_9mmAR_bullet" ); // M203 grenade - gSkillData.plrDmgM203Grenade = GetMPSkillCvarOrElse( "sk_mp_plr_9mmAR_grenade", 100 ); + gSkillData.plrDmgM203Grenade = CVAR_GET_FLOAT( "sk_mp_plr_9mmAR_grenade" ); // Shotgun buckshot - gSkillData.plrDmgBuckshot = GetMPSkillCvarOrElse( "sk_mp_plr_buckshot", 20 );// fewer pellets in deathmatch + gSkillData.plrDmgBuckshot = CVAR_GET_FLOAT( "sk_mp_plr_buckshot" ); // Crossbow - gSkillData.plrDmgCrossbowClient = GetMPSkillCvarOrElse( "sk_mp_plr_xbow_bolt_client", 20 ); + gSkillData.plrDmgCrossbowClient = CVAR_GET_FLOAT( "sk_mp_plr_xbow_bolt_client" ); // RPG - gSkillData.plrDmgRPG = GetMPSkillCvarOrElse( "sk_mp_plr_rpg", 120 ); + gSkillData.plrDmgRPG = CVAR_GET_FLOAT( "sk_mp_plr_rpg" ); // Egon - gSkillData.plrDmgEgonWide = GetMPSkillCvarOrElse( "sk_mp_plr_egon_wide" , 20 ); - gSkillData.plrDmgEgonNarrow = GetMPSkillCvarOrElse( "sk_mp_plr_egon_narrow", 10 ); + gSkillData.plrDmgEgonWide = CVAR_GET_FLOAT( "sk_mp_plr_egon_wide" ); + gSkillData.plrDmgEgonNarrow = CVAR_GET_FLOAT( "sk_mp_plr_egon_narrow" ); // Hand Grendade - gSkillData.plrDmgHandGrenade = GetMPSkillCvarOrElse( "sk_mp_plr_hand_grenade", 100 ); + gSkillData.plrDmgHandGrenade = CVAR_GET_FLOAT( "sk_mp_plr_hand_grenade" ); // Satchel Charge - gSkillData.plrDmgSatchel = GetMPSkillCvarOrElse( "sk_mp_plr_satchel", 120 ); + gSkillData.plrDmgSatchel = CVAR_GET_FLOAT( "sk_mp_plr_satchel" ); // Tripmine - gSkillData.plrDmgTripmine = GetMPSkillCvarOrElse( "sk_mp_plr_tripmine" , 150 ); + gSkillData.plrDmgTripmine = CVAR_GET_FLOAT( "sk_mp_plr_tripmine" ); // hornet - gSkillData.plrDmgHornet = GetMPSkillCvarOrElse( "sk_mp_plr_hornet" , 10 ); + gSkillData.plrDmgHornet = CVAR_GET_FLOAT( "sk_mp_plr_hornet" ); } // longest the intermission can last, in seconds From 0336dd8a04c0fc4fd324abb108600d8154d676b2 Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Tue, 26 Oct 2021 17:35:06 -0400 Subject: [PATCH 07/12] not needed either --- dlls/game.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/dlls/game.cpp b/dlls/game.cpp index 98fa9cf2fc..4b236c0f3f 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -53,8 +53,6 @@ cvar_t mp_chattime = { "mp_chattime","10", FCVAR_SERVER }; cvar_t mp_disable_longjump = {"mp_disable_longjump", "0", FCVAR_SERVER}; -cvar_t sv_cheats = {"sv_cheats", "0", FCVAR_SERVER}; - // Engine Cvars cvar_t *g_psv_gravity = NULL; cvar_t *g_psv_aim = NULL; From 7bb1ac9c73f19b8131401e0f70ad4f4d502f180e Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Wed, 27 Oct 2021 04:05:46 -0400 Subject: [PATCH 08/12] add elevated privilege commands. sv_cheats 2 = whitelist mode, only promoted users can run cheats. --- dlls/client.cpp | 46 ++++++++++++++++---------------- dlls/gamerules.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++ dlls/gamerules.h | 2 ++ dlls/player.cpp | 6 +++++ dlls/player.h | 2 ++ dlls/util.cpp | 21 +++++++++++++++ dlls/util.h | 2 ++ 7 files changed, 121 insertions(+), 24 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 82b8e7e762..3f135e63b8 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -471,42 +471,43 @@ called each time a player uses a "cmd" command extern cvar_t *g_enable_cheats; // Use CMD_ARGV, CMD_ARGV, and CMD_ARGC to get pointers the character string command. -void ClientCommand( edict_t *pEntity ) +void ClientCommand( edict_t *pEdict ) { const char *pcmd = CMD_ARGV( 0 ); const char *pstr; // Is the client spawned yet? - if( !pEntity->pvPrivateData ) + if( !pEdict->pvPrivateData ) return; - entvars_t *pev = &pEntity->v; + entvars_t *pev = &pEdict->v; + CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); if( FStrEq( pcmd, "say" ) ) { - Host_Say( pEntity, 0 ); + Host_Say( pEdict, 0 ); } else if( FStrEq( pcmd, "say_team" ) ) { - Host_Say( pEntity, 1 ); + Host_Say( pEdict, 1 ); } else if( FStrEq( pcmd, "fullupdate" ) ) { - GetClassPtr( (CBasePlayer *)pev )->ForceClientDllUpdate(); + pPlayer->ForceClientDllUpdate(); } else if( FStrEq(pcmd, "give" ) ) { - if( g_enable_cheats->value != 0 ) + if( g_enable_cheats->value == 1 || (g_enable_cheats->value == 2 && pPlayer->m_privilege_elevated) ) { int iszItem = ALLOC_STRING( CMD_ARGV( 1 ) ); // Make a copy of the classname - GetClassPtr( (CBasePlayer *)pev )->GiveNamedItem( STRING( iszItem ) ); + pPlayer->GiveNamedItem( STRING( iszItem ) ); } } else if( FStrEq( pcmd, "fire" ) ) { - if( g_enable_cheats->value != 0 ) + if( g_enable_cheats->value == 1 || (g_enable_cheats->value == 2 && pPlayer->m_privilege_elevated) ) { - CBaseEntity *pPlayer = CBaseEntity::Instance( pEntity ); + CBaseEntity *pPlayer = CBaseEntity::Instance( pEdict ); if( CMD_ARGC() > 1 ) { FireTargets( CMD_ARGV( 1 ), pPlayer, pPlayer, USE_TOGGLE, 0 ); @@ -518,7 +519,7 @@ void ClientCommand( edict_t *pEntity ) UTIL_TraceLine( pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 1000, - dont_ignore_monsters, pEntity, &tr + dont_ignore_monsters, pEdict, &tr ); if( tr.pHit ) @@ -527,7 +528,7 @@ void ClientCommand( edict_t *pEntity ) if( pHitEnt ) { pHitEnt->Use( pPlayer, pPlayer, USE_TOGGLE, 0 ); - ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Fired %s \"%s\"\n", STRING( pHitEnt->pev->classname ), STRING( pHitEnt->pev->targetname ) ) ); + ClientPrint( &pEdict->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Fired %s \"%s\"\n", STRING( pHitEnt->pev->classname ), STRING( pHitEnt->pev->targetname ) ) ); } } } @@ -536,34 +537,33 @@ void ClientCommand( edict_t *pEntity ) else if( FStrEq( pcmd, "drop" ) ) { // player is dropping an item. - GetClassPtr( (CBasePlayer *)pev )->DropPlayerItem( (char *)CMD_ARGV( 1 ) ); + pPlayer->DropPlayerItem( (char *)CMD_ARGV( 1 ) ); } else if( FStrEq( pcmd, "fov" ) ) { - if( g_enable_cheats->value != 0 && CMD_ARGC() > 1 ) + if( (g_enable_cheats->value == 1 || (g_enable_cheats->value == 2 && pPlayer->m_privilege_elevated) ) && CMD_ARGC() > 1 ) { - GetClassPtr( (CBasePlayer *)pev )->m_iFOV = atoi( CMD_ARGV( 1 ) ); + pPlayer->m_iFOV = atoi( CMD_ARGV( 1 ) ); } else { - CLIENT_PRINTF( pEntity, print_console, UTIL_VarArgs( "\"fov\" is \"%d\"\n", (int)GetClassPtr( (CBasePlayer *)pev )->m_iFOV ) ); + CLIENT_PRINTF( pEdict, print_console, UTIL_VarArgs( "\"fov\" is \"%d\"\n", (int)pPlayer->m_iFOV ) ); } } else if( FStrEq( pcmd, "use" ) ) { - GetClassPtr( (CBasePlayer *)pev )->SelectItem( (char *)CMD_ARGV( 1 ) ); + pPlayer->SelectItem( (char *)CMD_ARGV( 1 ) ); } else if( ( ( pstr = strstr( pcmd, "weapon_" ) ) != NULL ) && ( pstr == pcmd ) ) { - GetClassPtr( (CBasePlayer *)pev )->SelectItem( pcmd ); + pPlayer->SelectItem( pcmd ); } else if( FStrEq( pcmd, "lastinv" ) ) { - GetClassPtr( (CBasePlayer *)pev )->SelectLastItem(); + pPlayer->SelectLastItem(); } else if( FStrEq( pcmd, "spectate" ) ) // clients wants to become a spectator { - CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); if( !pPlayer->IsObserver() ) { // always allow proxies to become a spectator @@ -590,7 +590,6 @@ void ClientCommand( edict_t *pEntity ) } else if( FStrEq( pcmd, "specmode" ) ) // new spectator mode { - CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); if( pPlayer->IsObserver() ) pPlayer->Observer_SetMode( atoi( CMD_ARGV( 1 ) ) ); @@ -601,12 +600,11 @@ void ClientCommand( edict_t *pEntity ) } else if( FStrEq( pcmd, "follownext" ) ) // follow next player { - CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); if( pPlayer->IsObserver() ) pPlayer->Observer_FindNextPlayer( atoi( CMD_ARGV( 1 ) ) ? true : false ); } - else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) ) + else if( g_pGameRules->ClientCommand( pPlayer, pcmd ) ) { // MenuSelect returns true only if the command is properly handled, so don't print a warning } @@ -626,7 +624,7 @@ void ClientCommand( edict_t *pEntity ) command[127] = '\0'; // tell the user they entered an unknown command - ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Unknown command: %s\n", command ) ); + ClientPrint( &pEdict->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Unknown command: %s\n", command ) ); } } diff --git a/dlls/gamerules.cpp b/dlls/gamerules.cpp index bfbbf59ec7..79221ca631 100644 --- a/dlls/gamerules.cpp +++ b/dlls/gamerules.cpp @@ -325,6 +325,11 @@ CGameRules *InstallGameRules( void ) } else { + // Add new Deathmatch Commands + g_engfuncs.pfnAddServerCommand( "promote", SV_PromotePlayer_f ); + g_engfuncs.pfnAddServerCommand( "demote", SV_DemotePlayer_f ); + + if( teamplay.value > 0 ) { // teamplay @@ -345,3 +350,64 @@ CGameRules *InstallGameRules( void ) } } } + + +//========================================================= +// New Server Commands +//========================================================= + +void SV_PromotePlayer_f ( void ) +{ + if( g_engfuncs.pfnCmd_Argc() != 2 ) + { + g_engfuncs.pfnServerPrint("Usage: promote \n" ); + return; + } + + const char* p_user_search = g_engfuncs.pfnCmd_Argv( 1 ); + + CBasePlayer* p_plyr = UTIL_FindPlayerByName(p_user_search); + + if(p_plyr != NULL) + { + UTIL_LogPrintf("Promote: \"%s<%i><%s>\"\n" + , STRING(p_plyr->pev->netname) + , GETPLAYERUSERID( p_plyr->edict() ) + , GETPLAYERAUTHID( p_plyr->edict() )); + + p_plyr->m_privilege_elevated = TRUE; + } + else + { + g_engfuncs.pfnServerPrint("Player not found!\n" ); + } + +} + +void SV_DemotePlayer_f ( void ) +{ + if( g_engfuncs.pfnCmd_Argc() != 2 ) + { + g_engfuncs.pfnServerPrint("Usage: demote \n" ); + return; + } + + const char* p_user_search = g_engfuncs.pfnCmd_Argv( 1 ); + + CBasePlayer* p_plyr = UTIL_FindPlayerByName(p_user_search); + + if(p_plyr != NULL) + { + UTIL_LogPrintf("Demote: \"%s<%i><%s>\"\n" + , STRING(p_plyr->pev->netname) + , GETPLAYERUSERID( p_plyr->edict() ) + , GETPLAYERAUTHID( p_plyr->edict() )); + + p_plyr->m_privilege_elevated = FALSE; + } + else + { + g_engfuncs.pfnServerPrint("Player not found!\n" ); + } + +} \ No newline at end of file diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 781ef447fc..6f999a3092 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -165,6 +165,8 @@ class CGameRules }; extern CGameRules *InstallGameRules( void ); +extern void SV_PromotePlayer_f ( void ); +extern void SV_DemotePlayer_f ( void ); //========================================================= diff --git a/dlls/player.cpp b/dlls/player.cpp index cce57d02e3..7cab0bfe58 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3440,6 +3440,12 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) } CBaseEntity *pEntity; + + if(g_enable_cheats->value == 2 && m_privilege_elevated == FALSE) + { + return; + } + TraceResult tr; switch( iImpulse ) diff --git a/dlls/player.h b/dlls/player.h index d2f5d94587..be71621681 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -330,6 +330,8 @@ class CBasePlayer : public CBaseMonster Vector m_vecLastViewAngles; bool m_bSentBhopcap; // If false, the player just joined and needs a bhopcap message. + + BOOL m_privilege_elevated = false; // When set to true, the player can use cheats when sv_cheats is 2+. }; #define AUTOAIM_2DEGREES 0.0348994967025 diff --git a/dlls/util.cpp b/dlls/util.cpp index a7ab3ca4db..169516ccc0 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -579,6 +579,27 @@ CBaseEntity *UTIL_PlayerByIndex( int playerIndex ) return pPlayer; } +CBasePlayer* UTIL_FindPlayerByName (const char *p_search_name) +{ + for(int i=1; i<= gpGlobals->maxClients; i++) + { + edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex(i); + if(pEdict) + { + CBaseEntity *pEnt = CBaseEntity::Instance( pEdict ); + if(pEnt && pEnt->IsPlayer()) + { + const char *p_net_name = STRING(pEnt->pev->netname); + if( strcmp(p_net_name, p_search_name) == 0 ) + { + return (CBasePlayer*)pEnt; + } + } + } + } + return NULL; +} + void UTIL_MakeVectors( const Vector &vecAngles ) { MAKE_VECTORS( vecAngles ); diff --git a/dlls/util.h b/dlls/util.h index 6e3b2cca1b..5a80bb89c1 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -223,6 +223,7 @@ inline BOOL FClassnameIs(entvars_t* pev, const char* szClassname) } class CBaseEntity; +class CBasePlayer; // Misc. Prototypes extern void UTIL_SetSize (entvars_t* pev, const Vector &vecMin, const Vector &vecMax); @@ -241,6 +242,7 @@ extern CBaseEntity *UTIL_FindEntityGeneric(const char *szName, Vector &vecSrc, f // otherwise returns NULL // Index is 1 based extern CBaseEntity *UTIL_PlayerByIndex( int playerIndex ); +extern CBasePlayer *UTIL_FindPlayerByName ( const char *p_search_name ); #define UTIL_EntitiesInPVS(pent) (*g_engfuncs.pfnEntitiesInPVS)(pent) extern void UTIL_MakeVectors (const Vector &vecAngles); From 706fd6247f55d96c55e7e7d8adbcd68caef8e21e Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Wed, 27 Oct 2021 15:00:54 -0400 Subject: [PATCH 09/12] add give command parameter to spawn the object facing your direction and as far away as you'd like --- dlls/client.cpp | 20 ++++++++++++++++++-- dlls/player.cpp | 6 ++++++ dlls/player.h | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 3f135e63b8..45c6c4f700 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -499,8 +499,24 @@ void ClientCommand( edict_t *pEdict ) { if( g_enable_cheats->value == 1 || (g_enable_cheats->value == 2 && pPlayer->m_privilege_elevated) ) { - int iszItem = ALLOC_STRING( CMD_ARGV( 1 ) ); // Make a copy of the classname - pPlayer->GiveNamedItem( STRING( iszItem ) ); + if( CMD_ARGC() == 2 || CMD_ARGC() == 3) + { + int iszItem = ALLOC_STRING( CMD_ARGV( 1 ) ); + int units_ahead = 0; + if( CMD_ARGC() == 3 ) + units_ahead = atoi( CMD_ARGV ( 2 ) ); + + if( units_ahead == 0 ) + { + pPlayer->GiveNamedItem( STRING( iszItem ) ); + return; + } else if (units_ahead > 0) + { + pPlayer->CreateNamedItem( STRING( iszItem ) , units_ahead ); + return; + } + } + ClientPrint(&pEdict->v, HUD_PRINTCONSOLE, "Usage: give optional: . must be > 0.\n"); } } else if( FStrEq( pcmd, "fire" ) ) diff --git a/dlls/player.cpp b/dlls/player.cpp index 7cab0bfe58..9d6a481e96 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3270,6 +3270,12 @@ void CBasePlayer::GiveNamedItem( const char *pszName ) DispatchTouch( pent, ENT( pev ) ); } +void CBasePlayer::CreateNamedItem ( const char *pEntName, int units_ahead ) +{ + UTIL_MakeVectors( Vector( 0, pev->v_angle.y, 0 ) ); + Create( pEntName, pev->origin + gpGlobals->v_forward * units_ahead, pev->v_angle ); +} + CBaseEntity *FindEntityForward( CBaseEntity *pMe ) { TraceResult tr; diff --git a/dlls/player.h b/dlls/player.h index be71621681..0e3c087ea2 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -273,6 +273,7 @@ class CBasePlayer : public CBaseMonster void ItemPreFrame( void ); void ItemPostFrame( void ); void GiveNamedItem( const char *szName ); + void CreateNamedItem( const char *szName , int units_ahead ); void EnableControl(BOOL fControl); int GiveAmmo( int iAmount, const char *szName, int iMax ); From 1ef7adf66d32dacc4454e509815f7a13fa228f3d Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Thu, 28 Oct 2021 04:15:37 -0400 Subject: [PATCH 10/12] don't lock out a monster in a scripted sequence that has nothing left to do. Complete the scripted sequence. --- dlls/scripted.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index da495f98ba..73efd5958a 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -371,6 +371,9 @@ void CCineMonster::PossessEntity( void ) { pTarget->pev->framerate = 0; } + } else if ( m_fMoveTo == 4 && !m_iszPlay ) // Nothing else to do, so start an empty sequence so that the sequence completions can be fired off. + { + StartSequence( pTarget, 0, TRUE ); } } } From 6d698b5fc10b99cb833b73d5a2b0525f98669a89 Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Thu, 28 Oct 2021 05:09:22 -0400 Subject: [PATCH 11/12] Revert "don't lock out a monster in a scripted sequence that has nothing left to do. Complete the scripted sequence." This reverts commit 1ef7adf66d32dacc4454e509815f7a13fa228f3d. --- dlls/scripted.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index 73efd5958a..da495f98ba 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -371,9 +371,6 @@ void CCineMonster::PossessEntity( void ) { pTarget->pev->framerate = 0; } - } else if ( m_fMoveTo == 4 && !m_iszPlay ) // Nothing else to do, so start an empty sequence so that the sequence completions can be fired off. - { - StartSequence( pTarget, 0, TRUE ); } } } From a72c2c25756d528d61e44462c27c2a50c06f63ef Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Sat, 30 Oct 2021 11:31:15 -0400 Subject: [PATCH 12/12] sv_cheats 2 let unpriveleged users use baked-in cheat commands. Recreated those here under different names. Promote doesn't need sv_cheats anymore. --- dlls/client.cpp | 42 +++++++++++++++++++++++++++++++++++++++--- dlls/player.cpp | 7 +------ 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 45c6c4f700..823867c226 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -482,6 +482,7 @@ void ClientCommand( edict_t *pEdict ) entvars_t *pev = &pEdict->v; CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); + const bool p_can_cheat = g_enable_cheats->value == 1 || pPlayer->m_privilege_elevated; if( FStrEq( pcmd, "say" ) ) { @@ -497,7 +498,7 @@ void ClientCommand( edict_t *pEdict ) } else if( FStrEq(pcmd, "give" ) ) { - if( g_enable_cheats->value == 1 || (g_enable_cheats->value == 2 && pPlayer->m_privilege_elevated) ) + if( p_can_cheat ) { if( CMD_ARGC() == 2 || CMD_ARGC() == 3) { @@ -519,9 +520,44 @@ void ClientCommand( edict_t *pEdict ) ClientPrint(&pEdict->v, HUD_PRINTCONSOLE, "Usage: give optional: . must be > 0.\n"); } } + else if( FStrEq( pcmd, "fly" ) ) + { + if( pPlayer->m_privilege_elevated == FALSE ) return; + + if( pPlayer->pev->movetype != MOVETYPE_NOCLIP ) + { + ClientPrint(&pEdict->v, HUD_PRINTCONSOLE, "FLY ON.\n"); + pPlayer->pev->movetype = MOVETYPE_NOCLIP; + } + else + { + ClientPrint(&pEdict->v, HUD_PRINTCONSOLE, "FLY OFF.\n"); + pPlayer->pev->movetype = MOVETYPE_WALK; + } + return; + } + else if( FStrEq( pcmd, "nodamage" ) ) + { + if( pPlayer->m_privilege_elevated == FALSE ) return; + + pPlayer->pev->flags = pPlayer->pev->flags ^ FL_GODMODE; + + if( !FBitSet( pPlayer->pev->flags, FL_GODMODE ) ) + ClientPrint(&pEdict->v, HUD_PRINTCONSOLE, "NO DAMAGE OFF.\n"); + else ClientPrint(&pEdict->v, HUD_PRINTCONSOLE, "NO DAMAGE ON.\n"); + } + else if( FStrEq( pcmd, "noattack" ) ) + { + if( pPlayer->m_privilege_elevated == FALSE ) return; + pPlayer->pev->flags = pPlayer->pev->flags ^ FL_NOTARGET; + + if( !FBitSet( pPlayer->pev->flags, FL_NOTARGET ) ) + ClientPrint(&pEdict->v, HUD_PRINTCONSOLE, "NO ATTACK OFF.\n"); + else ClientPrint(&pEdict->v, HUD_PRINTCONSOLE, "NO ATTACK ON.\n"); + } else if( FStrEq( pcmd, "fire" ) ) { - if( g_enable_cheats->value == 1 || (g_enable_cheats->value == 2 && pPlayer->m_privilege_elevated) ) + if( p_can_cheat ) { CBaseEntity *pPlayer = CBaseEntity::Instance( pEdict ); if( CMD_ARGC() > 1 ) @@ -557,7 +593,7 @@ void ClientCommand( edict_t *pEdict ) } else if( FStrEq( pcmd, "fov" ) ) { - if( (g_enable_cheats->value == 1 || (g_enable_cheats->value == 2 && pPlayer->m_privilege_elevated) ) && CMD_ARGC() > 1 ) + if( p_can_cheat && CMD_ARGC() > 1 ) { pPlayer->m_iFOV = atoi( CMD_ARGV( 1 ) ); } diff --git a/dlls/player.cpp b/dlls/player.cpp index 9d6a481e96..e66e4a43b7 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3440,17 +3440,12 @@ void CBasePlayer::ImpulseCommands() void CBasePlayer::CheatImpulseCommands( int iImpulse ) { #if !HLDEMO_BUILD - if( g_enable_cheats->value == 0 ) + if( g_enable_cheats->value == 0 && m_privilege_elevated == FALSE ) { return; } CBaseEntity *pEntity; - - if(g_enable_cheats->value == 2 && m_privilege_elevated == FALSE) - { - return; - } TraceResult tr;