Check config before running cache swap logic

This commit is contained in:
gsemaj 2021-09-18 18:21:41 -04:00
parent c997ab96ec
commit 9c5338da2d

View File

@ -4,6 +4,7 @@ var remotefs = remote.require('fs-extra');
var userdir = remote.require('app').getPath('userData'); var userdir = remote.require('app').getPath('userData');
var versionarray var versionarray
var serverarray var serverarray
var config
function enableServerListButtons() { function enableServerListButtons() {
$('#of-connect-button').removeClass('disabled'); $('#of-connect-button').removeClass('disabled');
@ -56,9 +57,9 @@ function loadGameVersions() {
} }
function loadConfig() { function loadConfig() {
// TODO: actually use these values // load config object globally
var configjson = JSON.parse(remotefs.readFileSync(userdir+"\\config.json")); config = JSON.parse(remotefs.readFileSync(userdir+"\\config.json"));
} }
function loadServerList() { function loadServerList() {
var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
@ -96,6 +97,7 @@ function setGameInfo(serverUUID) {
var result = serverarray.filter(function(obj) {return (obj.uuid === serverUUID);})[0]; var result = serverarray.filter(function(obj) {return (obj.uuid === serverUUID);})[0];
var gameversion = versionarray.filter(function(obj) {return (obj.name === result.version);})[0]; var gameversion = versionarray.filter(function(obj) {return (obj.name === result.version);})[0];
if(config['cache-swapping']) { // if cache swapping property exists AND is `true`, run cache swapping logic
// Cache folder renaming // Cache folder renaming
var cachedir = userdir + '\\..\\..\\LocalLow\\Unity\\Web Player\\Cache'; var cachedir = userdir + '\\..\\..\\LocalLow\\Unity\\Web Player\\Cache';
var curversion = cachedir + '\\Fusionfall'; var curversion = cachedir + '\\Fusionfall';
@ -124,6 +126,7 @@ function setGameInfo(serverUUID) {
// make note of what version we are launching for next launch // make note of what version we are launching for next launch
remotefs.writeFileSync(record, gameversion.name); remotefs.writeFileSync(record, gameversion.name);
}
window.asseturl = gameversion.url; // gameclient.js needs to access this window.asseturl = gameversion.url; // gameclient.js needs to access this