Opened 18 years ago

Closed 16 years ago

Last modified 6 years ago

#8624 closed patch

Scumm: Load-/Save-support for the original save-dialog

Reported by: SF/tobigun Owned by: fingolfin
Priority: normal Component: Engine: SCUMM
Version: Keywords:
Cc: Game:

Description

The original save-dialogs of older SCUMM-games are shown by a ALT-F5 keypress but they do not work in Version 3 games (Indy3 (+FM-Towns), Zak FM-Towns and Loom) because no savegames names are shown in the list. In addition saving doesn't really work with the saveState() approach.

With this patch the original Save-menu behaves like it would with the original SCUMM interpreter.

This patch loads the names of the stored savegames in the loadVars() method and stores them into the array-slots 10-23 so the save-dialog can use them. In addition it creates a temporary savegame whenever Alt-F5 is pressed. When the user presses SAVE in the save-dialog the temporary savegame will be copied to the appropriate filename based on the selected slot as the ScummVM GUI would do it. In addition the header of the filename will be set to the name the user edited in the savegame list of the dialog.

This patch also contains the handling of IQ-points because it is also handled in the loadVars()/saveVars() methods. Ignore it if you don't like it.

Note: A withdraw of this solution is that the temporary file will not be deleted when saving a game or closing the dialog. This is due to the fact that with the original interpreter you can save a game in multiple slots so renaming the file does not work. In addition we do not know when the user quits the dialog because the dialog is completely handled by the game scripts. Removing all .c00 files whenever ScummVM terminates could be a solution to this problem.

Ticket imported from: #1687041. Ticket imported from: patches/729.

Attachments (6)

dialog_save.patch (11.3 KB ) - added by SF/tobigun 18 years ago.
dialog_save_alternative.patch (8.1 KB ) - added by SF/tobigun 18 years ago.
dialog_save.2.patch (5.4 KB ) - added by Kirben 18 years ago.
Patch for current SVN
dialog_save_alternative-1.patch (2.3 KB ) - added by Kirben 18 years ago.
Patch for current SVN
dialog_save_memory.patch (9.5 KB ) - added by SF/tobigun 16 years ago.
RAM buffer version
dialog_save_tmpfile.patch (6.4 KB ) - added by SF/tobigun 16 years ago.
Temp-file version

Download all attachments as: .zip

Change History (25)

by SF/tobigun, 18 years ago

Attachment: dialog_save.patch added

by SF/tobigun, 18 years ago

comment:1 by SF/tobigun, 18 years ago

An alternate approach (dialog_save_alternative.patch) would be to following: Save dialogs of old SCUMM games except Loom are cutscene, hence we can easily break the cutscene and save the state after the cutscene has terminated. A withdraw of this solution is that Loom doesn't use cutscene so we would run inside an endless loop. The patch works without a temporary savegame but does not behave like the original SAVE-dialog, beacause it returns to the game whenever a game is saved.

File Added: dialog_save_alternative.patch

by Kirben, 18 years ago

Attachment: dialog_save.2.patch added

Patch for current SVN

comment:2 by Kirben, 18 years ago

File Added: dialog_save.patch

by Kirben, 18 years ago

Patch for current SVN

comment:3 by Kirben, 18 years ago

File Added: dialog_save_alternative-1.patch

comment:4 by sev-, 17 years ago

I had an impression that this was committed. What is the status of this item?

comment:5 by Kirben, 17 years ago

No this patch was not committed, and the status is unchanged.

comment:6 by fingolfin, 17 years ago

Owner: set to fingolfin

comment:7 by fingolfin, 17 years ago

I will try to look at this in the near future.

comment:8 by fingolfin, 17 years ago

It would be nice to get this finally integrated into the trunk. Some comments:

* I prefer the "default" patch. * In theory, it would be possible to save into a special "WriteStream" which stores its data into a (dynamically growing) RAM buffer, to avoid the temporary savegame. This way it would be possible to overwrite the savegame name/title in RAM, too (i.e. inplace). * If we keep the temporary file, I would prefer if the file was named scumm.tmp or so. * Input handling has considerably changed since then. So the changes to input.cpp need to be revised

comment:9 by sev-, 16 years ago

What is the status of this item?

by SF/tobigun, 16 years ago

