]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/banning.qc
Merge branch 'master' into terencehill/slider_anim_improvements
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / banning.qc
index aed01c7cbf9ab7e126e808c432d6baa6b769a07c..add929004c0cece3df6467b8f2ec64e931acbea8 100644 (file)
@@ -1,3 +1,14 @@
+#include "../../common/command/command.qh"
+#include "banning.qh"
+#include "../_all.qh"
+
+#include "common.qh"
+
+#include "../cl_player.qh"
+#include "../ipban.qh"
+
+#include "../../common/util.qh"
+
 // =====================================================
 //  Banning and kicking command code, written by Samual
 //  Last updated: December 29th, 2011
@@ -26,14 +37,14 @@ void BanCommand_ban(float request, float argc, string command)
                }
 
                default:
-                       print("Incorrect parameters for ^2ban^7\n");
+                       LOG_INFO("Incorrect parameters for ^2ban^7\n");
                case CMD_REQUEST_USAGE:
                {
-                       print("\nUsage:^3 sv_cmd ban address [bantime] [reason]\n");
-                       print("  'address' is the IP address or range of the player to ban,\n");
-                       print("  'bantime' is the amount of time that the ban is active (default if not provided),\n");
-                       print("  and 'reason' is the string to label the ban with as reason for banning.\n");
-                       print("See also: ^2banlist, kickban, unban^7\n");
+                       LOG_INFO("\nUsage:^3 sv_cmd ban address [bantime] [reason]\n");
+                       LOG_INFO("  'address' is the IP address or range of the player to ban,\n");
+                       LOG_INFO("  'bantime' is the amount of time that the ban is active (default if not provided),\n");
+                       LOG_INFO("  and 'reason' is the string to label the ban with as reason for banning.\n");
+                       LOG_INFO("See also: ^2banlist, kickban, unban^7\n");
                        return;
                }
        }
@@ -52,9 +63,9 @@ void BanCommand_banlist(float request)
                default:
                case CMD_REQUEST_USAGE:
                {
-                       print("\nUsage:^3 sv_cmd banlist\n");
-                       print("  No arguments required.\n");
-                       print("See also: ^2ban, kickban, unban^7\n");
+                       LOG_INFO("\nUsage:^3 sv_cmd banlist\n");
+                       LOG_INFO("  No arguments required.\n");
+                       LOG_INFO("See also: ^2ban, kickban, unban^7\n");
                        return;
                }
        }
@@ -87,21 +98,21 @@ void BanCommand_kickban(float request, float argc, string command)
                                }
                                else
                                {
-                                       print("kickban: ", GetClientErrorString(accepted, argv(1)), ".\n");
+                                       LOG_INFO("kickban: ", GetClientErrorString(accepted, argv(1)), ".\n");
                                }
                        }
                }
 
                default:
-                       print("Incorrect parameters for ^2kickban^7\n");
+                       LOG_INFO("Incorrect parameters for ^2kickban^7\n");
                case CMD_REQUEST_USAGE:
                {
-                       print("\nUsage:^3 sv_cmd kickban client [bantime] [masksize] [reason]\n");
-                       print("  'client' is the entity number or name of the player to ban,\n");
-                       print("  'bantime' is the amount of time that the ban is active (default if not provided),\n");
-                       print("  'masksize' is the range of the IP address (1-thru-4, default if not provided),\n");
-                       print("  and 'reason' is the string to label the ban with as reason for banning.\n");
-                       print("See also: ^2ban, banlist, unban^7\n");
+                       LOG_INFO("\nUsage:^3 sv_cmd kickban client [bantime] [masksize] [reason]\n");
+                       LOG_INFO("  'client' is the entity number or name of the player to ban,\n");
+                       LOG_INFO("  'bantime' is the amount of time that the ban is active (default if not provided),\n");
+                       LOG_INFO("  'masksize' is the range of the IP address (1-thru-4, default if not provided),\n");
+                       LOG_INFO("  and 'reason' is the string to label the ban with as reason for banning.\n");
+                       LOG_INFO("See also: ^2ban, banlist, unban^7\n");
                        return;
                }
        }
@@ -116,27 +127,27 @@ void BanCommand_mute(float request, float argc, string command) // TODO: Add a s
                        if(argc >= 2)
                        {
                                entity client = GetFilteredEntity(argv(1));
-                               float accepted = VerifyClientEntity(client, TRUE, FALSE);
+                               float accepted = VerifyClientEntity(client, true, false);
 
                                if(accepted > 0)
                                {
-                                       client.muted = TRUE;
+                                       client.muted = true;
                                        return;
                                }
                                else
                                {
-                                       print("mute: ", GetClientErrorString(accepted, argv(1)), ".\n");
+                                       LOG_INFO("mute: ", GetClientErrorString(accepted, argv(1)), ".\n");
                                }
                        }
                }
 
                default:
