mirror of https://github.com/tstellar/bygfoot.git
Move country file validation out of main_init()
We only need to do this validation on program startup and main_init() may be called multiple times (e.g. if someone starts multiple new games without exiting)
This commit is contained in:
parent
5439513f1c
commit
0e72704a73
20
src/main.c
20
src/main.c
|
@ -338,6 +338,16 @@ static void validate_country_file(gpointer country_file, gpointer user_data)
|
||||||
xml_country_read(country_file, &country);
|
xml_country_read(country_file, &country);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void validate_country_files()
|
||||||
|
{
|
||||||
|
GPtrArray *country_files = file_get_country_files();
|
||||||
|
|
||||||
|
if(country_files->len == 0)
|
||||||
|
main_exit_program(EXIT_NO_COUNTRY_FILES,
|
||||||
|
"Didn't find any country definition files in the support directories.");
|
||||||
|
g_ptr_array_foreach(country_files, validate_country_file, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Process the command line arguments and do some things
|
Process the command line arguments and do some things
|
||||||
that have to be done at the beginning (like initializing the
|
that have to be done at the beginning (like initializing the
|
||||||
|
@ -389,14 +399,6 @@ main_init(gint *argc, gchar ***argv)
|
||||||
|
|
||||||
load_last_save = FALSE;
|
load_last_save = FALSE;
|
||||||
main_parse_cl_arguments(argc, argv);
|
main_parse_cl_arguments(argc, argv);
|
||||||
|
|
||||||
/* Validate XML */
|
|
||||||
country_files = file_get_country_files();
|
|
||||||
|
|
||||||
if(country_files->len == 0)
|
|
||||||
main_exit_program(EXIT_NO_COUNTRY_FILES,
|
|
||||||
"Didn't find any country definition files in the support directories.");
|
|
||||||
g_ptr_array_foreach(country_files, validate_country_file, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -427,6 +429,8 @@ main (gint argc, gchar *argv[])
|
||||||
bygfoot_init(&bygfoot, BYGFOOT_FRONTEND_GTK2);
|
bygfoot_init(&bygfoot, BYGFOOT_FRONTEND_GTK2);
|
||||||
main_init(&argc, &argv);
|
main_init(&argc, &argv);
|
||||||
|
|
||||||
|
validate_country_files();
|
||||||
|
|
||||||
gtk_init (&argc, &argv);
|
gtk_init (&argc, &argv);
|
||||||
|
|
||||||
if((load_last_save && !load_game_from_command_line("last_save")) ||
|
if((load_last_save && !load_game_from_command_line("last_save")) ||
|
||||||
|
|
Loading…
Reference in New Issue