Minor changes

- removed `js-md5` dependency
- added `core/md5()` function base on system `md5sum` command
  to calculate specified file's md5 hash
- updated `Patch` and `CheckIntegrity` files to follow above changes
- updated statistics, readme and statistics archive pages
This commit is contained in:
Observer KRypt0n_ 2022-03-24 17:46:54 +02:00
parent b1591c3ea8
commit f6a7498b18
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
8 changed files with 44 additions and 33 deletions

View file

@ -62,9 +62,9 @@ We have our own [An Anime Game](https://discord.gg/ck37X6UWBp) discord server wh
This is our current usage statistics. You can find older ones [here](repository/pages/STATISTICS.md) This is our current usage statistics. You can find older ones [here](repository/pages/STATISTICS.md)
### Our discord server — 343 member ### Our discord server — 386 member
<img src="repository/pics/stats/discord.png"> <img src="repository/pics/stats/2022/mar-apr.png">
<br> <br>

View file

@ -12,7 +12,6 @@
}, },
"dependencies": { "dependencies": {
"@empathize/framework": "^1.4.8", "@empathize/framework": "^1.4.8",
"js-md5": "^0.7.3",
"semver": "^7.3.5", "semver": "^7.3.5",
"svelte-i18n": "^3.3.13", "svelte-i18n": "^3.3.13",
"yaml": "^1.10.2" "yaml": "^1.10.2"
@ -21,7 +20,6 @@
"@neutralinojs/neu": "^9.2.0", "@neutralinojs/neu": "^9.2.0",
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.37", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.37",
"@tsconfig/svelte": "^3.0.0", "@tsconfig/svelte": "^3.0.0",
"@types/js-md5": "^0.4.3",
"neutralino-appimage-bundler": "^1.3.2", "neutralino-appimage-bundler": "^1.3.2",
"sass": "^1.49.8", "sass": "^1.49.8",
"svelte": "^3.46.4", "svelte": "^3.46.4",

View file

@ -4,12 +4,19 @@ This file is a launcher usage statistics archive. You can see here which journey
Our current statistics you can find in [readme](../../README.md) Our current statistics you can find in [readme](../../README.md)
### 2.2.0 — 29 total > You can suggest colors for your countries
<img src="../pics/stats/2.2.0.png"> ### 2.4.0
### 2.3.0 — 99 total | Period | Source | Data |
| - | - | - |
| 20 Feb — 10 Mar | Discord server | <img src="../pics/stats/2022/feb-mar.png" height="400px"> |
| 10 Mar — ? | Discord server | <img src="../pics/stats/2022/mar-apr.png" height="400px"> |
### 2.3.0 — 99 total — in-launcher analytics
<img src="../pics/stats/2.3.0.png"> <img src="../pics/stats/2.3.0.png">
> You can suggest colors for your countries ### 2.2.0 — 29 total — in-launcher analytics
<img src="../pics/stats/2.2.0.png">

View file

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View file

@ -1,5 +1,3 @@
import md5 from 'js-md5';
import type { PatchInfo } from './types/Patch'; import type { PatchInfo } from './types/Patch';
import { fetch, promisify, Debug, Cache, path, fs } from '../empathize'; import { fetch, promisify, Debug, Cache, path, fs } from '../empathize';
@ -8,6 +6,7 @@ import { DebugThread } from '@empathize/framework/dist/meta/Debug';
import constants from './Constants'; import constants from './Constants';
import Game from './Game'; import Game from './Game';
import Launcher from './Launcher'; import Launcher from './Launcher';
import md5 from './core/md5';
declare const Neutralino; declare const Neutralino;
@ -306,18 +305,13 @@ export default class Patch
// before responding whether the patch applied or not // before responding whether the patch applied or not
if (cache.value['playerHash'] !== null) if (cache.value['playerHash'] !== null)
{ {
constants.paths.gameDir.then((gameDir) => { const playerHash = await md5(`${await constants.paths.gameDir}/UnityPlayer.dll`);
Neutralino.filesystem.readBinaryFile(`${gameDir}/UnityPlayer.dll`)
.then((currPlayer: ArrayBuffer) => {
cache.value['output']['applied'] = md5(currPlayer) != cache.value['playerHash'];
resolve(cache.value['output']); if (playerHash !== null)
}) cache.value['output']['applied'] = playerHash != cache.value['playerHash'];
.catch(() => resolve(cache.value['output']));
});
} }
else resolve(cache.value['output']); resolve(cache.value['output']);
} }
else reject(cache.value['error']); else reject(cache.value['error']);
@ -403,15 +397,12 @@ export default class Patch
cn: hashesMatches[1][1] cn: hashesMatches[1][1]
}[patchInfo.server]; }[patchInfo.server];
constants.paths.gameDir.then((gameDir) => { const playerHash = await md5(`${await constants.paths.gameDir}/UnityPlayer.dll`);
Neutralino.filesystem.readBinaryFile(`${gameDir}/UnityPlayer.dll`)
.then((currPlayer: ArrayBuffer) => { if (playerHash !== null)
patchInfo.applied = md5(currPlayer) != originalPlayer; patchInfo.applied = playerHash != originalPlayer;
resolveOutput(patchInfo, originalPlayer); resolveOutput(patchInfo, originalPlayer);
})
.catch(() => resolveOutput(patchInfo));
});
} }
else resolveOutput(patchInfo); else resolveOutput(patchInfo);

