2000-05-10 20:33:16 +00:00
|
|
|
/*
|
2000-05-11 16:03:29 +00:00
|
|
|
sv_main.c
|
2000-05-10 20:33:16 +00:00
|
|
|
|
2000-05-11 16:03:29 +00:00
|
|
|
(description)
|
2000-05-10 20:33:16 +00:00
|
|
|
|
2000-05-11 16:03:29 +00:00
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
2000-05-10 20:33:16 +00:00
|
|
|
|
2000-05-11 16:03:29 +00:00
|
|
|
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.
|
2000-05-10 20:33:16 +00:00
|
|
|
|
2000-05-11 16:03:29 +00:00
|
|
|
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.
|
2000-05-10 20:33:16 +00:00
|
|
|
|
2000-05-11 16:03:29 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
$Id$
|
2000-05-10 20:33:16 +00:00
|
|
|
*/
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-05-17 10:03:19 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
2000-05-21 08:24:45 +00:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2000-11-26 09:48:01 +00:00
|
|
|
|
2000-05-26 03:55:27 +00:00
|
|
|
#ifdef HAVE_STRINGS_H
|
2000-11-26 09:48:01 +00:00
|
|
|
# include <strings.h>
|
2000-05-26 03:55:27 +00:00
|
|
|
#endif
|
2000-06-16 09:41:42 +00:00
|
|
|
|
2000-11-26 09:48:01 +00:00
|
|
|
#include "bothdefs.h"
|
|
|
|
#include "buildnum.h"
|
|
|
|
#include "cmd.h"
|
|
|
|
#include "commdef.h"
|
|
|
|
#include "crc.h"
|
|
|
|
#include "msg.h"
|
|
|
|
#include "pmove.h"
|
|
|
|
#include "qargs.h"
|
|
|
|
#include "quakefs.h"
|
|
|
|
#include "server.h"
|
|
|
|
#include "sys.h"
|
|
|
|
#include "va.h"
|
|
|
|
#include "ver_check.h"
|
|
|
|
#include "world.h"
|
|
|
|
|
2000-11-29 23:26:45 +00:00
|
|
|
quakeparms_t host_parms;
|
2000-11-25 14:20:04 +00:00
|
|
|
qboolean host_initialized; // true if into command execution
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
double sv_frametime;
|
|
|
|
double realtime; // without any filtering or bounding
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
int host_hunklevel;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
netadr_t master_adr[MAX_MASTERS]; // address of group servers
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
client_t *host_client; // current client
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-08-13 14:26:20 +00:00
|
|
|
// DoS protection
|
|
|
|
// FLOOD_PING, FLOOD_LOG, FLOOD_CONNECT, FLOOD_STATUS, FLOOD_RCON, FLOOD_BAN
|
|
|
|
// fixme: these default values need to be tweaked after more testing
|
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
double netdosexpire[DOSFLOODCMDS] = { 1, 1, 2, 0.9, 1, 5 };
|
|
|
|
double netdosvalues[DOSFLOODCMDS] = { 12, 1, 3, 1, 1, 1 };
|
2000-11-14 16:16:07 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *sv_netdosprotect; // tone down DoS from quake servers
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *sv_allow_status;
|
|
|
|
cvar_t *sv_allow_log;
|
|
|
|
cvar_t *sv_allow_ping;
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *fs_globalcfg;
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *sv_mintic; // bound the size of the
|
|
|
|
cvar_t *sv_maxtic; // physics time tic
|
2000-05-21 09:49:25 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *developer; // show extra messages
|
2000-05-16 04:47:41 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *timeout; // seconds without any message
|
|
|
|
cvar_t *zombietime; // seconds to sink messages after disconnect
|
2000-05-16 04:47:41 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *rcon_password; // password for remote server commands
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *password; // password for entering the game
|
|
|
|
cvar_t *spectator_password; // password for entering as a spectator
|
2000-11-14 16:16:07 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *allow_download;
|
|
|
|
cvar_t *allow_download_skins;
|
|
|
|
cvar_t *allow_download_models;
|
|
|
|
cvar_t *allow_download_sounds;
|
|
|
|
cvar_t *allow_download_maps;
|
2000-11-14 16:16:07 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *sv_highchars;
|
2000-05-16 04:47:41 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *sv_phs;
|
2000-05-16 04:47:41 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *pausable;
|
2000-05-16 04:47:41 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
extern cvar_t *sv_timekick;
|
|
|
|
extern cvar_t *sv_timekick_fuzz;
|
|
|
|
extern cvar_t *sv_timekick_interval;
|
2000-05-16 04:47:41 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *sv_minqfversion; // Minimum QF version allowed to connect
|
|
|
|
cvar_t *sv_maxrate; // Maximum allowable rate (silently capped)
|
2000-05-16 04:47:41 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *sv_timestamps;
|
|
|
|
cvar_t *sv_timefmt;
|
Enabled time stamped messages for server. To turn it on, set
sv_timestamps.
To configure how timestamps are formatted, use the sv_timefmt Cvar. It's a
formatted string, with the following special tokens (taken from the
strftime() manual page):
%a The abbreviated weekday name according to the cur
rent locale.
%A The full weekday name according to the current
locale.
%b The abbreviated month name according to the current
locale.
%B The full month name according to the current
locale.
%c The preferred date and time representation for the
current locale.
%C The century number (year/100) as a 2-digit integer.
(SU)
%C The century number (the year divided by 100 and
truncated to an integer).
%d The day of the month as a decimal number (range 01
to 31).
%D Equivalent to %m/%d/%y. (Yecch - for Americans
only. Americans should note that in other coun
tries %d/%m/%y is rather common. This means that in
international context this format is ambiguous and
should not be used.) (SU)
%e Like %d, the day of the month as a decimal number,
but a leading zero is replaced by a space. (SU)
%E Modifier: use alternative format, see below. (SU)
%G The ISO 8601 year with century as a decimal number.
The 4-digit year corresponding to the ISO week num
ber (see %V). This has the same format and value
as %y, except that if the ISO week number belongs
to the previous or next year, that year is used
instead. (TZ)
%g Like %G, but without century, i.e., with a 2-digit
year (00-99). (TZ)
%h Equivalent to %b. (SU)
%H The hour as a decimal number using a 24-hour clock
(range 00 to 23).
%I The hour as a decimal number using a 12-hour clock
(range 01 to 12).
%j The day of the year as a decimal number (range 001
to 366).
%k The hour (24-hour clock) as a decimal number (range
0 to 23); single digits are preceded by a blank.
(See also %H.) (TZ)
%l The hour (12-hour clock) as a decimal number (range
1 to 12); single digits are preceded by a blank.
(See also %I.) (TZ)
%m The month as a decimal number (range 01 to 12).
%M The minute as a decimal number (range 00 to 59).
%n A newline character. (SU)
%O Modifier: use alternative format, see below. (SU)
%p Either `AM' or `PM' according to the given time
value, or the corresponding strings for the current
locale. Noon is treated as `pm' and midnight as
`am'.
%P Like %p but in lowercase: `am' or `pm' or a corre
sponding string for the current locale. (GNU)
%r The time in a.m. or p.m. notation. In the POSIX
locale this is equivalent to `%I:%M:%S %p'. (SU)
%R The time in 24-hour notation (%H:%M). (SU) For a
version including the seconds, see %T below.
%s The number of seconds since the Epoch, i.e., since
1970-01-01 00:00:00 UTC. (TZ)
%S The second as a decimal number (range 00 to 61).
%t A tab character. (SU)
%T The time in 24-hour notation (%H:%M:%S). (SU)
%u The day of the week as a decimal, range 1 to 7,
Monday being 1. See also %w. (SU)
%U The week number of the current year as a decimal
number, range 00 to 53, starting with the first
Sunday as the first day of week 01. See also %V and
%W.
%V The ISO 8601:1988 week number of the current year
as a decimal number, range 01 to 53, where week 1
is the first week that has at least 4 days in the
current year, and with Monday as the first day of
the week. See also %U and %W. (SU)
%w The day of the week as a decimal, range 0 to 6,
Sunday being 0. See also %u.
%W The week number of the current year as a decimal
number, range 00 to 53, starting with the first
Monday as the first day of week 01.
%x The preferred date representation for the current
locale without the time.
%X The preferred time representation for the current
locale without the date.
%y The year as a decimal number without a century
(range 00 to 99).
%Y The year as a decimal number including the century.
%z The time-zone as hour offset from GMT. Required to
emit RFC822-conformant dates (using "%a, %d %b %Y
%H:%M:%S %z"). (GNU)
%Z The time zone or name or abbreviation.
%+ The date and time in date(1) format. (TZ)
%% A literal `%' character.
Some of these may not work on some systems.
2000-08-02 07:13:12 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
//
|
|
|
|
// game rules mirrored in svs.info
|
|
|
|
//
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *fraglimit;
|
|
|
|
cvar_t *timelimit;
|
|
|
|
cvar_t *teamplay;
|
|
|
|
cvar_t *samelevel;
|
|
|
|
cvar_t *maxclients;
|
|
|
|
cvar_t *maxspectators;
|
|
|
|
cvar_t *deathmatch; // 0, 1, or 2
|
|
|
|
cvar_t *spawn;
|
|
|
|
cvar_t *watervis;
|
2000-05-16 04:47:41 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
cvar_t *hostname;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
QFile *sv_logfile;
|
|
|
|
QFile *sv_fraglogfile;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
void SV_AcceptClient (netadr_t adr, int userid, char *userinfo);
|
|
|
|
void Master_Shutdown (void);
|
|
|
|
void PR_Init_Cvars (void);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
qboolean
|
|
|
|
ServerPaused (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
return sv.paused;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_Shutdown
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Quake calls this before calling Sys_Quit or Sys_Error
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_Shutdown (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
Master_Shutdown ();
|
2000-11-14 16:16:07 +00:00
|
|
|
if (sv_logfile) {
|
2000-09-27 19:44:26 +00:00
|
|
|
Qclose (sv_logfile);
|
2000-05-10 11:29:38 +00:00
|
|
|
sv_logfile = NULL;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
if (sv_fraglogfile) {
|
2000-09-27 19:44:26 +00:00
|
|
|
Qclose (sv_fraglogfile);
|
2000-05-10 11:29:38 +00:00
|
|
|
sv_logfile = NULL;
|
|
|
|
}
|
|
|
|
NET_Shutdown ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_Error
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Sends a datagram to all the clients informing them of the server crash,
|
|
|
|
then exits
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_Error (char *error, ...)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
va_list argptr;
|
|
|
|
static char string[1024];
|
|
|
|
static qboolean inerror = false;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
if (inerror)
|
|
|
|
Sys_Error ("SV_Error: recursively entered (%s)", string);
|
|
|
|
|
|
|
|
inerror = true;
|
|
|
|
|
2000-05-15 08:59:12 +00:00
|
|
|
va_start (argptr, error);
|
2000-11-14 16:16:07 +00:00
|
|
|
vsnprintf (string, sizeof (string), error, argptr);
|
2000-05-10 11:29:38 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Con_Printf ("SV_Error: %s\n", string);
|
|
|
|
|
|
|
|
SV_FinalMessage (va ("server crashed: %s\n", string));
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
SV_Shutdown ();
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Sys_Error ("SV_Error: %s\n", string);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +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.
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_FinalMessage (char *message)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int i;
|
|
|
|
client_t *cl;
|
2000-08-14 13:41:05 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
SZ_Clear (&net_message);
|
|
|
|
MSG_WriteByte (&net_message, svc_print);
|
|
|
|
MSG_WriteByte (&net_message, PRINT_HIGH);
|
|
|
|
MSG_WriteString (&net_message, message);
|
|
|
|
MSG_WriteByte (&net_message, svc_disconnect);
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)
|
2000-05-10 11:29:38 +00:00
|
|
|
if (cl->state >= cs_spawned)
|
2000-11-14 16:16:07 +00:00
|
|
|
Netchan_Transmit (&cl->netchan, net_message.cursize,
|
|
|
|
net_message.data);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_DropClient
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
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.
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_DropClient (client_t *drop)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
// add the disconnect
|
|
|
|
MSG_WriteByte (&drop->netchan.message, svc_disconnect);
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (drop->state == cs_spawned) {
|
|
|
|
if (!drop->spectator) {
|
2000-05-10 11:29:38 +00:00
|
|
|
// call the prog function for removing a client
|
|
|
|
// this will set the body to a dead frame, among other things
|
2000-11-14 16:16:07 +00:00
|
|
|
pr_global_struct->self = EDICT_TO_PROG (drop->edict);
|
2000-05-10 11:29:38 +00:00
|
|
|
PR_ExecuteProgram (pr_global_struct->ClientDisconnect);
|
2000-11-14 16:16:07 +00:00
|
|
|
} else if (SpectatorDisconnect) {
|
2000-05-10 11:29:38 +00:00
|
|
|
// call the prog function for removing a client
|
|
|
|
// this will set the body to a dead frame, among other things
|
2000-11-14 16:16:07 +00:00
|
|
|
pr_global_struct->self = EDICT_TO_PROG (drop->edict);
|
2000-05-10 11:29:38 +00:00
|
|
|
PR_ExecuteProgram (SpectatorDisconnect);
|
|
|
|
}
|
2000-05-10 20:33:16 +00:00
|
|
|
}
|
2000-05-10 11:29:38 +00:00
|
|
|
if (drop->spectator)
|
2000-11-14 16:16:07 +00:00
|
|
|
Con_Printf ("Spectator %s removed\n", drop->name);
|
2000-05-10 11:29:38 +00:00
|
|
|
else
|
2000-11-14 16:16:07 +00:00
|
|
|
Con_Printf ("Client %s removed\n", drop->name);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (drop->download) {
|
2000-09-27 19:44:26 +00:00
|
|
|
Qclose (drop->download);
|
2000-05-10 11:29:38 +00:00
|
|
|
drop->download = NULL;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
if (drop->upload) {
|
2000-09-27 19:44:26 +00:00
|
|
|
Qclose (drop->upload);
|
2000-05-10 11:29:38 +00:00
|
|
|
drop->upload = NULL;
|
|
|
|
}
|
|
|
|
*drop->uploadfn = 0;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
drop->state = cs_zombie; // become free in a few seconds
|
2000-05-10 11:29:38 +00:00
|
|
|
drop->connection_started = realtime; // for zombie timeout
|
|
|
|
|
|
|
|
drop->old_frags = 0;
|
|
|
|
drop->edict->v.frags = 0;
|
|
|
|
drop->name[0] = 0;
|
2000-11-14 16:16:07 +00:00
|
|
|
memset (drop->userinfo, 0, sizeof (drop->userinfo));
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// send notification to all remaining clients
|
2000-05-10 11:29:38 +00:00
|
|
|
SV_FullClientUpdate (drop, &sv.reliable_datagram);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_CalcPing
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
int
|
|
|
|
SV_CalcPing (client_t *cl)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
float ping;
|
|
|
|
int i;
|
|
|
|
int count;
|
|
|
|
register client_frame_t *frame;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
ping = 0;
|
|
|
|
count = 0;
|
2000-11-14 16:16:07 +00:00
|
|
|
for (frame = cl->frames, i = 0; i < UPDATE_BACKUP; i++, frame++) {
|
|
|
|
if (frame->ping_time > 0) {
|
2000-05-10 11:29:38 +00:00
|
|
|
ping += frame->ping_time;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!count)
|
|
|
|
return 9999;
|
|
|
|
ping /= count;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
return ping * 1000;
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_FullClientUpdate
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Writes all update values to a sizebuf
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_FullClientUpdate (client_t *client, sizebuf_t *buf)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int i;
|
|
|
|
char info[MAX_INFO_STRING];
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
i = client - svs.clients;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// Sys_Printf("SV_FullClientUpdate: Updated frags for client %d\n", i);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
MSG_WriteByte (buf, svc_updatefrags);
|
|
|
|
MSG_WriteByte (buf, i);
|
|
|
|
MSG_WriteShort (buf, client->old_frags);
|
2000-11-14 16:16:07 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
MSG_WriteByte (buf, svc_updateping);
|
|
|
|
MSG_WriteByte (buf, i);
|
|
|
|
MSG_WriteShort (buf, SV_CalcPing (client));
|
2000-11-14 16:16:07 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
MSG_WriteByte (buf, svc_updatepl);
|
|
|
|
MSG_WriteByte (buf, i);
|
|
|
|
MSG_WriteByte (buf, client->lossage);
|
2000-11-14 16:16:07 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
MSG_WriteByte (buf, svc_updateentertime);
|
|
|
|
MSG_WriteByte (buf, i);
|
|
|
|
MSG_WriteFloat (buf, realtime - client->connection_started);
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
strncpy (info, client->userinfo, sizeof (info));
|
2000-05-10 11:29:38 +00:00
|
|
|
Info_RemovePrefixedKeys (info, '_'); // server passwords, etc
|
|
|
|
|
|
|
|
MSG_WriteByte (buf, svc_updateuserinfo);
|
|
|
|
MSG_WriteByte (buf, i);
|
|
|
|
MSG_WriteLong (buf, client->userid);
|
|
|
|
MSG_WriteString (buf, info);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_FullClientUpdateToClient
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Writes all update values to a client's reliable stream
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_FullClientUpdateToClient (client_t *client, client_t *cl)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
ClientReliableCheckBlock (cl, 24 + strlen (client->userinfo));
|
2000-05-10 11:29:38 +00:00
|
|
|
if (cl->num_backbuf) {
|
|
|
|
SV_FullClientUpdate (client, &cl->backbuf);
|
2000-11-14 16:16:07 +00:00
|
|
|
ClientReliable_FinishWrite (cl);
|
2000-05-10 11:29:38 +00:00
|
|
|
} else
|
|
|
|
SV_FullClientUpdate (client, &cl->netchan.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
CONNECTIONLESS COMMANDS
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
|
|
|
|
2000-08-13 14:26:20 +00:00
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
CheckForFlood :: EXPERIMENTAL
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Makes it more difficult to use Quake servers for DoS attacks against
|
|
|
|
other sites.
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Bad sides: affects gamespy and spytools somewhat...
|
2000-08-13 14:26:20 +00:00
|
|
|
*/
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
int
|
|
|
|
CheckForFlood (flood_enum_t cmdtype)
|
2000-08-13 14:26:20 +00:00
|
|
|
{
|
2000-08-14 04:53:45 +00:00
|
|
|
static qboolean firsttime = true;
|
|
|
|
static flood_t floodstatus[DOSFLOODCMDS][DOSFLOODIP];
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
int i;
|
|
|
|
double currenttime;
|
|
|
|
double oldestTime;
|
|
|
|
static double lastmessagetime = 0;
|
|
|
|
int oldest;
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (!sv_netdosprotect->int_val)
|
2000-08-14 04:53:45 +00:00
|
|
|
return 0;
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-08-14 04:53:45 +00:00
|
|
|
oldestTime = 0x7fffffff;
|
|
|
|
oldest = 0;
|
2000-08-13 14:26:20 +00:00
|
|
|
|
|
|
|
if (firsttime) {
|
2000-11-14 16:16:07 +00:00
|
|
|
memset (floodstatus, sizeof (flood_t) * DOSFLOODCMDS * DOSFLOODIP, 0);
|
|
|
|
|
2000-08-14 04:53:45 +00:00
|
|
|
firsttime = false;
|
|
|
|
}
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
currenttime = Sys_DoubleTime ();
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < DOSFLOODIP; i++) {
|
2000-08-13 14:26:20 +00:00
|
|
|
if (NET_CompareBaseAdr (net_from, floodstatus[cmdtype][i].adr))
|
|
|
|
break;
|
2000-08-14 04:53:45 +00:00
|
|
|
if (floodstatus[cmdtype][i].issued < oldestTime) {
|
2000-08-13 14:26:20 +00:00
|
|
|
oldestTime = floodstatus[cmdtype][i].issued;
|
|
|
|
oldest = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-14 04:53:45 +00:00
|
|
|
if (i < DOSFLOODIP && floodstatus[cmdtype][i].issued) {
|
2000-08-14 13:02:17 +00:00
|
|
|
if ((floodstatus[cmdtype][i].issued + netdosexpire[cmdtype])
|
2000-11-14 16:16:07 +00:00
|
|
|
> currenttime) {
|
2000-08-14 04:53:45 +00:00
|
|
|
floodstatus[cmdtype][i].floodcount += 1;
|
|
|
|
if (floodstatus[cmdtype][i].floodcount > netdosvalues[cmdtype]) {
|
2000-08-14 13:02:17 +00:00
|
|
|
if ((lastmessagetime + 5) < currenttime)
|
2000-11-14 16:16:07 +00:00
|
|
|
Con_Printf ("Blocking type %d flood from (or to) %s\n",
|
|
|
|
cmdtype, NET_AdrToString (net_from));
|
2000-08-14 04:53:45 +00:00
|
|
|
floodstatus[cmdtype][i].floodcount = 0;
|
2000-08-13 14:26:20 +00:00
|
|
|
floodstatus[cmdtype][i].issued = currenttime;
|
2000-08-14 04:53:45 +00:00
|
|
|
floodstatus[cmdtype][i].cmdcount += 1;
|
|
|
|
lastmessagetime = currenttime;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
floodstatus[cmdtype][i].floodcount = 0;
|
|
|
|
}
|
|
|
|
}
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-08-14 04:53:45 +00:00
|
|
|
if (i == DOSFLOODIP) {
|
2000-08-13 14:26:20 +00:00
|
|
|
i = oldest;
|
|
|
|
floodstatus[cmdtype][i].adr = net_from;
|
2000-08-14 04:53:45 +00:00
|
|
|
floodstatus[cmdtype][i].firstseen = currenttime;
|
2000-11-14 16:16:07 +00:00
|
|
|
floodstatus[cmdtype][i].cmdcount = 0;
|
2000-08-14 13:02:17 +00:00
|
|
|
floodstatus[cmdtype][i].floodcount = 0;
|
2000-08-13 14:26:20 +00:00
|
|
|
}
|
|
|
|
floodstatus[cmdtype][i].issued = currenttime;
|
2000-08-14 04:53:45 +00:00
|
|
|
floodstatus[cmdtype][i].cmdcount += 1;
|
2000-08-13 14:26:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SVC_Status
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Responds with all the info that qplug or qspy can see
|
|
|
|
This message can be up to around 5k with worst case string lengths.
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SVC_Status (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int i;
|
|
|
|
client_t *cl;
|
|
|
|
int ping;
|
|
|
|
int top, bottom;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (!sv_allow_status->int_val)
|
|
|
|
return;
|
|
|
|
if (CheckForFlood (FLOOD_STATUS))
|
|
|
|
return;
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
Cmd_TokenizeString ("status");
|
|
|
|
SV_BeginRedirect (RD_PACKET);
|
|
|
|
Con_Printf ("%s\n", svs.info);
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < MAX_CLIENTS; i++) {
|
2000-05-10 11:29:38 +00:00
|
|
|
cl = &svs.clients[i];
|
2000-11-14 16:16:07 +00:00
|
|
|
if ((cl->state == cs_connected || cl->state == cs_spawned)
|
|
|
|
&& !cl->spectator) {
|
|
|
|
top = atoi (Info_ValueForKey (cl->userinfo, "topcolor"));
|
|
|
|
bottom = atoi (Info_ValueForKey (cl->userinfo, "bottomcolor"));
|
2000-05-10 11:29:38 +00:00
|
|
|
top = (top < 0) ? 0 : ((top > 13) ? 13 : top);
|
|
|
|
bottom = (bottom < 0) ? 0 : ((bottom > 13) ? 13 : bottom);
|
|
|
|
ping = SV_CalcPing (cl);
|
2000-11-14 16:16:07 +00:00
|
|
|
Con_Printf ("%i %i %i %i \"%s\" \"%s\" %i %i\n", cl->userid,
|
|
|
|
cl->old_frags,
|
|
|
|
(int) (realtime - cl->connection_started) / 60, ping,
|
|
|
|
cl->name, Info_ValueForKey (cl->userinfo, "skin"), top,
|
|
|
|
bottom);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SV_EndRedirect ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_CheckLog
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
|
|
|
#define LOG_HIGHWATER 4096
|
|
|
|
#define LOG_FLUSH 10*60
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_CheckLog (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
sizebuf_t *sz;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
sz = &svs.log[svs.logsequence & 1];
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
// bump sequence if allmost full, or ten minutes have passed and
|
|
|
|
// there is something still sitting there
|
|
|
|
if (sz->cursize > LOG_HIGHWATER
|
2000-11-14 16:16:07 +00:00
|
|
|
|| (realtime - svs.logtime > LOG_FLUSH && sz->cursize)) {
|
2000-05-10 11:29:38 +00:00
|
|
|
// swap buffers and bump sequence
|
|
|
|
svs.logtime = realtime;
|
|
|
|
svs.logsequence++;
|
2000-11-14 16:16:07 +00:00
|
|
|
sz = &svs.log[svs.logsequence & 1];
|
2000-05-10 11:29:38 +00:00
|
|
|
sz->cursize = 0;
|
|
|
|
Con_Printf ("beginning fraglog sequence %i\n", svs.logsequence);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +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.
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SVC_Log (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int seq;
|
|
|
|
char data[MAX_DATAGRAM + 64];
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (!sv_allow_log->int_val)
|
|
|
|
return;
|
|
|
|
if (CheckForFlood (FLOOD_LOG))
|
|
|
|
return;
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (Cmd_Argc () == 2)
|
|
|
|
seq = atoi (Cmd_Argv (1));
|
2000-05-10 11:29:38 +00:00
|
|
|
else
|
|
|
|
seq = -1;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (seq == svs.logsequence - 1 || !sv_fraglogfile) { // they allready
|
|
|
|
// have this
|
|
|
|
// data, or we
|
|
|
|
// aren't logging
|
|
|
|
// frags
|
2000-05-10 11:29:38 +00:00
|
|
|
data[0] = A2A_NACK;
|
|
|
|
NET_SendPacket (1, data, net_from);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Con_DPrintf ("sending log %i to %s\n", svs.logsequence - 1,
|
|
|
|
NET_AdrToString (net_from));
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// sprintf (data, "stdlog %i\n", svs.logsequence-1);
|
|
|
|
// strcat (data, (char *)svs.log_buf[((svs.logsequence-1)&1)]);
|
|
|
|
snprintf (data, sizeof (data), "stdlog %i\n%s",
|
|
|
|
svs.logsequence - 1,
|
|
|
|
(char *) svs.log_buf[((svs.logsequence - 1) & 1)]);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
NET_SendPacket (strlen (data) + 1, data, net_from);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SVC_Ping
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Just responds with an acknowledgement
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SVC_Ping (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
char data;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (!sv_allow_ping->int_val)
|
|
|
|
return;
|
|
|
|
if (CheckForFlood (FLOOD_PING))
|
|
|
|
return;
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
data = A2A_ACK;
|
|
|
|
|
|
|
|
NET_SendPacket (1, &data, net_from);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +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.
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SVC_GetChallenge (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int i;
|
|
|
|
int oldest;
|
|
|
|
int oldestTime;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
oldest = 0;
|
|
|
|
oldestTime = 0x7fffffff;
|
|
|
|
|
|
|
|
// see if we already have a challenge for this ip
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < MAX_CHALLENGES; i++) {
|
2000-05-10 11:29:38 +00:00
|
|
|
if (NET_CompareBaseAdr (net_from, svs.challenges[i].adr))
|
|
|
|
break;
|
2000-11-14 16:16:07 +00:00
|
|
|
if (svs.challenges[i].time < oldestTime) {
|
2000-05-10 11:29:38 +00:00
|
|
|
oldestTime = svs.challenges[i].time;
|
|
|
|
oldest = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (i == MAX_CHALLENGES) {
|
2000-05-10 11:29:38 +00:00
|
|
|
// overwrite the oldest
|
2000-11-14 16:16:07 +00:00
|
|
|
svs.challenges[oldest].challenge = (rand () << 16) ^ rand ();
|
2000-05-10 11:29:38 +00:00
|
|
|
svs.challenges[oldest].adr = net_from;
|
|
|
|
svs.challenges[oldest].time = realtime;
|
|
|
|
i = oldest;
|
|
|
|
}
|
|
|
|
// send it back
|
2000-10-04 16:22:51 +00:00
|
|
|
Netchan_OutOfBandPrint (net_from, "%c%i QF", S2C_CHALLENGE,
|
2000-11-14 16:16:07 +00:00
|
|
|
svs.challenges[i].challenge);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SVC_DirectConnect
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
A connection request that did not come from the master
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SVC_DirectConnect (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
char userinfo[1024];
|
|
|
|
static int userid;
|
|
|
|
netadr_t adr;
|
|
|
|
int i;
|
|
|
|
client_t *cl, *newcl;
|
|
|
|
client_t temp;
|
|
|
|
edict_t *ent;
|
|
|
|
int edictnum;
|
|
|
|
char *s;
|
|
|
|
int clients, spectators;
|
|
|
|
qboolean spectator;
|
|
|
|
int qport;
|
|
|
|
int version;
|
|
|
|
int challenge;
|
|
|
|
|
|
|
|
if (CheckForFlood (FLOOD_CONNECT))
|
|
|
|
return;
|
|
|
|
|
|
|
|
version = atoi (Cmd_Argv (1));
|
|
|
|
if (version != PROTOCOL_VERSION) {
|
|
|
|
Netchan_OutOfBandPrint (net_from, "%c\nServer is version %s.\n",
|
|
|
|
A2C_PRINT, QW_VERSION);
|
2000-05-10 11:29:38 +00:00
|
|
|
Con_Printf ("* rejected connect from version %i\n", version);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
qport = atoi (Cmd_Argv (2));
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
challenge = atoi (Cmd_Argv (3));
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
// note an extra byte is needed to replace spectator key
|
2000-11-14 16:16:07 +00:00
|
|
|
strncpy (userinfo, Cmd_Argv (4), sizeof (userinfo) - 2);
|
|
|
|
userinfo[sizeof (userinfo) - 2] = 0;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
// see if the challenge is valid
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < MAX_CHALLENGES; i++) {
|
|
|
|
if (NET_CompareBaseAdr (net_from, svs.challenges[i].adr)) {
|
2000-05-10 11:29:38 +00:00
|
|
|
if (challenge == svs.challenges[i].challenge)
|
2000-11-14 16:16:07 +00:00
|
|
|
break; // good
|
|
|
|
Netchan_OutOfBandPrint (net_from, "%c\nBad challenge.\n",
|
|
|
|
A2C_PRINT);
|
2000-05-10 11:29:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
if (i == MAX_CHALLENGES) {
|
|
|
|
Netchan_OutOfBandPrint (net_from, "%c\nNo challenge for address.\n",
|
|
|
|
A2C_PRINT);
|
2000-05-10 11:29:38 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-11-25 14:20:04 +00:00
|
|
|
|
|
|
|
s = Info_ValueForKey (userinfo, "*qf_version");
|
|
|
|
if ((!s[0]) || sv_minqfversion->value) { // kick old clients?
|
2000-11-26 09:48:01 +00:00
|
|
|
if (ver_compare (s, sv_minqfversion->string) < 0) {
|
|
|
|
Con_Printf ("%s: Version %s is less than minimum version %s.\n",
|
|
|
|
NET_AdrToString (net_from), s, sv_minqfversion->string);
|
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
Netchan_OutOfBandPrint (net_from,
|
2000-11-26 09:48:01 +00:00
|
|
|
"%c\nserver requires QuakeForge v%s or greater. Get it from http://www.quakeforge.net/\n",
|
|
|
|
A2C_PRINT, sv_minqfversion->string);
|
2000-11-25 14:20:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2000-05-10 11:29:38 +00:00
|
|
|
// check for password or spectator_password
|
|
|
|
s = Info_ValueForKey (userinfo, "spectator");
|
2000-11-14 16:16:07 +00:00
|
|
|
if (s[0] && strcmp (s, "0")) {
|
2000-08-14 13:02:17 +00:00
|
|
|
if (spectator_password->string[0] &&
|
2000-11-14 16:16:07 +00:00
|
|
|
stricmp (spectator_password->string, "none") &&
|
|
|
|
strcmp (spectator_password->string, s)) { // failed
|
|
|
|
Con_Printf ("%s:spectator password failed\n",
|
|
|
|
NET_AdrToString (net_from));
|
|
|
|
Netchan_OutOfBandPrint (net_from,
|
|
|
|
"%c\nrequires a spectator password\n\n",
|
|
|
|
A2C_PRINT);
|
2000-05-10 11:29:38 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
Info_RemoveKey (userinfo, "spectator"); // remove passwd
|
2000-05-10 11:29:38 +00:00
|
|
|
Info_SetValueForStarKey (userinfo, "*spectator", "1", MAX_INFO_STRING);
|
|
|
|
spectator = true;
|
2000-11-14 16:16:07 +00:00
|
|
|
} else {
|
2000-05-10 11:29:38 +00:00
|
|
|
s = Info_ValueForKey (userinfo, "password");
|
2000-11-14 16:16:07 +00:00
|
|
|
if (password->string[0] &&
|
|
|
|
stricmp (password->string, "none") && strcmp (password->string, s)) {
|
2000-05-10 11:29:38 +00:00
|
|
|
Con_Printf ("%s:password failed\n", NET_AdrToString (net_from));
|
2000-11-14 16:16:07 +00:00
|
|
|
Netchan_OutOfBandPrint (net_from,
|
|
|
|
"%c\nserver requires a password\n\n",
|
|
|
|
A2C_PRINT);
|
2000-05-10 11:29:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
spectator = false;
|
2000-11-14 16:16:07 +00:00
|
|
|
Info_RemoveKey (userinfo, "password"); // remove passwd
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
adr = net_from;
|
2000-11-14 16:16:07 +00:00
|
|
|
userid++; // so every client gets a unique id
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
newcl = &temp;
|
2000-11-14 16:16:07 +00:00
|
|
|
memset (newcl, 0, sizeof (client_t));
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
newcl->userid = userid;
|
|
|
|
|
|
|
|
// works properly
|
2000-10-17 03:17:42 +00:00
|
|
|
if (!sv_highchars->int_val) {
|
2000-11-14 16:16:07 +00:00
|
|
|
byte *p, *q;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
for (p = (byte *) newcl->userinfo, q = (byte *) userinfo;
|
|
|
|
*q && p < (byte *) newcl->userinfo + sizeof (newcl->userinfo) - 1;
|
|
|
|
q++)
|
2000-05-10 11:29:38 +00:00
|
|
|
if (*q > 31 && *q <= 127)
|
|
|
|
*p++ = *q;
|
|
|
|
} else
|
2000-11-14 16:16:07 +00:00
|
|
|
strncpy (newcl->userinfo, userinfo, sizeof (newcl->userinfo) - 1);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
// if there is allready a slot for this ip, drop it
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
2000-05-10 11:29:38 +00:00
|
|
|
if (cl->state == cs_free)
|
|
|
|
continue;
|
|
|
|
if (NET_CompareBaseAdr (adr, cl->netchan.remote_address)
|
2000-11-14 16:16:07 +00:00
|
|
|
&& (cl->netchan.qport == qport
|
|
|
|
|| adr.port == cl->netchan.remote_address.port)) {
|
2000-05-10 11:29:38 +00:00
|
|
|
if (cl->state == cs_connected) {
|
2000-11-14 16:16:07 +00:00
|
|
|
Con_Printf ("%s:dup connect\n", NET_AdrToString (adr));
|
2000-05-10 11:29:38 +00:00
|
|
|
userid--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Con_Printf ("%s:reconnect\n", NET_AdrToString (adr));
|
|
|
|
SV_DropClient (cl);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// count up the clients and spectators
|
|
|
|
clients = 0;
|
|
|
|
spectators = 0;
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
2000-05-10 11:29:38 +00:00
|
|
|
if (cl->state == cs_free)
|
|
|
|
continue;
|
|
|
|
if (cl->spectator)
|
|
|
|
spectators++;
|
|
|
|
else
|
|
|
|
clients++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if at server limits, refuse connection
|
2000-11-14 16:16:07 +00:00
|
|
|
if (maxclients->int_val > MAX_CLIENTS)
|
2000-05-17 23:16:23 +00:00
|
|
|
Cvar_SetValue (maxclients, MAX_CLIENTS);
|
2000-10-17 03:17:42 +00:00
|
|
|
if (maxspectators->int_val > MAX_CLIENTS)
|
2000-05-17 23:16:23 +00:00
|
|
|
Cvar_SetValue (maxspectators, MAX_CLIENTS);
|
2000-10-17 03:17:42 +00:00
|
|
|
if (maxspectators->int_val + maxclients->int_val > MAX_CLIENTS)
|
2000-11-14 16:16:07 +00:00
|
|
|
Cvar_SetValue (maxspectators, MAX_CLIENTS - maxclients->int_val);
|
|
|
|
if ((spectator && spectators >= maxspectators->int_val)
|
|
|
|
|| (!spectator && clients >= maxclients->int_val)) {
|
2000-05-10 11:29:38 +00:00
|
|
|
Con_Printf ("%s:full connect\n", NET_AdrToString (adr));
|
|
|
|
Netchan_OutOfBandPrint (adr, "%c\nserver is full\n\n", A2C_PRINT);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// find a client slot
|
|
|
|
newcl = NULL;
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
|
|
|
if (cl->state == cs_free) {
|
2000-05-10 11:29:38 +00:00
|
|
|
newcl = cl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
if (!newcl) {
|
2000-05-10 11:29:38 +00:00
|
|
|
Con_Printf ("WARNING: miscounted available clients\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// build a new connection
|
|
|
|
// accept the new client
|
|
|
|
// this is the only place a client_t is ever initialized
|
|
|
|
*newcl = temp;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Netchan_OutOfBandPrint (adr, "%c", S2C_CONNECTION);
|
|
|
|
|
|
|
|
edictnum = (newcl - svs.clients) + 1;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Netchan_Setup (&newcl->netchan, adr, qport);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
newcl->state = cs_connected;
|
|
|
|
|
|
|
|
newcl->datagram.allowoverflow = true;
|
|
|
|
newcl->datagram.data = newcl->datagram_buf;
|
2000-11-14 16:16:07 +00:00
|
|
|
newcl->datagram.maxsize = sizeof (newcl->datagram_buf);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
// spectator mode can ONLY be set at join time
|
|
|
|
newcl->spectator = spectator;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
ent = EDICT_NUM (edictnum);
|
2000-05-10 11:29:38 +00:00
|
|
|
newcl->edict = ent;
|
2000-11-14 16:16:07 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
// parse some info from the info strings
|
|
|
|
SV_ExtractFromUserinfo (newcl);
|
|
|
|
|
|
|
|
// JACK: Init the floodprot stuff.
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < 10; i++)
|
2000-05-10 11:29:38 +00:00
|
|
|
newcl->whensaid[i] = 0.0;
|
|
|
|
newcl->whensaidhead = 0;
|
|
|
|
newcl->lockedtill = 0;
|
|
|
|
|
|
|
|
// call the progs to get default spawn parms for the new client
|
|
|
|
PR_ExecuteProgram (pr_global_struct->SetNewParms);
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < NUM_SPAWN_PARMS; i++)
|
2000-05-10 11:29:38 +00:00
|
|
|
newcl->spawn_parms[i] = (&pr_global_struct->parm1)[i];
|
|
|
|
|
|
|
|
if (newcl->spectator)
|
|
|
|
Con_Printf ("Spectator %s connected\n", newcl->name);
|
|
|
|
else
|
|
|
|
Con_DPrintf ("Client %s connected\n", newcl->name);
|
|
|
|
newcl->sendinfo = true;
|
2000-05-15 08:59:12 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// QuakeForge stuff.
|
|
|
|
newcl->msecs = 0;
|
|
|
|
newcl->msec_cheating = 0;
|
2000-11-26 12:43:49 +00:00
|
|
|
newcl->last_check = -1;
|
2000-05-15 08:59:12 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
int
|
|
|
|
Rcon_Validate (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-05-16 04:47:41 +00:00
|
|
|
if (!strlen (rcon_password->string))
|
2000-05-10 11:29:38 +00:00
|
|
|
return 0;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (strcmp (Cmd_Argv (1), rcon_password->string))
|
2000-05-10 11:29:38 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SVC_RemoteCommand
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
A client issued an rcon command.
|
|
|
|
Shift down the remaining args
|
|
|
|
Redirect all printfs
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SVC_RemoteCommand (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int i;
|
|
|
|
int len = 0;
|
|
|
|
char remaining[1024];
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (CheckForFlood (FLOOD_RCON))
|
|
|
|
return;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
if (!Rcon_Validate ()) {
|
2000-11-14 16:16:07 +00:00
|
|
|
Con_Printf ("Bad rcon from %s:\n%s\n", NET_AdrToString (net_from),
|
|
|
|
net_message.data + 4);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
SV_BeginRedirect (RD_PACKET);
|
|
|
|
|
|
|
|
Con_Printf ("Bad rcon_password.\n");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
remaining[0] = 0;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 2; i < Cmd_Argc (); i++) {
|
|
|
|
strncat (remaining, Cmd_Argv (i), sizeof (remaining) - len - 1);
|
2000-10-20 18:03:26 +00:00
|
|
|
strncat (remaining, " ", sizeof (remaining) - len - 2);
|
|
|
|
len += strlen (Cmd_Argv (i)) + 1; // +1 for " "
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Con_Printf ("Rcon from %s:\nrcon (hidden) %s\n",
|
|
|
|
NET_AdrToString (net_from), remaining);
|
2000-10-20 18:03:26 +00:00
|
|
|
|
|
|
|
SV_BeginRedirect (RD_PACKET);
|
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
Cmd_ExecuteString (remaining);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SV_EndRedirect ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_ConnectionlessPacket
|
|
|
|
|
|
|
|
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.
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_ConnectionlessPacket (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
char *s;
|
|
|
|
char *c;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
MSG_BeginReading ();
|
2000-11-14 16:16:07 +00:00
|
|
|
MSG_ReadLong (); // skip the -1 marker
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
s = MSG_ReadStringLine ();
|
|
|
|
|
|
|
|
Cmd_TokenizeString (s);
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
c = Cmd_Argv (0);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (!strcmp (c, "ping")
|
|
|
|
|| (c[0] == A2A_PING && (c[1] == 0 || c[1] == '\n'))) {
|
2000-05-10 11:29:38 +00:00
|
|
|
SVC_Ping ();
|
|
|
|
return;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
if (c[0] == A2A_ACK && (c[1] == 0 || c[1] == '\n')) {
|
2000-05-10 11:29:38 +00:00
|
|
|
Con_Printf ("A2A_ACK from %s\n", NET_AdrToString (net_from));
|
|
|
|
return;
|
2000-11-14 16:16:07 +00:00
|
|
|
} else if (!strcmp (c, "status")) {
|
2000-05-10 11:29:38 +00:00
|
|
|
SVC_Status ();
|
|
|
|
return;
|
2000-11-14 16:16:07 +00:00
|
|
|
} else if (!strcmp (c, "log")) {
|
2000-05-10 11:29:38 +00:00
|
|
|
SVC_Log ();
|
|
|
|
return;
|
2000-11-14 16:16:07 +00:00
|
|
|
} else if (!strcmp (c, "connect")) {
|
2000-05-10 11:29:38 +00:00
|
|
|
SVC_DirectConnect ();
|
|
|
|
return;
|
2000-11-14 16:16:07 +00:00
|
|
|
} else if (!strcmp (c, "getchallenge")) {
|
2000-05-10 11:29:38 +00:00
|
|
|
SVC_GetChallenge ();
|
|
|
|
return;
|
2000-11-14 16:16:07 +00:00
|
|
|
} else if (!strcmp (c, "rcon"))
|
2000-05-10 11:29:38 +00:00
|
|
|
SVC_RemoteCommand ();
|
|
|
|
else
|
2000-11-14 16:16:07 +00:00
|
|
|
Con_Printf ("bad connectionless packet from %s:\n%s\n",
|
|
|
|
NET_AdrToString (net_from), s);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
PACKET FILTERING
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
You can add or remove addresses from the filter list with:
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
addip <ip>
|
|
|
|
removeip <ip>
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
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".
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Removeip will only remove an address specified exactly the same way.
|
|
|
|
You cannot addip a subnet, then removeip a single host.
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
listip
|
|
|
|
Prints the current list of filters.
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
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.
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
filterban <0 or 1>
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
If 1 (the default), then ip addresses matching the current list will be
|
|
|
|
prohibited from entering the game. This is the default setting.
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
If 0, then only addresses matching the list will be allowed. This lets
|
|
|
|
you easily set up a private game, or a game that only allows players
|
|
|
|
from your local network.
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
typedef struct {
|
|
|
|
unsigned int mask;
|
|
|
|
unsigned int compare;
|
2000-05-10 11:29:38 +00:00
|
|
|
} ipfilter_t;
|
|
|
|
|
|
|
|
#define MAX_IPFILTERS 1024
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
ipfilter_t ipfilters[MAX_IPFILTERS];
|
|
|
|
int numipfilters;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
cvar_t *filterban;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
StringToFilter
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
qboolean
|
|
|
|
StringToFilter (char *s, ipfilter_t * f)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
char num[128];
|
|
|
|
int i, j;
|
|
|
|
byte b[4];
|
|
|
|
byte m[4];
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
2000-05-10 11:29:38 +00:00
|
|
|
b[i] = 0;
|
|
|
|
m[i] = 0;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
if (*s < '0' || *s > '9') {
|
2000-05-10 11:29:38 +00:00
|
|
|
Con_Printf ("Bad filter address: %s\n", s);
|
|
|
|
return false;
|
|
|
|
}
|
2000-08-14 13:02:17 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
j = 0;
|
2000-11-14 16:16:07 +00:00
|
|
|
while (*s >= '0' && *s <= '9') {
|
2000-05-10 11:29:38 +00:00
|
|
|
num[j++] = *s++;
|
|
|
|
}
|
|
|
|
num[j] = 0;
|
2000-11-14 16:16:07 +00:00
|
|
|
b[i] = atoi (num);
|
2000-05-10 11:29:38 +00:00
|
|
|
if (b[i] != 0)
|
|
|
|
m[i] = 255;
|
|
|
|
|
|
|
|
if (!*s)
|
|
|
|
break;
|
|
|
|
s++;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
|
|
|
|
f->mask = *(unsigned int *) m;
|
|
|
|
f->compare = *(unsigned int *) b;
|
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_AddIP_f
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_AddIP_f (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < numipfilters; i++)
|
2000-05-10 11:29:38 +00:00
|
|
|
if (ipfilters[i].compare == 0xffffffff)
|
2000-11-14 16:16:07 +00:00
|
|
|
break; // free spot
|
|
|
|
if (i == numipfilters) {
|
|
|
|
if (numipfilters == MAX_IPFILTERS) {
|
2000-05-10 11:29:38 +00:00
|
|
|
Con_Printf ("IP filter list is full\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
numipfilters++;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
|
|
|
|
if (!StringToFilter (Cmd_Argv (1), &ipfilters[i]))
|
2000-05-10 11:29:38 +00:00
|
|
|
ipfilters[i].compare = 0xffffffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_RemoveIP_f
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_RemoveIP_f (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
ipfilter_t f;
|
|
|
|
int i, j;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (!StringToFilter (Cmd_Argv (1), &f))
|
2000-05-10 11:29:38 +00:00
|
|
|
return;
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < numipfilters; i++)
|
|
|
|
if (ipfilters[i].mask == f.mask && ipfilters[i].compare == f.compare) {
|
|
|
|
for (j = i + 1; j < numipfilters; j++)
|
|
|
|
ipfilters[j - 1] = ipfilters[j];
|
2000-05-10 11:29:38 +00:00
|
|
|
numipfilters--;
|
|
|
|
Con_Printf ("Removed.\n");
|
|
|
|
return;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
Con_Printf ("Didn't find %s.\n", Cmd_Argv (1));
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_ListIP_f
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_ListIP_f (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int i;
|
|
|
|
byte b[4];
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
Con_Printf ("Filter list:\n");
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < numipfilters; i++) {
|
|
|
|
*(unsigned int *) b = ipfilters[i].compare;
|
2000-05-10 11:29:38 +00:00
|
|
|
Con_Printf ("%3i.%3i.%3i.%3i\n", b[0], b[1], b[2], b[3]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_WriteIP_f
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_WriteIP_f (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
QFile *f;
|
|
|
|
char name[MAX_OSPATH];
|
|
|
|
byte b[4];
|
|
|
|
int i;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
snprintf (name, sizeof (name), "%s/listip.cfg", com_gamedir);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
Con_Printf ("Writing %s.\n", name);
|
|
|
|
|
2000-09-27 19:44:26 +00:00
|
|
|
f = Qopen (name, "wb");
|
2000-11-14 16:16:07 +00:00
|
|
|
if (!f) {
|
2000-05-10 11:29:38 +00:00
|
|
|
Con_Printf ("Couldn't open %s\n", name);
|
|
|
|
return;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
|
|
|
|
for (i = 0; i < numipfilters; i++) {
|
|
|
|
*(unsigned int *) b = ipfilters[i].compare;
|
2000-09-27 19:44:26 +00:00
|
|
|
Qprintf (f, "addip %i.%i.%i.%i\n", b[0], b[1], b[2], b[3]);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
|
2000-09-27 19:44:26 +00:00
|
|
|
Qclose (f);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
2000-08-13 14:34:49 +00:00
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
netDoSexpire_f
|
2000-08-13 14:34:49 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_netDoSexpire_f (void)
|
2000-08-13 14:34:49 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int arg1;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (Cmd_Argc () == 1) {
|
|
|
|
Con_Printf ("Current DoS prot. expire settings: ");
|
|
|
|
for (i = 0; i < DOSFLOODCMDS; i++)
|
|
|
|
Con_Printf ("%f ", netdosexpire[i]);
|
|
|
|
Con_Printf ("\n");
|
|
|
|
if (!sv_netdosprotect->int_val)
|
|
|
|
Con_Printf ("(disabled)\n");
|
|
|
|
return;
|
2000-08-13 14:34:49 +00:00
|
|
|
}
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (Cmd_Argc () != DOSFLOODCMDS + 1) {
|
|
|
|
Con_Printf
|
|
|
|
("Usage: netdosexpire <ping> <log> <connect> <status> <rcon> <ban>\n");
|
2000-08-13 14:34:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < DOSFLOODCMDS; i++) {
|
|
|
|
arg1 = atoi (Cmd_Argv (i + 1));
|
|
|
|
if (arg1 > 0)
|
|
|
|
netdosexpire[i] = arg1;
|
|
|
|
}
|
|
|
|
return;
|
2000-08-13 14:34:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
DoSvalues_f
|
2000-08-13 14:34:49 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_netDoSvalues_f (void)
|
2000-08-13 14:34:49 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int arg1;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (Cmd_Argc () == 1) {
|
|
|
|
Con_Printf ("Current DoS prot. value settings: ");
|
|
|
|
for (i = 0; i < DOSFLOODCMDS; i++)
|
|
|
|
Con_Printf ("%f ", netdosvalues[i]);
|
|
|
|
Con_Printf ("\n");
|
|
|
|
if (!sv_netdosprotect->int_val)
|
|
|
|
Con_Printf ("(disabled)\n");
|
|
|
|
return;
|
2000-08-13 14:34:49 +00:00
|
|
|
}
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (Cmd_Argc () != DOSFLOODCMDS + 1) {
|
|
|
|
Con_Printf
|
|
|
|
("Usage: netdosvalues <ping> <log> <connect> <status> <rcon> <ban>\n");
|
2000-08-13 14:34:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < DOSFLOODCMDS; i++) {
|
|
|
|
arg1 = atoi (Cmd_Argv (i + 1));
|
|
|
|
if (arg1 > 0)
|
|
|
|
netdosvalues[i] = arg1;
|
|
|
|
}
|
|
|
|
return;
|
2000-08-13 14:34:49 +00:00
|
|
|
}
|
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_SendBan
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_SendBan (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
char data[128];
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (CheckForFlood (FLOOD_BAN))
|
|
|
|
return;
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
data[0] = data[1] = data[2] = data[3] = 0xff;
|
|
|
|
data[4] = A2C_PRINT;
|
|
|
|
data[5] = 0;
|
|
|
|
strcat (data, "\nbanned.\n");
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
NET_SendPacket (strlen (data), data, net_from);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_FilterPacket
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
qboolean
|
|
|
|
SV_FilterPacket (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int i;
|
|
|
|
unsigned int in;
|
|
|
|
|
|
|
|
in = *(unsigned int *) net_from.ip;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < numipfilters; i++)
|
|
|
|
if ((in & ipfilters[i].mask) == ipfilters[i].compare)
|
2000-10-17 03:17:42 +00:00
|
|
|
return filterban->int_val;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
return !filterban->int_val; // FIXME eh?
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_ReadPackets
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_ReadPackets (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int i;
|
|
|
|
client_t *cl;
|
|
|
|
qboolean good;
|
|
|
|
int qport;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
good = false;
|
2000-11-14 16:16:07 +00:00
|
|
|
while (NET_GetPacket ()) {
|
|
|
|
if (SV_FilterPacket ()) {
|
|
|
|
SV_SendBan (); // tell them we aren't listening...
|
2000-05-10 11:29:38 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// check for connectionless packet (0xffffffff) first
|
2000-11-14 16:16:07 +00:00
|
|
|
if (*(int *) net_message.data == -1) {
|
2000-05-10 11:29:38 +00:00
|
|
|
SV_ConnectionlessPacket ();
|
|
|
|
continue;
|
|
|
|
}
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (net_message.cursize < 11) {
|
|
|
|
Con_Printf ("%s: Runt packet\n", NET_AdrToString (net_from));
|
2000-08-14 13:41:05 +00:00
|
|
|
continue;
|
|
|
|
}
|
2000-05-10 11:29:38 +00:00
|
|
|
// read the qport out of the message so we can fix up
|
|
|
|
// stupid address translating routers
|
|
|
|
MSG_BeginReading ();
|
2000-11-14 16:16:07 +00:00
|
|
|
MSG_ReadLong (); // sequence number
|
|
|
|
MSG_ReadLong (); // sequence number
|
2000-05-10 11:29:38 +00:00
|
|
|
qport = MSG_ReadShort () & 0xffff;
|
|
|
|
|
|
|
|
// check for packets from connected clients
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
2000-05-10 11:29:38 +00:00
|
|
|
if (cl->state == cs_free)
|
|
|
|
continue;
|
|
|
|
if (!NET_CompareBaseAdr (net_from, cl->netchan.remote_address))
|
|
|
|
continue;
|
|
|
|
if (cl->netchan.qport != qport)
|
|
|
|
continue;
|
2000-11-14 16:16:07 +00:00
|
|
|
if (cl->netchan.remote_address.port != net_from.port) {
|
2000-05-10 11:29:38 +00:00
|
|
|
Con_DPrintf ("SV_ReadPackets: fixing up a translated port\n");
|
|
|
|
cl->netchan.remote_address.port = net_from.port;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
if (Netchan_Process (&cl->netchan)) { // this is a valid,
|
|
|
|
// sequenced packet, so
|
|
|
|
// process it
|
2000-05-10 11:29:38 +00:00
|
|
|
svs.stats.packets++;
|
|
|
|
good = true;
|
|
|
|
cl->send_message = true; // reply at end of frame
|
|
|
|
if (cl->state != cs_zombie)
|
|
|
|
SV_ExecuteClientMessage (cl);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2000-08-14 13:02:17 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
if (i != MAX_CLIENTS)
|
|
|
|
continue;
|
2000-08-14 13:41:05 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
// packet is not from a known client
|
2000-11-14 16:16:07 +00:00
|
|
|
// Con_Printf ("%s:sequenced packet without connection\n"
|
2000-05-10 11:29:38 +00:00
|
|
|
// ,NET_AdrToString(net_from));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_CheckTimeouts
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
If a packet has not been received from a client in timeout.value
|
|
|
|
seconds, drop the conneciton.
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +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
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_CheckTimeouts (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int i;
|
|
|
|
client_t *cl;
|
|
|
|
float droptime;
|
|
|
|
int nclients;
|
|
|
|
|
2000-05-16 04:47:41 +00:00
|
|
|
droptime = realtime - timeout->value;
|
2000-05-10 11:29:38 +00:00
|
|
|
nclients = 0;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
|
2000-05-10 11:29:38 +00:00
|
|
|
if (cl->state == cs_connected || cl->state == cs_spawned) {
|
|
|
|
if (!cl->spectator)
|
|
|
|
nclients++;
|
|
|
|
if (cl->netchan.last_received < droptime) {
|
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "%s timed out\n", cl->name);
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_DropClient (cl);
|
2000-05-10 11:29:38 +00:00
|
|
|
cl->state = cs_free; // don't bother with zombie state
|
|
|
|
}
|
|
|
|
}
|
2000-08-13 14:26:20 +00:00
|
|
|
if (cl->state == cs_zombie &&
|
2000-11-14 16:16:07 +00:00
|
|
|
realtime - cl->connection_started > zombietime->value) {
|
|
|
|
cl->state = cs_free; // can now be reused
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sv.paused && !nclients) {
|
|
|
|
// nobody left, unpause the server
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_TogglePause ("Pause released since no players are left.\n");
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_GetConsoleCommands
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Add them exactly as if they had been typed at the console
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_GetConsoleCommands (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
char *cmd;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
while (1) {
|
2000-05-10 11:29:38 +00:00
|
|
|
cmd = Sys_ConsoleInput ();
|
|
|
|
if (!cmd)
|
|
|
|
break;
|
|
|
|
Cbuf_AddText (cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_CheckVars
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_CheckVars (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
static char *pw, *spw;
|
2000-11-14 16:16:07 +00:00
|
|
|
int v;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-05-16 04:47:41 +00:00
|
|
|
if (password->string == pw && spectator_password->string == spw)
|
2000-05-10 11:29:38 +00:00
|
|
|
return;
|
2000-05-16 04:47:41 +00:00
|
|
|
pw = password->string;
|
|
|
|
spw = spectator_password->string;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
v = 0;
|
2000-11-14 16:16:07 +00:00
|
|
|
if (pw && pw[0] && strcmp (pw, "none"))
|
2000-05-10 11:29:38 +00:00
|
|
|
v |= 1;
|
2000-11-14 16:16:07 +00:00
|
|
|
if (spw && spw[0] && strcmp (spw, "none"))
|
2000-05-10 11:29:38 +00:00
|
|
|
v |= 2;
|
|
|
|
|
|
|
|
Con_Printf ("Updated needpass.\n");
|
|
|
|
if (!v)
|
|
|
|
Info_SetValueForKey (svs.info, "needpass", "", MAX_SERVERINFO_STRING);
|
|
|
|
else
|
2000-11-14 16:16:07 +00:00
|
|
|
Info_SetValueForKey (svs.info, "needpass", va ("%i", v),
|
|
|
|
MAX_SERVERINFO_STRING);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_Frame
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_Frame (float time)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
static double start, end;
|
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
start = Sys_DoubleTime ();
|
|
|
|
svs.stats.idle += start - end;
|
2000-11-14 16:16:07 +00:00
|
|
|
|
|
|
|
// keep the random time dependent
|
2000-05-10 11:29:38 +00:00
|
|
|
rand ();
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// decide the simulation time
|
2000-05-10 11:29:38 +00:00
|
|
|
if (!sv.paused) {
|
|
|
|
realtime += time;
|
|
|
|
sv.time += time;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
// check timeouts
|
2000-05-10 11:29:38 +00:00
|
|
|
SV_CheckTimeouts ();
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// toggle the log buffer if full
|
2000-05-10 11:29:38 +00:00
|
|
|
SV_CheckLog ();
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// move autonomous things around if enough time has passed
|
2000-05-10 11:29:38 +00:00
|
|
|
if (!sv.paused)
|
|
|
|
SV_Physics ();
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// get packets
|
2000-05-10 11:29:38 +00:00
|
|
|
SV_ReadPackets ();
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// check for commands typed to the host
|
2000-05-10 11:29:38 +00:00
|
|
|
SV_GetConsoleCommands ();
|
2000-11-14 16:16:07 +00:00
|
|
|
|
|
|
|
// process console commands
|
2000-05-10 11:29:38 +00:00
|
|
|
Cbuf_Execute ();
|
|
|
|
|
|
|
|
SV_CheckVars ();
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// send messages back to the clients that had packets read this frame
|
2000-05-10 11:29:38 +00:00
|
|
|
SV_SendClientMessages ();
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// send a heartbeat to the master if needed
|
2000-05-10 11:29:38 +00:00
|
|
|
Master_Heartbeat ();
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// collect timing statistics
|
2000-05-10 11:29:38 +00:00
|
|
|
end = Sys_DoubleTime ();
|
2000-11-14 16:16:07 +00:00
|
|
|
svs.stats.active += end - start;
|
|
|
|
if (++svs.stats.count == STATFRAMES) {
|
2000-05-10 11:29:38 +00:00
|
|
|
svs.stats.latched_active = svs.stats.active;
|
|
|
|
svs.stats.latched_idle = svs.stats.idle;
|
|
|
|
svs.stats.latched_packets = svs.stats.packets;
|
|
|
|
svs.stats.active = 0;
|
|
|
|
svs.stats.idle = 0;
|
|
|
|
svs.stats.packets = 0;
|
|
|
|
svs.stats.count = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_InitLocal
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_InitLocal (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int i;
|
|
|
|
extern cvar_t *sv_maxvelocity;
|
|
|
|
extern cvar_t *sv_gravity;
|
|
|
|
extern cvar_t *sv_aim;
|
|
|
|
extern cvar_t *sv_stopspeed;
|
|
|
|
extern cvar_t *sv_spectatormaxspeed;
|
|
|
|
extern cvar_t *sv_accelerate;
|
|
|
|
extern cvar_t *sv_airaccelerate;
|
|
|
|
extern cvar_t *sv_wateraccelerate;
|
|
|
|
extern cvar_t *sv_friction;
|
|
|
|
extern cvar_t *sv_waterfriction;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
SV_UserInit ();
|
2000-08-13 14:26:20 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
rcon_password = Cvar_Get ("rcon_password", "", CVAR_NONE, "None");
|
|
|
|
password = Cvar_Get ("password", "", CVAR_NONE, "None");
|
|
|
|
spectator_password = Cvar_Get ("spectator_password", "", CVAR_NONE, "None");
|
|
|
|
|
|
|
|
sv_mintic = Cvar_Get ("sv_mintic", "0.03", CVAR_NONE, "None");
|
|
|
|
sv_maxtic = Cvar_Get ("sv_maxtic", "0.1", CVAR_NONE, "None");
|
|
|
|
|
|
|
|
fraglimit = Cvar_Get ("fraglimit", "0", CVAR_SERVERINFO, "None");
|
|
|
|
timelimit = Cvar_Get ("timelimit", "0", CVAR_SERVERINFO, "None");
|
|
|
|
teamplay = Cvar_Get ("teamplay", "0", CVAR_SERVERINFO, "None");
|
|
|
|
samelevel = Cvar_Get ("samelevel", "0", CVAR_SERVERINFO, "None");
|
|
|
|
maxclients = Cvar_Get ("maxclients", "8", CVAR_SERVERINFO, "None");
|
|
|
|
maxspectators = Cvar_Get ("maxspectators", "8", CVAR_SERVERINFO, "None");
|
|
|
|
hostname = Cvar_Get ("hostname", "unnamed", CVAR_SERVERINFO, "None");
|
|
|
|
deathmatch = Cvar_Get ("deathmatch", "1", CVAR_SERVERINFO, "None");
|
|
|
|
spawn = Cvar_Get ("spawn", "0", CVAR_SERVERINFO, "None");
|
|
|
|
watervis = Cvar_Get ("watervis", "0", CVAR_SERVERINFO, "None");
|
|
|
|
|
|
|
|
developer = Cvar_Get ("developer", "0", CVAR_NONE, "None");
|
|
|
|
|
|
|
|
timeout = Cvar_Get ("timeout", "65", CVAR_NONE, "None");
|
|
|
|
zombietime = Cvar_Get ("zombietime", "2", CVAR_NONE, "None");
|
|
|
|
|
|
|
|
sv_maxvelocity = Cvar_Get ("sv_maxvelocity", "2000", CVAR_NONE, "None");
|
|
|
|
sv_gravity = Cvar_Get ("sv_gravity", "800", CVAR_NONE, "None");
|
|
|
|
sv_stopspeed = Cvar_Get ("sv_stopspeed", "100", CVAR_NONE, "None");
|
|
|
|
sv_maxspeed = Cvar_Get ("sv_maxspeed", "320", CVAR_NONE, "None");
|
|
|
|
sv_spectatormaxspeed =
|
|
|
|
Cvar_Get ("sv_spectatormaxspeed", "500", CVAR_NONE, "None");
|
|
|
|
sv_accelerate = Cvar_Get ("sv_accelerate", "10", CVAR_NONE, "None");
|
|
|
|
sv_airaccelerate = Cvar_Get ("sv_airaccelerate", "0.7", CVAR_NONE, "None");
|
|
|
|
sv_wateraccelerate =
|
|
|
|
Cvar_Get ("sv_wateraccelerate", "10", CVAR_NONE, "None");
|
|
|
|
sv_friction = Cvar_Get ("sv_friction", "4", CVAR_NONE, "None");
|
|
|
|
sv_waterfriction = Cvar_Get ("sv_waterfriction", "4", CVAR_NONE, "None");
|
|
|
|
|
|
|
|
sv_aim = Cvar_Get ("sv_aim", "2", CVAR_NONE, "None");
|
|
|
|
|
|
|
|
sv_timekick =
|
2000-11-25 14:20:04 +00:00
|
|
|
Cvar_Get ("sv_timekick", "3", CVAR_SERVERINFO, "Time cheat protection");
|
2000-11-14 16:16:07 +00:00
|
|
|
sv_timekick_fuzz =
|
|
|
|
Cvar_Get ("sv_timekick_fuzz", "15", CVAR_NONE,
|
|
|
|
"Time cheat \"fuzz factor\"");
|
|
|
|
sv_timekick_interval =
|
|
|
|
Cvar_Get ("sv_timekick_interval", "30", CVAR_NONE,
|
|
|
|
"Time cheat check interval");
|
|
|
|
|
2000-11-25 14:20:04 +00:00
|
|
|
sv_minqfversion =
|
|
|
|
Cvar_Get ("sv_minqfversion", "0", CVAR_SERVERINFO, "Minimum QF version on client");
|
|
|
|
|
|
|
|
sv_maxrate =
|
|
|
|
Cvar_Get ("sv_maxrate", "0", CVAR_SERVERINFO, "Maximum allowable rate");
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
sv_allow_log =
|
|
|
|
Cvar_Get ("sv_allow_log", "1", CVAR_NONE, "Allow remote logging");
|
|
|
|
sv_allow_status =
|
|
|
|
Cvar_Get ("sv_allow_status", "1", CVAR_NONE,
|
|
|
|
"Allow remote status queries (gamespy etc)");
|
|
|
|
sv_allow_ping =
|
|
|
|
Cvar_Get ("sv_allow_pings", "1", CVAR_NONE,
|
|
|
|
"Allow remote pings (gamespy etc)");
|
|
|
|
sv_netdosprotect =
|
|
|
|
Cvar_Get ("sv_netdosprotect", "0", CVAR_NONE,
|
|
|
|
"DoS flood attack protection");
|
|
|
|
|
|
|
|
sv_timestamps =
|
|
|
|
Cvar_Get ("sv_timestamps", "0", CVAR_NONE,
|
|
|
|
"Time/date stamps in log entries");
|
|
|
|
sv_timefmt =
|
|
|
|
Cvar_Get ("sv_timefmt", "[%b %e %X] ", CVAR_NONE,
|
|
|
|
"Time/date format to use");
|
|
|
|
|
|
|
|
filterban = Cvar_Get ("filterban", "1", CVAR_NONE, "None");
|
|
|
|
|
|
|
|
allow_download = Cvar_Get ("allow_download", "1", CVAR_NONE, "None");
|
|
|
|
allow_download_skins =
|
|
|
|
Cvar_Get ("allow_download_skins", "1", CVAR_NONE, "None");
|
|
|
|
allow_download_models =
|
|
|
|
Cvar_Get ("allow_download_models", "1", CVAR_NONE, "None");
|
|
|
|
allow_download_sounds =
|
|
|
|
Cvar_Get ("allow_download_sounds", "1", CVAR_NONE, "None");
|
|
|
|
allow_download_maps =
|
|
|
|
Cvar_Get ("allow_download_maps", "1", CVAR_NONE, "None");
|
|
|
|
|
|
|
|
sv_highchars = Cvar_Get ("sv_highchars", "1", CVAR_NONE, "None");
|
|
|
|
|
|
|
|
sv_phs = Cvar_Get ("sv_phs", "1", CVAR_NONE, "None");
|
|
|
|
|
|
|
|
pausable = Cvar_Get ("pausable", "1", CVAR_NONE, "None");
|
|
|
|
|
|
|
|
// DoS protection
|
2000-08-13 14:37:26 +00:00
|
|
|
Cmd_AddCommand ("netdosexpire", SV_netDoSexpire_f);
|
|
|
|
Cmd_AddCommand ("netdosvalues", SV_netDoSvalues_f);
|
2000-08-13 14:34:49 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
Cmd_AddCommand ("addip", SV_AddIP_f);
|
|
|
|
Cmd_AddCommand ("removeip", SV_RemoveIP_f);
|
|
|
|
Cmd_AddCommand ("listip", SV_ListIP_f);
|
|
|
|
Cmd_AddCommand ("writeip", SV_WriteIP_f);
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < MAX_MODELS; i++)
|
|
|
|
snprintf (localmodels[i], sizeof (localmodels[i]), "*%i", i);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-05-13 20:51:02 +00:00
|
|
|
Info_SetValueForStarKey (svs.info, "*version", QW_VERSION,
|
2000-11-14 16:16:07 +00:00
|
|
|
MAX_SERVERINFO_STRING);
|
2000-05-14 23:58:57 +00:00
|
|
|
|
|
|
|
// Brand server as QF, with appropriate QSG standards version --KB
|
2000-05-17 18:28:13 +00:00
|
|
|
Info_SetValueForStarKey (svs.info, "*qf_version", VERSION,
|
2000-11-14 16:16:07 +00:00
|
|
|
MAX_SERVERINFO_STRING);
|
2000-05-17 18:28:13 +00:00
|
|
|
Info_SetValueForStarKey (svs.info, "*qsg_version", QSG_VERSION,
|
2000-11-14 16:16:07 +00:00
|
|
|
MAX_SERVERINFO_STRING);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
// init fraglog stuff
|
|
|
|
svs.logsequence = 1;
|
|
|
|
svs.logtime = realtime;
|
|
|
|
svs.log[0].data = svs.log_buf[0];
|
2000-11-14 16:16:07 +00:00
|
|
|
svs.log[0].maxsize = sizeof (svs.log_buf[0]);
|
2000-05-10 11:29:38 +00:00
|
|
|
svs.log[0].cursize = 0;
|
|
|
|
svs.log[0].allowoverflow = true;
|
|
|
|
svs.log[1].data = svs.log_buf[1];
|
2000-11-14 16:16:07 +00:00
|
|
|
svs.log[1].maxsize = sizeof (svs.log_buf[1]);
|
2000-05-10 11:29:38 +00:00
|
|
|
svs.log[1].cursize = 0;
|
|
|
|
svs.log[1].allowoverflow = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
Master_Heartbeat
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Send a message to the master every few minutes to
|
|
|
|
let it know we are alive, and log information
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
|
|
|
#define HEARTBEAT_SECONDS 300
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
Master_Heartbeat (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
char string[2048];
|
|
|
|
int active;
|
|
|
|
int i;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
if (realtime - svs.last_heartbeat < HEARTBEAT_SECONDS)
|
2000-11-14 16:16:07 +00:00
|
|
|
return; // not time to send yet
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
svs.last_heartbeat = realtime;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
//
|
2000-05-10 11:29:38 +00:00
|
|
|
// count active users
|
2000-11-14 16:16:07 +00:00
|
|
|
//
|
2000-05-10 11:29:38 +00:00
|
|
|
active = 0;
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < MAX_CLIENTS; i++)
|
2000-05-10 11:29:38 +00:00
|
|
|
if (svs.clients[i].state == cs_connected ||
|
2000-11-14 16:16:07 +00:00
|
|
|
svs.clients[i].state == cs_spawned) active++;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
svs.heartbeat_sequence++;
|
2000-11-14 16:16:07 +00:00
|
|
|
snprintf (string, sizeof (string), "%c\n%i\n%i\n", S2M_HEARTBEAT,
|
|
|
|
svs.heartbeat_sequence, active);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
// send to group master
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < MAX_MASTERS; i++)
|
|
|
|
if (master_adr[i].port) {
|
|
|
|
Con_Printf ("Sending heartbeat to %s\n",
|
|
|
|
NET_AdrToString (master_adr[i]));
|
|
|
|
NET_SendPacket (strlen (string), string, master_adr[i]);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
Master_Shutdown
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Informs all masters that this server is going down
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
Master_Shutdown (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
char string[2048];
|
|
|
|
int i;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
snprintf (string, sizeof (string), "%c\n", S2M_SHUTDOWN);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
// send to group master
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0; i < MAX_MASTERS; i++)
|
|
|
|
if (master_adr[i].port) {
|
|
|
|
Con_Printf ("Sending heartbeat to %s\n",
|
|
|
|
NET_AdrToString (master_adr[i]));
|
|
|
|
NET_SendPacket (strlen (string), string, master_adr[i]);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_ExtractFromUserinfo
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
Pull specific info from a newly changed userinfo string
|
|
|
|
into a more C freindly form.
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_ExtractFromUserinfo (client_t *cl)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
char *val, *p, *q;
|
|
|
|
int i;
|
|
|
|
client_t *client;
|
|
|
|
int dupc = 1;
|
|
|
|
char newname[80];
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
// name for C code
|
|
|
|
val = Info_ValueForKey (cl->userinfo, "name");
|
|
|
|
|
|
|
|
// trim user name
|
2000-11-14 16:16:07 +00:00
|
|
|
strncpy (newname, val, sizeof (newname) - 1);
|
|
|
|
newname[sizeof (newname) - 1] = 0;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
for (p = newname; (*p == ' ' || *p == '\r' || *p == '\n') && *p; p++);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
if (p != newname && !*p) {
|
2000-11-14 16:16:07 +00:00
|
|
|
// white space only
|
|
|
|
strcpy (newname, "unnamed");
|
2000-05-10 11:29:38 +00:00
|
|
|
p = newname;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p != newname && *p) {
|
2000-11-14 16:16:07 +00:00
|
|
|
for (q = newname; *p; *q++ = *p++);
|
2000-05-10 11:29:38 +00:00
|
|
|
*q = 0;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
for (p = newname + strlen (newname) - 1;
|
|
|
|
p != newname && (*p == ' ' || *p == '\r' || *p == '\n'); p--);
|
2000-05-10 11:29:38 +00:00
|
|
|
p[1] = 0;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (strcmp (val, newname)) {
|
2000-05-10 11:29:38 +00:00
|
|
|
Info_SetValueForKey (cl->userinfo, "name", newname, MAX_INFO_STRING);
|
|
|
|
val = Info_ValueForKey (cl->userinfo, "name");
|
|
|
|
}
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (!val[0] || !stricmp (val, "console")) {
|
2000-05-10 11:29:38 +00:00
|
|
|
Info_SetValueForKey (cl->userinfo, "name", "unnamed", MAX_INFO_STRING);
|
|
|
|
val = Info_ValueForKey (cl->userinfo, "name");
|
|
|
|
}
|
|
|
|
// check to see if another user by the same name exists
|
|
|
|
while (1) {
|
2000-11-14 16:16:07 +00:00
|
|
|
for (i = 0, client = svs.clients; i < MAX_CLIENTS; i++, client++) {
|
2000-05-10 11:29:38 +00:00
|
|
|
if (client->state != cs_spawned || client == cl)
|
|
|
|
continue;
|
2000-11-14 16:16:07 +00:00
|
|
|
if (!stricmp (client->name, val))
|
2000-05-10 11:29:38 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
if (i != MAX_CLIENTS) { // dup name
|
|
|
|
if (strlen (val) > sizeof (cl->name) - 1)
|
|
|
|
val[sizeof (cl->name) - 4] = 0;
|
2000-05-10 11:29:38 +00:00
|
|
|
p = val;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
if (val[0] == '(') {
|
2000-05-10 11:29:38 +00:00
|
|
|
if (val[2] == ')')
|
|
|
|
p = val + 3;
|
|
|
|
else if (val[3] == ')')
|
|
|
|
p = val + 4;
|
2000-05-10 20:33:16 +00:00
|
|
|
}
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
snprintf (newname, sizeof (newname), "(%d)%-.40s", dupc++, p);
|
|
|
|
Info_SetValueForKey (cl->userinfo, "name", newname,
|
|
|
|
MAX_INFO_STRING);
|
2000-05-10 11:29:38 +00:00
|
|
|
val = Info_ValueForKey (cl->userinfo, "name");
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
|
|
|
|
if (strncmp (val, cl->name, strlen (cl->name))) {
|
2000-05-10 11:29:38 +00:00
|
|
|
if (!sv.paused) {
|
|
|
|
if (!cl->lastnametime || realtime - cl->lastnametime > 5) {
|
|
|
|
cl->lastnamecount = 0;
|
|
|
|
cl->lastnametime = realtime;
|
|
|
|
} else if (cl->lastnamecount++ > 4) {
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "%s was kicked for name spam\n",
|
|
|
|
cl->name);
|
|
|
|
SV_ClientPrintf (cl, PRINT_HIGH,
|
|
|
|
"You were kicked from the game for name spamming\n");
|
2000-08-14 13:41:05 +00:00
|
|
|
SV_DropClient (cl);
|
2000-05-10 11:29:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
if (cl->state >= cs_spawned && !cl->spectator)
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_BroadcastPrintf (PRINT_HIGH, "%s changed name to %s\n", cl->name,
|
|
|
|
val);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
strncpy (cl->name, val, sizeof (cl->name) - 1);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
// rate command
|
|
|
|
val = Info_ValueForKey (cl->userinfo, "rate");
|
2000-11-14 16:16:07 +00:00
|
|
|
if (strlen (val)) {
|
|
|
|
i = atoi (val);
|
2000-11-25 14:20:04 +00:00
|
|
|
|
|
|
|
if ((sv_maxrate->int_val) && (i > sv_maxrate->int_val)) {
|
|
|
|
i = bound (500, i, sv_maxrate->int_val);
|
|
|
|
} else {
|
|
|
|
i = bound (500, i, 10000);
|
|
|
|
}
|
2000-11-14 16:16:07 +00:00
|
|
|
cl->netchan.rate = 1.0 / i;
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
// msg command
|
|
|
|
val = Info_ValueForKey (cl->userinfo, "msg");
|
2000-11-14 16:16:07 +00:00
|
|
|
if (strlen (val)) {
|
|
|
|
cl->messagelevel = atoi (val);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
cl->stdver = atoi (Info_ValueForKey (cl->userinfo, "stdver"));
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_InitNet
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
|
|
|
SV_InitNet (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-14 16:16:07 +00:00
|
|
|
int port;
|
|
|
|
int p;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
port = PORT_SERVER;
|
|
|
|
p = COM_CheckParm ("-port");
|
2000-11-14 16:16:07 +00:00
|
|
|
if (p && p < com_argc) {
|
|
|
|
port = atoi (com_argv[p + 1]);
|
2000-05-10 11:29:38 +00:00
|
|
|
Con_Printf ("Port: %i\n", port);
|
|
|
|
}
|
|
|
|
NET_Init (port);
|
|
|
|
|
|
|
|
Netchan_Init ();
|
|
|
|
|
|
|
|
// heartbeats will allways be sent to the id master
|
|
|
|
svs.last_heartbeat = -99999; // send immediately
|
2000-11-14 16:16:07 +00:00
|
|
|
// NET_StringToAdr ("192.246.40.70:27000", &idmaster_adr);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_Init
|
2000-05-10 11:29:38 +00:00
|
|
|
*/
|
2000-11-14 16:16:07 +00:00
|
|
|
void
|
2000-11-27 15:29:25 +00:00
|
|
|
SV_Init (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-11-27 13:17:48 +00:00
|
|
|
COM_InitArgv (host_parms.argc, host_parms.argv);
|
2000-11-14 16:16:07 +00:00
|
|
|
// COM_AddParm ("-game");
|
|
|
|
// COM_AddParm ("qw");
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
if (COM_CheckParm ("-minmemory"))
|
2000-11-27 13:17:48 +00:00
|
|
|
host_parms.memsize = MINIMUM_MEMORY;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-27 13:17:48 +00:00
|
|
|
if (host_parms.memsize < MINIMUM_MEMORY)
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_Error ("Only %4.1f megs of memory reported, can't execute game",
|
2000-11-27 13:17:48 +00:00
|
|
|
host_parms.memsize / (float) 0x100000);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-27 13:17:48 +00:00
|
|
|
Memory_Init (host_parms.membase, host_parms.memsize);
|
2000-05-16 06:28:50 +00:00
|
|
|
Cvar_Init ();
|
2000-10-31 05:29:32 +00:00
|
|
|
Sys_Init_Cvars ();
|
2000-05-20 22:13:45 +00:00
|
|
|
Sys_Init ();
|
2000-05-16 06:28:50 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
Cbuf_Init ();
|
2000-08-14 13:41:05 +00:00
|
|
|
Cmd_Init ();
|
2000-11-14 16:16:07 +00:00
|
|
|
SV_InitOperatorCommands ();
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-05-21 09:49:25 +00:00
|
|
|
// execute +set as early as possible
|
|
|
|
Cmd_StuffCmds_f ();
|
|
|
|
Cbuf_Execute_Sets ();
|
|
|
|
|
|
|
|
// execute the global configuration file if it exists
|
|
|
|
// would have been nice if Cmd_Exec_f could have been used, but it
|
|
|
|
// only reads from within the quake file system, and changing that is
|
|
|
|
// probably Not A Good Thing (tm).
|
2000-11-14 16:16:07 +00:00
|
|
|
fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG,
|
|
|
|
CVAR_ROM, "global configuration file");
|
2000-05-21 09:49:25 +00:00
|
|
|
Cmd_Exec_File (fs_globalcfg->string);
|
2000-11-30 19:53:25 +00:00
|
|
|
Cbuf_Execute_Sets ();
|
2000-05-22 21:32:14 +00:00
|
|
|
|
2000-11-30 19:53:25 +00:00
|
|
|
// execute +set again to override the config file
|
|
|
|
Cmd_StuffCmds_f ();
|
2000-05-21 09:49:25 +00:00
|
|
|
Cbuf_Execute_Sets ();
|
|
|
|
|
2000-10-30 00:05:21 +00:00
|
|
|
COM_Filesystem_Init_Cvars ();
|
2000-10-31 05:24:34 +00:00
|
|
|
COM_Init_Cvars ();
|
|
|
|
Mod_Init_Cvars ();
|
|
|
|
Netchan_Init_Cvars ();
|
|
|
|
Pmove_Init_Cvars ();
|
|
|
|
PR_Init_Cvars ();
|
2000-10-30 00:05:21 +00:00
|
|
|
|
2000-05-22 21:32:14 +00:00
|
|
|
// and now reprocess the cmdline's sets for overrides
|
2000-05-21 10:08:27 +00:00
|
|
|
Cmd_StuffCmds_f ();
|
2000-05-22 21:32:14 +00:00
|
|
|
Cbuf_Execute_Sets ();
|
2000-05-21 10:08:27 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
COM_Init ();
|
2000-11-14 16:16:07 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
PR_Init ();
|
|
|
|
Mod_Init ();
|
|
|
|
|
|
|
|
SV_InitNet ();
|
|
|
|
|
|
|
|
SV_InitLocal ();
|
|
|
|
Pmove_Init ();
|
|
|
|
|
|
|
|
Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
|
|
|
|
host_hunklevel = Hunk_LowMark ();
|
|
|
|
|
|
|
|
Cbuf_InsertText ("exec server.cfg\n");
|
|
|
|
|
|
|
|
host_initialized = true;
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
|
2000-11-27 13:17:48 +00:00
|
|
|
Con_Printf ("%4.1f megabyte heap\n", host_parms.memsize / (1024 * 1024.0));
|
2000-11-14 16:16:07 +00:00
|
|
|
|
|
|
|
Con_Printf ("\n%s server, Version %s (build %04d)\n\n", PROGRAM, VERSION,
|
|
|
|
build_number ());
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-11-04 07:42:43 +00:00
|
|
|
Con_Printf ("<==> %s initialized <==>\n", PROGRAM);
|
2000-08-14 13:02:17 +00:00
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// process command line arguments
|
2000-05-10 11:29:38 +00:00
|
|
|
Cmd_StuffCmds_f ();
|
|
|
|
Cbuf_Execute ();
|
|
|
|
|
2000-11-14 16:16:07 +00:00
|
|
|
// if a map wasn't specified on the command line, spawn start.map
|
2000-05-10 11:29:38 +00:00
|
|
|
if (sv.state == ss_dead)
|
|
|
|
Cmd_ExecuteString ("map start");
|
|
|
|
if (sv.state == ss_dead)
|
|
|
|
SV_Error ("Couldn't spawn a server");
|
|
|
|
}
|