This patch was made with the goal of troubleshooting, as such, it only auto saves.
Things that this patch does not do is:
- provide a manual save.
- allow changing the auto save file (found in struct Game auto_save_file) (default to g_get_user_data_dir()/pioneers/autosave.game.)
- saves all data found in struct Game and any other server specific data. Only data that is sent to client when the client joins is saved.
- provide a way to load the saved game.
Eventually these things can be added, but as a already stated, the purpose of this patch is to troubleshoot. I would also like to propose changing the protocol for submitting a bug is to send this file (before the end of the turn, where the data would be lost.) with actions that caused the bug. (If only half of the file is written, we have a good idea what caused the segfault.)
Provies auto saving server.
Finally I've found the time to review this patch.
The write_other_playerinfo is intended for the client to be able to receive information about the other players, but with secrets (e.g. exactly which resource cards they own). If the state of the server must be written to a file, for each Player struct the full data should be dumped. Also the stack of the StateMachine could be necessary to dump, and also all BuildRec entries (if undo states should also be saved).
The purpose of this patch is to troubleshoot. I would also recommend to use gdb, and to run Pioneers with the command line option --g-fatal-warnings. It's not an easy tool, but I've found and resolved many bugs with gdb.
Valgrind can also be of help to find cases where someone has forgotten to free allocated memory.
If this patch is modified to fully save a game, it should do that when prompted, either by a signal, a command sent on the admin interface or by a special message on the listening port. I would not recommend to fully save a game for every game for every turn. That generates a lot of I/O on the meta-server.
Note: saving a game that at a later time could be reloaded is a welcome feature request for people who play a very long game.