mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-26 15:20:06 +00:00
Compare commits
No commits in common. "7956f653fbaff553e665ee15b885c1807e2eed5f" and "e11023df54d6787fb92d474b7ed0a0ec2b234501" have entirely different histories.
7956f653fb
...
e11023df54
@ -312,7 +312,6 @@ function editConfig() {
|
||||
remotefs.writeFileSync(configPath, JSON.stringify(jsonToModify, null, 4));
|
||||
|
||||
loadConfig();
|
||||
// check all offline caches if the offline root changes
|
||||
if (shouldChangeRoot) handleCache("hash-check", null, "offline");
|
||||
}
|
||||
|
||||
@ -332,10 +331,6 @@ function validateCacheLocation() {
|
||||
function loadGameVersions() {
|
||||
var versionJson = remotefs.readJsonSync(versionsPath);
|
||||
versionArray = versionJson["versions"];
|
||||
|
||||
$("#addserver-versionselect").empty();
|
||||
$("#editserver-versionselect").empty();
|
||||
|
||||
$.each(versionArray, function (key, value) {
|
||||
$(new Option(value.name, "val")).appendTo("#addserver-versionselect");
|
||||
$(new Option(value.name, "val")).appendTo("#editserver-versionselect");
|
||||
@ -351,7 +346,6 @@ function loadConfig() {
|
||||
$("#editconfig-enableofflinecache").prop("checked", config["enable-offline-cache"]);
|
||||
$("#editconfig-verifyofflinecache").prop("checked", config["verify-offline-cache"]);
|
||||
|
||||
// alter offline root globally
|
||||
offlineRoot = config["offline-cache-location"] || offlineRootDefault;
|
||||
$("#editconfig-offlinecachelocation:text").val(offlineRoot);
|
||||
|
||||
@ -362,7 +356,7 @@ function loadServerList() {
|
||||
var serverJson = remotefs.readJsonSync(serversPath);
|
||||
serverArray = serverJson["servers"];
|
||||
|
||||
deselectServer(); // Remove selection and disable buttons until another server is selected
|
||||
deselectServer(); // Disable buttons until another server is selected
|
||||
$(".server-listing-entry").remove(); // Clear out old stuff, if any
|
||||
|
||||
if (serverArray.length > 0) {
|
||||
@ -390,10 +384,9 @@ function loadServerList() {
|
||||
}
|
||||
|
||||
function loadCacheList() {
|
||||
// we might want to use a new version right away, so reload them
|
||||
loadGameVersions();
|
||||
var versionjson = remotefs.readJsonSync(versionsPath);
|
||||
versionArray = versionjson["versions"];
|
||||
|
||||
// load default hashes.json for reference while running the cache handler
|
||||
if (!defaultHashes) {
|
||||
defaultHashes = remotefs.readJsonSync(path.join(
|
||||
__dirname,
|
||||
@ -401,8 +394,8 @@ function loadCacheList() {
|
||||
));
|
||||
}
|
||||
|
||||
deselectVersion(); // Remove selection and disable buttons until another server is selected
|
||||
$(".cache-listing-entry").remove(); // Clear out old stuff, if any
|
||||
deselectVersion();
|
||||
$(".cache-listing-entry").remove();
|
||||
|
||||
$.each(versionArray, function (key, value) {
|
||||
var row = document.createElement("tr");
|
||||
@ -423,7 +416,6 @@ function loadCacheList() {
|
||||
$("#cache-tablebody").append(row);
|
||||
});
|
||||
|
||||
// simulate a cache handler run so that the buttons update properly
|
||||
storageLoadingStart();
|
||||
storageLoadingUpdate(cacheSizes);
|
||||
storageLoadingComplete(cacheSizes);
|
||||
@ -481,7 +473,6 @@ function getCacheInfoCell(versionString, cacheMode) {
|
||||
var labelCache = document.createElement("label");
|
||||
labelCache.setAttribute("id", labelID);
|
||||
labelCache.setAttribute("for", divID);
|
||||
// pull existing info from cacheSizes when available
|
||||
labelCache.innerHTML = getCacheLabelText(
|
||||
(cacheSizes && cacheSizes[versionString]) ?
|
||||
cacheSizes[versionString][cacheMode] :
|
||||
@ -492,7 +483,6 @@ function getCacheInfoCell(versionString, cacheMode) {
|
||||
divCacheButtons.setAttribute("id", labelID);
|
||||
|
||||
$.each(settings, function (buttonMode, config) {
|
||||
// only delete allowed for playable game caches
|
||||
if (cacheMode === "playable" && buttonMode !== "delete") {
|
||||
return;
|
||||
}
|
||||
@ -507,7 +497,6 @@ function getCacheInfoCell(versionString, cacheMode) {
|
||||
buttonCache.setAttribute("class", config.class);
|
||||
buttonCache.setAttribute("title", config.tooltip);
|
||||
buttonCache.setAttribute("type", "button");
|
||||
// handler setup
|
||||
buttonCache.setAttribute("onclick", "handleCache(\"" + buttonMode + "\", \"" + versionString + "\", \"" + cacheMode + "\");");
|
||||
buttonCache.appendChild(iconItalic);
|
||||
|
||||
@ -522,7 +511,6 @@ function getCacheInfoCell(versionString, cacheMode) {
|
||||
}
|
||||
|
||||
function storageLoadingStart(vString, cMode) {
|
||||
// determine which cache versions and modes to visually update
|
||||
var versionStrings = [];
|
||||
$.each(versionArray, function (key, value) {
|
||||
if (vString) {
|
||||
@ -534,11 +522,9 @@ function storageLoadingStart(vString, cMode) {
|
||||
});
|
||||
var cacheModes = (cMode) ? [cMode] : ["offline", "playable"];
|
||||
|
||||
// deselect and disable the add version button until they are re-enabled
|
||||
deselectVersion();
|
||||
disableVersionAddButton();
|
||||
|
||||
// turn buttons into spinners
|
||||
$.each(versionStrings, function (vKey, versionString) {
|
||||
$.each(cacheModes, function (cKey, cacheMode) {
|
||||
var buttonDelete = document.getElementById(getCacheButtonID(versionString, cacheMode, "delete"));
|
||||
@ -562,7 +548,6 @@ function storageLoadingStart(vString, cMode) {
|
||||
}
|
||||
|
||||
function storageLoadingUpdate(allSizes) {
|
||||
// update cacheSizes and display results
|
||||
$.each(allSizes, function (versionString, vSizes) {
|
||||
$.each(vSizes, function (cacheMode, sizes) {
|
||||
var label = document.getElementById(getCacheElemID(versionString, cacheMode, "label"));
|
||||
@ -579,7 +564,6 @@ function storageLoadingUpdate(allSizes) {
|
||||
}
|
||||
|
||||
function storageLoadingComplete(allSizes) {
|
||||
// re-enable buttons according to the sizes that were read
|
||||
$.each(allSizes, function (versionString, vSizes) {
|
||||
$.each(vSizes, function (cacheMode, sizes) {
|
||||
var buttonDelete = document.getElementById(getCacheButtonID(versionString, cacheMode, "delete"));
|
||||
@ -616,33 +600,24 @@ function storageLoadingComplete(allSizes) {
|
||||
});
|
||||
});
|
||||
|
||||
// finally, re-enable the version add button
|
||||
enableVersionAddButton();
|
||||
}
|
||||
|
||||
function handleCache(operation, versionString, cacheMode, callback) {
|
||||
// see if any versions match (could be undefined or null)
|
||||
var versions = versionArray.filter(function (obj) {
|
||||
return obj.name === versionString;
|
||||
});
|
||||
// pull version url from the found object, if none found, use the default cdn link
|
||||
var cdnRoot = (versions.length === 0) ? cdnString : versions[0].url;
|
||||
|
||||
var lastSizes = { intact: 0, altered: 0, total: 0 };
|
||||
var buf = "";
|
||||
|
||||
// start loading on the given version and mode (could be undefined or null, which means 'all')
|
||||
storageLoadingStart(versionString, cacheMode);
|
||||
|
||||
// create the server and socket listener
|
||||
var server = net.createServer(function (sock) {
|
||||
sock.setEncoding("utf8");
|
||||
|
||||
sock.on("data", function (data) {
|
||||
// read data until the next \n, and keep reading
|
||||
// sometimes the updates are buffered, so there might be multiple objects
|
||||
// per update, and partial objects as well
|
||||
// buffer parsing allows us to handle these cases
|
||||
buf += data;
|
||||
|
||||
var end = buf.indexOf("\n");
|
||||
@ -651,7 +626,6 @@ function handleCache(operation, versionString, cacheMode, callback) {
|
||||
var sub = buf.substring(0, end);
|
||||
buf = buf.substring(end + 1);
|
||||
|
||||
// run a storage update here
|
||||
lastSizes = JSON.parse(sub);
|
||||
storageLoadingUpdate(lastSizes);
|
||||
|
||||
@ -660,7 +634,6 @@ function handleCache(operation, versionString, cacheMode, callback) {
|
||||
});
|
||||
});
|
||||
|
||||
// start listening on a randomly acquired port, and spawn cache handler when ready
|
||||
server.listen(0, "localhost", function () {
|
||||
spawn(
|
||||
path.join(__dirname, "lib", "cache_handler.exe"),
|
||||
@ -674,9 +647,7 @@ function handleCache(operation, versionString, cacheMode, callback) {
|
||||
"--cdn-root", cdnRoot,
|
||||
"--cache-mode", cacheMode || "all",
|
||||
"--cache-version", versionString || "all",
|
||||
// learn port from the server object and tell the script where to connect
|
||||
"--port", server.address().port,
|
||||
// tell the script which versions and caches are official
|
||||
"--official-caches"
|
||||
].concat(Object.keys(defaultHashes)),
|
||||
{
|
||||
@ -690,12 +661,10 @@ function handleCache(operation, versionString, cacheMode, callback) {
|
||||
);
|
||||
}
|
||||
|
||||
// when the script exits, close the server
|
||||
server.close();
|
||||
// set button state accordingly
|
||||
storageLoadingComplete(lastSizes);
|
||||
// then run the given callback (if any)
|
||||
if (callback) callback(lastSizes);
|
||||
if (callback)
|
||||
callback(lastSizes);
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -780,7 +749,7 @@ function prepGameInfo(serverUUID) {
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise, if main.unity3d is present, use the offline cache
|
||||
// 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);
|
||||
@ -788,7 +757,6 @@ function prepGameInfo(serverUUID) {
|
||||
|
||||
// For writing loginInfo.php, assetInfo.php, etc.
|
||||
function setGameInfo(serverInfo, versionURL) {
|
||||
// slash fix if people mess it up via text editors
|
||||
var versionURLRoot = versionURL.endsWith("/") ? versionURL : versionURL + "/";
|
||||
window.assetUrl = versionURLRoot; // game-client.js needs to access this
|
||||
console.log("Cache will expand from " + versionURLRoot);
|
||||
@ -866,7 +834,6 @@ function getSelectedServer() {
|
||||
return $("#server-tablebody > tr.bg-primary").prop("id");
|
||||
}
|
||||
|
||||
// Returns the name of the version with the selected background color.
|
||||
function getSelectedVersion() {
|
||||
return $("#cache-tablebody > tr.bg-primary").prop("id");
|
||||
}
|
||||
@ -892,19 +859,16 @@ function deselectServer() {
|
||||
$(".server-listing-entry").removeClass("bg-primary");
|
||||
}
|
||||
|
||||
// If applicable, deselect currently selected version.
|
||||
function deselectVersion() {
|
||||
disableVersionListButtons();
|
||||
$(".cache-listing-entry").removeClass("bg-primary");
|
||||
}
|
||||
|
||||
// Select a server
|
||||
$("#server-table").on("click", ".server-listing-entry", function (event) {
|
||||
enableServerListButtons();
|
||||
$(this).addClass("bg-primary").siblings().removeClass("bg-primary");
|
||||
});
|
||||
|
||||
// Select a version (if allowed)
|
||||
$("#cache-table").on("click", ".cache-listing-entry", function (event) {
|
||||
// wait for the add button to be re-enabled first
|
||||
if ($("#of-addversion-button").prop("disabled")) return;
|
||||
@ -930,7 +894,6 @@ $("#of-addversionmodal").on("show.bs.modal", function (e) {
|
||||
});
|
||||
|
||||
$("#of-editservermodal").on("show.bs.modal", function (e) {
|
||||
// populate the edit modal with existing values
|
||||
var jsonToModify = remotefs.readJsonSync(serversPath);
|
||||
|
||||
$.each(jsonToModify["servers"], function (key, value) {
|
||||
@ -952,7 +915,6 @@ $("#of-editservermodal").on("show.bs.modal", function (e) {
|
||||
});
|
||||
|
||||
$("#of-editversionmodal").on("show.bs.modal", function (e) {
|
||||
// populate the edit modal with existing values
|
||||
var jsonToModify = remotefs.readJsonSync(versionsPath);
|
||||
|
||||
$.each(jsonToModify["versions"], function (key, value) {
|
||||
@ -965,7 +927,6 @@ $("#of-editversionmodal").on("show.bs.modal", function (e) {
|
||||
validateVersionSave("edit");
|
||||
});
|
||||
|
||||
// Replace server name to delete
|
||||
$("#of-deleteservermodal").on("show.bs.modal", function (e) {
|
||||
var result = serverArray.filter(function (obj) {
|
||||
return obj.uuid === getSelectedServer();
|
||||
@ -973,7 +934,6 @@ $("#of-deleteservermodal").on("show.bs.modal", function (e) {
|
||||
$("#deleteserver-servername").html(result.description);
|
||||
});
|
||||
|
||||
// Replace version name to delete
|
||||
$("#of-deleteversionmodal").on("show.bs.modal", function (e) {
|
||||
var result = versionArray.filter(function (obj) {
|
||||
return obj.name === getSelectedVersion();
|
||||
@ -981,13 +941,11 @@ $("#of-deleteversionmodal").on("show.bs.modal", function (e) {
|
||||
$("#deleteversion-versionname").html(result.name);
|
||||
});
|
||||
|
||||
// Run the global hash check once and only if the cache modal is ever shown
|
||||
$("#of-editcacheconfigmodal").on("show.bs.modal", function (e) {
|
||||
if (!cacheSizes) handleCache("hash-check");
|
||||
});
|
||||
|
||||
// Keep all config values synced on modal show
|
||||
// Avoids cases where people forget that they changed the offline root but did not save
|
||||
$("#of-editconfigmodal").on("show.bs.modal", function (e) {
|
||||
// best to keep this synced on modal show
|
||||
loadConfig();
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
BIN
lib/cache_handler.exe
vendored
BIN
lib/cache_handler.exe
vendored
Binary file not shown.
Loading…
Reference in New Issue
Block a user