mirror of https://github.com/tstellar/bygfoot.git
Ensure that all teams are loaded from a save file before looking up pointers
This fixes a crash when loading a save file from the command line.
This commit is contained in:
parent
da454689f6
commit
84daa736a8
|
@ -256,6 +256,21 @@ load_save_load_game(Bygfoot *bygfoot, const gchar* filename, gboolean create_mai
|
|||
|
||||
xml_loadsave_leagues_cups_read(bygfoot, dirname, prefix);
|
||||
|
||||
if(debug > 60)
|
||||
g_print("load_save_load misc \n");
|
||||
|
||||
bygfoot_show_progress(bygfoot,
|
||||
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
|
||||
_("Loading miscellaneous..."),
|
||||
PIC_TYPE_LOAD);
|
||||
|
||||
xml_loadsave_misc_read(bygfoot, dirname, prefix);
|
||||
|
||||
/* Now that all the teams have been loaded, replace the team ids with team ptrs
|
||||
* where necessary. */
|
||||
xml_loadsave_leagues_cups_adjust_team_ptrs();
|
||||
|
||||
|
||||
if(debug > 60)
|
||||
g_print("load_save_load users \n");
|
||||
|
||||
|
@ -307,16 +322,6 @@ load_save_load_game(Bygfoot *bygfoot, const gchar* filename, gboolean create_mai
|
|||
|
||||
xml_loadsave_newspaper_read(dirname, prefix);
|
||||
|
||||
if(debug > 60)
|
||||
g_print("load_save_load misc \n");
|
||||
|
||||
bygfoot_show_progress(bygfoot,
|
||||
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
|
||||
_("Loading miscellaneous..."),
|
||||
PIC_TYPE_LOAD);
|
||||
|
||||
xml_loadsave_misc_read(bygfoot, dirname, prefix);
|
||||
|
||||
if(debug > 60)
|
||||
g_print("load_save_load done \n");
|
||||
|
||||
|
|
|
@ -288,6 +288,7 @@ main_init_variables(void)
|
|||
ligs = g_array_new(FALSE, FALSE, sizeof(League));
|
||||
cps = g_array_new(FALSE, FALSE, sizeof(Cup));;
|
||||
acps = g_ptr_array_new();
|
||||
country_list = NULL;
|
||||
country.name = NULL;
|
||||
country.symbol = NULL;
|
||||
country.sid = NULL;
|
||||
|
|
|
@ -167,8 +167,6 @@ xml_loadsave_leagues_cups_read(Bygfoot *bygfoot, const gchar *dirname, const gch
|
|||
debug_print_message("xml_loadsave_misc_read: error parsing file %s\n", file);
|
||||
misc_print_error(&error, TRUE);
|
||||
}
|
||||
|
||||
xml_loadsave_leagues_cups_adjust_team_ptrs();
|
||||
}
|
||||
|
||||
/** Write the leagues into xml files with the given prefix. */
|
||||
|
|
|
@ -271,7 +271,8 @@ xml_loadsave_misc_read(Bygfoot *bygfoot, const gchar *dirname, const gchar *base
|
|||
g_ptr_array_free(acps, TRUE);
|
||||
acps = g_ptr_array_new();
|
||||
|
||||
g_ptr_array_free(country_list, TRUE);
|
||||
if (country_list)
|
||||
g_ptr_array_free(country_list, TRUE);
|
||||
country_list = g_ptr_array_new();
|
||||
free_bets(TRUE);
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ tmphome=`mktemp -d`
|
|||
pushd $bygfoot_bindir
|
||||
HOME=$tmphome ./bygfoot --random-seed=1 --json=$json_file
|
||||
|
||||
# Verify that the save file are identical.
|
||||
for f in save0 save1 save2 save3; do
|
||||
|
||||
mkdir -p $save_dir/$f
|
||||
|
@ -38,3 +39,13 @@ for f in save0 save1 save2 save3; do
|
|||
done
|
||||
diff -r $save_dir/save0 $save_dir/save1
|
||||
diff -r $save_dir/save2 $save_dir/save3
|
||||
|
||||
# Test that we can load the saves on start up.
|
||||
cat << EOF > $json_file
|
||||
{ 'commands' : [
|
||||
{'load_bygfoot' : {'filename' : '$save_dir/save0.zip'}},
|
||||
{'load_bygfoot' : {'filename' : '$save_dir/save2.zip'}}
|
||||
]}
|
||||
EOF
|
||||
|
||||
HOME=$tmphome ./bygfoot --random-seed=1 --json=$json_file
|
||||
|
|
Loading…
Reference in New Issue