]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Rename command/ipban.qc to command/banning.qc
authorSamual <samual@xonotic.org>
Thu, 29 Dec 2011 03:36:51 +0000 (22:36 -0500)
committerSamual <samual@xonotic.org>
Thu, 29 Dec 2011 03:36:51 +0000 (22:36 -0500)
qcsrc/server/command/banning.qc [new file with mode: 0644]
qcsrc/server/command/banning.qh [new file with mode: 0644]
qcsrc/server/command/ipban.qc [deleted file]
qcsrc/server/command/ipban.qh [deleted file]
qcsrc/server/progs.src

diff --git a/qcsrc/server/command/banning.qc b/qcsrc/server/command/banning.qc
new file mode 100644 (file)
index 0000000..1d142bf
--- /dev/null
@@ -0,0 +1,245 @@
+// =====================================================
+//  Banning and kicking command code, written by Samual
+//  Last updated: December 29th, 2011
+// =====================================================
+
+
+// =======================
+//  Command Sub-Functions
+// =======================
+
+void BanCommand_ban(float request, float argc)
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       
+                       return;
+               }
+                       
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "));
+                       print("  No arguments required.\n");
+                       return;
+               }
+       }
+}
+
+void BanCommand_banlist(float request)
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       
+                       return;
+               }
+                       
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "));
+                       print("  No arguments required.\n");
+                       return;
+               }
+       }
+}
+
+void BanCommand_kickban(float request, float argc)
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       
+                       return;
+               }
+                       
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "));
+                       print("  No arguments required.\n");
+                       return;
+               }
+       }
+}
+
+void BanCommand_unban(float request, float argc)
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       
+                       return;
+               }
+                       
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "));
+                       print("  No arguments required.\n");
+                       return;
+               }
+       }
+}
+
+/* use this when creating a new command, making sure to place it in alphabetical order... also,
+** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION!
+void BanCommand_(float request)
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       
+                       return;
+               }
+                       
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "));
+                       print("  No arguments required.\n");
+                       return;
+               }
+       }
+}
+*/
+
+
+// ==================================
+//  Macro system for server commands
+// ==================================
+
+// Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
+#define BAN_COMMANDS(request,arguments,command) \
+       BAN_COMMAND("ban", BanCommand_ban(request, arguments), "Ban an IP address or a range of addresses (like 1.2.3)") \
+       BAN_COMMAND("banlist", BanCommand_banlist(request), "List all existing bans") \
+       BAN_COMMAND("kickban", BanCommand_kickban(request, arguments), "Disconnect a client and ban it at the same time") \
+       BAN_COMMAND("unban", BanCommand_unban(request, arguments), "Remove an existing ban") \
+       /* nothing */
+
+void BanCommand_macro_help()
+{
+       #define BAN_COMMAND(name,function,description) \
+               { print("  ^2", name, "^7: ", description, "\n"); }
+               
+       BAN_COMMANDS(0, 0, "")
+       #undef BAN_COMMAND
+       
+       return;
+}
+
+float BanCommand_macro_command(float argc, string command)
+{
+       #define BAN_COMMAND(name,function,description) \
+               { if(name == strtolower(argv(0))) { function; return TRUE; } }
+               
+       BAN_COMMANDS(CMD_REQUEST_COMMAND, argc, command)
+       #undef BAN_COMMAND
+       
+       return FALSE;
+}
+
+float BanCommand_macro_usage(float argc)
+{
+       #define BAN_COMMAND(name,function,description) \
+               { if(name == strtolower(argv(1))) { function; return TRUE; } }
+               
+       BAN_COMMANDS(CMD_REQUEST_USAGE, argc, "")
+       #undef BAN_COMMAND
+       
+       return FALSE;
+}
+
+void BanCommand_macro_write_aliases(float fh)
+{
+       #define BAN_COMMAND(name,function,description) \
+               { CMD_Write_Alias("qc_cmd_sv", name, description); }
+       
+       BAN_COMMANDS(0, 0, "")
+       #undef BAN_COMMAND
+       
+       return;
+}
+
+float BanCommand(string command)
+{
+       float argc;
+       float bantime;
+       entity client;
+       float entno;
+       float masksize;
+       string reason;
+       float reasonarg;
+
+       argc = tokenize_console(command);
+       if(argv(0) == "help")
+       {
+               print("  kickban # n m p reason - kickban player n for m seconds, using mask size p (1 to 4)\n");
+               print("  ban ip m reason - ban an IP or range (incomplete IP, like 1.2.3) for m seconds\n");
+               print("  bans - list all existing bans\n");
+               print("  unban n - delete the entry #n from the bans list\n");
+               return TRUE;
+       }
+       if(argv(0) == "kickban")
+       {
+#define INITARG(c) reasonarg = c
+#define GETARG(v,d) if((argc > reasonarg) && ((v = stof(argv(reasonarg))) != 0)) ++reasonarg; else v = d
+#define RESTARG(v) if(argc > reasonarg) v = substring(command, argv_start_index(reasonarg), strlen(command) - argv_start_index(reasonarg)); else v = ""
+               if(argc >= 3)
+               {
+                       entno = stof(argv(2));
+                       if(entno > maxclients || entno < 1)
+                               return TRUE;
+                       client = edict_num(entno);
+
+                       INITARG(3);
+                       GETARG(bantime, autocvar_g_ban_default_bantime);
+                       GETARG(masksize, autocvar_g_ban_default_masksize);
+                       RESTARG(reason);
+
+                       Ban_KickBanClient(client, bantime, masksize, reason);
+                       return TRUE;
+               }
+       }
+       else if(argv(0) == "ban")
+       {
+               if(argc >= 2)
+               {
+                       string ip;
+                       ip = argv(1);
+
+                       INITARG(2);
+                       GETARG(bantime, autocvar_g_ban_default_bantime);
+                       RESTARG(reason);
+
+                       Ban_Insert(ip, bantime, reason, 1);
+                       return TRUE;
+               }
+#undef INITARG
+#undef GETARG
+#undef RESTARG
+       }
+       else if(argv(0) == "bans")
+       {
+               Ban_View();
+               return TRUE;
+       }
+       else if(argv(0) == "unban")
+       {
+               if(argc >= 2)
+               {
+                       float who;
+                       who = stof(argv(1));
+                       Ban_Delete(who);
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
\ No newline at end of file
diff --git a/qcsrc/server/command/banning.qh b/qcsrc/server/command/banning.qh
new file mode 100644 (file)
index 0000000..30b0099
--- /dev/null
@@ -0,0 +1,12 @@
+// ====================================
+//  Declarations for kick/ban commands
+//  Last updated: December 14th, 2011
+// =====================================
+
+void Ban_KickBanClient(entity client, float bantime, float masksize, string reason);
+void Ban_View();
+float Ban_Insert(string ip, float bantime, string reason, float dosync);
+float Ban_Delete(float i);
+
+// used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
+void BanCommand_macro_write_aliases(float fh)
\ No newline at end of file
diff --git a/qcsrc/server/command/ipban.qc b/qcsrc/server/command/ipban.qc
deleted file mode 100644 (file)
index 1d142bf..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-// =====================================================
-//  Banning and kicking command code, written by Samual
-//  Last updated: December 29th, 2011
-// =====================================================
-
-
-// =======================
-//  Command Sub-Functions
-// =======================
-
-void BanCommand_ban(float request, float argc)
-{
-       switch(request)
-       {
-               case CMD_REQUEST_COMMAND:
-               {
-                       
-                       return;
-               }
-                       
-               default:
-               case CMD_REQUEST_USAGE:
-               {
-                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "));
-                       print("  No arguments required.\n");
-                       return;
-               }
-       }
-}
-
-void BanCommand_banlist(float request)
-{
-       switch(request)
-       {
-               case CMD_REQUEST_COMMAND:
-               {
-                       
-                       return;
-               }
-                       
-               default:
-               case CMD_REQUEST_USAGE:
-               {
-                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "));
-                       print("  No arguments required.\n");
-                       return;
-               }
-       }
-}
-
-void BanCommand_kickban(float request, float argc)
-{
-       switch(request)
-       {
-               case CMD_REQUEST_COMMAND:
-               {
-                       
-                       return;
-               }
-                       
-               default:
-               case CMD_REQUEST_USAGE:
-               {
-                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "));
-                       print("  No arguments required.\n");
-                       return;
-               }
-       }
-}
-
-void BanCommand_unban(float request, float argc)
-{
-       switch(request)
-       {
-               case CMD_REQUEST_COMMAND:
-               {
-                       
-                       return;
-               }
-                       
-               default:
-               case CMD_REQUEST_USAGE:
-               {
-                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "));
-                       print("  No arguments required.\n");
-                       return;
-               }
-       }
-}
-
-/* use this when creating a new command, making sure to place it in alphabetical order... also,
-** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION!
-void BanCommand_(float request)
-{
-       switch(request)
-       {
-               case CMD_REQUEST_COMMAND:
-               {
-                       
-                       return;
-               }
-                       
-               default:
-               case CMD_REQUEST_USAGE:
-               {
-                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "));
-                       print("  No arguments required.\n");
-                       return;
-               }
-       }
-}
-*/
-
-
-// ==================================
-//  Macro system for server commands
-// ==================================
-
-// Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
-#define BAN_COMMANDS(request,arguments,command) \
-       BAN_COMMAND("ban", BanCommand_ban(request, arguments), "Ban an IP address or a range of addresses (like 1.2.3)") \
-       BAN_COMMAND("banlist", BanCommand_banlist(request), "List all existing bans") \
-       BAN_COMMAND("kickban", BanCommand_kickban(request, arguments), "Disconnect a client and ban it at the same time") \
-       BAN_COMMAND("unban", BanCommand_unban(request, arguments), "Remove an existing ban") \
-       /* nothing */
-
-void BanCommand_macro_help()
-{
-       #define BAN_COMMAND(name,function,description) \
-               { print("  ^2", name, "^7: ", description, "\n"); }
-               
-       BAN_COMMANDS(0, 0, "")
-       #undef BAN_COMMAND
-       
-       return;
-}
-
-float BanCommand_macro_command(float argc, string command)
-{
-       #define BAN_COMMAND(name,function,description) \
-               { if(name == strtolower(argv(0))) { function; return TRUE; } }
-               
-       BAN_COMMANDS(CMD_REQUEST_COMMAND, argc, command)
-       #undef BAN_COMMAND
-       
-       return FALSE;
-}
-
-float BanCommand_macro_usage(float argc)
-{
-       #define BAN_COMMAND(name,function,description) \
-               { if(name == strtolower(argv(1))) { function; return TRUE; } }
-               
-       BAN_COMMANDS(CMD_REQUEST_USAGE, argc, "")
-       #undef BAN_COMMAND
-       
-       return FALSE;
-}
-
-void BanCommand_macro_write_aliases(float fh)
-{
-       #define BAN_COMMAND(name,function,description) \
-               { CMD_Write_Alias("qc_cmd_sv", name, description); }
-       
-       BAN_COMMANDS(0, 0, "")
-       #undef BAN_COMMAND
-       
-       return;
-}
-
-float BanCommand(string command)
-{
-       float argc;
-       float bantime;
-       entity client;
-       float entno;
-       float masksize;
-       string reason;
-       float reasonarg;
-
-       argc = tokenize_console(command);
-       if(argv(0) == "help")
-       {
-               print("  kickban # n m p reason - kickban player n for m seconds, using mask size p (1 to 4)\n");
-               print("  ban ip m reason - ban an IP or range (incomplete IP, like 1.2.3) for m seconds\n");
-               print("  bans - list all existing bans\n");
-               print("  unban n - delete the entry #n from the bans list\n");
-               return TRUE;
-       }
-       if(argv(0) == "kickban")
-       {
-#define INITARG(c) reasonarg = c
-#define GETARG(v,d) if((argc > reasonarg) && ((v = stof(argv(reasonarg))) != 0)) ++reasonarg; else v = d
-#define RESTARG(v) if(argc > reasonarg) v = substring(command, argv_start_index(reasonarg), strlen(command) - argv_start_index(reasonarg)); else v = ""
-               if(argc >= 3)
-               {
-                       entno = stof(argv(2));
-                       if(entno > maxclients || entno < 1)
-                               return TRUE;
-                       client = edict_num(entno);
-
-                       INITARG(3);
-                       GETARG(bantime, autocvar_g_ban_default_bantime);
-                       GETARG(masksize, autocvar_g_ban_default_masksize);
-                       RESTARG(reason);
-
-                       Ban_KickBanClient(client, bantime, masksize, reason);
-                       return TRUE;
-               }
-       }
-       else if(argv(0) == "ban")
-       {
-               if(argc >= 2)
-               {
-                       string ip;
-                       ip = argv(1);
-
-                       INITARG(2);
-                       GETARG(bantime, autocvar_g_ban_default_bantime);
-                       RESTARG(reason);
-
-                       Ban_Insert(ip, bantime, reason, 1);
-                       return TRUE;
-               }
-#undef INITARG
-#undef GETARG
-#undef RESTARG
-       }
-       else if(argv(0) == "bans")
-       {
-               Ban_View();
-               return TRUE;
-       }
-       else if(argv(0) == "unban")
-       {
-               if(argc >= 2)
-               {
-                       float who;
-                       who = stof(argv(1));
-                       Ban_Delete(who);
-                       return TRUE;
-               }
-       }
-       return FALSE;
-}
\ No newline at end of file
diff --git a/qcsrc/server/command/ipban.qh b/qcsrc/server/command/ipban.qh
deleted file mode 100644 (file)
index 30b0099..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// ====================================
-//  Declarations for kick/ban commands
-//  Last updated: December 14th, 2011
-// =====================================
-
-void Ban_KickBanClient(entity client, float bantime, float masksize, string reason);
-void Ban_View();
-float Ban_Insert(string ip, float bantime, string reason, float dosync);
-float Ban_Delete(float i);
-
-// used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
-void BanCommand_macro_write_aliases(float fh)
\ No newline at end of file
index 0a4c296cc445ac4b1e46e2ec3908019ece2e1de1..98f8197548bb3f1f2ac232493d7b046b412b2dfc 100644 (file)
@@ -40,7 +40,7 @@ campaign.qh
 ../common/mapinfo.qh
 
 command/common.qh
-command/ipban.qh
+command/banning.qh
 command/radarmap.qh
 command/vote.qh
 command/cmd.qh
@@ -152,7 +152,7 @@ campaign.qc
 ../common/command/rpn.qc
 ../common/command/generic.qc
 command/common.qc
-command/ipban.qc
+command/banning.qc
 command/radarmap.qc
 command/vote.qc
 command/cmd.qc