SLUDGE: Sort saves alphabetically, matching the original behaviour

This commit is contained in:
Eugene Sandulenko 2023-11-22 18:42:13 +01:00
parent 3af9526fff
commit fad953b088
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -188,6 +188,10 @@ int StackHandler::getStackSize() const {
return r;
}
static int stringCompareToIgnoreCase(const Common::String &s1, const Common::String &s2) {
return s1.compareToIgnoreCase(s2) > 0;
}
bool StackHandler::getSavedGamesStack(const Common::String &ext) {
// Make pattern
uint len = ext.size();
@ -197,11 +201,14 @@ bool StackHandler::getSavedGamesStack(const Common::String &ext) {
// Get all saved files
Common::StringArray sa = g_system->getSavefileManager()->listSavefiles(pattern);
Common::sort(sa.begin(), sa.end(), stringCompareToIgnoreCase);
// Save file names to stacks
Variable newName;
newName.varType = SVT_NULL;
Common::StringArray::iterator it;
for (it = sa.begin(); it != sa.end(); ++it) {
for (Common::StringArray::iterator it = sa.begin(); it != sa.end(); ++it) {
(*it).erase((*it).size() - len, len);
newName.makeTextVar((*it));
if (!addVarToStack(newName, first))