mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
2923: Don't str_copy into string itself r=Learath2 a=def- when reconnecting after server was full: [2020-09-25 15:39:34][client]: offline error='This server is full' Source and destination overlap in strncpy(0xd3328e2, 0xd3328e2, 255) at 0x483DFDC: strncpy (vg_replace_strmem.c:550) by 0x249180: str_copy (system.c:2328) by 0x27E1F5: CClient::Connect(char const*, char const*) (client.cpp:707) by 0x287864: CClient::Update() (client.cpp:2914) by 0x28891B: CClient::Run() (client.cpp:3216) by 0x28EDEC: main (client.cpp:4309) 2924: Fix Score/Time alignment r=def- a=Learath2 ![screenshot_2020-09-25_16-52-30](https://user-images.githubusercontent.com/490500/94275676-e81dfc80-ff4f-11ea-9f21-dbf5d1cf73a9.png) Also adds hours to the time Co-authored-by: def <dennis@felsin9.de> Co-authored-by: Learath <learath2@gmail.com>
This commit is contained in:
commit
5f6ba345b8
|
@ -704,6 +704,7 @@ void CClient::Connect(const char *pAddress, const char *pPassword)
|
|||
Disconnect();
|
||||
|
||||
m_ConnectionID = RandomUuid();
|
||||
if(pAddress != m_aServerAddressStr)
|
||||
str_copy(m_aServerAddressStr, pAddress, sizeof(m_aServerAddressStr));
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "connecting to '%s'", m_aServerAddressStr);
|
||||
|
|
|
@ -285,8 +285,14 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
RoundRadius = 15.0f;
|
||||
}
|
||||
|
||||
float ScoreOffset = x+10.0f, ScoreLength = TextRender()->TextWidth(0, 22.0f/*HeadlineFontsize*/, "00:00:0", -1, -1.0f);
|
||||
float TeeOffset = ScoreOffset+ScoreLength, TeeLength = 60*TeeSizeMod;
|
||||
float FontSize = 24.0f;
|
||||
if(m_pClient->m_Snap.m_aTeamSize[Team] > 48)
|
||||
FontSize = 16.0f;
|
||||
else if(m_pClient->m_Snap.m_aTeamSize[Team] > 32)
|
||||
FontSize = 20.0f;
|
||||
|
||||
float ScoreOffset = x + 10.0f, ScoreLength = TextRender()->TextWidth(0, FontSize, "00:00:00", -1, -1.0f);
|
||||
float TeeOffset = ScoreOffset + ScoreLength + 15.0f, TeeLength = 60 * TeeSizeMod;
|
||||
float NameOffset = TeeOffset + TeeLength, NameLength = 300.0f - TeeLength;
|
||||
float PingOffset = x + 610.0f, PingLength = 65.0f;
|
||||
float CountryOffset = PingOffset - (LineHeight - Spacing - TeeSizeMod * 5.0f) * 2.0f, CountryLength = (LineHeight - Spacing - TeeSizeMod * 5.0f) * 2.0f;
|
||||
|
@ -296,8 +302,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
y += 50.0f;
|
||||
float HeadlineFontsize = 22.0f;
|
||||
const char *pScore = (m_pClient->m_GameInfo.m_TimeScore && g_Config.m_ClDDRaceScoreBoard) ? Localize("Time") : Localize("Score");
|
||||
float ScoreWidth = TextRender()->TextWidth(0, HeadlineFontsize, pScore, -1, -1.0f);
|
||||
tw = ScoreLength > ScoreWidth ? ScoreLength : ScoreWidth;
|
||||
tw = TextRender()->TextWidth(0, HeadlineFontsize, pScore, -1, -1.0f);
|
||||
TextRender()->Text(0, ScoreOffset + ScoreLength - tw, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, pScore, -1.0f);
|
||||
|
||||
TextRender()->Text(0, NameOffset, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Name"), -1.0f);
|
||||
|
@ -310,11 +315,6 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
|
||||
// render player entries
|
||||
y += HeadlineFontsize * 2.0f;
|
||||
float FontSize = 24.0f;
|
||||
if(m_pClient->m_Snap.m_aTeamSize[Team] > 48)
|
||||
FontSize = 16.0f;
|
||||
else if(m_pClient->m_Snap.m_aTeamSize[Team] > 32)
|
||||
FontSize = 20.0f;
|
||||
CTextCursor Cursor;
|
||||
|
||||
int rendered = 0;
|
||||
|
@ -422,6 +422,9 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
else
|
||||
{
|
||||
int Time = abs(pInfo->m_Score);
|
||||
if(Time / 3600)
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%02d:%02d", Time / 3600, (Time / 60) % 60, Time % 60);
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%02d", Time / 60, Time % 60);
|
||||
}
|
||||
}
|
||||
|
@ -464,9 +467,8 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
if(g_Config.m_ClShowIDs)
|
||||
{
|
||||
char aId[64] = "";
|
||||
str_format(aId, sizeof(aId)," %2d: ", pInfo->m_ClientID);
|
||||
str_append(aId, m_pClient->m_aClients[pInfo->m_ClientID].m_aName,sizeof(aId));
|
||||
Cursor.m_LineWidth = NameLength+8;
|
||||
str_format(aId, sizeof(aId), "%2d: %s", pInfo->m_ClientID, m_pClient->m_aClients[pInfo->m_ClientID].m_aName);
|
||||
Cursor.m_LineWidth = NameLength;
|
||||
TextRender()->TextEx(&Cursor, aId, -1);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue