mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-30 05:28:15 +03:00
Small code style changes
This commit is contained in:
parent
ab5cf4e658
commit
3abd53753d
2 changed files with 24 additions and 25 deletions
|
@ -1,5 +1,6 @@
|
||||||
import type Launcher from '../../Launcher';
|
import type Launcher from '../../Launcher';
|
||||||
import { Debug, Notification, fs, path } from '../../../empathize';
|
|
||||||
|
import { Debug, fs, path } from '../../../empathize';
|
||||||
|
|
||||||
import constants from '../../Constants';
|
import constants from '../../Constants';
|
||||||
import Patch from "../../Patch";
|
import Patch from "../../Patch";
|
||||||
|
@ -10,16 +11,17 @@ declare const Neutralino;
|
||||||
export default (launcher: Launcher): Promise<void> => {
|
export default (launcher: Launcher): Promise<void> => {
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
const gameDir = await constants.paths.gameDir;
|
const gameDir = await constants.paths.gameDir;
|
||||||
|
|
||||||
Neutralino.filesystem.readFile(`${gameDir}/pkg_version`)
|
Neutralino.filesystem.readFile(`${gameDir}/pkg_version`)
|
||||||
.then(async (files) => {
|
.then(async (files) => {
|
||||||
let checkErrors = 0;
|
let mismatchedFiles = [];
|
||||||
|
|
||||||
files = files.split(/\r\n|\r|\n/).filter((file) => file != '');
|
files = files.split(/\r\n|\r|\n/).filter((file) => file != '');
|
||||||
|
|
||||||
const patch = await Patch.latest;
|
|
||||||
|
|
||||||
if (files.length > 0)
|
if (files.length > 0)
|
||||||
{
|
{
|
||||||
|
const patch = await Patch.latest;
|
||||||
|
|
||||||
launcher.progressBar?.init({
|
launcher.progressBar?.init({
|
||||||
label: Locales.translate('launcher.progress.game.integrity_check') as string,
|
label: Locales.translate('launcher.progress.game.integrity_check') as string,
|
||||||
showSpeed: false,
|
showSpeed: false,
|
||||||
|
@ -31,29 +33,22 @@ export default (launcher: Launcher): Promise<void> => {
|
||||||
launcher.progressBar?.show();
|
launcher.progressBar?.show();
|
||||||
|
|
||||||
let current = 0, total = files.length;
|
let current = 0, total = files.length;
|
||||||
const mismatchedFiles = new Array();
|
|
||||||
|
|
||||||
for (const file of files)
|
for (const file of files)
|
||||||
{
|
{
|
||||||
// {"remoteName": "GenshinImpact_Data/StreamingAssets/AssetBundles/blocks/00/16567284.blk", "md5": "79ab71cfff894edeaaef025ef1152b77", "fileSize": 3232361}
|
// {"remoteName": "AnAnimeGame_Data/StreamingAssets/AssetBundles/blocks/00/16567284.blk", "md5": "79ab71cfff894edeaaef025ef1152b77", "fileSize": 3232361}
|
||||||
const fileCheckInfo = JSON.parse(file) as { remoteName: string, md5: string, fileSize: number };
|
const fileCheckInfo = JSON.parse(file) as { remoteName: string, md5: string, fileSize: number };
|
||||||
|
|
||||||
if (await fs.exists(`${gameDir}/${fileCheckInfo.remoteName}`))
|
// If this file exists, it's not UnityPlayer.dll,
|
||||||
|
// or if it's UnityPlayer.dll, but patch wasn't applied
|
||||||
|
if (await fs.exists(`${gameDir}/${fileCheckInfo.remoteName}`) &&
|
||||||
|
(!fileCheckInfo.remoteName.includes('UnityPlayer.dll') || !patch.applied))
|
||||||
{
|
{
|
||||||
const process = await Neutralino.os.execCommand(`md5sum "${path.addSlashes(`${gameDir}/${fileCheckInfo.remoteName}`)}" | awk '{ print $1 }'`);
|
const process = await Neutralino.os.execCommand(`md5sum "${path.addSlashes(`${gameDir}/${fileCheckInfo.remoteName}`)}"`);
|
||||||
const md5 = process.stdOut || process.stdErr;
|
const fileHash = (process.stdOut || process.stdErr).split(' ')[0];
|
||||||
|
|
||||||
if (md5.substring(0, md5.length - 1) != fileCheckInfo.md5)
|
|
||||||
{
|
|
||||||
if (fileCheckInfo.remoteName.includes('UnityPlayer.dll') && patch.applied)
|
|
||||||
console.log('UnityPlayer patched. Skipping check...');
|
|
||||||
else
|
|
||||||
{
|
|
||||||
++checkErrors;
|
|
||||||
mismatchedFiles.push(fileCheckInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (fileHash != fileCheckInfo.md5)
|
||||||
|
mismatchedFiles.push(fileCheckInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
launcher.progressBar?.update(++current, total, 1);
|
launcher.progressBar?.update(++current, total, 1);
|
||||||
|
@ -61,13 +56,17 @@ export default (launcher: Launcher): Promise<void> => {
|
||||||
|
|
||||||
Debug.log({
|
Debug.log({
|
||||||
function: 'Launcher/States/Integrity',
|
function: 'Launcher/States/Integrity',
|
||||||
message: `Checked ${total} files${checkErrors > 0 ? `, there were ${checkErrors} mismatch(es):\n${JSON.stringify(mismatchedFiles, null, 4)}` : ', there were no mismatches'}`
|
message: mismatchedFiles.length == 0 ?
|
||||||
|
`Checked ${total} files with ${mismatchedFiles.length} mismatches` :
|
||||||
|
[
|
||||||
|
`Checked ${total} files with ${mismatchedFiles.length} mismatches:`,
|
||||||
|
...mismatchedFiles
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
mismatchedFiles.length = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
launcher.progressBar?.hide();
|
launcher.progressBar?.hide();
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.catch(() => resolve());
|
.catch(() => resolve());
|
||||||
|
|
Loading…
Reference in a new issue