From 4dfc191981fe439cdfd066597734ced6fb22b590 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Wed, 14 Apr 2021 21:25:09 +0100 Subject: [PATCH] AGS: Fix assert when trying to save screenshots The SaveFileManager triggers an assert when passed a path and not just a file name. And we were passing "/saves/scrshotname.bmp" to it. Now the path is stripped and we also add the game target as prefix to the filename. --- engines/ags/shared/gfx/allegrobitmap.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/engines/ags/shared/gfx/allegrobitmap.cpp b/engines/ags/shared/gfx/allegrobitmap.cpp index 141c51e89bc..fd62d900031 100644 --- a/engines/ags/shared/gfx/allegrobitmap.cpp +++ b/engines/ags/shared/gfx/allegrobitmap.cpp @@ -25,6 +25,7 @@ #include "ags/lib/aastr-0.1.1/aastr.h" #include "common/savefile.h" #include "common/system.h" +#include "common/config-manager.h" namespace AGS3 { @@ -129,7 +130,14 @@ bool Bitmap::SaveToFile(Common::WriteStream &out, const void *palette) { } bool Bitmap::SaveToFile(const char *filename, const void *palette) { - Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(filename, false); + // Only keeps the file name and add the game target as prefix. + Common::String name = filename; + size_t lastSlash = name.findLastOf('/'); + if (lastSlash != Common::String::npos) + name = name.substr(lastSlash + 1); + name = ConfMan.getActiveDomainName() + "-" + name; + + Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(name, false); assert(out); bool result = SaveToFile(*out, palette); out->finalize();