3557: Log duplicate messages in console r=edg-l a=def-

As reported by fokkonaut

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2021-01-31 14:55:45 +00:00 committed by GitHub
commit 8be462af26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -667,6 +667,8 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
if(*p == 0)
return;
bool IgnoreLine = false;
while(*p)
{
Highlighted = false;
@ -697,7 +699,11 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
pCurrentLine->m_Time = time();
pCurrentLine->m_YOffset[0] = -1.f;
pCurrentLine->m_YOffset[1] = -1.f;
return;
// Can't return here because we still want to log the message to console,
// even if we ignore it in chat. We will set the new line, fill it out
// totally, but then in the end revert back m_CurrentLine after writing
// the message to console.
IgnoreLine = true;
}
m_CurrentLine = (m_CurrentLine + 1) % MAX_LINES;
@ -814,6 +820,12 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, Team >= 2 ? "whisper" : (pCurrentLine->m_Team ? "teamchat" : "chat"), aBuf, Highlighted);
}
if(IgnoreLine)
{
m_CurrentLine = (m_CurrentLine + MAX_LINES - 1) % MAX_LINES;
return;
}
// play sound
int64 Now = time();
if(ClientID == -1)