Autosave names.

This commit is contained in:
gyboth 2009-02-21 14:45:25 +00:00
parent 29671e67d8
commit a013a21de1
3 changed files with 20 additions and 6 deletions

View File

@ -358,7 +358,7 @@ load_save_autosave(void)
printf("load_save_autosave\n");
#endif
gchar buf[SMALL];
gchar buf[SMALL], name[SMALL];
const gchar *home = g_get_home_dir();
FILE *fil = NULL;
@ -371,15 +371,17 @@ load_save_autosave(void)
if(counters[COUNT_AUTOSAVE] != 0)
return;
load_save_write_autosave_name(name);
if(os_is_unix)
sprintf(buf, "%s%s%s%ssaves%sautosave%02d.zip", home, G_DIR_SEPARATOR_S,
sprintf(buf, "%s%s%s%ssaves%s%s_%02d.zip", home, G_DIR_SEPARATOR_S,
HOMEDIRNAME, G_DIR_SEPARATOR_S, G_DIR_SEPARATOR_S,
counters[COUNT_AUTOSAVE_FILE]);
name, counters[COUNT_AUTOSAVE_FILE]);
else
{
gchar *pwd = g_get_current_dir();
sprintf(buf, "%s%ssaves%sautosave%02d.zip", pwd, G_DIR_SEPARATOR_S,
G_DIR_SEPARATOR_S, counters[COUNT_AUTOSAVE_FILE]);
sprintf(buf, "%s%ssaves%s%s_%02d.zip", pwd, G_DIR_SEPARATOR_S,
G_DIR_SEPARATOR_S, name, counters[COUNT_AUTOSAVE_FILE]);
g_free(pwd);
}
@ -394,6 +396,15 @@ load_save_autosave(void)
counters[COUNT_AUTOSAVE_FILE] = (counters[COUNT_AUTOSAVE_FILE] + 1) % opt_int("int_opt_autosave_files");
}
/** Write the autosave file name which is put together from
the user name, team name etc. into the parameter string. */
void
load_save_write_autosave_name(gchar *filename)
{
sprintf(filename, "autosave_%s_%s_%s_S%02d_W%02d",
usr(0).name, country.name, usr(0).tm->name, season, week);
}
/** Try to load a savegame given on the command line. */
gboolean
load_game_from_command_line(const gchar *filename)

View File

@ -40,4 +40,7 @@ load_save_autosave(void);
gboolean
load_game_from_command_line(const gchar *filename);
void
load_save_write_autosave_name(gchar *filename);
#endif

View File

@ -93,7 +93,7 @@ stat_update_league_players(League *league)
Player *pl = NULL;
gint maxlen = const_int("int_stat_players_len");
Stat new_stat;
for(i=0;i<league->teams->len;i++)
for(j=0;j<g_array_index(league->teams, Team, i).players->len;j++)
{