1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2024-12-14 09:25:14 +01:00

"Cup teams loaded all at once."

This commit is contained in:
gyboth 2005-08-15 16:25:49 +00:00
parent e436801289
commit 82a5b05deb
6 changed files with 51 additions and 33 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2005-08-15 15:12+0200\n"
"POT-Creation-Date: 2005-08-15 18:16+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -277,37 +277,37 @@ msgstr ""
msgid "Do you really want to kick the poor boy out of your academy?"
msgstr ""
#: src/cup.c:839
#: src/cup.c:847
msgid " -- Second leg"
msgstr ""
#: src/cup.c:841
#: src/cup.c:849
msgid " -- First leg"
msgstr ""
#: src/cup.c:844
#: src/cup.c:852
msgid " -- Replay matches"
msgstr ""
#: src/cup.c:856
#: src/cup.c:864
msgid "Round robin"
msgstr ""
#. A cup stage, e.g. Last 32 when there are only 32 teams left.
#: src/cup.c:864
#: src/cup.c:872
#, c-format
msgid "Last %d"
msgstr ""
#: src/cup.c:867
#: src/cup.c:875
msgid "Final"
msgstr ""
#: src/cup.c:870
#: src/cup.c:878
msgid "Semi-final"
msgstr ""
#: src/cup.c:873
#: src/cup.c:881
msgid "Quarter-final"
msgstr ""
@ -334,12 +334,12 @@ msgid "You have %d weeks to pay back the rest of your loan."
msgstr ""
#. Game was decided in penalty shoot-out.
#: src/fixture.c:797
#: src/fixture.c:802
msgid " p."
msgstr ""
#. Game was decided in extra time.
#: src/fixture.c:800
#: src/fixture.c:805
msgid " e.t."
msgstr ""

View File

@ -81,6 +81,7 @@ cup_round_new(void)
new.tables = g_array_new(FALSE, FALSE, sizeof(Table));
new.choose_teams = g_array_new(FALSE, FALSE, sizeof(CupChooseTeam));
new.teams = g_array_new(FALSE, FALSE, sizeof(Team));
new.team_ptrs = g_ptr_array_new();
return new;
}
@ -110,14 +111,19 @@ cup_reset(Cup *cup)
if(g_array_index(cup->rounds, CupRound, i).tables->len > 0)
{
for(j=0;j<g_array_index(cup->rounds, CupRound, i).tables->len;j++)
free_table(&g_array_index(g_array_index(cup->rounds, CupRound, i).tables, Table, j));
free_table(&g_array_index(
g_array_index(cup->rounds, CupRound, i).tables, Table, j));
g_array_free(g_array_index(cup->rounds, CupRound, i).tables, TRUE);
g_array_index(cup->rounds, CupRound, i).tables = g_array_new(FALSE, FALSE, sizeof(Table));
g_array_index(cup->rounds, CupRound, i).tables =
g_array_new(FALSE, FALSE, sizeof(Table));
}
if(g_array_index(cup->rounds, CupRound, i).teams->len > 0)
free_teams_array(&g_array_index(cup->rounds, CupRound, i).teams, TRUE);
g_ptr_array_free(g_array_index(cup->rounds, CupRound, i).team_ptrs, TRUE);
g_array_index(cup->rounds, CupRound, i).team_ptrs = g_ptr_array_new();
}
}
@ -190,19 +196,23 @@ cup_get_choose_team_league_cup(const CupChooseTeam *ct,
}
}
/** Return the pointers to the teams participating in the
cup. If necessary, teams are generated and stored in the teams
array of the cup. */
GPtrArray*
/** Load the pointers to the teams participating in the
cup round. If necessary, teams are generated and stored in the teams
array of the cup round. */
void
cup_get_team_pointers(Cup *cup, gint round)
{
gint i;
GPtrArray *teams = g_ptr_array_new();
CupRound *cup_round = &g_array_index(cup->rounds, CupRound, round);
GPtrArray *teams = cup_round->team_ptrs;
if(debug > 60)
printf("cup_get_team_pointers %s \n", cup->name->str);
if(teams->len > 0)
g_warning("cup_get_team_pointers: round %d in cup %s has non-empty team pointers array.",
round, cup->name->str);
for(i=0;i<cup_round->choose_teams->len;i++)
if(g_array_index(cup_round->choose_teams, CupChooseTeam, i).generate)
cup_load_choose_team_generate(cup, cup_round,
@ -228,8 +238,6 @@ 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);
return teams;
}
/** Get the pointers to the teams (already generated, in one of the leagues or cups)

View File

@ -27,7 +27,7 @@ cup_round_new(void);
void
cup_reset(Cup *cup);
GPtrArray*
void
cup_get_team_pointers(Cup *cup, gint round);
void

View File

@ -39,6 +39,10 @@ typedef struct
/** The teams that got loaded for this cup round.
Mostly this only happens in the first round. */
GArray *teams;
/** Pointers to all teams loaded in the cup round; these
teams get passed to the fixture generation function
together with the teams advancing from the previous round. */
GPtrArray *team_ptrs;
/** Which new teams come into the cup (@see #CupChooseTeam) */
GArray *choose_teams;
/** The round robin tables (in case there is a round robin). */