Attachment: dialog_save_memory.patch added

RAM buffer version

comment:10 by SF/tobigun, 16 years ago

I updated the patch to the current trunk. There is now a RAM buffer version as proposed by fingolfin and a temp-file based solution.

The RAM buffer version uses a compressed (if possible) memory stream for storage to keep memory consumption as low as possible. The savegame memory is freed on a reset, if the engine is destroyed or when the original load/save dialog is entered the next time. As the contents is compressed, in most cases it will not consume more than 20kb. Maybe a room-change listener could solve this problem but as multiple scripts might be loaded in front of the dialog one and as the save dialogs have different room numbers from game to game this might be inapplicable. IMPORTANT: This version needs the SEEK_END bugfix patch (tracker-ID: 2664460) to work properly.

The temp-file version is similar to the old "default" patch but the temporary filename is "savegame.tmp" now. So just one temp-file is used for all games.

Hopefully this patch will finally be integrated. File Added: dialog_save_memory.patch

by SF/tobigun, 16 years ago

Attachment: dialog_save_tmpfile.patch added

Temp-file version

comment:11 by SF/tobigun, 16 years ago

File Added: dialog_save_tmpfile.patch

comment:12 by sev-, 16 years ago

Since Max fixed all seek() usages, how does it correlate with it?

comment:13 by fingolfin, 16 years ago

Note that my fixes were based on tobigun's original report on the seek issue.

On thing that we should do before applying either patch: Ensure that all savefiles that are saved/loaded have either the targetname or the gameid as prefix.

Right now, we use the filename "iq-points" (or "iq-punkte" in the german version, and probably others in other languages) verbatim, as given to use by the engine. We really should internally translate this to TARGET-iq-points instead. So far, it wasn't so important since the IQ point system didn't work properly. But as soon as we fix it, we should take care of that, too.

comment:14 by SF/tobigun, 16 years ago

The IQ point system (indy3 + indy4) already works for me since ScummVM 0.11.0 but maybe I am wrong.

The IQ point part (for indy3) of this patch (tracker item 1687026) along with load support of the original save/load dialog have already been committed two years ago (first release with these patches was 0.11.0).

IQ points for indy3 are stored in "[_targetName].iq" since then. At least if a savegame is loaded with the original save/load dialog. This applies to both series and episode points. The "iq-points" and "iq-punkte" files are used by indy4 which is not addressed by this patch as the save/load dialog of indy4 (afaik) was implemented in the interpreter and not by scripts. I posted a suggestion for solving this problem to the tracker as item 2674880. Maybe you like it.

The only feature of this patch that is not already committed is the possibility to save a savegame via the "SAVE" button of the original save/load dialog. Although this stores the episode and series IQ-points too, it doesn't differ from what the "LOAD" button already does.

The only thing that is missing in regard to IQ points (indy3+4) is an automatic update of the IQ-file after loading a savegame via the ScummVM GUI. With Indy4 a workaround is to press 'i' after loading a savegame. With Indy3 you have to use the load-function of the original save/load dialog.

Sorry for causing confusion about what this patch is about.

comment:15 by fingolfin, 16 years ago

No need to be sorry for the confusion, it's my own fault :-).

Anyway, I made some tweaks (code formatting fixes, moved most of the code into ScummEngine_v3 where it belongs, etc.) and commited dialog_save_memory.patch.

Thanks a lot for your contribution! We should add you to the credits / COPYRIGHT file, if you want, but need your name for that.

comment:16 by fingolfin, 16 years ago

Status: newclosed

comment:17 by SF/tobigun, 16 years ago

Thanks for adding my patch finally :-) Maybe ScummEngine_v5::loadIQPoints()/saveIQPoints (from my older IQ-point patch for Indy3, tracker-ID #1687026) should be moved to ScummEngine_v3 too.

I have updated my profile with my name but if I remember correctly I'm already mentioned in the COPYRIGHT file.

comment:18 by fingolfin, 16 years ago

Yes, it should be changed accordingly. And your name is indeed already in the COPYRIGHT file, in fact it was there twice and I just removed the duplicate ;-). Thanks again for your patch and your persistence in getting it through.

comment:19 by digitall, 6 years ago

Component: Engine: SCUMM
Note: See TracTickets for help on using tickets.