summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-10-09 20:36:31 +0000
committerfrosch <frosch@openttd.org>2012-10-09 20:36:31 +0000
commitde770d75636e218c2d2540a160d7c698015c8de2 (patch)
tree60d304ad29905dffb0f1cf79756b74c97e132138
parenta9af5f3c76e74db860cad1cdf22acdc7175bbb31 (diff)
downloadopenttd-de770d75636e218c2d2540a160d7c698015c8de2.tar.xz
(svn r24580) -Fix [FS#5308]: Do not add duplicates to the ban list. (alechz)
-rw-r--r--src/network/network_server.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index cd4e5f564..3464efa9c 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -2052,7 +2052,16 @@ uint NetworkServerKickOrBanIP(ClientID client_id, bool ban)
uint NetworkServerKickOrBanIP(const char *ip, bool ban)
{
/* Add address to ban-list */
- if (ban) *_network_ban_list.Append() = strdup(ip);
+ if (ban) {
+ bool contains = false;
+ for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++) {
+ if (strcmp(*iter, ip) == 0) {
+ contains = true;
+ break;
+ }
+ }
+ if (!contains) *_network_ban_list.Append() = strdup(ip);
+ }
uint n = 0;