mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-02-06 02:33:30 +01:00
"Cup load/save fix."
This commit is contained in:
parent
82a5b05deb
commit
c4fb6e9e02
@ -237,7 +237,7 @@ cup_get_team_pointers(Cup *cup, gint round)
|
||||
|
||||
if(debug > 70)
|
||||
for(i=0;i<teams->len;i++)
|
||||
printf("%d %s \n", i, ((Team*)g_ptr_array_index(teams, i))->name->str);
|
||||
printf("cup_get_team_pointers: %d %s \n", i, ((Team*)g_ptr_array_index(teams, i))->name->str);
|
||||
}
|
||||
|
||||
/** Get the pointers to the teams (already generated, in one of the leagues or cups)
|
||||
@ -393,7 +393,7 @@ cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct)
|
||||
|
||||
if(debug > 80)
|
||||
for(i=debug_num;i<teams->len;i++)
|
||||
printf("%d %s \n", i, ((Team*)g_ptr_array_index(teams, i))->name->str);
|
||||
printf("cup_load_choose_team: %d %s \n", i, ((Team*)g_ptr_array_index(teams, i))->name->str);
|
||||
}
|
||||
|
||||
/** Load the teams specified in the chooseteam from a non-country league. */
|
||||
|
@ -47,10 +47,12 @@ fixture_write_cup_fixtures(Cup *cup)
|
||||
|
||||
if(g_array_index(cup->rounds, CupRound, 0).round_robin_number_of_groups > 0)
|
||||
fixture_write_cup_round_robin(cup, 0,
|
||||
g_array_index(cup->rounds, CupRound, 0).team_ptrs);
|
||||
misc_copy_ptr_array(
|
||||
g_array_index(cup->rounds, CupRound, 0).team_ptrs));
|
||||
else
|
||||
fixture_write_knockout_round(cup, 0,
|
||||
g_array_index(cup->rounds, CupRound, 0).team_ptrs);
|
||||
misc_copy_ptr_array(
|
||||
g_array_index(cup->rounds, CupRound, 0).team_ptrs));
|
||||
}
|
||||
|
||||
/** Update the fixtures for the given cup.
|
||||
|
18
src/misc.c
18
src/misc.c
@ -462,3 +462,21 @@ misc_parse(const gchar *s, gint *result)
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/** Return a freshly allocated copy of the array. */
|
||||
GPtrArray*
|
||||
misc_copy_ptr_array(const GPtrArray *array)
|
||||
{
|
||||
gint i;
|
||||
GPtrArray *copy = NULL;
|
||||
|
||||
if(array != NULL)
|
||||
copy = g_ptr_array_new();
|
||||
else
|
||||
return NULL;
|
||||
|
||||
for(i=0;i<array->len;i++)
|
||||
g_ptr_array_add(copy, g_ptr_array_index(array, i));
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
@ -71,4 +71,7 @@ misc_parse_and(const gchar *s, gint *result);
|
||||
const gchar*
|
||||
misc_parse(const gchar *s, gint *result);
|
||||
|
||||
GPtrArray*
|
||||
misc_copy_ptr_array(const GPtrArray *array);
|
||||
|
||||
#endif
|
||||
|
@ -83,6 +83,9 @@ xml_load_league(const gchar *dirname, const gchar *basename, const GPtrArray *di
|
||||
gtk_progress_bar_get_fraction(
|
||||
GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"))), buf);
|
||||
|
||||
if(debug > 80)
|
||||
printf("%s\n", buf);
|
||||
|
||||
sprintf(buf, "%s/%s_teams.xml", dirname, prefix);
|
||||
xml_loadsave_teams_read(buf, lig(ligs->len - 1).teams);
|
||||
|
||||
@ -143,6 +146,9 @@ xml_load_cup(Cup *cup, const gchar *dirname, const gchar *basename, const GPtrAr
|
||||
gtk_progress_bar_get_fraction(
|
||||
GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"))), buf);
|
||||
|
||||
if(debug > 80)
|
||||
printf("%s\n", buf);
|
||||
|
||||
sprintf(buf, "%s/%s_fixtures.xml", dirname, prefix);
|
||||
xml_loadsave_fixtures_read(buf, cup->fixtures);
|
||||
|
||||
|
@ -28,6 +28,7 @@ enum
|
||||
TAG_CUP_ROUND_NEW_TEAMS,
|
||||
TAG_CUP_ROUND_BYES,
|
||||
TAG_CUP_ROUND_TEAMS_FILE,
|
||||
TAG_CUP_ROUND_TEAM_PTR_ID,
|
||||
TAG_CUP_ROUND_TABLE_FILE,
|
||||
TAG_CUP_ROUND_HOME_AWAY,
|
||||
TAG_CUP_ROUND_REPLAY,
|
||||
@ -128,6 +129,7 @@ xml_loadsave_cup_end_element (GMarkupParseContext *context,
|
||||
state = TAG_CUP_CHOOSE_TEAM;
|
||||
else if(tag == TAG_CUP_ROUND_HOME_AWAY ||
|
||||
tag == TAG_CUP_ROUND_TEAMS_FILE ||
|
||||
tag == TAG_CUP_ROUND_TEAM_PTR_ID ||
|
||||
tag == TAG_CUP_ROUND_TABLE_FILE ||
|
||||
tag == TAG_CUP_ROUND_NEW_TEAMS ||
|
||||
tag == TAG_CUP_ROUND_BYES ||
|
||||
@ -225,6 +227,8 @@ xml_loadsave_cup_text (GMarkupParseContext *context,
|
||||
g_ptr_array_add(new_cup->teams,
|
||||
&g_array_index(new_round.teams, Team, i));
|
||||
}
|
||||
else if(state == TAG_CUP_ROUND_TEAM_PTR_ID)
|
||||
g_ptr_array_add(new_round.team_ptrs, team_of_id(int_value));
|
||||
else if(state == TAG_CUP_ROUND_TABLE_FILE)
|
||||
{
|
||||
new_table = table_new();
|
||||
@ -388,6 +392,10 @@ xml_loadsave_cup_write_round(FILE *fil, const gchar *prefix, const Cup *cup, gin
|
||||
xml_loadsave_cup_write_choose_team(
|
||||
fil, &g_array_index(cup_round->choose_teams, CupChooseTeam, i));
|
||||
|
||||
for(i=0;i<cup_round->team_ptrs->len;i++)
|
||||
xml_write_int(fil, ((Team*)g_ptr_array_index(cup_round->team_ptrs, i))->id,
|
||||
TAG_CUP_ROUND_TEAM_PTR_ID, I1);
|
||||
|
||||
fprintf(fil, "</_%d>\n", TAG_CUP_ROUND);
|
||||
|
||||
g_free(basename);
|
||||
|
Loading…
x
Reference in New Issue
Block a user