diff --git a/src/callback_func.c b/src/callback_func.c index b4eb5abd..ec15332f 100644 --- a/src/callback_func.c +++ b/src/callback_func.c @@ -56,70 +56,99 @@ 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;ilen;i++) { - usr(i).counters[COUNT_USER_TOOK_TURN] = 0; + for(i=0; ilen; i++) + { + usr(i).counters[COUNT_USER_TOOK_TURN] = 0; } - counters[COUNT_NEWS_SHOWN] = + counters[COUNT_NEWS_SHOWN] = counters[COUNT_NEW_NEWS] = 0; - for(i=0;ilen;i++) { - for(j=0;jlen;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 ) { - // 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)) { - store_default_team(&usr(user_team_involved)); + for(i=0; ilen; i++) + { + for(j=0; jlen; 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) + { + // 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)) + { + 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)) + { + 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; + } } - if (option_int("int_opt_user_show_live_game", - &usr(fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j))). - 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; - } - } + } } } - for(i=0;ilen;i++) { - for(j=0;jfixtures->len;j++) { + for(i=0; ilen; i++) + { + for(j=0; jfixtures->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) - { - // 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)) { - store_default_team(&usr(user_team_involved)); + 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) + { + // 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)) + { + 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)) + { + 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; + } } - if (option_int("int_opt_user_show_live_game", - &usr(fixture_user_team_involved(&g_array_index(acp(i)->fixtures, Fixture, j))). - 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; - } - } + } } } 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;ilen;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; ilen; 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(); @@ -139,47 +168,47 @@ callback_player_activate(gint idx) if(stat0 == STATUS_SHOW_TRANSFER_LIST) { - selected_row = -1; - transfer_add_remove_user_player(player_of_idx_team(current_user.tm, idx)); + selected_row = -1; + transfer_add_remove_user_player(player_of_idx_team(current_user.tm, idx)); } else if(stat0 == STATUS_SHOW_YA) { - selected_row = idx; - on_menu_move_to_youth_academy_activate(NULL, NULL); + selected_row = idx; + on_menu_move_to_youth_academy_activate(NULL, NULL); } else if(gtk_notebook_get_current_page( GTK_NOTEBOOK(lookup_widget(window.main, "notebook_player"))) == 1) { selected_row = idx; - return; + return; } else { - if(selected_row == -1) - { - selected_row = idx; - return; - } + if(selected_row == -1) + { + selected_row = idx; + return; + } - player_swap(current_user.tm, selected_row, - current_user.tm, idx); + player_swap(current_user.tm, selected_row, + current_user.tm, idx); - if(opt_user_int("int_opt_user_swap_adapts") == 1 && - current_user.tm->structure != - team_find_appropriate_structure(current_user.tm)) - { - team_change_structure(current_user.tm, - team_find_appropriate_structure(current_user.tm)); - team_rearrange(current_user.tm); - } + if(opt_user_int("int_opt_user_swap_adapts") == 1 && + current_user.tm->structure != + team_find_appropriate_structure(current_user.tm)) + { + team_change_structure(current_user.tm, + team_find_appropriate_structure(current_user.tm)); + team_rearrange(current_user.tm); + } - game_gui_write_av_skills(NULL); + game_gui_write_av_skills(NULL); - selected_row = -1; + selected_row = -1; - treeview_show_user_player_list(); - if(stat0 == STATUS_MAIN) - treeview_show_next_opponent(); + treeview_show_user_player_list(); + if(stat0 == STATUS_MAIN) + treeview_show_next_opponent(); } } @@ -196,20 +225,20 @@ callback_player_clicked(gint idx, GdkEventButton *event) /* Only accept single-clicks right now. */ if(event->type != GDK_BUTTON_PRESS) - return; + return; if(event->button == 1) - callback_player_activate(idx); + callback_player_activate(idx); else if(event->button == 3) { - selected_row = idx; - window_show_menu_player((GdkEvent*)event); + selected_row = idx; + window_show_menu_player((GdkEvent*)event); } setsav0; } -/** Show the last match of the current user. +/** Show the last match of the current user. @param start Whether we start the replay from the beginning or continue it. */ void callback_show_last_match(gboolean start, LiveGame *lg) @@ -224,46 +253,46 @@ callback_show_last_match(gboolean start, LiveGame *lg) if(start) { - stat2 = cur_user; - statp = lg; + stat2 = cur_user; + statp = lg; - window_create(WINDOW_LIVE); + window_create(WINDOW_LIVE); - gui_set_sensitive_lg_meters(FALSE); + gui_set_sensitive_lg_meters(FALSE); - treeview_show_game_stats( - GTK_TREE_VIEW(lookup_widget(window.live, "treeview_stats")), lg); + treeview_show_game_stats( + GTK_TREE_VIEW(lookup_widget(window.live, "treeview_stats")), lg); } else { - gtk_widget_set_sensitive(lookup_widget(window.live, "button_pause"), TRUE); - gtk_widget_set_sensitive(lookup_widget(window.live, "button_resume"), FALSE); + gtk_widget_set_sensitive(lookup_widget(window.live, "button_pause"), TRUE); + gtk_widget_set_sensitive(lookup_widget(window.live, "button_resume"), FALSE); } - for(i=stat3;iunits->len;i++) + for(i=stat3; iunits->len; i++) { - game_gui_live_game_show_unit(&g_array_index(lg->units, LiveGameUnit, i)); + game_gui_live_game_show_unit(&g_array_index(lg->units, LiveGameUnit, i)); - if(stat4 == STATUS_SHOW_LAST_MATCH_PAUSE || - stat4 == STATUS_SHOW_LAST_MATCH_ABORT) - { - stat3 = i + 1; - break; - } + if(stat4 == STATUS_SHOW_LAST_MATCH_PAUSE || + stat4 == STATUS_SHOW_LAST_MATCH_ABORT) + { + stat3 = i + 1; + break; + } } if(stat4 == STATUS_SHOW_LAST_MATCH_PAUSE) { - gtk_widget_set_sensitive(lookup_widget(window.live, "button_pause"), FALSE); - gtk_widget_set_sensitive(lookup_widget(window.live, "button_resume"), TRUE); + gtk_widget_set_sensitive(lookup_widget(window.live, "button_pause"), FALSE); + gtk_widget_set_sensitive(lookup_widget(window.live, "button_resume"), TRUE); } else if(stat4 == STATUS_SHOW_LAST_MATCH_ABORT) { - window_destroy(&window.live); - stat1 = stat2 = stat3 = stat4 = -1; + window_destroy(&window.live); + stat1 = stat2 = stat3 = stat4 = -1; } else - stat3 = -1; + stat3 = -1; } /** Show the last match stats of the current user. */ @@ -274,11 +303,11 @@ callback_show_last_match_stats(void) printf("callback_show_last_match_stats\n"); #endif - current_user.live_game.fix = - fixture_from_id(current_user.live_game.fix_id, TRUE); - + current_user.live_game.fix = + fixture_from_id(current_user.live_game.fix_id, TRUE); + treeview_show_game_stats(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")), - ¤t_user.live_game); + ¤t_user.live_game); } /** Show fixtures by week and round (as opposed to @@ -293,33 +322,33 @@ callback_show_fixtures_week(gint type) switch(type) { - default: - debug_print_message("callback_show_fixtures_week: unknown type %d \n", type); - return; - break; - case SHOW_CURRENT: - if(week == 1 && week_round == 1) - { - stat1 = week; - stat2 = week_round; - } - else if(week_round == 1) - { - stat1 = week - 1; - stat2 = fixture_get_last_week_round(week - 1); - } - else - { - stat1 = week; - stat2 = week_round - 1; - } - break; - case SHOW_NEXT: - fixture_get_next_week(&stat1, &stat2); - break; - case SHOW_PREVIOUS: - fixture_get_previous_week(&stat1, &stat2); - break; + default: + debug_print_message("callback_show_fixtures_week: unknown type %d \n", type); + return; + break; + case SHOW_CURRENT: + if(week == 1 && week_round == 1) + { + stat1 = week; + stat2 = week_round; + } + else if(week_round == 1) + { + stat1 = week - 1; + stat2 = fixture_get_last_week_round(week - 1); + } + else + { + stat1 = week; + stat2 = week_round - 1; + } + break; + case SHOW_NEXT: + fixture_get_next_week(&stat1, &stat2); + break; + case SHOW_PREVIOUS: + fixture_get_previous_week(&stat1, &stat2); + break; } treeview_show_fixtures_week(stat1, stat2); @@ -336,10 +365,10 @@ callback_show_fixtures(gint type) #endif const Fixture *fix = fixture_get(type, stat1, stat2, stat3, - current_user.tm); + current_user.tm); treeview_show_fixtures(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")), - fix->clid, fix->week_number, fix->week_round_number); + fix->clid, fix->week_number, fix->week_round_number); stat1 = fix->clid; stat2 = fix->week_number; stat3 = fix->week_round_number; @@ -358,30 +387,30 @@ callback_show_tables(gint type) gint clid = -1; if(type == SHOW_CURRENT) - clid = stat1; + clid = stat1; else if(type == SHOW_NEXT_LEAGUE) - clid = league_cup_get_next_clid(stat1, FALSE); + clid = league_cup_get_next_clid(stat1, FALSE); else if(type == SHOW_PREVIOUS_LEAGUE) - clid = league_cup_get_previous_clid(stat1, FALSE); + clid = league_cup_get_previous_clid(stat1, FALSE); else { - debug_print_message("callback_show_tables: unknown type %d \n", type); - return; + debug_print_message("callback_show_tables: unknown type %d \n", type); + return; } while((clid < ID_CUP_START && !query_league_active(league_from_clid(clid))) || - (clid >= ID_CUP_START && cup_has_tables(clid) == -1)) + (clid >= ID_CUP_START && cup_has_tables(clid) == -1)) { - if(type == SHOW_PREVIOUS_LEAGUE) - clid = league_cup_get_previous_clid(clid, FALSE); - else - clid = league_cup_get_next_clid(clid, FALSE); + if(type == SHOW_PREVIOUS_LEAGUE) + clid = league_cup_get_previous_clid(clid, FALSE); + else + clid = league_cup_get_next_clid(clid, FALSE); } stat1 = clid; - treeview_show_table(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")), - clid); + treeview_show_table(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")), + clid); } /** Open the digits window to get a loan. */ @@ -393,13 +422,13 @@ callback_get_loan(void) #endif gchar buf[SMALL], buf2[SMALL]; - gint max_loan = - finance_team_drawing_credit_loan(current_user.tm, TRUE) + current_user.debt; + gint max_loan = + finance_team_drawing_credit_loan(current_user.tm, TRUE) + current_user.debt; if(max_loan <= 0) { - game_gui_print_message(_("The bank doesn't grant you more money.")); - return; + game_gui_print_message(_("The bank doesn't grant you more money.")); + return; } stat1 = STATUS_GET_LOAN; @@ -422,14 +451,14 @@ callback_pay_loan(void) if(current_user.debt == 0) { - game_gui_print_message(_("You are not indebted.")); - return; + game_gui_print_message(_("You are not indebted.")); + return; } if(max_payback <= 0) { - game_gui_print_message(_("You don't have enough money to pay back.")); - return; + game_gui_print_message(_("You don't have enough money to pay back.")); + return; } stat1 = STATUS_PAY_LOAN; @@ -451,43 +480,43 @@ callback_transfer_list_user(gint button, gint idx) #endif gchar buf[SMALL], - buf2[SMALL], buf3[SMALL]; + buf2[SMALL], buf3[SMALL]; - if(button == 3 || - (button == 1 && trans(idx).offers->len == 0)) + if(button == 3 || + (button == 1 && trans(idx).offers->len == 0)) { - transfer_remove_player(idx); - on_button_transfers_clicked(NULL, NULL); - setsav0; + transfer_remove_player(idx); + on_button_transfers_clicked(NULL, NULL); + setsav0; } else if(button == 1) { - if(trans(idx).offers->len > 0 && - transoff(idx, 0).status != TRANSFER_OFFER_ACCEPTED) - game_gui_print_message(_("There are some offers for the player which you rejected or will see next week.")); - else - { - misc_print_grouped_int(transoff(idx, 0).fee, buf2); - misc_print_grouped_int(ABS(transoff(idx, 0).fee - - player_of_id_team(current_user.tm, - trans(idx).id)->value), buf3); - if(transoff(idx, 0).fee - - player_of_id_team(current_user.tm, trans(idx).id)->value > 0) - strcat(buf3, _(" more")); - else - strcat(buf3, _(" less")); - - sprintf(buf, _("%s would like to buy %s. They offer %s for him, which is %s than the player's value. Do you accept?"), transoff(idx, 0).tm->name, - player_of_id_team(current_user.tm, trans(idx).id)->name, - buf2, buf3); - stat1 = STATUS_TRANSFER_OFFER_USER; - stat2 = idx; - window_show_transfer_dialog(buf); - } + if(trans(idx).offers->len > 0 && + transoff(idx, 0).status != TRANSFER_OFFER_ACCEPTED) + game_gui_print_message(_("There are some offers for the player which you rejected or will see next week.")); + else + { + misc_print_grouped_int(transoff(idx, 0).fee, buf2); + misc_print_grouped_int(ABS(transoff(idx, 0).fee - + player_of_id_team(current_user.tm, + trans(idx).id)->value), buf3); + if(transoff(idx, 0).fee - + player_of_id_team(current_user.tm, trans(idx).id)->value > 0) + strcat(buf3, _(" more")); + else + strcat(buf3, _(" less")); + + sprintf(buf, _("%s would like to buy %s. They offer %s for him, which is %s than the player's value. Do you accept?"), transoff(idx, 0).tm->name, + player_of_id_team(current_user.tm, trans(idx).id)->name, + buf2, buf3); + stat1 = STATUS_TRANSFER_OFFER_USER; + stat2 = idx; + window_show_transfer_dialog(buf); + } } } -/** Handle a click on a cpu player for which the offer +/** Handle a click on a cpu player for which the offer got accepted. */ void callback_transfer_list_cpu(gint button, gint idx) @@ -499,36 +528,36 @@ callback_transfer_list_cpu(gint button, gint idx) gchar buf[SMALL], buf2[SMALL], buf3[SMALL]; if(button == 2) - return; + return; if(button == 3) { - g_array_remove_index(trans(idx).offers, 0); - if(trans(idx).offers->len > 0) - transfer_offers_notify(&trans(idx), FALSE); + g_array_remove_index(trans(idx).offers, 0); + if(trans(idx).offers->len > 0) + transfer_offers_notify(&trans(idx), FALSE); - game_gui_print_message(_("Your offer has been removed.")); - on_button_transfers_clicked(NULL, NULL); - return; + game_gui_print_message(_("Your offer has been removed.")); + on_button_transfers_clicked(NULL, NULL); + return; } - + if(current_user.tm->players->len == const_int("int_team_max_players")) { - game_gui_show_warning(_("Your roster is already full. You can't buy more players.")); - return; + game_gui_show_warning(_("Your roster is already full. You can't buy more players.")); + return; } misc_print_grouped_int(transoff(idx, 0).fee, buf2); misc_print_grouped_int(transoff(idx, 0).wage, buf3); - sprintf(buf, _("You offered a transfer fee of %s and a wage of %s for %s. The owners and the player are satisfied with your offer. Do you still want to buy the player?"), - buf2, buf3, player_of_id_team(trans(idx).tm, trans(idx).id)->name); + sprintf(buf, _("You offered a transfer fee of %s and a wage of %s for %s. The owners and the player are satisfied with your offer. Do you still want to buy the player?"), + buf2, buf3, player_of_id_team(trans(idx).tm, trans(idx).id)->name); stat1 = STATUS_TRANSFER_OFFER_CPU; stat2 = idx; window_show_transfer_dialog(buf); } -/** Handle a click on the transfer list. +/** Handle a click on the transfer list. @param button The mouse button number. @param idx The index of the selected player in the transfer list. */ void @@ -544,54 +573,54 @@ callback_transfer_list_clicked(gint button, gint idx) if(tr->tm == current_user.tm) { - callback_transfer_list_user(button, idx); - return; + callback_transfer_list_user(button, idx); + return; } else if(tr->offers->len > 0 && - transoff(idx, 0).status == TRANSFER_OFFER_ACCEPTED) + transoff(idx, 0).status == TRANSFER_OFFER_ACCEPTED) { - if(transoff(idx, 0).tm == current_user.tm) - { - if(team_is_user(tr->tm) != -1) - { - game_gui_print_message(_("User %s didn't consider your offer yet."), - user_from_team(tr->tm)->name); - } - else - callback_transfer_list_cpu(button, idx); - } - else - game_gui_print_message(_("The player is locked (the team owners are considering an offer currently).")); + if(transoff(idx, 0).tm == current_user.tm) + { + if(team_is_user(tr->tm) != -1) + { + game_gui_print_message(_("User %s didn't consider your offer yet."), + user_from_team(tr->tm)->name); + } + else + callback_transfer_list_cpu(button, idx); + } + else + game_gui_print_message(_("The player is locked (the team owners are considering an offer currently).")); - return; + return; } - + if(week >= transfer_get_deadline()) { - game_gui_print_message(_("The transfer deadline is over.")); - return; + game_gui_print_message(_("The transfer deadline is over.")); + return; } - + stat1 = STATUS_SHOW_TRANSFER_LIST; stat2 = idx; - + if(tr->offers->len > 0) - transfer_get_previous_offer(tr, current_user.tm, &old_fee, &old_wage); + transfer_get_previous_offer(tr, current_user.tm, &old_fee, &old_wage); if(old_wage == -1) { - sprintf(buf, _("You are making an offer for %s. Your scout's recommendations for fee and wage are preset."), - player_of_id_team(tr->tm, tr->id)->name); - - window_show_digits(buf, _("Fee"), tr->fee[current_user.scout % 10], - _("Wage"), tr->wage[current_user.scout % 10], FALSE); + sprintf(buf, _("You are making an offer for %s. Your scout's recommendations for fee and wage are preset."), + player_of_id_team(tr->tm, tr->id)->name); + + window_show_digits(buf, _("Fee"), tr->fee[current_user.scout % 10], + _("Wage"), tr->wage[current_user.scout % 10], FALSE); } else { - sprintf(buf, _("You are making an offer for %s again. Your previous values for fee and wage are preset."), - player_of_id_team(tr->tm, tr->id)->name); - - window_show_digits(buf, _("Fee"), old_fee, _("Wage"), old_wage, FALSE); + sprintf(buf, _("You are making an offer for %s again. Your previous values for fee and wage are preset."), + player_of_id_team(tr->tm, tr->id)->name); + + window_show_digits(buf, _("Fee"), old_fee, _("Wage"), old_wage, FALSE); } } @@ -607,52 +636,52 @@ callback_offer_new_contract(gint idx) gchar buf[SMALL]; Player *pl = player_of_idx_team(current_user.tm, idx); gfloat scout_dev = math_rnd(-const_float("float_transfer_scout_deviance_wage"), - const_float("float_transfer_scout_deviance_wage")) * - (current_user.scout % 10 + 1); + const_float("float_transfer_scout_deviance_wage")) * + (current_user.scout % 10 + 1); GtkSpinButton *spinbuttons[4]; if(pl->contract >= 2) { - game_gui_show_warning(_("You can't offer a new contract if the old one is still above 2 years.")); - return; + game_gui_show_warning(_("You can't offer a new contract if the old one is still above 2 years.")); + return; } else if(pl->offers == const_int("int_contract_max_offers")) { - game_gui_show_warning(_("The player won't negotiate with you anymore.")); - return; + game_gui_show_warning(_("The player won't negotiate with you anymore.")); + return; } else if(query_player_star_balks(pl, current_user.tm, FALSE)) { - pl->offers = const_int("int_contract_max_offers"); - game_gui_show_warning(_("The player feels he doesn't have a future in your star-studded team. He refuses to negotiate.")); - return; + pl->offers = const_int("int_contract_max_offers"); + game_gui_show_warning(_("The player feels he doesn't have a future in your star-studded team. He refuses to negotiate.")); + return; } stat1 = player_assign_wage(pl); statp = (gpointer)pl; if(pl->age < pl->peak_age) - stat1 = MAX(stat1, pl->wage); + stat1 = MAX(stat1, pl->wage); else - stat1 = MIN(stat1, pl->wage); + stat1 = MIN(stat1, pl->wage); window_create(WINDOW_CONTRACT); - sprintf(buf, _("You are negotiating with %s about a new contract. Pay attention to what you're doing; if you don't come to terms with him within %d offers, he's going to leave your team after his current contract expires (unless you sell him). You may only abort BEFORE making the first offer.\nYour scout's recommendations are preset:"), - pl->name, - const_int("int_contract_max_offers")); + sprintf(buf, _("You are negotiating with %s about a new contract. Pay attention to what you're doing; if you don't come to terms with him within %d offers, he's going to leave your team after his current contract expires (unless you sell him). You may only abort BEFORE making the first offer.\nYour scout's recommendations are preset:"), + pl->name, + const_int("int_contract_max_offers")); gtk_label_set_text(GTK_LABEL(lookup_widget(window.contract, "label_contract")), buf); - for(i=0;i<4;i++) + for(i=0; i<4; i++) { - sprintf(buf, "spinbutton_contract%d", i + 1); - spinbuttons[i] = GTK_SPIN_BUTTON(lookup_widget(window.contract, buf)); + sprintf(buf, "spinbutton_contract%d", i + 1); + spinbuttons[i] = GTK_SPIN_BUTTON(lookup_widget(window.contract, buf)); - gtk_spin_button_set_value(spinbuttons[i], - rint((gfloat)stat1 * - (1 + (i * const_float("float_contract_scale_factor") * - powf(-1, (pl->age > pl->peak_age)))) * - (1 + scout_dev))); + gtk_spin_button_set_value(spinbuttons[i], + rint((gfloat)stat1 * + (1 + (i * const_float("float_contract_scale_factor") * + powf(-1, (pl->age > pl->peak_age)))) * + (1 + scout_dev))); } setsav0; @@ -666,8 +695,8 @@ callback_show_team(gint type) printf("callback_show_team\n"); #endif - GtkTreeView *treeview_right = - GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")); + GtkTreeView *treeview_right = + GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")); const Team *tm; const GArray *teams = NULL; const GPtrArray *teamsp = NULL; @@ -675,58 +704,58 @@ callback_show_team(gint type) if(type == SHOW_CURRENT) { - tm = (const Team*)treeview_helper_get_pointer(treeview_right, 2); - stat1 = team_get_index(tm); - stat2 = tm->clid; + tm = (const Team*)treeview_helper_get_pointer(treeview_right, 2); + stat1 = team_get_index(tm); + stat2 = tm->clid; } else { - if(type == SHOW_NEXT_LEAGUE) - { - stat2 = league_cup_get_next_clid(stat2, TRUE); - while(stat2 >= ID_CUP_START && cup_from_clid(stat2)->teams->len == 0) - stat2 = league_cup_get_next_clid(stat2, TRUE); - } - else if(type == SHOW_PREVIOUS_LEAGUE) - { - stat2 = league_cup_get_previous_clid(stat2, TRUE); - while(stat2 >= ID_CUP_START && cup_from_clid(stat2)->teams->len == 0) - stat2 = league_cup_get_previous_clid(stat2, TRUE); - } + if(type == SHOW_NEXT_LEAGUE) + { + stat2 = league_cup_get_next_clid(stat2, TRUE); + while(stat2 >= ID_CUP_START && cup_from_clid(stat2)->teams->len == 0) + stat2 = league_cup_get_next_clid(stat2, TRUE); + } + else if(type == SHOW_PREVIOUS_LEAGUE) + { + stat2 = league_cup_get_previous_clid(stat2, TRUE); + while(stat2 >= ID_CUP_START && cup_from_clid(stat2)->teams->len == 0) + stat2 = league_cup_get_previous_clid(stat2, TRUE); + } - if(stat2 < ID_CUP_START) - { - teams = (GArray*)league_cup_get_teams(stat2); - len = teams->len; - } - else - { - teamsp = (GPtrArray*)league_cup_get_teams(stat2); - len = teamsp->len; - } + if(stat2 < ID_CUP_START) + { + teams = (GArray*)league_cup_get_teams(stat2); + len = teams->len; + } + else + { + teamsp = (GPtrArray*)league_cup_get_teams(stat2); + len = teamsp->len; + } - if(type == SHOW_NEXT) - stat1 = (stat1 == len - 1) ? 0 : stat1 + 1; - else if(type == SHOW_PREVIOUS) - stat1 = (stat1 == 0) ? len - 1 : stat1 - 1; - else - stat1 = 0; + if(type == SHOW_NEXT) + stat1 = (stat1 == len - 1) ? 0 : stat1 + 1; + else if(type == SHOW_PREVIOUS) + stat1 = (stat1 == 0) ? len - 1 : stat1 - 1; + else + stat1 = 0; - if(stat2 < ID_CUP_START) - tm = &g_array_index(teams, Team, stat1); - else - tm = (Team*)g_ptr_array_index(teamsp, stat1); + if(stat2 < ID_CUP_START) + tm = &g_array_index(teams, Team, stat1); + else + tm = (Team*)g_ptr_array_index(teamsp, stat1); } stat0 = STATUS_BROWSE_TEAMS; if(tm != current_user.tm) { - treeview_show_player_list_team(treeview_right, tm, current_user.scout % 10); - game_gui_write_av_skills(tm); + treeview_show_player_list_team(treeview_right, tm, current_user.scout % 10); + game_gui_write_av_skills(tm); } else - callback_show_team((type == SHOW_PREVIOUS) ? SHOW_PREVIOUS : SHOW_NEXT); + callback_show_team((type == SHOW_PREVIOUS) ? SHOW_PREVIOUS : SHOW_NEXT); } /** Show a sortable list of all players in a league or cup. */ @@ -741,23 +770,23 @@ callback_show_player_list(gint type) switch(type) { - default: - debug_print_message("callback_show_player_list: unknown type %d \n", type); - return; - break; - case SHOW_CURRENT: - stat1 = current_user.tm->clid; - break; - case SHOW_NEXT_LEAGUE: - stat1 = league_cup_get_next_clid(stat1, TRUE); - while(stat1 >= ID_CUP_START && cup_from_clid(stat1)->teams->len == 0) - stat1 = league_cup_get_next_clid(stat1, TRUE); - break; - case SHOW_PREVIOUS_LEAGUE: - stat1 = league_cup_get_previous_clid(stat1, TRUE); - while(stat1 >= ID_CUP_START && cup_from_clid(stat1)->teams->len == 0) - stat1 = league_cup_get_previous_clid(stat1, TRUE); - break; + default: + debug_print_message("callback_show_player_list: unknown type %d \n", type); + return; + break; + case SHOW_CURRENT: + stat1 = current_user.tm->clid; + break; + case SHOW_NEXT_LEAGUE: + stat1 = league_cup_get_next_clid(stat1, TRUE); + while(stat1 >= ID_CUP_START && cup_from_clid(stat1)->teams->len == 0) + stat1 = league_cup_get_next_clid(stat1, TRUE); + break; + case SHOW_PREVIOUS_LEAGUE: + stat1 = league_cup_get_previous_clid(stat1, TRUE); + while(stat1 >= ID_CUP_START && cup_from_clid(stat1)->teams->len == 0) + stat1 = league_cup_get_previous_clid(stat1, TRUE); + break; } treeview_show_all_players(stat1); @@ -796,26 +825,26 @@ callback_show_league_stats(gint type) switch(type) { - default: - debug_print_message("callback_show_league_stats: unknown type %d \n", type); - return; - break; - case SHOW_CURRENT: - stat1 = current_user.tm->clid; - while(stat1 >= ID_CUP_START || - !query_league_active(league_from_clid(stat1))) - stat1 = league_cup_get_next_clid(stat1, FALSE); - break; - case SHOW_NEXT_LEAGUE: - stat1 = league_cup_get_next_clid(stat1, FALSE); - while(stat1 >= ID_CUP_START) - stat1 = league_cup_get_next_clid(stat1, FALSE); - break; - case SHOW_PREVIOUS_LEAGUE: - stat1 = league_cup_get_previous_clid(stat1, FALSE); - while(stat1 >= ID_CUP_START) - stat1 = league_cup_get_previous_clid(stat1, FALSE); - break; + default: + debug_print_message("callback_show_league_stats: unknown type %d \n", type); + return; + break; + case SHOW_CURRENT: + stat1 = current_user.tm->clid; + while(stat1 >= ID_CUP_START || + !query_league_active(league_from_clid(stat1))) + stat1 = league_cup_get_next_clid(stat1, FALSE); + break; + case SHOW_NEXT_LEAGUE: + stat1 = league_cup_get_next_clid(stat1, FALSE); + while(stat1 >= ID_CUP_START) + stat1 = league_cup_get_next_clid(stat1, FALSE); + break; + case SHOW_PREVIOUS_LEAGUE: + stat1 = league_cup_get_previous_clid(stat1, FALSE); + while(stat1 >= ID_CUP_START) + stat1 = league_cup_get_previous_clid(stat1, FALSE); + break; } treeview_show_league_stats(stat1); @@ -834,38 +863,38 @@ callback_show_season_history(gint type) switch(type) { - default: - debug_print_message("callback_show_season_history: unknown type %d \n", type); - return; - break; - case SHOW_CURRENT: - stat1 = -1; - stat2 = len - 1; - break; - case SHOW_NEXT_LEAGUE: - stat = &g_array_index(season_stats, SeasonStat, stat2); - if(stat1 == -1) - stat1 = 0; - else if(stat1 == stat->league_stats->len - 1) - stat1 = -1; - else - stat1++; - break; - case SHOW_PREVIOUS_LEAGUE: - stat = &g_array_index(season_stats, SeasonStat, stat2); - if(stat1 == -1) - stat1 = stat->league_stats->len - 1; - else if(stat1 == 0) - stat1 = -1; - else - stat1--; - break; - case SHOW_NEXT: - stat2 = (stat2 + 1) % len; - break; - case SHOW_PREVIOUS: - stat2 = (stat2 == 0) ? len - 1 : stat2 - 1; - break; + default: + debug_print_message("callback_show_season_history: unknown type %d \n", type); + return; + break; + case SHOW_CURRENT: + stat1 = -1; + stat2 = len - 1; + break; + case SHOW_NEXT_LEAGUE: + stat = &g_array_index(season_stats, SeasonStat, stat2); + if(stat1 == -1) + stat1 = 0; + else if(stat1 == stat->league_stats->len - 1) + stat1 = -1; + else + stat1++; + break; + case SHOW_PREVIOUS_LEAGUE: + stat = &g_array_index(season_stats, SeasonStat, stat2); + if(stat1 == -1) + stat1 = stat->league_stats->len - 1; + else if(stat1 == 0) + stat1 = -1; + else + stat1--; + break; + case SHOW_NEXT: + stat2 = (stat2 + 1) % len; + break; + case SHOW_PREVIOUS: + stat2 = (stat2 == 0) ? len - 1 : stat2 - 1; + break; } treeview_show_season_history(stat1, stat2); @@ -881,12 +910,12 @@ callback_show_next_opponent(void) const Fixture *fix = team_get_fixture(current_user.tm, FALSE); const Team *opp = (fix == NULL) ? NULL : - fix->teams[fix->teams[0] == current_user.tm]; - GtkTreeView *treeview_right = - GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")); + fix->teams[fix->teams[0] == current_user.tm]; + GtkTreeView *treeview_right = + GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")); if(opp == NULL) - return; + return; stat0 = STATUS_BROWSE_TEAMS; stat1 = team_get_index(opp); @@ -904,16 +933,16 @@ callback_show_player_team(void) printf("callback_show_player_team\n"); #endif - GtkTreeView *treeview_right = - GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")); - const Player *pl = - (const Player*)treeview_helper_get_pointer(treeview_right, 2); - + GtkTreeView *treeview_right = + GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")); + const Player *pl = + (const Player*)treeview_helper_get_pointer(treeview_right, 2); + stat0 = STATUS_BROWSE_TEAMS; stat1 = team_get_index(pl->team); stat2 = pl->team->clid; - treeview_show_player_list_team(treeview_right, pl->team, current_user.scout % 10); + treeview_show_player_list_team(treeview_right, pl->team, current_user.scout % 10); } /** Show the youth players of the current user. */ @@ -927,22 +956,24 @@ callback_show_youth_academy(void) gint i; PlayerListAttribute attributes; - for(i=0;i