From 9a5ee2cdbf86057554e645b900bf62a5e88b2f37 Mon Sep 17 00:00:00 2001 From: def Date: Sat, 5 Sep 2020 23:15:14 +0200 Subject: [PATCH] Auto-bind F7 to show server console if it's free --- src/engine/shared/config_variables.h | 3 +- src/game/client/components/binds.cpp | 71 +++++++++++++++------------- src/game/client/gameclient.cpp | 3 +- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 318fd4613..95970eb10 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -182,8 +182,7 @@ MACRO_CONFIG_INT(SvHit, sv_hit, 1, 0, 1, CFGFLAG_SERVER|CFGFLAG_GAME, "Whether p MACRO_CONFIG_INT(SvEndlessDrag, sv_endless_drag, 0, 0, 1, CFGFLAG_SERVER|CFGFLAG_GAME, "Turns endless hooking on/off") MACRO_CONFIG_INT(SvTestingCommands, sv_test_cmds, 0, 0, 1, CFGFLAG_SERVER, "Turns testing commands aka cheats on/off (setting only works in initial config)") MACRO_CONFIG_INT(SvFreezeDelay, sv_freeze_delay, 3, 1, 30, CFGFLAG_SERVER|CFGFLAG_GAME, "How many seconds the players will remain frozen (applies to all except delayed freeze in switch layer & deepfreeze)") -MACRO_CONFIG_INT(ClDDRaceBinds, cl_race_binds, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Enable Default DDRace builds when pressing the reset binds button") -MACRO_CONFIG_INT(ClDDRaceBindsSet, cl_race_binds_set, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Whether the DDRace binds set or not (this is automated you don't need to use this)") +MACRO_CONFIG_INT(ClDDRaceBindsSet, cl_race_binds_set, 0, 0, 2, CFGFLAG_CLIENT|CFGFLAG_SAVE, "What level the DDRace binds are set to (this is automated, you don't need to use this)") MACRO_CONFIG_INT(SvEndlessSuperHook, sv_endless_super_hook, 0, 0, 1, CFGFLAG_SERVER, "Endless hook for super players on/off") MACRO_CONFIG_INT(SvHideScore, sv_hide_score, 0, 0, 1, CFGFLAG_SERVER, "Whether players scores will be announced or not") MACRO_CONFIG_INT(SvSaveWorseScores, sv_save_worse_scores, 1, 0, 1, CFGFLAG_SERVER|CFGFLAG_GAME, "Whether to save worse scores when you already have a better one") diff --git a/src/game/client/components/binds.cpp b/src/game/client/components/binds.cpp index c03280597..7fc8538bd 100644 --- a/src/game/client/components/binds.cpp +++ b/src/game/client/components/binds.cpp @@ -252,9 +252,8 @@ void CBinds::SetDefaults() Bind(KEY_P, "say /pause"); // DDRace - - if(g_Config.m_ClDDRaceBinds) - SetDDRaceBinds(false); + g_Config.m_ClDDRaceBindsSet = 0; + SetDDRaceBinds(false); } void CBinds::OnConsoleInit() @@ -447,34 +446,42 @@ void CBinds::ConfigSaveCallback(IConfig *pConfig, void *pUserData) void CBinds::SetDDRaceBinds(bool FreeOnly) { - Bind(KEY_KP_PLUS, "zoom+", FreeOnly); - Bind(KEY_KP_MINUS, "zoom-", FreeOnly); - Bind(KEY_KP_MULTIPLY, "zoom", FreeOnly); - Bind(KEY_PAUSE, "say /pause", FreeOnly); - Bind(KEY_UP, "+jump", FreeOnly); - Bind(KEY_LEFT, "+left", FreeOnly); - Bind(KEY_RIGHT, "+right", FreeOnly); - Bind(KEY_LEFTBRACKET, "+prevweapon", FreeOnly); - Bind(KEY_RIGHTBRACKET, "+nextweapon", FreeOnly); - Bind(KEY_C, "say /rank", FreeOnly); - Bind(KEY_V, "say /info", FreeOnly); - Bind(KEY_B, "say /top5", FreeOnly); - Bind(KEY_X, "emote 14", FreeOnly); - Bind(KEY_H, "emote 2", FreeOnly); - Bind(KEY_M, "emote 5", FreeOnly); - Bind(KEY_S, "+showhookcoll", FreeOnly); - Bind(KEY_X, "toggle cl_dummy 0 1", FreeOnly); - Bind(KEY_PAGEDOWN, "toggle cl_show_quads 0 1", FreeOnly); - Bind(KEY_PAGEUP, "toggle cl_overlay_entities 0 100", FreeOnly); - Bind(KEY_KP_0, "say /emote normal 999999", FreeOnly); - Bind(KEY_KP_1, "say /emote happy 999999", FreeOnly); - Bind(KEY_KP_2, "say /emote angry 999999", FreeOnly); - Bind(KEY_KP_3, "say /emote pain 999999", FreeOnly); - Bind(KEY_KP_4, "say /emote surprise 999999", FreeOnly); - Bind(KEY_KP_5, "say /emote blink 999999", FreeOnly); - Bind(KEY_MOUSE_3, "+spectate", FreeOnly); - Bind(KEY_MINUS, "spectate_previous", FreeOnly); - Bind(KEY_EQUALS, "spectate_next", FreeOnly); + if(g_Config.m_ClDDRaceBindsSet < 2) + { + Bind(KEY_F7, "toggle_server_console", FreeOnly); + } - g_Config.m_ClDDRaceBindsSet = 1; + if(g_Config.m_ClDDRaceBindsSet < 1) + { + Bind(KEY_KP_PLUS, "zoom+", FreeOnly); + Bind(KEY_KP_MINUS, "zoom-", FreeOnly); + Bind(KEY_KP_MULTIPLY, "zoom", FreeOnly); + Bind(KEY_PAUSE, "say /pause", FreeOnly); + Bind(KEY_UP, "+jump", FreeOnly); + Bind(KEY_LEFT, "+left", FreeOnly); + Bind(KEY_RIGHT, "+right", FreeOnly); + Bind(KEY_LEFTBRACKET, "+prevweapon", FreeOnly); + Bind(KEY_RIGHTBRACKET, "+nextweapon", FreeOnly); + Bind(KEY_C, "say /rank", FreeOnly); + Bind(KEY_V, "say /info", FreeOnly); + Bind(KEY_B, "say /top5", FreeOnly); + Bind(KEY_X, "emote 14", FreeOnly); + Bind(KEY_H, "emote 2", FreeOnly); + Bind(KEY_M, "emote 5", FreeOnly); + Bind(KEY_S, "+showhookcoll", FreeOnly); + Bind(KEY_X, "toggle cl_dummy 0 1", FreeOnly); + Bind(KEY_PAGEDOWN, "toggle cl_show_quads 0 1", FreeOnly); + Bind(KEY_PAGEUP, "toggle cl_overlay_entities 0 100", FreeOnly); + Bind(KEY_KP_0, "say /emote normal 999999", FreeOnly); + Bind(KEY_KP_1, "say /emote happy 999999", FreeOnly); + Bind(KEY_KP_2, "say /emote angry 999999", FreeOnly); + Bind(KEY_KP_3, "say /emote pain 999999", FreeOnly); + Bind(KEY_KP_4, "say /emote surprise 999999", FreeOnly); + Bind(KEY_KP_5, "say /emote blink 999999", FreeOnly); + Bind(KEY_MOUSE_3, "+spectate", FreeOnly); + Bind(KEY_MINUS, "spectate_previous", FreeOnly); + Bind(KEY_EQUALS, "spectate_next", FreeOnly); + } + + g_Config.m_ClDDRaceBindsSet = 2; } diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 40bcf5e4b..1a1371dc6 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -332,8 +332,7 @@ void CGameClient::OnInit() m_ShowOthers[1] = -1; // Set free binds to DDRace binds if it's active - if(!g_Config.m_ClDDRaceBindsSet && g_Config.m_ClDDRaceBinds) - gs_Binds.SetDDRaceBinds(true); + gs_Binds.SetDDRaceBinds(true); if(g_Config.m_ClTimeoutCode[0] == '\0' || str_comp(g_Config.m_ClTimeoutCode, "hGuEYnfxicsXGwFq") == 0) {