aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/saveload.cpp17
-rw-r--r--scumm/scumm.h6
-rw-r--r--scumm/scummvm.cpp21
3 files changed, 12 insertions, 32 deletions
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp
index 6cc2746ed8..dcdec31657 100644
--- a/scumm/saveload.cpp
+++ b/scumm/saveload.cpp
@@ -59,9 +59,7 @@ bool Scumm::saveState(int slot, bool compat)
out.fwrite(&hdr, sizeof(hdr), 1);
Serializer ser(out, true, CURRENT_VER);
-
- _savegameVersion = CURRENT_VER;
- saveOrLoad(&ser);
+ saveOrLoad(&ser, CURRENT_VER);
out.fclose();
debug(1, "State saved as '%s'", filename);
@@ -103,9 +101,6 @@ bool Scumm::loadState(int slot, bool compat)
if (hdr.ver == VER_V7)
hdr.ver = VER_V8;
- // _savegameVersion is set so that the load code can know which data format to expect
- _savegameVersion = hdr.ver;
-
memcpy(_saveLoadName, hdr.name, sizeof(hdr.name));
if (_imuseDigital) {
@@ -129,8 +124,8 @@ bool Scumm::loadState(int slot, bool compat)
initScummVars();
- Serializer ser(out, false, _savegameVersion);
- saveOrLoad(&ser);
+ Serializer ser(out, false, hdr.ver);
+ saveOrLoad(&ser, hdr.ver);
out.fclose();
sb = _screenB;
@@ -211,7 +206,7 @@ bool Scumm::getSavegameName(int slot, char *desc)
return true;
}
-void Scumm::saveOrLoad(Serializer *s)
+void Scumm::saveOrLoad(Serializer *s, uint32 savegameVersion)
{
const SaveLoadEntry objectEntries[] = {
MKLINE(ObjectData, offs_obim_to_room, sleUint32, VER_V8),
@@ -544,7 +539,7 @@ void Scumm::saveOrLoad(Serializer *s)
s->saveLoadArrayOf(_actors, NUM_ACTORS, sizeof(_actors[0]), actorEntries);
- if (_savegameVersion < VER_V9)
+ if (savegameVersion < VER_V9)
s->saveLoadArrayOf(vm.slot, 25, sizeof(vm.slot[0]), scriptSlotEntries);
else
s->saveLoadArrayOf(vm.slot, NUM_SCRIPT_SLOT, sizeof(vm.slot[0]), scriptSlotEntries);
@@ -571,7 +566,7 @@ void Scumm::saveOrLoad(Serializer *s)
s->saveLoadArrayOf(_shadowPalette, _shadowPaletteSize, 1, sleByte);
// PalManip data was not saved before V10 save games
- if (_savegameVersion < VER_V10)
+ if (savegameVersion < VER_V10)
_palManipCounter = 0;
if (_palManipCounter) {
if (!_palManipPalette)
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 01bb81de64..9978f8913a 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -418,15 +418,13 @@ public:
/* Save/Load class - some of this may be GUI */
byte _saveLoadFlag, _saveLoadSlot;
- bool _doAutosave;
+ uint32 _lastSaveTime;
bool _saveLoadCompatible;
char _saveLoadName[32];
- uint32 _savegameVersion;
-
bool saveState(int slot, bool compat);
bool loadState(int slot, bool compat);
- void saveOrLoad(Serializer *s);
+ void saveOrLoad(Serializer *s, uint32 savegameVersion);
bool getSavegameName(int slot, char *desc);
void makeSavegameName(char *out, int slot, bool compatible);
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index 7b4f431121..147bded726 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -48,11 +48,6 @@ Scumm *g_scumm = 0;
extern NewGui *g_gui;
-void autosave(void * engine)
-{
- g_scumm->_doAutosave = true;
-}
-
Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst)
{
Engine *engine;
@@ -342,7 +337,7 @@ void Scumm::scummInit()
_sound->_current_cache = 0;
- _timer->installProcedure(&autosave, 5 * 60 * 1000);
+ _lastSaveTime = _system->get_msecs();
}
@@ -443,16 +438,8 @@ int Scumm::scummLoop(int delta)
}
}
- // TODO - A fixed 5 minutes autosave interval seems a bit odd, e.g. if the
- // user just saved a second ago we should not autosave; i.e. the autosave
- // timer should be reset after each save/load. In fact, we don't need *any*
- // real timer object for autosave, we could just use a variable in which we
- // put the system time, and then check here if that time already passed during
- // every scummLoop iteration, resetting it whenever a save/load occurs. Of
- // course, that still leaves a small glitch (which is present now, too):
- // if you are in the GUI for 10 minutes, it'll autosave immediatly after you
- // close the GUI.
- if (_doAutosave && !_saveLoadFlag) {
+ // Trigger autosave all 5 minutes.
+ if (!_saveLoadFlag && _system->get_msecs() > _lastSaveTime + 5 * 60 * 1000) {
_saveLoadSlot = 0;
sprintf(_saveLoadName, "Autosave %d", _saveLoadSlot);
_saveLoadFlag = 1;
@@ -486,7 +473,7 @@ int Scumm::scummLoop(int delta)
displayError(errMsg, filename);
}
_saveLoadFlag = 0;
- _doAutosave = false;
+ _lastSaveTime = _system->get_msecs();
}
if (_completeScreenRedraw) {