From 3915f097959b1e61922bdf619b4d9bffa811f35d Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Wed, 24 Oct 2018 15:16:47 +0200 Subject: [PATCH 1/8] Write unbindall when saving to settings.cfg to avoid unbound keys being restored by defaults on the next session --- src/engine/shared/config.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/shared/config.cpp b/src/engine/shared/config.cpp index f616a7269..14bcf8a82 100644 --- a/src/engine/shared/config.cpp +++ b/src/engine/shared/config.cpp @@ -113,6 +113,8 @@ public: char aLineBuf[1024*2]; char aEscapeBuf[1024*2]; + WriteLine("unbindall"); + #define MACRO_CONFIG_INT(Name,ScriptName,def,min,max,flags,desc) if(((flags)&(CFGFLAG_SAVE))&&((flags)&(m_FlagMask))){ str_format(aLineBuf, sizeof(aLineBuf), "%s %i", #ScriptName, g_Config.m_##Name); WriteLine(aLineBuf); } #define MACRO_CONFIG_STR(Name,ScriptName,len,def,flags,desc) if(((flags)&(CFGFLAG_SAVE))&&((flags)&(m_FlagMask))){ EscapeParam(aEscapeBuf, g_Config.m_##Name, sizeof(aEscapeBuf)); str_format(aLineBuf, sizeof(aLineBuf), "%s \"%s\"", #ScriptName, aEscapeBuf); WriteLine(aLineBuf); } From 6d694396fc512a60b2a851fef1ed76ecd2f9fafa Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Thu, 25 Oct 2018 19:25:22 +0200 Subject: [PATCH 2/8] When saving config, now unbinds every unbound key that was bound by default --- src/engine/shared/config.cpp | 2 - src/game/client/components/binds.cpp | 71 +++++++++++++++------------- src/game/client/components/binds.h | 4 ++ 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/engine/shared/config.cpp b/src/engine/shared/config.cpp index 14bcf8a82..f616a7269 100644 --- a/src/engine/shared/config.cpp +++ b/src/engine/shared/config.cpp @@ -113,8 +113,6 @@ public: char aLineBuf[1024*2]; char aEscapeBuf[1024*2]; - WriteLine("unbindall"); - #define MACRO_CONFIG_INT(Name,ScriptName,def,min,max,flags,desc) if(((flags)&(CFGFLAG_SAVE))&&((flags)&(m_FlagMask))){ str_format(aLineBuf, sizeof(aLineBuf), "%s %i", #ScriptName, g_Config.m_##Name); WriteLine(aLineBuf); } #define MACRO_CONFIG_STR(Name,ScriptName,len,def,flags,desc) if(((flags)&(CFGFLAG_SAVE))&&((flags)&(m_FlagMask))){ EscapeParam(aEscapeBuf, g_Config.m_##Name, sizeof(aEscapeBuf)); str_format(aLineBuf, sizeof(aLineBuf), "%s \"%s\"", #ScriptName, aEscapeBuf); WriteLine(aLineBuf); } diff --git a/src/game/client/components/binds.cpp b/src/game/client/components/binds.cpp index 7d6ee5ffd..8f6d78802 100644 --- a/src/game/client/components/binds.cpp +++ b/src/game/client/components/binds.cpp @@ -4,6 +4,27 @@ #include #include "binds.h" +const int CBinds::s_aDefaultBindKeys[] = { + KEY_F1, KEY_F2, KEY_TAB, 'u', KEY_F10, + 'a', 'd', + KEY_SPACE, KEY_MOUSE_1, KEY_MOUSE_2, KEY_LSHIFT, KEY_RSHIFT, KEY_RIGHT, KEY_LEFT, + '1', '2', '3', '4', '5', + KEY_MOUSE_WHEEL_UP, KEY_MOUSE_WHEEL_DOWN, + 't', 'y', 'x', + KEY_F3, KEY_F4, + 'r', +}; +const char CBinds::s_aaDefaultBindValues[][32] = { + "toggle_local_console", "toggle_remote_console", "+scoreboard", "+show_chat", "screenshot", + "+left", "+right", + "+jump", "+fire", "+hook", "+emote", "+spectate", "spectate_next", "spectate_previous", + "+weapon1", "+weapon2", "+weapon3", "+weapon4", "+weapon5", + "+prevweapon", "+nextweapon", + "chat all", "chat team", "chat whisper", + "vote yes", "vote no", + "ready_change", +}; + bool CBinds::CBindsSpecial::OnInput(IInput::CEvent Event) { // don't handle invalid events and keys that arn't set to anything @@ -86,40 +107,10 @@ void CBinds::SetDefaults() { // set default key bindings UnbindAll(); - Bind(KEY_F1, "toggle_local_console"); - Bind(KEY_F2, "toggle_remote_console"); - Bind(KEY_TAB, "+scoreboard"); - Bind('u', "+show_chat"); - Bind(KEY_F10, "screenshot"); - - Bind('a', "+left"); - Bind('d', "+right"); - - Bind(KEY_SPACE, "+jump"); - Bind(KEY_MOUSE_1, "+fire"); - Bind(KEY_MOUSE_2, "+hook"); - Bind(KEY_LSHIFT, "+emote"); - Bind(KEY_RSHIFT, "+spectate"); - Bind(KEY_RIGHT, "spectate_next"); - Bind(KEY_LEFT, "spectate_previous"); - - Bind('1', "+weapon1"); - Bind('2', "+weapon2"); - Bind('3', "+weapon3"); - Bind('4', "+weapon4"); - Bind('5', "+weapon5"); - - Bind(KEY_MOUSE_WHEEL_UP, "+prevweapon"); - Bind(KEY_MOUSE_WHEEL_DOWN, "+nextweapon"); - - Bind('t', "chat all"); - Bind('y', "chat team"); - Bind('x', "chat whisper"); - - Bind(KEY_F3, "vote yes"); - Bind(KEY_F4, "vote no"); - - Bind('r', "ready_change"); + const int count = sizeof(s_aDefaultBindKeys)/sizeof(int); + dbg_assert(count == sizeof(s_aaDefaultBindValues)/32, "the count of bind keys differs from that of bind values!"); + for(int i = 0; i < count; i++) + Bind(s_aDefaultBindKeys[i], s_aaDefaultBindValues[i]); } void CBinds::OnConsoleInit() @@ -224,6 +215,7 @@ void CBinds::ConfigSaveCallback(IConfig *pConfig, void *pUserData) { if(pSelf->m_aaKeyBindings[i][0] == 0) continue; + str_format(aBuffer, sizeof(aBuffer), "bind %s ", pSelf->Input()->KeyName(i)); // process the string. we need to escape some characters @@ -241,4 +233,15 @@ void CBinds::ConfigSaveCallback(IConfig *pConfig, void *pUserData) pConfig->WriteLine(aBuffer); } + + for(unsigned j = 0; j < sizeof(s_aDefaultBindKeys)/sizeof(int); j++) + { + const int i = s_aDefaultBindKeys[j]; + if(pSelf->m_aaKeyBindings[i][0] == 0) + { + // explicitly unbind keys that were unbound by the user + str_format(aBuffer, sizeof(aBuffer), "unbind %s ", pSelf->Input()->KeyName(i)); + pConfig->WriteLine(aBuffer); + } + } } diff --git a/src/game/client/components/binds.h b/src/game/client/components/binds.h index 7812242cf..3beb3d30b 100644 --- a/src/game/client/components/binds.h +++ b/src/game/client/components/binds.h @@ -39,5 +39,9 @@ public: virtual void OnConsoleInit(); virtual bool OnInput(IInput::CEvent Event); + +private: + static const int s_aDefaultBindKeys[]; + static const char s_aaDefaultBindValues[][32]; }; #endif From bbdaf1ea3a4c7a24da8cc0fb5bcce7aadaa4d7d7 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 27 Oct 2018 11:49:57 +0200 Subject: [PATCH 3/8] reduced pause between round in survival gametypes by half. #1558 --- src/game/server/gamecontroller.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/server/gamecontroller.h b/src/game/server/gamecontroller.h index ab4aa5626..9a48f1083 100644 --- a/src/game/server/gamecontroller.h +++ b/src/game/server/gamecontroller.h @@ -102,7 +102,7 @@ protected: int m_aTeamscore[NUM_TEAMS]; void EndMatch() { SetGameState(IGS_END_MATCH, TIMER_END); } - void EndRound() { SetGameState(IGS_END_ROUND, TIMER_END); } + void EndRound() { SetGameState(IGS_END_ROUND, TIMER_END/2); } // info int m_GameFlags; From fdcb2f26fb582af8a9252c56820fc25456be33d9 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 27 Oct 2018 11:51:23 +0200 Subject: [PATCH 4/8] switch to game start timer for the last 3 seconds of warmup to prevent 2 timers. #1567 --- src/game/server/gamecontroller.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index d6945396f..2834bdddc 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -746,6 +746,8 @@ void IGameController::Tick() // check if player ready mode was disabled and it waits that all players are ready -> end warmup if(!g_Config.m_SvPlayerReadyMode && m_GameStateTimer == TIMER_INFINITE) SetGameState(IGS_WARMUP_USER, 0); + else if(m_GameStateTimer == 3 * Server()->TickSpeed()) + StartRound(); break; case IGS_START_COUNTDOWN: case IGS_GAME_PAUSED: From 1c3607d9bdde1b5720c79cdda02eacd9f74af938 Mon Sep 17 00:00:00 2001 From: nheir Date: Sat, 27 Oct 2018 14:06:49 +0200 Subject: [PATCH 5/8] Fix unset network error message A malicious server can make crash a client on debug (and it seems the reverse is possible but I couldn't reproduce) --- datasrc/compile.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/datasrc/compile.py b/datasrc/compile.py index f16e73efc..1d937d256 100644 --- a/datasrc/compile.py +++ b/datasrc/compile.py @@ -316,8 +316,13 @@ if gen_network_source: lines += ['\tif(pUnpacker->Error())'] lines += ['\t\tm_pMsgFailedOn = "(unpack error)";'] lines += ['\t'] - lines += ['\tif(m_pMsgFailedOn || m_pObjFailedOn)'] + lines += ['\tif(m_pMsgFailedOn || m_pObjFailedOn) {'] + lines += ['\t\tif(!m_pMsgFailedOn)'] + lines += ['\t\t\tm_pMsgFailedOn = "";'] + lines += ['\t\tif(!m_pObjFailedOn)'] + lines += ['\t\t\tm_pObjFailedOn = "";'] lines += ['\t\treturn 0;'] + lines += ['\t}'] lines += ['\tm_pMsgFailedOn = "";'] lines += ['\tm_pObjFailedOn = "";'] lines += ['\treturn m_aMsgData;'] From 6410f26c701ccedaf68b7ea88e2228afd0f42f73 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 27 Oct 2018 16:24:42 +0200 Subject: [PATCH 6/8] check for valid game message id (#1572) --- src/game/client/gameclient.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 2edbce7a2..4c5c53316 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -496,6 +496,10 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker) { int GameMsgID = pUnpacker->GetInt(); + // check for valid gamemsgid + if(GameMsgID < 0 || GameMsgID >= NUM_GAMEMSGS) + return; + int aParaI[3]; int NumParaI = 0; From 6bea95dbfa2955fce9ab8d85ba32e976e785bfd1 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 27 Oct 2018 17:48:47 +0200 Subject: [PATCH 7/8] fixed some warnings --- src/game/client/components/chat.cpp | 2 +- src/game/client/components/menus_browser.cpp | 2 +- src/game/client/components/menus_settings.cpp | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index f133769c4..5123ef1ae 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -430,7 +430,7 @@ void CChat::AddLine(int ClientID, int Mode, const char *pLine) { int Length = str_length(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_aName); if((pLine == pHL || pHL[-1] == ' ') // space or nothing before - && ((pHL[Length] == 0 || pHL[Length] == ' ') || pHL[Length] == ':' && (pHL[Length+1] == 0) || pHL[Length+1] == ' ')) // space or nothing after, allowing a colon + && (((pHL[Length] == 0 || pHL[Length] == ' ') || pHL[Length] == ':') && (pHL[Length+1] == 0 || pHL[Length+1] == ' '))) // space or nothing after, allowing a colon { Highlighted = true; } diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index cd6093a7e..f081f9800 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -135,7 +135,7 @@ void CMenus::CBrowserFilter::SetFilter(const CServerFilterInfo *pFilterInfo) void CMenus::LoadFilters() { // read file data into buffer - char *pFilename = "ui_settings.json"; + const char *pFilename = "ui_settings.json"; IOHANDLE File = Storage()->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL); if(!File) return; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 49838e8ed..4c0b69aa2 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1236,7 +1236,6 @@ bool CMenus::DoResolutionList(CUIRect* pRect, CListBoxState* pListBoxState, void CMenus::RenderSettingsGraphics(CUIRect MainView) { - char aBuf[128]; bool CheckSettings = false; static int s_GfxScreenWidth = g_Config.m_GfxScreenWidth; From fd99a6f7c952f9d643a4d7890a81401973c77b7d Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 27 Oct 2018 17:51:19 +0200 Subject: [PATCH 8/8] fixed the delete friend button in the friends browser #1571 --- src/game/client/components/menus_browser.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index f081f9800..6db92c0f8 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -2100,8 +2100,7 @@ void CMenus::DoFriendListEntry(CUIRect *pView, CFriendItem *pFriend, const void { // delete button Button.Margin(1.0f, &Button); - static int s_DeleteButton = 0; - if(DoButton_SpriteCleanID(&s_DeleteButton, IMAGE_FRIENDICONS, pFriend->IsClanFriend() ? SPRITE_FRIEND_X_A : SPRITE_FRIEND_X_B, &Button, false)) + if(DoButton_SpriteClean(IMAGE_FRIENDICONS, pFriend->IsClanFriend() ? SPRITE_FRIEND_X_A : SPRITE_FRIEND_X_B, &Button)) { m_pDeleteFriendInfo = pFriend->m_pFriendInfo; }