/** Start a new game after users and teams are selected. */ void misc_callback_start_game(void) { #ifdef DEBUG printf("misc_callback_start_game\n"); #endif gint i; GtkToggleButton *radio_load = GTK_TOGGLE_BUTTON(lookup_widget(window.startup, "radiobutton_team_def_load")); GtkToggleButton *radio_names = GTK_TOGGLE_BUTTON(lookup_widget(window.startup, "radiobutton_team_def_names")); GtkToggleButton *checkbutton_randomise_teams = GTK_TOGGLE_BUTTON(lookup_widget(window.startup, "checkbutton_randomise_teams")); stat0 = STATUS_MAIN; /* option_add(&options, "int_opt_load_defs", 1, NULL); */ /* option_add(&options, "int_opt_randomise_teams", 0, NULL); */ if(gtk_toggle_button_get_active(checkbutton_randomise_teams)) opt_set_int("int_opt_randomise_teams", 1); if(gtk_toggle_button_get_active(radio_load)) opt_set_int("int_opt_load_defs", 1); else if(gtk_toggle_button_get_active(radio_names)) opt_set_int("int_opt_load_defs", 2); else opt_set_int("int_opt_load_defs", 0); start_new_game(); window_destroy(&window.startup); file_store_text_in_saves("last_country", country.sid); if(!opt_int("int_opt_calodds")) { for(i=0;i<users->len;i++) user_set_up_team_new_game(&usr(i)); window_create(WINDOW_MAIN); game_gui_show_main(); if(statp != NULL) { debug_action((gchar*)statp); g_free(statp); statp = NULL; } } 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); } }
/** Free all memory allocated by the program. This mainly means we have to free a lot of strings and GArrays. */ void free_memory(void) { #ifdef DEBUG printf("free_memory\n"); #endif free_variables(); free_names(FALSE); free_transfer_list(); free_strategies(); free_country(&country, FALSE); free_users(FALSE); free_bets(FALSE); free_lg_commentary(FALSE); free_news(FALSE); free_newspaper(FALSE); free_support_dirs(); free_jobs(FALSE); free_g_array(&live_games); }
/* * Free everything that we allocated. * Can be used to detect memory leaks, e.g., with ccmalloc. * NOTE: This is tricky! Things are freed that functions depend on. Don't be * surprised if Vim crashes... * Some things can't be freed, esp. things local to a library function. */ void free_all_mem(void) { buf_T *buf, *nextbuf; static int entered = FALSE; /* When we cause a crash here it is caught and Vim tries to exit cleanly. * Don't try freeing everything again. */ if (entered) return; entered = TRUE; block_autocmds(); /* don't want to trigger autocommands here */ /* Close all tabs and windows. Reset 'equalalways' to avoid redraws. */ p_ea = FALSE; if (first_tabpage->tp_next != NULL) do_cmdline_cmd((char_u *)"tabonly!"); if (firstwin != lastwin) do_cmdline_cmd((char_u *)"only!"); /* Free all spell info. */ spell_free_all(); /* Clear user commands (before deleting buffers). */ ex_comclear(NULL); /* Clear menus. */ do_cmdline_cmd((char_u *)"aunmenu *"); do_cmdline_cmd((char_u *)"menutranslate clear"); /* Clear mappings, abbreviations, breakpoints. */ do_cmdline_cmd((char_u *)"lmapclear"); do_cmdline_cmd((char_u *)"xmapclear"); do_cmdline_cmd((char_u *)"mapclear"); do_cmdline_cmd((char_u *)"mapclear!"); do_cmdline_cmd((char_u *)"abclear"); do_cmdline_cmd((char_u *)"breakdel *"); do_cmdline_cmd((char_u *)"profdel *"); do_cmdline_cmd((char_u *)"set keymap="); free_titles(); free_findfile(); /* Obviously named calls. */ free_all_autocmds(); clear_termcodes(); free_all_options(); free_all_marks(); alist_clear(&global_alist); free_homedir(); free_users(); free_search_patterns(); free_old_sub(); free_last_insert(); free_prev_shellcmd(); free_regexp_stuff(); free_tag_stuff(); free_cd_dir(); free_signs(); set_expr_line(NULL); diff_clear(curtab); clear_sb_text(); /* free any scrollback text */ /* Free some global vars. */ vim_free(last_cmdline); vim_free(new_last_cmdline); set_keep_msg(NULL, 0); /* Clear cmdline history. */ p_hi = 0; init_history(); { win_T *win; tabpage_T *tab; qf_free_all(NULL); /* Free all location lists */ FOR_ALL_TAB_WINDOWS(tab, win) qf_free_all(win); } /* Close all script inputs. */ close_all_scripts(); /* Destroy all windows. Must come before freeing buffers. */ win_free_all(); /* Free all buffers. Reset 'autochdir' to avoid accessing things that * were freed already. */ p_acd = FALSE; for (buf = firstbuf; buf != NULL; ) { nextbuf = buf->b_next; close_buffer(NULL, buf, DOBUF_WIPE, FALSE); if (buf_valid(buf)) buf = nextbuf; /* didn't work, try next one */ else buf = firstbuf; } free_cmdline_buf(); /* Clear registers. */ clear_registers(); ResetRedobuff(); ResetRedobuff(); /* highlight info */ free_highlight(); reset_last_sourcing(); free_tabpage(first_tabpage); first_tabpage = NULL; # ifdef UNIX /* Machine-specific free. */ mch_free_mem(); # endif /* message history */ for (;; ) if (delete_first_msg() == FAIL) break; eval_clear(); free_termoptions(); /* screenlines (can't display anything now!) */ free_screenlines(); clear_hl_tables(); vim_free(NameBuff); }