diff options
author | Filippos Karapetis | 2011-09-25 19:33:01 +0300 |
---|---|---|
committer | Filippos Karapetis | 2011-09-25 19:33:01 +0300 |
commit | c8777b774ffc4d55564503fa323b9acb986b89db (patch) | |
tree | 68d395e92312526e21754bff9e25e82282c055bb /engines | |
parent | b56c5cc3709780c53d62fbc018a40543e2daeaac (diff) | |
download | scummvm-rg350-c8777b774ffc4d55564503fa323b9acb986b89db.tar.gz scummvm-rg350-c8777b774ffc4d55564503fa323b9acb986b89db.tar.bz2 scummvm-rg350-c8777b774ffc4d55564503fa323b9acb986b89db.zip |
AGI: Rewrite getSavegameFilename() so that it doesn't try to return a pointer to a local variable
Diffstat (limited to 'engines')
-rw-r--r-- | engines/agi/agi.h | 2 | ||||
-rw-r--r-- | engines/agi/cycle.cpp | 4 | ||||
-rw-r--r-- | engines/agi/saveload.cpp | 18 |
3 files changed, 15 insertions, 9 deletions
diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 080373d27b..447e55eaa5 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -881,7 +881,7 @@ public: StringData _stringdata; - const char *getSavegameFilename(int num); + void getSavegameFilename(int num, char *fileName); void getSavegameDescription(int num, char *buf, bool showEmpty = true); int selectSlot(); int saveGame(const char *fileName, const char *saveName); diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp index e6f122f9f6..f77ef79f29 100644 --- a/engines/agi/cycle.cpp +++ b/engines/agi/cycle.cpp @@ -361,7 +361,9 @@ int AgiEngine::playGame() { } if (shouldPerformAutoSave(_lastSaveTime)) { - saveGame(getSavegameFilename(0), "Autosave"); + char fileName[MAXPATHLEN]; + getSavegameFilename(0, fileName); + saveGame(fileName, "Autosave"); } } while (!(shouldQuit() || _restartGame)); diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index e62b9d4d69..648cb6f835 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -546,10 +546,10 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) { #define NUM_SLOTS 100 #define NUM_VISIBLE_SLOTS 12 -const char *AgiEngine::getSavegameFilename(int num) { +void AgiEngine::getSavegameFilename(int num, char *fileName) { Common::String saveLoadSlot = _targetName; saveLoadSlot += Common::String::format(".%.3d", num); - return saveLoadSlot.c_str(); + strcpy(fileName, saveLoadSlot.c_str()); } void AgiEngine::getSavegameDescription(int num, char *buf, bool showEmpty) { @@ -557,7 +557,8 @@ void AgiEngine::getSavegameDescription(int num, char *buf, bool showEmpty) { Common::InSaveFile *in; debugC(4, kDebugLevelMain | kDebugLevelSavegame, "Current game id is %s", _targetName.c_str()); - strcpy(fileName, getSavegameFilename(num)); + getSavegameFilename(num, fileName); + if (!(in = _saveFileMan->openForLoading(fileName))) { debugC(4, kDebugLevelMain | kDebugLevelSavegame, "File %s does not exist", fileName); @@ -852,7 +853,7 @@ int AgiEngine::saveGameDialog() { return errOK; } - strcpy(fileName, getSavegameFilename(_firstSlot + slot)); + getSavegameFilename(_firstSlot + slot, fileName); debugC(8, kDebugLevelMain | kDebugLevelResources, "file is [%s]", fileName); // Make sure all graphics was blitted to screen. This fixes bug @@ -870,7 +871,10 @@ int AgiEngine::saveGameDialog() { } int AgiEngine::saveGameSimple() { - int result = saveGame(getSavegameFilename(0), "Default savegame"); + char fileName[MAXPATHLEN]; + getSavegameFilename(0, fileName); + + int result = saveGame(fileName, "Default savegame"); if (result != errOK) messageBox("Error saving game."); return result; @@ -904,7 +908,7 @@ int AgiEngine::loadGameDialog() { return errOK; } - sprintf(fileName, "%s", getSavegameFilename(_firstSlot + slot)); + getSavegameFilename(_firstSlot + slot, fileName); if ((rc = loadGame(fileName)) == errOK) { messageBox("Game restored."); @@ -921,7 +925,7 @@ int AgiEngine::loadGameSimple() { char fileName[MAXPATHLEN]; int rc = 0; - sprintf(fileName, "%s", getSavegameFilename(0)); + getSavegameFilename(0, fileName); _sprites->eraseBoth(); _sound->stopSound(); |