summaryrefslogtreecommitdiff
path: root/openttd.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-11-17 19:43:37 +0000
committerbjarni <bjarni@openttd.org>2005-11-17 19:43:37 +0000
commiteba1f68439364236de7ae3c7792e2a87cfbcf670 (patch)
tree58b3df375737d146806314ed1b4a8e83dffbdac1 /openttd.c
parent3e702afc08bd8118f5b01e6493fcdea1aea4c0d4 (diff)
downloadopenttd-eba1f68439364236de7ae3c7792e2a87cfbcf670.tar.xz
(svn r3214) -Feature: openttd.cfg can now set how many autosaves to keep before starting to overwrite old ones
max_autosave_num in the config files sets the number of autosaves to keep (default 16) MAX_NUM_AUTOSAVES in Makefile.config sets the default value. 16 is used if no value is given this behaviour can still be overwritten by keep_all_autosave (openttd.config setting) Note: this is a requested behaviour for PDA ports, since they got limited storage space
Diffstat (limited to 'openttd.c')
-rw-r--r--openttd.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/openttd.c b/openttd.c
index e63685382..cc4732df7 100644
--- a/openttd.c
+++ b/openttd.c
@@ -888,10 +888,14 @@ static void DoAutosave(void)
SetDParam(2, _date);
s = GetString(buf + strlen(_path.autosave_dir) + strlen(PATHSEP), STR_4004);
strcpy(s, ".sav");
- } else { /* Save a maximum of 15 autosaves */
- int n = _autosave_ctr;
- _autosave_ctr = (_autosave_ctr + 1) & 15;
- sprintf(buf, "%s%sautosave%d.sav", _path.autosave_dir, PATHSEP, n);
+ } else { /* generate a savegame name and number according to _patches.max_num_autosaves */
+ sprintf(buf, "%s%sautosave%d.sav", _path.autosave_dir, PATHSEP, _autosave_ctr);
+
+ _autosave_ctr++;
+ if (_autosave_ctr >= _patches.max_num_autosaves) {
+ // we reached the limit for numbers of autosaves. We will start over
+ _autosave_ctr = 0;
+ }
}
DEBUG(misc, 2) ("Autosaving to %s", buf);