diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-06-26 22:25:22 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-06-26 23:05:21 +0200 |
commit | d65936200a2756e6619a109fa6fa673b91df802e (patch) | |
tree | 80b6b6fc7ba9023cbe47290b8ae1bc5468a19bb1 /proto-simconnect | |
parent | 4046773c41ee3c0f65840828ab983cfd13451c85 (diff) |
modernize C++ syntax
No visible changes (hopefully).
Diffstat (limited to 'proto-simconnect')
-rw-r--r-- | proto-simconnect/ftnoir_protocol_sc.cpp | 31 | ||||
-rw-r--r-- | proto-simconnect/ftnoir_protocol_sc.h | 18 |
2 files changed, 18 insertions, 31 deletions
diff --git a/proto-simconnect/ftnoir_protocol_sc.cpp b/proto-simconnect/ftnoir_protocol_sc.cpp index 05cc3d0b..ab4a85dd 100644 --- a/proto-simconnect/ftnoir_protocol_sc.cpp +++ b/proto-simconnect/ftnoir_protocol_sc.cpp @@ -14,10 +14,6 @@ #include "compat/timer.hpp" #include "compat/library-path.hpp" -simconnect::simconnect() : hSimConnect(nullptr), should_reconnect(false) -{ -} - simconnect::~simconnect() { requestInterruption(); @@ -112,11 +108,8 @@ void simconnect::pose( const double *headpose ) class ActivationContext { public: - ActivationContext(const int resid) : - ok(false) + explicit ActivationContext(int resid) { - hactctx = INVALID_HANDLE_VALUE; - actctx_cookie = 0; ACTCTXA actx = {}; actx.cbSize = sizeof(actx); actx.lpResourceName = MAKEINTRESOURCEA(resid); @@ -126,7 +119,6 @@ public: QByteArray name = QFile::encodeName(path); actx.lpSource = name.constData(); hactctx = CreateActCtxA(&actx); - actctx_cookie = 0; if (hactctx != INVALID_HANDLE_VALUE) { if (!ActivateActCtx(hactctx, &actctx_cookie)) @@ -151,9 +143,9 @@ public: bool is_ok() const { return ok; } private: - ULONG_PTR actctx_cookie; - HANDLE hactctx; - bool ok; + ULONG_PTR actctx_cookie = 0; + HANDLE hactctx = INVALID_HANDLE_VALUE; + bool ok = false; }; module_status simconnect::initialize() @@ -174,27 +166,22 @@ module_status simconnect::initialize() } simconnect_open = (importSimConnect_Open) SCClientLib.resolve("SimConnect_Open"); - if (simconnect_open == NULL) { + if (!simconnect_open) return error("Open function not found in DLL!"); - } simconnect_set6DOF = (importSimConnect_CameraSetRelative6DOF) SCClientLib.resolve("SimConnect_CameraSetRelative6DOF"); - if (simconnect_set6DOF == NULL) { + if (!simconnect_set6DOF) return error("CameraSetRelative6DOF function not found in DLL!"); - } simconnect_close = (importSimConnect_Close) SCClientLib.resolve("SimConnect_Close"); - if (simconnect_close == NULL) { + if (!simconnect_close) return error("Close function not found in DLL!"); - } simconnect_calldispatch = (importSimConnect_CallDispatch) SCClientLib.resolve("SimConnect_CallDispatch"); - if (simconnect_calldispatch == NULL) { + if (!simconnect_calldispatch) return error("CallDispatch function not found in DLL!"); - } simconnect_subscribetosystemevent = (importSimConnect_SubscribeToSystemEvent) SCClientLib.resolve("SimConnect_SubscribeToSystemEvent"); - if (simconnect_subscribetosystemevent == NULL) { + if (!simconnect_subscribetosystemevent) return error("SubscribeToSystemEvent function not found in DLL!"); - } start(); diff --git a/proto-simconnect/ftnoir_protocol_sc.h b/proto-simconnect/ftnoir_protocol_sc.h index 6932bfc8..749f7906 100644 --- a/proto-simconnect/ftnoir_protocol_sc.h +++ b/proto-simconnect/ftnoir_protocol_sc.h @@ -38,7 +38,7 @@ class simconnect : private QThread, public IProtocol { Q_OBJECT public: - simconnect(); + simconnect() = default; ~simconnect() override; module_status initialize() override; void pose(const double* headpose); @@ -74,12 +74,12 @@ private: void run() override; - std::atomic<float> virtSCPosX; - std::atomic<float> virtSCPosY; - std::atomic<float> virtSCPosZ; - std::atomic<float> virtSCRotX; - std::atomic<float> virtSCRotY; - std::atomic<float> virtSCRotZ; + std::atomic<float> virtSCPosX {0}; + std::atomic<float> virtSCPosY {0}; + std::atomic<float> virtSCPosZ {0}; + std::atomic<float> virtSCRotX {0}; + std::atomic<float> virtSCRotY {0}; + std::atomic<float> virtSCRotZ {0}; importSimConnect_Open simconnect_open; importSimConnect_Close simconnect_close; @@ -87,8 +87,8 @@ private: importSimConnect_CallDispatch simconnect_calldispatch; importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent; - HANDLE hSimConnect; - std::atomic<bool> should_reconnect; + HANDLE hSimConnect = nullptr; + std::atomic<bool> should_reconnect = false; static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); settings s; QLibrary SCClientLib; |