2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
sv_ccmds.c
|
|
|
|
|
|
|
|
(description)
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2001-09-10 05:04:00 +00:00
|
|
|
#include <ctype.h>
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cmd.h"
|
2001-11-05 22:24:16 +00:00
|
|
|
#include "QF/console.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2003-05-23 17:17:01 +00:00
|
|
|
#include "QF/dstring.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/msg.h"
|
|
|
|
#include "QF/qargs.h"
|
|
|
|
#include "QF/qendian.h"
|
2002-08-27 07:16:28 +00:00
|
|
|
#include "QF/quakefs.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/sys.h"
|
|
|
|
#include "QF/va.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
#include "compat.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
|
|
|
|
#include "qw/bothdefs.h"
|
|
|
|
#include "qw/include/server.h"
|
|
|
|
#include "qw/include/sv_demo.h"
|
|
|
|
#include "qw/include/sv_progs.h"
|
|
|
|
#include "qw/include/sv_qtv.h"
|
|
|
|
#include "qw/include/sv_recorder.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
qboolean sv_allow_cheats;
|
|
|
|
|
|
|
|
int fp_messages = 4, fp_persecond = 4, fp_secondsdead = 10;
|
|
|
|
char fp_msg[255] = { 0 };
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
int sv_leetnickmatch;
|
|
|
|
static cvar_t sv_leetnickmatch_cvar = {
|
|
|
|
.name = "sv_3133735_7h4n_7h0u",
|
|
|
|
.description =
|
|
|
|
"Match '1' as 'i' and such in nicks",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &sv_leetnickmatch },
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-10 05:04:00 +00:00
|
|
|
static qboolean
|
|
|
|
match_char (char a, char b)
|
|
|
|
{
|
2012-08-18 12:42:49 +00:00
|
|
|
a = tolower ((byte) sys_char_map[(byte) a]);
|
|
|
|
b = tolower ((byte) sys_char_map[(byte) b]);
|
2001-09-10 05:04:00 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (a == b || (sv_leetnickmatch
|
2002-10-02 22:56:34 +00:00
|
|
|
&& ( (a == '1' && b == 'i') || (a == 'i' && b == '1')
|
2001-09-11 05:43:58 +00:00
|
|
|
|| (a == '1' && b == 'l') || (a == 'l' && b == '1')
|
|
|
|
|| (a == '3' && b == 'e') || (a == 'e' && b == '3')
|
|
|
|
|| (a == '4' && b == 'a') || (a == 'a' && b == '4')
|
|
|
|
|| (a == '5' && b == 'g') || (a == 'g' && b == '5')
|
|
|
|
|| (a == '5' && b == 'r') || (a == 'r' && b == '5')
|
|
|
|
|| (a == '7' && b == 't') || (a == 't' && b == '7')
|
|
|
|
|| (a == '9' && b == 'p') || (a == 'p' && b == '9')
|
|
|
|
|| (a == '0' && b == 'o') || (a == 'o' && b == '0')
|
|
|
|
|| (a == '$' && b == 's') || (a == 's' && b == '$'))))
|
2001-09-10 05:04:00 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2001-08-28 02:43:24 +00:00
|
|
|
|
2001-09-11 07:10:45 +00:00
|
|
|
/*
|
|
|
|
FIXME: this function and it's callers are getting progressively
|
|
|
|
uglier as more features are added :)
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static client_t *
|
2002-10-10 02:17:11 +00:00
|
|
|
SV_Match_User (const char *substr)
|
2001-07-10 18:25:54 +00:00
|
|
|
{
|
2002-10-10 02:17:11 +00:00
|
|
|
int i, j, uid;
|
2001-07-10 18:25:54 +00:00
|
|
|
int count = 0;
|
|
|
|
char *str;
|
|
|
|
client_t *cl;
|
2002-10-10 02:17:11 +00:00
|
|
|
client_t *match = 0;
|
|
|
|
|
|
|
|
if (!substr || !*substr)
|
|
|
|
return 0;
|
|
|
|
uid = strtol (substr, &str, 10);
|
2001-07-10 18:25:54 +00:00
|
|
|
|
2002-10-10 02:17:11 +00:00
|
|
|
if (!*str) {
|
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
2003-03-03 17:08:45 +00:00
|
|
|
if (cl->state < cs_zombie)
|
2002-10-10 02:17:11 +00:00
|
|
|
continue;
|
|
|
|
if (cl->userid == uid) {
|
|
|
|
SV_Printf ("User %04d matches with name: %s\n",
|
|
|
|
cl->userid, cl->name);
|
|
|
|
return cl;
|
|
|
|
}
|
2001-09-11 07:10:45 +00:00
|
|
|
}
|
2002-10-10 02:17:11 +00:00
|
|
|
SV_Printf ("No such uid: %d\n", uid);
|
|
|
|
return 0;
|
2001-07-10 18:25:54 +00:00
|
|
|
}
|
2002-10-10 02:17:11 +00:00
|
|
|
|
2001-07-10 18:25:54 +00:00
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
2003-03-03 17:08:45 +00:00
|
|
|
if (cl->state < cs_zombie)
|
2001-07-10 18:25:54 +00:00
|
|
|
continue;
|
2001-09-10 05:04:00 +00:00
|
|
|
for (str = cl->name; *str && !match_char (*str, substr[0]); str++)
|
|
|
|
;
|
|
|
|
while (*str) {
|
2001-07-10 18:25:54 +00:00
|
|
|
for (j = 0; substr[j] && str[j]; j++)
|
2001-09-10 05:04:00 +00:00
|
|
|
if (!match_char (substr[j], str[j]))
|
2001-07-10 18:25:54 +00:00
|
|
|
break;
|
|
|
|
if (!substr[j]) { // found a match;
|
2002-10-10 02:17:11 +00:00
|
|
|
match = cl;
|
2001-07-10 18:25:54 +00:00
|
|
|
count++;
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("User %04d matches with name: %s\n",
|
2001-09-11 07:10:45 +00:00
|
|
|
cl->userid, cl->name);
|
|
|
|
break;
|
2001-07-10 18:25:54 +00:00
|
|
|
}
|
2001-09-11 07:10:45 +00:00
|
|
|
str++;
|
2001-07-10 18:25:54 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-10 02:17:11 +00:00
|
|
|
if (count != 1) {
|
|
|
|
SV_Printf ("No unique matches, ignoring command!\n");
|
|
|
|
return 0;
|
2001-07-10 18:25:54 +00:00
|
|
|
}
|
2002-10-10 02:17:11 +00:00
|
|
|
return match;
|
2001-07-10 18:25:54 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
OPERATOR CONSOLE ONLY COMMANDS
|
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
These commands can be entered only from stdin or by a remote operator
|
2001-02-19 21:15:25 +00:00
|
|
|
datagram
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
SV_SetMaster_f
|
|
|
|
|
|
|
|
Make a master server current
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_SetMaster_f (void)
|
|
|
|
{
|
2003-07-08 22:39:45 +00:00
|
|
|
char data[2];
|
2001-02-19 21:15:25 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
memset (&master_adr, 0, sizeof (master_adr));
|
|
|
|
|
|
|
|
for (i = 1; i < Cmd_Argc (); i++) {
|
2001-07-19 07:07:32 +00:00
|
|
|
if (i > MAX_MASTERS) {
|
2010-01-13 06:42:26 +00:00
|
|
|
SV_Printf ("Too many masters specified. Using only the first %d\n",
|
2001-07-19 07:07:32 +00:00
|
|
|
MAX_MASTERS);
|
|
|
|
break;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!strcmp (Cmd_Argv (i), "none")
|
|
|
|
|| !NET_StringToAdr (Cmd_Argv (i), &master_adr[i - 1])) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Setting nomaster mode.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (master_adr[i - 1].port == 0)
|
|
|
|
master_adr[i - 1].port = BigShort (27000);
|
|
|
|
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Master server at %s\n",
|
2001-02-19 21:15:25 +00:00
|
|
|
NET_AdrToString (master_adr[i - 1]));
|
|
|
|
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Sending a ping.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
data[0] = A2A_PING;
|
|
|
|
data[1] = 0;
|
2003-02-10 21:41:22 +00:00
|
|
|
Netchan_SendPacket (2, data, master_adr[i - 1]);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
svs.last_heartbeat = -99999;
|
|
|
|
}
|
|
|
|
|
2007-09-15 10:09:08 +00:00
|
|
|
#define RESTART_CLSTUFF \
|
|
|
|
"wait;wait;wait;wait;wait;"\
|
|
|
|
"wait;wait;wait;wait;wait;"\
|
|
|
|
"wait;wait;wait;reconnect\n"
|
|
|
|
|
|
|
|
static void
|
|
|
|
SV_Restart_f (void)
|
|
|
|
{
|
|
|
|
client_t *client;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
SZ_Clear (net_message->message);
|
|
|
|
|
|
|
|
MSG_WriteByte (net_message->message, svc_print);
|
|
|
|
MSG_WriteByte (net_message->message, PRINT_HIGH);
|
|
|
|
MSG_WriteString (net_message->message,
|
|
|
|
"\x9d\x9e\x9e\x9e\x9e\x9e\x9e\x9e"
|
|
|
|
"\x9e\x9e\x9e\x9e\x9e\x9e\x9e\x9e"
|
|
|
|
"\x9e\x9e\x9e\x9e\x9e\x9e\x9e\x9e"
|
|
|
|
"\x9e\x9e\x9f\n"
|
|
|
|
" Server \xf2\xe5\xf3\xf4\xe1\xf2\xf4 engaged\xae\xae\xae\n"
|
|
|
|
"\x9d\x9e\x9e\x9e\x9e\x9e\x9e\x9e"
|
|
|
|
"\x9e\x9e\x9e\x9e\x9e\x9e\x9e\x9e"
|
|
|
|
"\x9e\x9e\x9e\x9e\x9e\x9e\x9e\x9e"
|
|
|
|
"\x9e\x9e\x9f\n\n");
|
|
|
|
MSG_WriteByte (net_message->message, svc_stufftext);
|
|
|
|
MSG_WriteString (net_message->message, RESTART_CLSTUFF);
|
|
|
|
MSG_WriteByte (net_message->message, svc_disconnect);
|
|
|
|
|
|
|
|
for (j = 0, client = svs.clients; j < MAX_CLIENTS; j++, client++) {
|
|
|
|
if (client->state >= cs_spawned)
|
|
|
|
Netchan_Transmit (&client->netchan, net_message->message->cursize,
|
|
|
|
net_message->message->data);
|
|
|
|
}
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Shutting down: server restart, shell must relaunch server\n");
|
2020-03-21 13:24:11 +00:00
|
|
|
SV_Shutdown (0);
|
2007-09-15 10:09:08 +00:00
|
|
|
// Error code 2 on exit, indication shell must restart the server
|
|
|
|
exit (2);
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Quit_f (void)
|
|
|
|
{
|
|
|
|
SV_FinalMessage ("server shutdown\n");
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Shutting down.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
Sys_Quit ();
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Fraglogfile_f (void)
|
|
|
|
{
|
2003-05-23 17:17:01 +00:00
|
|
|
dstring_t *name;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (sv_fraglogfile) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Frag file logging off.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
Qclose (sv_fraglogfile);
|
|
|
|
sv_fraglogfile = NULL;
|
|
|
|
return;
|
|
|
|
}
|
2003-05-23 17:17:01 +00:00
|
|
|
name = dstring_new ();
|
2022-03-31 08:27:04 +00:00
|
|
|
if (!(sv_fraglogfile = QFS_NextFile (name,
|
|
|
|
va (0, "%s/frag_",
|
|
|
|
qfs_gamedir->dir.def), ".log"))) {
|
|
|
|
SV_Printf ("Can't open any logfiles.\n%s\n", name->str);
|
2003-05-23 17:17:01 +00:00
|
|
|
} else {
|
|
|
|
SV_Printf ("Logging frags to %s.\n", name->str);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2003-05-23 17:17:01 +00:00
|
|
|
dstring_delete (name);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SV_SetPlayer
|
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
Sets host_client and sv_player to the player with idnum Cmd_Argv (1)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static qboolean
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_SetPlayer (void)
|
|
|
|
{
|
|
|
|
client_t *cl;
|
2001-08-28 02:43:24 +00:00
|
|
|
int i, idnum;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
idnum = atoi (Cmd_Argv (1));
|
|
|
|
|
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
2003-03-03 17:08:45 +00:00
|
|
|
if (cl->state < cs_zombie)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
if (cl->userid == idnum) {
|
|
|
|
host_client = cl;
|
|
|
|
sv_player = host_client->edict;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Userid %i is not on the server\n", idnum);
|
2001-02-19 21:15:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SV_God_f
|
|
|
|
|
|
|
|
Sets client to godmode
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_God_f (void)
|
|
|
|
{
|
|
|
|
if (!sv_allow_cheats) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf
|
2001-02-19 21:15:25 +00:00
|
|
|
("You must run the server with -cheats to enable this command.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SV_SetPlayer ())
|
|
|
|
return;
|
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (sv_player, flags) = (int) SVfloat (sv_player, flags) ^ FL_GODMODE;
|
|
|
|
if (!((int) SVfloat (sv_player, flags) & FL_GODMODE))
|
2002-10-04 02:29:03 +00:00
|
|
|
SV_ClientPrintf (1, host_client, PRINT_HIGH, "godmode OFF\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2002-10-04 02:29:03 +00:00
|
|
|
SV_ClientPrintf (1, host_client, PRINT_HIGH, "godmode ON\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Noclip_f (void)
|
|
|
|
{
|
|
|
|
if (!sv_allow_cheats) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf
|
2001-02-19 21:15:25 +00:00
|
|
|
("You must run the server with -cheats to enable this command.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SV_SetPlayer ())
|
|
|
|
return;
|
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (sv_player, movetype) != MOVETYPE_NOCLIP) {
|
|
|
|
SVfloat (sv_player, movetype) = MOVETYPE_NOCLIP;
|
2002-10-04 02:29:03 +00:00
|
|
|
SV_ClientPrintf (1, host_client, PRINT_HIGH, "noclip ON\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
} else {
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (sv_player, movetype) = MOVETYPE_WALK;
|
2002-10-04 02:29:03 +00:00
|
|
|
SV_ClientPrintf (1, host_client, PRINT_HIGH, "noclip OFF\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Give_f (void)
|
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *t;
|
2001-02-19 21:15:25 +00:00
|
|
|
int v;
|
|
|
|
|
|
|
|
if (!sv_allow_cheats) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf
|
2001-02-19 21:15:25 +00:00
|
|
|
("You must run the server with -cheats to enable this command.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SV_SetPlayer ())
|
|
|
|
return;
|
|
|
|
|
|
|
|
t = Cmd_Argv (2);
|
|
|
|
v = atoi (Cmd_Argv (3));
|
|
|
|
|
|
|
|
switch (t[0]) {
|
|
|
|
case '2':
|
|
|
|
case '3':
|
|
|
|
case '4':
|
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
case '7':
|
|
|
|
case '8':
|
|
|
|
case '9':
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (sv_player, items) =
|
|
|
|
(int) SVfloat (sv_player, items) | IT_SHOTGUN << (t[0] - '2');
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 's':
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (sv_player, ammo_shells) = v;
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
case 'n':
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (sv_player, ammo_nails) = v;
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
case 'r':
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (sv_player, ammo_rockets) = v;
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
case 'h':
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (sv_player, health) = v;
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
case 'c':
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (sv_player, ammo_cells) = v;
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use this to keep track of current level --KB
|
2003-08-05 01:45:52 +00:00
|
|
|
static dstring_t *curlevel;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-04-13 20:31:06 +00:00
|
|
|
const char *
|
|
|
|
SV_Current_Map (void)
|
|
|
|
{
|
2003-08-05 01:45:52 +00:00
|
|
|
return curlevel ? curlevel->str : "";
|
2003-04-13 20:31:06 +00:00
|
|
|
}
|
|
|
|
|
2002-10-09 22:41:07 +00:00
|
|
|
static const char *
|
2021-07-10 23:18:02 +00:00
|
|
|
nice_time (double time)
|
2002-10-09 22:41:07 +00:00
|
|
|
{
|
|
|
|
int t = time + 0.5;
|
|
|
|
|
|
|
|
#if 0 //FIXME ditch or cvar?
|
|
|
|
if (t < 60) {
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "%ds", t);
|
2002-10-09 22:41:07 +00:00
|
|
|
} else if (t < 600) {
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "%dm%02ds", t / 60, t % 60);
|
2002-10-09 22:41:07 +00:00
|
|
|
} else if (t < 3600) {
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "%dm", t / 60);
|
2002-10-09 22:41:07 +00:00
|
|
|
} else if (t < 36000) {
|
|
|
|
t /= 60;
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "%dh%02dm", t / 60, t % 60);
|
2002-10-09 22:41:07 +00:00
|
|
|
} else if (t < 86400) {
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "%dh", t / 3600);
|
2002-10-09 22:41:07 +00:00
|
|
|
} else {
|
|
|
|
t /= 3600;
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "%dd%02dh", t / 24, t % 24);
|
2002-10-09 22:41:07 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (t < 60) {
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "%ds", t);
|
2002-10-09 22:41:07 +00:00
|
|
|
} else if (t < 3600) {
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "%dm%02ds", t / 60, t % 60);
|
2002-10-09 22:41:07 +00:00
|
|
|
} else if (t < 86400) {
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "%dh%02dm%02ds", t / 3600, (t / 60) % 60, t % 60);
|
2002-10-09 22:41:07 +00:00
|
|
|
} else {
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "%dd%02dh%02dm%02ds",
|
2002-10-09 22:41:07 +00:00
|
|
|
t / 86400, (t / 3600) % 24, (t / 60) % 60, t % 60);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
SV_Map_f
|
|
|
|
|
2012-05-21 23:23:22 +00:00
|
|
|
handle a
|
2001-02-19 21:15:25 +00:00
|
|
|
map <mapname>
|
|
|
|
command from the console or progs.
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Map_f (void)
|
|
|
|
{
|
2003-08-05 01:45:52 +00:00
|
|
|
const char *level;
|
|
|
|
char *expanded;
|
2002-08-27 07:16:28 +00:00
|
|
|
QFile *f;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-08-05 01:45:52 +00:00
|
|
|
if (!curlevel)
|
|
|
|
curlevel = dstring_newstr ();
|
|
|
|
|
2001-07-06 17:38:17 +00:00
|
|
|
if (Cmd_Argc () > 2) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("map <levelname> : continue game on a new level\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-07-06 17:38:17 +00:00
|
|
|
if (Cmd_Argc () == 1) {
|
2010-08-13 05:17:18 +00:00
|
|
|
SV_Printf ("map is %s \"%s\" (%s)\n", curlevel->str,
|
|
|
|
PR_GetString (&sv_pr_state, SVstring (sv.edicts, message)),
|
|
|
|
nice_time (sv.time));
|
2001-07-06 17:38:17 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-08-05 01:45:52 +00:00
|
|
|
level = Cmd_Argv (1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// check to make sure the level exists
|
2003-08-05 01:45:52 +00:00
|
|
|
expanded = nva ("maps/%s.bsp", level);
|
2014-01-23 02:57:57 +00:00
|
|
|
f = QFS_FOpenFile (expanded);
|
2002-09-04 18:26:34 +00:00
|
|
|
if (!f) {
|
|
|
|
SV_Printf ("Can't find %s\n", expanded);
|
2003-08-05 01:45:52 +00:00
|
|
|
free (expanded);
|
2002-09-04 18:26:34 +00:00
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
Qclose (f);
|
2003-08-05 01:45:52 +00:00
|
|
|
free (expanded);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-01-13 06:44:29 +00:00
|
|
|
if (sv.recording_demo)
|
2004-03-06 03:18:14 +00:00
|
|
|
SV_Stop (0);
|
2002-10-04 02:29:03 +00:00
|
|
|
|
2010-01-13 06:50:44 +00:00
|
|
|
SV_qtvChanging ();
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_BroadcastCommand ("changing\n");
|
|
|
|
SV_SendMessagesToAll ();
|
|
|
|
|
2003-08-05 01:45:52 +00:00
|
|
|
dstring_copystr (curlevel, level);
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_SpawnServer (level);
|
|
|
|
|
2010-01-13 06:50:44 +00:00
|
|
|
SV_qtvReconnect ();
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_BroadcastCommand ("reconnect\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SV_Kick_f
|
|
|
|
|
|
|
|
Kick a user off of the server
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Kick_f (void)
|
|
|
|
{
|
|
|
|
client_t *cl;
|
2004-03-20 00:23:26 +00:00
|
|
|
int argc = Cmd_Argc ();
|
|
|
|
const char *reason;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2004-03-20 00:23:26 +00:00
|
|
|
if (argc < 2) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("usage: kick <name/userid>\n");
|
2001-07-10 18:25:54 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-03-21 21:25:44 +00:00
|
|
|
if (!(cl = SV_Match_User (Cmd_Argv (1))))
|
2002-10-10 02:17:11 +00:00
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-10-10 02:17:11 +00:00
|
|
|
// print directly, because the dropped client won't get the
|
|
|
|
// SV_BroadcastPrintf message
|
2004-03-20 00:23:26 +00:00
|
|
|
if (argc > 2) {
|
|
|
|
reason = Cmd_Args (2);
|
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "%s was kicked: %s\n", cl->name,
|
|
|
|
reason);
|
|
|
|
SV_ClientPrintf (1, cl, PRINT_HIGH,
|
|
|
|
"You were kicked from the game: %s\n", reason);
|
|
|
|
} else {
|
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "%s was kicked\n", cl->name);
|
|
|
|
SV_ClientPrintf (1, cl, PRINT_HIGH, "You were kicked from the game\n");
|
|
|
|
}
|
2002-10-10 02:17:11 +00:00
|
|
|
SV_DropClient (cl);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SV_Status_f (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
client_t *cl;
|
2002-10-04 02:29:03 +00:00
|
|
|
float cpu, avg, pak, demo = 0;
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *s;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
cpu = (svs.stats.latched_active + svs.stats.latched_idle);
|
2002-10-04 02:29:03 +00:00
|
|
|
if (cpu) {
|
|
|
|
demo = 100 * svs.stats.latched_demo / cpu;
|
2001-02-19 21:15:25 +00:00
|
|
|
cpu = 100 * svs.stats.latched_active / cpu;
|
2002-10-04 02:29:03 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
avg = 1000 * svs.stats.latched_active / STATFRAMES;
|
|
|
|
pak = (float) svs.stats.latched_packets / STATFRAMES;
|
|
|
|
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("net address : %s\n", NET_AdrToString (net_local_adr));
|
2021-07-10 23:18:02 +00:00
|
|
|
SV_Printf ("uptime : %s\n",
|
|
|
|
nice_time (Sys_DoubleTime () - Sys_DoubleTimeBase ()));
|
2002-10-04 02:29:03 +00:00
|
|
|
SV_Printf ("cpu utilization : %3i%% (%3i%%)\n", (int) cpu, (int)demo);
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("avg response time: %i ms\n", (int) avg);
|
|
|
|
SV_Printf ("packets/frame : %5.2f\n", pak);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
// min fps lat drp
|
2003-11-21 06:09:21 +00:00
|
|
|
if (sv_redirected != RD_NONE && sv_redirected != RD_MOD) {
|
2001-02-19 21:15:25 +00:00
|
|
|
// most remote clients are 40 columns
|
2002-10-04 02:29:03 +00:00
|
|
|
// 0123456789012345678901234567890123456789
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("name userid frags\n");
|
|
|
|
SV_Printf (" address rate ping drop\n");
|
|
|
|
SV_Printf (" ---------------- ---- ---- -----\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
|
|
|
if (!cl->state)
|
|
|
|
continue;
|
|
|
|
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("%-16.16s ", cl->name);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
SV_Printf ("%6i %5i", cl->userid, (int) SVfloat (cl->edict, frags));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cl->spectator)
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf (" (s)\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
s = NET_BaseAdrToString (cl->netchan.remote_address);
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf (" %-16.16s", s);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cl->state == cs_connected) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("CONNECTING\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (cl->state == cs_zombie) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("ZOMBIE\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
2003-03-03 17:08:45 +00:00
|
|
|
if (cl->state == cs_server) {
|
2004-05-12 04:20:58 +00:00
|
|
|
SV_Printf ("SERVER %d\n", cl->ping);
|
2003-03-03 17:08:45 +00:00
|
|
|
continue;
|
|
|
|
}
|
2002-10-04 02:29:03 +00:00
|
|
|
SV_Printf ("%4i %4i %5.2f\n",
|
|
|
|
(int) (1000 * cl->netchan.frame_rate),
|
|
|
|
(int) SV_CalcPing (cl),
|
|
|
|
100.0 * cl->netchan.drop_count /
|
|
|
|
cl->netchan.incoming_sequence);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
} else {
|
2001-08-28 02:43:24 +00:00
|
|
|
SV_Printf ("frags userid address name rate ping "
|
|
|
|
"drop qport\n");
|
|
|
|
SV_Printf ("----- ------ --------------- --------------- ---- ---- "
|
|
|
|
"----- -----\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
|
|
|
if (!cl->state)
|
|
|
|
continue;
|
2001-08-28 02:43:24 +00:00
|
|
|
SV_Printf ("%5i %6i ", (int) SVfloat (cl->edict, frags),
|
|
|
|
cl->userid);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
s = NET_BaseAdrToString (cl->netchan.remote_address);
|
|
|
|
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("%-15.15s ", s);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("%-15.15s ", cl->name);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (cl->state == cs_connected) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("CONNECTING\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (cl->state == cs_zombie) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("ZOMBIE\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
2003-03-03 17:08:45 +00:00
|
|
|
if (cl->state == cs_server) {
|
2004-05-12 04:20:58 +00:00
|
|
|
SV_Printf ("SERVER %d\n", cl->ping);
|
2003-03-03 17:08:45 +00:00
|
|
|
continue;
|
|
|
|
}
|
2021-07-10 23:18:02 +00:00
|
|
|
SV_Printf ("%4i %4i %4.1f%% %5i",
|
2001-02-19 21:15:25 +00:00
|
|
|
(int) (1000 * cl->netchan.frame_rate),
|
|
|
|
(int) SV_CalcPing (cl),
|
|
|
|
100.0 * cl->netchan.drop_count /
|
|
|
|
cl->netchan.incoming_sequence, cl->netchan.qport);
|
|
|
|
if (cl->spectator)
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf (" (s)\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-09-09 04:51:08 +00:00
|
|
|
#define MAXPENALTY 10.0
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_Punish (int mode)
|
2001-09-09 04:51:08 +00:00
|
|
|
{
|
2002-10-10 02:17:11 +00:00
|
|
|
int i;
|
2001-09-09 04:51:08 +00:00
|
|
|
double mins = 0.5;
|
|
|
|
qboolean all = false, done = false;
|
2002-10-10 02:17:11 +00:00
|
|
|
client_t *cl = 0;
|
2003-08-05 01:45:52 +00:00
|
|
|
dstring_t *text = dstring_new();
|
|
|
|
const char *cmd = 0;
|
|
|
|
const char *cmd_do = 0;
|
2011-06-19 01:48:02 +00:00
|
|
|
//FIXME const char *cmd_undo = 0;
|
2003-08-05 01:45:52 +00:00
|
|
|
int field_offs = 0;
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case 0:
|
|
|
|
cmd = "cuff";
|
|
|
|
cmd_do = "cuffed";
|
2011-06-19 01:48:02 +00:00
|
|
|
//FIXME cmd_undo = "un-cuffed";
|
2003-08-05 01:45:52 +00:00
|
|
|
field_offs = field_offset (client_t, cuff_time);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
cmd = "mute";
|
|
|
|
cmd_do = "muted";
|
2011-06-19 01:48:02 +00:00
|
|
|
//FIXME cmd_undo = "can speak";
|
2003-08-05 01:45:52 +00:00
|
|
|
field_offs = field_offset (client_t, lockedtill);
|
|
|
|
break;
|
|
|
|
}
|
2001-09-09 04:51:08 +00:00
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
if (Cmd_Argc () != 2 && Cmd_Argc () != 3) {
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_Printf ("usage: %s <name/userid/ALL> [minutes]\n"
|
|
|
|
" (default = 0.5, 0 = cancel cuff).\n", cmd);
|
2001-09-09 04:51:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
if (strequal (Cmd_Argv (1), "ALL")) {
|
2001-09-09 04:51:08 +00:00
|
|
|
all = true;
|
|
|
|
} else {
|
2003-03-21 21:25:44 +00:00
|
|
|
cl = SV_Match_User (Cmd_Argv (1));
|
2001-09-09 04:51:08 +00:00
|
|
|
}
|
2002-10-10 02:17:11 +00:00
|
|
|
if (!all && !cl)
|
|
|
|
return;
|
2003-03-21 21:25:44 +00:00
|
|
|
if (Cmd_Argc () == 3) {
|
|
|
|
mins = atof (Cmd_Argv (2));
|
2001-09-09 04:51:08 +00:00
|
|
|
if (mins < 0.0 || mins > MAXPENALTY)
|
|
|
|
mins = MAXPENALTY;
|
|
|
|
}
|
2002-10-10 02:17:11 +00:00
|
|
|
if (cl) {
|
2003-08-05 01:45:52 +00:00
|
|
|
*(double *)((char *)cl + field_offs) = realtime + mins * 60.0;
|
2002-10-10 02:17:11 +00:00
|
|
|
if (mins) {
|
2003-08-05 01:45:52 +00:00
|
|
|
dsprintf (text, "You are %s for %.1f minutes\n\n"
|
|
|
|
"reconnecting won't help...\n", cmd_do, mins);
|
2004-02-22 05:40:08 +00:00
|
|
|
MSG_ReliableWrite_Begin (&cl->backbuf, svc_centerprint,
|
|
|
|
2 + strlen (text->str));
|
|
|
|
MSG_ReliableWrite_String (&cl->backbuf, text->str);
|
2002-10-10 02:17:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (all) {
|
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
2003-03-03 17:08:45 +00:00
|
|
|
if (cl->state < cs_zombie)
|
2002-10-10 02:17:11 +00:00
|
|
|
continue;
|
2003-08-05 01:45:52 +00:00
|
|
|
*(double *)((char *)cl + field_offs) = realtime + mins * 60.0;
|
2001-09-09 04:51:08 +00:00
|
|
|
done = true;
|
|
|
|
if (mins) {
|
2003-08-05 01:45:52 +00:00
|
|
|
dsprintf (text, "You are %s for %.1f minutes\n\n"
|
|
|
|
"reconnecting won't help...\n", cmd_do, mins);
|
2004-02-22 05:40:08 +00:00
|
|
|
MSG_ReliableWrite_Begin (&cl->backbuf, svc_centerprint,
|
|
|
|
2 + strlen (text->str));
|
|
|
|
MSG_ReliableWrite_String (&cl->backbuf, text->str);
|
2001-09-09 04:51:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (done) {
|
|
|
|
if (mins)
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "%s %s for %.1f minutes.\n",
|
|
|
|
all? "All Users" : cl->name, cmd_do, mins);
|
2001-09-09 04:51:08 +00:00
|
|
|
else
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "%s %s.\n",
|
|
|
|
all? "All Users" : cl->name, cmd_do);
|
2001-09-09 04:51:08 +00:00
|
|
|
}
|
2003-08-05 01:45:52 +00:00
|
|
|
dstring_delete (text);
|
2001-09-09 04:51:08 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_Cuff_f (void)
|
2001-09-09 04:51:08 +00:00
|
|
|
{
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_Punish (0);
|
2001-09-09 04:51:08 +00:00
|
|
|
}
|
|
|
|
|
2003-08-05 01:45:52 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_Mute_f (void)
|
2001-07-10 18:25:54 +00:00
|
|
|
{
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_Punish (1);
|
2001-07-10 18:25:54 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-09-09 04:51:08 +00:00
|
|
|
SV_Ban_f (void)
|
|
|
|
{
|
2004-03-20 00:23:26 +00:00
|
|
|
double mins = 30.0, m;
|
|
|
|
client_t *cl;
|
|
|
|
char *e;
|
|
|
|
const char *a, *reason;
|
|
|
|
int argc = Cmd_Argc (), argr = 2;
|
2001-09-09 04:51:08 +00:00
|
|
|
|
2004-03-20 00:23:26 +00:00
|
|
|
if (argc < 2) {
|
|
|
|
SV_Printf ("usage: ban <name/userid> [minutes] [reason]\n"
|
2001-09-09 04:51:08 +00:00
|
|
|
" (default = 30, 0 = permanent).\n");
|
|
|
|
return;
|
|
|
|
}
|
2003-03-21 21:25:44 +00:00
|
|
|
if (!(cl = SV_Match_User (Cmd_Argv (1))))
|
2002-10-10 02:17:11 +00:00
|
|
|
return;
|
2004-03-20 00:23:26 +00:00
|
|
|
if (argc >= 3) {
|
|
|
|
a = Cmd_Argv (2);
|
|
|
|
m = strtod (a, &e);
|
|
|
|
if (e != a) {
|
|
|
|
argr++;
|
|
|
|
mins = m;
|
|
|
|
if (mins < 0.0 || mins > 1000000.0) // bout 2 yrs
|
|
|
|
mins = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (argc > argr) {
|
|
|
|
reason = Cmd_Args (argr);
|
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "Admin Banned user %s %s: %s\n",
|
2021-01-31 07:01:20 +00:00
|
|
|
cl->name, mins ? va (0, "for %.1f minutes", mins)
|
2004-03-20 00:23:26 +00:00
|
|
|
: "permanently", reason);
|
|
|
|
} else {
|
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "Admin Banned user %s %s\n",
|
2021-01-31 07:01:20 +00:00
|
|
|
cl->name, mins ? va (0, "for %.1f minutes", mins)
|
2004-03-20 00:23:26 +00:00
|
|
|
: "permanently");
|
2001-09-09 04:51:08 +00:00
|
|
|
}
|
2002-10-10 02:17:11 +00:00
|
|
|
SV_DropClient (cl);
|
2021-01-31 07:01:20 +00:00
|
|
|
Cmd_ExecuteString (va (0, "addip %s %f",
|
2003-03-21 21:25:44 +00:00
|
|
|
NET_BaseAdrToString (cl->netchan.remote_address),
|
2002-10-10 02:17:11 +00:00
|
|
|
mins), src_command);
|
2001-09-09 04:51:08 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-09-11 07:10:45 +00:00
|
|
|
SV_Match_f (void)
|
|
|
|
{
|
2003-03-21 21:25:44 +00:00
|
|
|
if (Cmd_Argc () != 2) {
|
2001-09-11 07:10:45 +00:00
|
|
|
SV_Printf ("usage: match <name/userid>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
if (!SV_Match_User (Cmd_Argv (1)))
|
2002-10-10 02:17:11 +00:00
|
|
|
SV_Printf ("No unique uid/name matched\n");
|
2001-09-11 07:10:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_ConSay (const char *prefix, client_t *client)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
char *p;
|
2003-08-05 01:45:52 +00:00
|
|
|
dstring_t *text;
|
2001-08-28 02:43:24 +00:00
|
|
|
int j;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc () < 2)
|
|
|
|
return;
|
|
|
|
|
2021-07-28 06:01:45 +00:00
|
|
|
p = Hunk_TempAlloc (0, strlen (Cmd_Args (1)) + 1);
|
2001-07-15 07:04:17 +00:00
|
|
|
strcpy (p, Cmd_Args (1));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (*p == '"') {
|
|
|
|
p++;
|
|
|
|
p[strlen (p) - 1] = 0;
|
|
|
|
}
|
2003-08-05 01:45:52 +00:00
|
|
|
text = dstring_new ();
|
|
|
|
dstring_copystr (text, prefix);
|
|
|
|
dstring_appendstr (text, "\x8d "); // arrow
|
|
|
|
j = strlen (text->str);
|
|
|
|
dstring_appendstr (text, p);
|
|
|
|
SV_Printf ("%s\n", text->str);
|
|
|
|
while (text->str[j])
|
|
|
|
text->str[j++] |= 0x80; // non-bold text
|
|
|
|
|
|
|
|
if (client) {
|
2004-04-06 22:02:45 +00:00
|
|
|
if (client->state >= cs_zombie) {
|
|
|
|
SV_ClientPrintf (1, client, PRINT_CHAT, "\n"); // bell
|
|
|
|
SV_ClientPrintf (1, client, PRINT_HIGH, "%s\n", text->str);
|
|
|
|
SV_ClientPrintf (1, client, PRINT_CHAT, "%s", ""); // bell
|
|
|
|
}
|
2003-08-05 01:45:52 +00:00
|
|
|
} else {
|
|
|
|
for (j = 0, client = svs.clients; j < MAX_CLIENTS; j++, client++) {
|
|
|
|
if (client->state < cs_zombie)
|
|
|
|
continue;
|
2004-03-23 22:39:17 +00:00
|
|
|
SV_ClientPrintf (0, client, PRINT_HIGH, "%s\n", text->str);
|
2003-08-05 01:45:52 +00:00
|
|
|
if (*prefix != 'I') // beep, except for Info says
|
|
|
|
SV_ClientPrintf (0, client, PRINT_CHAT, "%s", "");
|
|
|
|
}
|
2005-05-01 09:07:20 +00:00
|
|
|
if (sv.recorders) {
|
|
|
|
sizebuf_t *dbuf;
|
|
|
|
dbuf = SVR_WriteBegin (dem_all, 0, strlen (text->str) + 7);
|
|
|
|
MSG_WriteByte (dbuf, svc_print);
|
|
|
|
MSG_WriteByte (dbuf, PRINT_HIGH);
|
2021-01-31 07:01:20 +00:00
|
|
|
MSG_WriteString (dbuf, va (0, "%s\n", text->str));
|
2005-05-01 09:07:20 +00:00
|
|
|
MSG_WriteByte (dbuf, svc_print);
|
|
|
|
MSG_WriteByte (dbuf, PRINT_CHAT);
|
|
|
|
MSG_WriteString (dbuf, "");
|
2003-08-05 01:45:52 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-07-10 18:25:54 +00:00
|
|
|
SV_Tell_f (void)
|
|
|
|
{
|
2003-08-05 01:45:52 +00:00
|
|
|
client_t *cl;
|
|
|
|
|
|
|
|
if (Cmd_Argc () < 3) {
|
|
|
|
SV_Printf ("usage: tell <name/userid> <text...>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!(cl = SV_Match_User (Cmd_Argv (1))))
|
|
|
|
return;
|
|
|
|
|
2001-07-10 18:25:54 +00:00
|
|
|
if (rcon_from_user)
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_ConSay ("[\xd0\xd2\xc9\xd6\xc1\xd4\xc5] Admin", cl);
|
2001-07-10 18:25:54 +00:00
|
|
|
else
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_ConSay ("[\xd0\xd2\xc9\xd6\xc1\xd4\xc5] Console", cl);
|
2001-07-10 18:25:54 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-07-09 23:33:35 +00:00
|
|
|
SV_ConSay_f (void)
|
|
|
|
{
|
|
|
|
if (rcon_from_user)
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_ConSay ("Admin", 0);
|
2001-07-09 23:33:35 +00:00
|
|
|
else
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_ConSay ("Console", 0);
|
2001-07-09 23:33:35 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-07-09 23:33:35 +00:00
|
|
|
SV_ConSay_Info_f (void)
|
|
|
|
{
|
2003-08-05 01:45:52 +00:00
|
|
|
SV_ConSay ("Info", 0);
|
2001-07-09 23:33:35 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Heartbeat_f (void)
|
|
|
|
{
|
|
|
|
svs.last_heartbeat = -9999;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-07-15 07:04:17 +00:00
|
|
|
SV_SendServerInfoChange (const char *key, const char *value)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
if (!sv.state)
|
|
|
|
return;
|
|
|
|
|
|
|
|
MSG_WriteByte (&sv.reliable_datagram, svc_serverinfo);
|
2001-11-07 08:24:56 +00:00
|
|
|
MSG_WriteString (&sv.reliable_datagram, key);
|
|
|
|
MSG_WriteString (&sv.reliable_datagram, value);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2002-09-17 05:11:28 +00:00
|
|
|
void
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Cvar_Info (void *data, const cvar_t *cvar)
|
2002-09-17 05:11:28 +00:00
|
|
|
{
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (cvar->flags & CVAR_SERVERINFO) {
|
|
|
|
const char *cvar_str = Cvar_VarString (cvar);
|
|
|
|
Info_SetValueForKey (svs.info, cvar->name, cvar_str, !sv_highchars);
|
|
|
|
SV_SendServerInfoChange (cvar->name, cvar_str);
|
2002-09-17 05:11:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
SV_Serverinfo_f
|
|
|
|
|
|
|
|
Examine or change the serverinfo string
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Serverinfo_f (void)
|
|
|
|
{
|
|
|
|
cvar_t *var;
|
2012-07-14 21:57:11 +00:00
|
|
|
const char *key;
|
|
|
|
const char *value;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-07-14 21:57:11 +00:00
|
|
|
switch (Cmd_Argc ()) {
|
|
|
|
case 1:
|
|
|
|
SV_Printf ("Server info settings:\n");
|
|
|
|
Info_Print (svs.info);
|
|
|
|
return;
|
|
|
|
case 2:
|
|
|
|
key = Cmd_Argv (1);
|
|
|
|
value = Info_ValueForKey (svs.info, key);
|
|
|
|
if (Info_Key (svs.info, key))
|
|
|
|
SV_Printf ("Server info %s: \"%s\"\n", key, value);
|
|
|
|
else
|
|
|
|
SV_Printf ("No such key %s\n", Cmd_Argv(1));
|
|
|
|
return;
|
|
|
|
case 3:
|
|
|
|
key = Cmd_Argv (1);
|
|
|
|
value = Cmd_Argv (2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SV_Printf ("usage: serverinfo [ <key> <value> ]\n");
|
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Cmd_Argv (1)[0] == '*') {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Star variables cannot be changed.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-21 23:23:22 +00:00
|
|
|
// if this is a cvar, change it too
|
2012-07-14 21:57:11 +00:00
|
|
|
var = Cvar_FindVar (key);
|
2002-09-17 05:11:28 +00:00
|
|
|
if (var && (var->flags & CVAR_SERVERINFO)) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Cvar_SetVar (var, value);
|
2002-09-17 05:11:28 +00:00
|
|
|
} else {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Info_SetValueForKey (svs.info, key, value, !sv_highchars);
|
2012-07-14 21:57:11 +00:00
|
|
|
SV_SendServerInfoChange (key, value);
|
2002-09-17 05:11:28 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-11-21 06:09:21 +00:00
|
|
|
void
|
|
|
|
SV_SetLocalinfo (const char *key, const char *value)
|
|
|
|
{
|
|
|
|
char *oldvalue = 0;
|
|
|
|
|
|
|
|
if (sv_funcs.LocalinfoChanged)
|
|
|
|
oldvalue = strdup (Info_ValueForKey (localinfo, key));
|
|
|
|
|
|
|
|
if (*value)
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Info_SetValueForKey (localinfo, key, value, !sv_highchars);
|
2003-11-21 06:09:21 +00:00
|
|
|
else
|
|
|
|
Info_RemoveKey (localinfo, key);
|
|
|
|
|
|
|
|
if (sv_funcs.LocalinfoChanged) {
|
|
|
|
*sv_globals.time = sv.time;
|
|
|
|
*sv_globals.self = 0;
|
2004-01-05 07:10:32 +00:00
|
|
|
PR_PushFrame (&sv_pr_state);
|
2005-06-12 09:54:01 +00:00
|
|
|
PR_RESET_PARAMS (&sv_pr_state);
|
2004-01-05 07:10:32 +00:00
|
|
|
P_STRING (&sv_pr_state, 0) = PR_SetTempString (&sv_pr_state, key);
|
|
|
|
P_STRING (&sv_pr_state, 1) = PR_SetTempString (&sv_pr_state, oldvalue);
|
|
|
|
P_STRING (&sv_pr_state, 2) = PR_SetTempString (&sv_pr_state, value);
|
2020-02-25 08:28:32 +00:00
|
|
|
sv_pr_state.pr_argc = 3;
|
2003-11-21 06:09:21 +00:00
|
|
|
PR_ExecuteProgram (&sv_pr_state, sv_funcs.LocalinfoChanged);
|
2004-01-05 07:10:32 +00:00
|
|
|
PR_PopFrame (&sv_pr_state);
|
2003-11-21 06:09:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (oldvalue)
|
|
|
|
free (oldvalue);
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
SV_Serverinfo_f
|
|
|
|
|
|
|
|
Examine or change the serverinfo string
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Localinfo_f (void)
|
|
|
|
{
|
2012-07-14 21:57:11 +00:00
|
|
|
const char *key;
|
|
|
|
const char *value;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-07-14 21:57:11 +00:00
|
|
|
switch (Cmd_Argc ()) {
|
|
|
|
case 1:
|
|
|
|
SV_Printf ("Local info settings:\n");
|
|
|
|
Info_Print (localinfo);
|
|
|
|
return;
|
|
|
|
case 2:
|
|
|
|
key = Cmd_Argv (1);
|
|
|
|
value = Info_ValueForKey (localinfo, key);
|
|
|
|
if (Info_Key (localinfo, key))
|
|
|
|
SV_Printf ("Localinfo %s: \"%s\"\n", key, value);
|
|
|
|
else
|
|
|
|
SV_Printf ("No such key %s\n", Cmd_Argv(1));
|
|
|
|
return;
|
|
|
|
case 3:
|
|
|
|
key = Cmd_Argv (1);
|
|
|
|
value = Cmd_Argv (2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SV_Printf ("usage: localinfo [ <key> <value> ]\n");
|
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2012-07-14 21:57:11 +00:00
|
|
|
if (key[0] == '*') {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Star variables cannot be changed.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-07-14 21:57:11 +00:00
|
|
|
SV_SetLocalinfo (key, value);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SV_User_f
|
|
|
|
|
|
|
|
Examine a users info strings
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_User_f (void)
|
|
|
|
{
|
|
|
|
if (Cmd_Argc () != 2) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Usage: user <userid>\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SV_SetPlayer ())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Info_Print (host_client->userinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SV_Gamedir
|
|
|
|
|
|
|
|
Sets the fake *gamedir to a different directory.
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Gamedir (void)
|
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *dir;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc () == 1) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Current *gamedir: %s\n",
|
2001-02-19 21:15:25 +00:00
|
|
|
Info_ValueForKey (svs.info, "*gamedir"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Cmd_Argc () != 2) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Usage: sv_gamedir <newgamedir>\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dir = Cmd_Argv (1);
|
|
|
|
|
|
|
|
if (strstr (dir, "..") || strstr (dir, "/")
|
|
|
|
|| strstr (dir, "\\") || strstr (dir, ":")) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("*Gamedir should be a single filename, not a path\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-21 23:23:22 +00:00
|
|
|
Info_SetValueForStarKey (svs.info, "*gamedir", dir,
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
!sv_highchars);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SV_Floodport_f
|
|
|
|
|
|
|
|
Sets the gamedir and path to a different directory.
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Floodprot_f (void)
|
|
|
|
{
|
|
|
|
int arg1, arg2, arg3;
|
|
|
|
|
|
|
|
if (Cmd_Argc () == 1) {
|
|
|
|
if (fp_messages) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf
|
2001-08-28 02:43:24 +00:00
|
|
|
("Current floodprot settings: \nAfter %d msgs per %d seconds, "
|
|
|
|
"silence for %d seconds\n",
|
2001-02-19 21:15:25 +00:00
|
|
|
fp_messages, fp_persecond, fp_secondsdead);
|
|
|
|
return;
|
|
|
|
} else
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("No floodprots enabled.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Cmd_Argc () != 4) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf
|
2001-08-28 02:43:24 +00:00
|
|
|
("Usage: floodprot <# of messages> <per # of seconds> <seconds to "
|
|
|
|
"silence>\n");
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf
|
2001-08-28 02:43:24 +00:00
|
|
|
("Use floodprotmsg to set a custom message to say to the "
|
|
|
|
"flooder.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
arg1 = atoi (Cmd_Argv (1));
|
|
|
|
arg2 = atoi (Cmd_Argv (2));
|
|
|
|
arg3 = atoi (Cmd_Argv (3));
|
|
|
|
|
|
|
|
if (arg1 <= 0 || arg2 <= 0 || arg3 <= 0) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("All values must be positive numbers\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arg1 > 10) {
|
2010-01-13 06:42:26 +00:00
|
|
|
SV_Printf ("Can track up to only 10 messages.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fp_messages = arg1;
|
|
|
|
fp_persecond = arg2;
|
|
|
|
fp_secondsdead = arg3;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Floodprotmsg_f (void)
|
|
|
|
{
|
|
|
|
if (Cmd_Argc () == 1) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Current msg: %s\n", fp_msg);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
} else if (Cmd_Argc () != 2) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Usage: floodprotmsg \"<message>\"\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
snprintf (fp_msg, sizeof (fp_msg), "%s", Cmd_Argv (1));
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Snap (int uid)
|
|
|
|
{
|
2001-08-28 02:43:24 +00:00
|
|
|
client_t *cl;
|
2001-02-19 21:15:25 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
2003-03-03 17:08:45 +00:00
|
|
|
if (cl->state < cs_zombie)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
if (cl->userid == uid)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i >= MAX_CLIENTS) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("userid not found\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-05-23 17:17:01 +00:00
|
|
|
if (!cl->uploadfn)
|
|
|
|
cl->uploadfn = dstring_new ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-31 08:27:04 +00:00
|
|
|
if (!(cl->upload = QFS_NextFile (cl->uploadfn,
|
|
|
|
va (0, "%s/snap/%d-",
|
|
|
|
qfs_gamedir->dir.def, uid), ".pcx"))) {
|
|
|
|
SV_Printf ("Snap: Couldn't create a file, clean some out.\n%s\n",
|
|
|
|
cl->uploadfn->str);
|
2003-05-23 17:17:01 +00:00
|
|
|
dstring_delete (cl->uploadfn);
|
|
|
|
cl->uploadfn = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-03-31 08:27:04 +00:00
|
|
|
cl->upload_started = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
memcpy (&cl->snap_from, &net_from, sizeof (net_from));
|
|
|
|
if (sv_redirected != RD_NONE)
|
|
|
|
cl->remote_snap = true;
|
|
|
|
else
|
|
|
|
cl->remote_snap = false;
|
|
|
|
|
2004-02-22 05:40:08 +00:00
|
|
|
MSG_ReliableWrite_Begin (&cl->backbuf, svc_stufftext, 24);
|
|
|
|
MSG_ReliableWrite_String (&cl->backbuf, "cmd snap\n");
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Requesting snap from user %d...\n", uid);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Snap_f (void)
|
|
|
|
{
|
|
|
|
int uid;
|
|
|
|
|
|
|
|
if (Cmd_Argc () != 2) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Usage: snap <userid>\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uid = atoi (Cmd_Argv (1));
|
|
|
|
|
|
|
|
SV_Snap (uid);
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_SnapAll_f (void)
|
|
|
|
{
|
|
|
|
client_t *cl;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
|
|
|
if (cl->state < cs_connected || cl->spectator)
|
|
|
|
continue;
|
|
|
|
SV_Snap (cl->userid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SV_InitOperatorCommands (void)
|
|
|
|
{
|
|
|
|
if (COM_CheckParm ("-cheats")) {
|
|
|
|
sv_allow_cheats = true;
|
2001-11-04 07:50:39 +00:00
|
|
|
Info_SetValueForStarKey (svs.info, "*cheats", "ON", 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
Cmd_AddCommand ("fraglogfile", SV_Fraglogfile_f, "Enables logging of kills "
|
|
|
|
"to frag_##.log");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-01-12 05:32:21 +00:00
|
|
|
Cmd_AddCommand ("snap", SV_Snap_f, "Take a screenshot of userid");
|
|
|
|
Cmd_AddCommand ("snapall", SV_SnapAll_f, "Take a screenshot of all users");
|
2001-08-28 02:43:24 +00:00
|
|
|
Cmd_AddCommand ("kick", SV_Kick_f, "Remove a user from the server (kick "
|
|
|
|
"userid)");
|
|
|
|
Cmd_AddCommand ("status", SV_Status_f, "Report information on the current "
|
|
|
|
"connected clients and the server - displays userids");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Cmd_AddCommand ("map", SV_Map_f, "Change to a new map (map mapname)");
|
2001-08-28 02:43:24 +00:00
|
|
|
Cmd_AddCommand ("setmaster", SV_SetMaster_f, "Lists the server with up to "
|
|
|
|
"eight masters.\n"
|
|
|
|
"When a server is listed with a master, the master is "
|
|
|
|
"aware of the server's IP address and port and it is added "
|
|
|
|
"to the\n"
|
|
|
|
"list of current servers connected to a master. A "
|
|
|
|
"heartbeat is sent to the master from the server to "
|
|
|
|
"indicated that the\n"
|
|
|
|
"server is still running and alive.\n\n"
|
|
|
|
"Examples:\n"
|
|
|
|
"setmaster 192.246.40.12:27002\n"
|
|
|
|
"setmaster 192.246.40.12:27002 192.246.40.12:27004");
|
|
|
|
Cmd_AddCommand ("heartbeat", SV_Heartbeat_f, "Force a heartbeat to be sent "
|
|
|
|
"to the master server.\n"
|
|
|
|
"A heartbeat tells the Master the server's IP address and "
|
|
|
|
"that it is still alive.");
|
2007-09-15 10:09:08 +00:00
|
|
|
Cmd_AddCommand ("restart", SV_Restart_f, "Restart the server (with shell "
|
|
|
|
"support)");
|
2001-02-19 21:15:25 +00:00
|
|
|
Cmd_AddCommand ("quit", SV_Quit_f, "Shut down the server");
|
2001-08-28 02:43:24 +00:00
|
|
|
Cmd_AddCommand ("god", SV_God_f, "Toggle god cheat to userid (god userid) "
|
|
|
|
"Requires cheats are enabled");
|
2001-02-19 21:15:25 +00:00
|
|
|
Cmd_AddCommand ("give", SV_Give_f, "Give userid items, or health.\n"
|
2001-08-28 02:43:24 +00:00
|
|
|
"Items: 1 Axe, 2 Shotgun, 3 Double-Barrelled Shotgun, 4 "
|
|
|
|
"Nailgun, 5 Super Nailgun, 6 Grenade Launcher, 7 Rocket "
|
|
|
|
"Launcher,\n"
|
|
|
|
"8 ThunderBolt, C Cells, H Health, N Nails, R Rockets, S "
|
|
|
|
"Shells. Requires cheats to be enabled. (give userid item "
|
|
|
|
"amount)");
|
|
|
|
Cmd_AddCommand ("noclip", SV_Noclip_f, "Toggle no clipping cheat for "
|
|
|
|
"userid. Requires cheats to be enabled. (noclip userid)");
|
|
|
|
Cmd_AddCommand ("serverinfo", SV_Serverinfo_f, "Reports or sets "
|
|
|
|
"information about server.\n"
|
|
|
|
"The information stored in this space is broadcast on the "
|
|
|
|
"network to all players.\n"
|
|
|
|
"Values:\n"
|
|
|
|
"dq - Drop Quad Damage when a player dies.\n"
|
|
|
|
"dr - Drop Ring of Shadows when a player dies.\n"
|
|
|
|
"rj - Sets the multiplier rate for splash damage kick.\n"
|
|
|
|
"needpass - Displays the passwords enabled on the server.\n"
|
|
|
|
"watervis - Toggle the use of r_watervis by OpenGL "
|
|
|
|
"clients.\n"
|
|
|
|
"Note: Keys with (*) in front cannot be changed. Maximum "
|
|
|
|
"key size cannot exceed 64-bytes.\n"
|
|
|
|
"Maximum size for all keys cannot exceed 512-bytes.\n"
|
|
|
|
"(serverinfo key value)");
|
|
|
|
Cmd_AddCommand ("localinfo", SV_Localinfo_f, "Shows or sets localinfo "
|
|
|
|
"variables.\n"
|
|
|
|
"Useful for mod programmers who need to allow the admin to "
|
|
|
|
"change settings.\n"
|
|
|
|
"This is an alternative storage space to the serverinfo "
|
|
|
|
"space for mod variables.\n"
|
|
|
|
"The variables stored in this space are not broadcast on "
|
|
|
|
"the network.\n"
|
|
|
|
"This space also has a 32-kilobyte limit which is much "
|
|
|
|
"greater then the 512-byte limit on the serverinfo space.\n"
|
|
|
|
"Special Keys: (current map) (next map) - Using this "
|
|
|
|
"combination will allow the creation of a custom map cycle "
|
|
|
|
"without editing code.\n\n"
|
|
|
|
"Example:\n"
|
|
|
|
"localinfo dm2 dm4\n"
|
|
|
|
"localinfo dm4 dm6\n"
|
|
|
|
"localinfo dm6 dm2\n"
|
|
|
|
"(localinfo key value)");
|
|
|
|
Cmd_AddCommand ("user", SV_User_f, "Report information about the user "
|
|
|
|
"(user userid)");
|
|
|
|
Cmd_AddCommand ("sv_gamedir", SV_Gamedir, "Displays or determines the "
|
|
|
|
"value of the serverinfo *gamedir variable.\n"
|
|
|
|
"Note: Useful when the physical gamedir directory has a "
|
|
|
|
"different name than the widely accepted gamedir "
|
|
|
|
"directory.\n"
|
|
|
|
"Example:\n"
|
|
|
|
"gamedir tf2_5; sv_gamedir fortress\n"
|
|
|
|
"gamedir ctf4_2; sv_gamedir ctf\n"
|
|
|
|
"(sv_gamedir dirname)");
|
|
|
|
Cmd_AddCommand ("floodprot", SV_Floodprot_f, "Sets the options for flood "
|
|
|
|
"protection.\n"
|
|
|
|
"Default: 4 4 10\n"
|
|
|
|
"(floodprot (number of messages) (number of seconds) "
|
|
|
|
"(silence time in seconds))");
|
|
|
|
Cmd_AddCommand ("floodprotmsg", SV_Floodprotmsg_f, "Sets the message "
|
|
|
|
"displayed after flood protection is invoked (floodprotmsg "
|
|
|
|
"message)");
|
2001-11-05 22:24:16 +00:00
|
|
|
Cmd_AddCommand ("maplist", Con_Maplist_f, "List all maps on the server");
|
2001-08-28 02:43:24 +00:00
|
|
|
Cmd_AddCommand ("say", SV_ConSay_f, "Say something to everyone on the "
|
|
|
|
"server. Will show up as the name 'Console' (or 'Admin') "
|
|
|
|
"in game");
|
|
|
|
Cmd_AddCommand ("sayinfo", SV_ConSay_Info_f, "Say something to everyone on "
|
|
|
|
"the server. Will show up as the name 'Info' in game");
|
|
|
|
Cmd_AddCommand ("tell", SV_Tell_f, "Say something to a specific user on "
|
|
|
|
"the server. Will show up as the name 'Console' (or "
|
|
|
|
"'Admin') in game");
|
2001-09-09 04:51:08 +00:00
|
|
|
Cmd_AddCommand ("ban", SV_Ban_f, "ban a player for a specified time");
|
|
|
|
Cmd_AddCommand ("cuff", SV_Cuff_f, "\"hand-cuff\" a player for a "
|
|
|
|
"specified time");
|
|
|
|
Cmd_AddCommand ("mute", SV_Mute_f, "silience a player for a specified "
|
|
|
|
"time");
|
2001-09-11 07:10:45 +00:00
|
|
|
Cmd_AddCommand ("match", SV_Match_f, "matches nicks as ban/cuff/mute "
|
|
|
|
"commands do, so you can check safely");
|
2001-07-09 23:33:35 +00:00
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
// poor description
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Cvar_Register (&sv_leetnickmatch_cvar, 0, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|