Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
cmd.qh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool ClientCommand_antispam (entity this, string command,.float antispam_fld, float antispam_time, int antispam_count)
 Returns true if antispam should prevent the command.
void ClientCommand_macro_write_aliases (float fh)
 Used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file.
int ignore_add_player (entity this, entity ignore, bool to_db_too)
 Adds a player to the ignore list of another player.
void ignore_clearall (entity this)
void ignore_list_send (entity this)
void ignore_list_update_on_connection (entity this)
 Updates ignore list of all the players.
bool ignore_playerindb (entity this, entity pl)
 Checks if pl is permanently ignored by this.
bool ignore_playerinlist (entity this, entity pl)
 Checks if pl is ignored by this (permanently or for the current match).
void ignore_remove_player (entity this, entity ignore, bool from_db_too)
 Removes a player from the ignore list of another player.
string MapVote_Suggest (entity this, string m)

Variables

int autocvar_sv_clientcommand_antispam_count
float autocvar_sv_clientcommand_antispam_time
float cmd_floodtime
string ignore_list
const int IGNORE_LIST_SEND_NOW = -1
float ignore_list_send_time
const int IGNORE_MAXPLAYERS = 16

Function Documentation

◆ ClientCommand_antispam()

bool ClientCommand_antispam ( entity this,
string command,
.float antispam_fld,
float antispam_time,
int antispam_count )

Returns true if antispam should prevent the command.

Definition at line 1165 of file cmd.qc.

1166{
1167 // this is basically the same as the chat flood control
1168 entity store = IS_CLIENT(this) ? CS(this) : this; // unfortunately, we need to store these on the client initially
1169 // NOTE: using mod_time instead of time here to avoid initializing both this.(antispam_fld)
1170 // and CS(this).(antispam_fld) to -(antispam_count * antispam_time) (or -999999)
1171 float mod_time = gettime(GETTIME_FRAMESTART) + antispam_count * antispam_time;
1172 if (mod_time < store.(antispam_fld))
1173 {
1174 sprint(this, strcat("^3CMD FLOOD CONTROL: wait ^1", ftos(store.(antispam_fld) - mod_time),
1175 "^3 seconds, command was: ", command, "\n"));
1176 return true; // too much spam, halt
1177 }
1178 else
1179 // micro-optimization: replaced mod_time - max_delay with time here as they are equal
1180 store.(antispam_fld) = max(gettime(GETTIME_FRAMESTART), store.(antispam_fld)) + antispam_time;
1181 return false;
1182}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define IS_CLIENT(s)
Definition player.qh:241
float GETTIME_FRAMESTART
void sprint(float clientnum, string text,...)
float gettime(void)
string ftos(float f)
float max(float f,...)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
entity this
Definition self.qh:76
ClientState CS(Client this)
Definition state.qh:47

References CS(), entity(), ftos(), gettime(), GETTIME_FRAMESTART, IS_CLIENT, max(), sprint(), and strcat().

Referenced by MapVote_ReadPlayerVote(), and SV_ParseClientCommand().

◆ ClientCommand_macro_write_aliases()

void ClientCommand_macro_write_aliases ( float fh)

Used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file.

Definition at line 1160 of file cmd.qc.

1161{
1162 FOREACH(CLIENT_COMMANDS, true, { CMD_Write_Alias("qc_cmd_cmd", it.m_name, it.m_description); });
1163}
#define CMD_Write_Alias(execute, command, description)
Definition generic.qh:34
#define FOREACH(list, cond, body)
Definition iter.qh:19

References CMD_Write_Alias, and FOREACH.

Referenced by GENERIC_COMMAND().

◆ ignore_add_player()

int ignore_add_player ( entity this,
entity ignore,
bool to_db_too )

Adds a player to the ignore list of another player.

Parameters
[in]thisignore list owner
[in]ignoreplayer to add to the ignore list
[in]to_db_toowhether to add ignore to db too (permanent ignore) or not
Returns
status of the operation:
  • 0: ignore not added (can happen only when trying to add too many permanent ignores)
  • 1: ignore added as temporary (only for the current match)
  • 2: ignore added as permanent (to the db too)

Definition at line 88 of file cmd.qc.

