mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-13 02:10:04 +00:00
removed async, adjusted load logic, and hash check
This commit is contained in:
parent
11f0c61a67
commit
6bae0d1ff6
@ -18,6 +18,7 @@ var offlineRoot = path.join(cacheRoot, "Offline");
|
||||
|
||||
var versionArray;
|
||||
var serverArray;
|
||||
var cacheSizes;
|
||||
var config;
|
||||
|
||||
function enableServerListButtons() {
|
||||
@ -288,7 +289,13 @@ function storageLoadingUpdate(allSizes) {
|
||||
$.each(allSizes, function (versionString, vSizes) {
|
||||
$.each(vSizes, function (cacheMode, sizes) {
|
||||
var label = document.getElementById(getCacheElemID(versionString, cacheMode, "label"));
|
||||
|
||||
cacheSizes = cacheSizes || {};
|
||||
cacheSizes[versionString] = cacheSizes[versionString] || {};
|
||||
cacheSizes[versionString][cacheMode] = sizes || {};
|
||||
|
||||
if (!label) return;
|
||||
|
||||
label.innerHTML = getCacheLabelText(sizes);
|
||||
});
|
||||
});
|
||||
@ -417,6 +424,12 @@ function loadCacheList() {
|
||||
});
|
||||
}
|
||||
|
||||
function startHashCheck() {
|
||||
// only run once
|
||||
if (!cacheSizes)
|
||||
handleCache("hash-check");
|
||||
}
|
||||
|
||||
function performCacheSwap(newVersion) {
|
||||
var currentCache = path.join(cacheRoot, "FusionFall");
|
||||
var newCache = path.join(cacheRoot, newVersion);
|
||||
@ -479,19 +492,34 @@ function prepGameInfo(serverUUID) {
|
||||
}
|
||||
}
|
||||
|
||||
handleCache("hash-check", versionInfo.name, "offline", function (sizes) {
|
||||
var versionURL = (sizes.intact < sizes.total) ?
|
||||
versionInfo.url :
|
||||
"file:///" + path.join(offlineRoot, versionInfo.name).replace(/\\/g, "/") + "/";
|
||||
console.log("Cache will expand from " + versionURL);
|
||||
if (config["always-use-cdn"]) {
|
||||
// if we always ignore the offline cache, just use the URL
|
||||
setGameInfo(serverInfo, versionInfo.url);
|
||||
return;
|
||||
}
|
||||
|
||||
setGameInfo(serverInfo, versionURL);
|
||||
});
|
||||
var offlinePath = path.join(offlineRoot, versionInfo.name);
|
||||
var offlineURL = "file:///" + offlinePath.replace(/\\/g, "/") + "/";
|
||||
|
||||
if (config["verify-offline-cache"]) {
|
||||
// if required, do a full hash check, and use the offline cache only if it is fully intact
|
||||
handleCache("hash-check", versionInfo.name, "offline", function (sizes) {
|
||||
var versionURL = (sizes.intact < sizes.total) ? versionInfo.url : offlineURL;
|
||||
setGameInfo(serverInfo, versionURL);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// if main.unity3d is present, use the offline cache
|
||||
var mainPath = path.join(offlinePath, "main.unity3d");
|
||||
var versionURL = remotefs.existsSync(mainPath) ? versionInfo.url : offlineURL;
|
||||
setGameInfo(serverInfo, versionURL);
|
||||
}
|
||||
|
||||
// For writing loginInfo.php, assetInfo.php, etc.
|
||||
function setGameInfo(serverInfo, versionURL) {
|
||||
window.assetUrl = versionURL; // game-client.js needs to access this
|
||||
console.log("Cache will expand from " + versionURL);
|
||||
|
||||
remotefs.writeFileSync(path.join(__dirname, "assetInfo.php"), assetUrl);
|
||||
if (serverInfo.hasOwnProperty("endpoint")) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
{
|
||||
"autoupdate-check": true,
|
||||
"cache-swapping": true,
|
||||
"always-use-cdn": false,
|
||||
"verify-offline-cache": false,
|
||||
"last-version-initialized": "1.5"
|
||||
}
|
||||
|
@ -117,7 +117,7 @@
|
||||
type="button"
|
||||
title="Edit Cache Storage"
|
||||
data-target="#of-editcacheconfigmodal"
|
||||
onclick="handleCache('hash-check')"
|
||||
onclick="startHashCheck()"
|
||||
>
|
||||
<i class="fas fa-cog"></i>
|
||||
</button>
|
||||
|
@ -74,7 +74,6 @@
|
||||
"afterPack": "./build/after-pack.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"fs-extra": "2.0.0",
|
||||
"async": "1.5.2"
|
||||
"fs-extra": "2.0.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user