1598: Fix home/end keys in console r=heinrich5991 a=def-



1601: 2 more tries to force DB to respond in UTF8 (fixes #1599) r=heinrich5991 a=def-



1605: Fix memory leak in draggers r=heinrich5991 a=def-



1606: Always initialize m_InfosLoaded r=heinrich5991 a=def-

otherwise it's uninitialized and then read, found by valgrind --tool=memcheck

1607: Enable a few more GCC warnings r=heinrich5991 a=def-



1609: Fix C90 compatibility on Windows r=heinrich5991 a=def-



Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2019-04-09 22:09:18 +00:00
8 changed files with 40 additions and 27 deletions

View file

@ -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)

View file

@ -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);
}

View file

@ -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];

View file

@ -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;
}

View file

@ -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);

View file

@ -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

View file

@ -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];
}
}

View file

@ -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