89{
90 int r = 1;
91 // permanent ignores work if both the player and the sender have a stats UID
92 if (to_db_too && ignore.crypto_idfp && ignore.crypto_idfp != "" && this.crypto_idfp && this.crypto_idfp != "")
93 {
94 for (int j = 0; j < IGNORE_MAXPLAYERS; ++j)
95 {
96 string pos = db_get(ServerProgsDB, strcat("/ignore/", this.crypto_idfp, "/", ftos(j)));
97 if(pos == "")
98 {
99 db_put(ServerProgsDB, strcat("/ignore/", this.crypto_idfp, "/", ftos(j)), ignore.crypto_idfp);
100 r = 2;
101 break;
102 }
103 }
104 if (r != 2)
105 return 0;
106 }
107
108 string list = cons(this.ignore_list, ftos(etof(ignore)));
109 strcpy(this.ignore_list, list);
110
111 this.ignore_list_send_time = time + 0.2;
112
113 return r;
114}
string ignore_list
Definition main.qh:130
float ignore_list_send_time
Definition cmd.qh:9
const int IGNORE_MAXPLAYERS
Definition cmd.qh:11
float time
string crypto_idfp
ERASEABLE string db_get(int db, string key)
Definition map.qh:93
ERASEABLE void db_put(int db, string key, string value)
Definition map.qh:103
#define etof(e)
Definition misc.qh:25
#define strcpy(this, s)
Definition string.qh:51
ERASEABLE string cons(string a, string b)
Definition string.qh:277
float ServerProgsDB
Definition world.qh:128

References cons(), crypto_idfp, db_get(), db_put(), entity(), etof, ftos(), ignore_list, ignore_list_send_time, IGNORE_MAXPLAYERS, ServerProgsDB, strcat(), strcpy, and time.

Referenced by ClientCommand_ignore(), and ignore_list_update_on_connection().

◆ ignore_clearall()

void ignore_clearall ( entity this)

Definition at line 176 of file cmd.qc.

177{
178 for(int j = 0; j < IGNORE_MAXPLAYERS; ++j)
179 {
180 string pos = db_get(ServerProgsDB, strcat("/ignore/", this.crypto_idfp, "/", ftos(j)));
181 if(pos != "")
182 {
183 db_remove(ServerProgsDB, strcat("/ignore/", this.crypto_idfp, "/", ftos(j)));
184 FOREACH_CLIENT(it != this && IS_REAL_CLIENT(it),
185 {
186 if(pos == it.crypto_idfp)
187 {
188 // permanent ignores already removed from db, remove only from list now
189 ignore_remove_player(this, it, false);
191 }
192 });
193 }
194 }
195}
void ignore_remove_player(entity this, entity ignore, bool from_db_too)
Removes a player from the ignore list of another player.
Definition cmd.qc:47
#define db_remove(db, key)
Definition map.qh:100
#define IS_REAL_CLIENT(v)
Definition utils.qh:17
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:52

References crypto_idfp, db_get(), db_remove, entity(), FOREACH_CLIENT, ftos(), ignore_list_send_time, IGNORE_MAXPLAYERS, ignore_remove_player(), IS_REAL_CLIENT, ServerProgsDB, strcat(), and time.

Referenced by ClientCommand_clear_ignores().

◆ ignore_list_send()

void ignore_list_send ( entity this)

Definition at line 168 of file cmd.qc.

169{
170 ClientData_Touch(this, false);
171 // changing ignore_list_send_time to IGNORE_LIST_SEND_NOW is needed
172 // to send ignore_list correctly in ClientData_Send
174}
const int IGNORE_LIST_SEND_NOW
Definition cmd.qh:8
void ClientData_Touch(entity e, bool to_spectators_too)
Definition client.qc:185

References ClientData_Touch(), entity(), IGNORE_LIST_SEND_NOW, and ignore_list_send_time.

Referenced by PlayerFrame().

◆ ignore_list_update_on_connection()

void ignore_list_update_on_connection ( entity this)

Updates ignore list of all the players.

It's meant to be called when player 'this' connects.

Definition at line 153 of file cmd.qc.

