Change: base autosaves intervals on real time (instead of game time) (#10655)

There are two fundamental issues with autosave:
- When fast-forwarding, it saves way too often
- When paused, it never saves

Both makes no sense. Autosaves are meant to prevent you from
accidentally losing your work. The emphasis on "your" work.

To solve both issues, the autosave now works on real time. You
can select every 10 / 30 / 60 / 120 minutes, which are similar to
what the setting was in game-months.

When you pause, autosaving will stop. Unless you make any change
to the game; then it will continue to make autosaves, even so
the game is paused. Unpausing / pausing resets this mechanism.
This commit is contained in:
Patric Stout
2023-04-27 17:21:29 +02:00
committed by GitHub
parent 57f2d70fef
commit f5fad88723
10 changed files with 187 additions and 28 deletions

View File

@@ -66,6 +66,7 @@ enum PauseMode : byte {
PM_PAUSED_ACTIVE_CLIENTS = 1 << 4, ///< A game paused for 'min_active_clients'
PM_PAUSED_GAME_SCRIPT = 1 << 5, ///< A game paused by a game script
PM_PAUSED_LINK_GRAPH = 1 << 6, ///< A game paused due to the link graph schedule lagging
PM_COMMAND_DURING_PAUSE = 1 << 7, ///< A game paused, and a command executed during the pause; resets on autosave
/** Pause mode bits when paused for network reasons. */
PMB_PAUSED_NETWORK = PM_PAUSED_ACTIVE_CLIENTS | PM_PAUSED_JOIN,
@@ -87,5 +88,6 @@ void SwitchToMode(SwitchMode new_mode);
bool RequestNewGRFScan(struct NewGRFScanCallback *callback = nullptr);
void OpenBrowser(const char *url);
void ChangeAutosaveFrequency(bool reset);
#endif /* OPENTTD_H */