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/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); } 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]; diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 5101a4c4b..b1ed7c22c 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -227,11 +227,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; } 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); 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 diff --git a/src/game/server/entities/dragger.cpp b/src/game/server/entities/dragger.cpp index 3f135d2bc..89373eb92 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; } @@ -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..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(); @@ -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