154{
155 if (!this)
156 return;
157
158 FOREACH_CLIENT(it != this && IS_REAL_CLIENT(it),
159 {
160 if (ignore_playerindb(this, it))
161 ignore_add_player(this, it, false); // update ignore list of the connecting player
162
163 if (ignore_playerindb(it, this))
164 ignore_add_player(it, this, false); // update ignore list of other players
165 });
166}
int ignore_add_player(entity this, entity ignore, bool to_db_too)
Adds a player to the ignore list of another player.
Definition cmd.qc:88
bool ignore_playerindb(entity this, entity pl)
Checks if pl is permanently ignored by this.
Definition cmd.qc:117

References entity(), FOREACH_CLIENT, ignore_add_player(), ignore_playerindb(), and IS_REAL_CLIENT.

Referenced by ClientConnect().

◆ ignore_playerindb()

bool ignore_playerindb ( entity this,
entity pl )

Checks if pl is permanently ignored by this.

Definition at line 117 of file cmd.qc.

118{
119 if(this.crypto_idfp && this.crypto_idfp != "" && pl.crypto_idfp && pl.crypto_idfp != "")
120 {
121 string thelist = "";
122 for(int j = 0; j < IGNORE_MAXPLAYERS; ++j)
123 {
124 string pos = db_get(ServerProgsDB, strcat("/ignore/", this.crypto_idfp, "/", ftos(j)));
125 thelist = cons(thelist, pos);
126 }
127
128 return ((thelist != "") ? PlayerInList(pl, thelist) : false);
129 }
130 return false;
131}
bool PlayerInList(entity player, string list)
Definition client.qc:1047

References cons(), crypto_idfp, db_get(), entity(), ftos(), IGNORE_MAXPLAYERS, PlayerInList(), ServerProgsDB, and strcat().

Referenced by ignore_list_update_on_connection().

◆ ignore_playerinlist()

bool ignore_playerinlist ( entity this,
entity pl )

Checks if pl is ignored by this (permanently or for the current match).

Definition at line 134 of file cmd.qc.

135{
136 if (!this.ignore_list || this.ignore_list == "")
137 return false;
138
139 string theid = ftos(etof(pl));
140
141 // we use a tempstring here because if the input string of FOREACH_WORD is strzoned
142 // then it can no longer be strunzoned and updated correctly
143 string ignore_list_copy = strcat(this.ignore_list);
144 FOREACH_WORD(ignore_list_copy, it == theid,
145 return true;
146 );
147
148 return false;
149}
#define FOREACH_WORD(words, cond, body)
Definition iter.qh:33

References entity(), etof, FOREACH_WORD, ftos(), ignore_list, and strcat().

Referenced by ClientCommand_ignore(), and Say().

◆ ignore_remove_player()

void ignore_remove_player ( entity this,
entity ignore,
bool from_db_too )

Removes a player from the ignore list of another player.

Parameters
[in]thisignore list owner
[in]ignoreplayer to remove from the ignore list
[in]from_db_toowhether to remove player from db too (permanent ignore) or not

Definition at line 47 of file cmd.qc.

48{
49 if (from_db_too && ignore.crypto_idfp && ignore.crypto_idfp != "" && this.crypto_idfp && this.crypto_idfp != "")
50 {
51 for(int j = 0; j < IGNORE_MAXPLAYERS; ++j)
52 {
53 string pos = db_get(ServerProgsDB, strcat("/ignore/", this.crypto_idfp, "/", ftos(j)));
54 if(pos == ignore.crypto_idfp)
55 {
56 db_remove(ServerProgsDB, strcat("/ignore/", this.crypto_idfp, "/", ftos(j)));
57 break;
58 }
59 }
60 }
61
62 if (this.ignore_list == "")
63 return;
64
65 string newlist = "";
66 string theid = ftos(etof(ignore));
67
68 // we use a tempstring here because if the input string of FOREACH_WORD is strzoned
69 // then it can no longer be strunzoned and updated correctly
70 string ignore_list_copy = strcat(this.ignore_list);
71 FOREACH_WORD(ignore_list_copy, it != theid,
72 newlist = cons(newlist, it););
73 strcpy(this.ignore_list, newlist);
74
75 this.ignore_list_send_time = time + 0.2;
76}

