Compare commits

..

No commits in common. "d554b6b9680475d89a6dea93aa0a7e728b77127e" and "7bc438d76a3de25b73c96636690de34d6637974a" have entirely different histories.

10 changed files with 1955 additions and 1760 deletions

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020-2023 OpenFusion Contributors
Copyright (c) 2020-2022 OpenFusion Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -54,7 +54,7 @@ body {
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}
#of-versionnumberdiv {
#of-versionnumber {
position: fixed;
bottom: 4px;
right: 8px;

View File

@ -25,23 +25,6 @@ function disableServerListButtons() {
$("#of-deleteserver-button").prop("disabled", true);
}
function getAppVersion() {
appversion = remote.require("app").getVersion();
// simplify version, ex. 1.4.0 -> 1.4,
// but only if a revision number isn't present
if(appversion.endsWith(".0")){
return appversion.substr(0, appversion.length - 2)
} else {
return appversion
}
}
function setAppVersionText() {
$("#of-aboutversionnumber").text("Version " + getAppVersion());
$("#of-versionnumber").text("v" + getAppVersion());
}
function addServer() {
var jsontomodify = JSON.parse(
remotefs.readFileSync(userdir + "\\servers.json")
@ -172,50 +155,6 @@ function loadServerList() {
}
}
function performCacheSwap(newversion) {
var cacheroot = userdir + "\\..\\..\\LocalLow\\Unity\\Web Player\\Cache";
var currentcache = cacheroot + "\\Fusionfall";
var newcache = cacheroot + "\\" + newversion;
var record = userdir + "\\.lastver";
// if cache renaming would result in a no-op (ex. launching the same version
// two times), then skip it. this avoids permissions errors with multiple clients
// (file/folder is already open in another process)
var skip = false;
if (remotefs.existsSync(currentcache)) {
// cache already exists, find out what version it belongs to
if (remotefs.existsSync(record)) {
lastversion = remotefs.readFileSync(record);
if (lastversion != newversion) {
remotefs.renameSync(
currentcache,
cacheroot + "\\" + lastversion
);
} else {
console.log(
"Cached version unchanged, renaming will be skipped"
);
skip = true;
}
console.log("Current cache is " + lastversion);
} else {
console.log(
"Couldn't find last version record; cache may get overwritten"
);
}
}
if (remotefs.existsSync(newcache) || !skip) {
// rename saved cache to FusionFall
remotefs.renameSync(newcache, currentcache);
console.log("Current cache swapped to " + newversion);
}
// make note of what version we are launching for next launch
remotefs.writeFileSync(record, newversion);
}
// For writing loginInfo.php, assetInfo.php, etc.
function setGameInfo(serverUUID) {
var result = serverarray.filter(function (obj) {
@ -225,17 +164,38 @@ function setGameInfo(serverUUID) {
return obj.name === result.version;
})[0];
// if cache swapping property exists AND is `true`, run cache swapping logic
if (config["cache-swapping"]) {
try {
performCacheSwap(gameversion.name);
} catch (ex) {
// 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";
var newversion = cachedir + "\\" + gameversion.name;
var record = userdir + "\\.lastver";
if (remotefs.existsSync(curversion)) {
// cache already exists
// find out what version it belongs to
if (remotefs.existsSync(record)) {
var lastversion = remotefs.readFileSync(record);
remotefs.renameSync(curversion, cachedir + "\\" + lastversion);
console.log("Cached version " + lastversion);
} else {
console.log(
"Error when swapping cache, it may get overwritten:\n" + ex
"Couldn't find last version record; cache may get overwritten"
);
}
}
if (remotefs.existsSync(newversion)) {
// rename saved cache to FusionFall
remotefs.renameSync(newversion, curversion);
console.log("Loaded cached " + gameversion.name);
}
// 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
remotefs.writeFileSync(__dirname + "\\assetInfo.php", asseturl);

View File

@ -1,28 +0,0 @@
const fs = require('fs');
const defaultdir = './dist/win-ia32-unpacked/resources/default_app'
const exefile = './dist/win-ia32-unpacked/OpenFusionClient.exe'
exports.default = function() {
// remove leftover files from default electron app
fs.rm(dir, { recursive: true }, (err) => {
if (err) {
throw err;
}
});
// patch executable for large address awareness
fs.open(exefile, "r+", (err, fd) => {
if(!err) {
fs.write(
fd, new Uint8Array([0x22]), 0, 1, 0x166,
(err) => {
if(err) {
throw err;
}
fs.closeSync(fd);
}
);
} else {
throw err;
}
});
}

View File

@ -0,0 +1,10 @@
const fs = require('fs');
const dir = './dist/win-ia32-unpacked/resources/default_app'
exports.default = async function(context) {
fs.rmdir(dir, { recursive: true }, (err) => {
if (err) {
throw err;
}
});
}

View File

@ -0,0 +1,5 @@
PUSHD %~dp0
.\UnityWebPlayer.exe /quiet /S
robocopy WebPlayer "%USERPROFILE%\AppData\LocalLow\Unity\WebPlayer" /s /e
del "%USERPROFILE%\AppData\LocalLow\Unity\WebPlayer\UnityBugReporter.exe"
POPD

View File

@ -151,9 +151,9 @@
</button>
</div>
<div class="modal-body">
<p id="of-aboutversionnumber" class="text-monospace">APP_VERSION_NUMBER</p>
<p class="text-monospace">Version 1.4</p>
<p>
©2020-2023 OpenFusion Contributors<br />OpenFusion
©2020-2022 OpenFusion Contributors<br />OpenFusion
is licensed under MIT.<br />
</p>
<a
@ -447,14 +447,13 @@
</div>
</div>
</div>
<div id="of-versionnumberdiv">
<div id="of-versionnumber">
<a
id="of-versionnumber"
class="text-monospace text-secondary"
href="#of-aboutmodal"
data-toggle="modal"
data-target="#of-aboutmodal"
>v0</a
>v1.4</a
>
</div>
</section>

View File

@ -9,51 +9,6 @@ var mainWindow = null;
app.commandLine.appendSwitch("--enable-npapi");
function verifyUnity() {
var dllpath =
app.getPath("appData") +
"\\..\\LocalLow\\Unity\\WebPlayer\\player\\fusion-2.x.x\\webplayer_win.dll";
if (fs.existsSync(dllpath)) {
var buff = fs.readFileSync(dllpath);
var hash = require("crypto")
.createHash("md5")
.update(buff)
.digest("hex");
if (hash == "e5028405b4483de9e5e5fe9cd5f1e98f") {
return true;
}
}
return false;
}
function installUnity(callback) {
var utilsdir = __dirname + "\\..\\..\\utils";
// if running in non-packaged / development mode, this dir will be slightly different
if (process.env.npm_node_execpath) {
utilsdir = app.getAppPath() + "\\build\\utils";
}
// run the installer silently
var child = require("child_process").spawn(
utilsdir + "\\UnityWebPlayer.exe",
["/quiet", "/S"]
);
child.on("exit", function () {
// overwrite 3.5.2 loader/player with FF's custom version
var dstfolder =
app.getPath("appData") + "..\\LocalLow\\Unity\\WebPlayer";
fs.copySync(utilsdir + "\\WebPlayer", dstfolder, {
clobber: true,
});
// avoids error reporter popping up when closing Electron
fs.removeSync(dstfolder + "\\UnityBugReporter.exe");
console.log("Unity Web Player installed successfully.");
callback();
});
}
function initialSetup(firstTime) {
// Display a small window to inform the user that the app is working
setupWindow = new BrowserWindow({
@ -64,7 +19,13 @@ function initialSetup(firstTime) {
frame: false,
});
setupWindow.loadUrl("file://" + __dirname + "/initialsetup.html");
installUnity(function () {
// Exec installUnity.bat and wait for it to finish.
var child = require("child_process").spawn("cmd.exe", [
"/c",
"utils\\installUnity.bat",
]);
child.on("exit", function () {
console.log("Unity installed.");
if (!firstTime) {
// migration from pre-1.4
// Back everything up, just in case
@ -146,15 +107,11 @@ app.on("ready", function () {
console.log("Pre-1.4 config detected. Running migration.");
initialSetup(false);
} else {
if (verifyUnity()) {
showMainWindow();
} else {
installUnity(showMainWindow);
}
}
}
} catch (ex) {
console.log("An error occurred while checking for the config");
} catch (e) {
console.log("An error occurred while checking for the config.");
}
// Makes it so external links are opened in the system browser, not Electron
@ -174,7 +131,6 @@ function showMainWindow() {
// Reduces white flash when opening the program
mainWindow.webContents.on("did-finish-load", function () {
mainWindow.webContents.executeJavaScript("setAppVersionText();");
mainWindow.show();
// everything's loaded, tell the renderer process to do its thing
mainWindow.webContents.executeJavaScript("loadConfig();");

3481
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,12 @@
{
"name": "OpenFusionClient",
"version": "1.4.1",
"name": "openfusionclient",
"version": "1.4.0",
"description": "OpenFusionClient",
"main": "index.js",
"scripts": {
"postinstall": "npx patch-package && npm explore electron-prebuilt -- npm run postinstall",
"start": "electron .",
"build": "node build.js",
"pack": "electron-builder --win --ia32 --dir",
"dist": "electron-builder --win --ia32",
"prettier": "npx prettier --write ."
@ -13,9 +14,9 @@
"author": "OpenFusion Contributors",
"license": "MIT",
"devDependencies": {
"electron-builder": "^22.14.13",
"electron-builder": "^22.10.5",
"electron-prebuilt": "^0.31.2",
"patch-package": "^6.5.1",
"patch-package": "^6.4.7",
"prettier": "^2.7.1"
},
"repository": {
@ -25,7 +26,7 @@
"build": {
"appId": "xyz.openfusion.client",
"productName": "OpenFusionClient",
"copyright": "© 2020-2023 OpenFusion Contributors",
"copyright": "© 2020-2022 OpenFusion Contributors",
"electronDownload": {
"version": "0.31.2",
"platform": "win32",
@ -51,23 +52,18 @@
},
"files": [
"!patches${/*}",
"!.vscode${/*}",
"!*.php",
"!rankurl.txt",
"!README.md",
"!LICENSE.md",
"!.npmrc",
"!.prettierrc",
"!.prettierignore"
"!.npmrc"
],
"extraFiles": [
"LICENSE.md",
{
"from": "build/utils",
"to": "utils"
}
],
"afterPack": "./build/afterpack.js"
"afterPack": "./build/delete-default-app.js"
},
"dependencies": {
"fs-extra": "^0.30.0"