mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
Sending wallop message
This commit is contained in:
@@ -280,7 +280,7 @@ namespace BlackCore
|
||||
{
|
||||
Q_UNUSED(originator;)
|
||||
if (commandLine.isEmpty()) { return false; }
|
||||
static const QStringList cmds({ ".msg", ".m", ".altos", ".altoffset", ".watchdog", ".reinit", ".reinitialize" });
|
||||
static const QStringList cmds({ ".msg", ".m", ".altos", ".altoffset", ".wallop", ".watchdog", ".reinit", ".reinitialize" });
|
||||
CSimpleCommandParser parser(cmds);
|
||||
parser.parse(commandLine);
|
||||
if (!parser.isKnownCommand()) { return false; }
|
||||
@@ -401,6 +401,15 @@ namespace BlackCore
|
||||
CLogMessage(this).info("Re-init %1 aircraft") << count;
|
||||
}
|
||||
}
|
||||
else if (parser.matchesCommand(".wallop"))
|
||||
{
|
||||
if (parser.countParts() < 2) { return false; }
|
||||
if (!m_network) { return false; }
|
||||
if (!this->isConnected()) { return false; }
|
||||
const QString wallopMsg = simplifyAccents(parser.part(1).simplified().trimmed());
|
||||
m_network->sendWallopMessage(wallopMsg);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -209,6 +209,7 @@ namespace BlackCore
|
||||
//! .altos .altoffset altitude offset for testing
|
||||
//! .reinit .reinitialize re-initialize all aircraft
|
||||
//! .watchdog on|off watchdog on/off
|
||||
//! .wallop message send wallop message
|
||||
//! </pre>
|
||||
//! @}
|
||||
//! \copydoc IContextNetwork::parseCommandLine
|
||||
@@ -223,6 +224,7 @@ namespace BlackCore
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".m callsign message text", "send text message"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".altos callsign offsetvalue", "set altitude offset value (testing)"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".watchdog on|off", "enable/disable network watchdog (testing)"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".wallop message", "send a wallop message"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".reinit", "re-initialize all aircraft"});
|
||||
}
|
||||
|
||||
|
||||
@@ -245,6 +245,12 @@ namespace BlackCore
|
||||
*/
|
||||
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &messages) = 0;
|
||||
|
||||
/*!
|
||||
* Send a wallop message.
|
||||
* \pre Network must be connected when calling this function.
|
||||
*/
|
||||
virtual void sendWallopMessage(const QString &message) = 0;
|
||||
|
||||
//! @}
|
||||
////////////////////////////////////////////////////////////////
|
||||
//! \name Custom packets
|
||||
|
||||
@@ -482,9 +482,9 @@ namespace BlackCore
|
||||
if (!m_net) { initializeSession(); }
|
||||
this->clearState();
|
||||
m_filterPasswordFromLogin = true;
|
||||
QByteArray callsign = toFSD(m_loginMode == LoginAsObserver ?
|
||||
m_ownCallsign.getAsObserverCallsignString() :
|
||||
m_ownCallsign.asString());
|
||||
QByteArray callsign = toFSDnoColon(m_loginMode == LoginAsObserver ?
|
||||
m_ownCallsign.getAsObserverCallsignString() :
|
||||
m_ownCallsign.asString());
|
||||
QByteArray name;
|
||||
if (m_loginMode == LoginAsObserver)
|
||||
{
|
||||
@@ -532,8 +532,8 @@ namespace BlackCore
|
||||
|
||||
void CNetworkVatlib::sendTextMessages(const CTextMessageList &messages)
|
||||
{
|
||||
Q_ASSERT_X(isConnected(), Q_FUNC_INFO, "Can't send to server when disconnected");
|
||||
|
||||
BLACK_VERIFY_X(this->isConnected(), Q_FUNC_INFO, "Sending text message, but not connected");
|
||||
if (!this->isConnected()) { return; }
|
||||
if (messages.isEmpty()) { return; }
|
||||
CTextMessageList privateMessages = messages.getPrivateMessages();
|
||||
privateMessages.markAsSent();
|
||||
@@ -559,6 +559,14 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CNetworkVatlib::sendWallopMessage(const QString &message)
|
||||
{
|
||||
if (message.isEmpty()) {return; }
|
||||
BLACK_VERIFY_X(this->isConnected(), Q_FUNC_INFO, "Sending wallop, but not connected");
|
||||
if (!this->isConnected()) { return; }
|
||||
Vat_SendWallop(m_net.data(), toFSDnoColon(simplifyAccents(message)));
|
||||
}
|
||||
|
||||
void CNetworkVatlib::sendCustomPacket(const CCallsign &callsign, const QString &packetId, const QStringList &data)
|
||||
{
|
||||
Q_ASSERT_X(isConnected(), Q_FUNC_INFO, "Can't send to server when disconnected");
|
||||
|
||||
@@ -101,6 +101,7 @@ namespace BlackCore
|
||||
//! \name Text message functions
|
||||
//! @{
|
||||
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &messages) override;
|
||||
virtual void sendWallopMessage(const QString &message) override;
|
||||
//! @}
|
||||
|
||||
//! \name ATC functions
|
||||
|
||||
Reference in New Issue
Block a user