SCI: Load volume resource files in consistent order

The order that volume resources are loaded subtly affects engine
behavior when they contain different versions of the same resource.
This order has been the file enumeration order from the operating
system, causing inconsistent behavior between environments and even
between two different directories of identical files.
This commit is contained in:
sluicebox 2020-11-18 07:08:31 -08:00
parent 3d02a6381c
commit e5b10e557c

View file

@ -640,6 +640,7 @@ int ResourceManager::addAppropriateSources() {
Common::ArchiveMemberList files;
SearchMan.listMatchingMembers(files, "resource.0##");
Common::sort(files.begin(), files.end(), Common::ArchiveMemberListComparator());
for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
const Common::String name = (*x)->getName();
const char *dot = strrchr(name.c_str(), '.');
@ -679,6 +680,7 @@ int ResourceManager::addAppropriateSources() {
_multiDiscAudio = true;
}
Common::sort(mapFiles.begin(), mapFiles.end(), Common::ArchiveMemberListComparator());
for (Common::ArchiveMemberList::const_iterator mapIterator = mapFiles.begin(); mapIterator != mapFiles.end(); ++mapIterator) {
Common::String mapName = (*mapIterator)->getName();
int mapNumber = atoi(strrchr(mapName.c_str(), '.') + 1);