mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
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.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user