[Scummvm-git-logs] scummvm master -> 19ef15177b19b47ebf42a4273024894b2d4654ca
criezy
criezy at scummvm.org
Thu Apr 8 23:19:38 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
19ef15177b AGS: Fix various issues with savegames
Commit: 19ef15177b19b47ebf42a4273024894b2d4654ca
https://github.com/scummvm/scummvm/commit/19ef15177b19b47ebf42a4273024894b2d4654ca
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-09T00:14:56+01:00
Commit Message:
AGS: Fix various issues with savegames
One of the issue was that we were listing the restart point
savegame (in slot 999), and it should not have been listed.
This caused a crash in the ags savegamedialog as it tried
to use the next slot, 1000, which is out of bound.
Changing this fixes bug #12386.
Another issue is that we could do out of bound writes due
to the AGS engine having to MAXSAVEGAMES define, one set to 20
and the other to 50. And in one place we were using the wrong
one.
Also specify a maximum save slot of 99. This is what the
original uses as it reserves higher slots for special purposes.
And finally do not use slot 999 for autosaves as it conflicts
with the slot used bu AGS for the restart point.
Changed paths:
engines/ags/engine/gui/guidialog.cpp
engines/ags/metaengine.cpp
engines/ags/metaengine.h
diff --git a/engines/ags/engine/gui/guidialog.cpp b/engines/ags/engine/gui/guidialog.cpp
index fd7cd8f0b6..6f10842504 100644
--- a/engines/ags/engine/gui/guidialog.cpp
+++ b/engines/ags/engine/gui/guidialog.cpp
@@ -279,17 +279,23 @@ void preparesavegamelist(int ctrllist) {
CSCISendControlMessage(ctrllist, CLB_ADDITEM, 0,
const_cast<char *>(desc.c_str()));
- // Select the first item
- CSCISendControlMessage(ctrllist, CLB_SETCURSEL, 0, 0);
_G(filenumbers)[_G(numsaves)] = it->getSaveSlot();
_G(filedates)[_G(numsaves)] = 0; // TODO: How to handle file dates in ScummVM
- ++_G(numsaves);
+ if (++_G(numsaves) == MAXSAVEGAMES_20) {
+ _G(toomanygames) = 1;
+ break;
+ }
}
- if (_G(numsaves) >= MAXSAVEGAMES)
- _G(toomanygames) = 1;
+ // Select the first item
+ CSCISendControlMessage(ctrllist, CLB_SETCURSEL, 0, 0);
+ // The code below reorder the savegames according to filedates
+ // Since we don't currently have this info, there is no sense in doing it.
+ // Also the newer AGS code does the sorting of the list before the loop above,
+ // which simpligies the code, and we might want to do the same.
+/*
for (int nn = 0; nn < _G(numsaves) - 1; nn++) {
for (int kk = 0; kk < _G(numsaves) - 1; kk++) { // Date order the games
if (_G(filedates)[kk] < _G(filedates)[kk + 1]) { // swap them round
@@ -306,6 +312,7 @@ void preparesavegamelist(int ctrllist) {
}
}
}
+*/
}
void enterstringwindow(const char *prompttext, char *stouse) {
diff --git a/engines/ags/metaengine.cpp b/engines/ags/metaengine.cpp
index c3bdb004b4..1a4686792b 100644
--- a/engines/ags/metaengine.cpp
+++ b/engines/ags/metaengine.cpp
@@ -52,6 +52,7 @@ SaveStateList AGSMetaEngine::listSaves(const char *target) const {
filenames = saveFileMan->listSavefiles(pattern);
+ int maxSlot = getMaximumSaveSlot();
SaveStateList saveList;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
Common::String filename = Common::String::format("%s%s",
@@ -65,6 +66,8 @@ SaveStateList AGSMetaEngine::listSaves(const char *target) const {
if (rich_media_header.dwMagicNumber == RM_MAGICNUMBER) {
int slotNum = atoi(file->c_str() + file->size() - 3);
+ if (slotNum > maxSlot)
+ continue;
SaveStateDescriptor desc;
desc.setSaveSlot(slotNum);
diff --git a/engines/ags/metaengine.h b/engines/ags/metaengine.h
index 0aa8dd7a41..fd5ca6e4b2 100644
--- a/engines/ags/metaengine.h
+++ b/engines/ags/metaengine.h
@@ -25,8 +25,6 @@
#include "engines/advancedDetector.h"
-#define MAX_SAVES 99
-
class AGSMetaEngine : public AdvancedMetaEngine {
public:
const char *getName() const override;
@@ -36,7 +34,13 @@ public:
SaveStateList listSaves(const char *target) const override;
int getAutosaveSlot() const override {
- return 999;
+ return 0;
+ }
+
+ int getMaximumSaveSlot() const override {
+ // The original allows saveslot 000 to 099 and reserves higher slots
+ // for special purposes.
+ return 99;
}
/**
More information about the Scummvm-git-logs
mailing list