2017-12-02 07:59:25 +00:00
|
|
|
const {AssetGuard} = require('./assetguard.js')
|
2017-12-03 03:41:47 +00:00
|
|
|
const ConfigManager = require('./configmanager.js')
|
2018-04-15 04:00:08 +00:00
|
|
|
const os = require('os')
|
2017-12-03 03:41:47 +00:00
|
|
|
const path = require('path')
|
2018-04-15 04:00:08 +00:00
|
|
|
const rimraf = require('rimraf')
|
2017-12-02 07:59:25 +00:00
|
|
|
|
|
|
|
console.log('Preloading')
|
|
|
|
|
2017-12-03 05:38:22 +00:00
|
|
|
// Load ConfigManager
|
|
|
|
ConfigManager.load()
|
2017-12-03 03:41:47 +00:00
|
|
|
|
2017-12-03 05:38:22 +00:00
|
|
|
// Ensure Distribution is downloaded and cached.
|
|
|
|
AssetGuard.retrieveDistributionDataSync(ConfigManager.getGameDirectory(), false)
|
2017-12-03 03:41:47 +00:00
|
|
|
|
2017-12-03 05:38:22 +00:00
|
|
|
// Resolve the selected server if its value has yet to be set.
|
|
|
|
if(ConfigManager.getSelectedServer() == null){
|
2017-12-03 03:41:47 +00:00
|
|
|
console.log('Determining default selected server..')
|
2018-04-16 02:35:14 +00:00
|
|
|
ConfigManager.setSelectedServer(AssetGuard.resolveSelectedServer(ConfigManager.getGameDirectory()).id)
|
2017-12-03 05:38:22 +00:00
|
|
|
ConfigManager.save()
|
2018-04-15 04:00:08 +00:00
|
|
|
}
|
|
|
|
|
2018-04-15 04:49:20 +00:00
|
|
|
// Clean up temp dir incase previous launches ended unexpectedly.
|
2018-04-15 04:00:08 +00:00
|
|
|
rimraf(path.join(os.tmpdir(), ConfigManager.getTempNativeFolder()), (err) => {
|
|
|
|
if(err){
|
|
|
|
console.warn('Error while cleaning temp dir', err)
|
|
|
|
} else {
|
|
|
|
console.log('Cleaned temp dir.')
|
|
|
|
}
|
|
|
|
})
|