(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
This commit is contained in:
bjarni
2005-11-17 19:43:37 +00:00
parent 2a9d325930
commit 8b4d7f97da
5 changed files with 25 additions and 5 deletions

View File

@@ -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);