summaryrefslogtreecommitdiff
path: root/src/console_cmds.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-04-03 12:49:58 +0000
committerrubidium <rubidium@openttd.org>2009-04-03 12:49:58 +0000
commit89d0eca6b74e3e2986425991674d3ffc67e9b974 (patch)
treea9a8b85ca45707ad3ca8b3d702645e0741aa5516 /src/console_cmds.cpp
parentd84fb358f5e8628bc9dc89edf9494248e6fe0a97 (diff)
downloadopenttd-89d0eca6b74e3e2986425991674d3ffc67e9b974.tar.xz
(svn r15931) -Codechange: let the host and ban lists use of SmallVector.
Diffstat (limited to 'src/console_cmds.cpp')
-rw-r--r--src/console_cmds.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index bd19fe425..2c63e5fdc 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -422,7 +422,6 @@ DEF_CONSOLE_CMD(ConBan)
DEF_CONSOLE_CMD(ConUnBan)
{
- uint i, index;
if (argc == 0) {
IConsoleHelp("Unban a client from a network game. Usage: 'unban <ip | client-id>'");
@@ -432,15 +431,14 @@ DEF_CONSOLE_CMD(ConUnBan)
if (argc != 2) return false;
- index = (strchr(argv[1], '.') == NULL) ? atoi(argv[1]) : 0;
+ uint index = (strchr(argv[1], '.') == NULL) ? atoi(argv[1]) : 0;
index--;
+ uint i = 0;
- for (i = 0; i < lengthof(_network_ban_list); i++) {
- if (_network_ban_list[i] == NULL) continue;
-
+ for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++, i++) {
if (strcmp(_network_ban_list[i], argv[1]) == 0 || index == i) {
free(_network_ban_list[i]);
- _network_ban_list[i] = NULL;
+ _network_ban_list.Erase(iter);
IConsolePrint(CC_DEFAULT, "IP unbanned.");
return true;
}
@@ -452,8 +450,6 @@ DEF_CONSOLE_CMD(ConUnBan)
DEF_CONSOLE_CMD(ConBanList)
{
- uint i;
-
if (argc == 0) {
IConsoleHelp("List the IP's of banned clients: Usage 'banlist'");
return true;
@@ -461,9 +457,9 @@ DEF_CONSOLE_CMD(ConBanList)
IConsolePrint(CC_DEFAULT, "Banlist: ");
- for (i = 0; i < lengthof(_network_ban_list); i++) {
- if (_network_ban_list[i] != NULL)
- IConsolePrintF(CC_DEFAULT, " %d) %s", i + 1, _network_ban_list[i]);
+ uint i = 1;
+ for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++, i++) {
+ IConsolePrintF(CC_DEFAULT, " %d) %s", i, *iter);
}
return true;