Skip to content

Commit 0236438

Browse files
committed
fix: remove unnecessary code
1 parent 9edd3f8 commit 0236438

File tree

8 files changed

+34
-298
lines changed

8 files changed

+34
-298
lines changed

src/misc/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,6 @@ add_library(misc SHARED
535535
simulation/flightgear/flightgearutil.h
536536
simulation/msfs2024/aircraftmodelloadermsfs2024.cpp
537537
simulation/msfs2024/aircraftmodelloadermsfs2024.h
538-
simulation/msfs2024/msfs2024util.cpp
539-
simulation/msfs2024/msfs2024util.h
540538
simulation/fscommon/aircraftcfgentries.cpp
541539
simulation/fscommon/aircraftcfgentries.h
542540
simulation/fscommon/aircraftcfgentrieslist.cpp

src/misc/simulation/msfs2024/msfs2024util.cpp

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/misc/simulation/msfs2024/msfs2024util.h

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/plugins/simulator/msfs2024/simconnectsymbolsmsfs2024.cpp

Lines changed: 2 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ bool resolveSimConnectSymbol(QLibrary &library, FuncPtr &funcPtr, const char *fu
160160
return true;
161161
}
162162

163-
bool resolveCommonSimConnectSymbols(QLibrary &simConnectDll)
163+
bool resolveMsfs2024SimConnectSymbols(QLibrary &simConnectDll)
164164
{
165165
bool resolveSuccess = true;
166166
resolveSuccess =
@@ -253,103 +253,6 @@ bool resolveP3DSimConnectSymbols(QLibrary &simConnectDll)
253253
return resolveSuccess;
254254
}
255255

256-
P3DSimConnectVersion stringToP3DVersion(const QString &p3d)
257-
{
258-
if (p3d.length() >= 2)
259-
{
260-
const QString p = digitOnlyString(p3d);
261-
if (p.contains("40")) { return P3DSimConnectv40; }
262-
if (p.contains("41")) { return P3DSimConnectv41; }
263-
if (p.contains("42")) { return P3DSimConnectv42; }
264-
if (p.contains("43")) { return P3DSimConnectv43; }
265-
if (p.contains("44")) { return P3DSimConnectv44; }
266-
if (p.contains("45")) { return P3DSimConnectv45; }
267-
268-
if (p.contains("50")) { return P3DSimConnectv45; }
269-
if (p.contains("51")) { return P3DSimConnectv45; }
270-
if (p.contains("52")) { return P3DSimConnectv45; }
271-
}
272-
return P3DSimConnectv44; // default
273-
}
274-
275-
bool loadAndResolveP3DSimConnect(P3DSimConnectVersion version)
276-
{
277-
// Check if already loaded
278-
if (gSymbols.SimConnect_Open) { return true; }
279-
280-
QString simConnectFileName(QStringLiteral("SimConnect.P3D-"));
281-
282-
switch (version)
283-
{
284-
case P3DSimConnectv40: simConnectFileName += "v4.0"; break;
285-
case P3DSimConnectv41: simConnectFileName += "v4.1"; break;
286-
case P3DSimConnectv42: simConnectFileName += "v4.2"; break;
287-
case P3DSimConnectv43: simConnectFileName += "v4.3"; break;
288-
case P3DSimConnectv44: simConnectFileName += "v4.4"; break;
289-
case P3DSimConnectv45: simConnectFileName += "v4.5"; break;
290-
}
291-
292-
QLibrary simConnectDll(simConnectFileName);
293-
simConnectDll.setLoadHints(QLibrary::PreventUnloadHint);
294-
if (simConnectDll.load())
295-
{
296-
const bool resolvedCommon = resolveCommonSimConnectSymbols(simConnectDll);
297-
const bool resolvedP3DSimConnectSymbols = resolveP3DSimConnectSymbols(simConnectDll);
298-
if (!resolvedCommon)
299-
{
300-
CLogMessage(CLogCategories::driver()).error(u"Failed to resolve common symbols from SimConnect.dll: '%1'")
301-
<< simConnectFileName;
302-
return false;
303-
}
304-
if (!resolvedP3DSimConnectSymbols)
305-
{
306-
CLogMessage(CLogCategories::driver()).error(u"Failed to resolve P3D symbols from SimConnect.dll: '%1'")
307-
<< simConnectFileName;
308-
return false;
309-
}
310-
311-
CLogMessage(CLogCategories::driver()).info(u"Loaded and resolved P3D symbols from SimConnect.dll: '%1'")
312-
<< simConnectFileName;
313-
return resolvedCommon && resolvedP3DSimConnectSymbols;
314-
}
315-
else
316-
{
317-
CLogMessage(CLogCategories::driver()).error(u"Failed to load SimConnect.dll: '%1' '%2'")
318-
<< simConnectFileName << simConnectDll.errorString();
319-
return false;
320-
}
321-
}
322-
323-
bool loadAndResolveMSFSimConnect()
324-
{
325-
// Check if already loaded
326-
if (gSymbols.SimConnect_Open) { return true; }
327-
328-
QString simConnectFileName(QStringLiteral("SimConnect.MSFS"));
329-
330-
QLibrary simConnectDll(simConnectFileName);
331-
simConnectDll.setLoadHints(QLibrary::PreventUnloadHint);
332-
if (simConnectDll.load())
333-
{
334-
const bool resolvedCommon = resolveCommonSimConnectSymbols(simConnectDll);
335-
if (!resolvedCommon)
336-
{
337-
CLogMessage(CLogCategories::driver()).error(u"Failed to resolve common symbols from SimConnect.dll: '%1'")
338-
<< simConnectFileName;
339-
return false;
340-
}
341-
342-
CLogMessage(CLogCategories::driver()).info(u"Loaded and resolved MSFS symbols from SimConnect.dll: '%1'")
343-
<< simConnectFileName;
344-
return resolvedCommon;
345-
}
346-
else
347-
{
348-
CLogMessage(CLogCategories::driver()).error(u"Failed to load SimConnect.dll: '%1' '%2'")
349-
<< simConnectFileName << simConnectDll.errorString();
350-
return false;
351-
}
352-
}
353256

354257
bool loadAndResolveMSFS2024SimConnect()
355258
{
@@ -362,7 +265,7 @@ bool loadAndResolveMSFS2024SimConnect()
362265
simConnectDll.setLoadHints(QLibrary::PreventUnloadHint);
363266
if (simConnectDll.load())
364267
{
365-
const bool resolvedCommon = resolveCommonSimConnectSymbols(simConnectDll);
268+
const bool resolvedCommon = resolveMsfs2024SimConnectSymbols(simConnectDll);
366269
if (!resolvedCommon)
367270
{
368271
CLogMessage(CLogCategories::driver()).error(u"Failed to resolve common symbols from SimConnect.dll: '%1'")
@@ -382,65 +285,7 @@ bool loadAndResolveMSFS2024SimConnect()
382285
}
383286
}
384287

385-
#else
386-
bool loadAndResolveFsxSimConnect(bool manifestProbing)
387-
{
388-
// Check if already loaded
389-
if (gSymbols.SimConnect_Open) { return true; }
390288

391-
QLibrary simConnectDll(QStringLiteral("SimConnect"));
392-
simConnectDll.setLoadHints(QLibrary::PreventUnloadHint);
393-
if (manifestProbing)
394-
{
395-
HMODULE hInst = nullptr;
396-
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)loadAndResolveSimConnect, &hInst);
397-
wchar_t szModuleName[MAX_PATH];
398-
GetModuleFileName(hInst, szModuleName, MAX_PATH);
399-
400-
// 101 => "SimConnect_RTM.manifest"
401-
// 102 => "SimConnect_SP1.manifest"
402-
// 103 => "SimConnect_XPack.manifest"
403-
// Use only SP1 and XPack, since RTM is missing two important symbols.
404-
// Try the latest one first.
405-
std::array<WORD, 2> resourceNumbers = { { 103U, 102U } };
406-
407-
for (const auto resourceNumber : resourceNumbers)
408-
{
409-
ACTCTX actCtx;
410-
memset(&actCtx, 0, sizeof(ACTCTX));
411-
actCtx.cbSize = sizeof(actCtx);
412-
actCtx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID;
413-
actCtx.lpSource = szModuleName;
414-
actCtx.lpResourceName = MAKEINTRESOURCE(resourceNumber);
415-
416-
HANDLE hActCtx;
417-
hActCtx = CreateActCtx(&actCtx);
418-
if (hActCtx != INVALID_HANDLE_VALUE)
419-
{
420-
ULONG_PTR lpCookie = 0;
421-
if (ActivateActCtx(hActCtx, &lpCookie))
422-
{
423-
simConnectDll.load();
424-
DeactivateActCtx(0, lpCookie);
425-
if (simConnectDll.isLoaded()) { break; }
426-
}
427-
}
428-
ReleaseActCtx(hActCtx);
429-
}
430-
}
431-
432-
// If at that stage, no SimConnect library was found in the WinSxS folder, try once without activation context to
433-
// link to the one we ship ourselves.
434-
if (!simConnectDll.isLoaded()) { simConnectDll.load(); }
435-
436-
if (simConnectDll.isLoaded()) { return resolveCommonSimConnectSymbols(simConnectDll); }
437-
else
438-
{
439-
CLogMessage(CLogCategories::driver()).error(u"Failed to load SimConnect.dll: %1")
440-
<< simConnectDll.errorString();
441-
return false;
442-
}
443-
}
444289

