OpenFactorioServerManager / factorio-server-manager

A tool to help manage Factorio multiplayer servers including mods and save games.
MIT License
568 stars 135 forks source link

Enable the creation of named save while server is active. #401

Open Squelch opened 3 months ago

Squelch commented 3 months ago

Background

On the Saves page, the user is prevented from creating a save while the server is running. Factorio now allows the console command /c server-save This will save the game as the currently loaded filename in the same manner as Save and Stop Server on the Controls page. However, a non documented feature of this command is that it also allows a named save to be created ie/c server save 123 with .zip extension being appended automattically. Cannot-save-while-running

Suggestion

Instead of displaying the message that saves are not possible, branch the code from using system IO file creation while game is not running, to issuing an RCON command to save the savegame name entered in the field while the game is running. Save-while-running

Expected result:

Save-Complete

The same result can be achieved from the console page, or by issuing the command ingame of course, but this suggestion would appear more intuitive, and remove the suggestion that no save while running is not possible.

knoxfighter commented 3 months ago

That is a great suggestion. Also there is no need to run the LUA console. The command /server-save can be used directly.

Mattie112 commented 3 months ago

Does this also leave the game running? E.g. does this prevent the "saving" pause when (autosaving) saving normally?

Squelch commented 3 months ago

Does this also leave the game running? E.g. does this prevent the "saving" pause when (autosaving) saving normally?

Only on Linux machines where forking and therefore asynchronous saving is possible. Sadly Windows does not allow this natively, but I think I recall that WSL2 can fork. Players will still see the save being created by the server however.

Some background. Asynchronous saving was, and still is in some places marked as experimental, but has been fixed. There were problems reported where it would cause crashes. The problem was eventually tracked down to being Steam specific where both forks of Factorio would send the same save to Steam. The first would be accepted and acknowledged, but the second would never complete. This left multiple forks hanging waiting for the acknowledgment that never arrived and an eventual crash. Standalone Factorio never suffered from this problem.

See the forum thread: https://forums.factorio.com/viewtopic.php?p=523229#p523229