From 5b3e98ce35e5eb2a586f2bc3132e21833e76e3ed Mon Sep 17 00:00:00 2001 From: LegItMate <77503777+LegItMate@users.noreply.github.com> Date: Fri, 23 Sep 2022 22:46:29 +0530 Subject: [PATCH] Fix launcher not working after a Uplay game has been deleted/removed --- src/components/launchers/RockstarGames.js | 2 +- src/components/launchers/Steam.js | 2 +- src/components/launchers/Uplay.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/launchers/RockstarGames.js b/src/components/launchers/RockstarGames.js index c48e93f5..c9d2374d 100644 --- a/src/components/launchers/RockstarGames.js +++ b/src/components/launchers/RockstarGames.js @@ -11,7 +11,7 @@ async function getInstalledGames() { if(allGames === "") return []; allGames = allGames.split(window.__TAURI__.os.EOL.repeat(2)).map(x => { let res = x.split(window.__TAURI__.os.EOL).filter(x => x.length > 1); - const name = res[0].split('HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Rockstar Games\\')[1]; + const name = res[0]?.split('HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Rockstar Games\\')[1]; const paths = res.filter(x => x.trim().startsWith('Install')).filter(async x => await fs.readDir(x.split('REG_SZ')[1].trim()).catch(() => null)); if (!paths[0]) return; const Install = paths[0].split('REG_SZ')[1].trim(); diff --git a/src/components/launchers/Steam.js b/src/components/launchers/Steam.js index b11af9de..529eca71 100644 --- a/src/components/launchers/Steam.js +++ b/src/components/launchers/Steam.js @@ -111,7 +111,7 @@ async function parseGameObject(acf_object = {}) { }; } -async function acf_to_json(acf_content = '') { +function acf_to_json(acf_content = '') { if (acf_content.length === 0) return; return JSON.parse(acf_content.split('\n').slice(1).map((x, i, arr) => { if (x.length === 0) return; diff --git a/src/components/launchers/Uplay.js b/src/components/launchers/Uplay.js index df5242af..43d24a1a 100644 --- a/src/components/launchers/Uplay.js +++ b/src/components/launchers/Uplay.js @@ -36,8 +36,8 @@ async function getInstalledGames() { async function parseGameObject(GameID, registry_res) { registry_res = registry_res.split(window.__TAURI__.os.EOL.repeat(2)).find(x => x.split(window.__TAURI__.os.EOL)[0].endsWith(GameID)); - const Location = registry_res.split('\r\n').map(x => x.trim()).filter(x => x.startsWith('InstallDir'))[0]?.split('REG_SZ')[1].trim(); - if (!(await fs.readDir(Location).catch(() => null))) return; + const Location = registry_res?.split('\r\n').map(x => x.trim()).filter(x => x.startsWith('InstallDir'))[0]?.split('REG_SZ')[1].trim(); + if (!Location || !(await fs.readDir(Location).catch(() => null))) return; const Executable = null; let title = Location.split('/').slice(-2)[0].replaceAll('_', ' '); if (title.match(/\d$/ig) && !title.replaceAll('\\d', '').endsWith(' ')) {