summaryrefslogtreecommitdiff
path: root/minecctl
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-26 15:02:59 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-26 15:02:59 +0200
commitc57d6480bf36c69c5f77d69e1eb1b1b2bc94ddd3 (patch)
treece462d6907c04507bda076439f2c8271b869acc7 /minecctl
parentc1d1ffc5e57f01c8da9b86cf0726735a30b9ee7c (diff)
Make args to get_player_count optional
Diffstat (limited to 'minecctl')
-rw-r--r--minecctl/minecctl-rcon.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/minecctl/minecctl-rcon.c b/minecctl/minecctl-rcon.c
index 16939d1..f11a20b 100644
--- a/minecctl/minecctl-rcon.c
+++ b/minecctl/minecctl-rcon.c
@@ -316,14 +316,20 @@ get_player_count(int fd, unsigned *current, unsigned *max)
{
char buf[4096];
const char *reply;
+ unsigned c, m;
- if (get_one_status(fd, buf, sizeof(buf), "list", 2,
- "There are %u of a max %u players online",
- &reply, current, max))
- return true;
-
- else
+ if (!get_one_status(fd, buf, sizeof(buf), "list", 2,
+ "There are %u of a max %u players online",
+ &reply, &c, &m))
return false;
+
+ if (current)
+ *current = c;
+
+ if (max)
+ *max = m;
+
+ return true;
}
static void
@@ -334,10 +340,9 @@ stop_one_server(struct cfg *cfg, struct server *server)
fd = rcon_login(cfg, server);
if (cfg->force_stop) {
- unsigned current, _unused_ max;
+ unsigned current;
- /* FIXME: args optional */
- if (!get_player_count(fd, &current, &max)) {
+ if (!get_player_count(fd, &current, NULL)) {
error("%s: unable to get player count, not stopping",
server->shortname);
return;