From d3ee4f6d358709dd97278d297cdd7e259da9202a Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 3 Oct 2024 12:38:33 +0000 Subject: [PATCH] Move ignore functions out of the header to avoid potential inclusion errors --- qcsrc/server/command/cmd.qc | 69 ++++++++++++++++++++++++++++++++++--- qcsrc/server/command/cmd.qh | 69 ++----------------------------------- 2 files changed, 68 insertions(+), 70 deletions(-) diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 25a8c1b67..5bae26bbd 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -37,11 +37,72 @@ #include #include -// ========================================================= -// Server side networked commands code, reworked by Samual -// Last updated: December 28th, 2011 -// ========================================================= +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))); + } +} // ======================= // Command Sub-Functions diff --git a/qcsrc/server/command/cmd.qh b/qcsrc/server/command/cmd.qh index 25c694918..89a3051ee 100644 --- a/qcsrc/server/command/cmd.qh +++ b/qcsrc/server/command/cmd.qh @@ -1,7 +1,5 @@ #pragma once -#include - float autocvar_sv_clientcommand_antispam_time; int autocvar_sv_clientcommand_antispam_count; @@ -16,69 +14,8 @@ string MapVote_Suggest(entity this, string m); 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; - }); +string ignore_removefromlist(entity list, entity ignore); - return false; -} +bool ignore_playerinlist(entity sender, entity targ); -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))); - } -} +void ignore_clearall(entity this); -- 2.39.2