aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/kyra/detection.cpp19
-rw-r--r--engines/kyra/kyra_v1.h1
-rw-r--r--engines/kyra/saveload.cpp8
3 files changed, 9 insertions, 19 deletions
diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp
index 06d96d57bb..c630e61b05 100644
--- a/engines/kyra/detection.cpp
+++ b/engines/kyra/detection.cpp
@@ -1164,12 +1164,7 @@ void KyraMetaEngine::removeSaveState(const char *target, int slot) const {
return;
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
-
- char extension[6];
- snprintf(extension, sizeof(extension), ".%03d", slot);
-
- Common::String filename = target;
- filename += extension;
+ Common::String filename = Kyra::KyraEngine_v1::getSavegameFilename(target, slot);
saveFileMan->removeSavefile(filename.c_str());
@@ -1193,22 +1188,14 @@ void KyraMetaEngine::removeSaveState(const char *target, int slot) const {
// is missing.
saveFileMan->renameSavefile(file->c_str(), filename.c_str());
- ++slot;
- snprintf(extension, sizeof(extension), ".%03d", slot);
-
- filename = target;
- filename += extension;
+ filename = Kyra::KyraEngine_v1::getSavegameFilename(target, ++slot);
}
}
}
Graphics::Surface *KyraMetaEngine::loadThumbnailFromSlot(const char *target, int slot) const {
- char extension[6];
- snprintf(extension, sizeof(extension), ".%03d", slot);
-
- Common::String filename = target;
- filename += extension;
+ Common::String filename = Kyra::KyraEngine_v1::getSavegameFilename(target, slot);
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
Kyra::KyraEngine_v1::SaveHeader header;
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index d2732011be..f4c2442c0e 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -275,6 +275,7 @@ protected:
void checkAutosave();
const char *getSavegameFilename(int num);
+ static Common::String getSavegameFilename(const Common::String &target, int num);
bool saveFileLoadable(int slot);
struct SaveHeader {
diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp
index 61201a2031..76089fdb2c 100644
--- a/engines/kyra/saveload.cpp
+++ b/engines/kyra/saveload.cpp
@@ -216,15 +216,17 @@ Common::WriteStream *KyraEngine_v1::openSaveForWriting(const char *filename, con
const char *KyraEngine_v1::getSavegameFilename(int num) {
static Common::String filename;
+ filename = getSavegameFilename(_targetName, num);
+ return filename.c_str();
+}
+Common::String KyraEngine_v1::getSavegameFilename(const Common::String &target, int num) {
assert(num >= 0 && num <= 999);
char extension[5];
sprintf(extension, "%03d", num);
- filename = _targetName + "." + extension;
-
- return filename.c_str();
+ return target + "." + extension;
}
bool KyraEngine_v1::saveFileLoadable(int slot) {