diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index d790b6aa1..b060f9cf1 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -147,7 +147,7 @@ void CChat::ConchainChatOld(IConsole::IResult *pResult, void *pUserData, IConsol void CChat::Echo(const char *pString) { - AddLine(-2, 0, pString); + AddLine(CLIENT_MSG, 0, pString); } void CChat::OnConsoleInit() @@ -637,7 +637,7 @@ void CChat::StoreSave(const char *pText) void CChat::AddLine(int ClientID, int Team, const char *pLine) { if(*pLine == 0 || - (ClientID == -1 && !g_Config.m_ClShowChatSystem) || + (ClientID == SERVER_MSG && !g_Config.m_ClShowChatSystem) || (ClientID >= 0 && (m_pClient->m_aClients[ClientID].m_aName[0] == '\0' || // unknown client m_pClient->m_aClients[ClientID].m_ChatIgnore || (m_pClient->m_Snap.m_LocalClientID != ClientID && g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[ClientID].m_Friend) || @@ -698,9 +698,9 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) ChatLogColor = color_cast(ColorHSLA(g_Config.m_ClMessageFriendColor)); else if(pLine_->m_Team) ChatLogColor = color_cast(ColorHSLA(g_Config.m_ClMessageTeamColor)); - else if(pLine_->m_ClientID == -1) // system + else if(pLine_->m_ClientID == SERVER_MSG) ChatLogColor = color_cast(ColorHSLA(g_Config.m_ClMessageSystemColor)); - else if(pLine_->m_ClientID == -2) // client + else if(pLine_->m_ClientID == CLIENT_MSG) ChatLogColor = color_cast(ColorHSLA(g_Config.m_ClMessageClientColor)); else // regular message ChatLogColor = color_cast(ColorHSLA(g_Config.m_ClMessageColor)); @@ -848,7 +848,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) // play sound int64_t Now = time(); - if(ClientID == -1) + if(ClientID == SERVER_MSG) { if(Now - m_aLastSoundPlayed[CHAT_SERVER] >= time_freq() * 3 / 10) { @@ -859,7 +859,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) } } } - else if(ClientID == -2) // Client message + else if(ClientID == CLIENT_MSG) { // No sound yet } @@ -1063,33 +1063,24 @@ void CChat::OnPrepareLines() // render name ColorRGBA NameColor; - if(m_aLines[r].m_ClientID == -1) // system - { + if(m_aLines[r].m_ClientID == SERVER_MSG) NameColor = color_cast(ColorHSLA(g_Config.m_ClMessageSystemColor)); - } - else if(m_aLines[r].m_ClientID == -2) // client - { + else if(m_aLines[r].m_ClientID == CLIENT_MSG) NameColor = color_cast(ColorHSLA(g_Config.m_ClMessageClientColor)); - } else if(m_aLines[r].m_Team) - { NameColor = CalculateNameColor(ColorHSLA(g_Config.m_ClMessageTeamColor)); - } else if(m_aLines[r].m_NameColor == TEAM_RED) - NameColor = ColorRGBA(1.0f, 0.5f, 0.5f, 1.f); // red + NameColor = ColorRGBA(1.0f, 0.5f, 0.5f, 1.f); else if(m_aLines[r].m_NameColor == TEAM_BLUE) - NameColor = ColorRGBA(0.7f, 0.7f, 1.0f, 1.f); // blue + NameColor = ColorRGBA(0.7f, 0.7f, 1.0f, 1.f); else if(m_aLines[r].m_NameColor == TEAM_SPECTATORS) - NameColor = ColorRGBA(0.75f, 0.5f, 0.75f, 1.f); // spectator + NameColor = ColorRGBA(0.75f, 0.5f, 0.75f, 1.f); else if(m_aLines[r].m_ClientID >= 0 && g_Config.m_ClChatTeamColors && m_pClient->m_Teams.Team(m_aLines[r].m_ClientID)) - { NameColor = color_cast(ColorHSLA(m_pClient->m_Teams.Team(m_aLines[r].m_ClientID) / 64.0f, 1.0f, 0.75f)); - } else NameColor = ColorRGBA(0.8f, 0.8f, 0.8f, 1.f); TextRender()->TextColor(NameColor); - TextRender()->CreateOrAppendTextContainer(m_aLines[r].m_TextContainerIndex, &Cursor, aName); if(m_aLines[r].m_TimesRepeated > 0) @@ -1106,13 +1097,13 @@ void CChat::OnPrepareLines() // render line ColorRGBA Color; - if(m_aLines[r].m_ClientID == -1) // system + if(m_aLines[r].m_ClientID == SERVER_MSG) Color = color_cast(ColorHSLA(g_Config.m_ClMessageSystemColor)); - else if(m_aLines[r].m_ClientID == -2) // client + else if(m_aLines[r].m_ClientID == CLIENT_MSG) Color = color_cast(ColorHSLA(g_Config.m_ClMessageClientColor)); - else if(m_aLines[r].m_Highlighted) // highlighted + else if(m_aLines[r].m_Highlighted) Color = color_cast(ColorHSLA(g_Config.m_ClMessageHighlightColor)); - else if(m_aLines[r].m_Team) // team message + else if(m_aLines[r].m_Team) Color = color_cast(ColorHSLA(g_Config.m_ClMessageTeamColor)); else // regular message Color = color_cast(ColorHSLA(g_Config.m_ClMessageColor)); diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index 66fde6e04..a077413c4 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -62,9 +62,12 @@ class CChat : public CComponent CLine m_aLines[MAX_LINES]; int m_CurrentLine; - // chat enum { + // client IDs for special messages + CLIENT_MSG = -2, + SERVER_MSG = -1, + MODE_NONE = 0, MODE_ALL, MODE_TEAM,