RetroArch icon indicating copy to clipboard operation
RetroArch copied to clipboard

Save state wrap-around

Open zoltanvb opened this issue 1 year ago • 5 comments

Description

When save state auto indexing is enabled, and maximum kept states are limited, wrap around to slot 0 after reaching the configured maximum.

A gap in the indexing is used to keep track of most recent state. If e.g. maximum kept amount is 5, then indexes 0..5 will be used, if 3 is empty, most recent state is 2. Presence of gap is maintained by garbage collector function.

Tested in several scenarios:

  • no limit (maximum kept = 0)
  • limit set up, load/save
  • limit change from lower to higher
  • limit change from higher to lower (extra saves created earlier will remain, but wraparound works correctly)

Previous maximum finder and garbage collector logic unified since now it requires very similar processing.

Originally, I planned to implement a more complicated version, where e.g. 10 lowest slots were reserved for saving manually (hence the "_without_reservation" in the branch name), but it turned out to be overly complex, with extra options, and still having lots of quirks, so I trimmed it down to this, without any optionality.

Also, doing extended cleanup would be tricky and easy for the user to make errors, so the only-one-delete-per-save rule is kept.

Related Issues

Fixes #10471 Fixes #16723 (will not allow loading old slots >999, but will prevent it from occurring)

zoltanvb avatar Sep 01 '24 09:09 zoltanvb

If e.g. maximum kept amount is 5, then indexes 0..5 will be used

This is another weird behaviour in Retroarch, a mix of array indexing and natural numbers. If 5 is the upper limit, why are there 6 save slots being occupied? I think slot 0 should be removed entirely.

opusforlife2 avatar Sep 01 '24 14:09 opusforlife2

Yes, it is stupid on every possible level that the count starts at 0. I would not mind changing it all the way regardless of breaking previous saves, but a cosmetic change is also ok.

sonninnos avatar Sep 01 '24 14:09 sonninnos

I don't think it would break previous saves if Retroarch simply couldn't create a savestate at index 0, or load from it. It would just leave an orphaned save state if one existed.

opusforlife2 avatar Sep 01 '24 14:09 opusforlife2

That is what I meant with breaking.

sonninnos avatar Sep 01 '24 15:09 sonninnos

If 5 is the upper limit, why are there 6 save slots being occupied?

The reason is the gap that allows to determine which one is the most recent. So, out of the 6 slots, 5 is occupied at any time (after the range is filled up).

Having an index 0 is needlessly technical, I can agree with that, but I personally would not like to bring a breaking change just because of that. Cosmetics can be adjusted at some point, but maybe it will be confusing to someone who has just lost "state14" in a filesystem accident.

Anyway, the point of auto-indexing is that one can just spam F2 to save, F4 to load last, and only go to the slot list when an older save is needed, and in this case I guess it is easier to look through the first x+1 entries, instead of a long list which is mostly empty.

zoltanvb avatar Sep 01 '24 18:09 zoltanvb

I think it's not worth it to try to mess with save state slot 0 even if we only represented it visually as Slot 1. Probably would cause a lot of unintended confusion among users who have grown accustomed to this over the years for very questionable gains if at all.

LibretroAdmin avatar Sep 04 '24 05:09 LibretroAdmin

https://github.com/libretro/RetroArch/issues/16693

Does it fix this too?

jayare5 avatar Sep 04 '24 22:09 jayare5