aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Milburn2011-05-23 11:50:38 +0200
committerAlyssa Milburn2011-05-23 11:55:34 +0200
commit998323129420ebde730074585d7aab9f093368a8 (patch)
tree9bfa4f410e8339d4469a102bd943a9523e74a111
parent9b43822a424606f9ba4e8c924ed831bc1bdd6aae (diff)
downloadscummvm-rg350-998323129420ebde730074585d7aab9f093368a8.tar.gz
scummvm-rg350-998323129420ebde730074585d7aab9f093368a8.tar.bz2
scummvm-rg350-998323129420ebde730074585d7aab9f093368a8.zip
SWORD25: De-hardcode target name in thumbnail code
This just uses the provided filename rather than trying to recreate it with a hard-coded target (causing crashes with other targets). (Also, add an error check rather then crashing there, just in case.)
-rw-r--r--engines/sword25/gfx/image/renderedimage.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index 23bf2623ad..395d29d81a 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -42,14 +42,6 @@
namespace Sword25 {
-// Duplicated from kernel/persistenceservice.cpp
-static Common::String generateSavegameFilename(uint slotID) {
- char buffer[100];
- // NOTE: This is hardcoded to sword25
- snprintf(buffer, 100, "%s.%.3d", "sword25", slotID);
- return Common::String(buffer);
-}
-
// -----------------------------------------------------------------------------
// CONSTRUCTION / DESTRUCTION
// -----------------------------------------------------------------------------
@@ -74,8 +66,9 @@ static Common::String loadString(Common::SeekableReadStream &in, uint maxSize =
static byte *readSavegameThumbnail(const Common::String &filename, uint &fileSize, bool &isPNG) {
byte *pFileData;
Common::SaveFileManager *sfm = g_system->getSavefileManager();
- int slotNum = atoi(filename.c_str() + filename.size() - 3);
- Common::InSaveFile *file = sfm->openForLoading(generateSavegameFilename(slotNum));
+ Common::InSaveFile *file = sfm->openForLoading(lastPathComponent(filename, '/'));
+ if (!file)
+ error("Save file \"%s\" could not be loaded.", filename.c_str());
// Seek to the actual PNG image
loadString(*file); // Marker (BS25SAVEGAME)