Fix detecting the autoboot title when the menu was opened

This commit is contained in:
Maschell 2022-09-24 13:56:28 +02:00
parent 8e8ce92822
commit 1e1a865f23

View File

@ -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) { 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); DirList environmentDirs("fs:/vol/external01/wiiu/environments/", nullptr, DirList::Dirs, 1);
std::map<std::string, std::string> environmentPaths;
for (int i = 0; i < environmentDirs.GetFilecount(); i++) {
environmentPaths[environmentDirs.GetFilename(i)] = environmentDirs.GetFilepath(i);
}
bool forceMenu = true; bool forceMenu = true;
auto res = getFileContent(AUTOBOOT_CONFIG_PATH); auto res = getFileContent(AUTOBOOT_CONFIG_PATH);
auto autobootIndex = -1; auto autobootIndex = -1;
if (res) { if (res) {
DEBUG_FUNCTION_LINE_VERBOSE("Got result %s", res->c_str()); DEBUG_FUNCTION_LINE_VERBOSE("Got result %s", res->c_str());
for (int i = 0; i < environmentDirs.GetFilecount(); i++) { int32_t i = 0;
if (environmentDirs.GetFilename(i) == res.value()) { 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); DEBUG_FUNCTION_LINE("Found environment %s from config at index %d", res.value().c_str(), i);
autobootIndex = i; autobootIndex = i;
environment_path = environmentDirs.GetFilepath(i); environment_path = val;
forceMenu = false; forceMenu = false;
break; break;
} }
i++;
} }
} else { } else {
DEBUG_FUNCTION_LINE_ERR("No config found"); DEBUG_FUNCTION_LINE_ERR("No config found");
} }
std::map<std::string, std::string> environmentPaths;
for (int i = 0; i < environmentDirs.GetFilecount(); i++) {
environmentPaths[environmentDirs.GetFilename(i)] = environmentDirs.GetFilepath(i);
}
VPADReadError err; VPADReadError err;
VPADStatus vpad_data; VPADStatus vpad_data;
VPADRead(VPAD_CHAN_0, &vpad_data, 1, &err); VPADRead(VPAD_CHAN_0, &vpad_data, 1, &err);