mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Merge pull request #1895 from Dune-jr/adjust-uid-msgdisplay
Adjust chat messages to not display UID when option is turned off
This commit is contained in:
commit
7447482152
|
@ -179,11 +179,12 @@ void CVoting::OnMessage(int MsgType, void *pRawMsg)
|
||||||
m_Closetime = time_get() + time_freq() * pMsg->m_Timeout;
|
m_Closetime = time_get() + time_freq() * pMsg->m_Timeout;
|
||||||
if(pMsg->m_ClientID != -1)
|
if(pMsg->m_ClientID != -1)
|
||||||
{
|
{
|
||||||
|
char aLabel[64];
|
||||||
|
CGameClient::GetPlayerLabel(aLabel, sizeof(aLabel), pMsg->m_ClientID, m_pClient->m_aClients[pMsg->m_ClientID].m_aName);
|
||||||
switch(pMsg->m_Type)
|
switch(pMsg->m_Type)
|
||||||
{
|
{
|
||||||
case VOTE_START_OP:
|
case VOTE_START_OP:
|
||||||
str_format(aBuf, sizeof(aBuf), Localize("'%2d: %s' called vote to change server option '%s' (%s)"), pMsg->m_ClientID,
|
str_format(aBuf, sizeof(aBuf), Localize("'%s' called vote to change server option '%s' (%s)"), aLabel, pMsg->m_pDescription, pMsg->m_pReason);
|
||||||
g_Config.m_ClShowsocial ? m_pClient->m_aClients[pMsg->m_ClientID].m_aName : "", pMsg->m_pDescription, pMsg->m_pReason);
|
|
||||||
str_copy(m_aDescription, pMsg->m_pDescription, sizeof(m_aDescription));
|
str_copy(m_aDescription, pMsg->m_pDescription, sizeof(m_aDescription));
|
||||||
m_pClient->m_pChat->AddLine(-1, 0, aBuf);
|
m_pClient->m_pChat->AddLine(-1, 0, aBuf);
|
||||||
break;
|
break;
|
||||||
|
@ -192,8 +193,7 @@ void CVoting::OnMessage(int MsgType, void *pRawMsg)
|
||||||
char aName[4];
|
char aName[4];
|
||||||
if(!g_Config.m_ClShowsocial)
|
if(!g_Config.m_ClShowsocial)
|
||||||
str_copy(aName, pMsg->m_pDescription, sizeof(aName));
|
str_copy(aName, pMsg->m_pDescription, sizeof(aName));
|
||||||
str_format(aBuf, sizeof(aBuf), Localize("'%2d: %s' called for vote to kick '%s' (%s)"), pMsg->m_ClientID,
|
str_format(aBuf, sizeof(aBuf), Localize("'%s' called for vote to kick '%s' (%s)"), aLabel, g_Config.m_ClShowsocial ? pMsg->m_pDescription : aName, pMsg->m_pReason);
|
||||||
g_Config.m_ClShowsocial ? m_pClient->m_aClients[pMsg->m_ClientID].m_aName : "", g_Config.m_ClShowsocial ? pMsg->m_pDescription : aName, pMsg->m_pReason);
|
|
||||||
str_format(m_aDescription, sizeof(m_aDescription), "Kick '%s'", g_Config.m_ClShowsocial ? pMsg->m_pDescription : aName);
|
str_format(m_aDescription, sizeof(m_aDescription), "Kick '%s'", g_Config.m_ClShowsocial ? pMsg->m_pDescription : aName);
|
||||||
m_pClient->m_pChat->AddLine(-1, 0, aBuf);
|
m_pClient->m_pChat->AddLine(-1, 0, aBuf);
|
||||||
break;
|
break;
|
||||||
|
@ -203,8 +203,7 @@ void CVoting::OnMessage(int MsgType, void *pRawMsg)
|
||||||
char aName[4];
|
char aName[4];
|
||||||
if(!g_Config.m_ClShowsocial)
|
if(!g_Config.m_ClShowsocial)
|
||||||
str_copy(aName, pMsg->m_pDescription, sizeof(aName));
|
str_copy(aName, pMsg->m_pDescription, sizeof(aName));
|
||||||
str_format(aBuf, sizeof(aBuf), Localize("'%2d: %s' called for vote to move '%s' to spectators (%s)"), pMsg->m_ClientID,
|
str_format(aBuf, sizeof(aBuf), Localize("'%s' called for vote to move '%s' to spectators (%s)"), aLabel, g_Config.m_ClShowsocial ? pMsg->m_pDescription : aName, pMsg->m_pReason);
|
||||||
g_Config.m_ClShowsocial ? m_pClient->m_aClients[pMsg->m_ClientID].m_aName : "", g_Config.m_ClShowsocial ? pMsg->m_pDescription : aName, pMsg->m_pReason);
|
|
||||||
str_format(m_aDescription, sizeof(m_aDescription), "Move '%s' to spectators", g_Config.m_ClShowsocial ? pMsg->m_pDescription : aName);
|
str_format(m_aDescription, sizeof(m_aDescription), "Move '%s' to spectators", g_Config.m_ClShowsocial ? pMsg->m_pDescription : aName);
|
||||||
m_pClient->m_pChat->AddLine(-1, 0, aBuf);
|
m_pClient->m_pChat->AddLine(-1, 0, aBuf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,16 @@ const char *CGameClient::GetTeamName(int Team, bool Teamplay) const
|
||||||
return Localize("spectators", "'X joined the <spectators>' (server message)");
|
return Localize("spectators", "'X joined the <spectators>' (server message)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGameClient::GetPlayerLabel(char* aBuf, int BufferSize, int ClientID, const char* ClientName)
|
||||||
|
{
|
||||||
|
if(!g_Config.m_ClShowsocial)
|
||||||
|
str_format(aBuf, BufferSize, "%2d:", ClientID);
|
||||||
|
else if(g_Config.m_ClShowUserId)
|
||||||
|
str_format(aBuf, BufferSize, "%2d: %s", ClientID, ClientName);
|
||||||
|
else
|
||||||
|
str_format(aBuf, BufferSize, "%s", ClientName);
|
||||||
|
}
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DO_CHAT=0,
|
DO_CHAT=0,
|
||||||
|
@ -556,12 +566,15 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
|
||||||
case GAMEMSG_CTF_CAPTURE:
|
case GAMEMSG_CTF_CAPTURE:
|
||||||
m_pSounds->Enqueue(CSounds::CHN_GLOBAL, SOUND_CTF_CAPTURE);
|
m_pSounds->Enqueue(CSounds::CHN_GLOBAL, SOUND_CTF_CAPTURE);
|
||||||
int ClientID = clamp(aParaI[1], 0, MAX_CLIENTS - 1);
|
int ClientID = clamp(aParaI[1], 0, MAX_CLIENTS - 1);
|
||||||
|
char aLabel[64];
|
||||||
|
GetPlayerLabel(aLabel, sizeof(aLabel), ClientID, m_aClients[ClientID].m_aName);
|
||||||
|
|
||||||
if(aParaI[2] <= 60*Client()->GameTickSpeed())
|
if(aParaI[2] <= 60*Client()->GameTickSpeed())
|
||||||
str_format(aBuf, sizeof(aBuf), Localize("The %s was captured by '%2d: %s' (%.2f seconds)"), aParaI[0] ? Localize("blue flag") : Localize("red flag"),
|
str_format(aBuf, sizeof(aBuf), Localize("The %s was captured by '%s' (%.2f seconds)"), aParaI[0] ? Localize("blue flag") : Localize("red flag"),
|
||||||
ClientID, g_Config.m_ClShowsocial ? m_aClients[ClientID].m_aName : "", aParaI[2]/(float)Client()->GameTickSpeed());
|
aLabel, aParaI[2]/(float)Client()->GameTickSpeed());
|
||||||
else
|
else
|
||||||
str_format(aBuf, sizeof(aBuf), Localize("The %s was captured by '%2d: %s'"), aParaI[0] ? Localize("blue flag") : Localize("red flag"),
|
str_format(aBuf, sizeof(aBuf), Localize("The %s was captured by '%s'"), aParaI[0] ? Localize("blue flag") : Localize("red flag"),
|
||||||
ClientID, g_Config.m_ClShowsocial ? m_aClients[ClientID].m_aName : "");
|
aLabel);
|
||||||
m_pChat->AddLine(-1, 0, aBuf);
|
m_pChat->AddLine(-1, 0, aBuf);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1401,18 +1414,20 @@ void CGameClient::CClientData::Reset(CGameClient *pGameClient)
|
||||||
|
|
||||||
void CGameClient::DoEnterMessage(const char *pName, int ClientID, int Team)
|
void CGameClient::DoEnterMessage(const char *pName, int ClientID, int Team)
|
||||||
{
|
{
|
||||||
char aBuf[128];
|
char aBuf[128], aLabel[64];
|
||||||
str_format(aBuf, sizeof(aBuf), Localize("'%2d: %s' entered and joined the %s"), ClientID, g_Config.m_ClShowsocial ? pName : "", GetTeamName(Team, m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS));
|
GetPlayerLabel(aLabel, sizeof(aLabel), ClientID, pName);
|
||||||
|
str_format(aBuf, sizeof(aBuf), Localize("'%s' entered and joined the %s"), aLabel, GetTeamName(Team, m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS));
|
||||||
m_pChat->AddLine(-1, 0, aBuf);
|
m_pChat->AddLine(-1, 0, aBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameClient::DoLeaveMessage(const char *pName, int ClientID, const char *pReason)
|
void CGameClient::DoLeaveMessage(const char *pName, int ClientID, const char *pReason)
|
||||||
{
|
{
|
||||||
char aBuf[128];
|
char aBuf[128], aLabel[64];
|
||||||
|
GetPlayerLabel(aLabel, sizeof(aLabel), ClientID, pName);
|
||||||
if(pReason[0])
|
if(pReason[0])
|
||||||
str_format(aBuf, sizeof(aBuf), Localize("'%2d: %s' has left the game (%s)"), ClientID, g_Config.m_ClShowsocial ? pName : "", pReason);
|
str_format(aBuf, sizeof(aBuf), Localize("'%s' has left the game (%s)"), aLabel, pReason);
|
||||||
else
|
else
|
||||||
str_format(aBuf, sizeof(aBuf), Localize("'%2d: %s' has left the game"), ClientID, g_Config.m_ClShowsocial ? pName : "");
|
str_format(aBuf, sizeof(aBuf), Localize("'%s' has left the game"), aLabel);
|
||||||
m_pChat->AddLine(-1, 0, aBuf);
|
m_pChat->AddLine(-1, 0, aBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,6 +250,7 @@ public:
|
||||||
virtual const char *NetVersion() const;
|
virtual const char *NetVersion() const;
|
||||||
virtual int ClientVersion() const;
|
virtual int ClientVersion() const;
|
||||||
const char *GetTeamName(int Team, bool Teamplay) const;
|
const char *GetTeamName(int Team, bool Teamplay) const;
|
||||||
|
static void GetPlayerLabel(char* aBuf, int BufferSize, int ClientID, const char* ClientName);
|
||||||
|
|
||||||
//
|
//
|
||||||
void DoEnterMessage(const char *pName, int ClientID, int Team);
|
void DoEnterMessage(const char *pName, int ClientID, int Team);
|
||||||
|
|
Loading…
Reference in a new issue