mirror of https://github.com/tstellar/bygfoot.git
Corrected cup delay.
This commit is contained in:
parent
9d2fb89452
commit
e2a53c9928
13
src/cup.c
13
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.
|
@param cup_round The index of the cup round in the cup.rounds array.
|
||||||
@return A week number. */
|
@return A week number. */
|
||||||
gint
|
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
|
#ifdef DEBUG
|
||||||
printf("cup_get_first_week_of_cup_round\n");
|
printf("cup_get_first_week_of_cup_round\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gint i;
|
|
||||||
gint week_number;
|
gint week_number;
|
||||||
|
|
||||||
if(cup_round == cup->rounds->len - 1)
|
if(cup_round == cup->rounds->len - 1)
|
||||||
week_number = cup->last_week -
|
week_number = cup->last_week -
|
||||||
(cup_get_matchdays_in_cup_round(cup, cup_round) - 1) * cup->week_gap;
|
(cup_get_matchdays_in_cup_round(cup, cup_round) - 1) * cup->week_gap;
|
||||||
else
|
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;
|
cup_get_matchdays_in_cup_round(cup, cup_round) * cup->week_gap;
|
||||||
|
|
||||||
week_number += g_array_index(cup->rounds, CupRound, cup_round).delay;
|
if(with_delay)
|
||||||
|
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(week_number <= 0)
|
if(week_number <= 0)
|
||||||
{
|
{
|
||||||
|
@ -830,7 +827,7 @@ cup_get_first_week_of_cup_round(Cup *cup, gint cup_round)
|
||||||
cup->last_week);
|
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;
|
return week_number;
|
||||||
|
|
|
@ -63,7 +63,7 @@ void
|
||||||
cup_load_choose_team_from_cup(Cup *cup, const Cup *cup_team, GPtrArray *teams, const CupChooseTeam *ct);
|
cup_load_choose_team_from_cup(Cup *cup, const Cup *cup_team, GPtrArray *teams, const CupChooseTeam *ct);
|
||||||
|
|
||||||
gint
|
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
|
gint
|
||||||
cup_get_matchdays_in_cup_round(const Cup *cup, gint round);
|
cup_get_matchdays_in_cup_round(const Cup *cup, gint round);
|
||||||
|
|
|
@ -512,7 +512,7 @@ fixture_write_round_robin(gpointer league_cup, gint cup_round,
|
||||||
{
|
{
|
||||||
cup = (Cup*)league_cup;
|
cup = (Cup*)league_cup;
|
||||||
if(first_week == -1)
|
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;
|
week_gap = cup->week_gap;
|
||||||
fixtures = cup->fixtures;
|
fixtures = cup->fixtures;
|
||||||
two_match_weeks = g_array_index(cup->rounds, CupRound, cup_round).two_match_weeks;
|
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
|
#endif
|
||||||
|
|
||||||
gint i, len = teams->len;
|
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;
|
gint week_number, week_round_number;
|
||||||
CupRound *round = &g_array_index(cup->rounds, CupRound, cup_round);
|
CupRound *round = &g_array_index(cup->rounds, CupRound, cup_round);
|
||||||
gint bye_len = (round->byes == -1) ?
|
gint bye_len = (round->byes == -1) ?
|
||||||
|
|
Loading…
Reference in New Issue