From 5d27cece2c24b5fe779f1560162a31442bf02617 Mon Sep 17 00:00:00 2001 From: HarpyWar Date: Tue, 25 Mar 2014 22:00:56 +0400 Subject: [PATCH] "/games lobby" command - show only games in lobby http://developer.berlios.de/patch/?func=detailpatch&patch_id=3235&group_id=2291 --- conf/bnhelp.conf.in | 3 ++- src/bnetd/command.cpp | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/conf/bnhelp.conf.in b/conf/bnhelp.conf.in index e3632bc6d..45162a6ea 100644 --- a/conf/bnhelp.conf.in +++ b/conf/bnhelp.conf.in @@ -53,7 +53,8 @@ whois - looks up some basic information on a user, including their acco %lusers /lusers - shows list of banned players in this channel %games -/games [] - displays current game list +/games [] - displays current game list of client type gametag, e.g. W3XP - Warcraft 3 TFT +/games [lobby], /games [l] - displays current list of games that are in the lobby (i.e. haven't started) %channels chs /channels /chs [all] - displays current channel list %connections con diff --git a/src/bnetd/command.cpp b/src/bnetd/command.cpp index def82a283..d1578cf12 100644 --- a/src/bnetd/command.cpp +++ b/src/bnetd/command.cpp @@ -2982,6 +2982,7 @@ namespace pvpgn t_game_difficulty diff; t_clienttag tag; t_connection *c; + bool lobby; }; static int _glist_cb(t_game *game, void *data) @@ -2990,7 +2991,8 @@ namespace pvpgn if ((!cbdata->tag || !prefs_get_hide_pass_games() || game_get_flag(game) != game_flag_private) && (!cbdata->tag || game_get_clienttag(game) == cbdata->tag) && - (cbdata->diff == game_difficulty_none || game_get_difficulty(game) == cbdata->diff)) + (cbdata->diff == game_difficulty_none || game_get_difficulty(game) == cbdata->diff) && + (cbdata->lobby == false || (game_get_status(game) != game_status_started && game_get_status(game) != game_status_done))) { snprintf(msgtemp, sizeof(msgtemp), " %-16.16s %1.1s %-8.8s %-21.21s %5u ", game_get_name(game), @@ -3020,7 +3022,7 @@ namespace pvpgn unsigned int i; unsigned int j; char clienttag_str[5]; - char dest[5]; + char dest[6]; struct glist_cb_struct cbdata; for (i = 0; text[i] != ' ' && text[i] != '\0'; i++); /* skip command */ @@ -3031,6 +3033,7 @@ namespace pvpgn for (; text[i] == ' '; i++); cbdata.c = c; + cbdata.lobby = false; if (std::strcmp(&text[i], "norm") == 0) cbdata.diff = game_difficulty_normal; @@ -3051,6 +3054,12 @@ namespace pvpgn cbdata.tag = 0; message_send_text(c, message_type_info, c, "All current games:"); } + else if (strcasecmp(&dest[0], "lobby") == 0 || strcasecmp(&dest[0], "l") == 0) + { + cbdata.tag = conn_get_clienttag(c); + cbdata.lobby = true; + message_send_text(c, message_type_info, c, "Games in lobby:"); + } else { cbdata.tag = tag_case_str_to_uint(&dest[0]);