From 99b2c70137fef05a5a18f439b9010ddba455f5cb Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Sat, 27 Jun 2020 15:18:45 +0200 Subject: Create a shared mc protocol implementation and use it in the proxy and cmd line tool --- minecctl/rcon-commands.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'minecctl/rcon-commands.c') diff --git a/minecctl/rcon-commands.c b/minecctl/rcon-commands.c index 02b970f..cf43c5e 100644 --- a/minecctl/rcon-commands.c +++ b/minecctl/rcon-commands.c @@ -387,23 +387,22 @@ do_stop_all(struct cfg *cfg) { } bool -do_pcount(struct cfg *cfg) { - int fd; - unsigned current, max; +do_rcon_pcount(struct cfg *cfg, unsigned *online, unsigned *max) +{ struct server *server; + bool rv; + int fd; server = server_get_default(cfg); fd = rcon_login(cfg, server); if (fd < 0) return false; - if (get_player_count(fd, ¤t, &max)) { - info("Players: %u/%u", current, max); - return true; - } else { - die("Failed to get player count"); - return false; - } + rv = get_player_count(fd, online, max); + + close(fd); + + return rv; } bool -- cgit v1.2.3