ENGINES: Fix autosave name check (#3648)

The length of the German translation for Autosave is 23 characters. Save names in Groovie are limited to 15 characters, and it's probably not the only engine with a similar limit. This meant you would get a warning on every autosave, even though you just told it to overwrite. Mminimum of 14 characters for confidence that the name is a match and not a false positive.
This commit is contained in:
Die4Ever 2022-01-13 02:52:59 -06:00 committed by GitHub
parent d794b2390a
commit 0d364029fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,7 +95,16 @@ bool SaveStateDescriptor::isAutosave() const {
bool SaveStateDescriptor::hasAutosaveName() const
{
return _description.contains(_("Autosave"));
const Common::U32String &autosave = _("Autosave");
// if the save file name is long enough, just check if it starts with "Autosave"
if (_description.size() >= autosave.size())
return _description.substr(0, autosave.size()) == autosave;
// if the save name has been trimmed, as long as it isn't too short, use fallback logic
if (_description.size() < 14)
return false;
return autosave.substr(0, _description.size()) == _description;
}
bool SaveStateDescriptor::isValid() const