From 002587ecbedad76e3d12c0f409b68e9328d10287 Mon Sep 17 00:00:00 2001 From: gyboth Date: Sat, 10 Dec 2005 12:21:19 +0000 Subject: [PATCH] Job exchange bugfixes. --- src/debug.c | 9 +++++++-- src/debug.h | 2 +- src/job.c | 20 +++----------------- src/job.h | 3 --- src/main.c | 8 +++++++- src/misc2_callback_func.c | 5 +---- src/misc2_callbacks.c | 7 ++----- src/misc_callback_func.c | 7 +++++++ src/misc_interface.c | 12 +++--------- src/player.c | 9 ++++++--- src/xml_loadsave_live_game.c | 5 ++--- support_files/bygfoot_help | 3 +-- 12 files changed, 40 insertions(+), 50 deletions(-) diff --git a/src/debug.c b/src/debug.c index db9f1558..85b0ff00 100644 --- a/src/debug.c +++ b/src/debug.c @@ -35,10 +35,15 @@ #include "user.h" #include "variables.h" -/** Take some debug action depending on the text and the value. */ +/** Take some debug action depending on the text. Text is a prefix and a number. */ void -debug_action(const gchar *text, gint value) +debug_action(const gchar *text) { + gchar buf[SMALL]; + gint value = -1; + + sscanf(text, "%[^-0-9]%d", buf, &value); + if(g_str_has_prefix(text, "deb")) { option_set_int("int_debug", &constants, value); diff --git a/src/debug.h b/src/debug.h index db04d622..a6455d16 100644 --- a/src/debug.h +++ b/src/debug.h @@ -29,7 +29,7 @@ #include "bygfoot.h" void -debug_action(const gchar *text, gint value); +debug_action(const gchar *text); gboolean debug_reset_counter(gpointer data); diff --git a/src/job.c b/src/job.c index 1787e312..0f39af3a 100644 --- a/src/job.c +++ b/src/job.c @@ -29,6 +29,7 @@ #include "free.h" #include "job.h" #include "league.h" +#include "live_game.h" #include "main.h" #include "maths.h" #include "option.h" @@ -369,13 +370,11 @@ job_change_country(Job *job) Team tm = *(job_get_team(job)); gint season_temp = season + 1; -/* printf("1\n"); */ for(i=transfer_list->len - 1;i>=0;i--) transfer_remove_player(i); free_bets(TRUE); -/* printf("2\n"); */ /* There's only one user (otherwise international job offers are disabled). */ for(i=0;i<2;i++) @@ -384,12 +383,12 @@ job_change_country(Job *job) usr(0).bets[i] = g_array_new(FALSE, FALSE, sizeof(BetUser)); } -/* printf("3\n"); */ + live_game_reset(&usr(0).live_game, NULL, FALSE); + free_country(&country, TRUE); xml_country_read(job->country_file, &country); -/* printf("4\n"); */ stat5 = STATUS_GENERATE_TEAMS; for(i=0;ilen;i++) for(j=0;jlen;j++) @@ -411,22 +410,9 @@ job_change_country(Job *job) } stat5 = -1; -/* printf("5\n"); */ /* Set season to 1 so that some special things in the start_new_season function don't get applied. */ season = 1; start_new_season(); season = season_temp; -/* printf("6\n"); */ -} - -/** Remove all national job offers from the jobs list (when changing country). */ -void -job_remove_national(void) -{ - gint i; - - for(i=jobs->len - 1; i >= 0; i--) - if(g_array_index(jobs, Job, i).type == JOB_TYPE_NATIONAL) - job_remove(&g_array_index(jobs, Job, i), TRUE); } diff --git a/src/job.h b/src/job.h index 82b46d4e..2a583f02 100644 --- a/src/job.h +++ b/src/job.h @@ -67,7 +67,4 @@ job_team_is_in_cup(const gchar *team_name); void job_change_country(Job *job); -void -job_remove_national(void); - #endif diff --git a/src/main.c b/src/main.c index 83a96081..19017228 100644 --- a/src/main.c +++ b/src/main.c @@ -65,7 +65,7 @@ main_parse_cl_arguments(gint *argc, gchar ***argv) gboolean testcom = FALSE, calodds = FALSE; gchar *support_dir = NULL, *lang = NULL, *testcom_file = NULL, *token_file = NULL, - *event_name = NULL; + *event_name = NULL, *debug_text = NULL; gint deb_level = -1, number_of_passes = 1, num_matches = 100, skilldiffmax = 20; GError *error = NULL; @@ -106,6 +106,9 @@ main_parse_cl_arguments(gint *argc, gchar ***argv) { "num-skilldiff", 'S', 0, G_OPTION_ARG_INT, &skilldiffmax, "[developer] How many skill diff steps to take", "N" }, + { "deb", 'D', 0, G_OPTION_ARG_STRING, &debug_text, + "A debug command like 'deb100 to set the debug level'; see the debug window and debug.c", "STRING" }, + {NULL}}; if(argc == NULL || argv == NULL) @@ -145,6 +148,9 @@ main_parse_cl_arguments(gint *argc, gchar ***argv) if(lang != NULL) language_set(language_get_code_index(lang) + 1); + + if(debug_text != NULL) + statp = debug_text; } /** diff --git a/src/misc2_callback_func.c b/src/misc2_callback_func.c index d49183ea..d148a022 100644 --- a/src/misc2_callback_func.c +++ b/src/misc2_callback_func.c @@ -333,10 +333,7 @@ misc2_callback_evaluate_job_application(Job *job, User *user) if(job->type == JOB_TYPE_NATIONAL) job_remove(job, TRUE); else - { - job_remove(job, FALSE); - job_remove_national(); - } + free_jobs(TRUE); return TRUE; } diff --git a/src/misc2_callbacks.c b/src/misc2_callbacks.c index c4f88b28..1eb1d966 100644 --- a/src/misc2_callbacks.c +++ b/src/misc2_callbacks.c @@ -363,11 +363,8 @@ on_button_debug_apply_clicked (GtkButton *button, GtkEntry *entry_debug = GTK_ENTRY(lookup_widget(window.wdebug, "entry_debug")); const gchar *entry_text = gtk_entry_get_text(entry_debug); - gchar buf[SMALL]; - gint value = -1; - - sscanf(entry_text, "%[^-0-9]%d", buf, &value); - debug_action(buf, value); + + debug_action(entry_text); gtk_entry_set_text(entry_debug, ""); } diff --git a/src/misc_callback_func.c b/src/misc_callback_func.c index 338a3148..5310c643 100644 --- a/src/misc_callback_func.c +++ b/src/misc_callback_func.c @@ -99,6 +99,13 @@ misc_callback_start_game(void) window_create(WINDOW_MAIN); game_gui_show_main(); + + if(statp != NULL) + { + debug_action((gchar*)statp); + g_free(statp); + statp = NULL; + } } else { diff --git a/src/misc_interface.c b/src/misc_interface.c index c2904746..75c6be00 100644 --- a/src/misc_interface.c +++ b/src/misc_interface.c @@ -40,7 +40,6 @@ create_window_startup (void) GtkWidget *treeview_users; GtkWidget *scrolledwindow1; GtkWidget *treeview_startup; - GtkWidget *hseparator10; GtkWidget *hseparator11; GtkWidget *label4; GtkWidget *comboboxentry_start_league; @@ -97,12 +96,13 @@ create_window_startup (void) vbox34 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox34); - gtk_box_pack_start (GTK_BOX (vbox2), vbox34, FALSE, TRUE, 5); + gtk_box_pack_start (GTK_BOX (vbox2), vbox34, FALSE, TRUE, 0); label69 = gtk_label_new (_("Choose country")); gtk_widget_show (label69); gtk_box_pack_start (GTK_BOX (vbox34), label69, FALSE, FALSE, 0); - gtk_misc_set_padding (GTK_MISC (label69), 0, 5); + gtk_label_set_justify (GTK_LABEL (label69), GTK_JUSTIFY_CENTER); + gtk_misc_set_padding (GTK_MISC (label69), 0, 1); combo_country = gtk_combo_box_new_text (); gtk_widget_show (combo_country); @@ -142,11 +142,6 @@ create_window_startup (void) gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview_startup), TRUE); gtk_tree_view_set_reorderable (GTK_TREE_VIEW (treeview_startup), TRUE); - hseparator10 = gtk_hseparator_new (); - gtk_widget_show (hseparator10); - gtk_box_pack_start (GTK_BOX (vbox2), hseparator10, FALSE, FALSE, 0); - gtk_widget_set_size_request (hseparator10, 1, 5); - hseparator11 = gtk_hseparator_new (); gtk_widget_show (hseparator11); gtk_box_pack_start (GTK_BOX (vbox2), hseparator11, FALSE, FALSE, 0); @@ -369,7 +364,6 @@ create_window_startup (void) GLADE_HOOKUP_OBJECT (window_startup, treeview_users, "treeview_users"); GLADE_HOOKUP_OBJECT (window_startup, scrolledwindow1, "scrolledwindow1"); GLADE_HOOKUP_OBJECT (window_startup, treeview_startup, "treeview_startup"); - GLADE_HOOKUP_OBJECT (window_startup, hseparator10, "hseparator10"); GLADE_HOOKUP_OBJECT (window_startup, hseparator11, "hseparator11"); GLADE_HOOKUP_OBJECT (window_startup, label4, "label4"); GLADE_HOOKUP_OBJECT (window_startup, comboboxentry_start_league, "comboboxentry_start_league"); diff --git a/src/player.c b/src/player.c index 01fe85a8..8aa4364a 100644 --- a/src/player.c +++ b/src/player.c @@ -431,10 +431,13 @@ player_compare_func(gconstpointer a, gconstpointer b, gpointer data) player_get_game_skill(pl2, FALSE, TRUE)); else if(type == PLAYER_COMPARE_ATTRIBUTE_POS) { - if(MIN(player_id_index(pl1->team, pl1->id), player_id_index(pl2->team, pl2->id)) < 11 && - MAX(player_id_index(pl1->team, pl1->id), player_id_index(pl2->team, pl2->id)) >= 11) + if(MIN(player_id_index(pl1->team, pl1->id), + player_id_index(pl2->team, pl2->id)) < 11 && + MAX(player_id_index(pl1->team, pl1->id), + player_id_index(pl2->team, pl2->id)) >= 11) return_value = - (player_id_index(pl1->team, pl1->id) > player_id_index(pl2->team, pl2->id)) ? + (player_id_index(pl1->team, pl1->id) > + player_id_index(pl2->team, pl2->id)) ? 1 : -1; else if(pl1->cskill == 0) return_value = (pl2->cskill == 0) ? 0 : 1; diff --git a/src/xml_loadsave_live_game.c b/src/xml_loadsave_live_game.c index 6aaeb127..47b40525 100644 --- a/src/xml_loadsave_live_game.c +++ b/src/xml_loadsave_live_game.c @@ -276,9 +276,8 @@ xml_loadsave_live_game_write(const gchar *filename, const LiveGame *live_game) if(live_game->fix->id > 10000000) g_warning( - "xml_loadsave_live_game_write: suspicious fix id: %d. competition: %s", - live_game->fix->id, - league_cup_get_name_string(live_game->fix->id)); + "xml_loadsave_live_game_write: suspicious fix id: %d.", + live_game->fix->id); for(i=0;i<2;i++) xml_write_string(fil, live_game->team_names[i], diff --git a/support_files/bygfoot_help b/support_files/bygfoot_help index e6f97b32..e0129ded 100644 --- a/support_files/bygfoot_help +++ b/support_files/bygfoot_help @@ -14,11 +14,10 @@ string_contrib_title Patches and ideas string_contrib_entry Mark Calderbank, Michal Rudolf string_contrib_title Country definitions -string_contrib_entry Győző Both (Australia, Italy, Scotland, USA, WC2006) +string_contrib_entry Győző Both (Australia, Brazil, Italy, Scotland, USA, WC2006) string_contrib_entry Mark Calderbank (Bulgaria, England, Ireland, Spain, Victoria, Wales) string_contrib_entry Tobe & Arne Deprez (Belgium) string_contrib_entry Theodore Dimitriadis (Greece) -string_contrib_entry Celso Goya (Brazil) string_contrib_entry Pechorin (Serbia & Montenegro) string_contrib_entry Koen Pijnenburg (Netherlands) string_contrib_entry Arnaud Le Rouzic (France)