From 8713f3b3b3f6c471c090ead22997a7e01c56253e Mon Sep 17 00:00:00 2001 From: Walter Agazzi Date: Sat, 26 Nov 2022 00:53:30 +0100 Subject: [PATCH] DRACI: Find max speech file using iterator --- engines/draci/sound.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/engines/draci/sound.cpp b/engines/draci/sound.cpp index 7afd90922cb..943081eb95d 100644 --- a/engines/draci/sound.cpp +++ b/engines/draci/sound.cpp @@ -203,6 +203,16 @@ void ZipSoundArchive::openArchive(const char *path, const char *extension, Sound Common::ArchiveMemberList files; _archive->listMembers(files); _sampleCount = files.size(); + + // The sample files are in the form ####.mp3 but not all numbers are used so we need to + // iterate the archive and find the last file + for (Common::ArchiveMemberList::iterator iter = files.begin(); iter != files.end(); iter++) { + Common::String filename = (*iter)->getName(); + filename.erase(filename.size() - 4); // remove .mp3 extension + uint file_number = atoi(filename.c_str()); + if(file_number > _sampleCount) // finds the last file (numerically) + _sampleCount = file_number; + } debugC(1, kDraciArchiverDebugLevel, "Capacity %d", _sampleCount); } else { debugC(1, kDraciArchiverDebugLevel, "Failed");