17
src/ts/core/md5.ts Normal file
View file

@ -0,0 +1,17 @@
import { fs, path } from '../../empathize';
declare const Neutralino;
export default function md5(file: string): Promise<string|null>
{
return new Promise(async (resolve) => {
if (await fs.exists(file))
{
const process = await Neutralino.os.execCommand(`md5sum "${path.addSlashes(file)}"`);
resolve((process.stdOut || process.stdErr).split(' ')[0]);
}
else resolve(null);
});
};

View file

@ -1,7 +1,7 @@
import type Launcher from '../../Launcher'; import type Launcher from '../../Launcher';
import type { PatchInfo } from '../../types/Patch'; import type { PatchInfo } from '../../types/Patch';
import { fs, path, Downloader } from '../../../empathize'; import { fs, Downloader } from '../../../empathize';
import { DebugThread } from '@empathize/framework/dist/meta/Debug'; import { DebugThread } from '@empathize/framework/dist/meta/Debug';
import constants from '../../Constants'; import constants from '../../Constants';
@ -9,6 +9,7 @@ import Patch from '../../Patch';
import Locales from '../Locales'; import Locales from '../Locales';
import Voice from '../../Voice'; import Voice from '../../Voice';
import Game from '../../Game'; import Game from '../../Game';
import md5 from '../../core/md5';
declare const Neutralino; declare const Neutralino;
@ -108,8 +109,7 @@ class FilesVerifier
else if (!fileCheckInfo.remoteName.includes('UnityPlayer.dll') || !this.patch.applied) else if (!fileCheckInfo.remoteName.includes('UnityPlayer.dll') || !this.patch.applied)
{ {
const process = await Neutralino.os.execCommand(`md5sum "${path.addSlashes(`${this.gameDir}/${fileCheckInfo.remoteName}`)}"`); const fileHash = await md5(`${this.gameDir}/${fileCheckInfo.remoteName}`);
const fileHash = (process.stdOut || process.stdErr).split(' ')[0];
if (fileHash != fileCheckInfo.md5) if (fileHash != fileCheckInfo.md5)
{ {
@ -223,9 +223,7 @@ class FilesRepairer
Downloader.download(fileUri, `${gameDir}/${fileInfo.remoteName}.new`).then((stream) => { Downloader.download(fileUri, `${gameDir}/${fileInfo.remoteName}.new`).then((stream) => {
stream.finish(async () => { stream.finish(async () => {
const process = await Neutralino.os.execCommand(`md5sum "${path.addSlashes(`${gameDir}/${fileInfo.remoteName}.new`)}"`); if (await md5(`${gameDir}/${fileInfo.remoteName}.new`) == fileInfo.md5)
if ((process.stdOut || process.stdErr).split(' ')[0] == fileInfo.md5)
{ {
await fs.remove(`${gameDir}/${fileInfo.remoteName}`); await fs.remove(`${gameDir}/${fileInfo.remoteName}`);
await fs.move(`${gameDir}/${fileInfo.remoteName}.new`, `${gameDir}/${fileInfo.remoteName}`); await fs.move(`${gameDir}/${fileInfo.remoteName}.new`, `${gameDir}/${fileInfo.remoteName}`);