From 527859e70c1ca610cf87853c1cbf7c1d7d1b4e9f Mon Sep 17 00:00:00 2001 From: def Date: Sun, 7 Apr 2019 23:28:30 +0200 Subject: [PATCH 1/7] Fix home/end keys in console --- src/game/client/components/console.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index f7afd19b2..80ca3a4ca 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -220,11 +220,13 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event) if(m_BacklogActPage < 0) m_BacklogActPage = 0; } - else if(Event.m_Key == KEY_HOME) + // in order not to conflict with CLineInput's handling of Home/End only + // react to it when the input is empty + else if(Event.m_Key == KEY_HOME && m_Input.GetString()[0] == '\0') { m_BacklogActPage = INT_MAX; } - else if(Event.m_Key == KEY_END) + else if(Event.m_Key == KEY_END && m_Input.GetString()[0] == '\0') { m_BacklogActPage = 0; } From ea093f6d3945ec0dc4c23f7ab70223181054c933 Mon Sep 17 00:00:00 2001 From: def Date: Mon, 8 Apr 2019 16:55:53 +0200 Subject: [PATCH 2/7] 2 more tries to force DB to respond in UTF8 (fixes #1599) --- src/engine/server/sql_server.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/server/sql_server.cpp b/src/engine/server/sql_server.cpp index da59dfb57..d9a3c6ec0 100644 --- a/src/engine/server/sql_server.cpp +++ b/src/engine/server/sql_server.cpp @@ -112,6 +112,7 @@ bool CSqlServer::Connect() connection_properties["OPT_WRITE_TIMEOUT"] = 20; connection_properties["OPT_RECONNECT"] = true; connection_properties["OPT_CHARSET_NAME"] = sql::SQLString("utf8mb4"); + connection_properties["OPT_SET_CHARSET_NAME"] = sql::SQLString("utf8mb4"); // Create connection { @@ -123,6 +124,9 @@ bool CSqlServer::Connect() // Create Statement m_pStatement = m_pConnection->createStatement(); + // Apparently OPT_CHARSET_NAME and OPT_SET_CHARSET_NAME are not enough + m_pStatement->execute("SET CHARACTER SET utf8mb4;"); + if (m_SetUpDB) { char aBuf[128]; From 173b43d487133546bb3657de13168b5fdcdf2c54 Mon Sep 17 00:00:00 2001 From: def Date: Mon, 8 Apr 2019 21:54:12 +0200 Subject: [PATCH 3/7] Fix memory leak in draggers --- src/game/server/entities/dragger.cpp | 15 ++++++++------- src/game/server/entities/dragger.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/game/server/entities/dragger.cpp b/src/game/server/entities/dragger.cpp index 1102a8d0c..c47956a32 100644 --- a/src/game/server/entities/dragger.cpp +++ b/src/game/server/entities/dragger.cpp @@ -392,13 +392,14 @@ CDraggerTeam::CDraggerTeam(CGameWorld *pGameWorld, vec2 Pos, float Strength, { for (int i = 0; i < MAX_CLIENTS; ++i) { - m_Draggers[i] = new CDragger(pGameWorld, Pos, Strength, NW, i, Layer, - Number); + m_Draggers[i] = new CDragger(pGameWorld, Pos, Strength, NW, i, Layer, Number); } } -//CDraggerTeam::~CDraggerTeam() { -//for(int i = 0; i < MAX_CLIENTS; ++i) { -// delete m_Draggers[i]; -//} -//} +CDraggerTeam::~CDraggerTeam() +{ + for (int i = 0; i < MAX_CLIENTS; ++i) + { + delete m_Draggers[i]; + } +} diff --git a/src/game/server/entities/dragger.h b/src/game/server/entities/dragger.h index 13c838f72..432fcadcb 100644 --- a/src/game/server/entities/dragger.h +++ b/src/game/server/entities/dragger.h @@ -36,7 +36,7 @@ public: CDraggerTeam(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW = false, int Layer = 0, int Number = 0); - //~CDraggerTeam(); + ~CDraggerTeam(); }; #endif // GAME_SERVER_ENTITIES_DRAGGER_H From 708019c675c5081275486dd2addb969da94fe38f Mon Sep 17 00:00:00 2001 From: def Date: Mon, 8 Apr 2019 21:54:33 +0200 Subject: [PATCH 4/7] Grammar fix: Catched -> Caught --- src/game/server/entities/dragger.cpp | 14 +++++++------- src/game/server/entities/dragger.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/game/server/entities/dragger.cpp b/src/game/server/entities/dragger.cpp index c47956a32..34746cf64 100644 --- a/src/game/server/entities/dragger.cpp +++ b/src/game/server/entities/dragger.cpp @@ -9,7 +9,7 @@ #include "dragger.h" CDragger::CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW, - int CatchedTeam, int Layer, int Number) : + int CaughtTeam, int Layer, int Number) : CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER) { m_Layer = Layer; @@ -18,7 +18,7 @@ CDragger::CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW, m_Strength = Strength; m_EvalTick = Server()->Tick(); m_NW = NW; - m_CatchedTeam = CatchedTeam; + m_CaughtTeam = CaughtTeam; GameWorld()->InsertEntity(this); for (int i = 0; i < MAX_CLIENTS; i++) @@ -48,7 +48,7 @@ void CDragger::Move() for (int i = 0; i < Num; i++) { Temp = m_SoloEnts[i]; - if (Temp->Team() != m_CatchedTeam) + if (Temp->Team() != m_CaughtTeam) { m_SoloEnts[i] = 0; continue; @@ -259,7 +259,7 @@ void CDragger::Reset() void CDragger::Tick() { if (((CGameControllerDDRace*) GameServer()->m_pController)->m_Teams.GetTeamState( - m_CatchedTeam) == CGameTeams::TEAMSTATE_EMPTY) + m_CaughtTeam) == CGameTeams::TEAMSTATE_EMPTY) return; if (Server()->Tick() % int(Server()->TickSpeed() * 0.15f) == 0) { @@ -282,7 +282,7 @@ void CDragger::Tick() void CDragger::Snap(int SnappingClient) { if (((CGameControllerDDRace*) GameServer()->m_pController)->m_Teams.GetTeamState( - m_CatchedTeam) == CGameTeams::TEAMSTATE_EMPTY) + m_CaughtTeam) == CGameTeams::TEAMSTATE_EMPTY) return; CCharacter *Target = m_Target; @@ -332,13 +332,13 @@ void CDragger::Snap(int SnappingClient) continue; if (Char && Char->IsAlive()) { - if (Char->Team() != m_CatchedTeam) + if (Char->Team() != m_CaughtTeam) continue; } else { // send to spectators only active draggers and some inactive from team 0 - if (!((Target && Target->IsAlive()) || m_CatchedTeam == 0)) + if (!((Target && Target->IsAlive()) || m_CaughtTeam == 0)) continue; } diff --git a/src/game/server/entities/dragger.h b/src/game/server/entities/dragger.h index 432fcadcb..8036aec01 100644 --- a/src/game/server/entities/dragger.h +++ b/src/game/server/entities/dragger.h @@ -14,14 +14,14 @@ class CDragger: public CEntity void Drag(); CCharacter * m_Target; bool m_NW; - int m_CatchedTeam; + int m_CaughtTeam; CCharacter * m_SoloEnts[MAX_CLIENTS]; int m_SoloIDs[MAX_CLIENTS]; public: CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW, - int CatchedTeam, int Layer = 0, int Number = 0); + int CaughtTeam, int Layer = 0, int Number = 0); virtual void Reset(); virtual void Tick(); From c3e36ee483f4843ab2314edefdb68cb9af60b16e Mon Sep 17 00:00:00 2001 From: def Date: Mon, 8 Apr 2019 22:13:47 +0200 Subject: [PATCH 5/7] Always initialize m_InfosLoaded --- src/game/client/components/menus_demo.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index b83878231..6c466aa56 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -690,6 +690,7 @@ int CMenus::DemolistFetchCallback(const char *pName, time_t Date, int IsDir, int if(IsDir) { str_format(Item.m_aName, sizeof(Item.m_aName), "%s/", pName); + Item.m_InfosLoaded = false; Item.m_Valid = false; } else From 0e7a514c7b3ad7e775b22b9cd476d9bfd896f63c Mon Sep 17 00:00:00 2001 From: def Date: Tue, 9 Apr 2019 21:58:04 +0200 Subject: [PATCH 6/7] Fix C90 compatibility on Windows --- src/base/system.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/base/system.c b/src/base/system.c index 7d65b7955..5d51399d8 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -171,27 +171,29 @@ static void logger_file(const char *line, void *user) #if defined(CONF_FAMILY_WINDOWS) static void logger_stdout_sync(const char *line, void *user) { - (void)user; - size_t length = strlen(line); wchar_t *wide = malloc(length * sizeof (*wide)); - mem_zero(wide, length * sizeof *wide); - const char *p = line; int wlen = 0; + HANDLE console; + + (void)user; + mem_zero(wide, length * sizeof *wide); + for(int codepoint = 0; (codepoint = str_utf8_decode(&p)); wlen++) { + char u16[4] = {0}; + if(codepoint < 0) return; - char u16[4] = {0}; if(str_utf16le_encode(u16, codepoint) != 2) return; mem_copy(&wide[wlen], u16, 2); } - HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); + console = GetStdHandle(STD_OUTPUT_HANDLE); WriteConsoleW(console, wide, wlen, NULL, NULL); WriteConsoleA(console, "\n", 1, NULL, NULL); } From fe432b8ae48ffa5a2d88337121f14ad958b43529 Mon Sep 17 00:00:00 2001 From: def Date: Tue, 9 Apr 2019 21:42:24 +0200 Subject: [PATCH 7/7] Enable a few more GCC warnings --- CMakeLists.txt | 5 +++++ src/game/client/components/menus.cpp | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d951b0863..091eb2039 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,6 +168,11 @@ if(NOT MSVC) add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wno-missing-field-initializers) add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wformat=2) # Warn about format strings. add_c_compiler_flag_if_supported(OUR_FLAGS_DEP -Wno-implicit-function-declaration) + add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wduplicated-cond) + add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wduplicated-branches) + add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wlogical-op) + add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wrestrict) + add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wuseless-cast) endif() if(NOT MSVC) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index f05aaeec1..5ea367bd1 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1058,8 +1058,6 @@ int CMenus::Render() RenderServerControl(MainView); else if(m_GamePage == PAGE_SETTINGS) RenderSettings(MainView); - else if(m_GamePage == PAGE_GHOST) - RenderGhost(MainView); } else if(g_Config.m_UiPage == PAGE_NEWS) RenderNews(MainView);