2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
sv_main.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
|
|
|
|
2002-10-11 20:47:17 +00:00
|
|
|
#ifdef HAVE_WINDOWS_H
|
|
|
|
# include "winquake.h"
|
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2001-10-17 18:49:25 +00:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
2002-03-03 06:03:51 +00:00
|
|
|
# define INET6
|
2002-08-09 02:44:23 +00:00
|
|
|
# define model_t sun_model_t
|
2001-10-17 18:49:25 +00:00
|
|
|
# include <netinet/in.h>
|
2002-08-09 02:44:23 +00:00
|
|
|
# undef model_t
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
|
|
# include <sys/socket.h>
|
2001-10-17 18:49:25 +00:00
|
|
|
#endif
|
2001-09-16 15:40:21 +00:00
|
|
|
#ifdef HAVE_ARPA_INET_H
|
|
|
|
# include <arpa/inet.h>
|
|
|
|
#endif
|
2001-09-25 06:18:30 +00:00
|
|
|
#ifdef HAVE_WINSOCK_H
|
|
|
|
# include <winsock.h>
|
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
2001-12-15 04:58:16 +00:00
|
|
|
#include <setjmp.h>
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
#include "QF/cbuf.h"
|
2002-07-31 22:03:53 +00:00
|
|
|
#include "QF/idparse.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cmd.h"
|
2001-07-10 22:36:22 +00:00
|
|
|
#include "QF/console.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2002-04-10 21:03:02 +00:00
|
|
|
#include "QF/dstring.h"
|
2001-04-10 06:55:28 +00:00
|
|
|
#include "QF/model.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/msg.h"
|
|
|
|
#include "QF/qargs.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"
|
|
|
|
#include "QF/ver_check.h"
|
|
|
|
#include "QF/zone.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
|
2012-02-13 12:58:34 +00:00
|
|
|
#include "QF/plugin/console.h"
|
|
|
|
|
2001-05-30 04:34:06 +00:00
|
|
|
#include "buildnum.h"
|
2001-07-10 22:36:22 +00:00
|
|
|
#include "compat.h"
|
2003-02-11 22:48:57 +00:00
|
|
|
#include "netchan.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
|
|
|
|
#include "qw/bothdefs.h"
|
|
|
|
#include "qw/include/crudefile.h"
|
|
|
|
#include "qw/include/game.h"
|
2005-05-02 04:09:15 +00:00
|
|
|
#include "qw/pmove.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "qw/include/server.h"
|
|
|
|
#include "qw/include/sv_demo.h"
|
|
|
|
#include "qw/include/sv_progs.h"
|
|
|
|
#include "qw/include/sv_gib.h"
|
|
|
|
#include "qw/include/sv_qtv.h"
|
|
|
|
#include "qw/include/sv_recorder.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-12-02 20:11:21 +00:00
|
|
|
SERVER_PLUGIN_PROTOS
|
|
|
|
static plugin_list_t server_plugin_list[] = {
|
2003-02-10 21:04:08 +00:00
|
|
|
SERVER_PLUGIN_LIST
|
2001-12-02 20:11:21 +00:00
|
|
|
};
|
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
cbuf_t *sv_cbuf;
|
|
|
|
cbuf_args_t *sv_args;
|
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
client_t *host_client; // current client
|
2007-05-07 14:58:53 +00:00
|
|
|
entity_state_t cl_entities[MAX_CLIENTS][UPDATE_BACKUP+1][MAX_PACKET_ENTITIES]; // client entities
|
2001-07-09 23:33:35 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
double sv_frametime;
|
|
|
|
double realtime; // without any filtering or bounding
|
|
|
|
|
2021-07-29 02:12:37 +00:00
|
|
|
size_t host_hunklevel;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
netadr_t master_adr[MAX_MASTERS]; // address of group servers
|
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
quakeparms_t host_parms;
|
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
bool host_initialized; // true if into command execution
|
|
|
|
bool rcon_from_user;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// DoS protection
|
|
|
|
// FLOOD_PING, FLOOD_LOG, FLOOD_CONNECT, FLOOD_STATUS, FLOOD_RCON, FLOOD_BAN
|
2001-02-21 23:45:49 +00:00
|
|
|
// FIXME: these default values need to be tweaked after more testing
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
double netdosexpire[DOSFLOODCMDS] = { 1, 1, 2, 0.9, 1, 5 };
|
|
|
|
double netdosvalues[DOSFLOODCMDS] = { 12, 1, 3, 1, 1, 1 };
|
|
|
|
|
[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
|
|
|
float sv_mem_size;
|
|
|
|
static cvar_t sv_mem_size_cvar = {
|
|
|
|
.name = "sv_mem_size",
|
|
|
|
.description =
|
|
|
|
"Amount of memory (in MB) to allocate for the "
|
|
|
|
PACKAGE_NAME
|
|
|
|
" heap",
|
|
|
|
.default_value = "8",
|
|
|
|
.flags = CVAR_ROM,
|
|
|
|
.value = { .type = &cexpr_float, .value = &sv_mem_size },
|
|
|
|
};
|
2001-11-14 20:18:37 +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
|
|
|
char *sv_console_plugin;
|
|
|
|
static cvar_t sv_console_plugin_cvar = {
|
|
|
|
.name = "sv_console_plugin",
|
|
|
|
.description =
|
|
|
|
"Plugin used for the console",
|
|
|
|
.default_value = "server",
|
|
|
|
.flags = CVAR_ROM,
|
|
|
|
.value = { .type = 0, .value = &sv_console_plugin },
|
|
|
|
};
|
2001-09-20 15:14:44 +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
|
|
|
int sv_allow_status;
|
|
|
|
static cvar_t sv_allow_status_cvar = {
|
|
|
|
.name = "sv_allow_status",
|
|
|
|
.description =
|
|
|
|
"Allow remote status queries (qstat etc)",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &sv_allow_status },
|
|
|
|
};
|
|
|
|
int sv_allow_log;
|
|
|
|
static cvar_t sv_allow_log_cvar = {
|
|
|
|
.name = "sv_allow_log",
|
|
|
|
.description =
|
|
|
|
"Allow remote logging",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &sv_allow_log },
|
|
|
|
};
|
|
|
|
int sv_allow_ping;
|
|
|
|
static cvar_t sv_allow_ping_cvar = {
|
|
|
|
.name = "sv_allow_pings",
|
|
|
|
.description =
|
|
|
|
"Allow remote pings (qstat etc)",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &sv_allow_ping },
|
|
|
|
};
|
2001-02-19 21:15:25 +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
|
|
|
int sv_extensions;
|
|
|
|
static cvar_t sv_extensions_cvar = {
|
|
|
|
.name = "sv_extensions",
|
|
|
|
.description =
|
|
|
|
"Use protocol extensions for QuakeForge clients",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &sv_extensions },
|
|
|
|
};
|
2001-09-11 03:50:24 +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
|
|
|
float sv_mintic;
|
|
|
|
static cvar_t sv_mintic_cvar = {
|
|
|
|
.name = "sv_mintic",
|
|
|
|
.description =
|
|
|
|
"The minimum amount of time the server will wait before sending "
|
|
|
|
"packets to a client. Set to .5 to make modem users happy",
|
|
|
|
.default_value = "0.03",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &sv_mintic },
|
|
|
|
};
|
|
|
|
float sv_maxtic;
|
|
|
|
static cvar_t sv_maxtic_cvar = {
|
|
|
|
.name = "sv_maxtic",
|
|
|
|
.description =
|
|
|
|
"The maximum amount of time in seconds before a client a receives an "
|
|
|
|
"update from the server",
|
|
|
|
.default_value = "0.1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &sv_maxtic },
|
|
|
|
};
|
2001-02-19 21:15:25 +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
|
|
|
int sv_netdosprotect;
|
|
|
|
static cvar_t sv_netdosprotect_cvar = {
|
|
|
|
.name = "sv_netdosprotect",
|
|
|
|
.description =
|
|
|
|
"DoS flood attack protection",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &sv_netdosprotect },
|
|
|
|
};
|
2001-08-28 02:43:24 +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
|
|
|
float sv_timeout;
|
|
|
|
static cvar_t sv_timeout_cvar = {
|
|
|
|
.name = "timeout",
|
|
|
|
.description =
|
|
|
|
"Sets the amount of time in seconds before a client is considered "
|
|
|
|
"disconnected if the server does not receive a packet",
|
|
|
|
.default_value = "65",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &sv_timeout },
|
|
|
|
};
|
|
|
|
float zombietime;
|
|
|
|
static cvar_t zombietime_cvar = {
|
|
|
|
.name = "zombietime",
|
|
|
|
.description =
|
|
|
|
"The number of seconds that the server will keep the character of a "
|
|
|
|
"player on the map who seems to have disconnected",
|
|
|
|
.default_value = "2",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &zombietime },
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
// disconnect
|
|
|
|
|
[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
|
|
|
char *rcon_password;
|
|
|
|
static cvar_t rcon_password_cvar = {
|
|
|
|
.name = "rcon_password",
|
|
|
|
.description =
|
|
|
|
"Set the password for rcon 'root' commands",
|
|
|
|
.default_value = "",
|
|
|
|
.flags = CVAR_NONE,
|
2022-04-24 12:13:46 +00:00
|
|
|
.value = { .type=0/*FIXME want secret strings*/, .value = &rcon_password },
|
[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
|
|
|
};
|
|
|
|
char *admin_password;
|
|
|
|
static cvar_t admin_password_cvar = {
|
|
|
|
.name = "admin_password",
|
|
|
|
.description =
|
|
|
|
"Set the password for rcon admin commands",
|
|
|
|
.default_value = "",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = 0/* not used */, .value = &admin_password },
|
|
|
|
};
|
2001-02-19 21:15:25 +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
|
|
|
char *password;
|
|
|
|
static cvar_t password_cvar = {
|
|
|
|
.name = "password",
|
|
|
|
.description =
|
|
|
|
"Set the server password for players",
|
|
|
|
.default_value = "",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = 0, .value = &password },
|
|
|
|
};
|
|
|
|
char *spectator_password;
|
|
|
|
static cvar_t spectator_password_cvar = {
|
|
|
|
.name = "spectator_password",
|
|
|
|
.description =
|
|
|
|
"Set the spectator password",
|
|
|
|
.default_value = "",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = 0, .value = &spectator_password },
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
// spectator
|
|
|
|
|
[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 allow_download;
|
|
|
|
static cvar_t allow_download_cvar = {
|
|
|
|
.name = "allow_download",
|
|
|
|
.description =
|
|
|
|
"Toggle if clients can download game data from the server",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &allow_download },
|
|
|
|
};
|
|
|
|
int allow_download_skins;
|
|
|
|
static cvar_t allow_download_skins_cvar = {
|
|
|
|
.name = "allow_download_skins",
|
|
|
|
.description =
|
|
|
|
"Toggle if clients can download skins from the server",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &allow_download_skins },
|
|
|
|
};
|
|
|
|
int allow_download_models;
|
|
|
|
static cvar_t allow_download_models_cvar = {
|
|
|
|
.name = "allow_download_models",
|
|
|
|
.description =
|
|
|
|
"Toggle if clients can download models from the server",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &allow_download_models },
|
|
|
|
};
|
|
|
|
int allow_download_sounds;
|
|
|
|
static cvar_t allow_download_sounds_cvar = {
|
|
|
|
.name = "allow_download_sounds",
|
|
|
|
.description =
|
|
|
|
"Toggle if clients can download sounds from the server",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &allow_download_sounds },
|
|
|
|
};
|
|
|
|
int allow_download_maps;
|
|
|
|
static cvar_t allow_download_maps_cvar = {
|
|
|
|
.name = "allow_download_maps",
|
|
|
|
.description =
|
|
|
|
"Toggle if clients can download maps from the server",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &allow_download_maps },
|
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
int allow_download_demos;
|
[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
|
|
|
static cvar_t allow_download_demos_cvar = {
|
|
|
|
.name = "allow_download_demos",
|
|
|
|
.description =
|
|
|
|
"Toggle if clients can download maps from the server",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_int, .value = &allow_download_demos },
|
[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
|
|
|
};
|
2001-02-19 21:15:25 +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
|
|
|
int sv_highchars;
|
|
|
|
static cvar_t sv_highchars_cvar = {
|
|
|
|
.name = "sv_highchars",
|
|
|
|
.description =
|
|
|
|
"Toggle the use of high character color names for players",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &sv_highchars },
|
|
|
|
};
|
|
|
|
int sv_phs;
|
|
|
|
static cvar_t sv_phs_cvar = {
|
|
|
|
.name = "sv_phs",
|
|
|
|
.description =
|
|
|
|
"Possibly Hearable Set. If set to zero, the server calculates sound "
|
|
|
|
"hearability in realtime",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &sv_phs },
|
|
|
|
};
|
2001-02-19 21:15:25 +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
|
|
|
int pausable;
|
|
|
|
static cvar_t pausable_cvar = {
|
|
|
|
.name = "pausable",
|
|
|
|
.description =
|
|
|
|
"None",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &pausable },
|
|
|
|
};
|
2001-02-19 21:15:25 +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
|
|
|
char *sv_minqfversion;
|
|
|
|
static cvar_t sv_minqfversion_cvar = {
|
|
|
|
.name = "sv_minqfversion",
|
|
|
|
.description =
|
|
|
|
"Minimum QF version on client",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_SERVERINFO,
|
|
|
|
.value = { .type = 0, .value = &sv_minqfversion },
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
// connect
|
|
|
|
|
[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_timestamps;
|
|
|
|
static cvar_t sv_timestamps_cvar = {
|
|
|
|
.name = "sv_timestamps",
|
|
|
|
.description =
|
|
|
|
"Time/date stamps in log entries",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &sv_timestamps },
|
|
|
|
};
|
|
|
|
char *sv_timefmt;
|
|
|
|
static cvar_t sv_timefmt_cvar = {
|
|
|
|
.name = "sv_timefmt",
|
|
|
|
.description =
|
|
|
|
"Time/date format to use",
|
|
|
|
.default_value = "[%b %e %X] ",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = 0, .value = &sv_timefmt },
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// game rules mirrored in svs.info
|
2022-04-24 11:04:06 +00:00
|
|
|
float fraglimit;
|
[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
|
|
|
static cvar_t fraglimit_cvar = {
|
|
|
|
.name = "fraglimit",
|
|
|
|
.description =
|
|
|
|
"None",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_SERVERINFO,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &fraglimit },
|
[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 timelimit;
|
|
|
|
static cvar_t timelimit_cvar = {
|
|
|
|
.name = "timelimit",
|
|
|
|
.description =
|
|
|
|
"None",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_SERVERINFO,
|
|
|
|
.value = { .type = &cexpr_int, .value = &timelimit },
|
|
|
|
};
|
|
|
|
int teamplay;
|
|
|
|
static cvar_t teamplay_cvar = {
|
|
|
|
.name = "teamplay",
|
|
|
|
.description =
|
|
|
|
"None",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_SERVERINFO,
|
|
|
|
.value = { .type = &cexpr_int, .value = &teamplay },
|
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
float samelevel;
|
[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
|
|
|
static cvar_t samelevel_cvar = {
|
|
|
|
.name = "samelevel",
|
|
|
|
.description =
|
|
|
|
"None",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &samelevel },
|
[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 maxclients;
|
|
|
|
static cvar_t maxclients_cvar = {
|
|
|
|
.name = "maxclients",
|
|
|
|
.description =
|
|
|
|
"Sets how many clients can connect to your server, this includes "
|
|
|
|
"spectators and players",
|
|
|
|
.default_value = "8",
|
|
|
|
.flags = CVAR_SERVERINFO,
|
|
|
|
.value = { .type = &cexpr_int, .value = &maxclients },
|
|
|
|
};
|
|
|
|
int maxspectators;
|
|
|
|
static cvar_t maxspectators_cvar = {
|
|
|
|
.name = "maxspectators",
|
|
|
|
.description =
|
|
|
|
"Sets how many spectators can connect to your server. The maxclients "
|
|
|
|
"value takes precedence over this value so this value should always be"
|
|
|
|
" equal-to or less-then the maxclients value",
|
|
|
|
.default_value = "8",
|
|
|
|
.flags = CVAR_SERVERINFO,
|
|
|
|
.value = { .type = &cexpr_int, .value = &maxspectators },
|
|
|
|
};
|
|
|
|
int deathmatch;
|
|
|
|
static cvar_t deathmatch_cvar = {
|
|
|
|
.name = "deathmatch",
|
|
|
|
.description =
|
|
|
|
"0, 1, or 2",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &deathmatch },
|
|
|
|
};
|
|
|
|
int coop;
|
|
|
|
static cvar_t coop_cvar = {
|
|
|
|
.name = "coop",
|
|
|
|
.description =
|
|
|
|
"0 or 1",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &coop },
|
|
|
|
};
|
|
|
|
int skill;
|
|
|
|
static cvar_t skill_cvar = {
|
|
|
|
.name = "skill",
|
|
|
|
.description =
|
|
|
|
"0 - 3",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &skill },
|
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
float spawn;
|
[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
|
|
|
static cvar_t spawn_cvar = {
|
|
|
|
.name = "spawn",
|
|
|
|
.description =
|
|
|
|
"Spawn the player entity",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_SERVERINFO,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &spawn },
|
[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
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
int watervis;
|
[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
|
|
|
static cvar_t watervis_cvar = {
|
|
|
|
.name = "watervis",
|
|
|
|
.description =
|
|
|
|
"Set nonzero to enable r_wateralpha on clients",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_SERVERINFO,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_int, .value = &watervis },
|
[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
|
|
|
};
|
2001-02-19 21:15:25 +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
|
|
|
char *hostname;
|
|
|
|
static cvar_t hostname_cvar = {
|
|
|
|
.name = "hostname",
|
|
|
|
.description =
|
|
|
|
"None",
|
|
|
|
.default_value = "UNNAMED",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = 0, .value = &hostname },
|
|
|
|
};
|
2001-02-19 21:15:25 +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
|
|
|
QFile *sv_fraglogfile;
|
2001-06-16 22:39:41 +00:00
|
|
|
|
2002-08-28 21:12:22 +00:00
|
|
|
int sv_net_initialized;
|
|
|
|
|
2001-09-11 03:10:29 +00:00
|
|
|
const char *client_info_filters[] = { // Info keys needed by client
|
|
|
|
"name",
|
2012-06-29 08:56:36 +00:00
|
|
|
"chat",
|
2001-09-11 03:10:29 +00:00
|
|
|
"topcolor",
|
|
|
|
"bottomcolor",
|
|
|
|
"rate",
|
|
|
|
"msg",
|
|
|
|
"skin",
|
|
|
|
"team",
|
|
|
|
"noaim",
|
|
|
|
"pmodel",
|
|
|
|
"emodel",
|
|
|
|
"spectator",
|
|
|
|
"*spectator",
|
|
|
|
"*ver",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2002-11-05 19:12:51 +00:00
|
|
|
/*
|
|
|
|
Master_Shutdown
|
|
|
|
|
|
|
|
Informs all masters that this server is going down
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2002-11-05 19:12:51 +00:00
|
|
|
Master_Shutdown (void)
|
|
|
|
{
|
|
|
|
char string[2048];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
snprintf (string, sizeof (string), "%c\n", S2M_SHUTDOWN);
|
|
|
|
|
|
|
|
// send to group master
|
|
|
|
for (i = 0; i < MAX_MASTERS; i++)
|
|
|
|
if (master_adr[i].port) {
|
|
|
|
SV_Printf ("Sending heartbeat to %s\n",
|
|
|
|
NET_AdrToString (master_adr[i]));
|
2003-02-10 21:41:22 +00:00
|
|
|
Netchan_SendPacket (strlen (string), string, master_adr[i]);
|
2002-11-05 19:12:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
SV_Shutdown
|
|
|
|
|
|
|
|
Quake calls this before calling Sys_Quit or Sys_Error
|
|
|
|
*/
|
|
|
|
void
|
2020-03-21 13:24:11 +00:00
|
|
|
SV_Shutdown (void *data)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
Master_Shutdown ();
|
|
|
|
if (sv_fraglogfile) {
|
|
|
|
Qclose (sv_fraglogfile);
|
2002-08-07 18:46:53 +00:00
|
|
|
sv_fraglogfile = NULL;
|
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);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SV_Error
|
|
|
|
|
|
|
|
Sends a datagram to all the clients informing them of the server crash,
|
|
|
|
then exits
|
|
|
|
*/
|
2021-03-27 10:52:59 +00:00
|
|
|
static __attribute__((format(PRINTF, 1, 0))) void
|
2002-02-20 19:22:52 +00:00
|
|
|
SV_Error (const char *error, va_list argptr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool inerror = false;
|
2006-12-09 08:43:18 +00:00
|
|
|
dstring_t *string;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (inerror)
|
2002-02-20 19:22:52 +00:00
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-04-10 21:03:02 +00:00
|
|
|
inerror = true;
|
2006-12-09 08:43:18 +00:00
|
|
|
string = dstring_new ();
|
|
|
|
dvsprintf (string, error, argptr);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("%s\n", string->str);
|
2002-08-28 21:12:22 +00:00
|
|
|
|
2006-12-09 08:43:18 +00:00
|
|
|
if (sv_net_initialized) {
|
2002-08-28 21:12:22 +00:00
|
|
|
dstring_insertstr (string, 0, "server crashed: ");
|
|
|
|
dstring_appendstr (string, "\n");
|
|
|
|
SV_FinalMessage (string->str);
|
2002-05-21 21:06:27 +00:00
|
|
|
}
|
2006-12-09 08:43:18 +00:00
|
|
|
dstring_delete (string);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SV_FinalMessage
|
|
|
|
|
|
|
|
Used by SV_Error and SV_Quit_f to send a final message to all connected
|
|
|
|
clients before the server goes down. The messages are sent immediately,
|
|
|
|
not just stuck on the outgoing message list, because the server is going
|
|
|
|
to totally exit after returning from this function.
|
|
|
|
*/
|
|
|
|
void
|
2001-07-15 07:04:17 +00:00
|
|
|
SV_FinalMessage (const char *message)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
client_t *cl;
|
2001-08-28 02:43:24 +00:00
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-23 23:16:13 +00:00
|
|
|
SZ_Clear (net_message->message);
|
|
|
|
MSG_WriteByte (net_message->message, svc_print);
|
2001-11-07 08:24:56 +00:00
|
|
|
MSG_WriteByte (net_message->message, PRINT_HIGH);
|
|
|
|
MSG_WriteString (net_message->message, message);
|
2001-02-23 23:16:13 +00:00
|
|
|
MSG_WriteByte (net_message->message, svc_disconnect);
|
2001-02-19 21:15:25 +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_connected)
|
2001-02-23 23:16:13 +00:00
|
|
|
Netchan_Transmit (&cl->netchan, net_message->message->cursize,
|
|
|
|
net_message->message->data);
|
2005-05-05 07:31:31 +00:00
|
|
|
SV_qtvFinalMessage (message);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SV_DropClient
|
|
|
|
|
|
|
|
Called when the player is totally leaving the server, either willingly
|
|
|
|
or unwillingly. This is NOT called if the entire server is quiting
|
|
|
|
or crashing.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SV_DropClient (client_t *drop)
|
|
|
|
{
|
2001-09-09 04:51:08 +00:00
|
|
|
SV_SavePenaltyFilter (drop, ft_mute, drop->lockedtill);
|
|
|
|
SV_SavePenaltyFilter (drop, ft_cuff, drop->cuff_time);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// add the disconnect
|
|
|
|
MSG_WriteByte (&drop->netchan.message, svc_disconnect);
|
|
|
|
|
2004-04-06 22:02:45 +00:00
|
|
|
if (drop->state == cs_spawned) {//FIXME cs_server?
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!drop->spectator) {
|
|
|
|
// call the prog function for removing a client
|
|
|
|
// this will set the body to a dead frame, among other things
|
2001-03-01 08:34:30 +00:00
|
|
|
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, drop->edict);
|
|
|
|
PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientDisconnect);
|
2003-11-21 06:09:21 +00:00
|
|
|
} else if (sv_funcs.SpectatorDisconnect) {
|
2001-02-19 21:15:25 +00:00
|
|
|
// call the prog function for removing a client
|
|
|
|
// this will set the body to a dead frame, among other things
|
2001-03-01 08:34:30 +00:00
|
|
|
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, drop->edict);
|
2003-11-21 06:09:21 +00:00
|
|
|
PR_ExecuteProgram (&sv_pr_state, sv_funcs.SpectatorDisconnect);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (drop->spectator)
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Spectator %s removed\n", drop->name);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Client %s removed\n", drop->name);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (drop->download) {
|
|
|
|
Qclose (drop->download);
|
|
|
|
drop->download = NULL;
|
|
|
|
}
|
|
|
|
if (drop->upload) {
|
|
|
|
Qclose (drop->upload);
|
|
|
|
drop->upload = NULL;
|
|
|
|
}
|
2003-05-23 17:17:01 +00:00
|
|
|
if (drop->uploadfn)
|
|
|
|
dstring_delete (drop->uploadfn);
|
|
|
|
drop->uploadfn = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
drop->state = cs_zombie; // become free in a few seconds
|
|
|
|
drop->connection_started = realtime; // for zombie timeout
|
|
|
|
|
|
|
|
drop->old_frags = 0;
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (drop->edict, frags) = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
drop->name[0] = 0;
|
2001-11-04 07:50:39 +00:00
|
|
|
|
2001-11-10 22:55:10 +00:00
|
|
|
if (drop->userinfo)
|
|
|
|
Info_Destroy (drop->userinfo);
|
2001-11-04 07:50:39 +00:00
|
|
|
drop->userinfo = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// send notification to all remaining clients
|
|
|
|
SV_FullClientUpdate (drop, &sv.reliable_datagram);
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2003-02-28 05:09:46 +00:00
|
|
|
// Trigger GIB event
|
|
|
|
if (sv_client_disconnect_e->func)
|
2003-03-21 21:25:44 +00:00
|
|
|
GIB_Event_Callback (sv_client_disconnect_e, 1,
|
2021-01-31 07:01:20 +00:00
|
|
|
va (0, "%u", drop->userid));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
SV_CalcPing (client_t *cl)
|
|
|
|
{
|
|
|
|
float ping;
|
2001-08-28 02:43:24 +00:00
|
|
|
int count, i;
|
2001-02-19 21:15:25 +00:00
|
|
|
register client_frame_t *frame;
|
|
|
|
|
2003-03-05 03:56:50 +00:00
|
|
|
if (cl->state == cs_server)
|
|
|
|
return cl->ping;
|
2001-02-19 21:15:25 +00:00
|
|
|
ping = 0;
|
|
|
|
count = 0;
|
2005-04-30 08:45:17 +00:00
|
|
|
for (frame = cl->delta.frames, i = 0; i < UPDATE_BACKUP; i++, frame++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (frame->ping_time > 0) {
|
|
|
|
ping += frame->ping_time;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!count)
|
|
|
|
return 9999;
|
|
|
|
ping /= count;
|
|
|
|
|
|
|
|
return ping * 1000;
|
|
|
|
}
|
|
|
|
|
2001-11-04 07:50:39 +00:00
|
|
|
static int
|
|
|
|
make_info_string_filter (const char *key)
|
|
|
|
{
|
2001-11-04 23:02:43 +00:00
|
|
|
return *key == '_' || !Info_FilterForKey (key, client_info_filters);
|
2001-11-04 07:50:39 +00:00
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
SV_FullClientUpdate
|
|
|
|
|
|
|
|
Writes all update values to a sizebuf
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SV_FullClientUpdate (client_t *client, sizebuf_t *buf)
|
|
|
|
{
|
2003-01-06 18:28:13 +00:00
|
|
|
const char *info;
|
2001-08-28 02:43:24 +00:00
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
i = client - svs.clients;
|
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
// SV_Printf ("SV_FullClientUpdate: Updated frags for client %d\n", i);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
MSG_WriteByte (buf, svc_updatefrags);
|
|
|
|
MSG_WriteByte (buf, i);
|
|
|
|
MSG_WriteShort (buf, client->old_frags);
|
|
|
|
|
|
|
|
MSG_WriteByte (buf, svc_updateping);
|
|
|
|
MSG_WriteByte (buf, i);
|
|
|
|
MSG_WriteShort (buf, SV_CalcPing (client));
|
|
|
|
|
|
|
|
MSG_WriteByte (buf, svc_updatepl);
|
|
|
|
MSG_WriteByte (buf, i);
|
|
|
|
MSG_WriteByte (buf, client->lossage);
|
|
|
|
|
|
|
|
MSG_WriteByte (buf, svc_updateentertime);
|
|
|
|
MSG_WriteByte (buf, i);
|
|
|
|
MSG_WriteFloat (buf, realtime - client->connection_started);
|
|
|
|
|
2001-11-04 07:50:39 +00:00
|
|
|
info = client->userinfo ? Info_MakeString (client->userinfo,
|
|
|
|
make_info_string_filter) : "";
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
MSG_WriteByte (buf, svc_updateuserinfo);
|
2001-11-07 08:24:56 +00:00
|
|
|
MSG_WriteByte (buf, i);
|
|
|
|
MSG_WriteLong (buf, client->userid);
|
|
|
|
MSG_WriteString (buf, info);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SV_FullClientUpdateToClient
|
|
|
|
|
|
|
|
Writes all update values to a client's reliable stream
|
|
|
|
*/
|
|
|
|
void
|
2005-05-05 07:31:31 +00:00
|
|
|
SV_FullClientUpdateToClient (client_t *client, backbuf_t *backbuf)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2003-08-21 03:50:30 +00:00
|
|
|
if (client->state < cs_connected && client->state != cs_server)
|
2001-11-04 07:50:39 +00:00
|
|
|
return;
|
2012-05-21 13:50:59 +00:00
|
|
|
MSG_ReliableCheckBlock (backbuf, 24 + Info_CurrentSize (client->userinfo));
|
2005-05-05 11:43:02 +00:00
|
|
|
if (backbuf->num_backbuf) {
|
|
|
|
SV_FullClientUpdate (client, &backbuf->backbuf);
|
|
|
|
MSG_Reliable_FinishWrite (backbuf);
|
|
|
|
} else
|
|
|
|
SV_FullClientUpdate (client, &backbuf->netchan->message);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
/* CONNECTIONLESS COMMANDS */
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
CheckForFlood :: EXPERIMENTAL
|
|
|
|
|
|
|
|
Makes it more difficult to use Quake servers for DoS attacks against
|
|
|
|
other sites.
|
|
|
|
|
|
|
|
Bad sides: affects gamespy and spytools somewhat...
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static int
|
2001-02-19 21:15:25 +00:00
|
|
|
CheckForFlood (flood_enum_t cmdtype)
|
|
|
|
{
|
|
|
|
double currenttime;
|
|
|
|
double oldestTime;
|
|
|
|
static double lastmessagetime = 0;
|
2001-08-28 02:43:24 +00:00
|
|
|
static flood_t floodstatus[DOSFLOODCMDS][DOSFLOODIP];
|
|
|
|
int oldest, i;
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool firsttime = true;
|
2001-02-19 21:15:25 +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 (!sv_netdosprotect)
|
2001-02-19 21:15:25 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
oldestTime = 0x7fffffff;
|
|
|
|
oldest = 0;
|
|
|
|
|
|
|
|
if (firsttime) {
|
2007-01-06 21:31:03 +00:00
|
|
|
memset (floodstatus, 0, sizeof (flood_t) * DOSFLOODCMDS * DOSFLOODIP);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
firsttime = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
currenttime = Sys_DoubleTime ();
|
|
|
|
|
|
|
|
for (i = 0; i < DOSFLOODIP; i++) {
|
|
|
|
if (NET_CompareBaseAdr (net_from, floodstatus[cmdtype][i].adr))
|
|
|
|
break;
|
|
|
|
if (floodstatus[cmdtype][i].issued < oldestTime) {
|
|
|
|
oldestTime = floodstatus[cmdtype][i].issued;
|
|
|
|
oldest = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < DOSFLOODIP && floodstatus[cmdtype][i].issued) {
|
|
|
|
if ((floodstatus[cmdtype][i].issued + netdosexpire[cmdtype])
|
|
|
|
> currenttime) {
|
|
|
|
floodstatus[cmdtype][i].floodcount += 1;
|
|
|
|
if (floodstatus[cmdtype][i].floodcount > netdosvalues[cmdtype]) {
|
|
|
|
if ((lastmessagetime + 5) < currenttime)
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Blocking type %d flood from (or to) %s\n",
|
2001-02-19 21:15:25 +00:00
|
|
|
cmdtype, NET_AdrToString (net_from));
|
|
|
|
floodstatus[cmdtype][i].floodcount = 0;
|
|
|
|
floodstatus[cmdtype][i].issued = currenttime;
|
|
|
|
floodstatus[cmdtype][i].cmdcount += 1;
|
|
|
|
lastmessagetime = currenttime;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
floodstatus[cmdtype][i].floodcount = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == DOSFLOODIP) {
|
|
|
|
i = oldest;
|
|
|
|
floodstatus[cmdtype][i].adr = net_from;
|
|
|
|
floodstatus[cmdtype][i].firstseen = currenttime;
|
|
|
|
floodstatus[cmdtype][i].cmdcount = 0;
|
|
|
|
floodstatus[cmdtype][i].floodcount = 0;
|
|
|
|
}
|
|
|
|
floodstatus[cmdtype][i].issued = currenttime;
|
|
|
|
floodstatus[cmdtype][i].cmdcount += 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SVC_Status
|
|
|
|
|
|
|
|
Responds with all the info that qplug or qspy can see
|
|
|
|
This message can be up to around 5k with worst case string lengths.
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SVC_Status (void)
|
|
|
|
{
|
|
|
|
client_t *cl;
|
2001-08-28 02:43:24 +00:00
|
|
|
int ping, bottom, top, i;
|
2001-02-19 21:15:25 +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 (!sv_allow_status)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
if (CheckForFlood (FLOOD_STATUS))
|
|
|
|
return;
|
|
|
|
|
|
|
|
con_printf_no_log = 1;
|
|
|
|
SV_BeginRedirect (RD_PACKET);
|
2001-11-04 07:50:39 +00:00
|
|
|
SV_Printf ("%s\n", Info_MakeString (svs.info, 0));
|
2001-02-19 21:15:25 +00:00
|
|
|
for (i = 0; i < MAX_CLIENTS; i++) {
|
|
|
|
cl = &svs.clients[i];
|
2003-03-03 17:08:45 +00:00
|
|
|
if ((cl->state >= cs_connected) && !cl->spectator) {
|
2001-02-19 21:15:25 +00:00
|
|
|
top = atoi (Info_ValueForKey (cl->userinfo, "topcolor"));
|
|
|
|
bottom = atoi (Info_ValueForKey (cl->userinfo, "bottomcolor"));
|
|
|
|
top = (top < 0) ? 0 : ((top > 13) ? 13 : top);
|
|
|
|
bottom = (bottom < 0) ? 0 : ((bottom > 13) ? 13 : bottom);
|
|
|
|
ping = SV_CalcPing (cl);
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("%i %i %i %i \"%s\" \"%s\" %i %i\n", cl->userid,
|
2001-02-19 21:15:25 +00:00
|
|
|
cl->old_frags,
|
|
|
|
(int) (realtime - cl->connection_started) / 60, ping,
|
|
|
|
cl->name, Info_ValueForKey (cl->userinfo, "skin"), top,
|
|
|
|
bottom);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SV_EndRedirect ();
|
|
|
|
con_printf_no_log = 0;
|
|
|
|
}
|
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
/* SV_CheckLog */
|
2005-05-09 22:33:21 +00:00
|
|
|
#define LOG_HIGHWATER (MAX_DATAGRAM - 100)
|
2001-02-19 21:15:25 +00:00
|
|
|
#define LOG_FLUSH 10*60
|
2001-08-28 02:43:24 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_CheckLog (void)
|
|
|
|
{
|
|
|
|
sizebuf_t *sz;
|
|
|
|
|
|
|
|
sz = &svs.log[svs.logsequence & 1];
|
|
|
|
|
2002-06-20 16:15:27 +00:00
|
|
|
// bump sequence if allmost full, or ten minutes have passed and
|
2001-02-19 21:15:25 +00:00
|
|
|
// there is something still sitting there
|
|
|
|
if (sz->cursize > LOG_HIGHWATER
|
2002-06-20 16:15:27 +00:00
|
|
|
|| (realtime - svs.logtime > LOG_FLUSH && sz->cursize)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
// swap buffers and bump sequence
|
2002-06-08 23:29:19 +00:00
|
|
|
svs.logtime = realtime;
|
2001-02-19 21:15:25 +00:00
|
|
|
svs.logsequence++;
|
|
|
|
sz = &svs.log[svs.logsequence & 1];
|
|
|
|
sz->cursize = 0;
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("beginning fraglog sequence %i\n", svs.logsequence);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
2002-06-20 16:15:27 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
SVC_Log
|
|
|
|
|
|
|
|
Responds with all the logged frags for ranking programs.
|
|
|
|
If a sequence number is passed as a parameter and it is
|
|
|
|
the same as the current sequence, an A2A_NACK will be returned
|
|
|
|
instead of the data.
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SVC_Log (void)
|
|
|
|
{
|
|
|
|
char data[MAX_DATAGRAM + 64];
|
2001-08-28 02:43:24 +00:00
|
|
|
int seq;
|
2001-02-19 21:15:25 +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 (!sv_allow_log)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
if (CheckForFlood (FLOOD_LOG))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (Cmd_Argc () == 2)
|
|
|
|
seq = atoi (Cmd_Argv (1));
|
|
|
|
else
|
|
|
|
seq = -1;
|
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
if (seq == svs.logsequence - 1 || !sv_fraglogfile) {
|
|
|
|
// they already have this data, or we aren't logging frags
|
2001-02-19 21:15:25 +00:00
|
|
|
data[0] = A2A_NACK;
|
2003-02-10 21:41:22 +00:00
|
|
|
Netchan_SendPacket (1, data, net_from);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "sending log %i to %s\n", svs.logsequence - 1,
|
2010-11-23 05:09:30 +00:00
|
|
|
NET_AdrToString (net_from));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
// snprintf (data, sizeof (data), "stdlog %i\n", svs.logsequence - 1);
|
|
|
|
// strncat (data, (char *) svs.log_buf[((svs.logsequence - 1) & 1)],
|
|
|
|
// sizeof (data) - strlen (data));
|
2001-02-19 21:15:25 +00:00
|
|
|
snprintf (data, sizeof (data), "stdlog %i\n%s",
|
|
|
|
svs.logsequence - 1,
|
|
|
|
(char *) svs.log_buf[((svs.logsequence - 1) & 1)]);
|
|
|
|
|
2003-02-10 21:41:22 +00:00
|
|
|
Netchan_SendPacket (strlen (data) + 1, data, net_from);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SVC_Ping
|
|
|
|
|
|
|
|
Just responds with an acknowledgement
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SVC_Ping (void)
|
|
|
|
{
|
|
|
|
char data;
|
|
|
|
|
[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 (!sv_allow_ping)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
if (CheckForFlood (FLOOD_PING))
|
|
|
|
return;
|
|
|
|
|
|
|
|
data = A2A_ACK;
|
|
|
|
|
2003-02-10 21:41:22 +00:00
|
|
|
Netchan_SendPacket (1, &data, net_from);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SVC_GetChallenge
|
|
|
|
|
|
|
|
Returns a challenge number that can be used
|
|
|
|
in a subsequent client_connect command.
|
|
|
|
We do this to prevent denial of service attacks that
|
|
|
|
flood the server with invalid connection IPs. With a
|
|
|
|
challenge, they must give a valid IP address.
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SVC_GetChallenge (void)
|
|
|
|
{
|
2001-08-28 02:43:24 +00:00
|
|
|
int oldest, oldestTime, i;
|
2003-01-06 18:28:13 +00:00
|
|
|
const char *extended = "";
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
oldest = 0;
|
|
|
|
oldestTime = 0x7fffffff;
|
|
|
|
|
|
|
|
// see if we already have a challenge for this ip
|
|
|
|
for (i = 0; i < MAX_CHALLENGES; i++) {
|
|
|
|
if (NET_CompareBaseAdr (net_from, svs.challenges[i].adr))
|
|
|
|
break;
|
|
|
|
if (svs.challenges[i].time < oldestTime) {
|
|
|
|
oldestTime = svs.challenges[i].time;
|
|
|
|
oldest = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == MAX_CHALLENGES) {
|
|
|
|
// overwrite the oldest
|
|
|
|
svs.challenges[oldest].challenge = (rand () << 16) ^ rand ();
|
|
|
|
svs.challenges[oldest].adr = net_from;
|
|
|
|
svs.challenges[oldest].time = realtime;
|
|
|
|
i = oldest;
|
|
|
|
}
|
2001-09-11 03:50:24 +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 (sv_extensions) {
|
2007-03-21 11:53:56 +00:00
|
|
|
extended = " QF qtv EXT";
|
2001-09-11 03:50:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// send it to the client
|
2021-12-27 08:54:58 +00:00
|
|
|
SV_OutOfBandPrint (net_from, "%c%i%s", S2C_CHALLENGE,
|
|
|
|
svs.challenges[i].challenge, extended);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-03-04 03:35:12 +00:00
|
|
|
client_t *
|
|
|
|
SV_AllocClient (int spectator, int server)
|
2003-03-04 01:36:30 +00:00
|
|
|
{
|
|
|
|
client_t *cl;
|
2003-03-06 19:06:10 +00:00
|
|
|
int i, clients, spectators, free, bots;
|
2003-03-04 03:35:12 +00:00
|
|
|
static int userid;
|
2003-03-04 01:36:30 +00:00
|
|
|
|
|
|
|
// count up the clients and spectators
|
|
|
|
clients = 0;
|
|
|
|
spectators = 0;
|
|
|
|
free = 0;
|
2003-03-06 19:06:10 +00:00
|
|
|
bots = 0;
|
2003-03-04 01:36:30 +00:00
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
|
|
|
if (cl->state == cs_free)
|
|
|
|
free++;
|
2003-03-06 19:06:10 +00:00
|
|
|
else if (cl->state == cs_server)
|
|
|
|
bots++;
|
2003-03-04 01:36:30 +00:00
|
|
|
else if (cl->spectator)
|
|
|
|
spectators++;
|
|
|
|
else
|
|
|
|
clients++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if at server limits, refuse connection
|
2003-03-04 03:35:12 +00:00
|
|
|
if (!free ||
|
[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
|
|
|
(!server && ((spectator && spectators >= maxspectators)
|
|
|
|
|| (!spectator && clients >= maxclients)))) {
|
2003-03-04 01:36:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// find a client slot
|
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
|
|
|
if (cl->state == cs_free) {
|
2003-03-04 03:35:12 +00:00
|
|
|
svs.num_clients++;
|
2003-03-04 16:00:57 +00:00
|
|
|
memset (cl, 0, sizeof (client_t));
|
2003-03-04 03:35:12 +00:00
|
|
|
cl->userid = userid++; // so every client gets a unique id
|
2005-04-30 03:59:23 +00:00
|
|
|
if (userid < 0) // reserve -ve userids for special purposes
|
|
|
|
userid = 0;
|
2003-03-04 16:00:57 +00:00
|
|
|
cl->edict = EDICT_NUM (&sv_pr_state, (cl - svs.clients) + 1);
|
2003-03-04 01:36:30 +00:00
|
|
|
return cl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SV_Printf ("WARNING: miscounted available clients\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
SVC_DirectConnect
|
|
|
|
|
|
|
|
A connection request that did not come from the master
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SVC_DirectConnect (void)
|
|
|
|
{
|
2001-12-03 21:06:57 +00:00
|
|
|
info_t *userinfo = 0;
|
2001-08-28 02:43:24 +00:00
|
|
|
const char *s;
|
2001-02-19 21:15:25 +00:00
|
|
|
client_t *cl, *newcl;
|
2011-07-23 08:51:07 +00:00
|
|
|
int challenge, version, i, qtv = 0;
|
2011-07-23 12:39:13 +00:00
|
|
|
int qport;
|
2001-08-28 02:43:24 +00:00
|
|
|
netadr_t adr;
|
2023-06-13 09:06:11 +00:00
|
|
|
bool spectator;
|
2005-04-30 08:45:17 +00:00
|
|
|
client_frame_t *frames;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (CheckForFlood (FLOOD_CONNECT))
|
|
|
|
return;
|
|
|
|
|
2004-03-01 23:45:59 +00:00
|
|
|
s = Cmd_Argv (1);
|
|
|
|
if (!strcmp (s, "qtv")) {
|
2004-03-05 23:42:15 +00:00
|
|
|
qtv = 1;
|
|
|
|
} else {
|
|
|
|
version = atoi (s);
|
|
|
|
if (version != PROTOCOL_VERSION) {
|
2021-12-27 08:54:58 +00:00
|
|
|
SV_OutOfBandPrint (net_from, "%c\nServer is version %s.\n",
|
|
|
|
A2C_PRINT, QW_VERSION);
|
2004-03-05 23:42:15 +00:00
|
|
|
SV_Printf ("* rejected connect from version %i\n", version);
|
|
|
|
return;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
qport = atoi (Cmd_Argv (2));
|
|
|
|
|
|
|
|
challenge = atoi (Cmd_Argv (3));
|
|
|
|
|
2001-12-03 21:06:57 +00:00
|
|
|
if (strlen (Cmd_Argv (4)) < MAX_INFO_STRING)
|
2003-02-19 17:39:21 +00:00
|
|
|
userinfo = Info_ParseString (Cmd_Argv (4), 1023,
|
[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
|
|
|
|
2001-05-22 12:00:45 +00:00
|
|
|
// Validate the userinfo string.
|
2001-11-04 07:50:39 +00:00
|
|
|
if (!userinfo) {
|
2021-12-27 08:54:58 +00:00
|
|
|
SV_OutOfBandPrint (net_from, "%c\nInvalid userinfo string.\n",
|
|
|
|
A2C_PRINT);
|
2001-05-22 12:00:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// see if the challenge is valid
|
|
|
|
for (i = 0; i < MAX_CHALLENGES; i++) {
|
|
|
|
if (NET_CompareBaseAdr (net_from, svs.challenges[i].adr)) {
|
|
|
|
if (challenge == svs.challenges[i].challenge)
|
|
|
|
break; // good
|
2021-12-27 08:54:58 +00:00
|
|
|
SV_OutOfBandPrint (net_from, "%c\nBad challenge.\n", A2C_PRINT);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == MAX_CHALLENGES) {
|
2021-12-27 08:54:58 +00:00
|
|
|
SV_OutOfBandPrint (net_from, "%c\nNo challenge for address.\n",
|
|
|
|
A2C_PRINT);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-05 23:42:15 +00:00
|
|
|
if (qtv) {
|
|
|
|
SV_qtvConnect (qport, userinfo);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
s = Info_ValueForKey (userinfo, "*qf_version");
|
[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 ((!s[0]) || sv_minqfversion[0]) { // kick old clients?
|
|
|
|
if (ver_compare (s, sv_minqfversion) < 0) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("%s: Version %s is less than minimum version %s.\n",
|
2001-08-28 02:43:24 +00:00
|
|
|
NET_AdrToString (net_from), s,
|
[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_minqfversion);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-12-27 08:54:58 +00:00
|
|
|
SV_OutOfBandPrint (net_from, "%c\nserver requires QuakeForge "
|
|
|
|
"v%s or greater. Get it from "
|
|
|
|
"http://www.quakeforge.net/\n", A2C_PRINT,
|
[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_minqfversion);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// check for password or spectator_password
|
|
|
|
s = Info_ValueForKey (userinfo, "spectator");
|
|
|
|
if (s[0] && strcmp (s, "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
|
|
|
if (spectator_password[0] &&
|
|
|
|
!strcaseequal (spectator_password, "none") &&
|
|
|
|
!strequal (spectator_password, s)) { // failed
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("%s: spectator password failed\n",
|
2001-02-19 21:15:25 +00:00
|
|
|
NET_AdrToString (net_from));
|
2021-12-27 08:54:58 +00:00
|
|
|
SV_OutOfBandPrint (net_from,
|
|
|
|
"%c\nrequires a spectator password\n\n",
|
|
|
|
A2C_PRINT);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
Info_RemoveKey (userinfo, "spectator"); // remove passwd
|
2001-11-04 07:50:39 +00:00
|
|
|
Info_SetValueForStarKey (userinfo, "*spectator", "1",
|
[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
|
|
|
spectator = true;
|
|
|
|
} else {
|
|
|
|
s = Info_ValueForKey (userinfo, "password");
|
[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 (password[0]
|
|
|
|
&& !strcaseequal (password, "none")
|
|
|
|
&& !strequal (password, s)) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("%s:password failed\n", NET_AdrToString (net_from));
|
2021-12-27 08:54:58 +00:00
|
|
|
SV_OutOfBandPrint (net_from,
|
|
|
|
"%c\nserver requires a password\n\n",
|
|
|
|
A2C_PRINT);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
spectator = false;
|
|
|
|
Info_RemoveKey (userinfo, "password"); // remove passwd
|
|
|
|
}
|
|
|
|
|
|
|
|
adr = net_from;
|
|
|
|
|
2002-06-18 21:41:24 +00:00
|
|
|
// if there is already a slot for this ip, drop it
|
2001-02-19 21:15:25 +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-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
if (NET_CompareBaseAdr (adr, cl->netchan.remote_address)
|
|
|
|
&& (cl->netchan.qport == qport
|
|
|
|
|| adr.port == cl->netchan.remote_address.port)) {
|
|
|
|
if (cl->state == cs_connected) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("%s:dup connect\n", NET_AdrToString (adr));
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("%s:reconnect\n", NET_AdrToString (adr));
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_DropClient (cl);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-03-04 03:35:12 +00:00
|
|
|
if (!(newcl = SV_AllocClient (spectator, 0))) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("%s:full connect\n", NET_AdrToString (adr));
|
2021-12-27 08:54:58 +00:00
|
|
|
SV_OutOfBandPrint (adr, "%c\nserver is full\n\n", A2C_PRINT);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-03-04 16:00:57 +00:00
|
|
|
newcl->userinfo = userinfo;
|
2001-02-19 21:15:25 +00:00
|
|
|
// build a new connection
|
|
|
|
// accept the new client
|
|
|
|
// this is the only place a client_t is ever initialized
|
2005-04-30 08:45:17 +00:00
|
|
|
frames = newcl->delta.frames;
|
2002-10-04 02:29:03 +00:00
|
|
|
for (i = 0; i < UPDATE_BACKUP; i++) {
|
2005-04-30 08:45:17 +00:00
|
|
|
frames[i].entities.entities = cl_entities[newcl-svs.clients][i];
|
2002-10-04 02:29:03 +00:00
|
|
|
memset (cl_entities[newcl-svs.clients][i], 0,
|
|
|
|
sizeof (cl_entities[newcl-svs.clients][i]));
|
|
|
|
}
|
2005-04-30 08:45:17 +00:00
|
|
|
newcl->delta.client = newcl;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-12-27 08:54:58 +00:00
|
|
|
SV_OutOfBandPrint (adr, "%c", S2C_CONNECTION);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2011-07-23 08:51:07 +00:00
|
|
|
Netchan_Setup (&newcl->netchan, adr, qport, NC_QPORT_READ);
|
2004-02-22 05:40:08 +00:00
|
|
|
newcl->backbuf.netchan = &newcl->netchan;
|
|
|
|
newcl->backbuf.name = newcl->name;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
newcl->state = cs_connected;
|
2001-08-01 00:38:16 +00:00
|
|
|
newcl->prespawned = false;
|
|
|
|
newcl->spawned = false;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
newcl->datagram.allowoverflow = true;
|
|
|
|
newcl->datagram.data = newcl->datagram_buf;
|
2007-05-07 14:58:53 +00:00
|
|
|
newcl->datagram.maxsize = sizeof (newcl->datagram_buf);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
// spectator mode can be set ONLY at join time
|
2001-02-19 21:15:25 +00:00
|
|
|
newcl->spectator = spectator;
|
|
|
|
|
|
|
|
// parse some info from the info strings
|
|
|
|
SV_ExtractFromUserinfo (newcl);
|
|
|
|
|
|
|
|
// JACK: Init the floodprot stuff.
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
newcl->whensaid[i] = 0.0;
|
|
|
|
newcl->whensaidhead = 0;
|
2003-03-21 21:25:44 +00:00
|
|
|
newcl->lockedtill = SV_RestorePenaltyFilter (newcl, ft_mute);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// call the progs to get default spawn parms for the new client
|
2001-03-01 08:34:30 +00:00
|
|
|
PR_ExecuteProgram (&sv_pr_state, sv_funcs.SetNewParms);
|
2001-02-19 21:15:25 +00:00
|
|
|
for (i = 0; i < NUM_SPAWN_PARMS; i++)
|
2001-03-01 08:34:30 +00:00
|
|
|
newcl->spawn_parms[i] = sv_globals.parms[i];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (newcl->spectator)
|
2001-09-20 19:50:24 +00:00
|
|
|
SV_Printf ("Spectator %s (%s) connected\n", newcl->name,
|
|
|
|
NET_AdrToString (adr));
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-10-27 22:33:42 +00:00
|
|
|
SV_Printf ("Client %s (%s) connected\n", newcl->name,
|
2001-09-20 19:50:24 +00:00
|
|
|
NET_AdrToString (adr));
|
2001-02-19 21:15:25 +00:00
|
|
|
newcl->sendinfo = true;
|
|
|
|
|
|
|
|
// QuakeForge stuff.
|
|
|
|
newcl->msecs = 0;
|
|
|
|
newcl->msec_cheating = 0;
|
|
|
|
newcl->last_check = -1;
|
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
newcl->cuff_time = SV_RestorePenaltyFilter (newcl, ft_cuff);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static int
|
[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
|
|
|
Rcon_Validate (const char *pass)
|
2001-02-19 21:15:25 +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 (!strlen (pass))
|
2001-02-19 21:15:25 +00:00
|
|
|
return 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
|
|
|
if (strcmp (Cmd_Argv (1), pass))
|
2001-02-19 21:15:25 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static char *
|
2001-07-09 23:33:35 +00:00
|
|
|
Name_of_sender (void)
|
|
|
|
{
|
|
|
|
client_t *cl;
|
2001-08-28 02:43:24 +00:00
|
|
|
int i;
|
2001-07-09 23:33:35 +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-09 23:33:35 +00:00
|
|
|
continue;
|
2003-03-21 21:25:44 +00:00
|
|
|
if (!NET_CompareBaseAdr (net_from, cl->netchan.remote_address))
|
2001-07-09 23:33:35 +00:00
|
|
|
continue;
|
|
|
|
if (cl->netchan.remote_address.port != net_from.port)
|
|
|
|
continue;
|
|
|
|
return cl->name;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-08-28 02:43:24 +00:00
|
|
|
SVC_RemoteCommand
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
A client issued an rcon command.
|
|
|
|
Shift down the remaining args
|
|
|
|
Redirect all printfs
|
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
|
|
|
SVC_RemoteCommand (void)
|
|
|
|
{
|
2001-09-22 02:24:46 +00:00
|
|
|
const char *command;
|
2001-07-09 23:33:35 +00:00
|
|
|
char *name;
|
2023-06-13 09:06:11 +00:00
|
|
|
bool admin_cmd = false;
|
|
|
|
bool do_cmd = false;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (CheckForFlood (FLOOD_RCON))
|
|
|
|
return;
|
|
|
|
|
2001-07-09 23:33:35 +00:00
|
|
|
if (Rcon_Validate (rcon_password)) {
|
|
|
|
do_cmd = true;
|
|
|
|
} else if (Rcon_Validate (admin_password)) {
|
|
|
|
admin_cmd = true;
|
2003-03-21 21:25:44 +00:00
|
|
|
if (strcmp (Cmd_Argv (2), "say") == 0
|
|
|
|
|| strcmp (Cmd_Argv (2), "kick") == 0
|
|
|
|
|| strcmp (Cmd_Argv (2), "ban") == 0
|
2003-04-29 21:45:57 +00:00
|
|
|
|| strcmp (Cmd_Argv (2), "map") == 0
|
2003-03-21 21:25:44 +00:00
|
|
|
|| strcmp (Cmd_Argv (2), "mute") == 0
|
|
|
|
|| strcmp (Cmd_Argv (2), "cuff") == 0
|
|
|
|
|| strcmp (Cmd_Argv (2), "exec") == 0
|
|
|
|
|| strcmp (Cmd_Argv (2), "addip") == 0
|
|
|
|
|| strcmp (Cmd_Argv (2), "listip") == 0
|
|
|
|
|| strcmp (Cmd_Argv (2), "writeip") == 0
|
|
|
|
|| strcmp (Cmd_Argv (2), "removeip") == 0)
|
2001-07-09 23:33:35 +00:00
|
|
|
do_cmd = true;
|
|
|
|
}
|
2003-03-21 21:25:44 +00:00
|
|
|
if ((name = Name_of_sender ())) { // log issuer
|
2001-07-09 23:33:35 +00:00
|
|
|
if (do_cmd && admin_cmd) {
|
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "Admin %s issued %s command:\n",
|
2003-03-21 21:25:44 +00:00
|
|
|
name, Cmd_Argv (2));
|
2001-07-09 23:33:35 +00:00
|
|
|
} else if (admin_cmd) {
|
2003-03-21 21:25:44 +00:00
|
|
|
SV_Printf ("Admin %s issued %s command:\n", name, Cmd_Argv (2));
|
2001-07-09 23:33:35 +00:00
|
|
|
} else {
|
2003-03-21 21:25:44 +00:00
|
|
|
SV_Printf ("User %s %s rcon command:\n", name,
|
|
|
|
do_cmd ? "issued" : "attempted");
|
2001-07-09 23:33:35 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2001-07-09 23:33:35 +00:00
|
|
|
if (do_cmd) {
|
2001-09-22 02:24:46 +00:00
|
|
|
command = Cmd_Args (2);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Rcon from %s:\n\trcon (hidden) %s\n",
|
2001-09-22 02:24:46 +00:00
|
|
|
NET_AdrToString (net_from), command);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
SV_BeginRedirect (RD_PACKET);
|
2001-07-09 23:33:35 +00:00
|
|
|
if (name)
|
|
|
|
rcon_from_user = true;
|
2001-09-22 02:24:46 +00:00
|
|
|
Cmd_ExecuteString (command, src_command);
|
2001-07-09 23:33:35 +00:00
|
|
|
rcon_from_user = false;
|
|
|
|
} else {
|
2002-10-06 03:54:54 +00:00
|
|
|
SV_Printf ("Bad rcon from %s:\n\t rcon (hidden) %s\n",
|
|
|
|
NET_AdrToString (net_from), Cmd_Args (2));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-07-09 23:33:35 +00:00
|
|
|
SV_BeginRedirect (RD_PACKET);
|
|
|
|
if (admin_cmd) {
|
2003-03-21 21:25:44 +00:00
|
|
|
SV_Printf ("Command not valid with admin password.\n");
|
2001-07-09 23:33:35 +00:00
|
|
|
} else {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Bad rcon_password.\n");
|
2001-07-09 23:33:35 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SV_EndRedirect ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-28 02:43:24 +00:00
|
|
|
SV_ConnectionlessPacket
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
A connectionless packet has four leading 0xff
|
|
|
|
characters to distinguish it from a game channel.
|
|
|
|
Clients that are in the game can still send
|
|
|
|
connectionless packets.
|
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_ConnectionlessPacket (void)
|
|
|
|
{
|
2001-08-28 02:43:24 +00:00
|
|
|
const char *c, *s;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-23 23:16:13 +00:00
|
|
|
MSG_BeginReading (net_message);
|
|
|
|
MSG_ReadLong (net_message); // skip the -1 marker
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-10-18 06:23:26 +00:00
|
|
|
s = MSG_ReadString (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
COM_TokenizeString (s, sv_args);
|
|
|
|
cmd_args = sv_args;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
c = sv_args->argv[0]->str;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (!strcmp (c, "ping")
|
|
|
|
|| (c[0] == A2A_PING && (c[1] == 0 || c[1] == '\n'))) {
|
|
|
|
SVC_Ping ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (c[0] == A2A_ACK && (c[1] == 0 || c[1] == '\n')) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("A2A_ACK from %s\n", NET_AdrToString (net_from));
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
} else if (!strcmp (c, "status")) {
|
|
|
|
SVC_Status ();
|
|
|
|
return;
|
|
|
|
} else if (!strcmp (c, "log")) {
|
|
|
|
SVC_Log ();
|
|
|
|
return;
|
|
|
|
} else if (!strcmp (c, "connect")) {
|
|
|
|
SVC_DirectConnect ();
|
|
|
|
return;
|
|
|
|
} else if (!strcmp (c, "getchallenge")) {
|
|
|
|
SVC_GetChallenge ();
|
|
|
|
return;
|
|
|
|
} else if (!strcmp (c, "rcon"))
|
|
|
|
SVC_RemoteCommand ();
|
|
|
|
else
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("bad connectionless packet from %s:\n%s\n",
|
2001-02-19 21:15:25 +00:00
|
|
|
NET_AdrToString (net_from), s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
PACKET FILTERING
|
|
|
|
|
|
|
|
You can add or remove addresses from the filter list with:
|
|
|
|
|
|
|
|
addip <ip>
|
|
|
|
removeip <ip>
|
|
|
|
|
|
|
|
The ip address is specified in dot format, and any unspecified digits
|
|
|
|
will match any value, so you can specify an entire class C network with
|
|
|
|
"addip 192.246.40".
|
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
Removeip will remove only an address specified exactly the same way.
|
2001-02-19 21:15:25 +00:00
|
|
|
You cannot addip a subnet, then removeip a single host.
|
|
|
|
|
|
|
|
listip
|
|
|
|
Prints the current list of filters.
|
|
|
|
|
|
|
|
writeip
|
|
|
|
Dumps "addip <ip>" commands to listip.cfg so it can be execed at a
|
|
|
|
later date. The filter lists are not saved and restored by default,
|
|
|
|
because I beleive it would cause too much confusion.
|
|
|
|
|
|
|
|
filterban <0 or 1>
|
|
|
|
|
|
|
|
If 1 (the default), then ip addresses matching the current list will be
|
|
|
|
prohibited from entering the game. This is the default setting.
|
|
|
|
|
|
|
|
If 0, then only addresses matching the list will be allowed. This lets
|
2010-01-13 06:42:26 +00:00
|
|
|
you easily set up a private game, or a game that allows only players
|
2001-02-19 21:15:25 +00:00
|
|
|
from your local network.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct {
|
2001-09-16 15:40:21 +00:00
|
|
|
int mask;
|
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
byte ip[16];
|
|
|
|
#else
|
|
|
|
byte ip[4];
|
|
|
|
#endif
|
|
|
|
double time;
|
|
|
|
filtertype_t type;
|
2001-02-19 21:15:25 +00:00
|
|
|
} ipfilter_t;
|
|
|
|
|
|
|
|
#define MAX_IPFILTERS 1024
|
|
|
|
|
[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 filterban;
|
|
|
|
static cvar_t filterban_cvar = {
|
|
|
|
.name = "filterban",
|
|
|
|
.description =
|
|
|
|
"Determines the rules for the IP list 0 Only IP addresses on the Ban "
|
|
|
|
"list will be allowed onto the server, 1 Only IP addresses NOT on the "
|
|
|
|
"Ban list will be allowed onto the server",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &filterban },
|
|
|
|
};
|
|
|
|
int sv_filter_automask;
|
|
|
|
static cvar_t sv_filter_automask_cvar = {
|
|
|
|
.name = "sv_filter_automask",
|
|
|
|
.description =
|
|
|
|
"Automatically determine the mask length when it is not explicitely "
|
|
|
|
"given. e.g. \"addip 1.2.0.0\" would be the same as \"addip "
|
|
|
|
"1.2.0.0/16\"",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &sv_filter_automask },
|
|
|
|
};
|
2001-08-28 02:43:24 +00:00
|
|
|
int numipfilters;
|
|
|
|
ipfilter_t ipfilters[MAX_IPFILTERS];
|
2001-09-16 15:40:21 +00:00
|
|
|
unsigned int ipmasks[33]; // network byte order
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-09-16 15:40:21 +00:00
|
|
|
SV_GenerateIPMasks (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-09-16 15:40:21 +00:00
|
|
|
int i;
|
2005-10-23 13:19:21 +00:00
|
|
|
unsigned int j = 0xFFFFFFFF;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
for (i = 32; i >= 0; i--) {
|
|
|
|
ipmasks[i] = htonl (j);
|
|
|
|
j = j << 1;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-09-16 15:40:21 +00:00
|
|
|
}
|
|
|
|
|
2001-09-17 06:10:39 +00:00
|
|
|
// Note: this function is non-reentrant and not threadsafe
|
2003-01-06 18:28:13 +00:00
|
|
|
static const char *
|
2001-09-17 06:10:39 +00:00
|
|
|
SV_PrintIP (byte *ip)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
static char buf[INET6_ADDRSTRLEN];
|
|
|
|
if (!inet_ntop (AF_INET6, ip, buf, INET6_ADDRSTRLEN))
|
|
|
|
#else
|
2004-01-20 03:47:27 +00:00
|
|
|
# ifdef _WIN32
|
2001-09-25 06:18:30 +00:00
|
|
|
static char buf[16];
|
|
|
|
strcpy (buf, inet_ntoa (*(struct in_addr*)ip));
|
|
|
|
if (0)
|
|
|
|
# else
|
2001-09-17 06:10:39 +00:00
|
|
|
static char buf[INET_ADDRSTRLEN];
|
|
|
|
if (!inet_ntop (AF_INET, ip, buf, INET_ADDRSTRLEN))
|
2001-09-25 06:18:30 +00:00
|
|
|
# endif
|
2001-09-17 06:10:39 +00:00
|
|
|
#endif
|
2002-05-14 06:12:29 +00:00
|
|
|
Sys_Error ("SV_CleanIPList: inet_ntop_failed. wtf?");
|
2001-09-17 06:10:39 +00:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
static inline void
|
|
|
|
SV_MaskIPTrim (byte *ip, int mask)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
int intcount = 4;
|
|
|
|
#else
|
|
|
|
int intcount = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (i = 0; i < intcount; i++) {
|
|
|
|
((unsigned int *)ip)[i] &= ipmasks[mask > 32 ? 32 : mask];
|
|
|
|
if ((mask -= 32) < 0)
|
|
|
|
mask = 0;
|
|
|
|
}
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
// assumes b has already been masked
|
2023-06-13 09:06:11 +00:00
|
|
|
static inline __attribute__((pure)) bool
|
2001-09-16 15:40:21 +00:00
|
|
|
SV_MaskIPCompare (byte *a, byte *b, int mask)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
int intcount = 4;
|
|
|
|
#else
|
|
|
|
int intcount = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (i = 0; i < intcount; i++) {
|
2009-12-19 10:54:23 +00:00
|
|
|
unsigned int x, y;
|
|
|
|
memcpy (&x, a + i * 4, 4);
|
|
|
|
memcpy (&y, b + i * 4, 4);
|
|
|
|
if ((x & ipmasks[mask > 32 ? 32 : mask]) != y)
|
2001-09-16 15:40:21 +00:00
|
|
|
return false;
|
|
|
|
if ((mask -= 32) < 0)
|
|
|
|
mask = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
static inline bool
|
2001-09-16 15:40:21 +00:00
|
|
|
SV_IPCompare (byte *a, byte *b)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
int intcount = 4;
|
|
|
|
#else
|
|
|
|
int intcount = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (i = 0; i < intcount; i++)
|
|
|
|
if (((unsigned int *)a)[i] != ((unsigned int *)b)[i])
|
2001-02-19 21:15:25 +00:00
|
|
|
return false;
|
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
SV_IPCopy (byte *dest, byte *src)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
int intcount = 4;
|
|
|
|
#else
|
|
|
|
int intcount = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (i = 0; i < intcount; i++)
|
|
|
|
((unsigned int *)dest)[i] = ((unsigned int *)src)[i];
|
|
|
|
}
|
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool
|
2001-09-16 15:40:21 +00:00
|
|
|
SV_StringToFilter (const char *address, ipfilter_t *f)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_IPV6
|
2007-03-22 23:20:57 +00:00
|
|
|
byte b[16] = {0};
|
2001-09-16 15:40:21 +00:00
|
|
|
#else
|
2007-03-22 23:20:57 +00:00
|
|
|
byte b[4] = {0};
|
2001-09-16 15:40:21 +00:00
|
|
|
#endif
|
2001-09-17 05:08:13 +00:00
|
|
|
int mask = 0;
|
2003-04-17 00:01:48 +00:00
|
|
|
unsigned int i;
|
2001-09-16 15:40:21 +00:00
|
|
|
char *s;
|
|
|
|
char *slash;
|
2001-09-17 05:08:13 +00:00
|
|
|
char *c;
|
2001-09-16 15:40:21 +00:00
|
|
|
|
|
|
|
s = strdup (address);
|
|
|
|
if (!s)
|
2002-05-14 06:12:29 +00:00
|
|
|
Sys_Error ("SV_StringToFilter: memory allocation failure");
|
2001-09-16 15:40:21 +00:00
|
|
|
|
2001-09-17 05:08:13 +00:00
|
|
|
// Parse out the mask (the /8 part)
|
2001-09-16 15:40:21 +00:00
|
|
|
if ((slash = strchr (s, '/'))) {
|
|
|
|
char *endptr;
|
|
|
|
*slash = '\0';
|
|
|
|
slash++;
|
2001-09-17 06:10:39 +00:00
|
|
|
if (*slash < '0' || *slash > '9' || strchr (slash, '/'))
|
2001-09-16 15:40:21 +00:00
|
|
|
goto bad_address;
|
|
|
|
mask = strtol (slash, &endptr, 10);
|
2001-09-17 05:41:17 +00:00
|
|
|
if (!*slash || *endptr)
|
2001-09-16 15:40:21 +00:00
|
|
|
goto bad_address;
|
|
|
|
} else
|
|
|
|
mask = -1;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-17 05:08:13 +00:00
|
|
|
// parse the ip for ipv6
|
2001-09-16 15:40:21 +00:00
|
|
|
#ifdef HAVE_IPV6
|
2001-09-17 05:08:13 +00:00
|
|
|
if (inet_pton (AF_INET6, s, b) != 1) {
|
2001-09-17 07:31:15 +00:00
|
|
|
b[10] = 0xFF; // Prefix bytes for hosts that don't support ipv6
|
|
|
|
b[11] = 0xFF; // (see RFC 2373, section 2.5.4)
|
|
|
|
i = 12;
|
|
|
|
#else
|
|
|
|
i = 0;
|
2001-09-16 15:40:21 +00:00
|
|
|
#endif
|
2001-09-17 05:08:13 +00:00
|
|
|
c = s;
|
|
|
|
|
|
|
|
// parse for ipv4, as dotted quad, only we have implicit trailing segments
|
|
|
|
do {
|
|
|
|
int j;
|
|
|
|
if (*c == '.')
|
|
|
|
c++;
|
|
|
|
j = strtol (c, &c, 10);
|
2001-09-17 06:10:39 +00:00
|
|
|
if (j < 0 || j > 255 || i >= sizeof (b))
|
2001-09-17 05:08:13 +00:00
|
|
|
goto bad_address;
|
|
|
|
b[i++] = j;
|
|
|
|
} while (*c == '.');
|
|
|
|
if (*c)
|
|
|
|
goto bad_address;
|
|
|
|
|
|
|
|
// change trailing 0 segments to be a mask, eg 1.2.0.0 gives a /16 mask
|
2001-09-16 15:40:21 +00:00
|
|
|
if (mask == -1) {
|
[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 (sv_filter_automask) {
|
2001-09-20 06:51:25 +00:00
|
|
|
mask = sizeof (b) * 8;
|
2012-12-21 12:53:13 +00:00
|
|
|
i = sizeof (b);
|
|
|
|
while (i > 0 && !b[i - 1]) {
|
2001-09-20 06:51:25 +00:00
|
|
|
mask -= 8;
|
2001-09-19 12:58:02 +00:00
|
|
|
i--;
|
|
|
|
}
|
2001-09-20 06:51:25 +00:00
|
|
|
} else
|
|
|
|
mask = 0;
|
2001-09-16 15:40:21 +00:00
|
|
|
}
|
|
|
|
#ifdef HAVE_IPV6
|
2002-10-23 22:55:28 +00:00
|
|
|
} else {
|
|
|
|
mask = 128;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-09-17 05:08:13 +00:00
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
if (mask > 128)
|
|
|
|
#else
|
|
|
|
if (mask > 32)
|
|
|
|
#endif
|
|
|
|
goto bad_address;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-17 05:08:13 +00:00
|
|
|
// incase they did 1.2.3.4/16, change it to 1.2.0.0 for easier comparison
|
2001-09-16 15:40:21 +00:00
|
|
|
SV_MaskIPTrim (b, mask);
|
2001-09-17 05:08:13 +00:00
|
|
|
|
|
|
|
// yada :)
|
2001-09-16 15:40:21 +00:00
|
|
|
f->mask = mask;
|
|
|
|
SV_IPCopy (f->ip, b);
|
|
|
|
|
|
|
|
free (s);
|
2001-02-19 21:15:25 +00:00
|
|
|
return true;
|
2001-09-16 15:40:21 +00:00
|
|
|
|
|
|
|
bad_address:
|
|
|
|
SV_Printf ("Bad filter address: %s\n", address);
|
|
|
|
free (s);
|
|
|
|
return false;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-09-16 15:40:21 +00:00
|
|
|
SV_RemoveIPFilter (int i)
|
2001-09-09 04:51:08 +00:00
|
|
|
{
|
2001-09-16 15:40:21 +00:00
|
|
|
for (; i + 1 < numipfilters; i++)
|
|
|
|
ipfilters[i] = ipfilters[i + 1];
|
|
|
|
|
|
|
|
numipfilters--;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-09-16 15:40:21 +00:00
|
|
|
SV_CleanIPList (void)
|
|
|
|
{
|
|
|
|
int i;
|
2003-01-06 18:28:13 +00:00
|
|
|
const char *type;
|
2001-09-16 15:40:21 +00:00
|
|
|
|
|
|
|
for (i = 0; i < numipfilters;) {
|
2002-06-20 16:15:27 +00:00
|
|
|
if (ipfilters[i].time && (ipfilters[i].time <= realtime)) {
|
2001-09-16 15:40:21 +00:00
|
|
|
switch (ipfilters[i].type) {
|
|
|
|
case ft_ban: type = "Ban"; break;
|
|
|
|
case ft_mute: type = "Mute"; break;
|
|
|
|
case ft_cuff: type = "Cuff"; break;
|
|
|
|
default: Sys_Error ("SV_CleanIPList: invalid filter type");
|
|
|
|
}
|
2001-09-17 06:10:39 +00:00
|
|
|
SV_Printf ("SV_CleanIPList: %s for %s/%d removed\n", type,
|
|
|
|
SV_PrintIP (ipfilters[i].ip), ipfilters[i].mask);
|
2001-09-16 15:40:21 +00:00
|
|
|
SV_RemoveIPFilter (i);
|
|
|
|
} else
|
|
|
|
i++;
|
2001-09-09 04:51:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_AddIP_f (void)
|
|
|
|
{
|
|
|
|
int i;
|
2001-09-16 15:40:21 +00:00
|
|
|
double bantime;
|
|
|
|
filtertype_t type;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
if (Cmd_Argc () < 2 || Cmd_Argc () > 4) {
|
|
|
|
SV_Printf ("Usage: addip <ip>/<mask> [<time> [<ban/mute/cuff>] ]\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Cmd_Argc () >= 3)
|
|
|
|
bantime = atof (Cmd_Argv (2)) * 60;
|
|
|
|
else
|
|
|
|
bantime = 0.0;
|
|
|
|
|
|
|
|
if (Cmd_Argc () >= 4) {
|
|
|
|
if (strequal ("ban", Cmd_Argv (3)))
|
|
|
|
type = ft_ban;
|
|
|
|
else if (strequal ("mute", Cmd_Argv (3)))
|
|
|
|
type = ft_mute;
|
|
|
|
else if (strequal ("cuff", Cmd_Argv (3)))
|
|
|
|
type = ft_cuff;
|
|
|
|
else {
|
|
|
|
SV_Printf ("Unknown filter type '%s'\n", Cmd_Argv (3));
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-09-16 15:40:21 +00:00
|
|
|
} else
|
|
|
|
type = ft_ban;
|
|
|
|
|
|
|
|
if (numipfilters == MAX_IPFILTERS) {
|
|
|
|
SV_Printf ("IP filter list is full\n");
|
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
if (SV_StringToFilter (Cmd_Argv (1), &ipfilters[numipfilters])) {
|
2002-06-20 16:15:27 +00:00
|
|
|
ipfilters[numipfilters].time = bantime ? realtime + bantime : 0.0;
|
2001-09-16 15:40:21 +00:00
|
|
|
ipfilters[numipfilters].type = type;
|
|
|
|
// FIXME: this should boot any matching clients
|
|
|
|
for (i = 0; i < MAX_CLIENTS; i++) {
|
|
|
|
client_t *cl = &svs.clients[i];
|
2018-08-19 15:05:00 +00:00
|
|
|
const char *text;
|
2003-01-06 18:28:13 +00:00
|
|
|
const char *typestr;
|
2001-09-16 15:40:21 +00:00
|
|
|
char timestr[1024];
|
2001-09-17 05:41:17 +00:00
|
|
|
|
2003-03-03 17:08:45 +00:00
|
|
|
if (cl->state < cs_zombie)
|
2001-09-17 05:41:17 +00:00
|
|
|
continue;
|
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
if (SV_MaskIPCompare (cl->netchan.remote_address.ip,
|
|
|
|
ipfilters[numipfilters].ip,
|
|
|
|
ipfilters[numipfilters].mask)) {
|
|
|
|
switch (type) {
|
|
|
|
case ft_ban:
|
|
|
|
typestr = "banned";
|
|
|
|
SV_DropClient (cl);
|
|
|
|
break;
|
|
|
|
case ft_mute:
|
|
|
|
typestr = "muted";
|
|
|
|
cl->lockedtill = bantime;
|
|
|
|
break;
|
|
|
|
case ft_cuff:
|
|
|
|
typestr = "cuffed";
|
|
|
|
cl->cuff_time = bantime;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Sys_Error ("SV_AddIP_f: unknown filter type %d", type);
|
|
|
|
}
|
|
|
|
if (bantime)
|
|
|
|
snprintf (timestr, sizeof (timestr), "for %.1f minutes",
|
|
|
|
bantime / 60);
|
|
|
|
else
|
|
|
|
strncpy (timestr, "permanently", sizeof (timestr));
|
2021-01-31 07:01:20 +00:00
|
|
|
text = va (0, "You are %s %s\n%s",
|
2018-08-19 15:05:00 +00:00
|
|
|
typestr, timestr, type == ft_ban ? "" :
|
|
|
|
"\nReconnecting won't help...");
|
2004-02-22 05:40:08 +00:00
|
|
|
MSG_ReliableWrite_Begin (&cl->backbuf, svc_centerprint,
|
|
|
|
strlen (text) + 2);
|
|
|
|
MSG_ReliableWrite_String (&cl->backbuf, text);
|
2001-09-16 15:40:21 +00:00
|
|
|
// FIXME: print on the console too
|
|
|
|
}
|
|
|
|
}
|
2001-09-20 06:51:25 +00:00
|
|
|
SV_Printf ("Added IP Filter for %s/%u\n",
|
|
|
|
SV_PrintIP (ipfilters[numipfilters].ip),
|
|
|
|
ipfilters[numipfilters].mask);
|
2001-09-16 15:40:21 +00:00
|
|
|
numipfilters++;
|
|
|
|
}
|
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_RemoveIP_f (void)
|
|
|
|
{
|
2001-09-16 15:40:21 +00:00
|
|
|
int i;
|
2001-08-28 02:43:24 +00:00
|
|
|
ipfilter_t f;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
if (!SV_StringToFilter (Cmd_Argv (1), &f))
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
for (i = 0; i < numipfilters; i++)
|
2001-09-16 15:40:21 +00:00
|
|
|
if (ipfilters[i].mask == f.mask && SV_IPCompare (ipfilters[i].ip, f.ip)) {
|
|
|
|
SV_RemoveIPFilter (i);
|
2001-09-20 06:51:25 +00:00
|
|
|
SV_Printf ("Removed IP Filter for %s/%u.\n",
|
|
|
|
SV_PrintIP (f.ip), f.mask);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-09-20 06:51:25 +00:00
|
|
|
SV_Printf ("Didn't find %s/%u.\n", SV_PrintIP (f.ip), f.mask);
|
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_ListIP_f (void)
|
|
|
|
{
|
2001-08-28 02:43:24 +00:00
|
|
|
int i;
|
2003-01-06 18:28:13 +00:00
|
|
|
const char *type;
|
2001-09-16 15:40:21 +00:00
|
|
|
char timestr[30];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-20 06:51:25 +00:00
|
|
|
SV_Printf ("IP Filter list:\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
for (i = 0; i < numipfilters; i++) {
|
2001-09-16 15:40:21 +00:00
|
|
|
switch (ipfilters[i].type) {
|
|
|
|
case ft_ban: type = "Ban:"; break;
|
|
|
|
case ft_mute: type = "Mute:"; break;
|
|
|
|
case ft_cuff: type = "Cuff:"; break;
|
|
|
|
default: Sys_Error ("SV_ListIP_f: invalid filter type");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ipfilters[i].time)
|
|
|
|
snprintf (timestr, sizeof (timestr), "%ds",
|
2002-06-20 16:15:27 +00:00
|
|
|
(int) (ipfilters[i].time ? ipfilters[i].time - realtime : 0));
|
2001-09-16 15:40:21 +00:00
|
|
|
else
|
|
|
|
strcpy (timestr, "Permanent");
|
2001-09-17 06:10:39 +00:00
|
|
|
|
|
|
|
SV_Printf ("%-5s %-10s %s/%u\n", type, timestr,
|
|
|
|
SV_PrintIP (ipfilters[i].ip), ipfilters[i].mask);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-09-20 06:51:25 +00:00
|
|
|
SV_Printf ("%d IP Filter%s\n", numipfilters,
|
|
|
|
numipfilters == 1 ? "" : "s");
|
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_WriteIP_f (void)
|
|
|
|
{
|
2001-08-28 02:43:24 +00:00
|
|
|
char name[MAX_OSPATH];
|
2001-02-19 21:15:25 +00:00
|
|
|
int i;
|
2002-08-27 07:16:28 +00:00
|
|
|
QFile *f;
|
2003-01-06 18:28:13 +00:00
|
|
|
const char *type;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-05-23 17:17:01 +00:00
|
|
|
snprintf (name, sizeof (name), "%s/listip.cfg", qfs_gamedir->dir.def);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-20 06:51:25 +00:00
|
|
|
SV_Printf ("Writing IP Filters to %s.\n", name);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-05-23 17:17:01 +00:00
|
|
|
f = QFS_Open (name, "wb");
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!f) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Couldn't open %s\n", name);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < numipfilters; i++) {
|
2001-09-19 12:58:02 +00:00
|
|
|
switch (ipfilters[i].type) {
|
|
|
|
case ft_ban: type = "ban"; break;
|
|
|
|
case ft_mute: type = "mute"; break;
|
|
|
|
case ft_cuff: type = "cuff"; break;
|
|
|
|
default: Sys_Error ("SV_WriteIP_f: invalid filter type");
|
|
|
|
}
|
|
|
|
Qprintf (f, "addip %s/%u 0 %s\n", SV_PrintIP (ipfilters[i].ip),
|
|
|
|
ipfilters[i].mask, type);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Qclose (f);
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_netDoSexpire_f (void)
|
|
|
|
{
|
2001-08-28 02:43:24 +00:00
|
|
|
int arg1, i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc () == 1) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Current DoS prot. expire settings: ");
|
2001-02-19 21:15:25 +00:00
|
|
|
for (i = 0; i < DOSFLOODCMDS; i++)
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("%f ", netdosexpire[i]);
|
|
|
|
SV_Printf ("\n");
|
[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 (!sv_netdosprotect)
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("(disabled)\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Cmd_Argc () != DOSFLOODCMDS + 1) {
|
2001-08-28 02:43:24 +00:00
|
|
|
SV_Printf ("Usage: netdosexpire <ping> <log> <connect> <status> "
|
|
|
|
"<rcon> <ban>\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < DOSFLOODCMDS; i++) {
|
|
|
|
arg1 = atoi (Cmd_Argv (i + 1));
|
|
|
|
if (arg1 > 0)
|
|
|
|
netdosexpire[i] = arg1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_netDoSvalues_f (void)
|
|
|
|
{
|
2001-08-28 02:43:24 +00:00
|
|
|
int arg1, i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc () == 1) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Current DoS prot. value settings: ");
|
2001-02-19 21:15:25 +00:00
|
|
|
for (i = 0; i < DOSFLOODCMDS; i++)
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("%f ", netdosvalues[i]);
|
|
|
|
SV_Printf ("\n");
|
[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 (!sv_netdosprotect)
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("(disabled)\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Cmd_Argc () != DOSFLOODCMDS + 1) {
|
2001-08-28 02:43:24 +00:00
|
|
|
SV_Printf ("Usage: netdosvalues <ping> <log> <connect> <status> "
|
|
|
|
"<rcon> <ban>\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < DOSFLOODCMDS; i++) {
|
|
|
|
arg1 = atoi (Cmd_Argv (i + 1));
|
|
|
|
if (arg1 > 0)
|
|
|
|
netdosvalues[i] = arg1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-09-09 04:51:08 +00:00
|
|
|
SV_SendBan (double till)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
char data[128];
|
2001-09-16 15:40:21 +00:00
|
|
|
// char *data2;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (CheckForFlood (FLOOD_BAN))
|
|
|
|
return;
|
|
|
|
|
|
|
|
data[0] = data[1] = data[2] = data[3] = 0xff;
|
|
|
|
data[4] = A2C_PRINT;
|
2001-09-09 04:51:08 +00:00
|
|
|
|
|
|
|
if (till) {
|
|
|
|
snprintf (data + 5, sizeof (data) - 5,
|
2002-06-20 16:15:27 +00:00
|
|
|
"\nbanned for %.1f more minutes.\n", (till - realtime)/60.0);
|
2001-09-09 04:51:08 +00:00
|
|
|
} else {
|
|
|
|
snprintf (data + 5, sizeof (data) - 5, "\nbanned permanently.\n");
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-02-10 21:41:22 +00:00
|
|
|
Netchan_SendPacket (strlen (data), data, net_from);
|
2001-09-16 15:40:21 +00:00
|
|
|
|
|
|
|
/* data[4] = A2C_CLIENT_COMMAND;
|
|
|
|
snprintf (data + 5, sizeof (data) - 5, "disconnect\n");
|
|
|
|
data2 = data + strlen (data) + 1;
|
|
|
|
snprintf (data2, sizeof (data) - (data2 - data), "12345");
|
2003-02-10 21:41:22 +00:00
|
|
|
Netchan_SendPacket (strlen (data) + strlen (data2) + 2, data, net_from);*/
|
2001-09-16 15:40:21 +00:00
|
|
|
// FIXME: this should send a disconnect to the client!
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool
|
2001-09-16 15:40:21 +00:00
|
|
|
SV_FilterIP (byte *ip, double *until)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
*until = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-09 04:51:08 +00:00
|
|
|
for (i = 0; i < numipfilters; i++) {
|
2001-09-16 15:40:21 +00:00
|
|
|
if (ipfilters[i].type != ft_ban)
|
2001-09-09 04:51:08 +00:00
|
|
|
continue;
|
2001-09-16 15:40:21 +00:00
|
|
|
if (SV_MaskIPCompare (ip, ipfilters[i].ip, ipfilters[i].mask)) {
|
2001-09-09 04:51:08 +00:00
|
|
|
if (!ipfilters[i].time) {
|
|
|
|
// normal ban
|
[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
|
|
|
return filterban;
|
2002-06-20 16:15:27 +00:00
|
|
|
} else if (ipfilters[i].time > realtime) {
|
2001-09-09 04:51:08 +00:00
|
|
|
*until = ipfilters[i].time;
|
|
|
|
return true; // banned no matter what
|
|
|
|
} else {
|
|
|
|
// time expired, set free
|
2001-09-16 15:40:21 +00:00
|
|
|
SV_RemoveIPFilter (i);
|
|
|
|
i--; // counter the increment, so we don't skip any
|
2001-09-09 04:51:08 +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
|
|
|
return !filterban;
|
2001-09-09 04:51:08 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-09 04:51:08 +00:00
|
|
|
void
|
|
|
|
SV_SavePenaltyFilter (client_t *cl, filtertype_t type, double pentime)
|
|
|
|
{
|
2001-09-16 15:40:21 +00:00
|
|
|
int i;
|
|
|
|
byte *b;
|
2002-06-20 16:15:27 +00:00
|
|
|
if (pentime < realtime) // no point
|
2001-09-16 15:40:21 +00:00
|
|
|
return;
|
2001-09-09 04:51:08 +00:00
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
b = cl->netchan.remote_address.ip;
|
2001-09-09 04:51:08 +00:00
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
for (i = 0; i < numipfilters; i++)
|
|
|
|
if (ipfilters[i].mask == 32 && SV_IPCompare (ipfilters[i].ip, b)
|
|
|
|
&& ipfilters[i].type == type) {
|
2001-10-27 22:33:42 +00:00
|
|
|
SV_Printf ("Penalty for user %d already exists\n", cl->userid);
|
2001-09-16 15:40:21 +00:00
|
|
|
return;
|
2001-09-09 04:51:08 +00:00
|
|
|
}
|
2001-09-16 15:40:21 +00:00
|
|
|
|
|
|
|
if (numipfilters == MAX_IPFILTERS) {
|
2001-10-27 22:33:42 +00:00
|
|
|
SV_Printf ("IP filter list is full\n");
|
2001-09-09 04:51:08 +00:00
|
|
|
return;
|
2001-09-16 15:40:21 +00:00
|
|
|
}
|
|
|
|
|
2001-10-27 22:33:42 +00:00
|
|
|
SV_Printf ("Penalty saved for user %d\n", cl->userid);
|
2001-09-16 15:40:21 +00:00
|
|
|
ipfilters[numipfilters].mask = 32;
|
|
|
|
SV_IPCopy (ipfilters[numipfilters].ip, b);
|
2001-09-09 04:51:08 +00:00
|
|
|
ipfilters[numipfilters].time = pentime;
|
2001-09-16 15:40:21 +00:00
|
|
|
ipfilters[numipfilters].type = type;
|
2001-09-09 04:51:08 +00:00
|
|
|
numipfilters++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
SV_RestorePenaltyFilter (client_t *cl, filtertype_t type)
|
|
|
|
{
|
|
|
|
int i;
|
2001-09-16 15:40:21 +00:00
|
|
|
byte *ip;
|
2001-09-09 04:51:08 +00:00
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
ip = cl->netchan.remote_address.ip;
|
2001-09-09 04:51:08 +00:00
|
|
|
|
|
|
|
// search for existing penalty filter of same type
|
2001-09-16 15:40:21 +00:00
|
|
|
for (i = 0; i < numipfilters; i++) {
|
|
|
|
if (type == ipfilters[i].type && SV_IPCompare (ip, ipfilters[i].ip)) {
|
2001-10-27 22:33:42 +00:00
|
|
|
SV_Printf ("Penalty restored for user %d\n", cl->userid);
|
2001-09-09 04:51:08 +00:00
|
|
|
return ipfilters[i].time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0.0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2021-12-27 08:54:58 +00:00
|
|
|
void
|
|
|
|
SV_OutOfBand (netadr_t adr, unsigned length, byte *data)
|
|
|
|
{
|
[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 (net_packetlog) {
|
2022-02-06 10:47:22 +00:00
|
|
|
Log_Outgoing_Packet (data, length, 0);
|
2021-12-27 08:54:58 +00:00
|
|
|
}
|
|
|
|
Netchan_OutOfBand (adr, length, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SV_OutOfBandPrint (netadr_t adr, const char *format, ...)
|
|
|
|
{
|
|
|
|
static dstring_t *string;
|
|
|
|
va_list argptr;
|
|
|
|
|
|
|
|
if (!string) {
|
|
|
|
string = dstring_new ();
|
|
|
|
}
|
|
|
|
|
|
|
|
va_start (argptr, format);
|
|
|
|
dvsprintf (string, format, argptr);
|
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
SV_OutOfBand (adr, string->size - 1, (byte *) string->str);
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_ReadPackets (void)
|
|
|
|
{
|
2001-12-15 04:58:16 +00:00
|
|
|
//NOTE star volatile, not volatile star
|
|
|
|
client_t *volatile cl; // * volatile for longjmp
|
2011-07-23 08:51:07 +00:00
|
|
|
int i;
|
2011-07-23 12:39:13 +00:00
|
|
|
int qport;
|
2001-09-09 04:51:08 +00:00
|
|
|
double until;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-03-16 03:17:50 +00:00
|
|
|
while (NET_GetPacket ()) {
|
[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 (net_packetlog)
|
2003-03-21 21:25:44 +00:00
|
|
|
Log_Incoming_Packet (net_message->message->data,
|
2022-02-06 10:47:22 +00:00
|
|
|
net_message->message->cursize, 1);
|
2001-09-16 15:40:21 +00:00
|
|
|
if (SV_FilterIP (net_from.ip, &until)) {
|
2001-09-09 04:51:08 +00:00
|
|
|
SV_SendBan (until); // tell them we aren't listening...
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// check for connectionless packet (0xffffffff) first
|
2001-02-23 23:16:13 +00:00
|
|
|
if (*(int *) net_message->message->data == -1) {
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_ConnectionlessPacket ();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2001-02-23 23:16:13 +00:00
|
|
|
if (net_message->message->cursize < 11) {
|
2010-01-13 06:50:44 +00:00
|
|
|
SV_Printf ("%s: Runt packet: %d\n", NET_AdrToString (net_from),
|
|
|
|
net_message->message->cursize);
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// read the qport out of the message so we can fix up
|
|
|
|
// stupid address translating routers
|
2001-02-23 23:16:13 +00:00
|
|
|
MSG_BeginReading (net_message);
|
|
|
|
MSG_ReadLong (net_message); // sequence number
|
|
|
|
MSG_ReadLong (net_message); // sequence number
|
|
|
|
qport = MSG_ReadShort (net_message) & 0xffff;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// check for packets from connected clients
|
|
|
|
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 (!NET_CompareBaseAdr (net_from, cl->netchan.remote_address))
|
|
|
|
continue;
|
|
|
|
if (cl->netchan.qport != qport)
|
|
|
|
continue;
|
|
|
|
if (cl->netchan.remote_address.port != net_from.port) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "SV_ReadPackets: fixing up a "
|
2010-11-23 05:09:30 +00:00
|
|
|
"translated port\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
cl->netchan.remote_address.port = net_from.port;
|
|
|
|
}
|
2001-12-15 04:13:56 +00:00
|
|
|
if (Netchan_Process (&cl->netchan)) {
|
|
|
|
// this is a valid, sequenced packet, so process it
|
2001-02-19 21:15:25 +00:00
|
|
|
svs.stats.packets++;
|
|
|
|
cl->send_message = true; // reply at end of frame
|
2001-12-15 04:58:16 +00:00
|
|
|
if (cl->state != cs_zombie) {
|
2002-01-14 17:41:38 +00:00
|
|
|
SV_ExecuteClientMessage (cl);
|
2001-12-15 04:58:16 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i != MAX_CLIENTS)
|
|
|
|
continue;
|
|
|
|
|
2004-03-05 23:42:15 +00:00
|
|
|
if (SV_qtvPacket (qport))
|
|
|
|
continue;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// packet is not from a known client
|
2001-08-28 02:43:24 +00:00
|
|
|
// SV_Printf ("%s:sequenced packet without connection\n",
|
2003-03-21 21:25:44 +00:00
|
|
|
// NET_AdrToString (net_from));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-28 02:43:24 +00:00
|
|
|
SV_CheckTimeouts
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
If a packet has not been received from a client in timeout.value
|
|
|
|
seconds, drop the conneciton.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
When a client is normally dropped, the client_t goes into a zombie
|
|
|
|
state for a few seconds to make sure any final reliable message gets
|
|
|
|
resent if necessary
|
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_CheckTimeouts (void)
|
|
|
|
{
|
|
|
|
client_t *cl;
|
|
|
|
float droptime;
|
2001-08-28 02:43:24 +00:00
|
|
|
int nclients, i;
|
2001-02-19 21:15:25 +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
|
|
|
droptime = realtime - sv_timeout;
|
2001-02-19 21:15:25 +00:00
|
|
|
nclients = 0;
|
|
|
|
|
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
2003-03-03 17:08:45 +00:00
|
|
|
if (cl->state >= cs_connected) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!cl->spectator)
|
|
|
|
nclients++;
|
|
|
|
if (cl->netchan.last_received < droptime) {
|
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "%s timed out\n", cl->name);
|
|
|
|
SV_DropClient (cl);
|
|
|
|
cl->state = cs_free; // don't bother with zombie state
|
|
|
|
svs.num_clients--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cl->state == cs_zombie &&
|
[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
|
|
|
realtime - cl->connection_started > zombietime) {
|
2001-02-19 21:15:25 +00:00
|
|
|
cl->state = cs_free; // can now be reused
|
|
|
|
svs.num_clients--;
|
|
|
|
}
|
|
|
|
}
|
2004-03-05 23:42:15 +00:00
|
|
|
SV_qtvCheckTimeouts ();
|
2001-02-19 21:15:25 +00:00
|
|
|
if (sv.paused && !nclients) {
|
|
|
|
// nobody left, unpause the server
|
|
|
|
SV_TogglePause ("Pause released since no players are left.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
SV_CheckVars
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_CheckVars (void)
|
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
static char const *pw, *spw;
|
2001-02-19 21:15:25 +00:00
|
|
|
int v;
|
|
|
|
|
[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 (password == pw && spectator_password == spw)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
[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
|
|
|
pw = password;
|
|
|
|
spw = spectator_password;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
v = 0;
|
|
|
|
if (pw && pw[0] && strcmp (pw, "none"))
|
|
|
|
v |= 1;
|
|
|
|
if (spw && spw[0] && strcmp (spw, "none"))
|
|
|
|
v |= 2;
|
|
|
|
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Updated needpass.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!v)
|
2001-11-04 07:50:39 +00:00
|
|
|
Info_SetValueForKey (svs.info, "needpass", "",
|
[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
|
|
|
else
|
2021-01-31 07:01:20 +00:00
|
|
|
Info_SetValueForKey (svs.info, "needpass", va (0, "%i", v),
|
[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-06-16 22:39:41 +00:00
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
SV_Frame (float time)
|
|
|
|
{
|
|
|
|
static double start, end;
|
2002-10-04 02:29:03 +00:00
|
|
|
double demo_start, demo_end;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
start = Sys_DoubleTime ();
|
|
|
|
svs.stats.idle += start - end;
|
|
|
|
|
|
|
|
// keep the random time dependent
|
|
|
|
rand ();
|
|
|
|
|
|
|
|
// decide the simulation time
|
2002-06-20 16:38:16 +00:00
|
|
|
realtime += time;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!sv.paused) {
|
|
|
|
sv.time += time;
|
|
|
|
}
|
|
|
|
// check timeouts
|
|
|
|
SV_CheckTimeouts ();
|
|
|
|
|
|
|
|
// toggle the log buffer if full
|
|
|
|
SV_CheckLog ();
|
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
// clean out expired bans/cuffs/mutes
|
|
|
|
SV_CleanIPList ();
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// move autonomous things around if enough time has passed
|
2002-02-25 22:57:17 +00:00
|
|
|
if (!sv.paused) {
|
|
|
|
static double old_time;
|
|
|
|
|
|
|
|
// don't bother running a frame if sys_ticrate seconds haven't passed
|
2002-06-20 16:38:16 +00:00
|
|
|
sv_frametime = sv.time - old_time;
|
|
|
|
if (sv_frametime < 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
|
|
|
old_time = sv.time - sv_mintic;
|
|
|
|
sv_frametime = sv_mintic;
|
2002-06-20 16:38:16 +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 (sv_frametime >= sv_mintic) {
|
|
|
|
if (sv_frametime > sv_maxtic)
|
|
|
|
sv_frametime = sv_maxtic;
|
2002-06-20 16:38:16 +00:00
|
|
|
old_time = sv.time;
|
2002-02-25 22:57:17 +00:00
|
|
|
|
2002-06-20 16:15:27 +00:00
|
|
|
*sv_globals.frametime = sv_frametime;
|
2002-02-25 22:57:17 +00:00
|
|
|
|
2002-06-20 16:15:27 +00:00
|
|
|
SV_Physics ();
|
2002-02-25 22:57:17 +00:00
|
|
|
}
|
|
|
|
}
|
2002-06-20 16:15:27 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// get packets
|
|
|
|
SV_ReadPackets ();
|
|
|
|
|
2010-01-13 06:53:10 +00:00
|
|
|
// check for typing at the console
|
|
|
|
Con_ProcessInput ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-08-27 04:47:49 +00:00
|
|
|
// process gib threads
|
|
|
|
GIB_Thread_Execute ();
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// process console commands
|
2002-08-03 06:04:00 +00:00
|
|
|
Cbuf_Execute_Stack (sv_cbuf);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
SV_CheckVars ();
|
|
|
|
|
|
|
|
// send messages back to the clients that had packets read this frame
|
|
|
|
SV_SendClientMessages ();
|
|
|
|
|
2002-10-04 02:29:03 +00:00
|
|
|
demo_start = Sys_DoubleTime ();
|
2005-05-01 09:07:20 +00:00
|
|
|
if (sv.recorders)
|
2010-01-13 06:45:43 +00:00
|
|
|
SVR_SendMessages ();
|
2002-10-04 02:29:03 +00:00
|
|
|
demo_end = Sys_DoubleTime ();
|
|
|
|
svs.stats.demo += demo_end - demo_start;
|
|
|
|
|
2005-05-05 07:31:31 +00:00
|
|
|
SV_qtvSendMessages ();
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// send a heartbeat to the master if needed
|
|
|
|
Master_Heartbeat ();
|
|
|
|
|
|
|
|
// collect timing statistics
|
|
|
|
end = Sys_DoubleTime ();
|
|
|
|
svs.stats.active += end - start;
|
|
|
|
if (++svs.stats.count == STATFRAMES) {
|
|
|
|
svs.stats.latched_active = svs.stats.active;
|
|
|
|
svs.stats.latched_idle = svs.stats.idle;
|
|
|
|
svs.stats.latched_packets = svs.stats.packets;
|
2002-10-04 02:29:03 +00:00
|
|
|
svs.stats.latched_demo = svs.stats.demo;
|
2001-02-19 21:15:25 +00:00
|
|
|
svs.stats.active = 0;
|
|
|
|
svs.stats.idle = 0;
|
|
|
|
svs.stats.packets = 0;
|
|
|
|
svs.stats.count = 0;
|
2002-10-04 02:29:03 +00:00
|
|
|
svs.stats.demo = 0;
|
2007-04-09 00:10:10 +00:00
|
|
|
Con_DrawConsole ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-03 18:30:09 +00:00
|
|
|
static 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
|
|
|
maxspectators_f (void *data, const cvar_t *cvar)
|
2003-03-03 18:30:09 +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 (maxspectators > MAX_CLIENTS)
|
|
|
|
maxspectators = maxclients;
|
|
|
|
else if (maxspectators + maxclients > MAX_CLIENTS)
|
|
|
|
maxspectators = MAX_CLIENTS - maxclients;
|
|
|
|
else if (maxspectators < 0)
|
|
|
|
maxspectators = 0;
|
|
|
|
Cvar_Info (data, cvar);
|
2003-03-03 18:30:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static 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
|
|
|
maxclients_f (void *data, const cvar_t *cvar)
|
2003-03-03 18:30:09 +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 (maxclients > MAX_CLIENTS)
|
|
|
|
maxclients = MAX_CLIENTS;
|
|
|
|
else if (maxclients < 1)
|
|
|
|
maxclients = 1;
|
|
|
|
Cvar_Info (data, cvar);
|
|
|
|
maxspectators_f (0, &maxspectators_cvar);
|
2003-03-03 18:30:09 +00:00
|
|
|
}
|
|
|
|
|
2011-09-03 05:18:35 +00:00
|
|
|
static void
|
2022-06-04 07:06:04 +00:00
|
|
|
gamedir_f (int phase, void *data)
|
2011-09-03 05:18:35 +00:00
|
|
|
{
|
|
|
|
if (!phase)
|
|
|
|
return;
|
|
|
|
if (qfs_gamedir->gamedir)
|
|
|
|
Info_SetValueForStarKey (svs.info, "*gamedir",
|
|
|
|
qfs_gamedir->gamedir, 0);
|
|
|
|
else
|
|
|
|
Info_RemoveKey (svs.info, "*gamedir");
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_InitLocal (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
SV_UserInit ();
|
2022-05-04 14:13:24 +00:00
|
|
|
SV_Physics_Init_Cvars ();
|
2001-02-19 21:15:25 +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
|
|
|
Cvar_Register (&rcon_password_cvar, 0, 0);
|
|
|
|
Cvar_Register (&admin_password_cvar, 0, 0);
|
|
|
|
Cvar_Register (&password_cvar, 0, 0);
|
|
|
|
Cvar_Register (&spectator_password_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_mintic_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_maxtic_cvar, 0, 0);
|
|
|
|
Cvar_Register (&fraglimit_cvar, Cvar_Info, &fraglimit);
|
|
|
|
Cvar_Register (&timelimit_cvar, Cvar_Info, &timelimit);
|
|
|
|
Cvar_Register (&teamplay_cvar, Cvar_Info, &teamplay);
|
|
|
|
Cvar_Register (&samelevel_cvar, 0, 0);
|
|
|
|
Cvar_Register (&maxclients_cvar, maxclients_f, 0);
|
|
|
|
Cvar_Register (&maxspectators_cvar, maxspectators_f, 0);
|
|
|
|
Cvar_Register (&hostname_cvar, 0, 0);
|
|
|
|
Cvar_Register (&deathmatch_cvar, 0, 0);
|
|
|
|
Cvar_Register (&coop_cvar, 0, 0);
|
|
|
|
Cvar_Register (&skill_cvar, 0, 0);
|
|
|
|
Cvar_Register (&spawn_cvar, Cvar_Info, &spawn);
|
|
|
|
Cvar_Register (&watervis_cvar, Cvar_Info, &watervis);
|
|
|
|
Cvar_Register (&sv_timeout_cvar, 0, 0);
|
|
|
|
Cvar_Register (&zombietime_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_extensions_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_minqfversion_cvar, Cvar_Info, &sv_minqfversion);
|
|
|
|
Cvar_Register (&sv_allow_log_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_allow_status_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_allow_ping_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_netdosprotect_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_timestamps_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_timefmt_cvar, 0, 0);
|
|
|
|
Cvar_Register (&filterban_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_filter_automask_cvar, 0, 0);
|
|
|
|
Cvar_Register (&allow_download_cvar, 0, 0);
|
|
|
|
Cvar_Register (&allow_download_skins_cvar, 0, 0);
|
|
|
|
Cvar_Register (&allow_download_models_cvar, 0, 0);
|
|
|
|
Cvar_Register (&allow_download_sounds_cvar, 0, 0);
|
|
|
|
Cvar_Register (&allow_download_maps_cvar, 0, 0);
|
|
|
|
Cvar_Register (&allow_download_demos_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_highchars_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_phs_cvar, 0, 0);
|
|
|
|
Cvar_Register (&pausable_cvar, 0, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
// DoS protection
|
2001-08-28 02:43:24 +00:00
|
|
|
Cmd_AddCommand ("netdosexpire", SV_netDoSexpire_f, "FIXME: part of DoS "
|
|
|
|
"protection obviously, but I don't know what it does. No "
|
|
|
|
"Description");
|
|
|
|
Cmd_AddCommand ("netdosvalues", SV_netDoSvalues_f, "FIXME: part of DoS "
|
|
|
|
"protection obviously, but I don't know what it does. No "
|
|
|
|
"Description");
|
|
|
|
Cmd_AddCommand ("addip", SV_AddIP_f, "Add a single IP or a domain of IPs "
|
|
|
|
"to the IP list of the server.\n"
|
|
|
|
"Useful for banning people. (addip (ipnumber))");
|
|
|
|
Cmd_AddCommand ("removeip", SV_RemoveIP_f, "Remove an IP address from the "
|
|
|
|
"server IP list. (removeip (ipnumber))");
|
|
|
|
Cmd_AddCommand ("listip", SV_ListIP_f, "Print out the current list of IPs "
|
|
|
|
"on the server list.");
|
|
|
|
Cmd_AddCommand ("writeip", SV_WriteIP_f, "Record all IP addresses on the "
|
|
|
|
"server IP list. The file name is listip.cfg");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_MODELS; i++)
|
|
|
|
snprintf (localmodels[i], sizeof (localmodels[i]), "*%i", i);
|
|
|
|
|
|
|
|
Info_SetValueForStarKey (svs.info, "*version", QW_VERSION,
|
[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
|
|
|
|
|
|
|
// Brand server as QF, with appropriate QSG standards version --KB
|
2010-08-19 06:01:43 +00:00
|
|
|
Info_SetValueForStarKey (svs.info, "*qf_version", PACKAGE_VERSION,
|
[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-21 21:38:07 +00:00
|
|
|
Info_SetValueForStarKey (svs.info, "*qsg_version", QW_QSG_VERSION,
|
[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
|
|
|
|
2001-07-22 19:03:26 +00:00
|
|
|
CF_Init ();
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// init fraglog stuff
|
|
|
|
svs.logsequence = 1;
|
2002-06-08 23:29:19 +00:00
|
|
|
svs.logtime = realtime;
|
2001-02-19 21:15:25 +00:00
|
|
|
svs.log[0].data = svs.log_buf[0];
|
|
|
|
svs.log[0].maxsize = sizeof (svs.log_buf[0]);
|
|
|
|
svs.log[0].cursize = 0;
|
|
|
|
svs.log[0].allowoverflow = true;
|
|
|
|
svs.log[1].data = svs.log_buf[1];
|
|
|
|
svs.log[1].maxsize = sizeof (svs.log_buf[1]);
|
|
|
|
svs.log[1].cursize = 0;
|
|
|
|
svs.log[1].allowoverflow = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Master_Heartbeat
|
|
|
|
|
|
|
|
Send a message to the master every few minutes to
|
|
|
|
let it know we are alive, and log information
|
|
|
|
*/
|
|
|
|
#define HEARTBEAT_SECONDS 300
|
|
|
|
void
|
|
|
|
Master_Heartbeat (void)
|
|
|
|
{
|
|
|
|
char string[2048];
|
2001-08-28 02:43:24 +00:00
|
|
|
int active, i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-06-20 16:15:27 +00:00
|
|
|
if (realtime - svs.last_heartbeat < HEARTBEAT_SECONDS)
|
2001-02-19 21:15:25 +00:00
|
|
|
return; // not time to send yet
|
2002-06-20 16:15:27 +00:00
|
|
|
|
2002-06-08 23:29:19 +00:00
|
|
|
svs.last_heartbeat = realtime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// count active users
|
|
|
|
active = 0;
|
|
|
|
for (i = 0; i < MAX_CLIENTS; i++)
|
2003-03-03 17:08:45 +00:00
|
|
|
if (svs.clients[i].state >= cs_connected)
|
|
|
|
active++;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
svs.heartbeat_sequence++;
|
|
|
|
snprintf (string, sizeof (string), "%c\n%i\n%i\n", S2M_HEARTBEAT,
|
|
|
|
svs.heartbeat_sequence, active);
|
|
|
|
|
|
|
|
|
|
|
|
// send to group master
|
|
|
|
for (i = 0; i < MAX_MASTERS; i++)
|
|
|
|
if (master_adr[i].port) {
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Sending heartbeat to %s\n",
|
2001-02-19 21:15:25 +00:00
|
|
|
NET_AdrToString (master_adr[i]));
|
2003-02-10 21:41:22 +00:00
|
|
|
Netchan_SendPacket (strlen (string), string, master_adr[i]);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
static inline bool
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
iswhitespace (char c)
|
|
|
|
{
|
|
|
|
return c == ' ' || c == '\r' || c == '\n' || c == '\t';
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
SV_ExtractFromUserinfo
|
|
|
|
|
|
|
|
Pull specific info from a newly changed userinfo string
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
into a more C friendly form.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
SV_ExtractFromUserinfo (client_t *cl)
|
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *val;
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
const char *p;
|
|
|
|
char *r;
|
|
|
|
char newname[MAX_NAME];
|
2001-02-19 21:15:25 +00:00
|
|
|
client_t *client;
|
2001-08-28 02:43:24 +00:00
|
|
|
int i;
|
2023-06-13 09:06:11 +00:00
|
|
|
bool badname = false;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
// name from the info string
|
2001-02-19 21:15:25 +00:00
|
|
|
val = Info_ValueForKey (cl->userinfo, "name");
|
|
|
|
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
// copy it, while converting \r, \n, and \t to space, trimming any
|
|
|
|
// leading/trailing whitespace, and merging consecutive spaces
|
|
|
|
for (p = val; iswhitespace (*p); p++);
|
|
|
|
for (r = newname; *p && r != newname + sizeof (newname) - 1; p++) {
|
|
|
|
if (iswhitespace (*p)) {
|
|
|
|
if (!iswhitespace (p[1]) && p[1] != '\0')
|
2001-11-07 08:24:56 +00:00
|
|
|
*r++ = *p;
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
} else
|
2001-11-07 08:24:56 +00:00
|
|
|
*r++ = *p;
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
}
|
|
|
|
*r = '\0';
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
// empty (or only whitespace) name
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
if (!*newname)
|
|
|
|
badname = true;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
// impersonating an user-xxx name. if they're using it
|
|
|
|
// legitimately it'll be a no-op later on
|
|
|
|
if (!strncasecmp (newname, "user-", 5))
|
|
|
|
badname = true;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
// impersonating the admin
|
|
|
|
if (strcasestr (newname, "console") || strcasestr (newname, "admin"))
|
|
|
|
badname = true;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
// check for duplicate names
|
|
|
|
for (i = 0, client = svs.clients; i < MAX_CLIENTS; i++, client++) {
|
|
|
|
if (client->state != cs_spawned || client == cl)
|
|
|
|
continue;
|
|
|
|
if (!strcasecmp (client->name, val)) {
|
|
|
|
badname = true;
|
|
|
|
break;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
// give them a name we like
|
|
|
|
if (badname)
|
|
|
|
snprintf (newname, sizeof (newname), "user-%d", cl->userid);
|
|
|
|
|
|
|
|
// set the name
|
2001-10-31 03:05:59 +00:00
|
|
|
if (strcmp (newname, val) || strcmp (cl->name, newname)) {
|
2001-11-04 07:50:39 +00:00
|
|
|
Info_SetValueForKey (cl->userinfo, "name", newname,
|
[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
|
|
|
val = Info_ValueForKey (cl->userinfo, "name");
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
SVstring (cl->edict, netname) = PR_SetString (&sv_pr_state, newname);
|
|
|
|
|
|
|
|
// If the new name was not set (due to the info string being too
|
|
|
|
// long), drop the client.
|
|
|
|
if (strcmp (val, newname)) {
|
2021-12-27 08:54:58 +00:00
|
|
|
SV_OutOfBandPrint (net_from, "%c\nPlease choose a "
|
|
|
|
"different name.\n", A2C_PRINT);
|
2002-10-04 02:29:03 +00:00
|
|
|
SV_ClientPrintf (1, cl, PRINT_HIGH, "Please choose a "
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
"different name.\n");
|
2003-03-21 21:25:44 +00:00
|
|
|
SV_Printf ("Client %d kicked for having a invalid name\n",
|
|
|
|
cl->userid);
|
2002-01-14 17:41:38 +00:00
|
|
|
cl->drop = true;
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
// check for spamming
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!sv.paused) {
|
|
|
|
if (!cl->lastnametime || realtime - cl->lastnametime > 5) {
|
|
|
|
cl->lastnamecount = 0;
|
|
|
|
cl->lastnametime = realtime;
|
|
|
|
} else if (cl->lastnamecount++ > 4) {
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "%s was kicked for "
|
|
|
|
"name spam\n", cl->name);
|
2002-10-04 02:29:03 +00:00
|
|
|
SV_ClientPrintf (1, cl, PRINT_HIGH, "You were kicked "
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
"from the game for name spamming\n");
|
2002-01-14 17:41:38 +00:00
|
|
|
cl->drop = true;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
// finally, report it to all our friends
|
2012-06-29 06:13:03 +00:00
|
|
|
if (!cl->spectator && *cl->name)
|
2001-08-28 02:43:24 +00:00
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "%s changed name to %s\n",
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
cl->name, newname);
|
|
|
|
strcpy (cl->name, newname);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// rate command
|
|
|
|
val = Info_ValueForKey (cl->userinfo, "rate");
|
|
|
|
if (strlen (val)) {
|
|
|
|
i = atoi (val);
|
|
|
|
|
[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 (sv_maxrate) {
|
|
|
|
i = bound (500, i, sv_maxrate);
|
2001-02-19 21:15:25 +00:00
|
|
|
} else {
|
2002-06-17 16:18:34 +00:00
|
|
|
i = max (500, i);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
cl->netchan.rate = 1.0 / i;
|
|
|
|
}
|
- fix a little mistake in SV_PrintToClient that'd cause it to
segfault if your first call was with "". Probably could cause
crashes too
- add a string.c file to libQFutil, with a Q_strcasestr function,
which strcasestr is defined to if it's not already defined. (we'd
get that with glibc if we defined __USE_GNU, but we don't)
- make client_t and SV_ExtractFromUserinfo both use NAME_MAX for
their name arrays, instead of 32 for one and 80 for the other
- rewrite almost all of SV_ExtractFromUserinfo's name handling.
- \r, \n, and \t are all converted to spaces
- leading/trailing spaces are stripped
- consecutive spaces are reduced to a single space
- empty names are considered bad
- user-* nicks are considered bad (unless forced to them)
- a name containing console or admin is considered bad
- a name that already exists is considered bad
- if they have a bad name it gets forced to user-%d, where %d is
their userid
- netname in the progs is now updated properly
- name changes are always reported unless it's the initial setting,
rather than only if they're full connected and not a spectator
- finally, if the name change fails (info string exceeded), give
them the boot. (before this was only done for duplicate names)
That's about it :)
2001-10-04 19:11:39 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// msg command
|
|
|
|
val = Info_ValueForKey (cl->userinfo, "msg");
|
|
|
|
if (strlen (val)) {
|
|
|
|
cl->messagelevel = atoi (val);
|
|
|
|
}
|
|
|
|
|
2001-09-11 03:50:24 +00:00
|
|
|
cl->stdver = atof (Info_ValueForKey (cl->userinfo, "*qsg_version"));
|
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_InitNet (void)
|
|
|
|
{
|
2001-08-28 02:43:24 +00:00
|
|
|
int port, p;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-16 15:40:21 +00:00
|
|
|
SV_GenerateIPMasks ();
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
port = PORT_SERVER;
|
|
|
|
p = COM_CheckParm ("-port");
|
|
|
|
if (p && p < com_argc) {
|
|
|
|
port = atoi (com_argv[p + 1]);
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("Port: %i\n", port);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
NET_Init (port);
|
|
|
|
|
|
|
|
Netchan_Init ();
|
2004-02-19 23:06:47 +00:00
|
|
|
net_realtime = &realtime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-06 10:47:22 +00:00
|
|
|
Net_Log_Init (sv.sound_precache, 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
svs.last_heartbeat = -99999; // send immediately
|
2002-08-28 21:12:22 +00:00
|
|
|
sv_net_initialized = 1;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2021-12-13 00:13:39 +00:00
|
|
|
static memhunk_t *
|
2001-11-14 20:18:37 +00:00
|
|
|
SV_Init_Memory (void)
|
|
|
|
{
|
|
|
|
int mem_parm = COM_CheckParm ("-mem");
|
2021-07-26 06:43:57 +00:00
|
|
|
size_t mem_size;
|
2001-11-14 20:18:37 +00:00
|
|
|
void *mem_base;
|
|
|
|
|
[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_mem_size_cvar, 0, 0);
|
2001-11-14 20:18:37 +00:00
|
|
|
if (mem_parm)
|
[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_Set ("sv_mem_size", com_argv[mem_parm + 1]);
|
2001-11-14 20:18:37 +00:00
|
|
|
|
|
|
|
if (COM_CheckParm ("-minmemory"))
|
[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_mem_size = MINIMUM_MEMORY / (1024 * 1024.0);
|
2001-11-14 20:18:37 +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
|
|
|
mem_size = (size_t) (sv_mem_size * 1024 * 1024);
|
2001-11-14 20:18:37 +00:00
|
|
|
|
|
|
|
if (mem_size < MINIMUM_MEMORY)
|
|
|
|
Sys_Error ("Only %4.1f megs of memory reported, can't execute game",
|
|
|
|
mem_size / (float) 0x100000);
|
|
|
|
|
2021-02-03 04:19:19 +00:00
|
|
|
mem_base = Sys_Alloc (mem_size);
|
2001-11-14 20:18:37 +00:00
|
|
|
|
|
|
|
if (!mem_base)
|
2021-07-26 06:43:57 +00:00
|
|
|
Sys_Error ("Can't allocate %zd", mem_size);
|
2001-11-14 20:18:37 +00:00
|
|
|
|
2021-12-13 00:13:39 +00:00
|
|
|
return Memory_Init (mem_base, mem_size);
|
2001-11-14 20:18:37 +00:00
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
SV_Init (void)
|
|
|
|
{
|
2002-08-07 06:17:50 +00:00
|
|
|
sv_cbuf = Cbuf_New (&id_interp);
|
2002-07-31 05:19:03 +00:00
|
|
|
sv_args = Cbuf_ArgsNew ();
|
|
|
|
|
2020-03-21 13:24:11 +00:00
|
|
|
Sys_RegisterShutdown (SV_Shutdown, 0);
|
2001-09-24 21:00:23 +00:00
|
|
|
|
2002-08-20 23:04:57 +00:00
|
|
|
Sys_Init ();
|
2002-11-14 05:28:54 +00:00
|
|
|
GIB_Init (true);
|
2021-04-12 13:09:09 +00:00
|
|
|
COM_ParseConfig (sv_cbuf);
|
2001-02-19 21:15:25 +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
|
|
|
cmd_warncmd = 1;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-11-29 04:40:25 +00:00
|
|
|
// snax: Init experimental object system and run a test
|
2004-04-20 05:34:35 +00:00
|
|
|
//Object_Init();
|
2003-11-29 04:40:25 +00:00
|
|
|
|
2021-12-13 00:13:39 +00:00
|
|
|
memhunk_t *hunk = SV_Init_Memory ();
|
2001-11-14 20:18:37 +00:00
|
|
|
|
2022-06-04 07:06:04 +00:00
|
|
|
QFS_GamedirCallback (gamedir_f, 0);
|
2002-02-25 22:57:17 +00:00
|
|
|
svs.maxclients = MAX_CLIENTS;
|
2003-02-19 17:39:21 +00:00
|
|
|
svs.info = Info_ParseString ("", MAX_SERVERINFO_STRING, 0);
|
|
|
|
localinfo = Info_ParseString ("", 0, 0); // unlimited
|
2001-11-14 20:18:37 +00:00
|
|
|
SV_InitOperatorCommands ();
|
2003-02-16 19:46:34 +00:00
|
|
|
SV_GIB_Init ();
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2021-12-13 00:13:39 +00:00
|
|
|
QFS_Init (hunk, "qw");
|
2001-04-25 00:20:23 +00:00
|
|
|
PI_Init ();
|
2001-02-19 21:15:25 +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
|
|
|
Cvar_Register (&sv_console_plugin_cvar, 0, 0);
|
2001-12-02 20:11:21 +00:00
|
|
|
PI_RegisterPlugins (server_plugin_list);
|
2023-01-20 04:27:17 +00:00
|
|
|
Con_Load (sv_console_plugin);
|
2002-07-31 05:19:03 +00:00
|
|
|
if (con_module)
|
|
|
|
con_module->data->console->cbuf = sv_cbuf;
|
2023-01-20 04:27:17 +00:00
|
|
|
Con_Init ();
|
2002-09-04 18:56:53 +00:00
|
|
|
con_list_print = Sys_Printf;
|
2002-02-20 19:22:52 +00:00
|
|
|
Sys_SetStdPrintf (SV_Print);
|
|
|
|
Sys_SetErrPrintf (SV_Error);
|
2001-07-10 22:36:22 +00:00
|
|
|
|
2001-03-30 00:44:35 +00:00
|
|
|
Game_Init_Cvars ();
|
2001-02-19 21:15:25 +00:00
|
|
|
Mod_Init_Cvars ();
|
|
|
|
Netchan_Init_Cvars ();
|
|
|
|
Pmove_Init_Cvars ();
|
|
|
|
|
|
|
|
// and now reprocess the cmdline's sets for overrides
|
2002-07-31 05:19:03 +00:00
|
|
|
Cmd_StuffCmds (sv_cbuf);
|
|
|
|
Cbuf_Execute_Sets (sv_cbuf);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2007-04-09 00:10:10 +00:00
|
|
|
SV_Sbar_Init ();
|
|
|
|
|
2001-04-01 01:42:40 +00:00
|
|
|
Game_Init ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
SV_Progs_Init ();
|
|
|
|
Mod_Init ();
|
|
|
|
|
|
|
|
SV_InitNet ();
|
|
|
|
|
|
|
|
SV_InitLocal ();
|
|
|
|
Pmove_Init ();
|
|
|
|
|
2005-05-01 09:07:20 +00:00
|
|
|
SVR_Init ();
|
2002-10-04 02:29:03 +00:00
|
|
|
Demo_Init ();
|
|
|
|
|
2021-07-28 06:01:45 +00:00
|
|
|
Hunk_AllocName (0, 0, "-HOST_HUNKLEVEL-");
|
|
|
|
host_hunklevel = Hunk_LowMark (0);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_InsertText (sv_cbuf, "exec server.cfg\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
host_initialized = true;
|
|
|
|
|
2001-08-28 02:43:24 +00:00
|
|
|
// SV_Printf ("Exe: "__TIME__" "__DATE__"\n");
|
[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_Printf ("%4.1f megabyte heap\n", sv_mem_size);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("\n");
|
2010-08-19 06:01:43 +00:00
|
|
|
SV_Printf ("%s server, Version %s (build %04d)\n",
|
|
|
|
PACKAGE_NAME, PACKAGE_VERSION,
|
|
|
|
build_number ());
|
2001-07-11 23:11:29 +00:00
|
|
|
SV_Printf ("\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-08-19 06:01:43 +00:00
|
|
|
SV_Printf ("<==> %s initialized <==>\n", PACKAGE_NAME);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// process command line arguments
|
[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
|
|
|
Cmd_Exec_File (sv_cbuf, fs_usercfg, 0);
|
2002-07-31 05:19:03 +00:00
|
|
|
Cmd_StuffCmds (sv_cbuf);
|
2002-11-30 21:12:45 +00:00
|
|
|
Cbuf_Execute_Stack (sv_cbuf);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// if a map wasn't specified on the command line, spawn start.map
|
|
|
|
if (sv.state == ss_dead)
|
2001-02-22 04:46:59 +00:00
|
|
|
Cmd_ExecuteString ("map start", src_command);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (sv.state == ss_dead)
|
2002-02-20 19:22:52 +00:00
|
|
|
Sys_Error ("Could not initialize server");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|