From 998323129420ebde730074585d7aab9f093368a8 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Mon, 23 May 2011 11:50:38 +0200 Subject: 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.) --- engines/sword25/gfx/image/renderedimage.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'engines/sword25/gfx') 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) -- cgit v1.2.3