From f987b81e6d79e6ae140626903f127d74fc5e26b7 Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Sun, 26 Jul 2020 11:57:59 +0200 Subject: [PATCH] Add feedback when .wallop message is sent This does the following: - Opens a message-tab called "SUP" when a .wallop message is sent. - Throws a validation error if another message is directly send into this "SUP" channel as another .wallop should be used. --- src/blackcore/fsd/fsdclient.cpp | 8 ++++++++ src/blackgui/components/textmessagecomponent.cpp | 7 +++++++ src/blackmisc/aviation/callsign.cpp | 6 ++++++ src/blackmisc/aviation/callsign.h | 3 +++ src/blackmisc/network/textmessage.cpp | 6 ++++++ src/blackmisc/network/textmessage.h | 3 +++ 6 files changed, 33 insertions(+) diff --git a/src/blackcore/fsd/fsdclient.cpp b/src/blackcore/fsd/fsdclient.cpp index 1acdc71d1..47fda6fa6 100644 --- a/src/blackcore/fsd/fsdclient.cpp +++ b/src/blackcore/fsd/fsdclient.cpp @@ -546,6 +546,14 @@ namespace BlackCore else { return; } const TextMessage textMessage(getOwnCallsignAsString(), receiver, message); sendQueudedMessage(textMessage); + if(receiver == QStringLiteral("*S")) + { + const CCallsign sender(getOwnCallsignAsString()); + const CCallsign recipient(receiver); + CTextMessage t(message, sender, recipient); + t.markAsSent(); + emit textMessageSent(t); + } increaseStatisticsValue(QStringLiteral("sendTextMessages")); } diff --git a/src/blackgui/components/textmessagecomponent.cpp b/src/blackgui/components/textmessagecomponent.cpp index 6cbd73d0d..cab3e281f 100644 --- a/src/blackgui/components/textmessagecomponent.cpp +++ b/src/blackgui/components/textmessagecomponent.cpp @@ -550,6 +550,9 @@ namespace BlackGui const bool isBroadcast = textMessage.isBroadcastMessage(); if (isBroadcast) { cs.markAsBroadcastCallsign(); } + const bool isWallopMessage = textMessage.isWallopMessage(); + if(isWallopMessage) { cs.markAsWallopCallsign(); } + const QWidget *tab = this->findTextMessageTabByCallsign(cs); if (!tab) { tab = this->addNewTextMessageTab(cs); } Q_ASSERT_X(tab, Q_FUNC_INFO, "Missing tab"); @@ -725,6 +728,10 @@ namespace BlackGui { CLogMessage(this).validationError(u"Incorrect message channel"); return {}; + } else if (ui->tw_TextMessages->tabText(index) == "SUP") + { + CLogMessage(this).validationError(u"Message cannot be send to SUP channel. To send another wallop message use .wallop instead"); + return{}; } else { diff --git a/src/blackmisc/aviation/callsign.cpp b/src/blackmisc/aviation/callsign.cpp index 8ada3c8ba..bb53c200e 100644 --- a/src/blackmisc/aviation/callsign.cpp +++ b/src/blackmisc/aviation/callsign.cpp @@ -145,6 +145,12 @@ namespace BlackMisc m_callsign = "BROADCAST"; } + void CCallsign::markAsWallopCallsign() + { + m_callsignAsSet = "SUP"; + m_callsign = "SUP"; + } + bool CCallsign::isMaybeCopilotCallsign(const CCallsign &pilotCallsign) const { return m_callsign.startsWith(pilotCallsign.asString()) && diff --git a/src/blackmisc/aviation/callsign.h b/src/blackmisc/aviation/callsign.h index 9382ad665..a0eed292d 100644 --- a/src/blackmisc/aviation/callsign.h +++ b/src/blackmisc/aviation/callsign.h @@ -86,6 +86,9 @@ namespace BlackMisc //! \remark hack, workaround for VATSIM using "*" as callsign for text messages void markAsBroadcastCallsign(); + //! Set a human readable name as "wallop-channel" callsign + void markAsWallopCallsign(); + //! Returns true if this is a co-pilot callsign of pilot. The logic is that the callsign is the same as the pilot one //! but with a single character as suffix. //! e.g Pilot logged in as DLH123, observer logged in as DLH123A diff --git a/src/blackmisc/network/textmessage.cpp b/src/blackmisc/network/textmessage.cpp index ad56cb732..6b7d3d4a0 100644 --- a/src/blackmisc/network/textmessage.cpp +++ b/src/blackmisc/network/textmessage.cpp @@ -208,6 +208,12 @@ namespace BlackMisc return cs.isBroadcastCallsign(); } + bool CTextMessage::isWallopMessage() const + { + const CCallsign cs = this->getRecipientCallsign(); + return cs.getStringAsSet() == "*S"; + } + QString CTextMessage::asString(bool withSender, bool withRecipient, const QString &separator) const { QString s(this->getFormattedUtcTimestampHms()); diff --git a/src/blackmisc/network/textmessage.h b/src/blackmisc/network/textmessage.h index 45d3879b5..a9e99a7b0 100644 --- a/src/blackmisc/network/textmessage.h +++ b/src/blackmisc/network/textmessage.h @@ -117,6 +117,9 @@ namespace BlackMisc //! Is this a broadcast message bool isBroadcastMessage() const; + //! Is this a message send via .wallop + bool isWallopMessage() const; + //! Whole message as formatted string. Used to display message in a console window. //! \param withSender include sender information in string? //! \param withRecipient include recipient information in string?