References cons(), crypto_idfp, db_get(), db_remove, entity(), etof, FOREACH_WORD, ftos(), ignore_list, ignore_list_send_time, IGNORE_MAXPLAYERS, ServerProgsDB, strcat(), strcpy, and time.

Referenced by ClientCommand_unignore(), ClientDisconnect(), and ignore_clearall().

◆ MapVote_Suggest()

string MapVote_Suggest ( entity this,
string m )

Definition at line 91 of file sv_mapvoting.qc.

92{
93 if (m == "")
94 return "That's not how to use this command.";
96 return "Suggestions are not accepted on this server.";
98 return "Can't suggest, voting is already in progress.";
100 if (!m)
101 return "The map you suggested is not available on this server.";
103 return "This server does not allow for recent maps to be played again. Please be patient for some rounds.";
104
106 return "The map you suggested does not support the current gametype.";
107 int i;
108 for (i = 0; i < mv_suggestion_ptr; ++i)
109 if (mv_suggestions[i] == m)
110 return "This map was already suggested.";
113 else
114 {
117 }
118
119 if (mv_suggestions[i] != "")
121 mv_suggestions[i] = strzone(m);
122 mv_suggester[i] = this.netname;
123
125 GameLogEcho(strcat(":vote:suggested:", m, ":", itos(this.playerid)));
126 return strcat("Suggestion of ", m, " accepted.");
127}
bool gametypevote
string netname
Definition powerups.qc:20
void GameLogEcho(string s)
Definition gamelog.qc:15
bool autocvar_sv_eventlog
Definition gamelog.qh:3
#define itos(i)
Definition int.qh:6
bool Map_IsRecent(string m)
float MapInfo_CheckMap(string s)
Definition mapinfo.qc:1502
const int MAPVOTE_COUNT
Max number of votable maps/gametypes.
Definition mapvoting.qh:6
string mv_suggester[MAPVOTE_COUNT]
(maps) .netname of the player who suggested the map
Definition mapvoting.qh:17
float random(void)
void strunzone(string s)
float floor(float f)
string strzone(string s)
int playerid
Definition client.qh:82
string GameTypeVote_MapInfo_FixName(string m)
bool autocvar_sv_vote_gametype
bool mapvote_initialized
bool autocvar_g_maplist_votable_suggestions_override_mostrecent
int mv_suggestion_ptr
(maps) index of where the next suggestion should be (starts as 0)
bool autocvar_g_maplist_votable_suggestions
string mv_suggestions[MAPVOTE_COUNT]
(maps) name of the suggested map, later copied into mv_entries

References autocvar_g_maplist_votable_suggestions, autocvar_g_maplist_votable_suggestions_override_mostrecent, autocvar_sv_eventlog, autocvar_sv_vote_gametype, entity(), floor(), GameLogEcho(), gametypevote, GameTypeVote_MapInfo_FixName(), itos, Map_IsRecent(), MapInfo_CheckMap(), MAPVOTE_COUNT, mapvote_initialized, mv_suggester, mv_suggestion_ptr, mv_suggestions, netname, playerid, random(), strcat(), strunzone(), and strzone().

Referenced by ClientCommand_suggestmap().

Variable Documentation

◆ autocvar_sv_clientcommand_antispam_count

int autocvar_sv_clientcommand_antispam_count

Definition at line 4 of file cmd.qh.

Referenced by SV_ParseClientCommand().

◆ autocvar_sv_clientcommand_antispam_time

float autocvar_sv_clientcommand_antispam_time

Definition at line 3 of file cmd.qh.

Referenced by SV_ParseClientCommand().

◆ cmd_floodtime

float cmd_floodtime

Definition at line 6 of file cmd.qh.

Referenced by SV_ParseClientCommand().

◆ ignore_list

string ignore_list

Definition at line 7 of file cmd.qh.

◆ IGNORE_LIST_SEND_NOW

const int IGNORE_LIST_SEND_NOW = -1

Definition at line 8 of file cmd.qh.

Referenced by ClientData_Send(), and ignore_list_send().

◆ ignore_list_send_time

float ignore_list_send_time

◆ IGNORE_MAXPLAYERS

const int IGNORE_MAXPLAYERS = 16