diff --git a/src/blackcore/context/contextnetworkimpl.cpp b/src/blackcore/context/contextnetworkimpl.cpp index 9b5c684fc..a70e95b67 100644 --- a/src/blackcore/context/contextnetworkimpl.cpp +++ b/src/blackcore/context/contextnetworkimpl.cpp @@ -6,36 +6,37 @@ * or distributed except according to the terms contained in the LICENSE file. */ -#include "blackconfig/buildconfig.h" -#include "blackcore/airspaceanalyzer.h" -#include "blackcore/airspacemonitor.h" -#include "blackcore/application.h" +#include "blackcore/vatsim/networkvatlib.h" #include "blackcore/context/contextnetworkimpl.h" #include "blackcore/context/contextownaircraft.h" #include "blackcore/context/contextownaircraftimpl.h" #include "blackcore/context/contextsimulatorimpl.h" +#include "blackcore/airspaceanalyzer.h" +#include "blackcore/airspacemonitor.h" +#include "blackcore/application.h" #include "blackcore/corefacade.h" -#include "blackcore/vatsim/networkvatlib.h" #include "blackcore/webdataservices.h" +#include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/aviation/aircrafticaocode.h" #include "blackmisc/aviation/aircraftparts.h" #include "blackmisc/aviation/atcstationlist.h" #include "blackmisc/aviation/comsystem.h" #include "blackmisc/aviation/callsign.h" #include "blackmisc/aviation/comsystem.h" -#include "blackmisc/dbusserver.h" -#include "blackmisc/logcategory.h" -#include "blackmisc/logmessage.h" #include "blackmisc/network/entityflags.h" #include "blackmisc/network/networkutils.h" #include "blackmisc/network/textmessage.h" #include "blackmisc/pq/constants.h" #include "blackmisc/pq/frequency.h" +#include "blackmisc/pq/time.h" #include "blackmisc/pq/units.h" +#include "blackmisc/dbusserver.h" +#include "blackmisc/logcategory.h" +#include "blackmisc/logmessage.h" #include "blackmisc/sequence.h" #include "blackmisc/simplecommandparser.h" -#include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/stringutils.h" +#include "blackconfig/buildconfig.h" #include "contextnetworkimpl.h" #include @@ -280,7 +281,7 @@ namespace BlackCore { Q_UNUSED(originator;) if (commandLine.isEmpty()) { return false; } - static const QStringList cmds({ ".msg", ".m", ".chat", ".altos", ".altoffset", ".wallop", ".watchdog", ".reinit", ".reinitialize", ".enable", ".disable", ".ignore", ".unignore" }); + static const QStringList cmds({ ".msg", ".m", ".chat", ".altos", ".altoffset", ".addtimeos", ".addtimeoffset", ".wallop", ".watchdog", ".reinit", ".reinitialize", ".enable", ".disable", ".ignore", ".unignore" }); CSimpleCommandParser parser(cmds); parser.parse(commandLine); if (!parser.isKnownCommand()) { return false; } @@ -394,6 +395,27 @@ namespace BlackCore return true; } + else if (parser.matchesCommand(".addtimeos", ".addtimeoffset")) + { + if (!m_airspace) { return false; } + if (parser.countParts() < 2) { return false; } + + CTime os(CTime::null()); + if (parser.hasPart(2)) + { + os.parseFromString(parser.part(2), CPqString::SeparatorBestGuess); + } + + if (!os.isNull() && os.isPositiveWithEpsilonConsidered()) + { + const qint64 ost = os.valueInteger(CTimeUnit::ms()); + CLogMessage(this).info(u"Added add offset time %1ms") << ost; + } + else + { + CLogMessage(this).info(u"Reset add. time offset"); + } + } else if (parser.matchesCommand(".watchdog")) { if (!m_airspace) { return false; } diff --git a/src/blackcore/context/contextnetworkimpl.h b/src/blackcore/context/contextnetworkimpl.h index 26efbdbfa..439133372 100644 --- a/src/blackcore/context/contextnetworkimpl.h +++ b/src/blackcore/context/contextnetworkimpl.h @@ -207,11 +207,12 @@ namespace BlackCore //! \addtogroup swiftdotcommands //! @{ //!
-            //! .m .msg .chat           message text
-            //! .altos .altoffset       altitude offset for testing
-            //! .reinit .reinitialize   re-initialize all aircraft
-            //! .watchdog on|off        watchdog on/off
-            //! .wallop message         send wallop message
+            //! .m .msg .chat              message text
+            //! .altos .altoffset          altitude offset for testing
+            //! .addtimeos .addtimeoffse   additional offset time for testing
+            //! .reinit .reinitialize      re-initialize all aircraft
+            //! .watchdog on|off           watchdog on/off
+            //! .wallop message            send wallop message
             //! 
