mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-22 13:40:06 +00:00
Check config before running cache swap logic
This commit is contained in:
parent
c997ab96ec
commit
9c5338da2d
@ -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,34 +97,36 @@ 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];
|
||||||
|
|
||||||
// Cache folder renaming
|
if(config['cache-swapping']) { // if cache swapping property exists AND is `true`, run cache swapping logic
|
||||||
var cachedir = userdir + '\\..\\..\\LocalLow\\Unity\\Web Player\\Cache';
|
// Cache folder renaming
|
||||||
var curversion = cachedir + '\\Fusionfall';
|
var cachedir = userdir + '\\..\\..\\LocalLow\\Unity\\Web Player\\Cache';
|
||||||
var newversion = cachedir + '\\' + gameversion.name;
|
var curversion = cachedir + '\\Fusionfall';
|
||||||
var record = userdir + '\\.lastver';
|
var newversion = cachedir + '\\' + gameversion.name;
|
||||||
|
var record = userdir + '\\.lastver';
|
||||||
|
|
||||||
if (remotefs.existsSync(curversion)) {
|
if (remotefs.existsSync(curversion)) {
|
||||||
// cache already exists
|
// cache already exists
|
||||||
// find out what version it belongs to
|
// find out what version it belongs to
|
||||||
if (remotefs.existsSync(record)) {
|
if (remotefs.existsSync(record)) {
|
||||||
var lastversion = remotefs.readFileSync(record);
|
var lastversion = remotefs.readFileSync(record);
|
||||||
remotefs.renameSync(curversion, cachedir + '\\' + lastversion);
|
remotefs.renameSync(curversion, cachedir + '\\' + lastversion);
|
||||||
console.log('Cached version ' + lastversion);
|
console.log('Cached version ' + lastversion);
|
||||||
} else {
|
} else {
|
||||||
console.log(
|
console.log(
|
||||||
"Couldn't find last version record; cache may get overwritten"
|
"Couldn't find last version record; cache may get overwritten"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (remotefs.existsSync(newversion)) {
|
if (remotefs.existsSync(newversion)) {
|
||||||
// rename saved cache to FusionFall
|
// rename saved cache to FusionFall
|
||||||
remotefs.renameSync(newversion, curversion);
|
remotefs.renameSync(newversion, curversion);
|
||||||
console.log('Loaded cached ' + gameversion.name);
|
console.log('Loaded cached ' + gameversion.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user