From bb2406f63816cdf3b888c0aacf0f15a77b378d98 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Fri, 30 Dec 2016 13:13:22 +0100 Subject: Include player count in clientlist --- src/crsm.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/crsm.cpp') diff --git a/src/crsm.cpp b/src/crsm.cpp index 87bcbfe..b638bd9 100644 --- a/src/crsm.cpp +++ b/src/crsm.cpp @@ -2938,14 +2938,32 @@ CMD_FUNCTION_IMPL(noadmin) } CMD_FUNCTION_IMPL(clientlist) - QString response = "Verbundene Clients (Chatnick (PC-Name)): "; + if(Session.State == CRSMSession::None) + { + respond(client, "Es ist zurzeit nichts gehostet.\n"); + return Success; + } + + if(Session.Clonk.Clients.isEmpty()) + { + respond(client, "Keine verbundenen Clients.\n"); + return Success; + } + + QString response = "Verbundene Clients ((Anzahl Spieler) Chatnick (PC-Name)): "; foreach(const ClientInfo& connectedClient, Session.Clonk.Clients) { - if(connectedClient.nick.isEmpty()) - continue; - response += connectedClient.toString() + ", "; + response += "(" + QString::number(connectedClient.players.count()) + ") " + connectedClient.toString() + ", "; + } + + if(!Session.Clonk.Server.players.isEmpty()) + { + response += "(" + QString::number(Session.Clonk.Server.players.count()) + ") " + Session.Clonk.Server.toString() + ", "; + } + else + { + response.chop(2); } - response = response.left(response.length() - 2); respond(client, response + "\n"); return Success; } -- cgit v1.2.3-54-g00ecf