diff --git a/src/cup.c b/src/cup.c index 272bfac1..8e2497e2 100644 --- a/src/cup.c +++ b/src/cup.c @@ -791,26 +791,23 @@ cup_get_round_reached(const Team *tm, const GArray *fixtures) @param cup_round The index of the cup round in the cup.rounds array. @return A week number. */ gint -cup_get_first_week_of_cup_round(Cup *cup, gint cup_round) +cup_get_first_week_of_cup_round(Cup *cup, gint cup_round, gboolean with_delay) { #ifdef DEBUG printf("cup_get_first_week_of_cup_round\n"); #endif - gint i; gint week_number; if(cup_round == cup->rounds->len - 1) week_number = cup->last_week - (cup_get_matchdays_in_cup_round(cup, cup_round) - 1) * cup->week_gap; else - week_number = cup_get_first_week_of_cup_round(cup, cup_round + 1) - + week_number = cup_get_first_week_of_cup_round(cup, cup_round + 1, FALSE) - cup_get_matchdays_in_cup_round(cup, cup_round) * cup->week_gap; - week_number += g_array_index(cup->rounds, CupRound, cup_round).delay; - - for(i=cup->rounds->len - 1; i > cup_round; i--) - week_number -= g_array_index(cup->rounds, CupRound, i).delay; + if(with_delay) + week_number += g_array_index(cup->rounds, CupRound, cup_round).delay; if(week_number <= 0) { @@ -830,7 +827,7 @@ cup_get_first_week_of_cup_round(Cup *cup, gint cup_round) cup->last_week); } - return cup_get_first_week_of_cup_round(cup, cup_round); + return cup_get_first_week_of_cup_round(cup, cup_round, with_delay); } return week_number; diff --git a/src/cup.h b/src/cup.h index a36763ab..5fe38f08 100644 --- a/src/cup.h +++ b/src/cup.h @@ -63,7 +63,7 @@ void cup_load_choose_team_from_cup(Cup *cup, const Cup *cup_team, GPtrArray *teams, const CupChooseTeam *ct); gint -cup_get_first_week_of_cup_round(Cup *cup, gint cup_round); +cup_get_first_week_of_cup_round(Cup *cup, gint cup_round, gboolean with_delay); gint cup_get_matchdays_in_cup_round(const Cup *cup, gint round); diff --git a/src/fixture.c b/src/fixture.c index b324a526..186202fc 100644 --- a/src/fixture.c +++ b/src/fixture.c @@ -512,7 +512,7 @@ fixture_write_round_robin(gpointer league_cup, gint cup_round, { cup = (Cup*)league_cup; if(first_week == -1) - first_week = cup_get_first_week_of_cup_round(cup, cup_round); + first_week = cup_get_first_week_of_cup_round(cup, cup_round, TRUE); week_gap = cup->week_gap; fixtures = cup->fixtures; two_match_weeks = g_array_index(cup->rounds, CupRound, cup_round).two_match_weeks; @@ -643,7 +643,7 @@ fixture_write_knockout_round(Cup *cup, gint cup_round, GPtrArray *teams) #endif gint i, len = teams->len; - gint first_week = cup_get_first_week_of_cup_round(cup, cup_round); + gint first_week = cup_get_first_week_of_cup_round(cup, cup_round, TRUE); gint week_number, week_round_number; CupRound *round = &g_array_index(cup->rounds, CupRound, cup_round); gint bye_len = (round->byes == -1) ?