(svn r3067) - Feature: allow unbanning players based on banlist-id (as well as IP).
authorDarkvater
Wed, 19 Oct 2005 19:38:35 +0000
changeset 2538 81e192bfcf10
parent 2537 d9c0df52a466
child 2539 20b0e2a6b9b0
(svn r3067) - Feature: allow unbanning players based on banlist-id (as well as IP).
- Feature: 'status' and 'clients' now show the IP of the players
console_cmds.c
network_server.c
network_server.h
--- a/console_cmds.c	Wed Oct 19 14:49:46 2005 +0000
+++ b/console_cmds.c	Wed Oct 19 19:38:35 2005 +0000
@@ -404,20 +404,24 @@
 
 DEF_CONSOLE_CMD(ConUnBan)
 {
-	uint i;
+	uint i, index;
 
 	if (argc == 0) {
-		IConsoleHelp("Unban a player from a network game. Usage: 'unban <ip>'");
+		IConsoleHelp("Unban a player from a network game. Usage: 'unban <ip\\id>'");
+		IConsoleHelp("For a list of banned IP's, see the command 'banlist'");
 		return true;
 	}
 
 	if (argc != 2) return false;
 
+	index = (strrchr(argv[1], '.') == '\0') ? atoi(argv[1]) : 0;
+	index--;
+
 	for (i = 0; i < lengthof(_network_ban_list); i++) {
 		if (_network_ban_list[i] == NULL || _network_ban_list[i][0] == '\0')
 			continue;
 
-		if (strncmp(_network_ban_list[i], argv[1], strlen(_network_ban_list[i])) == 0) {
+		if (strncmp(_network_ban_list[i], argv[1], strlen(_network_ban_list[i])) == 0 || index == i) {
 			_network_ban_list[i][0] = '\0';
 			IConsolePrint(_icolour_def, "IP unbanned.");
 			return true;
@@ -511,8 +515,8 @@
 		const NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs);
 
 		status = (cs->status <= STATUS_ACTIVE) ? stat_str[cs->status] : "unknown";
-		IConsolePrintF(8, "Client #%d/%s  status: %s  frame-lag: %d  play-as: %d  unique-id: %s",
-			cs->index, ci->client_name, status, lag, ci->client_playas, ci->unique_id);
+		IConsolePrintF(8, "Client #%1d  name: '%s'  status: '%s'  frame-lag: %3d  company: %1d  IP: %s  unique-id: '%s'",
+			cs->index, ci->client_name, status, lag, ci->client_playas, GetPlayerIP(ci), ci->unique_id);
 	}
 
 	return true;
@@ -613,13 +617,14 @@
 	NetworkClientInfo *ci;
 
 	if (argc == 0) {
-		IConsoleHelp("Get a list of connected clients including their ID, name, and company-id. Usage: 'clients'");
+		IConsoleHelp("Get a list of connected clients including their ID, name, company-id, and IP. Usage: 'clients'");
 		return true;
 	}
 
 	for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++) {
 		if (ci->client_index != NETWORK_EMPTY_INDEX) {
-			IConsolePrintF(8, "Client #%d   name: %s  play-as company: %d", ci->client_index, ci->client_name, ci->client_playas);
+			IConsolePrintF(8, "Client #%1d  name: '%s'  company: %1d  IP: %s",
+				ci->client_index, ci->client_name, ci->client_playas, GetPlayerIP(ci));
 		}
 	}
 
--- a/network_server.c	Wed Oct 19 14:49:46 2005 +0000
+++ b/network_server.c	Wed Oct 19 19:38:35 2005 +0000
@@ -762,8 +762,6 @@
 	}
 }
 
-static inline const char* GetPlayerIP(const NetworkClientInfo *ci) {return inet_ntoa(*(struct in_addr *)&ci->client_ip);}
-
 /** Enforce the command flags.
  * Eg a server-only command can only be executed by a server, etc.
  * @param *cp the commandpacket that is going to be checked
--- a/network_server.h	Wed Oct 19 14:49:46 2005 +0000
+++ b/network_server.h	Wed Oct 19 19:38:35 2005 +0000
@@ -20,6 +20,8 @@
 void NetworkServerMonthlyLoop(void);
 void NetworkServerYearlyLoop(void);
 
+static inline const char* GetPlayerIP(const NetworkClientInfo *ci) {return inet_ntoa(*(struct in_addr *)&ci->client_ip);}
+
 #endif /* ENABLE_NETWORK */
 
 #endif /* NETWORK_SERVER_H */