Ok, so, I tested @vladislavbelov's patch. It was obviously designed for an earlier version of 0ad, but it did essentially work with a few flaws.
I went with 4417_autosave.2.patch on the assumption that was the newer version of the patch. The code in binaries/data/mods/public/gui/session/session.js originally looked like this in his diff:
function GetSimState()
{
if (!g_SimState)
onSimulationUpdate();
setTimeout(displayGamestateNotifications, 1000);
// Report the performance after 5 seconds (when we're still near
// the initial camera view) and a minute (when the profiler will
// have settled down if framerates as very low), to give some
Engine.SendGameReport(reportObject);
}
The code was supposed to be inserted just after the setTimeout command. The newer code in 0ad though differs, so after I inserted the code it looks like this:
function GetSimState()
{
if (!g_SimState)
g_SimState = Engine.GuiInterfaceCall("GetSimulationState");
if (!g_IsNetworked && !g_IsReplay && Engine.ConfigDB_GetValue("user", "autosave") == "true")
{
g_AutosavePeriod = +Engine.ConfigDB_GetValue("user", "autosave.period") * 60000; // the autosave period is set in minutes
// Prevent the autosave spamming for invalid values
if (g_AutosavePeriod >= 60000)
setTimeout(autosaveGame, g_AutosavePeriod);
}
return g_SimState;
}
Everything else looks the same as his diffs. His code calls for the default autosave.period to be 10, I set it to 5 for testing purposes. Note that it did create an autosave file, which I was able to reload and restart the game at the correct point, however...
1) Minor layout bug in the settings screen causes the last two settings in the settings screen to get pushed down over the Reset button:
2) When it saves, it goes into an infinite loop of saving, completely freezing the game and making it unplayable:
Note that I alt-tabbed to the ~/.local/share/0ad/saves folder and watched the autosave.0adsave last modified date updating in real time, so I know that's what was happening, and I was able to reproduce this issue each time I tested.
3) Even though it's set to create 3 autosaves, I think, it only ever created autosave.0adsave. This includes when I reloaded, it didn't move on to autosave.1adsave on the next autosave, it just went back into the same infinite loop of saving autosave.0adsave.
Other than those issues though, it definitely works. :) I am hoping that the infinite loop is just because the code inside of function GetSimState() needs to be moved to a different location, although of course I have no idea where that should be.