diff --git a/bygfoot.glade b/bygfoot.glade index 8f2bcfd5..01069a79 100644 --- a/bygfoot.glade +++ b/bygfoot.glade @@ -68,7 +68,7 @@ - + True gtk-revert-to-saved 1 @@ -136,7 +136,7 @@ - + True gtk-preferences 1 @@ -200,7 +200,7 @@ - + True menu_save_geometry.png 0.5 @@ -234,7 +234,7 @@ - + True menu_fixtures.png 0.5 @@ -255,7 +255,7 @@ - + True menu_fixtures_comp.png 0.5 @@ -276,7 +276,7 @@ - + True menu_table.png 0.5 @@ -297,7 +297,7 @@ - + True menu_league_results.png 0.5 @@ -318,7 +318,7 @@ - + True menu_season_res.png 0.5 @@ -345,7 +345,7 @@ - + True menu_league_stats.png 0.5 @@ -366,7 +366,7 @@ - + True menu_history.png 0.5 @@ -398,7 +398,7 @@ True - + True menu_style.png 0.5 @@ -476,7 +476,7 @@ True - + True menu_scout.png 0.5 @@ -543,7 +543,7 @@ True - + True menu_physio.png 0.5 @@ -610,7 +610,7 @@ True - + True menu_youth_academy.png 0.5 @@ -777,7 +777,7 @@ True - + True menu_boost.png 0.5 @@ -840,7 +840,7 @@ - + True gtk-undo 1 @@ -861,7 +861,7 @@ - + True menu_structure.png 0.5 @@ -883,7 +883,7 @@ - + True menu_rearrange.png 0.5 @@ -909,7 +909,7 @@ - + True menu_browse_tms.png 0.5 @@ -942,7 +942,7 @@ - + True menu_player_info.png 0.5 @@ -962,7 +962,7 @@ - + True menu_player_put_transfer.png 0.5 @@ -982,7 +982,7 @@ - + True menu_player_remove_transfer.png 0.5 @@ -1002,7 +1002,7 @@ - + True menu_player_contract.png 0.5 @@ -1022,7 +1022,7 @@ - + True menu_player_fire.png 0.5 @@ -1042,7 +1042,7 @@ - + True menu_player_shoots.png 0.5 @@ -1062,7 +1062,7 @@ - + True menu_player_move_to_ya.png 0.5 @@ -1088,7 +1088,7 @@ - + True menu_player_browse.png 0.5 @@ -1122,7 +1122,7 @@ - + True menu_last_match.png 0.5 @@ -1143,7 +1143,7 @@ - + True menu_match_stats.png 0.5 @@ -1164,7 +1164,7 @@ - + True gtk-jump-to 1 @@ -1184,7 +1184,7 @@ True - + True menu_mmatches.png 0.5 @@ -1207,7 +1207,7 @@ - + True gtk-add 1 @@ -1230,7 +1230,7 @@ - + True gtk-preferences 1 @@ -1262,7 +1262,7 @@ - + True menu_history.png 0.5 @@ -1289,7 +1289,7 @@ - + True gtk-media-forward 1 @@ -1311,7 +1311,7 @@ - + True gtk-go-back 1 @@ -1333,7 +1333,7 @@ - + True gtk-justify-fill 1 @@ -1368,7 +1368,7 @@ - + True menu_finances.png 0.5 @@ -1389,7 +1389,7 @@ - + True menu_stadium.png 0.5 @@ -1400,6 +1400,23 @@ + + + + True + + + + + + True + Show the betting window + Betting + True + + + + @@ -1422,7 +1439,7 @@ - + True gtk-dialog-info 1 @@ -1443,7 +1460,7 @@ - + True gtk-add 1 @@ -1464,7 +1481,7 @@ - + True gtk-help 1 diff --git a/bygfoot_misc2.glade b/bygfoot_misc2.glade index f58589c9..1e733d16 100644 --- a/bygfoot_misc2.glade +++ b/bygfoot_misc2.glade @@ -736,7 +736,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER - False + True True False True diff --git a/bygfoot_options.glade b/bygfoot_options.glade index 1c704857..318e20b7 100644 --- a/bygfoot_options.glade +++ b/bygfoot_options.glade @@ -2655,6 +2655,117 @@ tab + + + + True + False + 0 + + + + True + False + 0 + + + + True + Whether to show matches of all leagues in the betting window + True + Show matches from all leagues + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + Whether to show cup matches in the betting window + True + Show matches from cups + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 0 + False + False + + + + + + True + True + Show only my recent bets + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + 0 + True + True + + + + + + + + + + + + + False + True + + + + + + True + Betting + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + 0 diff --git a/src/Makefile.am b/src/Makefile.am index 18eb6fd4..714f2697 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,6 +9,7 @@ INCLUDES = \ bin_PROGRAMS = bygfoot bygfoot_SOURCES = \ + bet.c bet.h bet_struct.h \ callback_func.c callback_func.h callbacks.h cup.h finance.h fixture.h game_gui.h gui.h league.h live_game.h maths.h misc.h option.h player.h start_end.h team.h transfer.h treeview.h treeview_helper.h user.h window.h \ callbacks.c callback_func.h callbacks.h debug.h free.h game_gui.h game.h gui.h league.h load_save.h main.h option.h player.h table.h team.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \ cup.c cup.h fixture.h free.h league.h main.h maths.h misc.h option.h table.h team.h variables.h xml_league.h \ @@ -31,10 +32,12 @@ bygfoot_SOURCES = \ misc.c main.h maths.h misc.h \ misc_callbacks.c callback_func.h callbacks.h game_gui.h game.h gui.h live_game.h load_save.h main.h maths.h misc_callback_func.h misc_callbacks.h option.h user.h variables.h window.h xml_country.h \ misc_callback_func.c callbacks.h finance.h game_gui.h game.h gui.h load_save.h maths.h misc_callback_func.h misc.h option.h start_end.h support.h treeview.h treeview_helper.h user.h variables.h window.h xml_country.h xml_name.h \ - misc_interface.c misc_callbacks.h misc_interface.h support.h \ misc2_callbacks.c callback_func.h callbacks.h debug.h finance.h free.h game_gui.h load_save.h main.h misc2_callback_func.h misc2_callbacks.h misc2_interface.h player.h support.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \ + misc3_callbacks.c misc3_callbacks.h misc3_interface.h support.h \ misc2_callback_func.c callback_func.h callbacks.h file.h finance.h free.h game_gui.h maths.h misc2_callback_func.h misc.h option.h player.h support.h team.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \ + misc_interface.c misc_callbacks.h misc_interface.h support.h \ misc2_interface.c misc2_callbacks.h misc2_interface.h support.h \ + misc3_interface.c misc3_callbacks.h misc3_interface.h support.h \ name.c main.h name.h option.h variables.h xml_name.h \ option.c main.h misc.h option.h variables.h \ option_gui.c callbacks.h file.h game_gui.h language.h misc.h option_gui.h option.h support.h treeview.h user.h variables.h \ diff --git a/src/bygfoot.h b/src/bygfoot.h index 6b65a221..0c3a8b03 100644 --- a/src/bygfoot.h +++ b/src/bygfoot.h @@ -112,6 +112,7 @@ enum ExitCodes EXIT_DEF_SORT, /**< Error sorting a team after loading the definition. */ EXIT_PROM_REL, /**< Error when executing the promotion/relegation stuff. */ EXIT_STRATEGY_ERROR, /**< Error related to CPU strategies. */ + EXIT_BET_ERROR, /**< Error related to betting. */ EXIT_END }; @@ -155,6 +156,7 @@ typedef struct *help, *transfer_dialog, *sponsors, - *mmatches; + *mmatches, + *bets; } Windows; #endif diff --git a/src/callbacks.c b/src/callbacks.c index 05028579..344c5481 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -1174,3 +1174,12 @@ on_menu_save_window_geometry_activate (GtkMenuItem *menuitem, { window_main_save_geometry(); } + +void +on_menu_betting_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + on_button_back_to_main_clicked(NULL, NULL); + window_show_bets(); +} + diff --git a/src/callbacks.h b/src/callbacks.h index 07f70db8..e03e89c0 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -332,3 +332,7 @@ void on_menu_season_results_activate (GtkMenuItem *menuitem, gpointer user_data); #endif + +void +on_menu_betting_activate (GtkMenuItem *menuitem, + gpointer user_data); diff --git a/src/debug.c b/src/debug.c index b1ab0ab8..16595d3f 100644 --- a/src/debug.c +++ b/src/debug.c @@ -24,8 +24,12 @@ #include "callbacks.h" #include "debug.h" #include "game_gui.h" +#include "league.h" +#include "live_game.h" #include "option.h" +#include "strategy.h" #include "support.h" +#include "team.h" #include "user.h" #include "variables.h" @@ -125,3 +129,42 @@ debug_reset_counter(gpointer data) return FALSE; } + +void +debug_calibrate_betting_odds(gint skilldiffmax, gint matches_per_skilldiff) +{ + gint i, skilldiff, matches; + Fixture *fix = &g_array_index(lig(0).fixtures, Fixture, 0); + + fix->home_advantage = FALSE; + + for(skilldiff=0;skilldiff<=skilldiffmax;skilldiff++) + { + gint res[3] = {0, 0, 0}; + + for(matches=0;matchesattendance = -1; + fix->result[0][0] = fix->result[1][0] = 0; + for(i=0;iteams[0]->players->len;i++) + { + strategy_repair_player(&g_array_index(fix->teams[0]->players, Player, i)); + strategy_repair_player(&g_array_index(fix->teams[1]->players, Player, i)); + g_array_index(fix->teams[0]->players, Player, i).skill = 90; + g_array_index(fix->teams[1]->players, Player, i).skill = 90 - skilldiff; + g_array_index(fix->teams[0]->players, Player, i).fitness = 0.9; + g_array_index(fix->teams[1]->players, Player, i).fitness = 0.9; + } + + live_game_calculate_fixture(fix); + if(fix->result[0][0] < fix->result[1][0]) + res[2]++; + else + res[(fix->result[0][0] == fix->result[1][0])]++; + } + + printf("sd %3d res %3d %3d %3d prob %.2f %.2f %.2f\n", skilldiff, + res[0], res[1], res[2], (gfloat)res[0] / (gfloat)matches, + (gfloat)res[1] / (gfloat)matches, (gfloat)res[2] / (gfloat)matches); + } +} diff --git a/src/debug.h b/src/debug.h index b96e152c..d743a00f 100644 --- a/src/debug.h +++ b/src/debug.h @@ -32,6 +32,8 @@ debug_action(const gchar *text, gint value); gboolean debug_reset_counter(gpointer data); +void +debug_calibrate_betting_odds(gint skilldiffmax, gint matches_per_skilldiff); #endif diff --git a/src/enums.h b/src/enums.h index d4e6ceb7..8c8bb61c 100644 --- a/src/enums.h +++ b/src/enums.h @@ -134,6 +134,7 @@ enum Status0Value STATUS_SELECT_MM_FILE_ADD, STATUS_SELECT_MM_FILE_IMPORT, STATUS_SELECT_MM_FILE_EXPORT, + STATUS_PLACE_BET, STATUS_END }; diff --git a/src/free.c b/src/free.c index 21625803..7908d0f0 100644 --- a/src/free.c +++ b/src/free.c @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "bet_struct.h" #include "free.h" #include "lg_commentary_struct.h" #include "strategy_struct.h" @@ -41,6 +42,7 @@ free_memory(void) free_strategies(); free_country(FALSE); free_users(FALSE); + free_bets(FALSE); free_live_game(&live_game_temp); free_lg_commentary(FALSE); free_support_dirs(); @@ -155,6 +157,9 @@ free_user(User *user) free_mmatches(&user->mmatches, FALSE); free_player_array(&user->youth_academy.players); + + free_g_array(&user->bets[0]); + free_g_array(&user->bets[1]); } /** Free the memorable matches array of the user and the memorable matches @@ -239,6 +244,8 @@ free_live_game(LiveGame *match) for(i=0;i<2;i++) { + free_g_array(&match->action_ids[i]); + free_gchar_ptr(match->team_names[i]); for(j=0;jlen;j++) + { g_free( g_array_index( g_array_index( strategies, Strategy, i).match_action, StrategyMatchAction, j).condition); + g_free( + g_array_index( + g_array_index( + strategies, Strategy, i).match_action, StrategyMatchAction, j).sub_condition); + } g_array_free(g_array_index(strategies, Strategy, i).match_action, TRUE); } g_array_free(strategies, TRUE); } + +/** Free the betting arrays. */ +void +free_bets(gboolean reset) +{ + free_g_array(&(bets[0])); + free_g_array(&(bets[1])); + + if(reset) + { + bets[0] = g_array_new(FALSE, FALSE, sizeof(BetMatch)); + bets[1] = g_array_new(FALSE, FALSE, sizeof(BetMatch)); + } +} diff --git a/src/free.h b/src/free.h index 73427ebc..f8758d43 100644 --- a/src/free.h +++ b/src/free.h @@ -128,4 +128,7 @@ free_mmatches(GArray **mmatches, gboolean reset); void free_strategies(void); +void +free_bets(gboolean reset); + #endif diff --git a/src/game.c b/src/game.c index 22f0c080..41e6a4ad 100644 --- a/src/game.c +++ b/src/game.c @@ -409,7 +409,8 @@ game_assign_attendance_neutral(Fixture *fix) { const GPtrArray *teamsp = (GPtrArray*)league_cup_get_teams(fix->clid); - gfloat av_att = (query_cup_is_international(fix->clid) && teamsp->len > 0) ? + gfloat av_att = (fix->clid >= ID_CUP_START && + query_cup_is_international(fix->clid) && teamsp->len > 0) ? (gfloat)league_cup_average_capacity(fix->clid) : (gfloat)league_cup_average_capacity(lig(0).id); @@ -664,6 +665,13 @@ game_substitute_player(Team *tm, gint player_number) if(g_array_index(tm->players, Player, i).cskill > 0) g_ptr_array_add(substitutes, &g_array_index(tm->players, Player, i)); + if(substitutes->len == 0) + { + g_ptr_array_free(substitutes, TRUE); + g_warning("game_substitute_player: no suitable substitutes found (all injured/banned?)"); + return -1; + } + g_ptr_array_sort_with_data(substitutes, (GCompareDataFunc)player_compare_substitute_func, GINT_TO_POINTER(player_of_idx_team(tm, @@ -801,6 +809,14 @@ game_substitute_player_send_off(gint clid, Team *tm, gint player_number, if(g_array_index(tm->players, Player, i).cskill > 0) g_ptr_array_add(substitutes, player_of_idx_team(tm, i)); + if(substitutes->len == 0) + { + g_ptr_array_free(substitutes, TRUE); + g_warning("game_substitute_player_send_off: no suitable substitutes found (all injured/banned?)"); + *to_substitute = -1; + return; + } + if(num_forw == 0 && MAX(num_def, num_mid) > 2) position = PLAYER_POS_FORWARD; else diff --git a/src/interface.c b/src/interface.c index 5a6dcb13..77b3c914 100644 --- a/src/interface.c +++ b/src/interface.c @@ -38,7 +38,7 @@ create_main_window (void) GtkWidget *menu_new; GtkWidget *menu_open; GtkWidget *menu_load_last_save; - GtkWidget *image2151; + GtkWidget *image2192; GtkWidget *menu_save; GtkWidget *menu_save_as; GtkWidget *trennlinie1; @@ -46,35 +46,35 @@ create_main_window (void) GtkWidget *menu_options; GtkWidget *menu_options_menu; GtkWidget *menu_preferences; - GtkWidget *image2152; + GtkWidget *image2193; GtkWidget *trennlinie7; GtkWidget *menu_job_offers; GtkWidget *menu_live_game; GtkWidget *menu_overwrite; GtkWidget *trennlinie14; GtkWidget *menu_save_window_geometry; - GtkWidget *image2153; + GtkWidget *image2194; GtkWidget *menu_figures; GtkWidget *menu_figures_menu; GtkWidget *menu_fixtures_week; - GtkWidget *image2154; + GtkWidget *image2195; GtkWidget *menu_fixtures; - GtkWidget *image2155; + GtkWidget *image2196; GtkWidget *menu_tables; - GtkWidget *image2156; + GtkWidget *image2197; GtkWidget *menu_my_league_results; - GtkWidget *image2157; + GtkWidget *image2198; GtkWidget *menu_season_results; - GtkWidget *image2158; + GtkWidget *image2199; GtkWidget *trennlinie13; GtkWidget *menu_league_stats; - GtkWidget *image2159; + GtkWidget *image2200; GtkWidget *menu_season_history; - GtkWidget *image2160; + GtkWidget *image2201; GtkWidget *menu_team; GtkWidget *menu_team_menu; GtkWidget *menu_playing_style; - GtkWidget *image2161; + GtkWidget *image2202; GtkWidget *menu_playing_style_menu; GSList *menu_all_out_defend_group = NULL; GtkWidget *menu_all_out_defend; @@ -83,7 +83,7 @@ create_main_window (void) GtkWidget *menu_attack; GtkWidget *menu_all_out_attack; GtkWidget *menu_scout; - GtkWidget *image2162; + GtkWidget *image2203; GtkWidget *menu_scout_menu; GSList *menu_scout_best_group = NULL; GtkWidget *menu_scout_best; @@ -91,7 +91,7 @@ create_main_window (void) GtkWidget *menu_scout_average; GtkWidget *menu_scout_bad; GtkWidget *menu_physio; - GtkWidget *image2163; + GtkWidget *image2204; GtkWidget *menu_physio_menu; GSList *menu_physio_best_group = NULL; GtkWidget *menu_physio_best; @@ -99,7 +99,7 @@ create_main_window (void) GtkWidget *menu_physio_average; GtkWidget *menu_physio_bad; GtkWidget *menu_youth_academy; - GtkWidget *image2164; + GtkWidget *image2205; GtkWidget *menu_youth_academy_menu; GtkWidget *menu_show_youth_academy; GtkWidget *youth_coach1; @@ -119,7 +119,7 @@ create_main_window (void) GtkWidget *menu_recruit4; GtkWidget *menu_set_investment; GtkWidget *menu_boost; - GtkWidget *image2165; + GtkWidget *image2206; GtkWidget *menu_boost_menu; GSList *menu_boost_on_group = NULL; GtkWidget *menu_boost_on; @@ -127,72 +127,74 @@ create_main_window (void) GtkWidget *menu_boost_anti; GtkWidget *trennlinie11; GtkWidget *menu_reset_players; - GtkWidget *image2166; + GtkWidget *image2207; GtkWidget *menu_custom_structure; - GtkWidget *image2167; + GtkWidget *image2208; GtkWidget *menu_rearrange_team; - GtkWidget *image2168; + GtkWidget *image2209; GtkWidget *trennlinie8; GtkWidget *menu_browse_teams; - GtkWidget *image2169; + GtkWidget *image2210; GtkWidget *menu_player; GtkWidget *menu_player_menu; GtkWidget *menu_show_info; - GtkWidget *image2170; + GtkWidget *image2211; GtkWidget *menu_put_on_transfer_list; - GtkWidget *image2171; + GtkWidget *image2212; GtkWidget *menu_remove_from_transfer_list; - GtkWidget *image2172; + GtkWidget *image2213; GtkWidget *menu_offer_new_contract; - GtkWidget *image2173; + GtkWidget *image2214; GtkWidget *menu_fire; - GtkWidget *image2174; + GtkWidget *image2215; GtkWidget *menu_shoots_penalties; - GtkWidget *image2175; + GtkWidget *image2216; GtkWidget *menu_move_to_youth_academy; - GtkWidget *image2176; + GtkWidget *image2217; GtkWidget *trennlinie10; GtkWidget *menu_browse_players; - GtkWidget *image2177; + GtkWidget *image2218; GtkWidget *menu_user; GtkWidget *menu_user_menu; GtkWidget *menu_user_show_last_match; - GtkWidget *image2178; + GtkWidget *image2219; GtkWidget *menu_user_show_last_stats; - GtkWidget *image2179; + GtkWidget *image2220; GtkWidget *menu_user_show_coming_matches; - GtkWidget *image2180; + GtkWidget *image2221; GtkWidget *memorable_matches; - GtkWidget *image2181; + GtkWidget *image2222; GtkWidget *memorable_matches_menu; GtkWidget *mm_add_last_match; - GtkWidget *image2182; + GtkWidget *image2223; GtkWidget *mm_manage_matches; - GtkWidget *image2183; + GtkWidget *image2224; GtkWidget *trennlinie12; GtkWidget *menu_user_show_history; - GtkWidget *image2184; + GtkWidget *image2225; GtkWidget *trennlinie9; GtkWidget *menu_next_user; - GtkWidget *image2185; + GtkWidget *image2226; GtkWidget *menu_previous_user; - GtkWidget *image2186; + GtkWidget *image2227; GtkWidget *menu_manage_users; - GtkWidget *image2187; + GtkWidget *image2228; GtkWidget *menu_finances_stadium; GtkWidget *menu_finances_stadium_menu; GtkWidget *menu_show_finances; - GtkWidget *image2188; + GtkWidget *image2229; GtkWidget *menu_show_stadium; - GtkWidget *image2189; + GtkWidget *image2230; + GtkWidget *trennlinie15; + GtkWidget *menu_betting; GtkWidget *menu_help1; GtkWidget *menu_help1_menu; GtkWidget *menu_about; - GtkWidget *image2190; + GtkWidget *image2231; GtkWidget *menu_contributors; - GtkWidget *image2191; + GtkWidget *image2232; GtkWidget *menu_help; - GtkWidget *image2192; + GtkWidget *image2233; GtkWidget *hbox1; GtkWidget *button_load; GtkWidget *image11; @@ -313,9 +315,9 @@ create_main_window (void) GDK_l, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE); - image2151 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_MENU); - gtk_widget_show (image2151); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_load_last_save), image2151); + image2192 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_MENU); + gtk_widget_show (image2192); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_load_last_save), image2192); menu_save = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group); gtk_widget_show (menu_save); @@ -348,9 +350,9 @@ create_main_window (void) GDK_p, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); - image2152 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU); - gtk_widget_show (image2152); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_preferences), image2152); + image2193 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU); + gtk_widget_show (image2193); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_preferences), image2193); trennlinie7 = gtk_separator_menu_item_new (); gtk_widget_show (trennlinie7); @@ -381,9 +383,9 @@ create_main_window (void) gtk_container_add (GTK_CONTAINER (menu_options_menu), menu_save_window_geometry); gtk_tooltips_set_tip (tooltips, menu_save_window_geometry, _("Save window size, position and vertical divider"), NULL); - image2153 = create_pixmap (main_window, "menu_save_geometry.png"); - gtk_widget_show (image2153); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_save_window_geometry), image2153); + image2194 = create_pixmap (main_window, "menu_save_geometry.png"); + gtk_widget_show (image2194); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_save_window_geometry), image2194); menu_figures = gtk_menu_item_new_with_mnemonic (_("F_igures")); gtk_widget_show (menu_figures); @@ -399,9 +401,9 @@ create_main_window (void) GDK_F3, 0, GTK_ACCEL_VISIBLE); - image2154 = create_pixmap (main_window, "menu_fixtures.png"); - gtk_widget_show (image2154); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_fixtures_week), image2154); + image2195 = create_pixmap (main_window, "menu_fixtures.png"); + gtk_widget_show (image2195); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_fixtures_week), image2195); menu_fixtures = gtk_image_menu_item_new_with_mnemonic (_("Fixtures (competitions)")); gtk_widget_show (menu_fixtures); @@ -410,9 +412,9 @@ create_main_window (void) GDK_F4, 0, GTK_ACCEL_VISIBLE); - image2155 = create_pixmap (main_window, "menu_fixtures_comp.png"); - gtk_widget_show (image2155); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_fixtures), image2155); + image2196 = create_pixmap (main_window, "menu_fixtures_comp.png"); + gtk_widget_show (image2196); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_fixtures), image2196); menu_tables = gtk_image_menu_item_new_with_mnemonic (_("Tables")); gtk_widget_show (menu_tables); @@ -421,9 +423,9 @@ create_main_window (void) GDK_F5, 0, GTK_ACCEL_VISIBLE); - image2156 = create_pixmap (main_window, "menu_table.png"); - gtk_widget_show (image2156); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_tables), image2156); + image2197 = create_pixmap (main_window, "menu_table.png"); + gtk_widget_show (image2197); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_tables), image2197); menu_my_league_results = gtk_image_menu_item_new_with_mnemonic (_("My league results")); gtk_widget_show (menu_my_league_results); @@ -432,9 +434,9 @@ create_main_window (void) GDK_F6, 0, GTK_ACCEL_VISIBLE); - image2157 = create_pixmap (main_window, "menu_league_results.png"); - gtk_widget_show (image2157); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_my_league_results), image2157); + image2198 = create_pixmap (main_window, "menu_league_results.png"); + gtk_widget_show (image2198); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_my_league_results), image2198); menu_season_results = gtk_image_menu_item_new_with_mnemonic (_("Season results")); gtk_widget_show (menu_season_results); @@ -443,9 +445,9 @@ create_main_window (void) GDK_s, GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE); - image2158 = create_pixmap (main_window, "menu_season_res.png"); - gtk_widget_show (image2158); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_season_results), image2158); + image2199 = create_pixmap (main_window, "menu_season_res.png"); + gtk_widget_show (image2199); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_season_results), image2199); trennlinie13 = gtk_separator_menu_item_new (); gtk_widget_show (trennlinie13); @@ -459,9 +461,9 @@ create_main_window (void) GDK_s, 0, GTK_ACCEL_VISIBLE); - image2159 = create_pixmap (main_window, "menu_league_stats.png"); - gtk_widget_show (image2159); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_league_stats), image2159); + image2200 = create_pixmap (main_window, "menu_league_stats.png"); + gtk_widget_show (image2200); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_league_stats), image2200); menu_season_history = gtk_image_menu_item_new_with_mnemonic (_("Season history")); gtk_widget_show (menu_season_history); @@ -470,9 +472,9 @@ create_main_window (void) GDK_h, 0, GTK_ACCEL_VISIBLE); - image2160 = create_pixmap (main_window, "menu_history.png"); - gtk_widget_show (image2160); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_season_history), image2160); + image2201 = create_pixmap (main_window, "menu_history.png"); + gtk_widget_show (image2201); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_season_history), image2201); menu_team = gtk_menu_item_new_with_mnemonic (_("_Team")); gtk_widget_show (menu_team); @@ -485,9 +487,9 @@ create_main_window (void) gtk_widget_show (menu_playing_style); gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_playing_style); - image2161 = create_pixmap (main_window, "menu_style.png"); - gtk_widget_show (image2161); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_playing_style), image2161); + image2202 = create_pixmap (main_window, "menu_style.png"); + gtk_widget_show (image2202); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_playing_style), image2202); menu_playing_style_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_playing_style), menu_playing_style_menu); @@ -526,9 +528,9 @@ create_main_window (void) gtk_widget_show (menu_scout); gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_scout); - image2162 = create_pixmap (main_window, "menu_scout.png"); - gtk_widget_show (image2162); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_scout), image2162); + image2203 = create_pixmap (main_window, "menu_scout.png"); + gtk_widget_show (image2203); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_scout), image2203); menu_scout_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_scout), menu_scout_menu); @@ -561,9 +563,9 @@ create_main_window (void) gtk_widget_show (menu_physio); gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_physio); - image2163 = create_pixmap (main_window, "menu_physio.png"); - gtk_widget_show (image2163); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_physio), image2163); + image2204 = create_pixmap (main_window, "menu_physio.png"); + gtk_widget_show (image2204); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_physio), image2204); menu_physio_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_physio), menu_physio_menu); @@ -596,9 +598,9 @@ create_main_window (void) gtk_widget_show (menu_youth_academy); gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_youth_academy); - image2164 = create_pixmap (main_window, "menu_youth_academy.png"); - gtk_widget_show (image2164); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_youth_academy), image2164); + image2205 = create_pixmap (main_window, "menu_youth_academy.png"); + gtk_widget_show (image2205); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_youth_academy), image2205); menu_youth_academy_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_youth_academy), menu_youth_academy_menu); @@ -687,9 +689,9 @@ create_main_window (void) gtk_widget_show (menu_boost); gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_boost); - image2165 = create_pixmap (main_window, "menu_boost.png"); - gtk_widget_show (image2165); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_boost), image2165); + image2206 = create_pixmap (main_window, "menu_boost.png"); + gtk_widget_show (image2206); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_boost), image2206); menu_boost_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_boost), menu_boost_menu); @@ -721,17 +723,17 @@ create_main_window (void) gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_reset_players); gtk_tooltips_set_tip (tooltips, menu_reset_players, _("Reset player list to the formation at the beginning of the live game pause (right click on player list)"), NULL); - image2166 = gtk_image_new_from_stock ("gtk-undo", GTK_ICON_SIZE_MENU); - gtk_widget_show (image2166); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_reset_players), image2166); + image2207 = gtk_image_new_from_stock ("gtk-undo", GTK_ICON_SIZE_MENU); + gtk_widget_show (image2207); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_reset_players), image2207); menu_custom_structure = gtk_image_menu_item_new_with_mnemonic (_("Enter custom structure")); gtk_widget_show (menu_custom_structure); gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_custom_structure); - image2167 = create_pixmap (main_window, "menu_structure.png"); - gtk_widget_show (image2167); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_custom_structure), image2167); + image2208 = create_pixmap (main_window, "menu_structure.png"); + gtk_widget_show (image2208); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_custom_structure), image2208); menu_rearrange_team = gtk_image_menu_item_new_with_mnemonic (_("Rearrange team")); gtk_widget_show (menu_rearrange_team); @@ -741,9 +743,9 @@ create_main_window (void) GDK_r, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); - image2168 = create_pixmap (main_window, "menu_rearrange.png"); - gtk_widget_show (image2168); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_rearrange_team), image2168); + image2209 = create_pixmap (main_window, "menu_rearrange.png"); + gtk_widget_show (image2209); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_rearrange_team), image2209); trennlinie8 = gtk_separator_menu_item_new (); gtk_widget_show (trennlinie8); @@ -754,9 +756,9 @@ create_main_window (void) gtk_widget_show (menu_browse_teams); gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_browse_teams); - image2169 = create_pixmap (main_window, "menu_browse_tms.png"); - gtk_widget_show (image2169); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_browse_teams), image2169); + image2210 = create_pixmap (main_window, "menu_browse_tms.png"); + gtk_widget_show (image2210); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_browse_teams), image2210); menu_player = gtk_menu_item_new_with_mnemonic (_("_Player")); gtk_widget_show (menu_player); @@ -769,57 +771,57 @@ create_main_window (void) gtk_widget_show (menu_show_info); gtk_container_add (GTK_CONTAINER (menu_player_menu), menu_show_info); - image2170 = create_pixmap (main_window, "menu_player_info.png"); - gtk_widget_show (image2170); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_show_info), image2170); + image2211 = create_pixmap (main_window, "menu_player_info.png"); + gtk_widget_show (image2211); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_show_info), image2211); menu_put_on_transfer_list = gtk_image_menu_item_new_with_mnemonic (_("Put on transfer list")); gtk_widget_show (menu_put_on_transfer_list); gtk_container_add (GTK_CONTAINER (menu_player_menu), menu_put_on_transfer_list); - image2171 = create_pixmap (main_window, "menu_player_put_transfer.png"); - gtk_widget_show (image2171); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_put_on_transfer_list), image2171); + image2212 = create_pixmap (main_window, "menu_player_put_transfer.png"); + gtk_widget_show (image2212); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_put_on_transfer_list), image2212); menu_remove_from_transfer_list = gtk_image_menu_item_new_with_mnemonic (_("Remove from transfer list")); gtk_widget_show (menu_remove_from_transfer_list); gtk_container_add (GTK_CONTAINER (menu_player_menu), menu_remove_from_transfer_list); - image2172 = create_pixmap (main_window, "menu_player_remove_transfer.png"); - gtk_widget_show (image2172); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_remove_from_transfer_list), image2172); + image2213 = create_pixmap (main_window, "menu_player_remove_transfer.png"); + gtk_widget_show (image2213); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_remove_from_transfer_list), image2213); menu_offer_new_contract = gtk_image_menu_item_new_with_mnemonic (_("Offer new contract")); gtk_widget_show (menu_offer_new_contract); gtk_container_add (GTK_CONTAINER (menu_player_menu), menu_offer_new_contract); - image2173 = create_pixmap (main_window, "menu_player_contract.png"); - gtk_widget_show (image2173); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_offer_new_contract), image2173); + image2214 = create_pixmap (main_window, "menu_player_contract.png"); + gtk_widget_show (image2214); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_offer_new_contract), image2214); menu_fire = gtk_image_menu_item_new_with_mnemonic (_("Fire")); gtk_widget_show (menu_fire); gtk_container_add (GTK_CONTAINER (menu_player_menu), menu_fire); - image2174 = create_pixmap (main_window, "menu_player_fire.png"); - gtk_widget_show (image2174); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_fire), image2174); + image2215 = create_pixmap (main_window, "menu_player_fire.png"); + gtk_widget_show (image2215); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_fire), image2215); menu_shoots_penalties = gtk_image_menu_item_new_with_mnemonic (_("Shoots penalties")); gtk_widget_show (menu_shoots_penalties); gtk_container_add (GTK_CONTAINER (menu_player_menu), menu_shoots_penalties); - image2175 = create_pixmap (main_window, "menu_player_shoots.png"); - gtk_widget_show (image2175); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_shoots_penalties), image2175); + image2216 = create_pixmap (main_window, "menu_player_shoots.png"); + gtk_widget_show (image2216); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_shoots_penalties), image2216); menu_move_to_youth_academy = gtk_image_menu_item_new_with_mnemonic (_("Move to youth academy")); gtk_widget_show (menu_move_to_youth_academy); gtk_container_add (GTK_CONTAINER (menu_player_menu), menu_move_to_youth_academy); - image2176 = create_pixmap (main_window, "menu_player_move_to_ya.png"); - gtk_widget_show (image2176); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_move_to_youth_academy), image2176); + image2217 = create_pixmap (main_window, "menu_player_move_to_ya.png"); + gtk_widget_show (image2217); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_move_to_youth_academy), image2217); trennlinie10 = gtk_separator_menu_item_new (); gtk_widget_show (trennlinie10); @@ -830,9 +832,9 @@ create_main_window (void) gtk_widget_show (menu_browse_players); gtk_container_add (GTK_CONTAINER (menu_player_menu), menu_browse_players); - image2177 = create_pixmap (main_window, "menu_player_browse.png"); - gtk_widget_show (image2177); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_browse_players), image2177); + image2218 = create_pixmap (main_window, "menu_player_browse.png"); + gtk_widget_show (image2218); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_browse_players), image2218); menu_user = gtk_menu_item_new_with_mnemonic (_("_User")); gtk_widget_show (menu_user); @@ -848,9 +850,9 @@ create_main_window (void) GDK_v, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); - image2178 = create_pixmap (main_window, "menu_last_match.png"); - gtk_widget_show (image2178); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_user_show_last_match), image2178); + image2219 = create_pixmap (main_window, "menu_last_match.png"); + gtk_widget_show (image2219); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_user_show_last_match), image2219); menu_user_show_last_stats = gtk_image_menu_item_new_with_mnemonic (_("Show last match stats")); gtk_widget_show (menu_user_show_last_stats); @@ -859,9 +861,9 @@ create_main_window (void) GDK_F2, 0, GTK_ACCEL_VISIBLE); - image2179 = create_pixmap (main_window, "menu_match_stats.png"); - gtk_widget_show (image2179); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_user_show_last_stats), image2179); + image2220 = create_pixmap (main_window, "menu_match_stats.png"); + gtk_widget_show (image2220); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_user_show_last_stats), image2220); menu_user_show_coming_matches = gtk_image_menu_item_new_with_mnemonic (_("Show coming matches")); gtk_widget_show (menu_user_show_coming_matches); @@ -870,17 +872,17 @@ create_main_window (void) GDK_F1, 0, GTK_ACCEL_VISIBLE); - image2180 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_MENU); - gtk_widget_show (image2180); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_user_show_coming_matches), image2180); + image2221 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_MENU); + gtk_widget_show (image2221); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_user_show_coming_matches), image2221); memorable_matches = gtk_image_menu_item_new_with_mnemonic (_("Memorable matches")); gtk_widget_show (memorable_matches); gtk_container_add (GTK_CONTAINER (menu_user_menu), memorable_matches); - image2181 = create_pixmap (main_window, "menu_mmatches.png"); - gtk_widget_show (image2181); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (memorable_matches), image2181); + image2222 = create_pixmap (main_window, "menu_mmatches.png"); + gtk_widget_show (image2222); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (memorable_matches), image2222); memorable_matches_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (memorable_matches), memorable_matches_menu); @@ -893,9 +895,9 @@ create_main_window (void) GDK_a, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); - image2182 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); - gtk_widget_show (image2182); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mm_add_last_match), image2182); + image2223 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); + gtk_widget_show (image2223); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mm_add_last_match), image2223); mm_manage_matches = gtk_image_menu_item_new_with_mnemonic (_("Manage matches")); gtk_widget_show (mm_manage_matches); @@ -905,9 +907,9 @@ create_main_window (void) GDK_m, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); - image2183 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU); - gtk_widget_show (image2183); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mm_manage_matches), image2183); + image2224 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU); + gtk_widget_show (image2224); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mm_manage_matches), image2224); trennlinie12 = gtk_separator_menu_item_new (); gtk_widget_show (trennlinie12); @@ -921,9 +923,9 @@ create_main_window (void) GDK_h, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); - image2184 = create_pixmap (main_window, "menu_history.png"); - gtk_widget_show (image2184); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_user_show_history), image2184); + image2225 = create_pixmap (main_window, "menu_history.png"); + gtk_widget_show (image2225); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_user_show_history), image2225); trennlinie9 = gtk_separator_menu_item_new (); gtk_widget_show (trennlinie9); @@ -937,9 +939,9 @@ create_main_window (void) GDK_F9, 0, GTK_ACCEL_VISIBLE); - image2185 = gtk_image_new_from_stock ("gtk-media-forward", GTK_ICON_SIZE_MENU); - gtk_widget_show (image2185); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_next_user), image2185); + image2226 = gtk_image_new_from_stock ("gtk-media-forward", GTK_ICON_SIZE_MENU); + gtk_widget_show (image2226); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_next_user), image2226); menu_previous_user = gtk_image_menu_item_new_with_mnemonic (_("Previous user")); gtk_widget_show (menu_previous_user); @@ -948,9 +950,9 @@ create_main_window (void) GDK_F8, 0, GTK_ACCEL_VISIBLE); - image2186 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU); - gtk_widget_show (image2186); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_previous_user), image2186); + image2227 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU); + gtk_widget_show (image2227); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_previous_user), image2227); menu_manage_users = gtk_image_menu_item_new_with_mnemonic (_("Manage users")); gtk_widget_show (menu_manage_users); @@ -959,9 +961,9 @@ create_main_window (void) GDK_F12, 0, GTK_ACCEL_VISIBLE); - image2187 = gtk_image_new_from_stock ("gtk-justify-fill", GTK_ICON_SIZE_MENU); - gtk_widget_show (image2187); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_manage_users), image2187); + image2228 = gtk_image_new_from_stock ("gtk-justify-fill", GTK_ICON_SIZE_MENU); + gtk_widget_show (image2228); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_manage_users), image2228); menu_finances_stadium = gtk_menu_item_new_with_mnemonic (_("Fin_Stad")); gtk_widget_show (menu_finances_stadium); @@ -977,9 +979,9 @@ create_main_window (void) GDK_f, 0, GTK_ACCEL_VISIBLE); - image2188 = create_pixmap (main_window, "menu_finances.png"); - gtk_widget_show (image2188); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_show_finances), image2188); + image2229 = create_pixmap (main_window, "menu_finances.png"); + gtk_widget_show (image2229); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_show_finances), image2229); menu_show_stadium = gtk_image_menu_item_new_with_mnemonic (_("Show stadium")); gtk_widget_show (menu_show_stadium); @@ -988,9 +990,22 @@ create_main_window (void) GDK_f, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); - image2189 = create_pixmap (main_window, "menu_stadium.png"); - gtk_widget_show (image2189); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_show_stadium), image2189); + image2230 = create_pixmap (main_window, "menu_stadium.png"); + gtk_widget_show (image2230); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_show_stadium), image2230); + + trennlinie15 = gtk_separator_menu_item_new (); + gtk_widget_show (trennlinie15); + gtk_container_add (GTK_CONTAINER (menu_finances_stadium_menu), trennlinie15); + gtk_widget_set_sensitive (trennlinie15, FALSE); + + menu_betting = gtk_menu_item_new_with_mnemonic (_("Betting")); + gtk_widget_show (menu_betting); + gtk_container_add (GTK_CONTAINER (menu_finances_stadium_menu), menu_betting); + gtk_tooltips_set_tip (tooltips, menu_betting, _("Show the betting window"), NULL); + gtk_widget_add_accelerator (menu_betting, "activate", accel_group, + GDK_b, 0, + GTK_ACCEL_VISIBLE); menu_help1 = gtk_menu_item_new_with_mnemonic (_("_Help")); gtk_widget_show (menu_help1); @@ -1003,25 +1018,25 @@ create_main_window (void) gtk_widget_show (menu_about); gtk_container_add (GTK_CONTAINER (menu_help1_menu), menu_about); - image2190 = gtk_image_new_from_stock ("gtk-dialog-info", GTK_ICON_SIZE_MENU); - gtk_widget_show (image2190); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_about), image2190); + image2231 = gtk_image_new_from_stock ("gtk-dialog-info", GTK_ICON_SIZE_MENU); + gtk_widget_show (image2231); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_about), image2231); menu_contributors = gtk_image_menu_item_new_with_mnemonic (_("Contributors")); gtk_widget_show (menu_contributors); gtk_container_add (GTK_CONTAINER (menu_help1_menu), menu_contributors); - image2191 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); - gtk_widget_show (image2191); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_contributors), image2191); + image2232 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); + gtk_widget_show (image2232); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_contributors), image2232); menu_help = gtk_image_menu_item_new_with_mnemonic (_("Help")); gtk_widget_show (menu_help); gtk_container_add (GTK_CONTAINER (menu_help1_menu), menu_help); - image2192 = gtk_image_new_from_stock ("gtk-help", GTK_ICON_SIZE_MENU); - gtk_widget_show (image2192); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_help), image2192); + image2233 = gtk_image_new_from_stock ("gtk-help", GTK_ICON_SIZE_MENU); + gtk_widget_show (image2233); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_help), image2233); hbox1 = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox1); @@ -1595,6 +1610,9 @@ create_main_window (void) g_signal_connect ((gpointer) menu_show_stadium, "activate", G_CALLBACK (on_menu_show_stadium_activate), NULL); + g_signal_connect ((gpointer) menu_betting, "activate", + G_CALLBACK (on_menu_betting_activate), + NULL); g_signal_connect ((gpointer) menu_about, "activate", G_CALLBACK (on_menu_about_activate), NULL); @@ -1665,7 +1683,7 @@ create_main_window (void) GLADE_HOOKUP_OBJECT (main_window, menu_new, "menu_new"); GLADE_HOOKUP_OBJECT (main_window, menu_open, "menu_open"); GLADE_HOOKUP_OBJECT (main_window, menu_load_last_save, "menu_load_last_save"); - GLADE_HOOKUP_OBJECT (main_window, image2151, "image2151"); + GLADE_HOOKUP_OBJECT (main_window, image2192, "image2192"); GLADE_HOOKUP_OBJECT (main_window, menu_save, "menu_save"); GLADE_HOOKUP_OBJECT (main_window, menu_save_as, "menu_save_as"); GLADE_HOOKUP_OBJECT (main_window, trennlinie1, "trennlinie1"); @@ -1673,35 +1691,35 @@ create_main_window (void) GLADE_HOOKUP_OBJECT (main_window, menu_options, "menu_options"); GLADE_HOOKUP_OBJECT (main_window, menu_options_menu, "menu_options_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_preferences, "menu_preferences"); - GLADE_HOOKUP_OBJECT (main_window, image2152, "image2152"); + GLADE_HOOKUP_OBJECT (main_window, image2193, "image2193"); GLADE_HOOKUP_OBJECT (main_window, trennlinie7, "trennlinie7"); GLADE_HOOKUP_OBJECT (main_window, menu_job_offers, "menu_job_offers"); GLADE_HOOKUP_OBJECT (main_window, menu_live_game, "menu_live_game"); GLADE_HOOKUP_OBJECT (main_window, menu_overwrite, "menu_overwrite"); GLADE_HOOKUP_OBJECT (main_window, trennlinie14, "trennlinie14"); GLADE_HOOKUP_OBJECT (main_window, menu_save_window_geometry, "menu_save_window_geometry"); - GLADE_HOOKUP_OBJECT (main_window, image2153, "image2153"); + GLADE_HOOKUP_OBJECT (main_window, image2194, "image2194"); GLADE_HOOKUP_OBJECT (main_window, menu_figures, "menu_figures"); GLADE_HOOKUP_OBJECT (main_window, menu_figures_menu, "menu_figures_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_fixtures_week, "menu_fixtures_week"); - GLADE_HOOKUP_OBJECT (main_window, image2154, "image2154"); + GLADE_HOOKUP_OBJECT (main_window, image2195, "image2195"); GLADE_HOOKUP_OBJECT (main_window, menu_fixtures, "menu_fixtures"); - GLADE_HOOKUP_OBJECT (main_window, image2155, "image2155"); + GLADE_HOOKUP_OBJECT (main_window, image2196, "image2196"); GLADE_HOOKUP_OBJECT (main_window, menu_tables, "menu_tables"); - GLADE_HOOKUP_OBJECT (main_window, image2156, "image2156"); + GLADE_HOOKUP_OBJECT (main_window, image2197, "image2197"); GLADE_HOOKUP_OBJECT (main_window, menu_my_league_results, "menu_my_league_results"); - GLADE_HOOKUP_OBJECT (main_window, image2157, "image2157"); + GLADE_HOOKUP_OBJECT (main_window, image2198, "image2198"); GLADE_HOOKUP_OBJECT (main_window, menu_season_results, "menu_season_results"); - GLADE_HOOKUP_OBJECT (main_window, image2158, "image2158"); + GLADE_HOOKUP_OBJECT (main_window, image2199, "image2199"); GLADE_HOOKUP_OBJECT (main_window, trennlinie13, "trennlinie13"); GLADE_HOOKUP_OBJECT (main_window, menu_league_stats, "menu_league_stats"); - GLADE_HOOKUP_OBJECT (main_window, image2159, "image2159"); + GLADE_HOOKUP_OBJECT (main_window, image2200, "image2200"); GLADE_HOOKUP_OBJECT (main_window, menu_season_history, "menu_season_history"); - GLADE_HOOKUP_OBJECT (main_window, image2160, "image2160"); + GLADE_HOOKUP_OBJECT (main_window, image2201, "image2201"); GLADE_HOOKUP_OBJECT (main_window, menu_team, "menu_team"); GLADE_HOOKUP_OBJECT (main_window, menu_team_menu, "menu_team_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_playing_style, "menu_playing_style"); - GLADE_HOOKUP_OBJECT (main_window, image2161, "image2161"); + GLADE_HOOKUP_OBJECT (main_window, image2202, "image2202"); GLADE_HOOKUP_OBJECT (main_window, menu_playing_style_menu, "menu_playing_style_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_all_out_defend, "menu_all_out_defend"); GLADE_HOOKUP_OBJECT (main_window, menu_defend, "menu_defend"); @@ -1709,21 +1727,21 @@ create_main_window (void) GLADE_HOOKUP_OBJECT (main_window, menu_attack, "menu_attack"); GLADE_HOOKUP_OBJECT (main_window, menu_all_out_attack, "menu_all_out_attack"); GLADE_HOOKUP_OBJECT (main_window, menu_scout, "menu_scout"); - GLADE_HOOKUP_OBJECT (main_window, image2162, "image2162"); + GLADE_HOOKUP_OBJECT (main_window, image2203, "image2203"); GLADE_HOOKUP_OBJECT (main_window, menu_scout_menu, "menu_scout_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_scout_best, "menu_scout_best"); GLADE_HOOKUP_OBJECT (main_window, menu_scout_good, "menu_scout_good"); GLADE_HOOKUP_OBJECT (main_window, menu_scout_average, "menu_scout_average"); GLADE_HOOKUP_OBJECT (main_window, menu_scout_bad, "menu_scout_bad"); GLADE_HOOKUP_OBJECT (main_window, menu_physio, "menu_physio"); - GLADE_HOOKUP_OBJECT (main_window, image2163, "image2163"); + GLADE_HOOKUP_OBJECT (main_window, image2204, "image2204"); GLADE_HOOKUP_OBJECT (main_window, menu_physio_menu, "menu_physio_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_physio_best, "menu_physio_best"); GLADE_HOOKUP_OBJECT (main_window, menu_physio_good, "menu_physio_good"); GLADE_HOOKUP_OBJECT (main_window, menu_physio_average, "menu_physio_average"); GLADE_HOOKUP_OBJECT (main_window, menu_physio_bad, "menu_physio_bad"); GLADE_HOOKUP_OBJECT (main_window, menu_youth_academy, "menu_youth_academy"); - GLADE_HOOKUP_OBJECT (main_window, image2164, "image2164"); + GLADE_HOOKUP_OBJECT (main_window, image2205, "image2205"); GLADE_HOOKUP_OBJECT (main_window, menu_youth_academy_menu, "menu_youth_academy_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_show_youth_academy, "menu_show_youth_academy"); GLADE_HOOKUP_OBJECT (main_window, youth_coach1, "youth_coach1"); @@ -1741,79 +1759,81 @@ create_main_window (void) GLADE_HOOKUP_OBJECT (main_window, menu_recruit4, "menu_recruit4"); GLADE_HOOKUP_OBJECT (main_window, menu_set_investment, "menu_set_investment"); GLADE_HOOKUP_OBJECT (main_window, menu_boost, "menu_boost"); - GLADE_HOOKUP_OBJECT (main_window, image2165, "image2165"); + GLADE_HOOKUP_OBJECT (main_window, image2206, "image2206"); GLADE_HOOKUP_OBJECT (main_window, menu_boost_menu, "menu_boost_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_boost_on, "menu_boost_on"); GLADE_HOOKUP_OBJECT (main_window, menu_boost_off, "menu_boost_off"); GLADE_HOOKUP_OBJECT (main_window, menu_boost_anti, "menu_boost_anti"); GLADE_HOOKUP_OBJECT (main_window, trennlinie11, "trennlinie11"); GLADE_HOOKUP_OBJECT (main_window, menu_reset_players, "menu_reset_players"); - GLADE_HOOKUP_OBJECT (main_window, image2166, "image2166"); + GLADE_HOOKUP_OBJECT (main_window, image2207, "image2207"); GLADE_HOOKUP_OBJECT (main_window, menu_custom_structure, "menu_custom_structure"); - GLADE_HOOKUP_OBJECT (main_window, image2167, "image2167"); + GLADE_HOOKUP_OBJECT (main_window, image2208, "image2208"); GLADE_HOOKUP_OBJECT (main_window, menu_rearrange_team, "menu_rearrange_team"); - GLADE_HOOKUP_OBJECT (main_window, image2168, "image2168"); + GLADE_HOOKUP_OBJECT (main_window, image2209, "image2209"); GLADE_HOOKUP_OBJECT (main_window, trennlinie8, "trennlinie8"); GLADE_HOOKUP_OBJECT (main_window, menu_browse_teams, "menu_browse_teams"); - GLADE_HOOKUP_OBJECT (main_window, image2169, "image2169"); + GLADE_HOOKUP_OBJECT (main_window, image2210, "image2210"); GLADE_HOOKUP_OBJECT (main_window, menu_player, "menu_player"); GLADE_HOOKUP_OBJECT (main_window, menu_player_menu, "menu_player_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_show_info, "menu_show_info"); - GLADE_HOOKUP_OBJECT (main_window, image2170, "image2170"); + GLADE_HOOKUP_OBJECT (main_window, image2211, "image2211"); GLADE_HOOKUP_OBJECT (main_window, menu_put_on_transfer_list, "menu_put_on_transfer_list"); - GLADE_HOOKUP_OBJECT (main_window, image2171, "image2171"); + GLADE_HOOKUP_OBJECT (main_window, image2212, "image2212"); GLADE_HOOKUP_OBJECT (main_window, menu_remove_from_transfer_list, "menu_remove_from_transfer_list"); - GLADE_HOOKUP_OBJECT (main_window, image2172, "image2172"); + GLADE_HOOKUP_OBJECT (main_window, image2213, "image2213"); GLADE_HOOKUP_OBJECT (main_window, menu_offer_new_contract, "menu_offer_new_contract"); - GLADE_HOOKUP_OBJECT (main_window, image2173, "image2173"); + GLADE_HOOKUP_OBJECT (main_window, image2214, "image2214"); GLADE_HOOKUP_OBJECT (main_window, menu_fire, "menu_fire"); - GLADE_HOOKUP_OBJECT (main_window, image2174, "image2174"); + GLADE_HOOKUP_OBJECT (main_window, image2215, "image2215"); GLADE_HOOKUP_OBJECT (main_window, menu_shoots_penalties, "menu_shoots_penalties"); - GLADE_HOOKUP_OBJECT (main_window, image2175, "image2175"); + GLADE_HOOKUP_OBJECT (main_window, image2216, "image2216"); GLADE_HOOKUP_OBJECT (main_window, menu_move_to_youth_academy, "menu_move_to_youth_academy"); - GLADE_HOOKUP_OBJECT (main_window, image2176, "image2176"); + GLADE_HOOKUP_OBJECT (main_window, image2217, "image2217"); GLADE_HOOKUP_OBJECT (main_window, trennlinie10, "trennlinie10"); GLADE_HOOKUP_OBJECT (main_window, menu_browse_players, "menu_browse_players"); - GLADE_HOOKUP_OBJECT (main_window, image2177, "image2177"); + GLADE_HOOKUP_OBJECT (main_window, image2218, "image2218"); GLADE_HOOKUP_OBJECT (main_window, menu_user, "menu_user"); GLADE_HOOKUP_OBJECT (main_window, menu_user_menu, "menu_user_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_user_show_last_match, "menu_user_show_last_match"); - GLADE_HOOKUP_OBJECT (main_window, image2178, "image2178"); + GLADE_HOOKUP_OBJECT (main_window, image2219, "image2219"); GLADE_HOOKUP_OBJECT (main_window, menu_user_show_last_stats, "menu_user_show_last_stats"); - GLADE_HOOKUP_OBJECT (main_window, image2179, "image2179"); + GLADE_HOOKUP_OBJECT (main_window, image2220, "image2220"); GLADE_HOOKUP_OBJECT (main_window, menu_user_show_coming_matches, "menu_user_show_coming_matches"); - GLADE_HOOKUP_OBJECT (main_window, image2180, "image2180"); + GLADE_HOOKUP_OBJECT (main_window, image2221, "image2221"); GLADE_HOOKUP_OBJECT (main_window, memorable_matches, "memorable_matches"); - GLADE_HOOKUP_OBJECT (main_window, image2181, "image2181"); + GLADE_HOOKUP_OBJECT (main_window, image2222, "image2222"); GLADE_HOOKUP_OBJECT (main_window, memorable_matches_menu, "memorable_matches_menu"); GLADE_HOOKUP_OBJECT (main_window, mm_add_last_match, "mm_add_last_match"); - GLADE_HOOKUP_OBJECT (main_window, image2182, "image2182"); + GLADE_HOOKUP_OBJECT (main_window, image2223, "image2223"); GLADE_HOOKUP_OBJECT (main_window, mm_manage_matches, "mm_manage_matches"); - GLADE_HOOKUP_OBJECT (main_window, image2183, "image2183"); + GLADE_HOOKUP_OBJECT (main_window, image2224, "image2224"); GLADE_HOOKUP_OBJECT (main_window, trennlinie12, "trennlinie12"); GLADE_HOOKUP_OBJECT (main_window, menu_user_show_history, "menu_user_show_history"); - GLADE_HOOKUP_OBJECT (main_window, image2184, "image2184"); + GLADE_HOOKUP_OBJECT (main_window, image2225, "image2225"); GLADE_HOOKUP_OBJECT (main_window, trennlinie9, "trennlinie9"); GLADE_HOOKUP_OBJECT (main_window, menu_next_user, "menu_next_user"); - GLADE_HOOKUP_OBJECT (main_window, image2185, "image2185"); + GLADE_HOOKUP_OBJECT (main_window, image2226, "image2226"); GLADE_HOOKUP_OBJECT (main_window, menu_previous_user, "menu_previous_user"); - GLADE_HOOKUP_OBJECT (main_window, image2186, "image2186"); + GLADE_HOOKUP_OBJECT (main_window, image2227, "image2227"); GLADE_HOOKUP_OBJECT (main_window, menu_manage_users, "menu_manage_users"); - GLADE_HOOKUP_OBJECT (main_window, image2187, "image2187"); + GLADE_HOOKUP_OBJECT (main_window, image2228, "image2228"); GLADE_HOOKUP_OBJECT (main_window, menu_finances_stadium, "menu_finances_stadium"); GLADE_HOOKUP_OBJECT (main_window, menu_finances_stadium_menu, "menu_finances_stadium_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_show_finances, "menu_show_finances"); - GLADE_HOOKUP_OBJECT (main_window, image2188, "image2188"); + GLADE_HOOKUP_OBJECT (main_window, image2229, "image2229"); GLADE_HOOKUP_OBJECT (main_window, menu_show_stadium, "menu_show_stadium"); - GLADE_HOOKUP_OBJECT (main_window, image2189, "image2189"); + GLADE_HOOKUP_OBJECT (main_window, image2230, "image2230"); + GLADE_HOOKUP_OBJECT (main_window, trennlinie15, "trennlinie15"); + GLADE_HOOKUP_OBJECT (main_window, menu_betting, "menu_betting"); GLADE_HOOKUP_OBJECT (main_window, menu_help1, "menu_help1"); GLADE_HOOKUP_OBJECT (main_window, menu_help1_menu, "menu_help1_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_about, "menu_about"); - GLADE_HOOKUP_OBJECT (main_window, image2190, "image2190"); + GLADE_HOOKUP_OBJECT (main_window, image2231, "image2231"); GLADE_HOOKUP_OBJECT (main_window, menu_contributors, "menu_contributors"); - GLADE_HOOKUP_OBJECT (main_window, image2191, "image2191"); + GLADE_HOOKUP_OBJECT (main_window, image2232, "image2232"); GLADE_HOOKUP_OBJECT (main_window, menu_help, "menu_help"); - GLADE_HOOKUP_OBJECT (main_window, image2192, "image2192"); + GLADE_HOOKUP_OBJECT (main_window, image2233, "image2233"); GLADE_HOOKUP_OBJECT (main_window, hbox1, "hbox1"); GLADE_HOOKUP_OBJECT (main_window, button_load, "button_load"); GLADE_HOOKUP_OBJECT (main_window, image11, "image11"); diff --git a/src/live_game.c b/src/live_game.c index 7cb3982b..90e63d2c 100644 --- a/src/live_game.c +++ b/src/live_game.c @@ -438,7 +438,7 @@ void live_game_event_injury(gint team, gint player, gboolean create_new) { LiveGameUnit new; - gint old_structure = -1; + gint old_structure = -1, sub_in = -1; if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || debug > 130) @@ -496,18 +496,20 @@ live_game_event_injury(gint team, gint player, gboolean create_new) misc_callback_pause_live_game(); else if(tm[last_unit.event.team]->players->len > 11) { - old_structure = tm[last_unit.event.team]->structure; - live_game_event_substitution( - last_unit.event.team, - game_substitute_player( - tm[last_unit.event.team], - player_id_index(tm[last_unit.event.team], - last_unit.event.player)), - last_unit.event.player); - + sub_in = game_substitute_player(tm[last_unit.event.team], + player_id_index(tm[last_unit.event.team], + last_unit.event.player)); + if(sub_in != -1) + { + old_structure = tm[last_unit.event.team]->structure; + live_game_event_substitution( + last_unit.event.team, sub_in, + last_unit.event.player); + if(old_structure != tm[last_unit.event.team]->structure) live_game_event_team_change(last_unit.event.team, LIVE_GAME_EVENT_STRUCTURE_CHANGE); + } } } } @@ -1400,7 +1402,8 @@ live_game_finish_unit(void) if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || debug > 130) - printf("OOOO1 idx %d type %d poss %d team %d pl %d %d\n", unis->len - 1, + printf("OOOO1 idx %d min %d type %d poss %d team %d pl %d %d\n", unis->len - 1, + unit->minute, unit->event.type, unit->possession, unit->event.team, unit->event.player, unit->event.player2); @@ -1556,6 +1559,8 @@ live_game_reset(LiveGame *live_game, Fixture *fix, gboolean free_variable) free_live_game(live_game); live_game->units = g_array_new(FALSE, FALSE, sizeof(LiveGameUnit)); + live_game->action_ids[0] = g_array_new(FALSE, FALSE, sizeof(gint)); + live_game->action_ids[1] = g_array_new(FALSE, FALSE, sizeof(gint)); for(i=0;i #include +#include "bet_struct.h" +#include "debug.h" #include "file.h" #include "free.h" #include "language.h" @@ -40,6 +42,7 @@ #include "misc_callbacks.h" #include "name_struct.h" #include "option.h" +#include "start_end.h" #include "stat_struct.h" #include "strategy_struct.h" #include "transfer_struct.h" @@ -55,11 +58,12 @@ gboolean load_last_save; void main_parse_cl_arguments(gint *argc, gchar ***argv) { - gboolean testcom = FALSE; + gboolean testcom = FALSE, calodds = FALSE; gchar *support_dir = NULL, *lang = NULL, *testcom_file = NULL, *token_file = NULL, *event_name = NULL; - gint deb_level = -1, number_of_passes = 1; + gint deb_level = -1, number_of_passes = 1, + num_matches = 100, skilldiffmax = 20; GError *error = NULL; GOptionContext *context = NULL; GOptionEntry entries[] = @@ -86,6 +90,15 @@ main_parse_cl_arguments(gint *argc, gchar ***argv) { "num-passes", 'n', 0, G_OPTION_ARG_INT, &number_of_passes, _("How many commentaries to generate per event"), "N" }, + { "calodds", 'o', 0, G_OPTION_ARG_NONE, &calodds, + _("Calibrate the betting odds by simulating a lot of matches"), NULL }, + + { "num-matches", 'm', 0, G_OPTION_ARG_INT, &num_matches, + _("How many matches to simulate per skill diff step"), "N" }, + + { "num-skilldiff", 'S', 0, G_OPTION_ARG_INT, &skilldiffmax, + _("How many skill diff steps to take"), "N" }, + {NULL}}; if(argc == NULL || argv == NULL) @@ -99,6 +112,15 @@ main_parse_cl_arguments(gint *argc, gchar ***argv) misc_print_error(&error, TRUE); + if(calodds) + { + option_add(&options, "int_opt_calodds", 1, NULL); + option_add(&options, "int_opt_calodds_skilldiffmax", skilldiffmax, NULL); + option_add(&options, "int_opt_calodds_matches", num_matches, NULL); + } + else + option_add(&options, "int_opt_calodds", 0, NULL); + if(testcom) { lg_commentary_test(testcom_file, token_file, event_name, number_of_passes); @@ -149,7 +171,7 @@ main_init_variables(void) window.options = window.font_sel = window.file_chooser = window.contract = window.menu_player = window.user_management = - window.mmatches = NULL; + window.mmatches = window.bets = NULL; live_game_reset(&live_game_temp, NULL, FALSE); @@ -158,6 +180,8 @@ main_init_variables(void) season_stats = g_array_new(FALSE, FALSE, sizeof(SeasonStat)); name_lists = g_array_new(FALSE, FALSE, sizeof(NameList)); strategies = g_array_new(FALSE, FALSE, sizeof(Strategy)); + bets[0] = g_array_new(FALSE, FALSE, sizeof(BetMatch)); + bets[1] = g_array_new(FALSE, FALSE, sizeof(BetMatch)); save_file = NULL; diff --git a/src/misc.c b/src/misc.c index 3778b211..56221c57 100644 --- a/src/misc.c +++ b/src/misc.c @@ -532,7 +532,7 @@ misc_string_replace_expressions(gchar *string) printf("misc_string_replace_expressions: #%s#\n", string); - if(!g_strrstr(string, "[")) + if(g_strrstr(string, "[") == NULL) return; strcpy(buf, string); @@ -605,15 +605,54 @@ misc_string_replace_tokens(gchar *string, GPtrArray **token_rep) (gchar*)g_ptr_array_index(token_rep[1], i)); } +/** Replace the portion 'paren' plus parentheses in the string. */ +void +misc_string_replace_parenthesised(gchar *string, const gchar *paren, + const gchar *replacement) +{ + gchar buf[SMALL]; + + sprintf(buf, "(%s)", paren); + + misc_string_replace_token(string, buf, replacement); +} + +/** Find the innermost parenthesised portion of the string + and write it into the dest string. */ +void +misc_string_get_parenthesised(const gchar *string, gchar *dest) +{ + const gchar *openpar = g_strrstr(string, "("); + const gchar *closepar = g_strstr_len(string, strlen(string), ")"); + gint len = strlen(openpar) - strlen(closepar) - 1; + + strncpy(dest, openpar + 1, len); + dest[len] = '\0'; + + printf("getpar %s\n", dest); +} + /** Find out whether the conditions in the string are fulfilled. */ gboolean misc_parse_condition(const gchar *condition, GPtrArray **token_rep) { gboolean return_value = FALSE; gchar buf[SMALL], buf2[SMALL]; + + if(condition == NULL) + return TRUE; strcpy(buf, condition); + while(g_strrstr(buf, "(")) + { + misc_string_get_parenthesised(buf, buf2); + if(misc_parse_condition(buf2, token_rep)) + misc_string_replace_parenthesised(buf, buf2, "1 = 1"); + else + misc_string_replace_parenthesised(buf, buf2, "1 = 2"); + } + do { strcpy(buf2, buf); diff --git a/src/misc.h b/src/misc.h index d8253099..5006a1f2 100644 --- a/src/misc.h +++ b/src/misc.h @@ -27,6 +27,7 @@ #include "bygfoot.h" #define misc_int_to_char(number) g_strdup_printf("%d", number) +#define query_misc_string_contains(haystack, needle) (g_strstr_len(haystack, strlen(haystack), needle) != NULL) void misc_print_error(GError **error, gboolean abort_program); @@ -55,9 +56,6 @@ misc_int_compare(gint first, gint second); gint misc_float_compare(gfloat first, gfloat second); -gboolean -query_misc_string_contains(const gchar *string, const gchar *text); - gboolean query_misc_string_in_array(const gchar *string, GPtrArray *array); @@ -117,5 +115,11 @@ misc_token_add(GPtrArray **token_rep, gint token_idx, void misc_token_remove(GPtrArray **token_rep, gint idx); +void +misc_string_get_parenthesised(const gchar *string, gchar *dest); + +void +misc_string_replace_parenthesised(gchar *string, const gchar *paren, + const gchar *replacement); #endif diff --git a/src/misc2_callbacks.c b/src/misc2_callbacks.c index 849f871a..98404be9 100644 --- a/src/misc2_callbacks.c +++ b/src/misc2_callbacks.c @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "bet.h" #include "callbacks.h" #include "callback_func.h" #include "debug.h" @@ -146,10 +147,13 @@ on_button_digits_ok_clicked (GtkButton *button, case STATUS_SET_YA_PERCENTAGE: current_user.youth_academy.percentage = values[1]; break; + case STATUS_PLACE_BET: + bet_place((Fixture*)statp, stat2, values[0]); + break; } if(destroy_window) - window_destroy(&window.digits, TRUE); + window_destroy(&window.digits, FALSE); game_gui_set_main_window_header(); @@ -161,9 +165,7 @@ void on_button_digits_cancel_clicked (GtkButton *button, gpointer user_data) { - window_destroy(&window.digits, TRUE); - if(stat0 == STATUS_LIVE_GAME_PAUSE) - gtk_widget_set_sensitive(window.main, TRUE); + window_destroy(&window.digits, FALSE); } gboolean diff --git a/src/misc2_interface.c b/src/misc2_interface.c index dadf4fa1..fd3d325e 100644 --- a/src/misc2_interface.c +++ b/src/misc2_interface.c @@ -1,26 +1,3 @@ -/* - Bygfoot Football Manager -- a small and simple GTK2-based - football management game. - - http://bygfoot.sourceforge.net - - Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - /* * DO NOT EDIT THIS FILE - it is generated by Glade. */ @@ -401,6 +378,7 @@ create_window_digits (void) window_digits = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width (GTK_CONTAINER (window_digits), 5); gtk_window_set_position (GTK_WINDOW (window_digits), GTK_WIN_POS_CENTER); + gtk_window_set_modal (GTK_WINDOW (window_digits), TRUE); vbox14 = gtk_vbox_new (FALSE, 10); gtk_widget_show (vbox14); diff --git a/src/misc2_interface.h b/src/misc2_interface.h index 0a5aba1c..db5bf74b 100644 --- a/src/misc2_interface.h +++ b/src/misc2_interface.h @@ -1,26 +1,3 @@ -/* - Bygfoot Football Manager -- a small and simple GTK2-based - football management game. - - http://bygfoot.sourceforge.net - - Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - /* * DO NOT EDIT THIS FILE - it is generated by Glade. */ diff --git a/src/misc_callback_func.c b/src/misc_callback_func.c index 03d09d00..95cc8293 100644 --- a/src/misc_callback_func.c +++ b/src/misc_callback_func.c @@ -22,11 +22,14 @@ */ #include "callbacks.h" +#include "debug.h" #include "finance.h" +#include "free.h" #include "game.h" #include "game_gui.h" #include "gui.h" #include "load_save.h" +#include "main.h" #include "maths.h" #include "misc.h" #include "misc_callback_func.h" @@ -84,15 +87,24 @@ misc_callback_start_game(void) opt_set_int("int_opt_load_defs", 0); start_new_game(); - - for(i=0;ilen;i++) - user_set_up_team_new_game(&usr(i)); - window_destroy(&window.startup, TRUE); - window_create(WINDOW_MAIN); - - game_gui_show_main(); + if(!opt_int("int_opt_calodds")) + { + for(i=0;ilen;i++) + user_set_up_team_new_game(&usr(i)); + + window_create(WINDOW_MAIN); + + game_gui_show_main(); + } + else + { + free_users(TRUE); + debug_calibrate_betting_odds(opt_int("int_opt_calodds_skilldiffmax"), + opt_int("int_opt_calodds_matches")); + main_exit_program(EXIT_OK, NULL); + } } /** Add a user to the users array. */ diff --git a/src/option_gui.c b/src/option_gui.c index 42fbbe9b..05b319f3 100644 --- a/src/option_gui.c +++ b/src/option_gui.c @@ -55,6 +55,9 @@ enum BooleanOptions BOOL_OPT_SWAP, BOOL_OPT_SHOW_OVERALL, BOOL_OPT_SHOW_ALL_LEAGUES, + BOOL_OPT_BET_SHOW_ALL_LEAGUES, + BOOL_OPT_BET_SHOW_CUPS, + BOOL_OPT_BET_SHOW_MY_RECENT, BOOL_OPT_PL1_ATT_NAME, BOOL_OPT_PL1_ATT_CPOS, BOOL_OPT_PL1_ATT_POS, @@ -171,6 +174,18 @@ option_gui_write_bool_widgets(gint **bool_options, GtkToggleButton **bool_widget GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_show_all_leagues")); bool_options[BOOL_OPT_SHOW_ALL_LEAGUES] = opt_user_intp("int_opt_user_show_all_leagues"); + bool_widgets[BOOL_OPT_BET_SHOW_ALL_LEAGUES] = + GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_bet_show_all_leagues")); + bool_options[BOOL_OPT_BET_SHOW_ALL_LEAGUES] = opt_user_intp("int_opt_user_bet_show_all_leagues"); + + bool_widgets[BOOL_OPT_BET_SHOW_CUPS] = + GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_bet_show_cups")); + bool_options[BOOL_OPT_BET_SHOW_CUPS] = opt_user_intp("int_opt_user_bet_show_cups"); + + bool_widgets[BOOL_OPT_BET_SHOW_MY_RECENT] = + GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_bet_show_only_recent")); + bool_options[BOOL_OPT_BET_SHOW_MY_RECENT] = opt_user_intp("int_opt_user_bet_show_my_recent"); + bool_widgets[BOOL_OPT_PL1_ATT_NAME] = GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton1")); bool_options[BOOL_OPT_PL1_ATT_NAME] = opt_user_intp("int_opt_user_pl1_att_name"); diff --git a/src/options_interface.c b/src/options_interface.c index d2897f03..c388f0e1 100644 --- a/src/options_interface.c +++ b/src/options_interface.c @@ -1,26 +1,3 @@ -/* - Bygfoot Football Manager -- a small and simple GTK2-based - football management game. - - http://bygfoot.sourceforge.net - - Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - /* * DO NOT EDIT THIS FILE - it is generated by Glade. */ @@ -193,6 +170,12 @@ create_window_options (void) GtkWidget *label33; GtkWidget *hseparator2; GtkWidget *label4; + GtkWidget *hbox11; + GtkWidget *vbox8; + GtkWidget *checkbutton_bet_show_all_leagues; + GtkWidget *checkbutton_bet_show_cups; + GtkWidget *checkbutton_bet_show_only_recent; + GtkWidget *label41; GtkWidget *hseparator1; GtkWidget *hbox1; GtkWidget *vbox2; @@ -974,6 +957,33 @@ create_window_options (void) gtk_widget_show (label4); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 3), label4); + hbox11 = gtk_hbox_new (FALSE, 0); + gtk_widget_show (hbox11); + gtk_container_add (GTK_CONTAINER (notebook1), hbox11); + + vbox8 = gtk_vbox_new (FALSE, 0); + gtk_widget_show (vbox8); + gtk_box_pack_start (GTK_BOX (hbox11), vbox8, TRUE, TRUE, 0); + + checkbutton_bet_show_all_leagues = gtk_check_button_new_with_mnemonic (_("Show matches from all leagues")); + gtk_widget_show (checkbutton_bet_show_all_leagues); + gtk_box_pack_start (GTK_BOX (vbox8), checkbutton_bet_show_all_leagues, FALSE, FALSE, 0); + gtk_tooltips_set_tip (tooltips, checkbutton_bet_show_all_leagues, _("Whether to show matches of all leagues in the betting window"), NULL); + + checkbutton_bet_show_cups = gtk_check_button_new_with_mnemonic (_("Show matches from cups")); + gtk_widget_show (checkbutton_bet_show_cups); + gtk_box_pack_start (GTK_BOX (vbox8), checkbutton_bet_show_cups, FALSE, FALSE, 0); + gtk_tooltips_set_tip (tooltips, checkbutton_bet_show_cups, _("Whether to show cup matches in the betting window"), NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_bet_show_cups), TRUE); + + checkbutton_bet_show_only_recent = gtk_check_button_new_with_mnemonic (_("Show only my recent bets")); + gtk_widget_show (checkbutton_bet_show_only_recent); + gtk_box_pack_start (GTK_BOX (vbox8), checkbutton_bet_show_only_recent, FALSE, FALSE, 0); + + label41 = gtk_label_new (_("Betting")); + gtk_widget_show (label41); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 4), label41); + hseparator1 = gtk_hseparator_new (); gtk_widget_show (hseparator1); gtk_box_pack_start (GTK_BOX (vbox1), hseparator1, FALSE, FALSE, 0); @@ -1166,6 +1176,12 @@ create_window_options (void) GLADE_HOOKUP_OBJECT (window_options, label33, "label33"); GLADE_HOOKUP_OBJECT (window_options, hseparator2, "hseparator2"); GLADE_HOOKUP_OBJECT (window_options, label4, "label4"); + GLADE_HOOKUP_OBJECT (window_options, hbox11, "hbox11"); + GLADE_HOOKUP_OBJECT (window_options, vbox8, "vbox8"); + GLADE_HOOKUP_OBJECT (window_options, checkbutton_bet_show_all_leagues, "checkbutton_bet_show_all_leagues"); + GLADE_HOOKUP_OBJECT (window_options, checkbutton_bet_show_cups, "checkbutton_bet_show_cups"); + GLADE_HOOKUP_OBJECT (window_options, checkbutton_bet_show_only_recent, "checkbutton_bet_show_only_recent"); + GLADE_HOOKUP_OBJECT (window_options, label41, "label41"); GLADE_HOOKUP_OBJECT (window_options, hseparator1, "hseparator1"); GLADE_HOOKUP_OBJECT (window_options, hbox1, "hbox1"); GLADE_HOOKUP_OBJECT (window_options, vbox2, "vbox2"); diff --git a/src/options_interface.h b/src/options_interface.h index 57cc6f7a..4506878d 100644 --- a/src/options_interface.h +++ b/src/options_interface.h @@ -1,26 +1,3 @@ -/* - Bygfoot Football Manager -- a small and simple GTK2-based - football management game. - - http://bygfoot.sourceforge.net - - Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - /* * DO NOT EDIT THIS FILE - it is generated by Glade. */ diff --git a/src/start_end.c b/src/start_end.c index ae754db8..bc794a19 100644 --- a/src/start_end.c +++ b/src/start_end.c @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "bet.h" #include "cup.h" #include "file.h" #include "finance.h" @@ -59,7 +60,7 @@ WeekFunc end_week_round_funcs[] = /** Array of functions called when a week round is started. */ WeekFunc start_week_round_funcs[] = -{start_week_round_update_teams , NULL}; +{start_week_round_update_teams, bet_update, NULL}; /** Array of functions called when a week is started. */ @@ -160,6 +161,9 @@ start_new_season(void) for(i=0;ilen;i++) name_shorten_list(&nli(i)); + + if(season == 1) + bet_update(); } /** Fill some global variables with default values at the diff --git a/src/strategy.c b/src/strategy.c index 0e83e29d..fa7e8bdb 100644 --- a/src/strategy.c +++ b/src/strategy.c @@ -273,8 +273,7 @@ strategy_update_team_pre_match(Team *tm) strategy_set_tokens(tm, NULL); for(i=prematches->len - 1; i >= 0; i--) - if(g_array_index(prematches, StrategyPrematch, i).condition == NULL || - misc_parse_condition(g_array_index(prematches, StrategyPrematch, i).condition, + if(misc_parse_condition(g_array_index(prematches, StrategyPrematch, i).condition, token_strat)) { strategy_apply_prematch(tm, &g_array_index(prematches, StrategyPrematch, i)); @@ -425,39 +424,64 @@ strategy_compare_players_sub(gconstpointer a, gfloat skill1, skill2; const Player *pl1 = *(const Player**)a; const Player *pl2 = *(const Player**)b; - gint type = GPOINTER_TO_INT(user_data); + gint position = GPOINTER_TO_INT(user_data) % 10; + gint property = (GPOINTER_TO_INT(user_data) - position) / 10; gint return_value = 0; - switch(type) - { - default: - g_warning("strategy_compare_players_sub: unknown type %d\n", - type); - return_value = 0; - break; - case STRAT_LINEUP_FITTEST: - return_value = misc_float_compare(pl1->fitness, - pl2->fitness); - break; - case STRAT_LINEUP_UNFITTEST: - return_value = misc_float_compare(pl2->fitness, - pl1->fitness); - break; - case STRAT_LINEUP_BEST: - skill1 = player_get_game_skill(pl1, TRUE); - skill2 = player_get_game_skill(pl2, TRUE); - return_value = misc_float_compare(skill1, skill2); - break; - case STRAT_LINEUP_WEAKEST: - skill1 = player_get_game_skill(pl1, TRUE); - skill2 = player_get_game_skill(pl2, TRUE); - return_value = misc_float_compare(skill2, skill1); - break; - } + if(pl1->pos != pl2->pos && + (pl1->pos == position || pl2->pos == position)) + return_value = (pl1->pos == position) ? -1 : 1; + else + switch(property) + { + default: + g_warning("strategy_compare_players_sub: unknown property %d\n", + property); + return_value = 0; + break; + case STRAT_LINEUP_FITTEST: + return_value = misc_float_compare(pl1->fitness, + pl2->fitness); + break; + case STRAT_LINEUP_UNFITTEST: + return_value = misc_float_compare(pl2->fitness, + pl1->fitness); + break; + case STRAT_LINEUP_BEST: + skill1 = player_get_game_skill(pl1, TRUE); + skill2 = player_get_game_skill(pl2, TRUE); + return_value = misc_float_compare(skill1, skill2); + break; + case STRAT_LINEUP_WEAKEST: + skill1 = player_get_game_skill(pl1, TRUE); + skill2 = player_get_game_skill(pl2, TRUE); + return_value = misc_float_compare(skill2, skill1); + break; + } return return_value; } +/** Compare two player positions, taking into account the number + of players playing the position in the team. */ +gint +strategy_compare_positions(gconstpointer a, + gconstpointer b, + gpointer user_data) +{ + gint i, pos[4] = {0, 0, 0, 0}; + gint pos1 = *(gint*)a, + pos2 = *(gint*)b; + const Team *tm = (const Team*)user_data; + + for(i=0;i<11;i++) + if(player_of_idx_team(tm, i)->cskill > 0 && + player_is_banned(player_of_idx_team(tm, i)) <= 0) + pos[player_of_idx_team(tm, i)->pos]++; + + return misc_int_compare(pos[pos1], pos[pos2]); +} + /** Find an appropriate player to send out or in. @param tm The team we work with. @param position The position of the player we seek. @@ -471,10 +495,28 @@ strategy_get_sub(const Team *tm, gint position, stop = (sub_in) ? tm->players->len : 11; GPtrArray *players = g_ptr_array_new(); gint return_value = -1; + GArray *positions = g_array_new(FALSE, FALSE, sizeof(gint)); + + if(position < 90) + g_array_append_val(positions, position); + else + { + while(position >= 90) + { + i = math_get_place(position, 1); + g_array_append_val(positions, i); + position = (position - position % 10) / 10; + } + + g_array_sort_with_data(positions, + (GCompareDataFunc)strategy_compare_positions, + (gpointer)tm); + } for(i=start;ipos == position && - player_of_idx_team(tm, i)->cskill > 0 && + if(player_of_idx_team(tm, i)->cskill > 0 && + query_misc_integer_is_in_g_array( + player_of_idx_team(tm, i)->pos, positions) && (i > 10 || player_is_banned(player_of_idx_team(tm, i)) <= 0)) g_ptr_array_add(players, (gpointer)player_of_idx_team(tm, i)); @@ -486,7 +528,7 @@ strategy_get_sub(const Team *tm, gint position, g_ptr_array_sort_with_data(players, (GCompareDataFunc)strategy_compare_players_sub, - GINT_TO_POINTER(property)); + GINT_TO_POINTER(property * 10 + g_array_index(positions, gint, 0))); return_value = ((Player*)g_ptr_array_index(players, 0))->id; @@ -504,6 +546,8 @@ strategy_live_game_apply_action(LiveGame *match, gint team_idx, Team *tm = match->fix->teams[team_idx]; gint old_form = tm->structure; + g_array_append_val(match->action_ids[team_idx], action->id); + if(action->style != -100 && tm->style != action->style) { tm->style = action->style; @@ -520,7 +564,8 @@ strategy_live_game_apply_action(LiveGame *match, gint team_idx, tm->boost + 1); } - if(action->sub_in_pos != -1 && match->subs_left[team_idx] > 0) + if(action->sub_in_pos != -1 && match->subs_left[team_idx] > 0 && + misc_parse_condition(action->sub_condition, token_strat)) { sub_in_id = strategy_get_sub(tm, action->sub_in_pos, action->sub_in_prop, TRUE); @@ -558,7 +603,11 @@ strategy_live_game_check(LiveGame *match, gint team_idx) for(i=strat->match_action->len - 1; i >= 0; i--) { if((match->subs_left[team_idx] > 0 || - g_array_index(strat->match_action, StrategyMatchAction, i).sub_in_pos == -1) && + g_array_index(strat->match_action, + StrategyMatchAction, i).sub_in_pos == -1) && + !query_misc_integer_is_in_g_array( + g_array_index(strat->match_action, StrategyMatchAction, i).id, + match->action_ids[team_idx]) && misc_parse_condition( g_array_index(strat->match_action, StrategyMatchAction, i).condition, token_strat)) diff --git a/src/strategy.h b/src/strategy.h index 3f79fc6e..c9e96b5e 100644 --- a/src/strategy.h +++ b/src/strategy.h @@ -89,4 +89,9 @@ gint strategy_get_sub(const Team *tm, gint position, gint property, gboolean sub_in); +gint +strategy_compare_positions(gconstpointer a, + gconstpointer b, + gpointer user_data); + #endif diff --git a/src/strategy_struct.h b/src/strategy_struct.h index 5754d6e8..40f54562 100644 --- a/src/strategy_struct.h +++ b/src/strategy_struct.h @@ -28,7 +28,7 @@ are preferred when putting together the first 11). */ enum StratLineupType { - STRAT_LINEUP_BEST = 0, + STRAT_LINEUP_BEST = 1, STRAT_LINEUP_WEAKEST, STRAT_LINEUP_FITTEST, STRAT_LINEUP_UNFITTEST, @@ -53,14 +53,16 @@ typedef struct typedef struct { /** A condition describing when the action should be taken. */ - gchar *condition; + gchar *condition, *sub_condition; /** New boost and style values. */ gint boost, style; /** Substitution specifiers (position and property). Property is taken from #StratLineupType. */ gint sub_in_pos, sub_in_prop, sub_out_pos, sub_out_prop; - + /** An id to prevent actions from being applied again and + again during a match. */ + gint id; } StrategyMatchAction; /** A CPU strategy. */ diff --git a/src/team.c b/src/team.c index d9c8fdc6..b9595c6f 100644 --- a/src/team.c +++ b/src/team.c @@ -388,7 +388,9 @@ team_get_average_skill(const Team *tm, gboolean cskill) else for(i=0;i<11;i++) { - sum += player_get_game_skill(player_of_idx_team(tm, i), FALSE); + sum += (player_get_game_skill(player_of_idx_team(tm, i), FALSE) / + (1 + (gfloat)player_of_idx_team(tm, i)->streak * + const_float("float_player_streak_influence_skill"))); counter++; } diff --git a/src/treeview.c b/src/treeview.c index cc5264db..746c69ae 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -1333,7 +1333,8 @@ treeview_create_finances(const User* user) gchar *in_titles[MON_IN_TRANSFERS] = {_("Prize money"), _("Ticket income"), - _("Sponsorship")}; + _("Sponsorship"), + _("Betting")}; gchar *out_titles[MON_OUT_TRANSFERS] = {_("Wages"), _("Physio"), @@ -1342,7 +1343,8 @@ treeview_create_finances(const User* user) _("Youth academy"), _("Journey costs"), /* Money paid to players a user fired. */ - _("Compensations")}; + _("Compensations"), + _("Betting")}; GtkTreeIter iter; GtkListStore *ls = diff --git a/src/treeview2.c b/src/treeview2.c index dee94ab9..9444f748 100644 --- a/src/treeview2.c +++ b/src/treeview2.c @@ -21,11 +21,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "bet.h" #include "fixture.h" #include "league.h" #include "live_game.h" +#include "misc.h" #include "option.h" #include "support.h" +#include "team.h" #include "treeview2.h" #include "treeview_helper.h" #include "user.h" @@ -243,3 +246,181 @@ treeview2_show_season_results(void) gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(model)); g_object_unref(model); } + +void +treeview2_create_bets(GtkListStore *ls) +{ + gint i, j, k, rank; + GtkTreeIter iter; + gchar buf[SMALL], buf2[SMALL], + team_names[2][SMALL]; + const BetMatch *bet = NULL; + const BetUser *bet_user = NULL; + + for(k=1;k>=0;k--) + { + if(bets[k]->len > 0) + { + gtk_list_store_append(ls, &iter); + gtk_list_store_set(ls, &iter, + 0, (k == 1) ? + _("Current bets") : + _("Recent bets"), + 1, NULL, 2, NULL, 3, NULL, 4, "", 5, "", -1); + } + + for(i=0;ilen;i++) + { + if(g_array_index(bets[k], BetMatch, i).fix->clid == + current_user.tm->clid || + (g_array_index(bets[k], BetMatch, i).fix->clid >= ID_CUP_START && + opt_user_int("int_opt_user_bet_show_cups")) || + (g_array_index(bets[k], BetMatch, i).fix->clid < ID_CUP_START && + opt_user_int("int_opt_user_bet_show_all_leagues"))) + { + bet = &g_array_index(bets[k], BetMatch, i); + bet_user = bet_is_user(bet); + strcpy(buf, ""); + + if(k == 1 || (k == 0 && + (bet_user != NULL || + !opt_user_int("int_opt_user_bet_show_my_recent")))) + { + if(i == 0 || bet->fix->clid != + g_array_index(bets[k], BetMatch, i - 1).fix->clid) + { + if(i > 0) + { + gtk_list_store_append(ls, &iter); + gtk_list_store_set(ls, &iter, 0, "", + 1, NULL, 2, NULL, 3, NULL, 4, "", 5, "", -1); + } + + gtk_list_store_append(ls, &iter); + gtk_list_store_set(ls, &iter, + 0, league_cup_get_name_string(bet->fix->clid), + 1, NULL, 2, NULL, 3, NULL, 4, "", 5, "", -1); + } + + if(bet_user != NULL) + { + misc_print_grouped_int(bet_user->wager, buf2); + + if(bet_user->wager > 0) + strcpy(buf, buf2); + else + sprintf(buf, "%s", + const_app("string_treeview_finances_expenses_fg"), buf2); + } + + for(j=0;j<2;j++) + if(query_fixture_has_tables(bet->fix)) + { + if(bet->fix->clid < ID_CUP_START) + rank = team_get_league_rank(bet->fix->teams[j]); + else + rank = team_get_cup_rank(bet->fix->teams[j], + cup_get_last_tables_round(bet->fix->clid), TRUE); + + sprintf(team_names[j], "%s [%d]", + bet->fix->teams[j]->name, rank); + } + else if(bet->fix->clid >= ID_CUP_START && + query_cup_is_national(bet->fix->clid)) + sprintf(team_names[j], "%s (%d)", + bet->fix->teams[j]->name, + league_from_clid(bet->fix->teams[j]->clid)->layer); + else + strcpy(team_names[j], bet->fix->teams[j]->name); + + gtk_list_store_append(ls, &iter); + gtk_list_store_set(ls, &iter, 0, team_names[0], + 1, bet, 2, bet, 3, bet, + 4, team_names[1], + 5, buf, -1); + } + } + } + } +} + +void +treeview2_set_up_bets(GtkTreeView *treeview) +{ + gint i; + GtkTreeViewColumn *col; + GtkCellRenderer *renderer; + gchar *titles[6] = + {_("Team1"), + /* Team 1 wins (betting window). */ + _("Win1"), + _("Draw"), + /* Team 2 wins (betting window). */ + _("Win2"), + _("Team2"), + _("Wager/\nWin/Loss")}; + + gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview), + GTK_SELECTION_SINGLE); + gtk_tree_view_set_headers_visible(treeview, TRUE); + + col = gtk_tree_view_column_new(); + gtk_tree_view_column_set_title(col, titles[0]); + gtk_tree_view_append_column(treeview, col); + renderer = treeview_helper_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(col, renderer, TRUE); + gtk_tree_view_column_add_attribute(col, renderer, + "markup", 0); + + gtk_tree_view_column_set_alignment(col, 1.0); + g_object_set(renderer, "xalign", 1.0, NULL); + + for(i=1;i<4;i++) + { + col = gtk_tree_view_column_new(); + gtk_tree_view_column_set_title(col, titles[i]); + gtk_tree_view_append_column(treeview, col); + renderer = treeview_helper_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(col, renderer, TRUE); + gtk_tree_view_column_set_cell_data_func(col, renderer, + treeview_helper_bet_odds, + NULL, NULL); + } + + col = gtk_tree_view_column_new(); + gtk_tree_view_column_set_title(col, titles[4]); + gtk_tree_view_append_column(treeview, col); + renderer = treeview_helper_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(col, renderer, TRUE); + gtk_tree_view_column_add_attribute(col, renderer, + "text", 4); + + col = gtk_tree_view_column_new(); + gtk_tree_view_column_set_title(col, titles[5]); + gtk_tree_view_append_column(treeview, col); + renderer = treeview_helper_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(col, renderer, TRUE); + gtk_tree_view_column_add_attribute(col, renderer, + "markup", 5); + gtk_tree_view_column_set_alignment(col, 0.5); + g_object_set(renderer, "xalign", 0.5, NULL); +} + +/** Show the current and recent bets in the betting window. */ +void +treeview2_show_bets(void) +{ + GtkTreeView *treeview = + GTK_TREE_VIEW(lookup_widget(window.bets, "treeview_bets")); + GtkListStore *model = + gtk_list_store_new(6, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER, + G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING); + + treeview_helper_clear(treeview); + + treeview2_set_up_bets(treeview); + + treeview2_create_bets(model); + gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(model)); + g_object_unref(model); +} diff --git a/src/treeview2.h b/src/treeview2.h index f99df2cf..46a3dde7 100644 --- a/src/treeview2.h +++ b/src/treeview2.h @@ -53,4 +53,13 @@ treeview2_set_up_season_results(GtkTreeView *treeview); void treeview2_show_season_results(void); +void +treeview2_create_bets(GtkListStore *ls); + +void +treeview2_set_up_bets(GtkTreeView *treeview); + +void +treeview2_show_bets(void); + #endif diff --git a/src/treeview_helper.c b/src/treeview_helper.c index 3b479d56..e1b9a2e0 100644 --- a/src/treeview_helper.c +++ b/src/treeview_helper.c @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "bet.h" #include "cup.h" #include "file.h" #include "fixture.h" @@ -1392,7 +1393,8 @@ void treeview_helper_player_cskill_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl) { sprintf(buf, "%.*f", opt_int("int_opt_player_precision"), - player_get_game_skill(pl, FALSE)); + player_get_game_skill(pl, FALSE) / + (1 + (gfloat)pl->streak * const_float("float_player_streak_influence_skill"))); if(pl->cskill < pl->skill) g_object_set(renderer, "background", @@ -1592,3 +1594,46 @@ treeview_helper_season_results(GtkTreeViewColumn *col, g_object_set(renderer, "text", buf, NULL); } + +void +treeview_helper_bet_odds(GtkTreeViewColumn *col, + GtkCellRenderer *renderer, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer user_data) +{ + gint column = treeview_helper_get_col_number_column(col); + gchar buf[SMALL]; + const BetMatch *bet = NULL; + const BetUser *bet_user = NULL; + + gtk_tree_model_get(model, iter, column, &bet, -1); + + g_object_set(renderer, "background", + const_app("string_treeview_helper_color_default_background"), + "foreground", + const_app("string_treeview_helper_color_default_foreground"), + "text", "", NULL); + + if(bet == NULL) + return; + + strcpy(buf, ""); + bet_user = bet_is_user(bet); + + if(bet->fix->attendance == -1) + sprintf(buf, "%.2f", bet->odds[column - 1]); + else if(column == 2) + sprintf(buf, "%d - %d", bet->fix->result[0][0], + bet->fix->result[1][0]); + + if(bet->fix->attendance == -1 && + bet_user != NULL && + bet_user->outcome == column - 1) + g_object_set(renderer, "background", + const_app("string_treeview_helper_color_user_bet_bg"), + "foreground", + const_app("string_treeview_helper_color_user_bet_fg"), NULL); + + g_object_set(renderer, "text", buf, NULL); +} diff --git a/src/treeview_helper.h b/src/treeview_helper.h index 04e2de79..6cd5bf31 100644 --- a/src/treeview_helper.h +++ b/src/treeview_helper.h @@ -204,4 +204,11 @@ treeview_helper_season_results(GtkTreeViewColumn *col, GtkTreeIter *iter, gpointer user_data); +void +treeview_helper_bet_odds(GtkTreeViewColumn *col, + GtkCellRenderer *renderer, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer user_data); + #endif diff --git a/src/user.c b/src/user.c index 5a330206..91c69d1e 100644 --- a/src/user.c +++ b/src/user.c @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "bet.h" #include "cup.h" #include "file.h" #include "finance.h" @@ -71,6 +72,9 @@ user_new(void) new.mmatches_file = NULL; new.mmatches = g_array_new(FALSE, FALSE, sizeof(MemMatch)); + new.bets[0] = g_array_new(FALSE, FALSE, sizeof(BetUser)); + new.bets[1] = g_array_new(FALSE, FALSE, sizeof(BetUser)); + return new; } diff --git a/src/user_struct.h b/src/user_struct.h index 31908d57..d8990a3d 100644 --- a/src/user_struct.h +++ b/src/user_struct.h @@ -38,6 +38,7 @@ enum MonIn MON_IN_PRIZE = 0, MON_IN_TICKET, MON_IN_SPONSOR, + MON_IN_BETS, MON_IN_TRANSFERS, MON_IN_END }; @@ -52,6 +53,7 @@ enum MonOut MON_OUT_YA, MON_OUT_JOURNEY, MON_OUT_COMPENSATIONS, + MON_OUT_BETS, MON_OUT_TRANSFERS, MON_OUT_STADIUM_IMPROVEMENT, MON_OUT_STADIUM_BILLS, @@ -172,6 +174,8 @@ typedef struct gchar *mmatches_file; /** The array of MMs. */ GArray *mmatches; + /** Array of current and recent bets. */ + GArray *bets[2]; } User; enum EventType diff --git a/src/variables.h b/src/variables.h index a395c4ab..164c6587 100644 --- a/src/variables.h +++ b/src/variables.h @@ -71,6 +71,9 @@ GArray *season_stats; /** Array of available CPU strategies. */ GArray *strategies; +/** Array of current and recent bets. */ +GArray *bets[2]; + /** Some counters we use. */ gint counters[COUNT_END]; @@ -103,6 +106,7 @@ gint cur_user; gint timeout_id; GRand *rand_generator; + /** The list of directories the file_find_support_file() function searches for support files (e.g. pixmaps or text files). diff --git a/src/window.c b/src/window.c index a2636849..91ccc9cd 100644 --- a/src/window.c +++ b/src/window.c @@ -35,6 +35,7 @@ #include "misc_callback_func.h" #include "misc_interface.h" #include "misc2_interface.h" +#include "misc3_interface.h" #include "option.h" #include "option_gui.h" #include "options_interface.h" @@ -63,6 +64,25 @@ /* _("News")); */ /* } */ +/** Show the betting window. */ +void +window_show_bets(void) +{ + window_create(WINDOW_BETS); + + gtk_toggle_button_set_active( + GTK_TOGGLE_BUTTON(lookup_widget(window.bets, "checkbutton_bet_all_leagues")), + opt_user_int("int_opt_user_bet_show_all_leagues")); + gtk_toggle_button_set_active( + GTK_TOGGLE_BUTTON(lookup_widget(window.bets, "checkbutton_bet_cups")), + opt_user_int("int_opt_user_bet_show_cups")); + gtk_toggle_button_set_active( + GTK_TOGGLE_BUTTON(lookup_widget(window.bets, "checkbutton_bet_user_recent")), + opt_user_int("int_opt_user_bet_show_my_recent")); + + treeview2_show_bets(); +} + /** Show the help/about window. @param page Which notebook page to display. */ void @@ -607,10 +627,8 @@ window_create(gint window_type) if(window.digits != NULL) g_warning("window_create: called on already existing window\n"); else - { - popups_active++; window.digits = create_window_digits(); - } + wind = window.digits; strcpy(buf, _("Numbers...")); break; @@ -731,6 +749,14 @@ window_create(gint window_type) wind = window.mmatches; strcpy(buf, _("Memorable matches")); break; + case WINDOW_BETS: + if(window.bets != NULL) + g_warning("window_create: called on already existing window\n"); + else + window.bets = create_window_bets(); + wind = window.bets; + strcpy(buf, _("Betting")); + break; } if(window_type != WINDOW_FILE_CHOOSER) diff --git a/src/window.h b/src/window.h index 3e00201b..d27891bb 100644 --- a/src/window.h +++ b/src/window.h @@ -49,6 +49,7 @@ enum Windows WINDOW_TRANSFER_DIALOG, WINDOW_SPONSORS, WINDOW_MMATCHES, + WINDOW_BETS, WINDOW_END }; @@ -104,4 +105,7 @@ window_main_save_geometry(void); void window_main_load_geometry(void); +void +window_show_bets(void); + #endif diff --git a/src/xml_loadsave_misc.c b/src/xml_loadsave_misc.c index 99943ce3..e526ea9f 100644 --- a/src/xml_loadsave_misc.c +++ b/src/xml_loadsave_misc.c @@ -21,8 +21,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "bet_struct.h" #include "cup.h" #include "file.h" +#include "fixture.h" +#include "free.h" #include "misc.h" #include "xml.h" #include "variables.h" @@ -38,10 +41,15 @@ enum XmlLoadSaveCountryTags TAG_MISC_WEEK_ROUND, TAG_MISC_COUNTER, TAG_MISC_ALLCUP, + TAG_MISC_BET0, + TAG_MISC_BET1, + TAG_MISC_BET_FIX_ID, + TAG_MISC_BET_ODD, TAG_END }; -gint state, countidx; +gint state, countidx, oddidx, betidx; +BetMatch new_bet; void xml_loadsave_misc_start_element (GMarkupParseContext *context, @@ -72,6 +80,13 @@ xml_loadsave_misc_start_element (GMarkupParseContext *context, if(tag == TAG_MISC) countidx = 0; + if(tag == TAG_MISC_BET0 || + tag == TAG_MISC_BET1) + { + oddidx = 0; + betidx = (tag == TAG_MISC_BET1); + } + if(!valid_tag) g_warning("xml_loadsave_misc_start_element: unknown tag: %s; I'm in state %d\n", element_name, state); @@ -92,11 +107,23 @@ xml_loadsave_misc_end_element (GMarkupParseContext *context, tag == TAG_MISC_COUNTER || tag == TAG_MISC_SEASON || tag == TAG_MISC_WEEK || - tag == TAG_MISC_WEEK_ROUND) + tag == TAG_MISC_WEEK_ROUND || + tag == TAG_MISC_BET0 || + tag == TAG_MISC_BET1) { state = TAG_MISC; if(tag == TAG_MISC_COUNTER) countidx++; + else if(tag == TAG_MISC_BET0 || + tag == TAG_MISC_BET1) + g_array_append_val(bets[betidx], new_bet); + } + else if(tag == TAG_MISC_BET_ODD || + tag == TAG_MISC_BET_FIX_ID) + { + state = (betidx == 0) ? TAG_MISC_BET0 : TAG_MISC_BET1; + if(tag == TAG_MISC_BET_ODD) + oddidx++; } else if(tag != TAG_MISC) g_warning("xml_loadsave_misc_end_element: unknown tag: %s; I'm in state %d\n", @@ -105,18 +132,20 @@ xml_loadsave_misc_end_element (GMarkupParseContext *context, void xml_loadsave_misc_text (GMarkupParseContext *context, - const gchar *text, - gsize text_len, - gpointer user_data, - GError **error) + const gchar *text, + gsize text_len, + gpointer user_data, + GError **error) { gchar buf[SMALL]; gint int_value = -1; + gfloat float_value = -1; strncpy(buf, text, text_len); buf[text_len] = '\0'; int_value = (gint)g_ascii_strtod(buf, NULL); + float_value = (gfloat)g_ascii_strtod(buf, NULL) / 10000; if(state == TAG_NAME) misc_string_assign(&country.name, buf); @@ -134,6 +163,10 @@ xml_loadsave_misc_text (GMarkupParseContext *context, counters[countidx] = int_value; else if(state == TAG_MISC_ALLCUP) g_ptr_array_add(acps, cup_from_clid(int_value)); + else if(state == TAG_MISC_BET_ODD) + new_bet.odds[oddidx] = float_value; + else if(state == TAG_MISC_BET_FIX_ID) + new_bet.fix = fixture_from_id(int_value); } @@ -164,6 +197,8 @@ xml_loadsave_misc_read(const gchar *dirname, const gchar *basename) g_ptr_array_free(acps, TRUE); acps = g_ptr_array_new(); + free_bets(TRUE); + if(g_markup_parse_context_parse(context, file_contents, length, &error)) { g_markup_parse_context_end_parse(context, NULL); @@ -204,6 +239,27 @@ xml_loadsave_misc_write(const gchar *prefix) for(i=0;ilen;i++) xml_write_int(fil, acp(i)->id, TAG_MISC_ALLCUP, I0); + xml_loadsave_misc_write_bets(fil); + fprintf(fil, "\n", TAG_MISC); fclose(fil); } + +/** Write the bets arrays into the file. */ +void +xml_loadsave_misc_write_bets(FILE *fil) +{ + gint i, j, k; + + for(i=0;i<2;i++) + for(j=0;jlen;j++) + { + fprintf(fil, "%s<_%d>\n", I0, (i == 0) ? TAG_MISC_BET0 : TAG_MISC_BET1); + xml_write_int(fil, g_array_index(bets[i], BetMatch, j).fix->id, + TAG_MISC_BET_FIX_ID, I1); + for(k=0;k<3;k++) + xml_write_float(fil, g_array_index(bets[i], BetMatch, j).odds[k], + TAG_MISC_BET_ODD, I1); + fprintf(fil, "%s\n", I0, (i == 0) ? TAG_MISC_BET0 : TAG_MISC_BET1); + } +} diff --git a/src/xml_loadsave_misc.h b/src/xml_loadsave_misc.h index dcd69f94..3225d5d7 100644 --- a/src/xml_loadsave_misc.h +++ b/src/xml_loadsave_misc.h @@ -32,4 +32,7 @@ xml_loadsave_misc_read(const gchar *dirname, const gchar *basename); void xml_loadsave_misc_write(const gchar *prefix); +void +xml_loadsave_misc_write_bets(FILE *fil); + #endif diff --git a/src/xml_loadsave_users.c b/src/xml_loadsave_users.c index 9cf96dc5..1d1cc137 100644 --- a/src/xml_loadsave_users.c +++ b/src/xml_loadsave_users.c @@ -21,7 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "bet_struct.h" #include "file.h" +#include "fixture.h" #include "misc.h" #include "team.h" #include "user.h" @@ -65,13 +67,19 @@ enum TAG_USER_YA_AV_COACH, TAG_USER_YA_AV_PERCENTAGE, TAG_USER_YA_COUNTER, + TAG_USER_BET0, + TAG_USER_BET1, + TAG_USER_BET_WAGER, + TAG_USER_BET_OUTCOME, + TAG_USER_BET_FIX_ID, TAG_END }; -gint state, idx_mon_in, idx_mon_out, idx; +gint state, idx_mon_in, idx_mon_out, idx, idx_bet; User new_user; UserHistory new_history; Event new_event; +BetUser new_bet; void xml_loadsave_users_start_element (GMarkupParseContext *context, @@ -120,6 +128,10 @@ xml_loadsave_users_start_element (GMarkupParseContext *context, state == TAG_USER_MONEY_INS) idx = 0; + if(state == TAG_USER_BET0 || + state == TAG_USER_BET1) + idx_bet = (state == TAG_USER_BET1); + if(tag == TAG_USER_HISTORY) new_history.value_string = NULL; else if(tag == TAG_USER_EVENT) @@ -161,7 +173,9 @@ xml_loadsave_users_end_element (GMarkupParseContext *context, tag == TAG_USER_YA_PERCENTAGE || tag == TAG_USER_YA_AV_COACH || tag == TAG_USER_YA_AV_PERCENTAGE || - tag == TAG_USER_YA_COUNTER) + tag == TAG_USER_YA_COUNTER || + tag == TAG_USER_BET0 || + tag == TAG_USER_BET1) { state = TAG_USER; if(tag == TAG_USER_COUNTER) @@ -174,6 +188,9 @@ xml_loadsave_users_end_element (GMarkupParseContext *context, g_array_append_val(new_user.history, new_history); else if(tag == TAG_USER_EVENT) g_array_append_val(new_user.events, new_event); + else if(tag == TAG_USER_BET0 || + tag == TAG_USER_BET1) + g_array_append_val(new_user.bets[idx_bet], new_bet); } else if(tag == TAG_USER_MONEY_OUT) { @@ -198,6 +215,10 @@ xml_loadsave_users_end_element (GMarkupParseContext *context, tag == TAG_USER_EVENT_VALUE2 || tag == TAG_USER_EVENT_VALUE_STRING) state = TAG_USER_EVENT; + else if(tag == TAG_USER_BET_FIX_ID || + tag == TAG_USER_BET_WAGER || + tag == TAG_USER_BET_OUTCOME) + state = (idx_bet == 0) ? TAG_USER_BET0 : TAG_USER_BET1; else if(tag >= TAG_START_PLAYERS && tag <= TAG_END_PLAYERS) { xml_loadsave_players_end_element(tag, new_user.youth_academy.players); @@ -289,6 +310,12 @@ xml_loadsave_users_text (GMarkupParseContext *context, new_user.youth_academy.av_percentage = float_value; else if(state == TAG_USER_YA_COUNTER) new_user.youth_academy.counter_youth = float_value; + else if(state == TAG_USER_BET_WAGER) + new_bet.wager = int_value; + else if(state == TAG_USER_BET_OUTCOME) + new_bet.outcome = int_value; + else if(state == TAG_USER_BET_FIX_ID) + new_bet.fix = fixture_from_id(int_value); else if(state >= TAG_START_PLAYERS && state <= TAG_END_PLAYERS) xml_loadsave_players_text(buf); } @@ -367,6 +394,10 @@ xml_loadsave_users_write(const gchar *prefix) xml_write_int(fil, usr(i).sponsor.contract, TAG_USER_SPONSOR_CONTRACT, I1); xml_write_int(fil, usr(i).sponsor.benefit, TAG_USER_SPONSOR_BENEFIT, I1); + xml_user_write_history(fil, usr(i).history); + xml_user_write_events(fil, usr(i).events); + xml_user_write_bets(fil, usr(i).bets); + for(j=0;j\n", I1, TAG_USER_MONEY_OUTS); } - for(j=0;jlen;j++) - { - fprintf(fil, "%s<_%d>\n", I1, TAG_USER_HISTORY); - - xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).season, - TAG_USER_HISTORY_SEASON, I2); - xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).week, - TAG_USER_HISTORY_WEEK, I2); - xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).type, - TAG_USER_HISTORY_TYPE, I2); - xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).team_id, - TAG_USER_HISTORY_TEAM_ID, I2); - xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).value1, - TAG_USER_HISTORY_VALUE1, I2); - xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).value2, - TAG_USER_HISTORY_VALUE2, I2); - xml_write_string(fil, g_array_index(usr(i).history, UserHistory, j).value_string, - TAG_USER_HISTORY_VALUE_STRING, I2); - - fprintf(fil, "%s\n", I1, TAG_USER_HISTORY); - } - - for(j=0;jlen;j++) - { - fprintf(fil, "%s<_%d>\n", I1, TAG_USER_EVENT); - - xml_write_int(fil, g_array_index(usr(i).events, Event, j).type, - TAG_USER_EVENT_TYPE, I2); - xml_write_int(fil, g_array_index(usr(i).events, Event, j).value1, - TAG_USER_EVENT_VALUE1, I2); - xml_write_int(fil, g_array_index(usr(i).events, Event, j).value2, - TAG_USER_EVENT_VALUE2, I2); - xml_write_string(fil, g_array_index(usr(i).events, Event, j).value_string, - TAG_USER_EVENT_VALUE_STRING, I2); - - fprintf(fil, "%s\n", I1, TAG_USER_EVENT); - } - xml_write_int(fil, usr(i).youth_academy.coach, TAG_USER_YA_COACH, I1); xml_write_int(fil, usr(i).youth_academy.percentage, TAG_USER_YA_PERCENTAGE, I1); xml_write_float(fil, usr(i).youth_academy.av_coach, TAG_USER_YA_AV_COACH, I1); @@ -439,3 +432,77 @@ xml_loadsave_users_write(const gchar *prefix) fclose(fil); } + +/** Write the history of a user into the file. */ +void +xml_user_write_history(FILE *fil, const GArray *history) +{ + gint i; + + for(i=0;ilen;i++) + { + fprintf(fil, "%s<_%d>\n", I1, TAG_USER_HISTORY); + + xml_write_int(fil, g_array_index(history, UserHistory, i).season, + TAG_USER_HISTORY_SEASON, I2); + xml_write_int(fil, g_array_index(history, UserHistory, i).week, + TAG_USER_HISTORY_WEEK, I2); + xml_write_int(fil, g_array_index(history, UserHistory, i).type, + TAG_USER_HISTORY_TYPE, I2); + xml_write_int(fil, g_array_index(history, UserHistory, i).team_id, + TAG_USER_HISTORY_TEAM_ID, I2); + xml_write_int(fil, g_array_index(history, UserHistory, i).value1, + TAG_USER_HISTORY_VALUE1, I2); + xml_write_int(fil, g_array_index(history, UserHistory, i).value2, + TAG_USER_HISTORY_VALUE2, I2); + xml_write_string(fil, g_array_index(history, UserHistory, i).value_string, + TAG_USER_HISTORY_VALUE_STRING, I2); + + fprintf(fil, "%s\n", I1, TAG_USER_HISTORY); + } +} + +/** Write the events of a user into the file. */ +void +xml_user_write_events(FILE *fil, const GArray *events) +{ + gint i; + + for(i=0;ilen;i++) + { + fprintf(fil, "%s<_%d>\n", I1, TAG_USER_EVENT); + + xml_write_int(fil, g_array_index(events, Event, i).type, + TAG_USER_EVENT_TYPE, I2); + xml_write_int(fil, g_array_index(events, Event, i).value1, + TAG_USER_EVENT_VALUE1, I2); + xml_write_int(fil, g_array_index(events, Event, i).value2, + TAG_USER_EVENT_VALUE2, I2); + xml_write_string(fil, g_array_index(events, Event, i).value_string, + TAG_USER_EVENT_VALUE_STRING, I2); + + fprintf(fil, "%s\n", I1, TAG_USER_EVENT); + } +} + +/** Write the bets of a user into the file. */ +void +xml_user_write_bets(FILE *fil, GArray **bets) +{ + gint i, j; + + for(i=0;i<2;i++) + for(j=0;jlen;j++) + { + fprintf(fil, "%s<_%d>\n", I1, + (i == 0) ? TAG_USER_BET0 : TAG_USER_BET1); + xml_write_int(fil, g_array_index(bets[i], BetUser, j).wager, + TAG_USER_BET_WAGER, I2); + xml_write_int(fil, g_array_index(bets[i], BetUser, j).outcome, + TAG_USER_BET_OUTCOME, I2); + xml_write_int(fil, g_array_index(bets[i], BetUser, j).fix->id, + TAG_USER_BET_FIX_ID, I2); + fprintf(fil, "%s\n", I1, + (i == 0) ? TAG_USER_BET0 : TAG_USER_BET1); + } +} diff --git a/src/xml_loadsave_users.h b/src/xml_loadsave_users.h index 2ecfa30b..a2fd524a 100644 --- a/src/xml_loadsave_users.h +++ b/src/xml_loadsave_users.h @@ -53,5 +53,14 @@ xml_loadsave_users_read(const gchar *dirname, const gchar *basename); void xml_loadsave_users_write(const gchar *prefix); +void +xml_user_write_history(FILE *fil, const GArray *history); + +void +xml_user_write_events(FILE *fil, const GArray *events); + +void +xml_user_write_bets(FILE *fil, GArray **bets); + #endif diff --git a/src/xml_strategy.c b/src/xml_strategy.c index fe1d1160..e964f5ba 100644 --- a/src/xml_strategy.c +++ b/src/xml_strategy.c @@ -89,7 +89,7 @@ enum STATE_STRATEGY_MATCH_ACTION_SUB_OUT_POS, }; -gint state; +gint state, action_id; #define curstrat g_array_index(strategies, Strategy, strategies->len - 1) #define curprematch g_array_index(curstrat.prematch, StrategyPrematch, curstrat.prematch->len - 1) @@ -127,7 +127,8 @@ xml_strategy_read_start_element (GMarkupParseContext *context, while(attribute_names[atidx] != NULL) { - if(strcmp(attribute_names[atidx], ATT_NAME_COND) == 0) + if(strcmp(attribute_names[atidx], ATT_NAME_COND) == 0 && + new_prematch.condition == NULL) new_prematch.condition = g_strdup(attribute_values[atidx]); else @@ -166,15 +167,18 @@ xml_strategy_read_start_element (GMarkupParseContext *context, StrategyMatchAction new_match_action; state = STATE_STRATEGY_MATCH_ACTION; + new_match_action.sub_condition = NULL; new_match_action.condition = NULL; new_match_action.boost = new_match_action.style = -100; new_match_action.sub_in_pos = -1; + new_match_action.id = action_id++; while(attribute_names[atidx] != NULL) { - if(strcmp(attribute_names[atidx], ATT_NAME_COND) == 0) + if(strcmp(attribute_names[atidx], ATT_NAME_COND) == 0 && + new_match_action.condition == NULL) new_match_action.condition = g_strdup(attribute_values[atidx]); else @@ -191,7 +195,22 @@ xml_strategy_read_start_element (GMarkupParseContext *context, else if(strcmp(element_name, TAG_STRATEGY_MATCH_ACTION_STYLE) == 0) state = STATE_STRATEGY_MATCH_ACTION_STYLE; else if(strcmp(element_name, TAG_STRATEGY_MATCH_ACTION_SUB) == 0) + { state = STATE_STRATEGY_MATCH_ACTION_SUB; + + while(attribute_names[atidx] != NULL) + { + if(strcmp(attribute_names[atidx], ATT_NAME_COND) == 0 && + curmatchaction.sub_condition == NULL) + curmatchaction.sub_condition = + g_strdup(attribute_values[atidx]); + else + g_warning("xml_strategy_read_start_element: unknown attribute %s\n", + attribute_names[atidx]); + + atidx++; + } + } else if(strcmp(element_name, TAG_STRATEGY_MATCH_ACTION_SUB_IN_POS) == 0) { state = STATE_STRATEGY_MATCH_ACTION_SUB_IN_POS; @@ -389,33 +408,51 @@ xml_strategy_read_text (GMarkupParseContext *context, g_warning( "xml_strategy_read_text: unknown boost type %s\n", buf); } - else if(state == STATE_STRATEGY_MATCH_ACTION_SUB_IN_POS) + else if(state == STATE_STRATEGY_MATCH_ACTION_SUB_IN_POS || + state == STATE_STRATEGY_MATCH_ACTION_SUB_OUT_POS) { - if(strcmp(buf, POS_NAME_GOALIE) == 0) - curmatchaction.sub_in_pos = 0; - else if(strcmp(buf, POS_NAME_DEFENDER) == 0) - curmatchaction.sub_in_pos = 1; - else if(strcmp(buf, POS_NAME_MIDFIELDER) == 0) - curmatchaction.sub_in_pos = 2; - else if(strcmp(buf, POS_NAME_FORWARD) == 0) - curmatchaction.sub_in_pos = 3; + GPtrArray *positions = misc_separate_strings(buf); + gint i, *pos; + + if(state == STATE_STRATEGY_MATCH_ACTION_SUB_IN_POS) + { + if(positions->len > 1) + { + free_gchar_array(&positions); + main_exit_program(EXIT_STRATEGY_ERROR, + "xml_strategy_read_text: too many sub_in positions: %s\n", + buf); + } + + pos = &curmatchaction.sub_in_pos; + } else - g_warning( - "xml_strategy_read_text: unknown position %s\n", buf); - } - else if(state == STATE_STRATEGY_MATCH_ACTION_SUB_OUT_POS) - { - if(strcmp(buf, POS_NAME_GOALIE) == 0) - curmatchaction.sub_out_pos = 0; - else if(strcmp(buf, POS_NAME_DEFENDER) == 0) - curmatchaction.sub_out_pos = 1; - else if(strcmp(buf, POS_NAME_MIDFIELDER) == 0) - curmatchaction.sub_out_pos = 2; - else if(strcmp(buf, POS_NAME_FORWARD) == 0) - curmatchaction.sub_out_pos = 3; - else - g_warning( - "xml_strategy_read_text: unknown position %s\n", buf); + pos = &curmatchaction.sub_out_pos; + + *pos = 9; + + for(i=0;ilen;i++) + if(strcmp((gchar*)g_ptr_array_index(positions, i), + POS_NAME_GOALIE) == 0) + *pos *= 10; + else if(strcmp((gchar*)g_ptr_array_index(positions, i), + POS_NAME_DEFENDER) == 0) + *pos = (*pos * 10) + 1; + else if(strcmp((gchar*)g_ptr_array_index(positions, i), + POS_NAME_MIDFIELDER) == 0) + *pos = (*pos * 10) + 2; + else if(strcmp((gchar*)g_ptr_array_index(positions, i), + POS_NAME_FORWARD) == 0) + *pos = (*pos * 10) + 3; + else + g_warning( + "xml_strategy_read_text: unknown position %s\n", + (gchar*)g_ptr_array_index(positions, i)); + + if(*pos < 100) + *pos = *pos % 10; + + free_gchar_array(&positions); } } @@ -451,6 +488,8 @@ xml_strategy_read(const gchar *filename) g_array_append_val(strategies, new_strat); + action_id = 0; + if(g_markup_parse_context_parse(context, file_contents, length, &error)) { g_markup_parse_context_end_parse(context, NULL); diff --git a/support_files/bygfoot_app b/support_files/bygfoot_app index 7caf7e95..700ca8ac 100644 --- a/support_files/bygfoot_app +++ b/support_files/bygfoot_app @@ -226,3 +226,7 @@ string_treeview_helper_player_status_injury player_status_injury.png string_treeview_helper_player_status_ban player_status_ban.png string_treeview_helper_player_status_ok string_treeview_helper_player_status_yellow_danger player_status_yellow.png + +# betting cell +string_treeview_helper_color_user_bet_fg black +string_treeview_helper_color_user_bet_bg lightblue diff --git a/support_files/bygfoot_constants b/support_files/bygfoot_constants index 89007fe1..875a9983 100644 --- a/support_files/bygfoot_constants +++ b/support_files/bygfoot_constants @@ -874,3 +874,14 @@ float_player_streak_prob_max 40000 # probability at streak_prob=0 (this is >0 because # the streak_prob is between -1 and 1, not 0 and 1) float_player_streak_prob_zero 5000 + +# factors for the betting odds functions +float_bet_better_factor 2430 +float_bet_worse_factor -1290 + +# this determines how much worse the odds +# are made because of betting commission +float_bet_commission_decrease 25000 + +# how small the odds may become +float_bet_lower_limit 5000 diff --git a/support_files/bygfoot_user.conf b/support_files/bygfoot_user.conf index 769aae8b..801e350c 100644 --- a/support_files/bygfoot_user.conf +++ b/support_files/bygfoot_user.conf @@ -22,6 +22,10 @@ int_opt_user_contract_limit 12 int_opt_user_penalty_shooter -1 +int_opt_user_bet_show_all_leagues 0 +int_opt_user_bet_show_cups 1 +int_opt_user_bet_show_my_recent 1 + # the order of these attributes is important # don't change it, only the values int_opt_user_pl1_att_name 1