static gchar *gfire_sq_gamespy2_details(gfire_game_server *p_server) { GString *str = g_string_new(NULL); gfire_sq_gamespy2_data *data = (gfire_sq_gamespy2_data*)p_server->data->proto_data; // General server infos g_string_append(str, _("<b><font size=\"5\">General Server Details:</font></b><br>")); // Server Name gchar *escaped = gfire_escape_html(p_server->data->name); g_string_append_printf(str, _("<b>Server Name:</b> %s<br>"), escaped); g_free(escaped); // Players g_string_append_printf(str, _("<b>Players:</b> %u/%u<br>"), p_server->data->players, p_server->data->max_players); // Map escaped = gfire_escape_html(p_server->data->map); g_string_append_printf(str, _("<b>Map:</b> %s<br>"), escaped); g_free(escaped); // Password secured g_string_append_printf(str, _("<b>Password secured:</b> %s<br>"), (g_strcmp0("True", g_datalist_get_data(&data->info, "password")) == 0) || (g_strcmp0("1", g_datalist_get_data(&data->info, "password")) == 0) ? _("Yes") : _("No")); // Game Type g_string_append_printf(str, _("<b>Game Type:</b> %s<br>"), g_datalist_get_data(&data->info, "gametype") ? (gchar*)g_datalist_get_data(&data->info, "gametype") : _("N/A")); // Version g_string_append_printf(str, _("<b>Version:</b> %s"), g_datalist_get_data(&data->info, "gamever") ? (gchar*)g_datalist_get_data(&data->info, "gamever") : _("N/A")); // Players g_string_append(str, _("<br><br><b><font size=\"5\">Players:</font></b><br><font face=\"monospace\"><b>Name Score Ping</b><br>")); GSList *cur = data->players; while(cur) { gfire_sq_gamespy2_player *player = (gfire_sq_gamespy2_player*)cur->data; gchar *unescaped = gfire_sq_gamespy2_fixed_len_string(player->name, 16); gchar *name = gfire_escape_html(unescaped); g_free(unescaped); g_string_append_printf(str, "%s %-10d %d<br>", name, player->score, player->ping); g_free(name); cur = g_slist_next(cur); } // Other server rules g_string_append(str, _("<br></font><b><font size=\"5\">All Server Info:</font></b><br>")); g_datalist_foreach(&data->info, gfire_sq_gamespy2_details_vars, str); return g_string_free(str, FALSE); }
gchar *gfire_game_short_name(guint32 p_gameid) { const gfire_game *game = gfire_game_by_id(p_gameid); if(!game) return g_strdup_printf("%u", p_gameid); return gfire_escape_html(game->short_name); }
gchar *gfire_game_name(guint32 p_gameid, gboolean p_html) { const gfire_game *game = gfire_game_by_id(p_gameid); if(!game) return g_strdup_printf("%u", p_gameid); if(p_html) return gfire_escape_html(game->name); else return g_strdup(game->name); }
static void gfire_sq_savage_details_vars(GQuark p_key, gpointer p_data, gpointer p_udata) { if(g_strcmp0(g_quark_to_string(p_key), "players") != 0) { gchar *escaped = gfire_escape_html((gchar*)p_data); gchar *html = gfire_sq_savage_color_codes_to_html(escaped); g_free(escaped); g_string_append_printf((GString*)p_udata, "<b>%s:</b> %s<br>", g_quark_to_string(p_key), html); g_free(html); } }
static gchar *gfire_sq_ase_details(gfire_game_server *p_server) { GString *str = g_string_new(NULL); gfire_sq_ase_data *data = (gfire_sq_ase_data*)p_server->data->proto_data; // General server infos g_string_append(str, _("<b><font size=\"5\">General Server Details:</font></b><br>")); // Server Name gchar *escaped = gfire_escape_html(data->server_name); gchar *name = gfire_sq_ase_color_codes_to_html(escaped); g_free(escaped); g_string_append_printf(str, _("<b>Server Name:</b> %s<br>"), name); g_free(name); // Players g_string_append_printf(str, _("<b>Players:</b> %u/%u<br>"), p_server->data->players, p_server->data->max_players); // Map escaped = gfire_escape_html(data->map); g_string_append_printf(str, _("<b>Map:</b> %s<br>"), escaped); g_free(escaped); // Password secured g_string_append_printf(str, _("<b>Password secured:</b> %s<br>"), data->password ? _("Yes") : _("No")); // Game Type g_string_append_printf(str, _("<b>Game Type:</b> %s<br>"), data->game_type); // Version g_string_append_printf(str, _("<b>Version:</b> %s"), data->version); // Players g_string_append(str, _("<br><br><b><font size=\"5\">Players:</font></b><br><font face=\"monospace\"><b>Name Score Ping</b><br>")); GSList *cur = data->players; while(cur) { gfire_sq_ase_player *player = (gfire_sq_ase_player*)cur->data; gchar *stripped = gfire_sq_ase_strip_color_codes(player->name ? player->name : _("N/A")); gchar *unescaped = gfire_sq_ase_fixed_len_string(stripped, 16); g_free(stripped); gchar *name = gfire_escape_html(unescaped); g_free(unescaped); unescaped = gfire_sq_ase_fixed_len_string(player->score ? player->score : _("N/A"), 10); gchar *score = gfire_escape_html(unescaped); g_free(unescaped); gchar *ping = gfire_escape_html(player->ping ? player->ping : _("N/A")); g_string_append_printf(str, "%s %s %s<br>", name, score, ping); g_free(ping); g_free(score); g_free(name); cur = g_slist_next(cur); } // Other server rules g_string_append(str, _("<br></font><b><font size=\"5\">All Server Rules:</font></b><br>")); g_datalist_foreach(&data->rules, gfire_sq_ase_details_vars, str); return g_string_free(str, FALSE); }
static void gfire_sq_gamespy2_details_vars(GQuark p_key, gpointer p_data, gpointer p_udata) { gchar *escaped = gfire_escape_html((gchar*)p_data); g_string_append_printf((GString*)p_udata, "<b>%s:</b> %s<br>", g_quark_to_string(p_key), escaped); g_free(escaped); }
static gchar *gfire_sq_savage_details(gfire_game_server *p_server) { GString *str = g_string_new(NULL); gchar *escaped; gchar *html; gfire_sq_savage_data *data = (gfire_sq_savage_data*)p_server->data->proto_data; // General server infos g_string_append(str, _("<b><font size=\"5\">General Server Details:</font></b><br>")); // Server Name if(g_datalist_get_data(&data->info, "name")) { escaped = gfire_escape_html(g_datalist_get_data(&data->info, "name")); html = gfire_sq_savage_color_codes_to_html(escaped); g_free(escaped); g_string_append_printf(str, _("<b>Server Name:</b> %s<br>"), html); g_free(html); } else g_string_append_printf(str, _("<b>Server Name:</b> %s<br>"), _("N/A")); // Players g_string_append_printf(str, _("<b>Players:</b> %u/%u<br>"), p_server->data->players, p_server->data->max_players); // Map escaped = gfire_escape_html(p_server->data->map); g_string_append_printf(str, _("<b>Map:</b> %s<br>"), escaped); g_free(escaped); // Password secured g_string_append_printf(str, _("<b>Password secured:</b> %s<br>"), (g_strcmp0("1", g_datalist_get_data(&data->info, "pass")) == 0) ? _("Yes") : _("No")); // Game Type if(g_datalist_get_data(&data->info, "gametype")) { escaped = gfire_escape_html(g_datalist_get_data(&data->info, "gametype")); html = gfire_sq_savage_color_codes_to_html(escaped); g_free(escaped); g_string_append_printf(str, _("<b>Game Type:</b> %s<br>"), html); g_free(html); } else g_string_append_printf(str, _("<b>Game Type:</b> %s<br>"), _("N/A")); // Version if(g_datalist_get_data(&data->info, "ver")) { escaped = gfire_escape_html(g_datalist_get_data(&data->info, "ver")); html = gfire_sq_savage_color_codes_to_html(escaped); g_free(escaped); g_string_append_printf(str, _("<b>Version:</b> %s"), html); g_free(html); } else g_string_append_printf(str, _("<b>Version:</b> %s"), _("N/A")); // Players g_string_append(str, _("<br><br><b><font size=\"5\">Players:</font></b><br>")); gchar **cur = data->players; while(cur && *cur) { escaped = gfire_escape_html(*cur); html = gfire_sq_savage_color_codes_to_html(escaped); g_free(escaped); g_string_append_printf(str, "%s<br>", html); g_free(html); cur++; } // Other server rules g_string_append(str, _("<br></font><b><font size=\"5\">All Server Info:</font></b><br>")); g_datalist_foreach(&data->info, gfire_sq_savage_details_vars, str); return g_string_free(str, FALSE); }