]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/command/cmd.qh
Merge branch 'bones_was_here/q1bsp_hitbox' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / cmd.qh
1 #pragma once
2
3 #include <server/world.qh>
4
5 float autocvar_sv_clientcommand_antispam_time;
6 int autocvar_sv_clientcommand_antispam_count;
7
8 .float cmd_floodtime;
9 .string ignore_list; // stores player id's, maybe can be upgraded to store net address for reconnect protection
10
11 const int IGNORE_MAXPLAYERS = 16; // maximum players to be ignored in the personal chat
12
13 string MapVote_Suggest(entity this, string m);
14
15 // used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
16 void ClientCommand_macro_write_aliases(float fh);
17
18 // functions for ignore command
19 string ignore_removefromlist(entity list, entity ignore)
20 {
21         if(ignore.crypto_idfp && ignore.crypto_idfp != "" && list.crypto_idfp && list.crypto_idfp != "")
22         {
23                 for(int j = 0; j < IGNORE_MAXPLAYERS; ++j)
24                 {
25                         string pos = db_get(ServerProgsDB, strcat("/ignore/", list.crypto_idfp, "/", ftos(j)));
26                         if(pos == ignore.crypto_idfp)
27                         {
28                                 db_remove(ServerProgsDB, strcat("/ignore/", list.crypto_idfp, "/", ftos(j)));
29                                 return string_null;
30                         }
31                 }
32                 // should this fall back? we know advanced mode is being used
33         }
34
35         string newlist = "";
36         string theid = ftos(etof(ignore));
37
38         FOREACH_WORD(list.ignore_list, it != theid,
39         {
40                 newlist = cons(newlist, it);
41         });
42
43         if(newlist == "")
44                 return string_null;
45         else
46                 return newlist;
47 }
48
49 bool ignore_playerinlist(entity sender, entity targ)
50 {
51         // TODO: optimize this by saving it to .ignore_list?
52         if(targ.crypto_idfp && targ.crypto_idfp != "" && sender.crypto_idfp && sender.crypto_idfp != "")
53         {
54                 string thelist = "";
55                 for(int j = 0; j < IGNORE_MAXPLAYERS; ++j)
56                 {
57                         string pos = db_get(ServerProgsDB, strcat("/ignore/", targ.crypto_idfp, "/", ftos(j)));
58                         thelist = cons(thelist, pos);
59                 }
60
61                 return ((thelist != "") ? PlayerInList(sender, thelist) : false);
62         }
63         else if(!targ.ignore_list || targ.ignore_list == "")
64                 return false;
65
66         string theid = ftos(etof(sender));
67
68         FOREACH_WORD(targ.ignore_list, it == theid,
69         {
70                 return true;
71         });
72
73         return false;
74 }
75
76 void ignore_clearall(entity this)
77 {
78         for(int j = 0; j < IGNORE_MAXPLAYERS; ++j)
79         {
80                 string pos = db_get(ServerProgsDB, strcat("/ignore/", this.crypto_idfp, "/", ftos(j)));
81                 if(pos != "")
82                         db_remove(ServerProgsDB, strcat("/ignore/", this.crypto_idfp, "/", ftos(j)));
83         }
84 }