Tell the user if saving a game fails. (I haven't tested the saveGameSimple()
function, since I don't know when it's used.) This should fix bug #1767237 ("AGI: Saving games to non existing path"). svn-id: r28441
This commit is contained in:
parent
feb07bb1d8
commit
3447c0e264
2 changed files with 16 additions and 9 deletions
|
@ -156,6 +156,7 @@ enum AGIErrors {
|
||||||
errNoLoopsInView,
|
errNoLoopsInView,
|
||||||
errViewDataError,
|
errViewDataError,
|
||||||
errNoGameList,
|
errNoGameList,
|
||||||
|
errIOError,
|
||||||
|
|
||||||
errUnk = 127
|
errUnk = 127
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,6 +55,7 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
|
||||||
int i;
|
int i;
|
||||||
struct ImageStackElement *ptr = _imageStack;
|
struct ImageStackElement *ptr = _imageStack;
|
||||||
Common::OutSaveFile *out;
|
Common::OutSaveFile *out;
|
||||||
|
int result = errOK;
|
||||||
|
|
||||||
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "AgiEngine::saveGame(%s, %s)", fileName, description);
|
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "AgiEngine::saveGame(%s, %s)", fileName, description);
|
||||||
if (!(out = _saveFileMan->openForSaving(fileName))) {
|
if (!(out = _saveFileMan->openForSaving(fileName))) {
|
||||||
|
@ -206,14 +207,15 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
|
||||||
out->writeSint16BE(_gfx->getAGIPalFileNum());
|
out->writeSint16BE(_gfx->getAGIPalFileNum());
|
||||||
|
|
||||||
out->finalize();
|
out->finalize();
|
||||||
if (out->ioFailed())
|
if (out->ioFailed()) {
|
||||||
warning("Can't write file '%s'. (Disk full?)", fileName);
|
warning("Can't write file '%s'. (Disk full?)", fileName);
|
||||||
else
|
result = errIOError;
|
||||||
|
} else
|
||||||
debugC(1, kDebugLevelMain | kDebugLevelSavegame, "Saved game %s in file %s", description, fileName);
|
debugC(1, kDebugLevelMain | kDebugLevelSavegame, "Saved game %s in file %s", description, fileName);
|
||||||
|
|
||||||
delete out;
|
delete out;
|
||||||
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "Closed %s", fileName);
|
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "Closed %s", fileName);
|
||||||
return errOK;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AgiEngine::loadGame(const char *fileName, bool checkId) {
|
int AgiEngine::loadGame(const char *fileName, bool checkId) {
|
||||||
|
@ -751,20 +753,24 @@ int AgiEngine::saveGameDialog() {
|
||||||
sprintf(fileName, "%s", getSavegameFilename(slot));
|
sprintf(fileName, "%s", getSavegameFilename(slot));
|
||||||
debugC(8, kDebugLevelMain | kDebugLevelResources, "file is [%s]", fileName);
|
debugC(8, kDebugLevelMain | kDebugLevelResources, "file is [%s]", fileName);
|
||||||
|
|
||||||
saveGame(fileName, desc);
|
int result = saveGame(fileName, desc);
|
||||||
|
|
||||||
messageBox("Game saved.");
|
if (result == errOK)
|
||||||
|
messageBox("Game saved.");
|
||||||
|
else
|
||||||
|
messageBox("Error saving game.");
|
||||||
|
|
||||||
return errOK;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AgiEngine::saveGameSimple() {
|
int AgiEngine::saveGameSimple() {
|
||||||
char fileName[MAX_PATH];
|
char fileName[MAX_PATH];
|
||||||
|
|
||||||
sprintf(fileName, "%s", getSavegameFilename(0));
|
sprintf(fileName, "%s", getSavegameFilename(0));
|
||||||
saveGame(fileName, "Default savegame");
|
int result = saveGame(fileName, "Default savegame");
|
||||||
|
if (result != errOK)
|
||||||
return errOK;
|
messageBox("Error saving game.");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AgiEngine::loadGameDialog() {
|
int AgiEngine::loadGameDialog() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue