aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2002-11-10 14:59:15 +0000
committerMax Horn2002-11-10 14:59:15 +0000
commit93d5d667d0d29dcbeff0060cca686484c8eab01d (patch)
tree1fdba6a3ffed4b39976d9182aa50b00c10cc3fdd /scumm
parentca5a230d333c81b1f1af3e838a3ecd0d3633efc5 (diff)
downloadscummvm-rg350-93d5d667d0d29dcbeff0060cca686484c8eab01d.tar.gz
scummvm-rg350-93d5d667d0d29dcbeff0060cca686484c8eab01d.tar.bz2
scummvm-rg350-93d5d667d0d29dcbeff0060cca686484c8eab01d.zip
added Scumm::displayError() method; make use of that to display errors if save/load failed; changed runDialog() to return the result of Dialog::runModal(); changed the order in which autosave is performed a little bit
svn-id: r5493
Diffstat (limited to 'scumm')
-rw-r--r--scumm/scumm.h3
-rw-r--r--scumm/scummvm.cpp63
2 files changed, 52 insertions, 14 deletions
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 5e2ff313f9..6186c8b7fc 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -347,10 +347,11 @@ public:
Dialog *_optionsDialog;
Dialog *_saveLoadDialog;
- void runDialog(Dialog *dialog);
+ int runDialog(Dialog *dialog);
void pauseDialog();
void saveloadDialog();
void optionsDialog();
+ void displayError(const char *message, ...);
// Misc startup/event functions
void main();
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index cc879868b7..0f1e69ac08 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -428,29 +428,49 @@ 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) {
+ _saveLoadSlot = 0;
+ sprintf(_saveLoadName, "Autosave %d", _saveLoadSlot);
+ _saveLoadFlag = 1;
+ _saveLoadCompatible = false;
+ }
if (_saveLoadFlag) {
+ bool success;
+ const char *errMsg = NULL;
if (_saveLoadFlag == 1) {
- saveState(_saveLoadSlot, _saveLoadCompatible);
+ success = saveState(_saveLoadSlot, _saveLoadCompatible);
+ if (!success)
+ errMsg = "Failed so save game state to file:\n\n%s";
// Ender: Disabled for small_header games, as
// can overwrite game variables (eg, Zak256 cashcards)
- if (_saveLoadCompatible && !(_features & GF_SMALL_HEADER))
+ if (success && _saveLoadCompatible && !(_features & GF_SMALL_HEADER))
_vars[VAR_GAME_LOADED] = 201;
} else {
- loadState(_saveLoadSlot, _saveLoadCompatible);
+ success = loadState(_saveLoadSlot, _saveLoadCompatible);
+ if (!success)
+ errMsg = "Failed so load game state from file:\n\n%s";
// Ender: Disabled for small_header games, as
// can overwrite game variables (eg, Zak256 cashcards)
- if (_saveLoadCompatible && !(_features & GF_SMALL_HEADER))
+ if (success && _saveLoadCompatible && !(_features & GF_SMALL_HEADER))
_vars[VAR_GAME_LOADED] = 203;
}
- _saveLoadFlag = 0;
- }
- if (_doAutosave) {
- _saveLoadSlot = 0;
- sprintf(_saveLoadName, "Autosave %d", _saveLoadSlot);
- _saveLoadFlag = 1;
- _saveLoadCompatible = false;
+ if (!success) {
+ char filename[256];
+ makeSavegameName(filename, _saveLoadSlot, _saveLoadCompatible);
+ displayError(errMsg, filename);
+ }
+ _saveLoadFlag = 0;
_doAutosave = false;
}
@@ -945,20 +965,23 @@ void Scumm::setOptions()
//_newgui->optionsDialog();
}
-void Scumm::runDialog(Dialog *dialog)
+int Scumm::runDialog(Dialog *dialog)
{
// Pause sound put
bool old_soundsPaused = _sound->_soundsPaused;
_sound->pauseSounds(true);
// Open & run the dialog
- dialog->runModal();
+ int result = dialog->runModal();
// Restore old cursor
updateCursor();
// Resume sound output
_sound->pauseSounds(old_soundsPaused);
+
+ // Return the result
+ return result;
}
void Scumm::pauseDialog()
@@ -984,6 +1007,20 @@ void Scumm::optionsDialog()
runDialog(_optionsDialog);
}
+void Scumm::displayError(const char *message, ...)
+{
+ char buf[1024];
+ va_list va;
+
+ va_start(va, message);
+ vsprintf(buf, message, va);
+ va_end(va);
+
+ Dialog *dialog = new MessageDialog(_newgui, buf);
+ runDialog(dialog);
+ delete dialog;
+}
+
void Scumm::shutDown(int i)
{
/* TODO: implement this */