diff --git a/src/blackcore/network_vatlib.cpp b/src/blackcore/network_vatlib.cpp index eccc0ff10..69d53e23d 100644 --- a/src/blackcore/network_vatlib.cpp +++ b/src/blackcore/network_vatlib.cpp @@ -40,7 +40,7 @@ namespace BlackCore : INetwork(parent), COwnAircraftAware(ownAircraft), m_loginMode(LoginNormal), m_status(vatStatusIdle), - m_fsdTextCodec(QTextCodec::codecForName("latin1")), + m_fsdTextCodec(QTextCodec::codecForName(m_fsdTextCodecSetting.get().toLocal8Bit())), m_tokenBucket(10, CTime(5, CTimeUnit::s()), 1) { connect(this, &CNetworkVatlib::terminate, this, &INetwork::terminateConnection, Qt::QueuedConnection); @@ -48,7 +48,6 @@ namespace BlackCore Q_ASSERT_X(m_fsdTextCodec, "CNetworkVatlib", "Missing default wire text encoding"); Q_ASSERT_X(Vat_GetVersion() == VAT_LIBVATLIB_VERSION, "swift.network", "Wrong vatlib shared library installed"); - //TODO reinit m_fsdTextCodec from WireTextEncoding config setting if present Vat_SetNetworkLogHandler(SeverityError, CNetworkVatlib::networkLogHandler); diff --git a/src/blackcore/network_vatlib.h b/src/blackcore/network_vatlib.h index 03e4f7094..c7810deba 100644 --- a/src/blackcore/network_vatlib.h +++ b/src/blackcore/network_vatlib.h @@ -14,6 +14,7 @@ #include "blackcoreexport.h" #include "network.h" +#include "settings/network.h" #include "blackmisc/simulation/ownaircraftprovider.h" #include "token_bucket.h" #include @@ -181,12 +182,13 @@ namespace BlackCore static int const c_processingIntervalMsec = 100; static int const c_updateIntervalMsec = 5000; static int const c_logoffTimeoutSec = 5; - QTextCodec *m_fsdTextCodec; + + CSetting m_fsdTextCodecSetting { this }; + QTextCodec *m_fsdTextCodec = nullptr; BlackMisc::Aviation::CAircraftParts m_sentAircraftConfig; QTimer m_scheduledConfigUpdate; CTokenBucket m_tokenBucket; - }; } //namespace BlackCore diff --git a/src/blackcore/settings/network.h b/src/blackcore/settings/network.h index 336950a5f..a0598b454 100644 --- a/src/blackcore/settings/network.h +++ b/src/blackcore/settings/network.h @@ -14,6 +14,7 @@ #include "blackcore/settingscache.h" #include "blackmisc/network/serverlist.h" +#include namespace BlackCore { @@ -21,6 +22,19 @@ namespace BlackCore { namespace Network { + //! Name of text codec to use with text in FSD protocol + struct WireTextCodec : public CSettingTrait + { + //! \copydoc BlackCore::CSetting::key + static const char *key() { return "network/wiretextcodec"; } + + //! \copydoc BlackCore::CSetting::defaultValue + static const QString &defaultValue() { static const QString dv("latin1"); return dv; } + + //! \copydoc BlackCore::CSetting::isValid + static bool isValid(const QString &value) { return QTextCodec::codecForName(qPrintable(value)); } + }; + //! Virtual air traffic servers struct TrafficServers : public CSettingTrait {