//! @} //! \copydoc IContextNetwork::parseCommandLine @@ -225,6 +226,7 @@ namespace BlackCore BlackMisc::CSimpleCommandParser::registerCommand({".m message text", "send text message"}); BlackMisc::CSimpleCommandParser::registerCommand({".m callsign message text", "send text message"}); BlackMisc::CSimpleCommandParser::registerCommand({".altos callsign|? offsetvalue", "set altitude offset value (testing)"}); + BlackMisc::CSimpleCommandParser::registerCommand({".addtimeos offsetvalue", "add (delta) time offset (testing), e.g. 50ms"}); 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"}); diff --git a/src/blackcore/network.h b/src/blackcore/network.h index 05cde291c..1abcd19b0 100644 --- a/src/blackcore/network.h +++ b/src/blackcore/network.h @@ -395,6 +395,19 @@ namespace BlackCore * \sa metarReplyReceived */ virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao) = 0; + //! @} + + + //! @} + //////////////////////////////////////////////////////////////// + //! \name Others + //! @{ + //////////////////////////////////////////////////////////////// + + //! Additional offset time @{ + virtual qint64 getAdditionalOffsetTime() const = 0; + virtual void setAdditionalOffsetTime(qint64 addOffset) = 0; + //! @} signals: //! @} diff --git a/src/blackcore/vatsim/networkvatlib.cpp b/src/blackcore/vatsim/networkvatlib.cpp index d5520fa1f..99c8f3120 100644 --- a/src/blackcore/vatsim/networkvatlib.cpp +++ b/src/blackcore/vatsim/networkvatlib.cpp @@ -1273,7 +1273,7 @@ namespace BlackCore offsetTime = CFsdSetup::c_interimPositionTimeOffsetMsec; } - return offsetTime; + return m_additionalOffsetTime + offsetTime; } qint64 CNetworkVatlib::currentOffsetTime(const CCallsign &callsign) const diff --git a/src/blackcore/vatsim/networkvatlib.h b/src/blackcore/vatsim/networkvatlib.h index 84c3ede03..976843abd 100644 --- a/src/blackcore/vatsim/networkvatlib.h +++ b/src/blackcore/vatsim/networkvatlib.h @@ -121,14 +121,19 @@ namespace BlackCore virtual const BlackMisc::Aviation::CCallsignSet &getInterimPositionReceivers() const override; //! @} - //! Arguments to be passed to another swift appplication - static QStringList vatlibArguments(); - //! \name Weather functions //! @{ virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao) override; //! @} + //! Additional offset time @{ + virtual qint64 getAdditionalOffsetTime() const override { return m_additionalOffsetTime; } + virtual void setAdditionalOffsetTime(qint64 addOffset) override { m_additionalOffsetTime = addOffset; } + //! @} + + //! Arguments to be passed to another swift appplication + static QStringList vatlibArguments(); + //! Command line options this library can handle static const QList &getCmdLineOptions(); @@ -136,6 +141,7 @@ namespace BlackCore static int constexpr c_processingIntervalMsec = 100; //!< interval for the processing timer static int constexpr c_updatePostionIntervalMsec = 5000; //!< interval for the position update timer (send our position to network) static int constexpr c_updateInterimPostionIntervalMsec = 1000; //!< interval for iterim position updates (send our position as interim position) + qint64 m_additionalOffsetTime = 0; //!< additional offset time static bool getCmdLineClientIdAndKey(int &id, QString &key); @@ -186,11 +192,12 @@ namespace BlackCore void initializeSession(); void changeConnectionStatus(VatConnectionStatus newStatus); bool isDisconnected() const { return m_status != vatStatusConnecting && m_status != vatStatusConnected; } + void sendCustomPacket(const BlackMisc::Aviation::CCallsign &callsign, const QString &packetId, const QStringList &data); + static QString convertToUnicodeEscaped(const QString &str); static VatSimType convertToSimType(BlackMisc::Simulation::CSimulatorPluginInfo &simInfo); static void networkLogHandler(VatSeverityLevel severity, const char *context, const char *message); static QString simplifyTextMessage(const QString &msg); - void sendCustomPacket(const BlackMisc::Aviation::CCallsign &callsign, const QString &packetId, const QStringList &data); //! Default model string static const QString &defaultModelString()