From bac23d04db8d0c262cc80f87ed103b6af8c83284 Mon Sep 17 00:00:00 2001 From: 3Shain Date: Wed, 4 Dec 2024 14:15:21 +0800 Subject: [PATCH] chore: hkrpg 2.7.0 --- src/clients/mhy/hkrpg/index.tsx | 2 +- src/clients/mhy/unity.ts | 55 ++++++--------------------------- 2 files changed, 11 insertions(+), 46 deletions(-) diff --git a/src/clients/mhy/hkrpg/index.tsx b/src/clients/mhy/hkrpg/index.tsx index 385c7dc..bcf647e 100644 --- a/src/clients/mhy/hkrpg/index.tsx +++ b/src/clients/mhy/hkrpg/index.tsx @@ -40,7 +40,7 @@ import { VoicePackNames } from "../launcher-info"; import createPatchOff from "./config/patch-off"; import { getLatestAdvInfo, getLatestVersionInfo } from "../hyp-connect"; -const CURRENT_SUPPORTED_VERSION = "2.6.0"; +const CURRENT_SUPPORTED_VERSION = "2.7.0"; export async function createHKRPGChannelClient({ server, diff --git a/src/clients/mhy/unity.ts b/src/clients/mhy/unity.ts index 12b7668..7e5779e 100644 --- a/src/clients/mhy/unity.ts +++ b/src/clients/mhy/unity.ts @@ -32,53 +32,18 @@ export async function getGameVersion2019(gameDataDir: string) { if (index == -1) { throw new Error("pattern not found"); //FIXME } else { - let str = ""; - let offset = 0; - try { - for (let i = 0; i < 3; i++) { - for (;;) { - const w = view[index + 0x40 + offset]; - if (w - 48 == -2) { - // dot - str += "."; - offset++; - break; - } else if (w - 48 >= 0 && w - 48 < 10) { - // decimal - str += String.fromCharCode(w); - offset++; - continue; - } else if (i == 2) { - return str; - } else { - throw new Error("Falied to parse version"); - } - } - } - } catch { - // second attempt - for (let i = 0; i < 3; i++) { - for (;;) { - const w = view[index + 0x35 + offset]; - if (w - 48 == -2) { - // dot - str += "."; - offset++; - break; - } else if (w - 48 >= 0 && w - 48 < 10) { - // decimal - str += String.fromCharCode(w); - offset++; - continue; - } else if (i == 2) { - return str; - } else { - throw new Error("Falied to parse version"); - } - } + for (let j = index; j < index + 0x80; j++) { + if (view[j] == 0x2e && view[j + 2] == 0x2e) { + return ( + String.fromCharCode(view[j - 1]) + + "." + + String.fromCharCode(view[j + 1]) + + "." + + String.fromCharCode(view[j + 3]) + ); } } - throw new Error("Assertation: unreachable"); + throw new Error("Falied to parse version"); } }