mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2025-01-01 22:47:19 +03:00
Implemented files verification feature (!45)
This commit is contained in:
parent
f80399bb55
commit
ebe22485e6
17 changed files with 113 additions and 95 deletions
|
@ -25,7 +25,7 @@ launcher:
|
|||
unpacking: Unpacking game...
|
||||
applying_changes: Applying changes...
|
||||
deleting_outdated: Deleting outdated files...
|
||||
integrity_check: Verifying Files...
|
||||
integrity_check: Verifying files...
|
||||
download_mismatch_files: Downloading mismatched files...
|
||||
|
||||
# Voice packages installation
|
||||
|
@ -72,7 +72,7 @@ launcher:
|
|||
ready:
|
||||
launch: Launch
|
||||
predownload: Pre-download update
|
||||
integrity: Verify Files & Repair
|
||||
integrity: Verify and repair files
|
||||
|
||||
# Settings window
|
||||
settings:
|
||||
|
|
|
@ -25,7 +25,7 @@ launcher:
|
|||
unpacking: Descomprimiendo el juego...
|
||||
applying_changes: Applying changes...
|
||||
deleting_outdated: Borrando archivos viejos...
|
||||
integrity_check: Verifying Files...
|
||||
integrity_check: Verifying files...
|
||||
download_mismatch_files: Downloading mismatched files...
|
||||
|
||||
# Instalación de paquetes de voz
|
||||
|
@ -72,7 +72,7 @@ launcher:
|
|||
ready:
|
||||
launch: Jugar
|
||||
predownload: Pre-descargar actualización
|
||||
integrity: Verify Files & Repair
|
||||
integrity: Verify and repair files
|
||||
|
||||
# Ventana de opciones
|
||||
settings:
|
||||
|
|
|
@ -25,7 +25,7 @@ launcher:
|
|||
unpacking: Décompression du jeu...
|
||||
applying_changes: Application des changements...
|
||||
deleting_outdated: Suppression des fichiers non à jour...
|
||||
integrity_check: Verifying Files...
|
||||
integrity_check: Verifying files...
|
||||
download_mismatch_files: Downloading mismatched files...
|
||||
|
||||
# Voice packages installation
|
||||
|
@ -75,7 +75,7 @@ launcher:
|
|||
ready:
|
||||
launch: Lancer
|
||||
predownload: Pre-téléchargement de mise à jour
|
||||
integrity: Verify Files & Repair
|
||||
integrity: Verify and repair files
|
||||
|
||||
# Settings window
|
||||
settings:
|
||||
|
|
|
@ -25,7 +25,7 @@ launcher:
|
|||
unpacking: Játék kibontása folyamatban...
|
||||
applying_changes: Változások alkalmazása...
|
||||
deleting_outdated: Lejárt fájlok kitörlése...
|
||||
integrity_check: Verifying Files...
|
||||
integrity_check: Verifying files...
|
||||
download_mismatch_files: Downloading mismatched files...
|
||||
|
||||
# Voice packages installation
|
||||
|
@ -72,7 +72,7 @@ launcher:
|
|||
ready:
|
||||
launch: Indítás
|
||||
predownload: Frissítés előtöltése
|
||||
integrity: Verify Files & Repair
|
||||
integrity: Verify and repair files
|
||||
|
||||
# Settings window
|
||||
settings:
|
||||
|
|
|
@ -25,7 +25,7 @@ launcher:
|
|||
unpacking: Membongkar game...
|
||||
applying_changes: Applying changes...
|
||||
deleting_outdated: Menghapus file lama...
|
||||
integrity_check: Verifying Files...
|
||||
integrity_check: Verifying files...
|
||||
download_mismatch_files: Downloading mismatched files...
|
||||
|
||||
# Voice packages installation
|
||||
|
@ -72,7 +72,7 @@ launcher:
|
|||
ready:
|
||||
launch: Luncurkan
|
||||
predownload: Pembaruan pra-unduh
|
||||
integrity: Verify Files & Repair
|
||||
integrity: Verify and repair files
|
||||
|
||||
# Settings window
|
||||
settings:
|
||||
|
|
|
@ -25,7 +25,7 @@ launcher:
|
|||
unpacking: Decomprimendo il gioco...
|
||||
applying_changes: Applicando i cambiamenti...
|
||||
deleting_outdated: Cancellando file vecchi...
|
||||
integrity_check: Verifying Files...
|
||||
integrity_check: Verifying files...
|
||||
download_mismatch_files: Downloading mismatched files...
|
||||
|
||||
# Voice packages installation
|
||||
|
@ -72,7 +72,7 @@ launcher:
|
|||
ready:
|
||||
launch: Avvia
|
||||
predownload: Pre-scarica aggiornamento
|
||||
integrity: Verify Files & Repair
|
||||
integrity: Verify and repair files
|
||||
|
||||
# Settings window
|
||||
settings:
|
||||
|
|
|
@ -25,7 +25,7 @@ launcher:
|
|||
unpacking: Pakker ut spill...
|
||||
applying_changes: Applying changes...
|
||||
deleting_outdated: Fjerner utdaterte filer...
|
||||
integrity_check: Verifying Files...
|
||||
integrity_check: Verifying files...
|
||||
download_mismatch_files: Downloading mismatched files...
|
||||
|
||||
# Voice packages installation
|
||||
|
@ -72,7 +72,7 @@ launcher:
|
|||
ready:
|
||||
launch: Start
|
||||
predownload: Forhånds-nedlast oppdatering
|
||||
integrity: Verify Files & Repair
|
||||
integrity: Verify and repair files
|
||||
|
||||
# Settings window
|
||||
settings:
|
||||
|
|
|
@ -25,8 +25,8 @@ launcher:
|
|||
unpacking: Распаковка игры...
|
||||
applying_changes: Применение изменений...
|
||||
deleting_outdated: Удаление устаревших файлов...
|
||||
integrity_check: Verifying Files...
|
||||
download_mismatch_files: Downloading mismatched files...
|
||||
integrity_check: Проверка файлов...
|
||||
download_mismatch_files: Исправление неисправных файлов...
|
||||
|
||||
# Установка звуковых пакетов
|
||||
voice:
|
||||
|
@ -72,7 +72,7 @@ launcher:
|
|||
ready:
|
||||
launch: Запустить
|
||||
predownload: Предзагрузить обновление
|
||||
integrity: Verify Files & Repair
|
||||
integrity: Проверить и исправить файлы
|
||||
|
||||
# Окно настроек
|
||||
settings:
|
||||
|
|
|
@ -3,6 +3,7 @@ splash:
|
|||
title: 启动器加载中
|
||||
phrases:
|
||||
- 一些重要的事情...
|
||||
- 欺负派蒙
|
||||
- 抽神子...
|
||||
- 捡材料...
|
||||
- 凹深渊...
|
||||
|
@ -24,8 +25,8 @@ launcher:
|
|||
unpacking: 解压游戏中...
|
||||
applying_changes: 应用更改...
|
||||
deleting_outdated: 删除过期文件...
|
||||
integrity_check: Verifying Files...
|
||||
download_mismatch_files: Downloading mismatched files...
|
||||
integrity_check: 校验文件中...
|
||||
download_mismatch_files: 重新下载校验失败的文件...
|
||||
|
||||
# Voice packages installation
|
||||
voice:
|
||||
|
@ -71,7 +72,7 @@ launcher:
|
|||
ready:
|
||||
launch: 启动
|
||||
predownload: 预下载更新
|
||||
integrity: Verify Files & Repair
|
||||
integrity: 验证并修复文件
|
||||
|
||||
# Settings window
|
||||
settings:
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 10 KiB |
Binary file not shown.
Before Width: | Height: | Size: 64 KiB |
BIN
src/assets/images/wrench.png
Normal file
BIN
src/assets/images/wrench.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -13,10 +13,10 @@
|
|||
import Game from './ts/Game';
|
||||
import Background from './ts/launcher/Background';
|
||||
|
||||
import Gear from './assets/images/gear.png';
|
||||
import GearActive from './assets/images/gear-active.png';
|
||||
import Download from './assets/images/cloud-download.png';
|
||||
import Integrity from './assets/images/integrity.png';
|
||||
import GearIcon from './assets/images/gear.png';
|
||||
import GearActiveIcon from './assets/images/gear-active.png';
|
||||
import DownloadIcon from './assets/images/cloud-download.png';
|
||||
import WrenchIcon from './assets/images/wrench.png';
|
||||
|
||||
const launcher = new Launcher(onMount);
|
||||
|
||||
|
@ -141,17 +141,17 @@
|
|||
</div>
|
||||
|
||||
<div id="settings">
|
||||
<img src={Gear} class="unactive" alt="Settings">
|
||||
<img src={GearIcon} class="unactive" alt="Settings">
|
||||
|
||||
<img src={GearActive} class="active" alt="Settings">
|
||||
<img src={GearActiveIcon} class="active" alt="Settings">
|
||||
</div>
|
||||
|
||||
<button class="button hint--left hint--small" aria-label="{typeof $locale === 'string' ? $_('launcher.states.ready.integrity') : ''}" id="integrity">
|
||||
<img src={Integrity} alt="Integrity" />
|
||||
<img src={WrenchIcon} alt="Integrity" />
|
||||
</button>
|
||||
|
||||
<button class="button hint--left hint--small" aria-label="{typeof $locale === 'string' ? $_('launcher.states.ready.predownload') : ''}" id="predownload">
|
||||
<img src={Download} alt="Download" />
|
||||
<img src={DownloadIcon} alt="Download" />
|
||||
</button>
|
||||
|
||||
<button class="button hint--top hint--large" aria-label="" id="launch">Launch</button>
|
||||
|
|
|
@ -54,7 +54,7 @@ img.background
|
|||
#pause
|
||||
display: none
|
||||
|
||||
#predownload
|
||||
#predownload, #integrity
|
||||
position: absolute
|
||||
display: none
|
||||
|
||||
|
@ -70,22 +70,6 @@ img.background
|
|||
width: 60%
|
||||
margin: auto
|
||||
|
||||
#integrity
|
||||
position: absolute
|
||||
display: none
|
||||
|
||||
width: 52px
|
||||
height: 52px
|
||||
|
||||
right: 386px
|
||||
bottom: 54px
|
||||
|
||||
border-radius: 8px
|
||||
|
||||
img
|
||||
width: 80%
|
||||
margin: auto
|
||||
|
||||
#settings
|
||||
width: 76px
|
||||
height: 76px
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
runnersRecommendable = true,
|
||||
fpsUnlockerAvailable = true,
|
||||
voiceUpdateRequired = false;
|
||||
|
||||
|
||||
let winevdSettings: object = {},
|
||||
winevdSettingsUpdater = false;
|
||||
|
@ -296,6 +295,13 @@
|
|||
background: true
|
||||
});
|
||||
}} />
|
||||
|
||||
<!-- svelte-ignore missing-declaration -->
|
||||
<Button lang="check files integrity" click={async () => {
|
||||
Neutralino.os.execCommand(`xdg-open "${path.addSlashes(await constants.paths.gameDir)}"`, {
|
||||
background: true
|
||||
});
|
||||
}} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,36 +1,47 @@
|
|||
import type Launcher from '../../Launcher';
|
||||
|
||||
import { Debug, fs, path, Cache, Downloader } from '../../../empathize';
|
||||
import { fs, path, Downloader } from '../../../empathize';
|
||||
import { DebugThread } from '@empathize/framework/dist/meta/Debug';
|
||||
|
||||
import constants from '../../Constants';
|
||||
import Patch from "../../Patch";
|
||||
import Patch from '../../Patch';
|
||||
import Locales from '../Locales';
|
||||
import Voice from "../../Voice";
|
||||
import Voice from '../../Voice';
|
||||
import Game from '../../Game';
|
||||
|
||||
declare const Neutralino;
|
||||
|
||||
async function download(fileInfo): Promise<boolean>
|
||||
type FileInfo = {
|
||||
remoteName: string;
|
||||
md5: string;
|
||||
fileSize: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Try to the repair game's file
|
||||
*/
|
||||
function repairFile(fileInfo: FileInfo): Promise<boolean>
|
||||
{
|
||||
return new Promise(async (resolve) => {
|
||||
const gameDir = await constants.paths.gameDir;
|
||||
const cache = await Cache.get('Game.getLatestData.ServerResponse');
|
||||
const fileUri = `${(await Game.getLatestData()).game.latest.decompressed_path}/${fileInfo.remoteName}`;
|
||||
|
||||
let uri = `${cache!.value['game']['latest']['decompressed_path']}/${fileInfo.remoteName}`;
|
||||
|
||||
Downloader.download(uri, `${gameDir}/${fileInfo.remoteName}.new`).then((stream) => {
|
||||
Downloader.download(fileUri, `${gameDir}/${fileInfo.remoteName}.new`).then((stream) => {
|
||||
stream.finish(async () => {
|
||||
const process = await Neutralino.os.execCommand(`md5sum "${path.addSlashes(`${gameDir}/${fileInfo.remoteName}.new`)}"`);
|
||||
const fileHash = (process.stdOut || process.stdErr).split(' ')[0];
|
||||
|
||||
if (fileHash == fileInfo.md5)
|
||||
if ((process.stdOut || process.stdErr).split(' ')[0] == fileInfo.md5)
|
||||
{
|
||||
await fs.remove(`${gameDir}/${fileInfo.remoteName}`);
|
||||
await fs.move(`${gameDir}/${fileInfo.remoteName}.new`, `${gameDir}/${fileInfo.remoteName}`);
|
||||
|
||||
resolve(true);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
await fs.remove(`${gameDir}/${fileInfo.remoteName}.new`);
|
||||
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
|
@ -42,31 +53,26 @@ export default (launcher: Launcher): Promise<void> => {
|
|||
return new Promise(async (resolve) => {
|
||||
const gameDir = await constants.paths.gameDir;
|
||||
|
||||
const debugThread = new DebugThread('State/IntegrityCheck', 'Checking files integrity...');
|
||||
|
||||
// Check Game and Voice Pack integrity
|
||||
Neutralino.filesystem.readFile(`${gameDir}/pkg_version`)
|
||||
.then(async (files) => {
|
||||
// Check Game and Voice Pack Integrity
|
||||
|
||||
let mismatchedFiles = new Array();
|
||||
|
||||
files = files.split(/\r\n|\r|\n/).filter((file) => file != '');
|
||||
|
||||
const InstalledVoices = await Voice.installed;
|
||||
|
||||
for (const voice of InstalledVoices)
|
||||
{
|
||||
// Add voice packages integrity info
|
||||
for (const voice of await Voice.installed)
|
||||
Neutralino.filesystem.readFile(`${gameDir}/Audio_${Voice.langs[voice.lang]}_pkg_version`)
|
||||
.then(async (vfiles) => {
|
||||
vfiles = vfiles.split(/\r\n|\r|\n/).filter((file) => file != '');
|
||||
files.push(...vfiles);
|
||||
})
|
||||
}
|
||||
.then(async (voiceFiles) => {
|
||||
files.push(...voiceFiles.split(/\r\n|\r|\n/).filter((file) => file != ''));
|
||||
});
|
||||
|
||||
if (files.length > 0)
|
||||
{
|
||||
const patch = await Patch.latest;
|
||||
|
||||
launcher.progressBar?.init({
|
||||
label: Locales.translate('launcher.progress.game.integrity_check') as string,
|
||||
label: Locales.translate<string>('launcher.progress.game.integrity_check'),
|
||||
showSpeed: false,
|
||||
showEta: true,
|
||||
showPercents: true,
|
||||
|
@ -76,11 +82,14 @@ export default (launcher: Launcher): Promise<void> => {
|
|||
launcher.progressBar?.show();
|
||||
|
||||
let current = 0, total = files.length;
|
||||
let mismatchedFiles = new Array();
|
||||
|
||||
debugThread.log(`Verifying ${total} files...`);
|
||||
|
||||
for (const file of files)
|
||||
{
|
||||
// {"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: FileInfo = JSON.parse(file);
|
||||
|
||||
// If the file exists and it's not UnityPlayer.dll
|
||||
// or if it's UnityPlayer.dll but the patch wasn't applied
|
||||
|
@ -91,48 +100,66 @@ export default (launcher: Launcher): Promise<void> => {
|
|||
const fileHash = (process.stdOut || process.stdErr).split(' ')[0];
|
||||
|
||||
if (fileHash != fileCheckInfo.md5)
|
||||
{
|
||||
mismatchedFiles.push(fileCheckInfo);
|
||||
|
||||
debugThread.log({
|
||||
message: [
|
||||
'Wrong file hash found',
|
||||
`[path] ${fileCheckInfo.remoteName}`,
|
||||
`[hash] ${fileHash}`,
|
||||
`[remote hash] ${fileCheckInfo.md5}`
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
launcher.progressBar?.update(++current, total, 1);
|
||||
}
|
||||
|
||||
Debug.log({
|
||||
function: 'Launcher/States/Integrity',
|
||||
debugThread.log({
|
||||
message: mismatchedFiles.length == 0 ?
|
||||
`Checked ${total} files with ${mismatchedFiles.length} mismatches` :
|
||||
[
|
||||
`Checked ${total} files with ${mismatchedFiles.length} mismatch(es):`,
|
||||
...mismatchedFiles.map(e => `[${e.md5}] ${e.remoteName}`)
|
||||
...mismatchedFiles.map((mismatch) => `[${mismatch.md5}] ${mismatch.remoteName}`)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
launcher.progressBar?.hide();
|
||||
// Replace mismatched files
|
||||
|
||||
// Replace mismatched files
|
||||
if (mismatchedFiles.length > 0)
|
||||
{
|
||||
launcher.progressBar?.init({
|
||||
label: Locales.translate<string>('launcher.progress.game.download_mismatch_files'),
|
||||
showSpeed: false,
|
||||
showEta: false,
|
||||
showPercents: true,
|
||||
showTotals: false
|
||||
});
|
||||
|
||||
mismatchedFiles.forEach(async (fileInfo: { remoteName: string, md5: string, fileSize: number }) =>
|
||||
{
|
||||
launcher.progressBar?.init({
|
||||
label: Locales.translate('launcher.progress.game.download_mismatch_files') as string,
|
||||
showSpeed: false,
|
||||
showEta: false,
|
||||
showPercents: false,
|
||||
showTotals: false
|
||||
});
|
||||
let current = 0, total = mismatchedFiles.length;
|
||||
|
||||
download(fileInfo).then(async (success) => {
|
||||
if (!success)
|
||||
Debug.log({
|
||||
function: 'Launcher/States/Integrity',
|
||||
message: `Download of ${fileInfo.remoteName} failed`
|
||||
for (const fileInfo of mismatchedFiles)
|
||||
{
|
||||
await repairFile(fileInfo).then((success) => {
|
||||
if (!success)
|
||||
debugThread.log(`Repair failed: ${fileInfo.remoteName}`);
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
launcher.progressBar?.update(++current, total, 1);
|
||||
}
|
||||
}
|
||||
|
||||
launcher.progressBar?.hide();
|
||||
}
|
||||
|
||||
resolve();
|
||||
})
|
||||
.catch(() => resolve());
|
||||
})
|
||||
.catch(() => {
|
||||
debugThread.log('No pkg_version file provided');
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue