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
1 changed files with 30 additions and 27 deletions

View File

@ -4,6 +4,7 @@ var remotefs = remote.require('fs-extra');
var userdir = remote.require('app').getPath('userData');
var versionarray
var serverarray
var config
function enableServerListButtons() {
$('#of-connect-button').removeClass('disabled');
@ -56,9 +57,9 @@ function loadGameVersions() {
}
function loadConfig() {
// TODO: actually use these values
var configjson = JSON.parse(remotefs.readFileSync(userdir+"\\config.json"));
}
// load config object globally
config = JSON.parse(remotefs.readFileSync(userdir+"\\config.json"));
}
function loadServerList() {
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 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
var cachedir = userdir + '\\..\\..\\LocalLow\\Unity\\Web Player\\Cache';
var curversion = cachedir + '\\Fusionfall';
@ -124,6 +126,7 @@ function setGameInfo(serverUUID) {
// make note of what version we are launching for next launch
remotefs.writeFileSync(record, gameversion.name);
}
window.asseturl = gameversion.url; // gameclient.js needs to access this