Forum rules - please read before posting.

Bug with high ID numbers for saves

edited June 2023 in Technical Q&A

My game autosaves on scene switch, and I only allow the player to load the autosave. The player cannot create new saves. At certain important points in the game, I create new saves, but the player isn't allowed to simply load one of them: they work as checkpoints, and for the player to resume playing from one of them, all the more recent saves are deleted first.

I tried different approaches (iterating through GetPreviousSaveIDs() etc), but they never worked quite right (possibly because DeleteSave() modifies the list every time you use it). So I ended up doing it like this:

    void RewindToCheckpoint()

        int saveToRewindTo = AC.GlobalVariables.GetIntegerValue(15); // The rewind save variable      

        int lastSave = Options.optionsData.lastSaveID;

        while (lastSave != saveToRewindTo)
            lastSave = Options.optionsData.lastSaveID;


This has been working great, though it once became an infinite loop (I'm almost sure it was because I incorrectly set saveToRewindTo to an integer that was not in the PreviousSaveIDs list).

Soon I'm also going to write a script to sort my Unity Menu according to the GetPreviousSaveIDs() list (new ones at the top).

So far so good (I think).

The thing is that almost all checkpoints are supposed to be permanent (until the player chooses to rewind to them), except one: a "new day" checkpoint, which is created not when something important has happened in the plot, but simply when a day/night cycle starts. Now, I don't want a bunch of "new day" checkpoints littering the menu, so I will simply overwrite the previous day's one.

This sounds straightforward at first: simply pick an ID and stick to it. The issue here is that sometimes the player might rewind to a plot checkpoint on a previous day, and the "new day" save will be deleted. Then, if the player does something significant in the plot before the next day, a new save will occupy that slot, and it will get unintentionally overwritten when a new day/night cycle starts.

I thought a fairly simple solution would be to pick a really high ID (say, 500) for that one save, so there would be no danger of a different save taking that ID accidentally. This is where I found a bug: AC does not seem to recognise save IDs higher than 49. I set my max amount of saves to 700, but 49 seems to be the maximum AC can work with without breaking.

AC will correctly write save files with ID higher than 49 to disk, and the ID will show up in lastSaveID and the GetPreviousSaveIDs() list. BUT it will not show up in the Save Game Manager, will not be deleted by the "Delete all saves" button, and will not be loaded via ActionList (console message: "Could not load game: file with ID 55 does not exist.").

Tbh I probably don't need more than 49 saves. But I figured I'd report the error I found.

I'm using AC 1.77.4 and Unity 2021.2.7f1


  • There's a hard-coded limit to the number of saves on line 53 of SaveSystem.cs:

    public const int MAX_SAVES = 50;

    I'll look to see if this can be removed/merged with the exposed option in the Settings Manager.

  • After looking into this: I'll be keeping these two variables separate, as there is a subtle difference.

    However, I shall move the MAX_SAVES variable to a property in the SaveFileHandler scripts, which can be overridden through simple subclassing.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.