mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-01-08 21:22:39 +01:00
Reset all cups at the beginning of each season
This fixes a bug in league fixture scheduling where league matches would be scheduled around cup matches from the previous season. This caused league matches to be scheduled in later week rounds which in some cases caused these matches to not be played.
This commit is contained in:
parent
4ee618fadf
commit
3e4ead3aae
16
src/cup.c
16
src/cup.c
@ -440,7 +440,7 @@ cup_load_choose_team_from_cup(Cup *cup, const Cup *cup_temp, GPtrArray *teams, c
|
||||
/* Self-referential cup or no? */
|
||||
cup_teams_sorted = (cup == cup_temp) ?
|
||||
cup_get_last_season_results(cup) :
|
||||
cup_get_teams_sorted(cup_temp);
|
||||
cup_get_most_recent_results(cup_temp);
|
||||
|
||||
start = cup_choose_team_compute_start_idx(ct);
|
||||
end = cup_choose_team_compute_end_idx(ct, cup_teams_sorted->len) + 1;
|
||||
@ -1430,3 +1430,17 @@ cup_get_last_season_results(const Cup *cup)
|
||||
{
|
||||
return g_ptr_array_index(cup->history, cup->history->len - 1);
|
||||
}
|
||||
|
||||
/** @return The most recent cup results. If the cup has no fixtures scheduled
|
||||
* for this year, this function returns last year's results. If it does have
|
||||
* fixtures schedule then this year's results are returned (even if the cup
|
||||
* is not complete yet). The caller is responsible for freeing the returned
|
||||
* GPtrArray.
|
||||
*/
|
||||
GPtrArray *
|
||||
cup_get_most_recent_results(const Cup *cup)
|
||||
{
|
||||
if (cup->fixtures->len == 0)
|
||||
return misc_copy_ptr_array(cup_get_last_season_results(cup));
|
||||
return cup_get_teams_sorted(cup);
|
||||
}
|
||||
|
@ -148,4 +148,7 @@ query_cup_hidden(const Cup *cup);
|
||||
GPtrArray *
|
||||
cup_get_last_season_results(const Cup *cup);
|
||||
|
||||
GPtrArray *
|
||||
cup_get_most_recent_results(const Cup *cup);
|
||||
|
||||
#endif
|
||||
|
@ -1206,7 +1206,7 @@ league_get_team_movements(League *league, GArray *team_movements)
|
||||
{
|
||||
prom_cup = cup_from_sid(g_array_index(league->prom_rel.prom_games, PromGames, i).cup_sid);
|
||||
|
||||
prom_games_teams = cup_get_teams_sorted(prom_cup);
|
||||
prom_games_teams = cup_get_most_recent_results(prom_cup);
|
||||
|
||||
league_get_team_movements_prom_games(league, &g_array_index(league->prom_rel.prom_games, PromGames, i),
|
||||
team_movements, prom_games_teams, TRUE);
|
||||
|
@ -168,13 +168,18 @@ start_new_season(void)
|
||||
g_ptr_array_remove_index(acps, i);
|
||||
}
|
||||
|
||||
/* Deal with cups that have to take place before promotion/relegation. */
|
||||
for(i=cps->len - 1; i >= 0; i--)
|
||||
if(cp(i).add_week == -1) {
|
||||
/* Reset cup to save its history. */
|
||||
cup_reset(&cp(i));
|
||||
for(i=cps->len - 1; i >= 0; i--) {
|
||||
/* Reset all cups. We need to make sure all cups get reset
|
||||
* before the start of the next season. Otherwise, the fixtures
|
||||
* from last year's cup will interfere with scheduling the league
|
||||
* fixtures. Also, cup_reset() saves this season's results in the
|
||||
* history list. */
|
||||
cup_reset(&cp(i));
|
||||
|
||||
/* Deal with cups that have to take place before promotion/relegation. */
|
||||
if(cp(i).add_week == -1)
|
||||
fixture_write_cup_fixtures(&cp(i));
|
||||
}
|
||||
}
|
||||
|
||||
if(season > 1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user