]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/ipban.qc
Properly support team field on trigger_multiple
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / ipban.qc
index 5de4c56a7e796260d04e69b812ba8f8ffc2320e9..98dbf5c55b748d5a4d106f8dadec8fc3e29b412f 100644 (file)
@@ -1,5 +1,7 @@
 #include "ipban.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "autocvars.qh"
 #include "command/banning.qh"
 #include "defs.qh"
@@ -91,18 +93,18 @@ void OnlineBanList_URI_Get_Callback(float id, float status, string data)
 
        if(id >= MAX_IPBAN_URIS)
        {
-               LOG_INFO("Received ban list for invalid ID\n");
+               LOG_INFO("Received ban list for invalid ID");
                return;
        }
 
        tokenize_console(autocvar_g_ban_sync_uri);
        uri = argv(id);
 
-       LOG_INFO("Received ban list from ", uri, ": ");
+       string prelude = strcat("Received ban list from ", uri, ": ");
 
        if(OnlineBanList_RequestWaiting[id] == 0)
        {
-               LOG_INFO("rejected (unexpected)\n");
+               LOG_INFO(prelude, "rejected (unexpected)");
                return;
        }
 
@@ -110,14 +112,14 @@ void OnlineBanList_URI_Get_Callback(float id, float status, string data)
 
        if(time > OnlineBanList_Timeout)
        {
-               LOG_INFO("rejected (too late)\n");
+               LOG_INFO(prelude, "rejected (too late)");
                return;
        }
 
        syncinterval = autocvar_g_ban_sync_interval;
        if(syncinterval == 0)
        {
-               LOG_INFO("rejected (syncing disabled)\n");
+               LOG_INFO(prelude, "rejected (syncing disabled)");
                return;
        }
        if(syncinterval > 0)
@@ -125,19 +127,19 @@ void OnlineBanList_URI_Get_Callback(float id, float status, string data)
 
        if(status != 0)
        {
-               LOG_INFO("error: status is ", ftos(status), "\n");
+               LOG_INFO(prelude, "error: status is ", ftos(status));
                return;
        }
 
        if(substring(data, 0, 1) == "<")
        {
-               LOG_INFO("error: received HTML instead of a ban list\n");
+               LOG_INFO(prelude, "error: received HTML instead of a ban list");
                return;
        }
 
        if(strstrofs(data, "\r", 0) != -1)
        {
-               LOG_INFO("error: received carriage returns\n");
+               LOG_INFO(prelude, "error: received carriage returns");
                return;
        }
 
@@ -148,11 +150,11 @@ void OnlineBanList_URI_Get_Callback(float id, float status, string data)
 
        if((n % 4) != 0)
        {
-               LOG_INFO("error: received invalid item count: ", ftos(n), "\n");
+               LOG_INFO(prelude, "error: received invalid item count: ", ftos(n));
                return;
        }
 
-       LOG_INFO("OK, ", ftos(n / 4), " items\n");
+       LOG_INFO(prelude, "OK, ", ftos(n / 4), " items");
 
        for(i = 0; i < n; i += 4)
        {
@@ -163,7 +165,7 @@ void OnlineBanList_URI_Get_Callback(float id, float status, string data)
 
                LOG_TRACE("received ban list item ", ftos(i / 4), ": ip=", ip);
                LOG_TRACE(" timeleft=", ftos(timeleft), " reason=", reason);
-               LOG_TRACE(" serverip=", serverip, "\n");
+               LOG_TRACE(" serverip=", serverip);
 
                timeleft -= 1.5 * autocvar_g_ban_sync_timeout;
                if(timeleft < 0)
@@ -175,7 +177,7 @@ void OnlineBanList_URI_Get_Callback(float id, float status, string data)
                        for(j = 0; j < l; ++j)
                                if(strstrofs("0123456789.", substring(ip, j, 1), 0) == -1)
                                {
-                                       LOG_INFO("Invalid character ", substring(ip, j, 1), " in IP address ", ip, ". Skipping this ban.\n");
+                                       LOG_INFO("Invalid character ", substring(ip, j, 1), " in IP address ", ip, ". Skipping this ban.");
                                        goto skip;
                                }
                }
@@ -189,8 +191,7 @@ void OnlineBanList_URI_Get_Callback(float id, float status, string data)
                        // the ban will be prolonged on the next sync
                        // or expire 5 seconds after the next timeout
                Ban_Insert(ip, timeleft, strcat("ban synced from ", serverip, " at ", uri), 0);
-               LOG_INFO("Ban list syncing: accepted ban of ", ip, " by ", serverip, " at ", uri, ": ");
-               LOG_INFO(reason, "\n");
+               LOG_INFO("Ban list syncing: accepted ban of ", ip, " by ", serverip, " at ", uri, ": ", reason);
 
 LABEL(skip)
        }
@@ -237,13 +238,13 @@ void OnlineBanList_Think(entity this)
        }
 
        if(autocvar_g_ban_sync_interval > 0)
-               self.nextthink = time + max(60, autocvar_g_ban_sync_interval * 60);
+               this.nextthink = time + max(60, autocvar_g_ban_sync_interval * 60);
        else
                goto killme;
        return;
 
 LABEL(killme)
-       remove(self);
+       delete(this);
 }
 
 const float BAN_MAX = 256;
@@ -328,7 +329,7 @@ void Ban_View()
        float i, n;
        string msg;
 
-       LOG_INFO("^2Listing all existing active bans:\n");
+       LOG_INFO("^2Listing all existing active bans:");
 
        n = 0;
        for(i = 0; i < ban_count; ++i)
@@ -342,10 +343,10 @@ void Ban_View()
                msg = strcat(msg, ban_ip[i], " is still banned for ");
                msg = strcat(msg, ftos(ban_expire[i] - time), " seconds");
 
-               LOG_INFO("  ", msg, "\n");
+               LOG_INFO("  ", msg);
        }
 
-       LOG_INFO("^2Done listing all active (", ftos(n), ") bans.\n");
+       LOG_INFO("^2Done listing all active (", ftos(n), ") bans.");
 }
 
 float Ban_GetClientIP(entity client)
@@ -507,10 +508,10 @@ float Ban_Insert(string ip, float bantime, string reason, float dosync)
                        if(time + bantime > ban_expire[i])
                        {
                                ban_expire[i] = time + bantime;
-                               LOG_TRACE(ip, "'s ban has been prolonged to ", ftos(bantime), " seconds from now\n");
+                               LOG_TRACE(ip, "'s ban has been prolonged to ", ftos(bantime), " seconds from now");
                        }
                        else
-                               LOG_TRACE(ip, "'s ban is still active until ", ftos(ban_expire[i] - time), " seconds from now\n");
+                               LOG_TRACE(ip, "'s ban is still active until ", ftos(ban_expire[i] - time), " seconds from now");
 
                        // and enforce
                        reason = Ban_Enforce(i, reason);
@@ -547,12 +548,12 @@ float Ban_Insert(string ip, float bantime, string reason, float dosync)
        if(i < ban_count)
        if(ban_expire[i] > time + bantime)
        {
-               LOG_INFO(ip, " could not get banned due to no free ban slot\n");
+               LOG_INFO(ip, " could not get banned due to no free ban slot");
                return false;
        }
        // okay, insert our new victim as i
        Ban_Delete(i);
-       LOG_TRACE(ip, " has been banned for ", ftos(bantime), " seconds\n");
+       LOG_TRACE(ip, " has been banned for ", ftos(bantime), " seconds");
        ban_expire[i] = time + bantime;
        ban_ip[i] = strzone(ip);
        ban_count = max(ban_count, i + 1);