From d09f06fb26ee712a4b87ea8723a901f12de6f08e Mon Sep 17 00:00:00 2001 From: gsemaj Date: Thu, 6 May 2021 14:39:09 -0400 Subject: [PATCH 1/3] Implement basic rename-based cache switching --- assets/js/serverselector.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/assets/js/serverselector.js b/assets/js/serverselector.js index d4c5778..5795b3e 100644 --- a/assets/js/serverselector.js +++ b/assets/js/serverselector.js @@ -95,7 +95,36 @@ function loadServerList() { function setGameInfo(serverUUID) { var result = serverarray.filter(function(obj) {return (obj.uuid === serverUUID);})[0]; var gameversion = versionarray.filter(function(obj) {return (obj.name === result.version);})[0]; - window.asseturl = gameversion.url // gameclient.js needs to access this + + // Cache folder renaming + var cachedir = userdir + '\\..\\..\\LocalLow\\Unity\\Web Player\\Cache'; + var curversion = cachedir + '\\Fusionfall'; + var newversion = cachedir + '\\' + gameversion.name; + + if (remotefs.existsSync(curversion)) { + // cache already exists + // find out what version it belongs to + if (remotefs.existsSync(userdir + '\\lastver')) { + var lastversion = remotefs.readFileSync(userdir + '\\lastver'); + remotefs.renameSync(curversion, cachedir + '\\' + lastversion); + console.log('Cached version ' + lastversion); + } else { + console.log( + "Couldn't find last version record; cache will get overwritten" + ); + } + } + + if (remotefs.existsSync(newversion)) { + // rename saved cache to FusionFall + remotefs.renameSync(newversion, curversion); + console.log('Loaded cached ' + gameversion.name); + } + + // make note of what version we are launching for next launch + remotefs.writeFileSync(userdir + '\\lastver', gameversion.name); + + window.asseturl = gameversion.url; // gameclient.js needs to access this remotefs.writeFileSync(__dirname+"\\assetInfo.php", asseturl); remotefs.writeFileSync(__dirname+"\\loginInfo.php", result.ip); From 33be67f7e93e6c2d68636266998e8a7740ef9a21 Mon Sep 17 00:00:00 2001 From: gsemaj Date: Wed, 15 Sep 2021 15:46:12 -0400 Subject: [PATCH 2/3] Make lastver a dotfile to keep it hidden --- assets/js/serverselector.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/assets/js/serverselector.js b/assets/js/serverselector.js index 5795b3e..5c84870 100644 --- a/assets/js/serverselector.js +++ b/assets/js/serverselector.js @@ -100,12 +100,13 @@ function setGameInfo(serverUUID) { var cachedir = userdir + '\\..\\..\\LocalLow\\Unity\\Web Player\\Cache'; var curversion = cachedir + '\\Fusionfall'; var newversion = cachedir + '\\' + gameversion.name; + var record = userdir + '\\.lastver'; if (remotefs.existsSync(curversion)) { // cache already exists // find out what version it belongs to - if (remotefs.existsSync(userdir + '\\lastver')) { - var lastversion = remotefs.readFileSync(userdir + '\\lastver'); + if (remotefs.existsSync(record)) { + var lastversion = remotefs.readFileSync(record); remotefs.renameSync(curversion, cachedir + '\\' + lastversion); console.log('Cached version ' + lastversion); } else { @@ -122,7 +123,7 @@ function setGameInfo(serverUUID) { } // make note of what version we are launching for next launch - remotefs.writeFileSync(userdir + '\\lastver', gameversion.name); + remotefs.writeFileSync(record, gameversion.name); window.asseturl = gameversion.url; // gameclient.js needs to access this From 24a802facc806b92cb931b18cd3ec382579e1a7f Mon Sep 17 00:00:00 2001 From: gsemaj Date: Wed, 15 Sep 2021 15:48:01 -0400 Subject: [PATCH 3/3] Adjust terminology in logging --- assets/js/serverselector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/serverselector.js b/assets/js/serverselector.js index 5c84870..f6bf45a 100644 --- a/assets/js/serverselector.js +++ b/assets/js/serverselector.js @@ -111,7 +111,7 @@ function setGameInfo(serverUUID) { console.log('Cached version ' + lastversion); } else { console.log( - "Couldn't find last version record; cache will get overwritten" + "Couldn't find last version record; cache may get overwritten" ); } }