Don't show chat messages from ignored users in the game (same as in the frontend), but still save them for the demo
--- 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;
--- 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);
--- 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);
--- 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;
--- 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 &);
--- 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;
--- 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();