Refactor cup_load_choose_team_generate()

This commit is contained in:
Tom Stellard 2021-02-05 21:05:16 -08:00 committed by Tom Stellard
parent 4248c08b7a
commit f56e1b64be
1 changed files with 11 additions and 10 deletions

View File

@ -573,24 +573,25 @@ cup_load_choose_team_generate(Cup *cup, CupRound *cup_round, const CupChooseTeam
for(j=0;j<sids->len;j++) for(j=0;j<sids->len;j++)
{ {
if(!query_cup_choose_team_is_league((gchar*)g_ptr_array_index(sids, j))) const gchar *sid = g_ptr_array_index(sids, j);
if(!query_cup_choose_team_is_league(sid))
{ {
xml_league_read((gchar*)g_ptr_array_index(sids, j), leagues); League *league;
xml_league_read(sid, leagues);
league = &g_array_index(leagues, League, leagues->len -1);
for(k=0; k < g_array_index(leagues, League, leagues->len - 1).teams->len; k++) for(k=0; k < league->teams->len; k++)
{ {
Team *team = &g_array_index(league->teams, Team, k);
if(query_league_cup_has_property(cup->id, "league_talents")) if(query_league_cup_has_property(cup->id, "league_talents"))
{ {
g_array_index( team->average_talent = league->average_talent;
g_array_index(leagues, League, leagues->len - 1).teams, Team, k).average_talent =
g_array_index(leagues, League, leagues->len - 1).average_talent;
} }
g_array_append_val(teams_local, g_array_index( g_array_append_val(teams_local, *team);
g_array_index(leagues, League, leagues->len - 1).teams, Team, k));
} }
free_g_array(&g_array_index(leagues, League, leagues->len - 1).teams); free_g_array(&league->teams);
free_league(&g_array_index(leagues, League, leagues->len - 1)); free_league(league);
} }
} }