nstlaurent / DoomLauncher

Doom Launcher is a doom launching utility and database for custom wads and pk3s
GNU General Public License v3.0
223 stars 19 forks source link

Option to load latest savefile #202

Closed jdznd closed 1 year ago

jdznd commented 3 years ago

I usually play Doom 5-10 times a day but only for 10-20 minutes each session so having to manually load last save each time when I just want to continue the game quickly can be a minor annoyance.

2020-10-06 (2)

I tried to use -loadgame parameter but I couldn't figure out how to load LATEST savefile in GZDoom.

I'd like to see a checkbox in the launch settings which automatically load the LATEST savefile for the wad. It will be a small but meaningful feature for me.

Thank you.

ALDamico commented 3 years ago

Heads up: the save file format varies greatly between source ports. In the case of GZDoom, savegames are actually zip archives containing four files: image

In our case, the info.json file is the most important: it contains metadata about the GZDoom version, the title of the map, the name of the map, the IWAD and possibly the mod we're playing, as well as a timestamp detailing when the game was saved.

PrBoom Plus uses an eight-slot save system, where each entry corresponds to a prboom-plus-savegameX.dsg file, with X being a number from 0 through 7. I tried opening a dsg file with a hex editor but, besides the save text and a couple paths to the iwad and other files, couldn't find much other useful information.

ALDamico commented 3 years ago

A small update regarding this feature: I was able to get this feature implemented for GZDoom versions using the new, Zip-based savegame format. However, the implementation is still very rough around the edges (for example, it's still not capable of determining whether the current GameProfile and the latest savegame are compatible with each other and trying to automatically loading the latest savegame on any other source port like Chocolate Doom and PrBoom will result in a NotImplementedException.

@nstlaurent would you like me to start a MR for the developments so far, or would you rather wait for this development to be further along before merging everything to your development branch?

nstlaurent commented 3 years ago

I can take a look and compare the branch autoload-last-save in your repository. If you have discord you can reach me at haxxx#2976, it might be easier to discuss there. I can give you a general idea of how I would go about this feature.

nstlaurent commented 3 years ago

I took a look at your branch and it looks over complicated for what we are trying to accomplish. This is how I would go about this feature:

Add LoadSaveGameSupported() to ISourcePort, similar to StatisticsSupported(). Add LoadSaveParameter(SpData) function. Implement these functions for ZDoom. As far as I know, ZDoom is the only port that supports loading a save file by command line. If there others then they can be implemented there.

Check box added to the PlayForm similar to save statistics.

Add LoadSaveFile bool to GameFilePlayerAdapter, again similar to how SaveStatistics works .

In GameFilePlayAdapter check if LoadSaveFIle is set and the ISourcePort supports loading a save. Use DataCache.Instance.DataSourceAdapter.GetFiles(GameFile, FileType.SaveGame), then filter down to the current source port, and selected the newest one (DateCreated).

Doom Launcher stores and keep track of all save game files, so we can just pull them from the database. Save files for the game file will be copied into the source port, so the GameFilePlayAdapter can create the parameter assuming this. There is an option that disables this feature, so we would want to warn the user that this won't work if that is the case.

ALDamico commented 3 years ago

Thank you for taking the time to sift through my edits. I'll follow your suggestions and implement the feature as you described tomorrow, since I have a day off work.

nstlaurent commented 3 years ago

@ALDamico were you able to work on this? I was looking to do implement this feature next.

ALDamico commented 3 years ago

I was able to partially implement it. I got to the point where the feature works but the checkbox status isn't saved and right now I can't work any further on it (doing job interviews, you see). I can commit what I have so far and do a merge request if you want.

nstlaurent commented 1 year ago

Closing. Load latest save has been implemented.