445290
#endif
446291

src/plugins/simulator/msfs2024/simconnectsymbolsmsfs2024.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212

1313
#ifdef Q_OS_WIN64
1414

15-
//! P3D versions
16-
enum P3DSimConnectVersion
17-
{
18-
P3DSimConnectv40,
19-
P3DSimConnectv41,
20-
P3DSimConnectv42,
21-
P3DSimConnectv43,
22-
P3DSimConnectv44,
23-
P3DSimConnectv45
24-
};
15+
////! P3D versions
16+
//enum P3DSimConnectVersion
17+
//{
18+
// P3DSimConnectv40,
19+
// P3DSimConnectv41,
20+
// P3DSimConnectv42,
21+
// P3DSimConnectv43,
22+
// P3DSimConnectv44,
23+
// P3DSimConnectv45
24+
//};
2525

2626
//! FSXCOMMON_EXPORT to the enum
2727
//MSFS2024COMMON_EXPORT P3DSimConnectVersion stringToP3DVersion(const QString &p3d);

src/plugins/simulator/msfs2024/simulatormsfs2024common.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "misc/simulation/fscommon/aircraftcfgparser.h"
2626
#include "misc/simulation/fscommon/bcdconversions.h"
2727
#include "misc/simulation/fscommon/fscommonutil.h"
28-
#include "misc/simulation/msfs2024/msfs2024util.h"
2928
#include "misc/simulation/fsx/simconnectutilities.h"
3029
#include "misc/simulation/interpolation/interpolatormulti.h"
3130
#include "misc/simulation/settings/simulatorsettings.h"
@@ -44,7 +43,7 @@ using namespace swift::misc::math;
4443
using namespace swift::misc::simulation;
4544
using namespace swift::misc::simulation::fscommon;
4645
using namespace swift::misc::simulation::fsx;
47-
using namespace swift::misc::simulation::msfs2024;
46+
//using namespace swift::misc::simulation::msfs2024;
4847
using namespace swift::misc::simulation::settings;
4948
using namespace swift::core;
5049
using namespace swift::simplugin::fscommon;

src/plugins/simulator/msfs2024/simulatormsfs2024common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
# include "misc/statusmessage.h"
2828
# include "plugins/simulator/fscommon/simulatorfscommon.h"
2929
# include "plugins/simulator/fsxcommon/fsxcommonexport.h"
30-
# include "plugins/simulator/fsxcommon/simconnectwindows.h"
3130
# include "plugins/simulator/msfs2024/simconnectdatadefinitionmsfs2024.h"
3231
# include "plugins/simulator/msfs2024/simconnectobjectmsfs2024.h"
32+
# include "plugins/simulator/fsxcommon/simconnectwindows.h"
3333

3434
namespace swift::simplugin::msfs2024common
3535
{
@@ -768,4 +768,4 @@ namespace swift::simplugin::msfs2024common
768768
};
769769
} // namespace swift::simplugin::msfs2024common
770770

771-
#endif // SWIFT_SIMPLUGIN_MSFS2024COMMON_SIMULATORFSXCOMMON_H
771+
#endif // SWIFT_SIMPLUGIN_MSFS2024COMMON_SIMULATORMSFS2024COMMON_H

0 commit comments

Comments
 (0)