]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/cmd.qh
New banning systems (ignore, muteban, voteban and playban) and new features for moder...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / cmd.qh
index bb97f0d0b17cf18926d1d0c05a996d4a515e116e..27be10dd32facfdb2cc69719edb3f00628958f9b 100644 (file)
@@ -1,11 +1,84 @@
 #pragma once
 
+#include <server/world.qh>
+
 float autocvar_sv_clientcommand_antispam_time;
 int autocvar_sv_clientcommand_antispam_count;
 
 .float cmd_floodtime;
+.string ignore_list; // stores player id's, maybe can be upgraded to store net address for reconnect protection
+
+const int IGNORE_MAXPLAYERS = 8; // maximum players to be ignored in the personal chat
 
 string MapVote_Suggest(entity this, string m);
 
 // used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
 void ClientCommand_macro_write_aliases(float fh);
+
+// functions for ignore command
+string ignore_removefromlist(entity list, entity ignore)
+{
+       if(ignore.crypto_idfp && ignore.crypto_idfp != "" && list.crypto_idfp && list.crypto_idfp != "")
+       {
+               for(int j = 0; j < IGNORE_MAXPLAYERS; ++j)
+               {
+                       string pos = db_get(ServerProgsDB, strcat("/ignore/", list.crypto_idfp, "/", ftos(j)));
+                       if(pos == ignore.crypto_idfp)
+                       {
+                               db_remove(ServerProgsDB, strcat("/ignore/", list.crypto_idfp, "/", ftos(j)));
+                               return string_null;
+                       }
+               }
+               // should this fall back? we know advanced mode is being used
+       }
+
+       string newlist = "";
+       string theid = ftos(etof(ignore));
+
+       FOREACH_WORD(list.ignore_list, it != theid,
+       {
+               newlist = cons(newlist, it);
+       });
+
+       if(newlist == "")
+               return string_null;
+       else
+               return newlist;
+}
+
+bool ignore_playerinlist(entity sender, entity targ)
+{
+       // TODO: optimize this by saving it to .ignore_list?
+       if(targ.crypto_idfp && targ.crypto_idfp != "" && sender.crypto_idfp && sender.crypto_idfp != "")
+       {
+               string thelist = "";
+               for(int j = 0; j < IGNORE_MAXPLAYERS; ++j)
+               {
+                       string pos = db_get(ServerProgsDB, strcat("/ignore/", targ.crypto_idfp, "/", ftos(j)));
+                       thelist = cons(thelist, pos);
+               }
+
+               return ((thelist != "") ? PlayerInList(sender, thelist) : false);
+       }
+       else if(!targ.ignore_list || targ.ignore_list == "")
+               return false;
+
+       string theid = ftos(etof(sender));
+
+       FOREACH_WORD(targ.ignore_list, it == theid,
+       {
+               return true;
+       });
+
+       return false;
+}
+
+void ignore_clearall(entity this)
+{
+       for(int j = 0; j < IGNORE_MAXPLAYERS; ++j)
+       {
+               string pos = db_get(ServerProgsDB, strcat("/ignore/", this.crypto_idfp, "/", ftos(j)));
+               if(pos != "")
+                       db_remove(ServerProgsDB, strcat("/ignore/", this.crypto_idfp, "/", ftos(j)));
+       }
+}