mirror of https://github.com/tstellar/bygfoot.git
Remove team_id member from TableElement
This is no longer needed now that Team pointers always point to the same team.
This commit is contained in:
parent
47b6d5c80d
commit
801cb99b74
17
src/cup.c
17
src/cup.c
|
@ -497,8 +497,7 @@ cup_load_choose_team_from_league(Cup *cup, const League *league,
|
|||
{
|
||||
for(j=0;j<table->elements->len;j++)
|
||||
{
|
||||
Team *team = team_of_id(
|
||||
g_array_index(table->elements, TableElement, j).team_id);
|
||||
Team *team = g_array_index(table->elements, TableElement, j).team;
|
||||
if (team_is_reserve_team(team) &&
|
||||
!query_league_cup_has_property(cup->id, "include_reserve_teams"))
|
||||
continue;
|
||||
|
@ -520,18 +519,18 @@ cup_load_choose_team_from_league(Cup *cup, const League *league,
|
|||
|
||||
for(j = 0; j < end; j++)
|
||||
{
|
||||
Team *team = team_of_id(g_array_index(table->elements, TableElement, order[j]).team_id);
|
||||
Team *team = g_array_index(table->elements, TableElement, order[j]).team;
|
||||
if (team_is_reserve_team(team) &&
|
||||
!query_league_cup_has_property(cup->id, "include_reserve_teams"))
|
||||
continue;
|
||||
if(debug > 80)
|
||||
g_print("j %d order %d team %s isinint %d numteams %d\n",
|
||||
j, order[j],
|
||||
team_of_id(g_array_index(table->elements,
|
||||
TableElement, order[j]).team_id)->name,
|
||||
g_array_index(table->elements,
|
||||
TableElement, order[j]).team->name,
|
||||
query_team_is_in_cups(
|
||||
team_of_id(g_array_index(table->elements,
|
||||
TableElement, order[j]).team_id),
|
||||
g_array_index(table->elements,
|
||||
TableElement, order[j]).team,
|
||||
cup->group),
|
||||
number_of_teams);
|
||||
|
||||
|
@ -853,9 +852,9 @@ cup_compare_success_tables(const Team *tm1, const Team *tm2, const Cup *cup, gin
|
|||
{
|
||||
for(i=0;i<cupround->tables->len;i++)
|
||||
for(j=0;j<g_array_index(cupround->tables, Table, i).elements->len;j++)
|
||||
if(g_array_index(g_array_index(cupround->tables, Table, i).elements, TableElement, j).team_id == tm1->id)
|
||||
if(g_array_index(g_array_index(cupround->tables, Table, i).elements, TableElement, j).team == tm1)
|
||||
elem1 = &g_array_index(g_array_index(cupround->tables, Table, i).elements, TableElement, j);
|
||||
else if(g_array_index(g_array_index(cupround->tables, Table, i).elements, TableElement, j).team_id == tm2->id)
|
||||
else if(g_array_index(g_array_index(cupround->tables, Table, i).elements, TableElement, j).team == tm2)
|
||||
elem2 = &g_array_index(g_array_index(cupround->tables, Table, i).elements, TableElement, j);
|
||||
|
||||
return_value = table_element_compare_func(elem1, elem2, GINT_TO_POINTER(cup->id));
|
||||
|
|
|
@ -1447,7 +1447,6 @@ bygfoot_json_serialize_table_element(const TableElement *element)
|
|||
SERIALIZE_OBJECT_FIELD(element_obj, element, field, serialize_func);
|
||||
|
||||
SERIALIZE(team, bygfoot_json_serialize_team_ptr);
|
||||
SERIALIZE(team_id, json_object_new_int64);
|
||||
SERIALIZE(old_rank, json_object_new_int64);
|
||||
json_object_object_add(element_obj, "played",
|
||||
json_object_new_int64(element->values[TABLE_PLAYED]));
|
||||
|
|
|
@ -527,8 +527,7 @@ league_season_start(League *league)
|
|||
gint idx = league_index_from_sid(league->sid);
|
||||
gboolean user_champ =
|
||||
(team_is_user(
|
||||
team_of_id(
|
||||
g_array_index(league_table((&lig(0)))->elements, TableElement, 0).team_id)) != -1);
|
||||
g_array_index(league_table((&lig(0)))->elements, TableElement, 0).team) != -1);
|
||||
gboolean league_above_talent =
|
||||
(team_get_average_talents(league->teams) > league->average_talent *
|
||||
const_float("float_season_end_league_above_talent_factor") && !user_champ);
|
||||
|
@ -551,8 +550,7 @@ league_season_start(League *league)
|
|||
|
||||
if(user_champ)
|
||||
{
|
||||
tm = team_of_id(
|
||||
g_array_index(league_table((&lig(0)))->elements, TableElement, 0).team_id);
|
||||
tm = g_array_index(league_table((&lig(0)))->elements, TableElement, 0).team;
|
||||
tm->luck = MAX(tm->luck * const_float("float_season_end_user_champ_luck_factor"),
|
||||
const_float("float_luck_limit"));
|
||||
}
|
||||
|
|
14
src/table.c
14
src/table.c
|
@ -63,7 +63,6 @@ table_element_new(Team *team, gint old_rank)
|
|||
TableElement new;
|
||||
|
||||
new.team = team;
|
||||
new.team_id = team->id;
|
||||
new.old_rank = old_rank;
|
||||
|
||||
for(i=0;i<TABLE_END;i++)
|
||||
|
@ -204,7 +203,7 @@ table_element_compare_func(gconstpointer a,
|
|||
GArray *fixtures;
|
||||
const Fixture *fix[2] = {NULL, NULL};
|
||||
|
||||
if(element1->team_id == element2->team_id)
|
||||
if(element1->team == element2->team)
|
||||
return 0;
|
||||
|
||||
clid = GPOINTER_TO_INT(clid_pointer);
|
||||
|
@ -234,11 +233,11 @@ table_element_compare_func(gconstpointer a,
|
|||
g_array_index(fixtures, Fixture, i).week_number <= week &&
|
||||
g_array_index(fixtures, Fixture, i).week_round_number <= week_round)
|
||||
{
|
||||
if(g_array_index(fixtures, Fixture, i).team_ids[0] == element1->team_id &&
|
||||
g_array_index(fixtures, Fixture, i).team_ids[1] == element2->team_id)
|
||||
if(g_array_index(fixtures, Fixture, i).team_ids[0] == element1->team->id &&
|
||||
g_array_index(fixtures, Fixture, i).team_ids[1] == element2->team->id)
|
||||
fix[0] = &g_array_index(fixtures, Fixture, i);
|
||||
else if(g_array_index(fixtures, Fixture, i).team_ids[1] == element1->team_id &&
|
||||
g_array_index(fixtures, Fixture, i).team_ids[0] == element2->team_id)
|
||||
else if(g_array_index(fixtures, Fixture, i).team_ids[1] == element1->team->id &&
|
||||
g_array_index(fixtures, Fixture, i).team_ids[0] == element2->team->id)
|
||||
fix[1] = &g_array_index(fixtures, Fixture, i);
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +306,6 @@ table_copy(const Table *table)
|
|||
{
|
||||
elem = &g_array_index(table->elements, TableElement, i);
|
||||
new_table_element.team = elem->team;
|
||||
new_table_element.team_id = elem->team_id;
|
||||
new_table_element.old_rank = elem->old_rank;
|
||||
|
||||
for(j=0;j<TABLE_END;j++)
|
||||
|
@ -327,5 +325,5 @@ table_refresh_team_pointers(Table *table)
|
|||
|
||||
for(i = 0; i < table->elements->len; i++)
|
||||
g_array_index(table->elements, TableElement, i).team =
|
||||
team_of_id(g_array_index(table->elements, TableElement, i).team_id);
|
||||
team_of_id(GPOINTER_TO_INT(g_array_index(table->elements, TableElement, i).team));
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ enum TableElementValues
|
|||
typedef struct
|
||||
{
|
||||
Team *team;
|
||||
gint team_id;
|
||||
/** The rank of the element before the last update.
|
||||
Used to display an arrow if the rank changed. */
|
||||
gint old_rank;
|
||||
|
|
|
@ -524,7 +524,7 @@ team_get_league_rank(const Team *tm, gint clid)
|
|||
}
|
||||
|
||||
for(i=0;i<elements->len;i++)
|
||||
if(g_array_index(elements, TableElement, i).team_id == tm->id)
|
||||
if(g_array_index(elements, TableElement, i).team == tm)
|
||||
return i + 1;
|
||||
|
||||
main_exit_program(EXIT_INT_NOT_FOUND,
|
||||
|
@ -548,7 +548,7 @@ team_get_cup_rank(const Team *tm, const CupRound *cupround, gboolean abort)
|
|||
for(i=0;i<cupround->tables->len;i++)
|
||||
{
|
||||
for(j=0;j<g_array_index(cupround->tables, Table, i).elements->len;j++)
|
||||
if(g_array_index(g_array_index(cupround->tables, Table, i).elements, TableElement, j).team_id == tm->id)
|
||||
if(g_array_index(g_array_index(cupround->tables, Table, i).elements, TableElement, j).team == tm)
|
||||
return j + 1;
|
||||
}
|
||||
|
||||
|
@ -823,7 +823,7 @@ team_get_table_value(const Team *tm, gint type)
|
|||
elements = league_table(league_from_clid(tm->clid))->elements;
|
||||
|
||||
for(i=0;i<elements->len;i++)
|
||||
if(g_array_index(elements, TableElement, i).team_id == tm->id)
|
||||
if(g_array_index(elements, TableElement, i).team == tm)
|
||||
break;
|
||||
|
||||
if(i == elements->len)
|
||||
|
|
|
@ -140,7 +140,7 @@ xml_loadsave_table_text (GMarkupParseContext *context,
|
|||
else if(state == TAG_ROUND)
|
||||
new_table->round = int_value;
|
||||
else if(state == TAG_TEAM_ID)
|
||||
new_element.team_id = int_value;
|
||||
new_element.team = GINT_TO_POINTER(int_value);
|
||||
else if(state == TAG_TABLE_ELEMENT_VALUE)
|
||||
new_element.values[valueidx] = int_value;
|
||||
else if(state == TAG_TABLE_ELEMENT_OLD_RANK)
|
||||
|
|
Loading…
Reference in New Issue