From 5e2c67c57020c872583b4fa46613d42b8eb51909 Mon Sep 17 00:00:00 2001 From: gyboth Date: Tue, 13 Jan 2009 21:47:52 +0000 Subject: [PATCH] Load save bugfix. --- src/start_end.c | 2 ++ src/team.c | 10 +++++----- src/xml_loadsave_fixtures.c | 7 ++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/start_end.c b/src/start_end.c index dd513591..8994cb95 100644 --- a/src/start_end.c +++ b/src/start_end.c @@ -184,6 +184,8 @@ start_new_season(void) (pointers might have changed because of prom/rel). */ else if(cp(i).add_week == -1) fixture_refresh_team_pointers(cp(i).fixtures); + else if(!query_cup_self_referential(&cp(i))) + cup_reset(&cp(i)); } for(i = acps->len - 1; i >= 0; i--) diff --git a/src/team.c b/src/team.c index 19b05c76..0872f1c2 100644 --- a/src/team.c +++ b/src/team.c @@ -233,8 +233,7 @@ team_of_id(gint id) printf("team_of_id\n"); #endif - - gint i, j; + gint i, j, k; for(i=0;ilen;i++) for(j=0;jlen;j++) @@ -242,9 +241,10 @@ team_of_id(gint id) return &g_array_index(lig(i).teams, Team, j); for(i=0;ilen;i++) - for(j=0;jlen;j++) - if(((Team*)g_ptr_array_index(cp(i).teams, j))->id == id) - return (Team*)g_ptr_array_index(cp(i).teams, j); + for(j = 0; j < cp(i).rounds->len; j++) + for(k = 0; k < g_array_index(cp(i).rounds, CupRound, j).teams->len; k++) + if(g_array_index(g_array_index(cp(i).rounds, CupRound, j).teams, Team, k).id == id) + return &g_array_index(g_array_index(cp(i).rounds, CupRound, j).teams, Team, k); main_exit_program(EXIT_POINTER_NOT_FOUND, "team_of_id: team with id %d not found.", id); diff --git a/src/xml_loadsave_fixtures.c b/src/xml_loadsave_fixtures.c index 367a7f2d..caadb006 100644 --- a/src/xml_loadsave_fixtures.c +++ b/src/xml_loadsave_fixtures.c @@ -261,13 +261,10 @@ xml_loadsave_fixtures_write(const gchar *filename, const GArray *fixtures) TAG_FIXTURE_RESULT, I1); xml_write_int(fil, g_array_index(fixtures, Fixture, i).result[j][2], TAG_FIXTURE_RESULT, I1); + xml_write_int(fil, g_array_index(fixtures, Fixture, i).team_ids[j], + TAG_TEAM_ID, I1); } - xml_write_int(fil, g_array_index(fixtures, Fixture, i).team_ids[0], - TAG_TEAM_ID, I1); - xml_write_int(fil, g_array_index(fixtures, Fixture, i).team_ids[1], - TAG_TEAM_ID, I1); - fprintf(fil, "\n", TAG_FIXTURE); } fprintf(fil, "\n", TAG_FIXTURES);