3
3
* Glade will not overwrite this file.
11
#include "live_game.h"
18
/* set some variables that are used but not saved
20
void set_variables(void)
23
gchar buf[BUF_SIZE_SMALL];
27
selected_rows[i] = -1;
30
bookmaker_tips[i][j] = -1;
33
/* debug mode or no? */
36
status = save_status = notify_status = popups_active = 0;
37
/* reset main window pointer */
39
/* reset default save file name */
40
sprintf(buf, "%s/.bygfoot/saves/", getenv("HOME"));
41
save_file = g_string_new(buf);
42
/* reset history chained list */
44
/* reset font and country file names */
45
strcpy(font_name, "0");
46
strcpy(country_file_name, "0");
48
/* this plays a role in case the human player has
49
specified a country file on the command line */
50
strcpy(teams[0].name, "");
53
gint bygfoot_init(gint argc, gchar *argv[])
13
#include "misc_callbacks.h"
14
#include "name_struct.h"
16
#include "stat_struct.h"
17
#include "transfer_struct.h"
18
#include "variables.h"
22
Initialize some global variables. Most of them get nullified.
25
main_init_variables(void)
56
gchar buf[BUF_SIZE_SMALL];
31
country.name = country.symbol = country.sid = NULL;
33
season = week = week_round = 1;
35
for(i=0;i<COUNT_END;i++)
38
counters[COUNT_LEAGUE_ID] = ID_LEAGUE_START;
39
counters[COUNT_CUP_ID] = ID_CUP_START;
41
window.main = window.startup =
42
window.live = window.warning = window.progress = window.digits =
43
window.stadium = window.job_offer = window.yesno =
44
window.options = window.font_sel =
45
window.file_chooser = window.contract =
46
window.menu_player = window.user_management = NULL;
48
live_game_reset(&live_game_temp, NULL, FALSE);
50
users = g_array_new(FALSE, FALSE, sizeof(User));
51
transfer_list = g_array_new(FALSE, FALSE, sizeof(Transfer));
52
season_stats = g_array_new(FALSE, FALSE, sizeof(SeasonStat));
53
name_lists = g_array_new(FALSE, FALSE, sizeof(NameList));
55
save_file = g_string_new("");
58
constants.list = options.list = NULL;
59
constants_app.datalist =
60
constants.datalist = options.datalist = NULL;
63
selected_row[0] = selected_row[1] = -1;
67
file_load_conf_files();
69
language_set(language_get_code_index(opt_str("string_opt_language_code")) + 1);
73
Process the command line arguments and do some things
74
that have to be done at the beginning (like initializing the
75
random number generator).
76
@param argc Number of command line arguments.
77
@param argv Command line arguments array.
80
main_init(gint argc, gchar *argv[])
83
gchar *pwd = g_get_current_dir();
59
85
/* initialize the random nr generator */
60
srandom((unsigned)time(NULL));
64
sprintf(buf, "%s/support_files", getenv("PWD"));
65
add_support_directory(buf);
67
sprintf(buf, "%s/.bygfoot", getenv("HOME"));
68
add_support_directory(buf);
70
/* look for pixmap directory and country file */
71
for(i=1;i<argc - 1;i++)
73
if(strcmp(argv[i], "-d") == 0)
74
add_support_directory (argv[i + 1]);
75
else if(strcmp(argv[i], "-f") == 0)
76
country_names(0, argv[i + 1]);
79
/* check for the files with team and player names
85
/* fill the player names array */
86
text_file_number_to_char(TEXT_FILES_PLAYER_NAMES, buf, TRUE);
87
get_names(buf, player_names);
89
/* look for 'start editor' option */
91
if(strcmp(argv[i], "--editor") == 0 ||
92
strcmp(argv[i], "-e") == 0)
95
main_window = return_main_window();
97
/* look for savegame */
99
if(strcmp(argv[i - 1], "-d") != 0 &&
100
strcmp(argv[i], "-d") != 0 &&
101
strcmp(argv[i - 1], "-f") != 0 &&
102
strcmp(argv[i], "-f") != 0)
104
sprintf(buf, "%s", argv[i]);
105
buf2 = find_support_file(buf);
107
if(buf2 == NULL || argv[i][0] == '/')
108
g_string_assign(save_file, argv[i]);
110
g_string_assign(save_file, buf2);
115
if(check_save_game(save_file->str))
117
load_game(save_file->str);
118
on_button_back_to_main_clicked(NULL, NULL);
119
gtk_widget_show(main_window);
125
g_print("\nUsage: bygfoot [-e|--editor] [-d pixmapdir] [-f country_file] [savegame]\n\n");
126
g_print("Options\n");
127
g_print("-e, --editor:\t Start Bygfoot Team Editor instead of the game itself\n");
128
g_print("-d\t\t Add the 'pixmapdir' directory to the list Bygfoot searches when\n");
129
g_print("\t\t looking for text files and pixmap files.\n");
130
g_print("-f\t\t Load the file 'country_file' which is structured like\n");
131
g_print("\t\t 'country_eng' and specifies team and cup names\n\n");
132
g_print("Any other argument is interpreted as a savegame file.\n\n");
134
if(strcmp(argv[i], "-h") != 0 &&
135
strcmp(argv[i], "--help") != 0)
137
"\n *** Doesn't seem to be a Bygfoot savegame: %s ***\n\n",
140
g_string_free(save_file, TRUE);
141
gtk_widget_destroy(main_window);
86
rand_generator = g_rand_new();
88
support_directories = NULL;
90
file_add_support_directory_recursive(PACKAGE_DATA_DIR "/" PACKAGE "/support_files");
92
sprintf(buf, "%s/%s", g_get_home_dir(), HOMEDIRNAME);
93
file_add_support_directory_recursive(buf);
95
sprintf(buf, "%s/support_files", pwd);
97
file_add_support_directory_recursive(buf);
99
file_check_home_dir();
101
main_init_variables();
105
Initialize the GTK stuff and the gettext stuff.
107
@param argc Number of command line arguments.
108
@param argv Command line arguments array.
151
111
main (gint argc, gchar *argv[])
156
114
#ifdef ENABLE_NLS
157
115
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
158
116
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
159
117
textdomain (GETTEXT_PACKAGE);
163
gtk_init (&argc, &argv);
165
add_support_directory(PACKAGE_DATA_DIR "/" PACKAGE "/support_files");
167
return_value = bygfoot_init(argc, argv);
169
if(return_value == 5)
171
else if(return_value == 0)
121
gtk_init (&argc, &argv);
123
main_init(argc, argv);
125
window_show_startup();
126
stat0 = STATUS_TEAM_SELECTION;
130
main_exit_program(EXIT_OK, NULL);
135
/** Exit the program with the given exit code and message. Try to
136
destroy all widgets and free all memory first.
137
@param exit_code The number we return to the shell.
138
@param exit_message The message we print.
139
@return The exit code of the program. */
141
main_exit_program(gint exit_code, gchar *exit_message)
143
if(gtk_main_level() > 0)
148
if(exit_message != NULL)
149
g_warning(exit_message);