# HG changeset patch # User S.D. # Date 1667175097 -7200 # Node ID 35d26863a88e090fcc3ba573f0975ff97f9f951a # Parent 08b88572b1c2a7adca463d7699e468eda3cf12b5 Don't show chat messages from ignored users in the game (same as in the frontend), but still save them for the demo diff -r 08b88572b1c2 -r 35d26863a88e QTfrontend/game.cpp --- a/QTfrontend/game.cpp Sun Oct 30 18:29:29 2022 +0200 +++ b/QTfrontend/game.cpp Mon Oct 31 02:11:37 2022 +0200 @@ -558,6 +558,13 @@ RawSendIPC(buf); } +void HWGame::FromNetChatIgnored(const QString & msg) +{ + QByteArray buf; + HWProto::addStringToBuffer(buf, 's' + msg + "\x20\x20"); + RawSendToDemoOnly(buf); +} + void HWGame::FromNetWarning(const QString & msg) { QByteArray buf; diff -r 08b88572b1c2 -r 35d26863a88e QTfrontend/game.h --- a/QTfrontend/game.h Sun Oct 30 18:29:29 2022 +0200 +++ b/QTfrontend/game.h Mon Oct 31 02:11:37 2022 +0200 @@ -108,6 +108,7 @@ public slots: void FromNet(const QByteArray & msg); void FromNetChat(const QString & msg); + void FromNetChatIgnored(const QString & msg); void FromNetWarning(const QString & msg); void FromNetError(const QString & msg); diff -r 08b88572b1c2 -r 35d26863a88e QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Sun Oct 30 18:29:29 2022 +0200 +++ b/QTfrontend/hwform.cpp Mon Oct 31 02:11:37 2022 +0200 @@ -1949,6 +1949,7 @@ connect(game, SIGNAL(SendTeamMessage(const QString &)), hwnet, SLOT(SendTeamMessage(const QString &))); connect(game, SIGNAL(SendDrawCmd(const QByteArray &)), hwnet, SLOT(SendDrawCmd(const QByteArray &))); connect(hwnet, SIGNAL(chatStringFromNet(const QString &)), game, SLOT(FromNetChat(const QString &)), Qt::QueuedConnection); + connect(hwnet, SIGNAL(chatStringFromNetIgnored(const QString &)), game, SLOT(FromNetChatIgnored(const QString &)), Qt::QueuedConnection); connect(hwnet, SIGNAL(Warning(const QString&)), game, SLOT(FromNetWarning(const QString&)), Qt::QueuedConnection); connect(hwnet, SIGNAL(Error(const QString&)), game, SLOT(FromNetError(const QString&)), Qt::QueuedConnection); diff -r 08b88572b1c2 -r 35d26863a88e QTfrontend/net/newnetclient.cpp --- a/QTfrontend/net/newnetclient.cpp Sun Oct 30 18:29:29 2022 +0200 +++ b/QTfrontend/net/newnetclient.cpp Mon Oct 31 02:11:37 2022 +0200 @@ -426,6 +426,7 @@ return; } + bool isIgnored = false; QString action; QString message; QString sender = lst[1]; @@ -438,6 +439,7 @@ // Another kind of fake nick. '(' nicks are server messages, but they must not be translated if(!sender.startsWith('(')) { + isIgnored = m_playersModel->isFlagSet(sender, PlayersListModel::Ignore); // Check for action (/me command) action = HWProto::chatStringToAction(message); } @@ -465,7 +467,10 @@ } else { - emit chatStringFromNet(HWProto::formatChatMsg(sender, message)); + if (isIgnored) + emit chatStringFromNetIgnored(HWProto::formatChatMsg(sender, message)); + else + emit chatStringFromNet(HWProto::formatChatMsg(sender, message)); if (!action.isNull()) emit roomChatAction(sender, action); else @@ -492,7 +497,12 @@ } else { - emit chatStringFromNet(HWProto::formatDirectMsg(mynick, nick, message, isEcho)); + bool isIgnored = m_playersModel->isFlagSet(nick, PlayersListModel::Ignore) && !isEcho; + QString formattedMsg = HWProto::formatDirectMsg(mynick, nick, message, isEcho); + if (isIgnored) + emit chatStringFromNetIgnored(formattedMsg); + else + emit chatStringFromNet(formattedMsg); emit roomDirectMessage(nick, message, isEcho); } return; diff -r 08b88572b1c2 -r 35d26863a88e QTfrontend/net/newnetclient.h --- a/QTfrontend/net/newnetclient.h Sun Oct 30 18:29:29 2022 +0200 +++ b/QTfrontend/net/newnetclient.h Mon Oct 31 02:11:37 2022 +0200 @@ -137,6 +137,7 @@ void lobbyDirectMessage(const QString & nick, const QString & message, bool isEcho); void roomDirectMessage(const QString & nick, const QString & message, bool isEcho); void chatStringFromNet(const QString&); + void chatStringFromNetIgnored(const QString&); void roomsList(const QStringList&); void serverMessage(const QString &); diff -r 08b88572b1c2 -r 35d26863a88e QTfrontend/net/tcpBase.cpp --- a/QTfrontend/net/tcpBase.cpp Sun Oct 30 18:29:29 2022 +0200 +++ b/QTfrontend/net/tcpBase.cpp Mon Oct 31 02:11:37 2022 +0200 @@ -344,6 +344,12 @@ } } +void TCPBase::RawSendToDemoOnly(const QByteArray & buf) +{ + if (!buf.isEmpty() && m_isDemoMode) + demo.append(buf); +} + bool TCPBase::couldBeRemoved() { return false; diff -r 08b88572b1c2 -r 35d26863a88e QTfrontend/net/tcpBase.h --- a/QTfrontend/net/tcpBase.h Sun Oct 30 18:29:29 2022 +0200 +++ b/QTfrontend/net/tcpBase.h Mon Oct 31 02:11:37 2022 +0200 @@ -65,6 +65,7 @@ void SendIPC(const QByteArray & buf); void RawSendIPC(const QByteArray & buf); + void RawSendToDemoOnly(const QByteArray & buf); virtual QStringList getArguments()=0; virtual void onClientRead();