Opened 3 years ago

Closed 3 years ago

#12864 closed defect (fixed)

AGS: Crash making in-game saves in Strangeland

Reported by: dreammaster Owned by: dreammaster
Priority: normal Component: Engine: AGS
Version: Keywords:
Cc: Game:

Description

It seems like the filename is being created with a subdirectory folder as part of the name rather than a straight strangeland.001 form. Need to investigate further.

Change History (5)

comment:1 by criezy, 3 years ago

It indeed does:

criezy@MacBook-Air scummvm % ./scummvm --debugflags=FilePath strangeland
User picked target 'strangeland' (engine ID 'ags', game ID 'strangeland')...
   Looking for a plugin supporting this target... Adventure Game Studio

[...]

ResolveScriptPath($SAVEGAMEDIR$/test/save2.bmp)
Adding ScummVM game target prefix
ResolveScriptPath($SAVEGAMEDIR$/test/saveHD2.bmp)
Adding ScummVM game target prefix
ResolveScriptPath($SAVEGAMEDIR$/save2_test.dat)
Adding ScummVM game target prefix
ResolveScriptPath($SAVEGAMEDIR$/test/save2_test.dat)
Adding ScummVM game target prefix
Assertion failed: (!n.contains('/')), function getChild, file backends/fs/posix/posix-fs.cpp, line 139.

Here test was the name I gave when trying to save into the second slot.

I already noticed in the past that SaveFileManager cannot deal with subdirectories and wondered if we needed to flatten paths in ResolveScriptPath. But since I had not found a game needing that yet, and never looked into it further.

My suggestion would be to flatten save paths if needed in ResolveScriptPath. So for example $SAVEGAMEDIR$/test/save2_test.dat would become /saves/test-save2_test.dat (instead of /saves/test/save2_test.dat).

I can look into that further tomorrow if you want.

Version 0, edited 3 years ago by criezy (next)

comment:2 by criezy, 3 years ago

Although if we want to make in-game saves compatible with saves from the GMM (to be able to mix the two, and in particular reload an in-game save from the launcher or command line), that would be more complicated.

comment:3 by dreammaster, 3 years ago

This is weird. I actually double-checked with the standalone interpreter, and the filename it uses doesn't have a slash in it. Instead, it produces a file in the form of "save1-temp save.dat" (where "temp save" is the name I gave it). So it's not using subdirectories, it's just that there's something wrong in the way ScummVM is building up the filename that differs from the standalone.

On a side note, the produced file is only 24Kb.. quite a difference from the massive 300Mb+ file created for the autosave :)

comment:4 by criezy, 3 years ago

Yes, there is something weird. It seems it is trying to both use a subdirectory, and not use one:

ResolveScriptPath($SAVEGAMEDIR$/save2_test.dat)
ResolveScriptPath($SAVEGAMEDIR$/test/save2_test.dat)

I am not sure if this is something in our code, or if the original does that as well. It could try using a subdirectory only if it fails reading/writing without one for example...

In any case flattening paths ensure we are not going to assert if some games really try to do it (even if Strangeland doesn't), so I made the commit (and it was only a one line change).

However while saving and loading seems to work if I reload the game in the same session, this still does not work when closing the game and restarting. I suspect this is because we do not support the kFile_Create mode and always treat it as kFile_CreateAlways, which means that it replaces the file if is already exists instead of opening it in append mode or read-write mode. This may be why the strangeland-list.slot file, which contains a list of the saved games, seems to be cleared when closing and restarting the game.

Last edited 3 years ago by criezy (previous) (diff)

comment:5 by dreammaster, 3 years ago

Owner: set to dreammaster
Resolution: fixed
Status: newclosed

Everything should be sorted out now.

Note: See TracTickets for help on using tickets.