fix: Solve some missed multi-soundbank song errors

> missed some rarer cases, as long as soundbank is alphanumeric, it should work now
> affected 2dx soundbanks like 01004 and non-digit ones like 28102
This commit is contained in:
[ ]
2026-01-06 00:53:31 +09:00
parent f13c9d0e50
commit 26bc8fdda5
+6 -6
View File
@@ -469,7 +469,7 @@ public:
static snd_bank *new_instance(int id);
static void flush_cache();
static void pop_cache();
static snd_bank *get_bank(int id, uint8_t suffix = 0);
static snd_bank *get_bank(int id, const char suffix = '0');
static uint8_t *read_bank_any(const char *avspath, const char *ext, size_t *sz);
static bool has_format(const char *avspath, const char *ext);
static avs::core::avs_file_t map_ifs(char *avspath);
@@ -608,10 +608,10 @@ snd_bank::~snd_bank()
avs::core::avs_fs_umount(mnt_);
}
}
snd_bank *snd_bank::get_bank(int id, uint8_t suffix)
snd_bank *snd_bank::get_bank(int id, const char suffix)
{
// Find in cache (latest=>oldest)
id = id + (suffix * 1e6_i);
id = id + ((suffix - '0') * 1e6_i);
for (snd_bank *it = cache_; it; it = it->next_)
if (it->id == id) return it;
@@ -621,7 +621,7 @@ snd_bank *snd_bank::get_bank(int id, uint8_t suffix)
if (has_format(bank->avspath, ".ifs"))
bank->mnt_ = map_ifs(bank->avspath);
snprintf(bank->avspath + strlen(bank->avspath), 7, "/%05d", (id % 1e6_i));
if (suffix) snprintf(bank->avspath + strlen(bank->avspath), 2, "%d", suffix);
if (id / 1e6_i) snprintf(bank->avspath + strlen(bank->avspath), 2, "%c", '0' + (id / 1e6_i));
if (!(has_format(bank->avspath, ".s3p") || has_format(bank->avspath, ".2dx")))
{
pop_cache();
@@ -739,7 +739,7 @@ void *on_enum_valid_soundbanks(void *song, int32_t difficulty, int32_t unk2)
}
else
log_info("hooks::soundbank", "Processing s3p->2dx transcoding routine for [{}]({} - {})", id, artistl, titlel);
if (!(keysounds = snd_bank::get_bank(id, suffix - '0')))
if (!(keysounds = snd_bank::get_bank(id, suffix)))
{
log_warning("hooks::soundbank", "soundbank::get_bank() was 0x0, this shouldn't happen..");
memcpy(reinterpret_cast<void *>(offset_.RD_05d_2dx), "%05d/%05d", SNDPATHFMTMAX);
@@ -778,7 +778,7 @@ void *on_enum_valid_soundbanks(void *song, int32_t difficulty, int32_t unk2)
memcpy(reinterpret_cast<void *>(offset_.RD_05d_2dx), t, SNDPATHFMTMAX);
log_info("hooks::soundbank", "RD_05d_2dx set to '{}'", reinterpret_cast<const char *>(offset_.RD_05d_2dx));
log_info("hooks::soundbank", "Processing completed");
*((char *) song + offset_.DAT_song_id + 8 + difficulty) = '0';
*((char *) song + offset_.DAT_song_id + 8 + difficulty) = keysounds->is_cached() ? '0' : suffix;
void *r = EnumValidSoundbanks(song, difficulty, unk2);
*((char *) song + offset_.DAT_song_id + 8 + difficulty) = suffix;
return r;