From 1e1a865f2394bf7c074d79bc84059aef4ccca003 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 24 Sep 2022 13:56:28 +0200 Subject: [PATCH] Fix detecting the autoboot title when the menu was opened --- source/main.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 2ebdd8c..d8da5f3 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -132,29 +132,31 @@ int main(int argc, char **argv) { if (strncmp(environmentPath, "fs:/vol/external01/wiiu/environments/", strlen("fs:/vol/external01/wiiu/environments/")) != 0) { DirList environmentDirs("fs:/vol/external01/wiiu/environments/", nullptr, DirList::Dirs, 1); + std::map environmentPaths; + for (int i = 0; i < environmentDirs.GetFilecount(); i++) { + environmentPaths[environmentDirs.GetFilename(i)] = environmentDirs.GetFilepath(i); + } + bool forceMenu = true; auto res = getFileContent(AUTOBOOT_CONFIG_PATH); auto autobootIndex = -1; if (res) { DEBUG_FUNCTION_LINE_VERBOSE("Got result %s", res->c_str()); - for (int i = 0; i < environmentDirs.GetFilecount(); i++) { - if (environmentDirs.GetFilename(i) == res.value()) { + int32_t i = 0; + for (auto const &[key, val] : environmentPaths) { + if (res.value() == key) { DEBUG_FUNCTION_LINE("Found environment %s from config at index %d", res.value().c_str(), i); autobootIndex = i; - environment_path = environmentDirs.GetFilepath(i); + environment_path = val; forceMenu = false; break; } + i++; } } else { DEBUG_FUNCTION_LINE_ERR("No config found"); } - std::map environmentPaths; - for (int i = 0; i < environmentDirs.GetFilecount(); i++) { - environmentPaths[environmentDirs.GetFilename(i)] = environmentDirs.GetFilepath(i); - } - VPADReadError err; VPADStatus vpad_data; VPADRead(VPAD_CHAN_0, &vpad_data, 1, &err);