GlosSITarget: Fix pontential settings aprse crash

pull/183/head
Peter Repukat 2 years ago
parent 5754372264
commit dd978ae80c

@ -28,7 +28,6 @@ limitations under the License.
#include <Windows.h> #include <Windows.h>
#endif #endif
namespace Settings { namespace Settings {
inline struct Launch { inline struct Launch {
@ -62,7 +61,6 @@ inline bool extendedLogging = false;
inline std::filesystem::path settings_path_ = ""; inline std::filesystem::path settings_path_ = "";
inline bool checkIsUwp(const std::wstring& launch_path) inline bool checkIsUwp(const std::wstring& launch_path)
{ {
if (launch_path.find(L"://") != std::wstring::npos) { if (launch_path.find(L"://") != std::wstring::npos) {
@ -107,10 +105,10 @@ inline void checkWinVer()
if (isWin10) { if (isWin10) {
spdlog::info("Running on Windows 10; Winver: {}.{}.{}", VN.dwMajorVersion, VN.dwMinorVersion, VN.dwBuildNumber); spdlog::info("Running on Windows 10; Winver: {}.{}.{}", VN.dwMajorVersion, VN.dwMinorVersion, VN.dwBuildNumber);
} else { }
else {
spdlog::info("Running on Windows 11; Winver: {}.{}.{}", VN.dwMajorVersion, VN.dwMinorVersion, VN.dwBuildNumber); spdlog::info("Running on Windows 11; Winver: {}.{}.{}", VN.dwMajorVersion, VN.dwMinorVersion, VN.dwBuildNumber);
} }
} }
#endif #endif
@ -173,8 +171,8 @@ inline void Parse(std::wstring arg1)
} }
// TODO: make this as much generic as fits in about the same amount of code if one would parse every value separately. // TODO: make this as much generic as fits in about the same amount of code if one would parse every value separately.
try {
if (auto launchconf = json["launch"]; launchconf.is_object()) { if (auto launchconf = json["launch"]; launchconf.is_null() && launchconf.empty() && launchconf.is_object()) {
safeParseValue(launchconf, "launch", launch.launch); safeParseValue(launchconf, "launch", launch.launch);
safeWStringParse(launchconf, "launchPath", launch.launchPath); safeWStringParse(launchconf, "launchPath", launch.launchPath);
safeWStringParse(launchconf, "launchAppArgs", launch.launchAppArgs); safeWStringParse(launchconf, "launchAppArgs", launch.launchAppArgs);
@ -182,23 +180,30 @@ inline void Parse(std::wstring arg1)
safeParseValue(launchconf, "waitForChildProcs", launch.waitForChildProcs); safeParseValue(launchconf, "waitForChildProcs", launch.waitForChildProcs);
} }
if (auto devconf = json["devices"]; devconf.is_object()) { if (auto devconf = json["devices"]; devconf.is_null() && devconf.empty() && devconf.is_object()) {
safeParseValue(devconf, "hideDevices", devices.hideDevices); safeParseValue(devconf, "hideDevices", devices.hideDevices);
safeParseValue(devconf, "realDeviceIds", devices.realDeviceIds); safeParseValue(devconf, "realDeviceIds", devices.realDeviceIds);
} }
if (auto winconf = json["window"]; winconf.is_object()) { if (auto winconf = json["window"]; winconf.is_null() && winconf.empty() && winconf.is_object()) {
safeParseValue(winconf, "windowMode", window.windowMode); safeParseValue(winconf, "windowMode", window.windowMode);
safeParseValue(winconf, "maxFps", window.maxFps); safeParseValue(winconf, "maxFps", window.maxFps);
safeParseValue(winconf, "scale", window.scale); safeParseValue(winconf, "scale", window.scale);
safeParseValue(winconf, "disableOverlay", window.disableOverlay); safeParseValue(winconf, "disableOverlay", window.disableOverlay);
} }
if (auto controllerConf = json["controller"]; controllerConf.is_object()) { if (auto controllerConf = json["controller"]; controllerConf.is_null() && controllerConf.empty() && controllerConf.is_object()) {
safeParseValue(controllerConf, "maxControllers", controller.maxControllers); safeParseValue(controllerConf, "maxControllers", controller.maxControllers);
safeParseValue(controllerConf, "allowDesktopConfig", controller.allowDesktopConfig); safeParseValue(controllerConf, "allowDesktopConfig", controller.allowDesktopConfig);
safeParseValue(controllerConf, "emulateDS4", controller.emulateDS4); safeParseValue(controllerConf, "emulateDS4", controller.emulateDS4);
} }
}
catch (const nlohmann::json::exception& e) {
spdlog::warn("Err parsing config: {}", e.what());
}
catch (const std::exception& e) {
spdlog::warn("Err parsing config: {}", e.what());
}
safeParseValue(json, "extendedLogging", extendedLogging); safeParseValue(json, "extendedLogging", extendedLogging);

Loading…
Cancel
Save