Merge pull request #203 from illwieckz/gamesh
also write server_type enum from games.xml, avoid GAMES_TOTAL ambiguity
This commit is contained in:
commit
ecb165f246
@ -501,7 +501,7 @@ target_link_libraries (gamesxml2c xml2)
|
||||
# Custom build rule for converting games.xml to games.c
|
||||
add_custom_command (
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/games.c
|
||||
COMMAND gamesxml2c ${CMAKE_SOURCE_DIR}/src/games.xml > ${CMAKE_BINARY_DIR}/games.c
|
||||
COMMAND gamesxml2c ${CMAKE_SOURCE_DIR}/src/games.xml ${CMAKE_BINARY_DIR}/games.c ${CMAKE_BINARY_DIR}/games.h
|
||||
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/src/games.xml
|
||||
DEPENDS gamesxml2c)
|
||||
|
||||
|
71
src/defs.h
71
src/defs.h
@ -26,6 +26,8 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "games.h"
|
||||
|
||||
// max 0x8000, server->flags is unsigned
|
||||
enum server_flags {
|
||||
PLAYER_GROUP_RED = 0x001,
|
||||
@ -47,74 +49,6 @@ enum launch_mode {
|
||||
LAUNCH_RECORD
|
||||
};
|
||||
|
||||
|
||||
// note: there is a limit of 256 servers, see get_server_pixmap in srv-list.c
|
||||
enum server_type {
|
||||
ALIENARENA_SERVER = 0,
|
||||
AAO_SERVER,
|
||||
BF1942_SERVER,
|
||||
COD_SERVER,
|
||||
CODUO_SERVER,
|
||||
COD2_SERVER,
|
||||
COD4_SERVER,
|
||||
DESCENT3_SERVER,
|
||||
DOOM3_SERVER,
|
||||
ETL_SERVER,
|
||||
ETQW_SERVER,
|
||||
HL_SERVER_OLD,
|
||||
HL_SERVER,
|
||||
HL2_SERVER,
|
||||
HR_SERVER,
|
||||
H2_SERVER,
|
||||
HW_SERVER,
|
||||
JK2_SERVER,
|
||||
JK3_SERVER,
|
||||
KP_SERVER,
|
||||
MOHAA_SERVER,
|
||||
NETP_SERVER,
|
||||
NEXUIZ_SERVER,
|
||||
OPENARENA_SERVER,
|
||||
OTTD_SERVER,
|
||||
POSTAL2_SERVER,
|
||||
Q3RALLY_SERVER,
|
||||
Q1_SERVER,
|
||||
QW_SERVER,
|
||||
Q2_SERVER,
|
||||
Q3_SERVER,
|
||||
Q4_SERVER,
|
||||
REACTION_SERVER,
|
||||
WO_SERVER,
|
||||
RUNE_SERVER,
|
||||
SAS_SERVER,
|
||||
SSAM_SERVER,
|
||||
SSAMSE_SERVER,
|
||||
SN_SERVER,
|
||||
SMOKINGUNS_SERVER,
|
||||
SFS_SERVER,
|
||||
SOF2S_SERVER,
|
||||
TEEWORLDS_SERVER,
|
||||
TREMFUSION_SERVER,
|
||||
TREMULOUS_SERVER,
|
||||
TREMULOUSGPP_SERVER,
|
||||
T2_SERVER,
|
||||
TURTLEARENA_SERVER,
|
||||
UN_SERVER,
|
||||
UT2_SERVER,
|
||||
UT2004_SERVER,
|
||||
UNVANQUISHED_SERVER,
|
||||
IOURT_SERVER,
|
||||
EF_SERVER,
|
||||
WARSOW_SERVER,
|
||||
WOET_SERVER,
|
||||
WOP_SERVER,
|
||||
XONOTIC_SERVER,
|
||||
ZEQ2LITE_SERVER,
|
||||
GPS_SERVER,
|
||||
UNKNOWN_SERVER,
|
||||
};
|
||||
|
||||
#define GAMES_TOTAL UNKNOWN_SERVER
|
||||
|
||||
enum master_state {
|
||||
SOURCE_NA = 0,
|
||||
SOURCE_UP,
|
||||
@ -155,7 +89,6 @@ struct host {
|
||||
int ref_count;
|
||||
};
|
||||
|
||||
|
||||
// server_new, server_free_info, server_move_info must be adapted for changes to this structure
|
||||
|
||||
struct server {
|
||||
|
10
src/game.c
10
src/game.c
@ -223,11 +223,11 @@ void init_games() {
|
||||
|
||||
debug(3, "initializing games");
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
g_datalist_init(&games[i].games_data);
|
||||
}
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (j = 0; games[i].attributes && games[i].attributes[j]; j += 2) {
|
||||
game_set_attribute_const(i, games[i].attributes[j], games[i].attributes[j+1]);
|
||||
}
|
||||
@ -253,7 +253,7 @@ void init_games() {
|
||||
void games_done() {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
g_free(games[i].real_home);
|
||||
}
|
||||
}
|
||||
@ -282,13 +282,13 @@ enum server_type id2type (const char *id) {
|
||||
|
||||
g_return_val_if_fail(id != NULL, UNKNOWN_SERVER);
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
g_return_val_if_fail(games[i].id != NULL, UNKNOWN_SERVER);
|
||||
if (g_ascii_strcasecmp (id, games[i].id) == 0)
|
||||
return games[i].type;
|
||||
}
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
if (g_ascii_strcasecmp (id, games[i].qstat_str) == 0)
|
||||
return games[i].type;
|
||||
}
|
||||
|
@ -274,10 +274,10 @@ GameList* parseGames(const char* filename) {
|
||||
return list;
|
||||
}
|
||||
|
||||
void printGame(FILE* f, RawGame* rg, RawGame* template) {
|
||||
void printGame(FILE* cfile, RawGame* rg, RawGame* template) {
|
||||
GameTag tag;
|
||||
|
||||
fputs("\t{\n", f);
|
||||
fputs("\t{\n", cfile);
|
||||
for (tag = TAG_start_basic; tag <= TAG_end_basic; ++tag) {
|
||||
xmlChar* val = rg->basic[tag];
|
||||
|
||||
@ -291,13 +291,13 @@ void printGame(FILE* f, RawGame* rg, RawGame* template) {
|
||||
|
||||
switch(tag_type(tag)) {
|
||||
case Tag_type_string:
|
||||
fprintf(f, "\t\t.%-20s = \"%s\",\n", tag_name(tag), val);
|
||||
fprintf(cfile, "\t\t.%-20s = \"%s\",\n", tag_name(tag), val);
|
||||
break;
|
||||
case Tag_type_address:
|
||||
fprintf(f, "\t\t.%-20s = &%s,\n", tag_name(tag), val);
|
||||
fprintf(cfile, "\t\t.%-20s = &%s,\n", tag_name(tag), val);
|
||||
break;
|
||||
case Tag_type_literal:
|
||||
fprintf(f, "\t\t.%-20s = %s,\n", tag_name(tag), val);
|
||||
fprintf(cfile, "\t\t.%-20s = %s,\n", tag_name(tag), val);
|
||||
break;
|
||||
case Tag_type_invalid:
|
||||
break;
|
||||
@ -315,10 +315,10 @@ void printGame(FILE* f, RawGame* rg, RawGame* template) {
|
||||
|
||||
if (!m || !m->val || !xmlStrcmp(m->val, (xmlChar*) "NULL")) continue;
|
||||
|
||||
fprintf(f, "\t\t.%-20s = stringlist%03u,\n", tag_name(tag), rg->num_multitags++);
|
||||
fprintf(cfile, "\t\t.%-20s = stringlist%03u,\n", tag_name(tag), rg->num_multitags++);
|
||||
}
|
||||
|
||||
fputs("\t},\n", f);
|
||||
fputs("\t},\n", cfile);
|
||||
}
|
||||
|
||||
int main (int argc, char* argv[]) {
|
||||
@ -326,11 +326,19 @@ int main (int argc, char* argv[]) {
|
||||
GameList* ptr = NULL;
|
||||
GameList* next = NULL;
|
||||
RawGame* template = NULL;
|
||||
unsigned i = 0;
|
||||
unsigned i = 0, type_count;
|
||||
|
||||
FILE* f = stdout;
|
||||
if (argc < 3) return 1;
|
||||
|
||||
if (argc < 2) return 1;
|
||||
FILE* cfile = fopen(argv[2], "w");;
|
||||
if (cfile == NULL) {
|
||||
fprintf(stderr, "%s: can't write to file\n", argv[2]);
|
||||
}
|
||||
|
||||
FILE* hfile = fopen(argv[3], "w");;
|
||||
if (hfile == NULL) {
|
||||
fprintf(stderr, "%s: can't write to file\n", argv[3]);
|
||||
}
|
||||
|
||||
tags_init();
|
||||
|
||||
@ -368,12 +376,17 @@ int main (int argc, char* argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
fputs("// DO NOT EDIT THIS FILE, AUTOMATICALLY GENERATED\n", f);
|
||||
fputs("// DO NOT EDIT THIS FILE, AUTOMATICALLY GENERATED\n", cfile);
|
||||
fputs("// DO NOT EDIT THIS FILE, AUTOMATICALLY GENERATED\n", hfile);
|
||||
|
||||
for (ptr = list; ptr; ptr = ptr->next) {
|
||||
fputs("enum server_type {\n", hfile);
|
||||
|
||||
for (ptr = list, type_count = 0; ptr; ptr = ptr->next, type_count++) {
|
||||
RawGame* rg = ptr->game;
|
||||
GameTag tag;
|
||||
|
||||
fprintf(hfile, "\t%s%s,\n", ptr->game->basic[TAG_type], type_count == 0 ? " = 0" : "");
|
||||
|
||||
for (tag = TAG_start_multi; tag <= TAG_end_multi; ++tag) {
|
||||
struct MultiTag* m = rg->multi[tag - TAG_start_multi];
|
||||
|
||||
@ -385,27 +398,29 @@ int main (int argc, char* argv[]) {
|
||||
|
||||
if (!m || !m->val || !xmlStrcmp(m->val, (xmlChar*) "NULL")) continue;
|
||||
|
||||
fprintf(f, "static char* stringlist%03u[] = {", i);
|
||||
fprintf(cfile, "static char* stringlist%03u[] = {", i);
|
||||
for (; m; m = m->next) {
|
||||
fprintf(f, " \"%s\",", m->val);
|
||||
fprintf(cfile, " \"%s\",", m->val);
|
||||
}
|
||||
fputs(" NULL };\n", f);
|
||||
fputs(" NULL };\n", cfile);
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
fputs("struct game games[] = {\n", f);
|
||||
fputs("};\n", hfile);
|
||||
|
||||
fputs("struct game games[] = {\n", cfile);
|
||||
|
||||
i = 0;
|
||||
for (ptr = list; ptr; ptr = ptr->next) {
|
||||
RawGame* rg = ptr->game;
|
||||
rg->num_multitags = i;
|
||||
printGame(f, rg, template);
|
||||
printGame(cfile, rg, template);
|
||||
i = rg->num_multitags;
|
||||
}
|
||||
|
||||
fputs("};\n", f);
|
||||
fputs("};\n", cfile);
|
||||
|
||||
// TODO free
|
||||
|
||||
|
@ -253,7 +253,7 @@ void free_pixmaps (void) {
|
||||
free_pixmap (&punkbuster_pix);
|
||||
free_pixmap (&locked_punkbuster_pix);
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
free_pixmap(games[i].pix);
|
||||
g_free(games[i].pix);
|
||||
games[i].pix = NULL;
|
||||
@ -373,7 +373,7 @@ void init_pixmaps (GtkWidget *window) {
|
||||
create_pixmap (window, "punkbuster.xpm", &punkbuster_pix);
|
||||
cat_pixmaps(window, &locked_punkbuster_pix, &punkbuster_pix, &locked_pix);
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
struct pixmap* pix = NULL;
|
||||
|
||||
pix = g_malloc0(sizeof(struct pixmap));
|
||||
|
32
src/pref.c
32
src/pref.c
@ -217,9 +217,9 @@ static int q2_skin_is_valid = TRUE;
|
||||
|
||||
static GtkWidget *color_menu = NULL;
|
||||
|
||||
static GtkWidget *custom_args_add_button[GAMES_TOTAL];
|
||||
static GtkWidget *custom_args_entry_game[GAMES_TOTAL];
|
||||
static GtkWidget *custom_args_entry_args[GAMES_TOTAL];
|
||||
static GtkWidget *custom_args_add_button[UNKNOWN_SERVER];
|
||||
static GtkWidget *custom_args_entry_game[UNKNOWN_SERVER];
|
||||
static GtkWidget *custom_args_entry_args[UNKNOWN_SERVER];
|
||||
static int current_row = -1;
|
||||
|
||||
struct generic_prefs {
|
||||
@ -1191,7 +1191,7 @@ static void get_new_defaults (void) {
|
||||
|
||||
config_pop_prefix();
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
get_new_defaults_for_game (i);
|
||||
}
|
||||
|
||||
@ -3039,7 +3039,7 @@ static void game_listitem_selected_callback (GtkItem *item, enum server_type typ
|
||||
|
||||
|
||||
#define GAMES_COLS 3
|
||||
#define GAMES_ROWS ((GAMES_TOTAL + GAMES_COLS - 1) / GAMES_COLS)
|
||||
#define GAMES_ROWS ((UNKNOWN_SERVER + GAMES_COLS - 1) / GAMES_COLS)
|
||||
|
||||
// create dialog where commandline and working dir for all games are configured
|
||||
static GtkWidget *games_config_page (int defgame) {
|
||||
@ -3075,7 +3075,7 @@ static GtkWidget *games_config_page (int defgame) {
|
||||
// gtk_container_add (GTK_CONTAINER (scrollwin), gtklist);
|
||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollwin), gtklist);
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
genprefs[i].game_button = gtk_list_item_new();
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (genprefs[i].game_button), game_pixmap_with_label (i));
|
||||
@ -3099,7 +3099,7 @@ static GtkWidget *games_config_page (int defgame) {
|
||||
gtk_notebook_set_show_border (GTK_NOTEBOOK (games_notebook), FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (games_hbox), games_notebook, FALSE, FALSE, 15);
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
page = generic_game_frame (i);
|
||||
|
||||
label = gtk_label_new (games[i].name);
|
||||
@ -3117,7 +3117,7 @@ static GtkWidget *games_config_page (int defgame) {
|
||||
}
|
||||
}
|
||||
|
||||
if (defgame >= GAMES_TOTAL) {
|
||||
if (defgame >= UNKNOWN_SERVER) {
|
||||
defgame = QW_SERVER;
|
||||
}
|
||||
|
||||
@ -3695,7 +3695,7 @@ static void save_srvinfo_toggled_callback (GtkWidget *widget, gpointer data) {
|
||||
static void scan_maps_callback (GtkWidget *widget, gpointer data) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
scan_maps_for(i);
|
||||
}
|
||||
|
||||
@ -4332,7 +4332,7 @@ static struct generic_prefs* new_generic_prefs (void) {
|
||||
|
||||
struct generic_prefs* new_genprefs;
|
||||
|
||||
new_genprefs = g_malloc0 (sizeof (struct generic_prefs) * GAMES_TOTAL);
|
||||
new_genprefs = g_malloc0 (sizeof (struct generic_prefs) * UNKNOWN_SERVER);
|
||||
|
||||
pref_q1_top_color = default_q1_top_color;
|
||||
pref_q1_bottom_color = default_q1_bottom_color;
|
||||
@ -4387,7 +4387,7 @@ static struct generic_prefs* new_generic_prefs (void) {
|
||||
new_genprefs[TURTLEARENA_SERVER].add_options_to_notebook = add_q3_options_to_notebook;
|
||||
new_genprefs[ALIENARENA_SERVER].add_options_to_notebook = add_q3_options_to_notebook;
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
new_genprefs[i].pref_dir = g_strdup (games[i].dir);
|
||||
new_genprefs[i].real_dir = g_strdup (games[i].real_dir);
|
||||
g_datalist_init(&new_genprefs[i].games_data);
|
||||
@ -4403,7 +4403,7 @@ static void generic_prefs_free(struct generic_prefs* prefs) {
|
||||
g_free(pref_qw_skin);
|
||||
g_free(pref_q2_skin);
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
g_free(prefs[i].pref_dir);
|
||||
g_free(prefs[i].real_dir);
|
||||
g_datalist_clear(&prefs[i].games_data);
|
||||
@ -4498,7 +4498,7 @@ void preferences_dialog (int page_num) {
|
||||
q2_skin_is_valid = TRUE;
|
||||
update_q2_skins (pref_q2_skin);
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
update_cfgs (i, genprefs[i].real_dir, games[i].game_cfg);
|
||||
}
|
||||
|
||||
@ -4577,7 +4577,7 @@ static void user_fix_defaults (void) {
|
||||
|
||||
debug(1, "Setting defaults");
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
files = games[i].command;
|
||||
if (!files) continue;
|
||||
suggested_file = find_file_in_path_list_relative(files);
|
||||
@ -4818,7 +4818,7 @@ int prefs_load (void) {
|
||||
|
||||
} while (0);
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
prefs_load_for_game (i);
|
||||
}
|
||||
|
||||
@ -4894,7 +4894,7 @@ int prefs_load (void) {
|
||||
|
||||
/* Convert "dir" -> "real_dir" for all game types */
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
load_game_defaults (i);
|
||||
|
||||
if (default_auto_maps && !skip_startup_mapscan) {
|
||||
|
@ -1673,7 +1673,7 @@ void init_masters (int update) {
|
||||
|
||||
favorites = create_master (N_("Favorites"), UNKNOWN_SERVER, FALSE);
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
m = create_master (games[i].name, i, TRUE);
|
||||
master_groups = g_slist_append (master_groups, m);
|
||||
}
|
||||
|
@ -123,21 +123,21 @@ static enum server_type selected_country;
|
||||
static void server_stats_create (void) {
|
||||
#ifdef USE_GEOIP
|
||||
unsigned g;
|
||||
// position GAMES_TOTAL is used for total number of all games
|
||||
unsigned i = (sizeof(struct country_stats) + geoip_num_countries()*sizeof(struct country_num)) * (GAMES_TOTAL+1);
|
||||
// position UNKNOWN_SERVER is used for total number of all games
|
||||
unsigned i = (sizeof(struct country_stats) + geoip_num_countries()*sizeof(struct country_num)) * (UNKNOWN_SERVER+1);
|
||||
srv_countries = g_malloc0 (i);
|
||||
|
||||
for (g = 0; g < GAMES_TOTAL+1; ++g) {
|
||||
for (g = 0; g < UNKNOWN_SERVER+1; ++g) {
|
||||
srv_countries[g].country = (struct country_num*)((void*)srv_countries
|
||||
+ sizeof(struct country_stats)*(GAMES_TOTAL+1) + g*geoip_num_countries()*sizeof(struct country_num));
|
||||
+ sizeof(struct country_stats)*(UNKNOWN_SERVER+1) + g*geoip_num_countries()*sizeof(struct country_num));
|
||||
}
|
||||
#endif
|
||||
|
||||
// position GAMES_TOTAL is used for total number of all games
|
||||
srv_stats = g_malloc0 (sizeof (struct server_stats) * (GAMES_TOTAL+1));
|
||||
// position UNKNOWN_SERVER is used for total number of all games
|
||||
srv_stats = g_malloc0 (sizeof (struct server_stats) * (UNKNOWN_SERVER+1));
|
||||
|
||||
srv_archs = g_malloc0 (sizeof (struct arch_stats) * GAMES_TOTAL);
|
||||
players = g_malloc0 (sizeof (struct arch_stats) * GAMES_TOTAL);
|
||||
srv_archs = g_malloc0 (sizeof (struct arch_stats) * UNKNOWN_SERVER);
|
||||
players = g_malloc0 (sizeof (struct arch_stats) * UNKNOWN_SERVER);
|
||||
|
||||
servers_count = 0;
|
||||
players_count = 0;
|
||||
@ -278,9 +278,9 @@ static void collect_statistics (void) {
|
||||
srv_countries[s->type].country[s->country_id].c = s->country_id;
|
||||
++srv_countries[s->type].nonzero;
|
||||
}
|
||||
if (++srv_countries[GAMES_TOTAL].country[s->country_id].n == 1) {
|
||||
srv_countries[GAMES_TOTAL].country[s->country_id].c = s->country_id;
|
||||
++srv_countries[GAMES_TOTAL].nonzero;
|
||||
if (++srv_countries[UNKNOWN_SERVER].country[s->country_id].n == 1) {
|
||||
srv_countries[UNKNOWN_SERVER].country[s->country_id].c = s->country_id;
|
||||
++srv_countries[UNKNOWN_SERVER].nonzero;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -321,7 +321,7 @@ static void collect_statistics (void) {
|
||||
#ifdef USE_GEOIP
|
||||
{
|
||||
unsigned g;
|
||||
for (g = 0; g < GAMES_TOTAL+1; ++g) {
|
||||
for (g = 0; g < UNKNOWN_SERVER+1; ++g) {
|
||||
qsort(srv_countries[g].country, geoip_num_countries(), sizeof(struct country_num), country_stat_compare_func);
|
||||
}
|
||||
}
|
||||
@ -396,7 +396,7 @@ static GtkWidget *server_stats_page (void) {
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollwin), alignment);
|
||||
|
||||
table = gtk_table_new (GAMES_TOTAL + 2, 7, FALSE);
|
||||
table = gtk_table_new (UNKNOWN_SERVER + 2, 7, FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), table);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (table), 6);
|
||||
|
||||
@ -407,12 +407,12 @@ static GtkWidget *server_stats_page (void) {
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 1, 20);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 5, 20);
|
||||
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 12);
|
||||
gtk_table_set_row_spacing (GTK_TABLE (table), GAMES_TOTAL, 12);
|
||||
gtk_table_set_row_spacing (GTK_TABLE (table), UNKNOWN_SERVER, 12);
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
put_label_to_table (table, _(srv_headers[i]), 1.0, i + 1, 0);
|
||||
|
||||
for (i = 0, row = 1; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0, row = 1; i < UNKNOWN_SERVER; i++) {
|
||||
|
||||
// Skip a game if it's not configured and show only configured is enabled
|
||||
if (!games[i].cmd && default_show_only_configured_games)
|
||||
@ -426,12 +426,12 @@ static GtkWidget *server_stats_page (void) {
|
||||
put_server_stats (table, i, row);
|
||||
|
||||
{
|
||||
srv_stats[GAMES_TOTAL].servers += srv_stats[i].servers;
|
||||
srv_stats[GAMES_TOTAL].ok += srv_stats[i].ok;
|
||||
srv_stats[GAMES_TOTAL].timeout += srv_stats[i].timeout;
|
||||
srv_stats[GAMES_TOTAL].down += srv_stats[i].down;
|
||||
srv_stats[GAMES_TOTAL].na += srv_stats[i].na;
|
||||
srv_stats[GAMES_TOTAL].players += srv_stats[i].players;
|
||||
srv_stats[UNKNOWN_SERVER].servers += srv_stats[i].servers;
|
||||
srv_stats[UNKNOWN_SERVER].ok += srv_stats[i].ok;
|
||||
srv_stats[UNKNOWN_SERVER].timeout += srv_stats[i].timeout;
|
||||
srv_stats[UNKNOWN_SERVER].down += srv_stats[i].down;
|
||||
srv_stats[UNKNOWN_SERVER].na += srv_stats[i].na;
|
||||
srv_stats[UNKNOWN_SERVER].players += srv_stats[i].players;
|
||||
}
|
||||
|
||||
row++;
|
||||
@ -439,7 +439,7 @@ static GtkWidget *server_stats_page (void) {
|
||||
|
||||
put_label_to_table (table, _("Total"), 0.0, 0, row + 1);
|
||||
|
||||
put_server_stats (table, GAMES_TOTAL, row + 1);
|
||||
put_server_stats (table, UNKNOWN_SERVER, row + 1);
|
||||
|
||||
gtk_widget_show (table);
|
||||
gtk_widget_show (scrollwin);
|
||||
@ -554,7 +554,7 @@ static GtkWidget *archs_stats_page (void) {
|
||||
|
||||
to_activate = config_get_int("/" CONFIG_FILE "/Statistics/game");
|
||||
|
||||
for (type = 0; type < GAMES_TOTAL; ++type) {
|
||||
for (type = 0; type < UNKNOWN_SERVER; ++type) {
|
||||
if (!create_server_type_menu_filter_hasharch(type))
|
||||
continue;
|
||||
|
||||
@ -679,7 +679,7 @@ static GtkWidget *country_stats_page (void) {
|
||||
|
||||
selected_country = to_activate = config_get_int("/" CONFIG_FILE "/Statistics/country");
|
||||
|
||||
for (type = 0; type <= GAMES_TOTAL; ++type) {
|
||||
for (type = 0; type <= UNKNOWN_SERVER; ++type) {
|
||||
if (!srv_countries[type].nonzero)
|
||||
continue;
|
||||
|
||||
@ -692,7 +692,7 @@ static GtkWidget *country_stats_page (void) {
|
||||
hbox = gtk_hbox_new(FALSE,0);
|
||||
gtk_box_pack_start (GTK_BOX (page_vbox), hbox, FALSE, TRUE, 0);
|
||||
|
||||
option_menu = create_server_type_menu (to_activate == GAMES_TOTAL?-1:to_activate,
|
||||
option_menu = create_server_type_menu (to_activate == UNKNOWN_SERVER?-1:to_activate,
|
||||
create_server_type_menu_filter_hascountries,
|
||||
G_CALLBACK(select_country_server_type_callback));
|
||||
{
|
||||
@ -709,12 +709,12 @@ static GtkWidget *country_stats_page (void) {
|
||||
gtk_menu_prepend (GTK_MENU (menu), menu_item);
|
||||
gtk_container_add (GTK_CONTAINER (menu_item), label);
|
||||
|
||||
g_signal_connect (menu_item, "activate", G_CALLBACK (select_country_server_type_callback), (gpointer)GAMES_TOTAL);
|
||||
g_signal_connect (menu_item, "activate", G_CALLBACK (select_country_server_type_callback), (gpointer)UNKNOWN_SERVER);
|
||||
|
||||
gtk_widget_show (menu_item);
|
||||
gtk_widget_show (label);
|
||||
|
||||
if (to_activate == GAMES_TOTAL) {
|
||||
if (to_activate == UNKNOWN_SERVER) {
|
||||
gtk_menu_item_activate (GTK_MENU_ITEM (menu_item));
|
||||
gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), 0);
|
||||
}
|
||||
|
@ -763,7 +763,7 @@ GtkWidget *create_server_type_menu (int active_type, gboolean (*filterfunc)(enum
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
|
||||
for (i = 0; i < GAMES_TOTAL; ++i) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; ++i) {
|
||||
if (filterfunc && !filterfunc (i))
|
||||
continue;
|
||||
|
||||
|
@ -2521,7 +2521,7 @@ gboolean check_cmdline_launch (gpointer nothing) {
|
||||
if (port) // guess the type from the port
|
||||
{
|
||||
unsigned i = 0;
|
||||
for (i = 0; i < GAMES_TOTAL; i++) {
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
if (games[i].default_port == port) {
|
||||
++matches;
|
||||
if (type == UNKNOWN_SERVER) type = i;
|
||||
|
Loading…
x
Reference in New Issue
Block a user