mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 11:51:52 +00:00
DIRECTOR: LINGO: Make b_getNthFileNameInFolder always check cache
It's possible for games to request files that don't exist in the game path, e.g. C:\WINDOWS\TX2SAVES. As such, the method needs to always include the quirk files, regardless of whether the path exists. Fixes loading save games in Operation: Eco-Nightmare
This commit is contained in:
parent
4e1b32c0d4
commit
8ff91ce024
@ -1154,36 +1154,37 @@ void LB::b_getNthFileNameInFolder(int nargs) {
|
||||
}
|
||||
|
||||
Datum r;
|
||||
Common::Array<Common::String> fileNameList;
|
||||
|
||||
// First, mix in any files injected from the quirks
|
||||
Common::Archive *cache = SearchMan.getArchive(kQuirksCacheArchive);
|
||||
if (cache) {
|
||||
Common::ArchiveMemberList files;
|
||||
|
||||
cache->listMatchingMembers(files, path + (path.empty() ? "*" : "/*"), true);
|
||||
|
||||
for (auto &fi : files) {
|
||||
fileNameList.push_back(Common::lastPathComponent(fi->getName(), '/'));
|
||||
}
|
||||
}
|
||||
|
||||
// Next, mix in files from the game filesystem (if they exist)
|
||||
if (d.exists()) {
|
||||
Common::FSList f;
|
||||
if (!d.getChildren(f, Common::FSNode::kListAll)) {
|
||||
warning("Cannot access directory %s", path.c_str());
|
||||
} else {
|
||||
if ((uint)fileNum < f.size()) {
|
||||
// here, we sort all the fileNames
|
||||
Common::Array<Common::String> fileNameList;
|
||||
for (uint i = 0; i < f.size(); i++)
|
||||
fileNameList.push_back(f[i].getName());
|
||||
|
||||
// Now mix in any files coming from the quirks
|
||||
Common::Archive *cache = SearchMan.getArchive(kQuirksCacheArchive);
|
||||
|
||||
if (cache) {
|
||||
Common::ArchiveMemberList files;
|
||||
|
||||
cache->listMatchingMembers(files, path + (path.empty() ? "*" : "/*"), true);
|
||||
|
||||
for (auto &fi : files) {
|
||||
fileNameList.push_back(fi->getName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Common::sort(fileNameList.begin(), fileNameList.end());
|
||||
r = Datum(fileNameList[fileNum]);
|
||||
}
|
||||
for (uint i = 0; i < f.size(); i++)
|
||||
fileNameList.push_back(f[i].getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (!fileNameList.empty() && (uint)fileNum < fileNameList.size()) {
|
||||
// Sort files alphabetically
|
||||
Common::sort(fileNameList.begin(), fileNameList.end());
|
||||
r = Datum(fileNameList[fileNum]);
|
||||
}
|
||||
|
||||
g_lingo->push(r);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user