Allow optional tag to be used when selecting teams from cups

This fixes a segfault caused by the uefa_el definitions when there
aren't enough teams in uefa_cl to fill all the spots in the choose_team
definition.
This commit is contained in:
Tom Stellard 2021-07-07 10:29:16 -07:00 committed by Tom Stellard
parent b126786553
commit 4d4d73caa0
2 changed files with 9 additions and 1 deletions

View File

@ -444,7 +444,7 @@ cup_load_choose_team_from_cup(Cup *cup, const Cup *cup_temp, GPtrArray *teams, G
start = cup_choose_team_compute_start_idx(ct);
end = cup_choose_team_compute_end_idx(ct, cup_teams_sorted->len) + 1;
for(i = start; i < end; i++)
for(i = start; i < end && i < cup_teams_sorted->len; i++)
{
if(ct->skip_group_check ||
!query_team_is_in_cups(
@ -467,6 +467,8 @@ cup_load_choose_team_from_cup(Cup *cup, const Cup *cup_temp, GPtrArray *teams, G
number_of_teams != ct->number_of_teams) {
if (ct->next)
return cup_load_choose_team(cup, teams, teams_sorted, ct->next);
if (ct->optional)
return;
main_exit_program(EXIT_CHOOSE_TEAM_ERROR,
"cup_load_choose_team_from_cup (3): not enough teams (that don't participate in international cups yet) found in chooseteam %s for cup %s (%d specified, %d found) cup group %d.\n ",
ct->sid, cup->name,

View File

@ -1221,6 +1221,12 @@
<number_of_teams>3</number_of_teams>
<start_idx>9</start_idx>
<end_idx>11</end_idx>
<!-- It's possible for there to be less than 3 losers if one
of the teams that is supposed to play in that round
qualifies for Champions League by being the previous
year's winner.
-->
<optional>1</optional>
</choose_team>
#UEFA Ranking 17