add LAN browser for all games, fix #213
add a dummy LAN_SERVER game and add to its master group all LAN servers for all games
This commit is contained in:
parent
ff4e58f4a1
commit
3c17a9f64e
Binary file not shown.
Before Width: | Height: | Size: 610 B After Width: | Height: | Size: 612 B |
10
src/game.c
10
src/game.c
@ -183,11 +183,11 @@ void init_games() {
|
||||
|
||||
debug(3, "initializing games");
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; i < UNKNOWN_SERVER; i++) {
|
||||
g_datalist_init(&games[i].games_data);
|
||||
}
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; 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]);
|
||||
}
|
||||
@ -213,7 +213,7 @@ void init_games() {
|
||||
void games_done() {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; i < UNKNOWN_SERVER; i++) {
|
||||
g_free(games[i].real_home);
|
||||
}
|
||||
}
|
||||
@ -242,13 +242,13 @@ enum server_type id2type (const char *id) {
|
||||
|
||||
g_return_val_if_fail(id != NULL, UNKNOWN_SERVER);
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (i = LAN_SERVER; 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 < UNKNOWN_SERVER; i++) {
|
||||
for (i = LAN_SERVER; i < UNKNOWN_SERVER; i++) {
|
||||
if (g_ascii_strcasecmp (id, games[i].qstat_str) == 0)
|
||||
return games[i].type;
|
||||
}
|
||||
|
@ -34,6 +34,12 @@
|
||||
<private_suffix/>
|
||||
<pd/>
|
||||
</game>
|
||||
<game>
|
||||
<type>LAN_SERVER</type>
|
||||
<id>LAN</id>
|
||||
<name>LAN</name>
|
||||
<icon>lan.xpm</icon>
|
||||
</game>
|
||||
<game>
|
||||
<base>Q2_SERVER</base>
|
||||
<type>AQ2_SERVER</type>
|
||||
|
@ -499,6 +499,7 @@ int main (int argc, char* argv[]) {
|
||||
|
||||
fclose(games_c_file);
|
||||
|
||||
fputs("#define KNOWN_SERVER_START LAN_SERVER + 1\n", games_h_file);
|
||||
fputs("enum server_type {\n", games_h_file);
|
||||
|
||||
// write server_type enum
|
||||
@ -512,6 +513,7 @@ int main (int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
fputs("};\n", games_h_file);
|
||||
fputs("#define KNOWN_SERVER_START LAN_SERVER + 1\n", games_h_file);
|
||||
|
||||
fclose(games_h_file);
|
||||
fclose(icons_c_file);
|
||||
|
@ -197,7 +197,7 @@ void free_pixmaps (void) {
|
||||
free_pixmap (&punkbuster_pix);
|
||||
free_pixmap (&locked_punkbuster_pix);
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (i = LAN_SERVER; i < UNKNOWN_SERVER; i++) {
|
||||
free_pixmap(games[i].pix);
|
||||
g_free(games[i].pix);
|
||||
games[i].pix = NULL;
|
||||
|
20
src/pref.c
20
src/pref.c
@ -1190,7 +1190,7 @@ static void get_new_defaults (void) {
|
||||
|
||||
config_pop_prefix();
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; i < UNKNOWN_SERVER; i++) {
|
||||
get_new_defaults_for_game (i);
|
||||
}
|
||||
|
||||
@ -3074,7 +3074,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 < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; 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));
|
||||
@ -3098,7 +3098,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 < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; i < UNKNOWN_SERVER; i++) {
|
||||
page = generic_game_frame (i);
|
||||
|
||||
label = gtk_label_new (games[i].name);
|
||||
@ -3694,7 +3694,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 < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; i < UNKNOWN_SERVER; i++) {
|
||||
scan_maps_for(i);
|
||||
}
|
||||
|
||||
@ -4386,7 +4386,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 < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; 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);
|
||||
@ -4402,7 +4402,7 @@ static void generic_prefs_free(struct generic_prefs* prefs) {
|
||||
g_free(pref_qw_skin);
|
||||
g_free(pref_q2_skin);
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; i < UNKNOWN_SERVER; i++) {
|
||||
g_free(prefs[i].pref_dir);
|
||||
g_free(prefs[i].real_dir);
|
||||
g_datalist_clear(&prefs[i].games_data);
|
||||
@ -4497,7 +4497,7 @@ void preferences_dialog (int page_num) {
|
||||
q2_skin_is_valid = TRUE;
|
||||
update_q2_skins (pref_q2_skin);
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; i < UNKNOWN_SERVER; i++) {
|
||||
update_cfgs (i, genprefs[i].real_dir, games[i].game_cfg);
|
||||
}
|
||||
|
||||
@ -4576,7 +4576,7 @@ static void user_fix_defaults (void) {
|
||||
|
||||
debug(1, "Setting defaults");
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; i < UNKNOWN_SERVER; i++) {
|
||||
files = games[i].command;
|
||||
if (!files) continue;
|
||||
suggested_file = find_file_in_path_list_relative(files);
|
||||
@ -4817,7 +4817,7 @@ int prefs_load (void) {
|
||||
|
||||
} while (0);
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; i < UNKNOWN_SERVER; i++) {
|
||||
prefs_load_for_game (i);
|
||||
}
|
||||
|
||||
@ -4893,7 +4893,7 @@ int prefs_load (void) {
|
||||
|
||||
/* Convert "dir" -> "real_dir" for all game types */
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; i < UNKNOWN_SERVER; i++) {
|
||||
load_game_defaults (i);
|
||||
|
||||
if (default_auto_maps && !skip_startup_mapscan) {
|
||||
|
26
src/source.c
26
src/source.c
@ -823,7 +823,6 @@ char *master_to_url(QFMaster* m) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/** only free content, not pointer itself */
|
||||
static void master_options_release(QFMasterOptions* o, gboolean doit) {
|
||||
if (!doit || !o) return;
|
||||
@ -860,6 +859,11 @@ struct master *add_master (char *path, char *name, enum server_type type, enum s
|
||||
case MASTER_NATIVE:
|
||||
case MASTER_GAMESPY:
|
||||
case MASTER_LAN:
|
||||
if (query_type == MASTER_LAN) {
|
||||
// override master “LAN” name with game name
|
||||
name = games[type].name;
|
||||
}
|
||||
|
||||
// check for valid hostname/ip
|
||||
if (parse_address (path + strlen(master_prefixes[query_type]), &addr, &port)) {
|
||||
// if no port was specified, add default master port if available or fail
|
||||
@ -978,6 +982,7 @@ struct master *add_master (char *path, char *name, enum server_type type, enum s
|
||||
freeoptions = FALSE;
|
||||
|
||||
if (m) {
|
||||
type = query_type == MASTER_LAN? LAN_SERVER : type;
|
||||
group = (struct master *) g_slist_nth_data (master_groups, type);
|
||||
group->masters = g_slist_append (group->masters, m);
|
||||
m->user = user;
|
||||
@ -999,7 +1004,12 @@ void free_master (struct master *m) {
|
||||
}
|
||||
else {
|
||||
if (m->type != UNKNOWN_SERVER) {
|
||||
group = (struct master *) g_slist_nth_data (master_groups, m->type);
|
||||
if (m->master_type == MASTER_LAN) {
|
||||
group = (struct master *) g_slist_nth_data (master_groups, LAN_SERVER);
|
||||
}
|
||||
else{
|
||||
group = (struct master *) g_slist_nth_data (master_groups, m->type);
|
||||
}
|
||||
group->masters = g_slist_remove (group->masters, m);
|
||||
}
|
||||
all_masters = g_slist_remove (all_masters, m);
|
||||
@ -1019,8 +1029,7 @@ void free_master (struct master *m) {
|
||||
g_free (m);
|
||||
}
|
||||
|
||||
|
||||
/** parse type of the form <TYPE>[,QSTAT_MASTER_OPION]
|
||||
/** parse type of the form <TYPE>[,QSTAT_MASTER_OPTION]
|
||||
* DESTRUCTIVE
|
||||
* @return qstat_master_option or NULL
|
||||
*/
|
||||
@ -1263,8 +1272,15 @@ void init_masters (int update) {
|
||||
|
||||
favorites = create_master (N_("Favorites"), UNKNOWN_SERVER, FALSE);
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; i++) {
|
||||
for (i = LAN_SERVER; i < UNKNOWN_SERVER; i++) {
|
||||
m = create_master (games[i].name, i, TRUE);
|
||||
|
||||
if (i == LAN_SERVER) {
|
||||
m->master_type = MASTER_LAN;
|
||||
g_free(m->name);
|
||||
m->name = g_strdup(N_("Local network"));
|
||||
}
|
||||
|
||||
master_groups = g_slist_append (master_groups, m);
|
||||
}
|
||||
|
||||
|
@ -123,18 +123,21 @@ static enum server_type selected_country;
|
||||
static void server_stats_create (void) {
|
||||
#ifdef USE_GEOIP
|
||||
unsigned g;
|
||||
// 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);
|
||||
|
||||
// HACK: 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 < UNKNOWN_SERVER+1; ++g) {
|
||||
// HACK: position UNKNOWN_SERVER is used for total number of all games
|
||||
for (g = KNOWN_SERVER_START; g <= UNKNOWN_SERVER; ++g) {
|
||||
srv_countries[g].country = (struct country_num*)((void*)srv_countries
|
||||
+ sizeof(struct country_stats)*(UNKNOWN_SERVER+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 UNKNOWN_SERVER is used for total number of all games
|
||||
srv_stats = g_malloc0 (sizeof (struct server_stats) * (UNKNOWN_SERVER+1));
|
||||
// HACK: 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) * UNKNOWN_SERVER);
|
||||
players = g_malloc0 (sizeof (struct arch_stats) * UNKNOWN_SERVER);
|
||||
@ -278,6 +281,7 @@ static void collect_statistics (void) {
|
||||
srv_countries[s->type].country[s->country_id].c = s->country_id;
|
||||
++srv_countries[s->type].nonzero;
|
||||
}
|
||||
// HACK: position UNKNOWN_SERVER is used for total number of all games
|
||||
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;
|
||||
@ -321,7 +325,8 @@ static void collect_statistics (void) {
|
||||
#ifdef USE_GEOIP
|
||||
{
|
||||
unsigned g;
|
||||
for (g = 0; g < UNKNOWN_SERVER+1; ++g) {
|
||||
// HACK: position UNKNOWN_SERVER is used for total number of all games
|
||||
for (g = KNOWN_SERVER_START; g <= UNKNOWN_SERVER; ++g) {
|
||||
qsort(srv_countries[g].country, geoip_num_countries(), sizeof(struct country_num), country_stat_compare_func);
|
||||
}
|
||||
}
|
||||
@ -412,7 +417,7 @@ static GtkWidget *server_stats_page (void) {
|
||||
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 < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START, 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,6 +431,7 @@ static GtkWidget *server_stats_page (void) {
|
||||
put_server_stats (table, i, row);
|
||||
|
||||
{
|
||||
// HACK: position UNKNOWN_SERVER is used for total number of all games
|
||||
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;
|
||||
@ -554,7 +560,7 @@ static GtkWidget *archs_stats_page (void) {
|
||||
|
||||
to_activate = config_get_int("/" CONFIG_FILE "/Statistics/game");
|
||||
|
||||
for (type = 0; type < UNKNOWN_SERVER; ++type) {
|
||||
for (type = KNOWN_SERVER_START; type < UNKNOWN_SERVER; ++type) {
|
||||
if (!create_server_type_menu_filter_hasharch(type))
|
||||
continue;
|
||||
|
||||
@ -679,7 +685,8 @@ static GtkWidget *country_stats_page (void) {
|
||||
|
||||
selected_country = to_activate = config_get_int("/" CONFIG_FILE "/Statistics/country");
|
||||
|
||||
for (type = 0; type <= UNKNOWN_SERVER; ++type) {
|
||||
// HACK: position UNKNOWN_SERVER is used for total number of all games
|
||||
for (type = KNOWN_SERVER_START; type <= UNKNOWN_SERVER; ++type) {
|
||||
if (!srv_countries[type].nonzero)
|
||||
continue;
|
||||
|
||||
|
116
src/xpm/lan.xpm
Normal file
116
src/xpm/lan.xpm
Normal file
@ -0,0 +1,116 @@
|
||||
/* XPM */
|
||||
static char * lan_xpm[] = {
|
||||
"16 16 97 2",
|
||||
" c None",
|
||||
". c #838383",
|
||||
"+ c #BABABA",
|
||||
"@ c #989898",
|
||||
"# c #000000",
|
||||
"$ c #4B4B4C",
|
||||
"% c #A7A7A7",
|
||||
"& c #9D9D9D",
|
||||
"* c #6C6C6C",
|
||||
"= c #676767",
|
||||
"- c #3E3B3B",
|
||||
"; c #7F8080",
|
||||
"> c #7F7F7F",
|
||||
", c #6B6B6B",
|
||||
"' c #505050",
|
||||
") c #919292",
|
||||
"! c #8C8C8C",
|
||||
"~ c #767575",
|
||||
"{ c #B5B5B5",
|
||||
"] c #D8D8D7",
|
||||
"^ c #ADACAC",
|
||||
"/ c #6E6E6E",
|
||||
"( c #6F6F6F",
|
||||
"_ c #474747",
|
||||
": c #848484",
|
||||
"< c #7A7A7A",
|
||||
"[ c #8E8E8E",
|
||||
"} c #D9DADB",
|
||||
"| c #FBFFFF",
|
||||
"1 c #FFFFFF",
|
||||
"2 c #FAFEFF",
|
||||
"3 c #CECFD0",
|
||||
"4 c #878787",
|
||||
"5 c #555656",
|
||||
"6 c #626262",
|
||||
"7 c #A2A2A2",
|
||||
"8 c #E3E4E4",
|
||||
"9 c #F1EBE9",
|
||||
"0 c #DCCABF",
|
||||
"a c #BEA192",
|
||||
"b c #C7B1AA",
|
||||
"c c #F0EBE9",
|
||||
"d c #DFDFDF",
|
||||
"e c #979696",
|
||||
"f c #5C5B5B",
|
||||
"g c #706F6F",
|
||||
"h c #5E5D5D",
|
||||
"i c #D0D0D0",
|
||||
"j c #F2F3F4",
|
||||
"k c #D0BAAA",
|
||||
"l c #B58B6E",
|
||||
"m c #CA946D",
|
||||
"n c #874017",
|
||||
"o c #C4ACA2",
|
||||
"p c #F4F4F5",
|
||||
"q c #C4C4C4",
|
||||
"r c #585757",
|
||||
"s c #646464",
|
||||
"t c #CECECE",
|
||||
"u c #F1F2F3",
|
||||
"v c #BEA58E",
|
||||
"w c #AE8159",
|
||||
"x c #F4AA6A",
|
||||
"y c #852500",
|
||||
"z c #B4978B",
|
||||
"A c #F1F1F2",
|
||||
"B c #CAC9C9",
|
||||
"C c #565656",
|
||||
"D c #676867",
|
||||
"E c #CCCCCC",
|
||||
"F c #EFF1F2",
|
||||
"G c #B59E84",
|
||||
"H c #A2642C",
|
||||
"I c #E08236",
|
||||
"J c #7D1E00",
|
||||
"K c #B89C90",
|
||||
"L c #EFEFEF",
|
||||
"M c #575757",
|
||||
"N c #606060",
|
||||
"O c #D1D1D1",
|
||||
"P c #AE957D",
|
||||
"Q c #954100",
|
||||
"R c #D36616",
|
||||
"S c #721A00",
|
||||
"T c #B1978D",
|
||||
"U c #F0F1F1",
|
||||
"V c #CFCECE",
|
||||
"W c #5A5959",
|
||||
"X c #555555",
|
||||
"Y c #656565",
|
||||
"Z c #4B443E",
|
||||
"` c #402818",
|
||||
" . c #513421",
|
||||
".. c #382519",
|
||||
"+. c #4D4543",
|
||||
"@. c #636362",
|
||||
"#. c #595959",
|
||||
" ",
|
||||
" . ",
|
||||
" + @ . . ",
|
||||
" # $ % & * * = ",
|
||||
" - ; & > , , * ' ",
|
||||
" ) ! ~ { ] ^ / ( _ ",
|
||||
" : < [ } | 1 2 3 4 , 5 ",
|
||||
" 6 = 7 8 9 0 a b c d e f 5 ",
|
||||
" g g h i j k l m n o p q r 6 6 ",
|
||||
" s t u v w x y z A B C ",
|
||||
" D E F G H I J K L B M ",
|
||||
" N O u P Q R S T U V W ",
|
||||
" D X Y Z ` ...+.@.#.W ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
@ -458,7 +458,8 @@ void source_ctree_add_master (GtkWidget *ctree, struct master *m) {
|
||||
return;
|
||||
|
||||
if (m->type != UNKNOWN_SERVER) {
|
||||
group = (struct master *) g_slist_nth_data (master_groups, m->type);
|
||||
enum server_type type = m->master_type == MASTER_LAN? LAN_SERVER : m->type;
|
||||
group = (struct master *) g_slist_nth_data (master_groups, type);
|
||||
source_ctree_enable_master_group (ctree, group, TRUE);
|
||||
}
|
||||
|
||||
@ -763,7 +764,7 @@ GtkWidget *create_server_type_menu (int active_type, gboolean (*filterfunc)(enum
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
|
||||
for (i = 0; i < UNKNOWN_SERVER; ++i) {
|
||||
for (i = KNOWN_SERVER_START; 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 < UNKNOWN_SERVER; i++) {
|
||||
for (i = KNOWN_SERVER_START; 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