View File

@ -40,14 +40,17 @@ fixture_write_league_fixtures(League *league)
void
fixture_write_cup_fixtures(Cup *cup)
{
GPtrArray *teams = NULL;
gint i;
teams = cup_get_team_pointers(cup, 0);
for(i=0;i<cup->rounds->len;i++)
cup_get_team_pointers(cup, i);
if(g_array_index(cup->rounds, CupRound, 0).round_robin_number_of_groups > 0)
fixture_write_cup_round_robin(cup, 0, teams);
fixture_write_cup_round_robin(cup, 0,
g_array_index(cup->rounds, CupRound, 0).team_ptrs);
else
fixture_write_knockout_round(cup, 0, teams);
fixture_write_knockout_round(cup, 0,
g_array_index(cup->rounds, CupRound, 0).team_ptrs);
}
/** Update the fixtures for the given cup.
@ -59,7 +62,7 @@ fixture_update(Cup *cup)
GArray *fixtures = cup->fixtures;
gint round = g_array_index(fixtures, Fixture, fixtures->len - 1).round;
gint replay = g_array_index(cup->rounds, CupRound, round).replay;
GPtrArray *teams = NULL, *teams_new = NULL;
GPtrArray *teams = NULL;
const CupRound *new_round = NULL;
if(replay != 0 &&
@ -70,27 +73,29 @@ fixture_update(Cup *cup)
teams = fixture_get_cup_round_winners(cup);
if(round == cup->rounds->len - 1 && teams->len < 2)
{
g_ptr_array_free(teams, TRUE);
return;
}
if(round + 1 > cup->rounds->len - 1)
{
g_warning("fixture_update: round index %d too high for round array (%d) in cup %s\n",
round + 1, cup->rounds->len - 1, cup->name->str);
g_ptr_array_free(teams, TRUE);
main_exit_program(EXIT_CUP_ROUND_ERROR, NULL);
}
new_round = &g_array_index(cup->rounds, CupRound, round + 1);
if(new_round->choose_teams->len > 0)
{
teams_new = cup_get_team_pointers(cup, round + 1);
for(i=0;i<teams_new->len;i++)
g_ptr_array_add(teams, g_ptr_array_index(teams_new, i));
g_ptr_array_free(teams_new, TRUE);
}
for(i=0;i<new_round->team_ptrs->len;i++)
g_ptr_array_add(teams, g_ptr_array_index(new_round->team_ptrs, i));
if(teams->len < 2)
{
g_ptr_array_free(teams, TRUE);
return;
}
if(cup->bye != NULL && cup->bye->len != 0)
{

View File

@ -436,6 +436,7 @@ free_cup(Cup *cup)
free_g_array(&g_array_index(cup->rounds, CupRound, i).choose_teams);
free_teams_array(&g_array_index(cup->rounds, CupRound, i).teams, FALSE);
g_ptr_array_free(g_array_index(cup->rounds, CupRound, i).team_ptrs, TRUE);
}
free_g_array(&cup->rounds);