[Scummvm-cvs-logs] CVS: scummvm/scumm saveload.cpp,1.30,1.31 scumm.h,1.78,1.79 scummvm.cpp,1.93,1.94
Max Horn
fingolfin at users.sourceforge.net
Thu Dec 12 19:24:01 CET 2002
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv28852
Modified Files:
saveload.cpp scumm.h scummvm.cpp
Log Message:
cleaned up autosave code
Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- saveload.cpp 10 Dec 2002 11:14:40 -0000 1.30
+++ saveload.cpp 13 Dec 2002 03:23:16 -0000 1.31
@@ -59,9 +59,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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)
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- scumm.h 13 Dec 2002 00:52:14 -0000 1.78
+++ scumm.h 13 Dec 2002 03:23:17 -0000 1.79
@@ -418,15 +418,13 @@
/* 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);
Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- scummvm.cpp 12 Dec 2002 16:29:21 -0000 1.93
+++ scummvm.cpp 13 Dec 2002 03:23:17 -0000 1.94
@@ -48,11 +48,6 @@
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 @@
_sound->_current_cache = 0;
- _timer->installProcedure(&autosave, 5 * 60 * 1000);
+ _lastSaveTime = _system->get_msecs();
}
@@ -443,16 +438,8 @@
}
}
- // 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 @@
displayError(errMsg, filename);
}
_saveLoadFlag = 0;
- _doAutosave = false;
+ _lastSaveTime = _system->get_msecs();
}
if (_completeScreenRedraw) {
More information about the Scummvm-git-logs
mailing list