From 6561ea923008f1fd5ff14f74f2445df8d1b4a762 Mon Sep 17 00:00:00 2001 From: "[ ]" <[ ]> Date: Wed, 12 Nov 2025 00:40:42 +0900 Subject: [PATCH] refactor: Add support for LDJ-20250825 > account for changes in IIDX32 onward affecting `hooks::soundbank` > `hooks::soundbank` should support any ambiguous IIDX32/33 datacodes again --- hooks/sndbhook.cpp | 50 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/hooks/sndbhook.cpp b/hooks/sndbhook.cpp index 8905f79..13aa6e4 100644 --- a/hooks/sndbhook.cpp +++ b/hooks/sndbhook.cpp @@ -696,6 +696,7 @@ static struct offset_t intptr_t DAT_song_titlel; intptr_t DAT_song_artistl; intptr_t DAT_song_id; + bool is_lstr_wchar; memutils::VProtectGuard *guard; static constexpr unsigned int by_ext(const char *ext, int h = 0) @@ -705,7 +706,7 @@ static struct offset_t } offset_; snd_bank *snd_bank::cache_ = nullptr; size_t snd_bank::cachesz_ = 0; -avcodec::pcm_resampler_t snd_bank::resampler_ = avcodec::bmswac_resampler_s16_ad; +avcodec::pcm_resampler_t snd_bank::resampler_ = avcodec::bmswac_resampler_s16_ad; //_REM: Temporary (revert to bmswac_resampler_s16) static BmsbEnumValidSoundbanks_t BmsbEnumValidSoundbanks; void *on_enum_valid_soundbanks(void *song, int32_t difficulty, int32_t unk2) { @@ -717,7 +718,17 @@ void *on_enum_valid_soundbanks(void *song, int32_t difficulty, int32_t unk2) const int32_t id = *(int32_t *) ((const char *) song + offset_.DAT_song_id); const char suffix = *((const char *) song + offset_.DAT_song_id + 8 + difficulty); - log_info("hooks::soundbank", "Processing s3p->2dx transcoding routine for [{}]({} - {})", id, artistl, titlel); + if (offset_.is_lstr_wchar) + { + std::wstring_convert> converter; + log_info("hooks::soundbank", "Processing s3p->2dx transcoding routine for [{}]({} - {})", + id, + converter.to_bytes(std::wstring(reinterpret_cast(artistl), wcslen(reinterpret_cast(artistl)))), + converter.to_bytes(std::wstring(reinterpret_cast(titlel), wcslen(reinterpret_cast(titlel)))) + ); + } + else + log_info("hooks::soundbank", "Processing s3p->2dx transcoding routine for [{}]({} - {})", id, artistl, titlel); if (!(keysounds = snd_bank::get_bank(id, suffix - '0'))) { log_warning("hooks::soundbank", "soundbank::get_bank() was 0x0, this shouldn't happen.."); @@ -875,21 +886,37 @@ void init(HINSTANCE hmodule, const char *ext) } // Override .text .data per datacode _REV: prefer runtime offset lookup based on universal asm pattern - offset_.DAT_song_titlel = 0x00; - offset_.DAT_song_artistl = 0xc0; - offset_.DAT_song_id = 0x3b0; + long extl = strtol(ext, nullptr, 10); + if (extl < 2019100800) + { + offset_.DAT_song_titlel = 0x00; + offset_.DAT_song_artistl = 0xc0; + offset_.DAT_song_id = 0x1c8; + offset_.is_lstr_wchar = false; + snd_bank::resampler_ = avcodec::bmswac_resampler_s16_ad; + } + else if (extl < 2024082700) + { + offset_.DAT_song_titlel = 0x00; + offset_.DAT_song_artistl = 0xc0; + offset_.DAT_song_id = 0x3b0; + offset_.is_lstr_wchar = false; + } + else + { + offset_.DAT_song_titlel = 0x00; + offset_.DAT_song_artistl = 0x1c0; + offset_.DAT_song_id = 0x67c; + offset_.is_lstr_wchar = true; + } switch (offset_t::by_ext(ext)) { case offset_t::by_ext("2018091900"): offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x1170b0; - offset_.DAT_song_id = 0x1C8; - snd_bank::resampler_ = avcodec::bmswac_resampler_s16_ad; break; case offset_t::by_ext("2019090200"): case offset_t::by_ext("2019100700"): offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x37a540; - offset_.DAT_song_id = 0x1C8; - snd_bank::resampler_ = avcodec::bmswac_resampler_s16_ad; break; case offset_t::by_ext("2020092900"): offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x5ac460; @@ -909,10 +936,11 @@ void init(HINSTANCE hmodule, const char *ext) case offset_t::by_ext("2024082600"): offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x8eae40; break; + case offset_t::by_ext("2025082500"): + offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + 0x969fb0; + break; default: offset_.TX_BmsbEnumValidSoundbanks = (intptr_t) hmodule + (int64_t) avcodec::BmswEnumValidSoundbanksAddr(); - offset_.DAT_song_id = strtol(ext, nullptr, 10) < 2019100800 ? 0x1C8 : offset_.DAT_song_id; - snd_bank::resampler_ = strtol(ext, nullptr, 10) < 2019100800 ? avcodec::bmswac_resampler_s16_ad : snd_bank::resampler_; if (offset_.TX_BmsbEnumValidSoundbanks == (intptr_t) hmodule) { log_warning("hooks::soundbank", "Unsupported game version({}), skipping..", ext);