aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen
diff options
context:
space:
mode:
Diffstat (limited to 'engines/xeen')
-rw-r--r--engines/xeen/detection.cpp13
-rw-r--r--engines/xeen/saves.cpp12
-rw-r--r--engines/xeen/saves.h2
3 files changed, 11 insertions, 16 deletions
diff --git a/engines/xeen/detection.cpp b/engines/xeen/detection.cpp
index 49b74b24a2..abf82188a9 100644
--- a/engines/xeen/detection.cpp
+++ b/engines/xeen/detection.cpp
@@ -170,12 +170,9 @@ SaveStateList XeenMetaEngine::listSaves(const char *target) const {
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
if (in) {
- Xeen::SavesManager::readSavegameHeader(in, header);
- saveList.push_back(SaveStateDescriptor(slot, header._saveName));
+ if (Xeen::SavesManager::readSavegameHeader(in, header))
+ saveList.push_back(SaveStateDescriptor(slot, header._saveName));
- if (header._thumbnail)
- header._thumbnail->free();
- delete header._thumbnail;
delete in;
}
}
@@ -200,7 +197,11 @@ SaveStateDescriptor XeenMetaEngine::querySaveMetaInfos(const char *target, int s
if (f) {
Xeen::XeenSavegameHeader header;
- Xeen::SavesManager::readSavegameHeader(f, header);
+ if (!Xeen::SavesManager::readSavegameHeader(f, header, false)) {
+ delete f;
+ return SaveStateDescriptor();
+ }
+
delete f;
// Create the return descriptor
diff --git a/engines/xeen/saves.cpp b/engines/xeen/saves.cpp
index 1f58562bf0..2f290960d3 100644
--- a/engines/xeen/saves.cpp
+++ b/engines/xeen/saves.cpp
@@ -48,9 +48,8 @@ SavesManager::~SavesManager() {
const char *const SAVEGAME_STR = "XEEN";
#define SAVEGAME_STR_SIZE 6
-bool SavesManager::readSavegameHeader(Common::InSaveFile *in, XeenSavegameHeader &header) {
+WARN_UNUSED_RESULT bool SavesManager::readSavegameHeader(Common::InSaveFile *in, XeenSavegameHeader &header, bool skipThumbnail) {
char saveIdentBuffer[SAVEGAME_STR_SIZE + 1];
- header._thumbnail = nullptr;
// Validate the header Id
in->read(saveIdentBuffer, SAVEGAME_STR_SIZE + 1);
@@ -68,9 +67,9 @@ bool SavesManager::readSavegameHeader(Common::InSaveFile *in, XeenSavegameHeader
header._saveName += ch;
// Get the thumbnail
- header._thumbnail = Graphics::loadThumbnail(*in);
- if (!header._thumbnail)
+ if (!Graphics::loadThumbnail(*in, header._thumbnail, skipThumbnail)) {
return false;
+ }
// Read in save date/time
header._year = in->readSint16LE();
@@ -168,11 +167,6 @@ Common::Error SavesManager::loadGameState(int slot) {
if (!readSavegameHeader(saveFile, header))
error("Invalid savegame");
- if (header._thumbnail) {
- header._thumbnail->free();
- delete header._thumbnail;
- }
-
// Set the total play time
events.setPlayTime(header._totalFrames);
diff --git a/engines/xeen/saves.h b/engines/xeen/saves.h
index b18e04a822..9b1bea62a3 100644
--- a/engines/xeen/saves.h
+++ b/engines/xeen/saves.h
@@ -65,7 +65,7 @@ public:
/**
* Read in a savegame header
*/
- static bool readSavegameHeader(Common::InSaveFile *in, XeenSavegameHeader &header);
+ WARN_UNUSED_RESULT static bool readSavegameHeader(Common::InSaveFile *in, XeenSavegameHeader &header, bool skipThumbnail = true);
/**
* Write out a savegame header