Skip to content

Commit

Permalink
"/games lobby" command - show only games in lobby
Browse files Browse the repository at this point in the history
  • Loading branch information
HarpyWar committed Mar 25, 2014
1 parent a1fb914 commit 5d27cec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion conf/bnhelp.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ whois <player> - looks up some basic information on a user, including their acco
%lusers
/lusers - shows list of banned players in this channel
%games
/games [<gametag>] - displays current game list
/games [<gametag>] - 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
Expand Down
13 changes: 11 additions & 2 deletions src/bnetd/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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),
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
Expand All @@ -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]);
Expand Down

0 comments on commit 5d27cec

Please sign in to comment.