From c57d6480bf36c69c5f77d69e1eb1b1b2bc94ddd3 Mon Sep 17 00:00:00 2001
From: David Härdeman <david@hardeman.nu>
Date: Fri, 26 Jun 2020 15:02:59 +0200
Subject: Make args to get_player_count optional

---
 minecctl/minecctl-rcon.c | 23 ++++++++++++++---------
 1 file 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;
-- 
cgit v1.2.3