the default team was restored even if no match was played

This commit is contained in:
gunnar_g 2011-05-19 19:26:11 +00:00
parent 5c207bf284
commit cd4a2283d7
1 changed files with 407 additions and 376 deletions

View File

@ -56,29 +56,41 @@ callback_show_next_live_game(void)
gint i, j;
gint user_team_involved;
GArray *user_teams_played;
user_teams_played = g_array_new (FALSE, FALSE, sizeof (gint));
for(i=0;i<users->len;i++) {
for(i=0; i<users->len; i++)
{
usr(i).counters[COUNT_USER_TOOK_TURN] = 0;
}
counters[COUNT_NEWS_SHOWN] =
counters[COUNT_NEW_NEWS] = 0;
for(i=0;i<ligs->len;i++) {
for(j=0;j<lig(i).fixtures->len;j++) {
for(i=0; i<ligs->len; i++)
{
for(j=0; j<lig(i).fixtures->len; j++)
{
user_team_involved = fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j));
if(g_array_index(lig(i).fixtures, Fixture, j).week_number == week &&
g_array_index(lig(i).fixtures, Fixture, j).week_round_number == week_round &&
fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j)) != -1 &&
g_array_index(lig(i).fixtures, Fixture, j).attendance == -1 ) {
fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j)) != -1)
{
// Add user teams that played
g_array_append_val(user_teams_played, user_team_involved);
if(g_array_index(lig(i).fixtures, Fixture, j).attendance == -1 )
{
// Store the player order before the live match: get the team that is involved, if it's a user team
// and that user has the option to always store the default team checked, store it
if (option_int("int_opt_user_store_restore_default_team", &usr(user_team_involved).options)) {
if (option_int("int_opt_user_store_restore_default_team", &usr(user_team_involved).options))
{
store_default_team(&usr(user_team_involved));
}
if (option_int("int_opt_user_show_live_game",
&usr(fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j))).
options)) {
options))
{
live_game_calculate_fixture(&g_array_index(lig(i).fixtures, Fixture, j),
&usr(fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j))).live_game);
return;
@ -86,23 +98,33 @@ callback_show_next_live_game(void)
}
}
}
}
for(i=0;i<acps->len;i++) {
for(j=0;j<acp(i)->fixtures->len;j++) {
for(i=0; i<acps->len; i++)
{
for(j=0; j<acp(i)->fixtures->len; j++)
{
user_team_involved = fixture_user_team_involved(&g_array_index(acp(i)->fixtures, Fixture, j));
if(g_array_index(acp(i)->fixtures, Fixture, j).week_number == week &&
g_array_index(acp(i)->fixtures, Fixture, j).week_round_number == week_round &&
fixture_user_team_involved(&g_array_index(acp(i)->fixtures, Fixture, j)) != -1 &&
g_array_index(acp(i)->fixtures, Fixture, j).attendance == -1)
fixture_user_team_involved(&g_array_index(acp(i)->fixtures, Fixture, j)) != -1)
{
// Add user teams that played
g_array_append_val(user_teams_played, user_team_involved);
if (g_array_index(acp(i)->fixtures, Fixture, j).attendance == -1)
{
// Store the player order before the live match: get the team that is involved, if it's a user team
// and that user has the option to always store the default team checked, store it
if (option_int("int_opt_user_store_restore_default_team", &usr(user_team_involved).options)) {
if (option_int("int_opt_user_store_restore_default_team", &usr(user_team_involved).options))
{
store_default_team(&usr(user_team_involved));
}
if (option_int("int_opt_user_show_live_game",
&usr(fixture_user_team_involved(&g_array_index(acp(i)->fixtures, Fixture, j))).
options)) {
options))
{
live_game_calculate_fixture(&g_array_index(acp(i)->fixtures, Fixture, j),
&usr(fixture_user_team_involved(&g_array_index(acp(i)->fixtures, Fixture, j))).live_game);
return;
@ -110,16 +132,23 @@ callback_show_next_live_game(void)
}
}
}
}
window_destroy(&window.live);
// Restore the default team of all user teams that played
gint user_team_to_restore;
/* Restore the player_order as it was before the match */
for(i=0;i<users->len;i++) {
if (usr(i).default_team->len!=0 && option_int("int_opt_user_store_restore_default_team",
&usr(i).options)) {
restore_default_team(&usr(i));
for(i=0; i<user_teams_played->len; i++)
{
user_team_to_restore = g_array_index (user_teams_played, gint, i);
if (usr(user_team_to_restore).default_team->len!=0 && option_int("int_opt_user_store_restore_default_team",
&usr(user_team_to_restore).options))
{
restore_default_team(&usr(user_team_to_restore));
}
}
g_array_free (user_teams_played, TRUE);
treeview_show_user_player_list();
/* no more user games to show: end round. */
end_week_round();
@ -946,3 +975,5 @@ callback_show_youth_academy(void)
player_get_pointers_from_array(current_user.youth_academy.players),
attributes, FALSE, FALSE);
}