We know generate cup results for each cup before starting the game.
This allows cups to select last year's winner without having to
special case cup selection for the first season.
If the main team was in the user's country and the alternative was not,
the choose team would fail, because there are different paths for
the user's country and other countries.
This patch merges both paths into cup_load_choose_team() so that
function will work for any country.
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 allows us to have stable Team pointers throughout the game,
so we don't need to recompute pointers from Team IDs every time
the league order changes.
This way strategy_live_game_check() only needs to evaluate the condition
and does not need to reparse it over and over again.
This reduces the number of instructions reported by
./test/benchmark.sh --benchmark by ~35%.
team_get_fixture() is expensive and we can avoid this call in the
majority of cases.
This reduces the number of instructions reported by
./test/benchmark.sh --benchmark by ~40%.
The function incorrectly assumed that cups where all the scheduled games
had been played wre complete, and did not take into account the fact
that games for later rounds may not have been scheduled yet.
This allows you to specify an alternative choose_team in the case the
first choose_team does not match any teams. This can happen if a team
qualifies for another cup in the same cup group. You may list an
unlimited number of alternatives with this new tag. Here is an example of
how to use it:
<choose_team>
<choose_team_sid>faroe_islands_cup</choose_team_sid>
<number_of_teams>1</number_of_teams>
<start_idx>1</start_idx>
<end_idx>1</end_idx>
<alternatives>
<choose_team>
<choose_team_sid>faroe_islands1</choose_team_sid>
<number_of_teams>1</number_of_teams>
<start_idx>1</start_idx>
<end_idx>1</end_idx>
</choose_team>
</alternatives>
</choose_team>
This example chooses the winner of the faroe_islands_cup, but if that
team is not eligible for the cup, then it will choose the winner of the
faroe_islands1 league.