-                       print("Incorrect parameters for ^2mute^7\n");
+                       LOG_INFO("Incorrect parameters for ^2mute^7\n");
                case CMD_REQUEST_USAGE:
                {
-                       print("\nUsage:^3 sv_cmd mute client\n");
-                       print("  'client' is the entity number or name of the player to mute.\n");
-                       print("See also: ^2unmute^7\n");
+                       LOG_INFO("\nUsage:^3 sv_cmd mute client\n");
+                       LOG_INFO("  'client' is the entity number or name of the player to mute.\n");
+                       LOG_INFO("See also: ^2unmute^7\n");
                        return;
                }
        }
@@ -187,9 +198,9 @@ void BanCommand_unban(float request, float argc)
                default:
                case CMD_REQUEST_USAGE:
                {
-                       print("\nUsage:^3 sv_cmd unban banid\n");
-                       print("  Where 'banid' is the ID of the ban of which to remove.\n");
-                       print("See also: ^2ban, banlist, kickban^7\n");
+                       LOG_INFO("\nUsage:^3 sv_cmd unban banid\n");
+                       LOG_INFO("  Where 'banid' is the ID of the ban of which to remove.\n");
+                       LOG_INFO("See also: ^2ban, banlist, kickban^7\n");
                        return;
                }
        }
@@ -204,27 +215,27 @@ void BanCommand_unmute(float request, float argc)
                        if(argc >= 2)
                        {
                                entity client = GetFilteredEntity(argv(1));
-                               float accepted = VerifyClientEntity(client, TRUE, FALSE);
+                               float accepted = VerifyClientEntity(client, true, false);
 
                                if(accepted > 0)
                                {
-                                       client.muted = FALSE;
+                                       client.muted = false;
                                        return;
                                }
                                else
                                {
-                                       print("unmute: ", GetClientErrorString(accepted, argv(1)), ".\n");
+                                       LOG_INFO("unmute: ", GetClientErrorString(accepted, argv(1)), ".\n");
                                }
                        }
                }
 
                default:
-                       print("Incorrect parameters for ^2mute^7\n");
+                       LOG_INFO("Incorrect parameters for ^2mute^7\n");
                case CMD_REQUEST_USAGE:
                {
-                       print("\nUsage:^3 sv_cmd unmute client\n");
-                       print("  'client' is the entity number or name of the player to unmute.\n");
-                       print("See also: ^2mute^7\n");
+                       LOG_INFO("\nUsage:^3 sv_cmd unmute client\n");
+                       LOG_INFO("  'client' is the entity number or name of the player to unmute.\n");
+                       LOG_INFO("See also: ^2mute^7\n");
                        return;
                }
        }
@@ -271,9 +282,9 @@ void BanCommand_(float request)
 void BanCommand_macro_help()
 {
        #define BAN_COMMAND(name,function,description) \
-               { if(strtolower(description) != "") { print("  ^2", name, "^7: ", description, "\n"); } }
+               { if(strtolower(description) != "") { LOG_INFO("  ^2", name, "^7: ", description, "\n"); } }
 
-       BAN_COMMANDS(0, 0, "")
+       BAN_COMMANDS(0, 0, "");
        #undef BAN_COMMAND
 
        return;
@@ -282,23 +293,23 @@ void BanCommand_macro_help()
 float BanCommand_macro_command(float argc, string command)
 {
        #define BAN_COMMAND(name,function,description) \
-               { if(name == strtolower(argv(0))) { function; return TRUE; } }
+               { if(name == strtolower(argv(0))) { function; return true; } }
 
-       BAN_COMMANDS(CMD_REQUEST_COMMAND, argc, command)
+       BAN_COMMANDS(CMD_REQUEST_COMMAND, argc, command);
        #undef BAN_COMMAND
 
-       return FALSE;
+       return false;
 }
 
 float BanCommand_macro_usage(float argc)
 {
        #define BAN_COMMAND(name,function,description) \
-               { if(name == strtolower(argv(1))) { function; return TRUE; } }
+               { if(name == strtolower(argv(1))) { function; return true; } }
 
-       BAN_COMMANDS(CMD_REQUEST_USAGE, argc, "")
+       BAN_COMMANDS(CMD_REQUEST_USAGE, argc, "");
        #undef BAN_COMMAND
 
-       return FALSE;
+       return false;
 }
 
 void BanCommand_macro_write_aliases(float fh)
@@ -306,7 +317,7 @@ void BanCommand_macro_write_aliases(float fh)
        #define BAN_COMMAND(name,function,description) \
                { if(strtolower(description) != "") { CMD_Write_Alias("qc_cmd_sv", name, description); } }
 
-       BAN_COMMANDS(0, 0, "")
+       BAN_COMMANDS(0, 0, "");
        #undef BAN_COMMAND
 
        return;
@@ -323,8 +334,8 @@ float BanCommand(string command)
 
        if(BanCommand_macro_command(argc, command)) // continue as usual and scan for normal commands
        {
-               return TRUE; // handled by one of the above GenericCommand_* functions
+               return true; // handled by one of the above GenericCommand_* functions
        }
 
-       return FALSE;
+       return false;
 }