2004-08-23 00:15:46 +00:00
/*
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
2005-07-03 15:16:20 +00:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
2004-08-23 00:15:46 +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 the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
2013-03-31 04:21:08 +00:00
# include "quakedef.h"
2006-05-09 00:02:05 +00:00
# include "netinc.h"
2005-12-21 03:07:33 +00:00
# include <sys/types.h>
2004-11-29 01:21:00 +00:00
# ifndef CLIENTONLY
2004-08-23 00:15:46 +00:00
# define Q2EDICT_NUM(i) (q2edict_t*)((char *)ge->edicts+i*ge->edict_size)
2014-03-31 17:06:41 +00:00
void SV_LegacySavegame_f ( void ) ;
2004-08-23 00:15:46 +00:00
void SV_Savegame_f ( void ) ;
void SV_Loadgame_f ( void ) ;
# define INVIS_CHAR1 12
# define INVIS_CHAR2 (char)138
# define INVIS_CHAR3 (char)160
2013-03-12 23:09:25 +00:00
# ifdef SERVERONLY
2004-08-23 00:15:46 +00:00
double host_frametime ;
double realtime ; // without any filtering or bounding
2013-03-12 23:09:25 +00:00
qboolean host_initialized ; // true if into command execution (compatability)
quakeparms_t host_parms ;
2004-08-23 00:15:46 +00:00
int host_hunklevel ;
2013-03-12 23:09:25 +00:00
# endif
2004-08-23 00:15:46 +00:00
2006-05-07 05:31:01 +00:00
// callbacks
void SV_Masterlist_Callback ( struct cvar_s * var , char * oldvalue ) ;
void SV_Tcpport_Callback ( struct cvar_s * var , char * oldvalue ) ;
2008-11-09 22:29:28 +00:00
void SV_Tcpport6_Callback ( struct cvar_s * var , char * oldvalue ) ;
2006-05-09 00:02:05 +00:00
void SV_Port_Callback ( struct cvar_s * var , char * oldvalue ) ;
void SV_PortIPv6_Callback ( struct cvar_s * var , char * oldvalue ) ;
void SV_PortIPX_Callback ( struct cvar_s * var , char * oldvalue ) ;
2006-05-07 05:31:01 +00:00
2005-05-26 12:55:34 +00:00
typedef struct {
2009-02-08 19:05:28 +00:00
enum {
MP_NONE ,
MP_QUAKEWORLD ,
MP_DARKPLACES ,
} protocol ;
2005-05-26 12:55:34 +00:00
cvar_t cv ;
2009-02-08 19:05:28 +00:00
qboolean needsresolve ; //set any time the cvar is modified
2005-05-26 12:55:34 +00:00
netadr_t adr ;
} sv_masterlist_t ;
sv_masterlist_t sv_masterlist [ ] = {
2010-07-11 02:22:39 +00:00
{ MP_QUAKEWORLD , CVARC ( " sv_master1 " , " " , SV_Masterlist_Callback ) } ,
{ MP_QUAKEWORLD , CVARC ( " sv_master2 " , " " , SV_Masterlist_Callback ) } ,
{ MP_QUAKEWORLD , CVARC ( " sv_master3 " , " " , SV_Masterlist_Callback ) } ,
{ MP_QUAKEWORLD , CVARC ( " sv_master4 " , " " , SV_Masterlist_Callback ) } ,
{ MP_QUAKEWORLD , CVARC ( " sv_master5 " , " " , SV_Masterlist_Callback ) } ,
{ MP_QUAKEWORLD , CVARC ( " sv_master6 " , " " , SV_Masterlist_Callback ) } ,
{ MP_QUAKEWORLD , CVARC ( " sv_master7 " , " " , SV_Masterlist_Callback ) } ,
{ MP_QUAKEWORLD , CVARC ( " sv_master8 " , " " , SV_Masterlist_Callback ) } ,
{ MP_QUAKEWORLD , CVARC ( " sv_qwmasterextra1 " , " qwmaster.ocrana.de:27000 " , SV_Masterlist_Callback ) } , //german. admin unknown
{ MP_QUAKEWORLD , CVARC ( " sv_qwmasterextra2 " , " masterserver.exhale.de:27000 " , SV_Masterlist_Callback ) } , //german. admin unknown
2011-07-09 09:14:05 +00:00
{ MP_QUAKEWORLD , CVARC ( " sv_qwmasterextra3 " , " asgaard.morphos-team.net:27000 " , SV_Masterlist_Callback ) } , //german. admin bigfoot
2010-07-11 02:22:39 +00:00
{ MP_QUAKEWORLD , CVARC ( " sv_qwmasterextra4 " , " master.quakeservers.net:27000 " , SV_Masterlist_Callback ) } , //european. admin: raz0?
2011-07-09 06:32:29 +00:00
{ MP_QUAKEWORLD , CVARC ( " sv_qwmasterextra5 " , " qwmaster.fodquake.net:27000 " , SV_Masterlist_Callback ) } ,
2010-07-11 02:22:39 +00:00
{ MP_DARKPLACES , CVARC ( " sv_masterextra1 " , " ghdigital.com:27950 " , SV_Masterlist_Callback ) } , //69.59.212.88 (admin: LordHavoc)
{ MP_DARKPLACES , CVARC ( " sv_masterextra2 " , " dpmaster.deathmask.net:27950 " , SV_Masterlist_Callback ) } , //209.164.24.243 (admin: Willis)
{ MP_DARKPLACES , CVARC ( " sv_masterextra3 " , " dpmaster.tchr.no:27950 " , SV_Masterlist_Callback ) } , // (admin: tChr)
{ MP_NONE , CVAR ( NULL , NULL ) }
2005-05-26 12:55:34 +00:00
} ;
2004-08-23 00:15:46 +00:00
client_t * host_client ; // current client
2005-04-26 16:04:12 +00:00
// bound the size of the physics time tic
# ifdef SERVERONLY
2014-03-30 08:55:06 +00:00
cvar_t sv_mintic = CVARD ( " sv_mintic " , " 0.013 " , " The minimum interval between running physics frames. " ) ;
2005-04-26 16:04:12 +00:00
# else
2014-03-30 08:55:06 +00:00
cvar_t sv_mintic = CVARD ( " sv_mintic " , " 0 " , " The minimum interval between running physics frames. " ) ; //client builds can think as often as they want.
2005-04-26 16:04:12 +00:00
# endif
2014-03-30 08:55:06 +00:00
cvar_t sv_maxtic = CVARD ( " sv_maxtic " , " 0.1 " , " The maximum interval between running physics frames. If the value is too low, multiple physics interations might be run at a time (based upon sv_limittics). Set identical to sv_mintic for fixed-interval ticks, which may be required if ODE is used. " ) ; //never run a tick slower than this
cvar_t sv_limittics = CVARD ( " sv_limittics " , " 3 " , " The maximum number of ticks that may be run within a frame, to allow the server to catch up if it stalled or if sv_maxtic is too low. " ) ; //
2009-11-15 03:20:17 +00:00
2014-03-30 08:55:06 +00:00
cvar_t sv_nailhack = CVARD ( " sv_nailhack " , " 0 " , " If set to 1, disables the nail entity networking optimisation. This hack was popularised by qizmo which recommends it for better compression. Also allows clients to interplate nail positions and add trails. " ) ;
2014-01-13 02:42:25 +00:00
cvar_t sv_nopvs = CVARD ( " sv_nopvs " , " 0 " , " Set to 1 to ignore pvs on the server. This can make wallhacks more dangerous, so should only be used for debugging. " ) ;
2014-04-24 01:53:01 +00:00
cvar_t fraglog_public = CVARD ( " fraglog_public " , " 1 " , " Enables support for connectionless fraglog requests " ) ;
2004-08-23 00:15:46 +00:00
2006-02-11 02:09:43 +00:00
cvar_t timeout = SCVAR ( " timeout " , " 65 " ) ; // seconds without any message
cvar_t zombietime = SCVAR ( " zombietime " , " 2 " ) ; // seconds to sink messages
2004-08-23 00:15:46 +00:00
// after disconnect
# ifdef SERVERONLY
2006-02-11 02:09:43 +00:00
cvar_t developer = SCVAR ( " developer " , " 0 " ) ; // show extra messages
2004-08-23 00:15:46 +00:00
2006-06-12 22:05:41 +00:00
cvar_t rcon_password = SCVARF ( " rcon_password " , " " , CVAR_NOUNSAFEEXPAND ) ; // password for remote server commands
cvar_t password = SCVARF ( " password " , " " , CVAR_NOUNSAFEEXPAND ) ; // password for entering the game
2004-08-23 00:15:46 +00:00
# else
extern cvar_t developer ;
extern cvar_t rcon_password ;
extern cvar_t password ;
# endif
2010-07-11 02:22:39 +00:00
cvar_t spectator_password = CVARF ( " spectator_password " , " " , CVAR_NOUNSAFEEXPAND ) ; // password for entering as a sepctator
cvar_t allow_download = CVAR ( " allow_download " , " 1 " ) ;
cvar_t allow_download_skins = CVAR ( " allow_download_skins " , " 1 " ) ;
cvar_t allow_download_models = CVAR ( " allow_download_models " , " 1 " ) ;
cvar_t allow_download_sounds = CVAR ( " allow_download_sounds " , " 1 " ) ;
cvar_t allow_download_demos = CVAR ( " allow_download_demos " , " 1 " ) ;
cvar_t allow_download_maps = CVAR ( " allow_download_maps " , " 1 " ) ;
cvar_t allow_download_anymap = CVAR ( " allow_download_pakmaps " , " 0 " ) ;
2013-12-02 14:30:30 +00:00
cvar_t allow_download_pakcontents = CVARD ( " allow_download_pakcontents " , " 1 " , " controls whether clients connected to this server are allowed to download files from within packages. Does NOT implicitly allow downloading bsps, set allow_download_pakmaps to enable that. " ) ;
2013-12-02 14:33:22 +00:00
cvar_t allow_download_root = CVARD ( " allow_download_root " , " 0 " , " If set, enables downloading from the root of the gamedir (not the basedir). This setting is dangerous as it can allow downloading configs. " ) ;
2010-07-11 02:22:39 +00:00
cvar_t allow_download_textures = CVAR ( " allow_download_textures " , " 1 " ) ;
2011-10-27 16:16:29 +00:00
cvar_t allow_download_packages = CVAR ( " allow_download_packages " , " 1 " ) ;
2013-06-23 02:17:02 +00:00
cvar_t allow_download_refpackages = CVARD ( " allow_download_refpackages " , " 1 " , " If set to 1, packages that contain files needed during spawn functions will be become 'referenced' and automatically downloaded to clients. \n This cvar should probably not be set if you have large packages that provide replacement pickup models on public servers. \n The path command will show a '(ref)' tag next to packages which clients will automatically attempt to download. " ) ;
2010-07-11 02:22:39 +00:00
cvar_t allow_download_wads = CVAR ( " allow_download_wads " , " 1 " ) ;
cvar_t allow_download_configs = CVAR ( " allow_download_configs " , " 0 " ) ;
2012-01-17 07:57:46 +00:00
cvar_t allow_download_copyrighted = CVAR ( " allow_download_copyrighted " , " 0 " ) ;
2010-07-11 02:22:39 +00:00
2014-03-30 08:55:06 +00:00
cvar_t sv_serverip = CVARD ( " sv_serverip " , " " , " Set this cvar to the server's public ip address if the server is behind a firewall and cannot detect its own public address. Providing a port is required if the firewall/nat remaps it, but is otherwise optional. " ) ;
2010-07-11 02:22:39 +00:00
cvar_t sv_public = CVAR ( " sv_public " , " 0 " ) ;
cvar_t sv_listen_qw = CVARAF ( " sv_listen_qw " , " 1 " , " sv_listen " , 0 ) ;
2013-12-09 01:18:27 +00:00
cvar_t sv_listen_nq = CVARD ( " sv_listen_nq " , " 2 " , " Allow new (net)quake clients to connect to the server. \n 0 = don't let them in. \n 1 = allow them in (WARNING: this allows 'qsmurf' DOS attacks). \n 2 = accept (net)quake clients by emulating a challenge (as secure as QW/Q2 but does not fully conform to the NQ protocol). " ) ;
2011-10-27 16:16:29 +00:00
cvar_t sv_listen_dp = CVAR ( " sv_listen_dp " , " 0 " ) ; /*kinda fucked right now*/
2010-07-11 02:22:39 +00:00
cvar_t sv_listen_q3 = CVAR ( " sv_listen_q3 " , " 0 " ) ;
cvar_t sv_reportheartbeats = CVAR ( " sv_reportheartbeats " , " 1 " ) ;
cvar_t sv_highchars = CVAR ( " sv_highchars " , " 1 " ) ;
cvar_t sv_loadentfiles = CVAR ( " sv_loadentfiles " , " 1 " ) ;
2011-10-27 16:16:29 +00:00
cvar_t sv_maxrate = CVAR ( " sv_maxrate " , " 30000 " ) ;
2011-06-15 21:29:54 +00:00
cvar_t sv_maxdrate = CVARAF ( " sv_maxdrate " , " 100000 " ,
2010-07-11 02:22:39 +00:00
" sv_maxdownloadrate " , 0 ) ;
2013-03-12 22:35:33 +00:00
cvar_t sv_minping = CVARF ( " sv_minping " , " " , CVAR_SERVERINFO ) ;
2010-07-11 02:22:39 +00:00
2012-09-30 05:52:03 +00:00
cvar_t sv_bigcoords = CVARFD ( " sv_bigcoords " , " " , CVAR_SERVERINFO , " Uses floats for coordinates instead of 16bit values. Affects clients thusly: \n QW: enforces a mandatory protocol extension \n DP: enables DPP7 protocol support \n NQ: uses RMQ protocol (protocol 999). " ) ;
cvar_t sv_calcphs = CVARFD ( " sv_calcphs " , " 2 " , CVAR_LATCH , " Enables culling of sound effects. 0=always skip phs. Sounds are globally broadcast. 1=always generate phs. Sounds are always culled. On large maps the phs will be dumped to disk. 2=On large single-player maps, generation of phs is skipped. Otherwise like option 1. " ) ;
2010-07-11 02:22:39 +00:00
2012-09-30 05:52:03 +00:00
cvar_t sv_cullplayers_trace = CVARFD ( " sv_cullplayers_trace " , " " , CVAR_SERVERINFO , " Attempt to cull player entities using tracelines as an anti-wallhack. " ) ;
cvar_t sv_cullentities_trace = CVARFD ( " sv_cullentities_trace " , " " , CVAR_SERVERINFO , " Attempt to cull non-player entities using tracelines as an extreeme anti-wallhack. " ) ;
cvar_t sv_phs = CVARD ( " sv_phs " , " 1 " , " If 1, do not use the phs. It is generally better to use sv_calcphs instead, and leave this as 1. " ) ;
2010-07-11 02:22:39 +00:00
cvar_t sv_resetparms = CVAR ( " sv_resetparms " , " 0 " ) ;
2010-08-17 02:44:21 +00:00
cvar_t sv_pupglow = CVARF ( " sv_pupglow " , " " , CVAR_SERVERINFO ) ;
2010-07-11 02:22:39 +00:00
cvar_t sv_master = CVAR ( " sv_master " , " 0 " ) ;
cvar_t sv_masterport = CVAR ( " sv_masterport " , " 0 " ) ;
2013-09-09 01:16:03 +00:00
cvar_t pext_ezquake_nochunks = CVARD ( " pext_ezquake_nochunks " , " 1 " , " Prevents ezquake clients from being able to use the chunked download extension. This sidesteps numerous ezquake issues, and will make downloads slower but more robust. " ) ;
2014-03-30 08:55:06 +00:00
cvar_t sv_gamespeed = CVARAF ( " sv_gamespeed " , " 1 " , " slowmo " , 0 ) ;
2010-07-11 02:22:39 +00:00
cvar_t sv_csqcdebug = CVAR ( " sv_csqcdebug " , " 0 " ) ;
cvar_t sv_csqc_progname = CVAR ( " sv_csqc_progname " , " csprogs.dat " ) ;
cvar_t pausable = CVAR ( " pausable " , " 1 " ) ;
2013-11-28 00:45:22 +00:00
cvar_t sv_banproxies = CVARD ( " sv_banproxies " , " 0 " , " If enabled, anyone connecting via known proxy software will be refused entry. This should aid with blocking aimbots, but is only reliable for certain public proxies. " ) ;
2004-08-23 00:15:46 +00:00
//
// game rules mirrored in svs.info
//
2010-07-11 02:22:39 +00:00
cvar_t fraglimit = CVARF ( " fraglimit " , " " , CVAR_SERVERINFO ) ;
cvar_t timelimit = CVARF ( " timelimit " , " " , CVAR_SERVERINFO ) ;
cvar_t teamplay = CVARF ( " teamplay " , " " , CVAR_SERVERINFO ) ;
cvar_t samelevel = CVARF ( " samelevel " , " " , CVAR_SERVERINFO ) ;
2013-10-29 17:38:22 +00:00
cvar_t sv_playerslots = CVARAD ( " sv_playerslots " , " " ,
2014-03-30 08:55:06 +00:00
" maxplayers " , " Specify maximum number of player/spectator/bot slots, new value takes effect on the next map (this may result in players getting kicked). This should generally be set to maxclients+maxspectators. Leave blank for a default value. \n Maximum value of " STRINGIFY ( MAX_CLIENTS ) " . Values above 16 will result in issues with vanilla NQ clients. Effective values other than 32 will result in issues with vanilla QW clients. " ) ;
2013-10-29 17:38:22 +00:00
cvar_t maxclients = CVARAFD ( " maxclients " , " 8 " ,
" sv_maxclients " , CVAR_SERVERINFO , " Specify the maximum number of players allowed on the server at once. Can be changed mid-map. " ) ;
cvar_t maxspectators = CVARFD ( " maxspectators " , " 8 " , CVAR_SERVERINFO , " Specify the maximum number of spectators allowed on the server at once. Can be changed mid-map. " ) ;
2004-08-23 00:15:46 +00:00
# ifdef SERVERONLY
2010-07-11 02:22:39 +00:00
cvar_t deathmatch = CVARF ( " deathmatch " , " 1 " , CVAR_SERVERINFO ) ; // 0, 1, or 2
2004-08-23 00:15:46 +00:00
# else
2013-03-12 22:35:33 +00:00
cvar_t deathmatch = CVARF ( " deathmatch " , " " , CVAR_SERVERINFO ) ; // 0, 1, or 2
2004-08-23 00:15:46 +00:00
# endif
2010-07-11 02:22:39 +00:00
cvar_t coop = CVARF ( " coop " , " " , CVAR_SERVERINFO ) ;
cvar_t skill = CVARF ( " skill " , " " , CVAR_SERVERINFO ) ; // 0, 1, 2 or 3
cvar_t spawn = CVARF ( " spawn " , " " , CVAR_SERVERINFO ) ;
cvar_t watervis = CVARF ( " watervis " , " " , CVAR_SERVERINFO ) ;
cvar_t rearview = CVARF ( " rearview " , " " , CVAR_SERVERINFO ) ;
2011-10-27 16:16:29 +00:00
# pragma warningmsg("Remove this some time")
2010-07-11 02:22:39 +00:00
cvar_t allow_skybox = CVARF ( " allow_skybox " , " " , CVAR_SERVERINFO ) ;
cvar_t sv_allow_splitscreen = CVARF ( " allow_splitscreen " , " " , CVAR_SERVERINFO ) ;
2013-03-12 22:35:33 +00:00
cvar_t fbskins = CVARF ( " fbskins " , " " , CVAR_SERVERINFO ) ; //to get rid of lame fuhquake fbskins
2010-07-11 02:22:39 +00:00
cvar_t mirrors = CVARF ( " mirrors " , " " , CVAR_SERVERINFO ) ;
cvar_t sv_motd [ ] = { CVAR ( " sv_motd1 " , " " ) ,
CVAR ( " sv_motd2 " , " " ) ,
CVAR ( " sv_motd3 " , " " ) ,
CVAR ( " sv_motd4 " , " " ) } ;
cvar_t sv_compatiblehulls = CVAR ( " sv_compatiblehulls " , " 1 " ) ;
2012-11-27 03:23:19 +00:00
cvar_t dpcompat_stats = CVAR ( " dpcompat_stats " , " 0 " ) ;
2010-07-11 02:22:39 +00:00
cvar_t hostname = CVARF ( " hostname " , " unnamed " , CVAR_SERVERINFO ) ;
cvar_t secure = CVARF ( " secure " , " " , CVAR_SERVERINFO ) ;
2004-08-23 00:15:46 +00:00
2013-03-12 22:53:23 +00:00
extern cvar_t sv_nqplayerphysics ;
2004-08-23 00:15:46 +00:00
char cvargroup_serverpermissions [ ] = " server permission variables " ;
char cvargroup_serverinfo [ ] = " serverinfo variables " ;
char cvargroup_serverphysics [ ] = " server physics variables " ;
char cvargroup_servercontrol [ ] = " server control variables " ;
2005-12-21 03:07:33 +00:00
vfsfile_t * sv_fraglogfile ;
2004-08-23 00:15:46 +00:00
2008-08-23 19:17:19 +00:00
void SV_FixupName ( char * in , char * out , unsigned int outlen ) ;
2013-05-03 04:28:08 +00:00
void SV_AcceptClient ( netadr_t * adr , int userid , char * userinfo ) ;
2004-08-23 00:15:46 +00:00
void Master_Shutdown ( void ) ;
2010-05-01 22:47:47 +00:00
void PRH2_SetPlayerClass ( client_t * cl , int classnum , qboolean fromqc ) ;
2009-07-14 23:42:54 +00:00
char * SV_BannedReason ( netadr_t * a ) ;
2014-03-30 08:55:06 +00:00
void SV_EvaluatePenalties ( client_t * cl ) ;
2004-08-23 00:15:46 +00:00
2008-04-14 07:47:30 +00:00
# ifdef SQL
void PR_SQLCycle ( ) ;
# endif
2014-03-30 08:55:06 +00:00
int nextuserid ;
2004-08-23 00:15:46 +00:00
//============================================================================
qboolean ServerPaused ( void )
{
return sv . paused ;
}
/*
= = = = = = = = = = = = = = = =
SV_Shutdown
Quake calls this before calling Sys_Quit or Sys_Error
= = = = = = = = = = = = = = = =
*/
void SV_Shutdown ( void )
{
Master_Shutdown ( ) ;
if ( sv_fraglogfile )
{
2005-12-21 03:07:33 +00:00
VFS_CLOSE ( sv_fraglogfile ) ;
2004-08-23 00:15:46 +00:00
sv_fraglogfile = NULL ;
}
2012-11-29 13:37:48 +00:00
PR_Shutdown ( ) ;
2009-11-05 01:22:27 +00:00
# ifdef USEODE
2011-09-03 03:49:43 +00:00
World_ODE_Shutdown ( ) ;
2009-11-05 01:22:27 +00:00
# endif
2004-08-23 00:15:46 +00:00
if ( sv . mvdrecording )
2011-08-16 04:12:15 +00:00
SV_MVDStop ( 0 , false ) ;
2004-08-23 00:15:46 +00:00
2012-07-05 19:42:36 +00:00
if ( svs . entstatebuffer . entities )
{
BZ_Free ( svs . entstatebuffer . entities ) ;
memset ( & svs . entstatebuffer . entities , 0 , sizeof ( svs . entstatebuffer . entities ) ) ;
}
if ( sv_staticentities )
{
sv_max_staticentities = 0 ;
sv . num_static_entities = 0 ;
BZ_Free ( sv_staticentities ) ;
sv_staticentities = NULL ;
}
2012-11-29 13:37:48 +00:00
T_FreeStrings ( ) ;
2012-07-05 19:42:36 +00:00
SV_GibFilterPurge ( ) ;
2004-08-23 00:15:46 +00:00
NET_Shutdown ( ) ;
2010-03-14 14:35:56 +00:00
# ifdef WEBSERVER
2004-08-23 00:15:46 +00:00
IWebShutdown ( ) ;
# endif
2008-05-09 14:22:37 +00:00
Memory_DeInit ( ) ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = =
SV_Error
Sends a datagram to all the clients informing them of the server crash ,
then exits
= = = = = = = = = = = = = = = =
*/
void VARGS SV_Error ( char * error , . . . )
{
va_list argptr ;
static char string [ 1024 ] ;
static qboolean inerror = false ;
if ( inerror )
2004-11-17 17:43:07 +00:00
{
2004-08-23 00:15:46 +00:00
Sys_Error ( " SV_Error: recursively entered (%s) " , string ) ;
2004-11-17 17:43:07 +00:00
}
2004-08-23 00:15:46 +00:00
inerror = true ;
va_start ( argptr , error ) ;
2006-03-06 01:41:09 +00:00
vsnprintf ( string , sizeof ( string ) - 1 , error , argptr ) ;
2004-08-23 00:15:46 +00:00
va_end ( argptr ) ;
2005-06-14 04:52:10 +00:00
{
2005-08-19 19:06:22 +00:00
extern cvar_t pr_ssqc_coreonerror ;
2007-09-02 19:55:17 +00:00
if ( svprogfuncs & & pr_ssqc_coreonerror . value & & svprogfuncs - > save_ents )
2005-08-19 19:06:22 +00:00
{
int size = 1024 * 1024 * 8 ;
char * buffer = BZ_Malloc ( size ) ;
2013-08-21 07:14:39 +00:00
svprogfuncs - > save_ents ( svprogfuncs , buffer , & size , size , 3 ) ;
2005-08-19 19:06:22 +00:00
COM_WriteFile ( " ssqccore.txt " , buffer , size ) ;
BZ_Free ( buffer ) ;
}
2005-06-14 04:52:10 +00:00
}
2004-08-23 00:15:46 +00:00
SV_EndRedirect ( ) ;
Con_Printf ( " SV_Error: %s \n " , string ) ;
if ( sv . state )
SV_FinalMessage ( va ( " server crashed: %s \n " , string ) ) ;
SV_UnspawnServer ( ) ;
# ifndef SERVERONLY
if ( cls . state )
{
inerror = false ;
Host_EndGame ( " SV_Error: %s \n " , string ) ;
}
2009-11-04 21:16:50 +00:00
SCR_EndLoadingPlaque ( ) ;
2004-08-23 00:15:46 +00:00
if ( ! isDedicated ) //dedicated servers crash...
{
extern jmp_buf host_abort ;
SCR_EndLoadingPlaque ( ) ;
inerror = false ;
longjmp ( host_abort , 1 ) ;
}
# endif
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
SV_Shutdown ( ) ;
Sys_Error ( " SV_Error: %s \n " , string ) ;
}
2009-11-18 20:41:30 +00:00
# ifdef SERVERONLY
2010-02-06 01:25:04 +00:00
void VARGS Host_Error ( char * error , . . . )
2009-11-18 20:41:30 +00:00
{
va_list argptr ;
char string [ 1024 ] ;
va_start ( argptr , error ) ;
vsnprintf ( string , sizeof ( string ) - 1 , error , argptr ) ;
va_end ( argptr ) ;
SV_Error ( " %s " , string ) ;
}
# endif
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
# ifdef SERVERONLY
void VARGS Host_EndGame ( char * error , . . . )
{
va_list argptr ;
char string [ 1024 ] ;
va_start ( argptr , error ) ;
vsnprintf ( string , sizeof ( string ) - 1 , error , argptr ) ;
va_end ( argptr ) ;
SV_Error ( " %s " , string ) ;
}
# endif
2004-08-23 00:15:46 +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 SV_FinalMessage ( char * message )
{
int i ;
client_t * cl ;
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
SZ_Clear ( & sv . datagram ) ;
MSG_WriteByte ( & sv . datagram , svc_print ) ;
MSG_WriteByte ( & sv . datagram , PRINT_HIGH ) ;
MSG_WriteString ( & sv . datagram , message ) ;
MSG_WriteByte ( & sv . datagram , svc_disconnect ) ;
2013-10-29 17:38:22 +00:00
for ( i = 0 , cl = svs . clients ; i < svs . allocated_client_slots ; i + + , cl + + )
2004-08-23 00:15:46 +00:00
if ( cl - > state > = cs_spawned )
2005-06-14 04:52:10 +00:00
if ( ISNQCLIENT ( cl ) | | ISQWCLIENT ( cl ) )
Netchan_Transmit ( & cl - > netchan , sv . datagram . cursize
, sv . datagram . data , 10000 ) ;
2004-08-23 00:15:46 +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 )
{
2007-08-30 20:45:01 +00:00
laggedpacket_t * lp ;
2013-05-03 04:28:08 +00:00
sizebuf_t termmsg ;
char termbuf [ 64 ] ;
2010-12-23 03:55:10 +00:00
/*drop the first in the chain first*/
if ( drop - > controller & & drop - > controller ! = drop )
{
SV_DropClient ( drop - > controller ) ;
return ;
}
2014-05-20 02:23:37 +00:00
if ( ! drop - > controller & & drop - > netchan . remote_address . type ! = NA_INVALID & & drop - > netchan . remote_address . type ! = NA_LOOPBACK )
2004-08-23 00:15:46 +00:00
{
2008-11-09 22:29:28 +00:00
// add the disconnect
2014-03-30 08:55:06 +00:00
if ( drop - > state < cs_connected )
2005-05-26 12:55:34 +00:00
{
2008-11-09 22:29:28 +00:00
switch ( drop - > protocol )
{
case SCP_QUAKE2 :
MSG_WriteByte ( & drop - > netchan . message , svcq2_disconnect ) ;
break ;
case SCP_QUAKEWORLD :
case SCP_NETQUAKE :
2012-10-01 14:29:44 +00:00
case SCP_PROQUAKE :
2011-10-27 16:16:29 +00:00
case SCP_FITZ666 :
2008-11-09 22:29:28 +00:00
case SCP_DARKPLACES6 :
case SCP_DARKPLACES7 :
MSG_WriteByte ( & drop - > netchan . message , svc_disconnect ) ;
break ;
case SCP_BAD :
break ;
case SCP_QUAKE3 :
break ;
}
2005-05-26 12:55:34 +00:00
}
}
2004-08-23 00:15:46 +00:00
if ( drop - > state = = cs_spawned )
{
2014-03-30 08:55:06 +00:00
# ifdef SVRANKING
2004-08-23 00:15:46 +00:00
if ( drop - > rankid )
{
2014-03-30 08:55:06 +00:00
int j ;
rankstats_t rs ;
2004-08-23 00:15:46 +00:00
if ( Rank_GetPlayerStats ( drop - > rankid , & rs ) )
{
rs . timeonserver + = realtime - drop - > stats_started ;
drop - > stats_started = realtime ;
rs . kills + = drop - > kills ;
rs . deaths + = drop - > deaths ;
rs . flags1 & = ~ ( RANK_CUFFED | RANK_MUTED | RANK_CRIPPLED ) ;
if ( drop - > iscuffed = = 2 )
rs . flags1 | = RANK_CUFFED ;
if ( drop - > ismuted = = 2 )
rs . flags1 | = RANK_MUTED ;
if ( drop - > iscrippled = = 2 )
rs . flags1 | = RANK_CRIPPLED ;
drop - > kills = 0 ;
drop - > deaths = 0 ;
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , drop - > edict ) ;
2011-10-27 16:16:29 +00:00
if ( pr_global_ptrs - > SetChangeParms )
2004-08-23 00:15:46 +00:00
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > SetChangeParms ) ;
2009-11-05 03:07:52 +00:00
for ( j = 0 ; j < NUM_RANK_SPAWN_PARMS ; j + + )
2011-10-27 16:16:29 +00:00
if ( pr_global_ptrs - > spawnparamglobals [ j ] )
rs . parm [ j ] = * pr_global_ptrs - > spawnparamglobals [ j ] ;
2004-08-23 00:15:46 +00:00
Rank_SetPlayerStats ( drop - > rankid , & rs ) ;
}
}
# endif
2014-03-30 08:55:06 +00:00
# ifdef SUBSERVERS
SSV_SavePlayerStats ( drop , false ) ;
# endif
}
2004-08-23 00:15:46 +00:00
# ifdef SVCHAT
SV_WipeChat ( drop ) ;
# endif
2005-08-26 22:56:51 +00:00
switch ( svs . gametype )
{
2007-08-07 19:16:32 +00:00
case GT_MAX :
2005-08-26 22:56:51 +00:00
break ;
2007-09-02 19:55:17 +00:00
case GT_Q1QVM :
2005-08-26 22:56:51 +00:00
case GT_PROGS :
if ( svprogfuncs )
2004-08-23 00:15:46 +00:00
{
2014-03-30 08:55:06 +00:00
if ( ( drop - > state = = cs_spawned | | drop - > istobeloaded ) & & host_initialized )
2004-08-23 00:15:46 +00:00
{
2007-09-02 19:55:17 +00:00
# ifdef VM_Q1
if ( svs . gametype = = GT_Q1QVM )
2005-08-26 22:56:51 +00:00
{
2007-09-02 19:55:17 +00:00
Q1QVM_DropClient ( drop ) ;
2005-08-26 22:56:51 +00:00
}
2007-09-02 19:55:17 +00:00
else
# endif
2005-08-26 22:56:51 +00:00
{
2007-09-02 19:55:17 +00:00
if ( ! drop - > spectator )
{
2005-08-26 22:56:51 +00:00
// call the prog function for removing a client
// this will set the body to a dead frame, among other things
2007-09-02 19:55:17 +00:00
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , drop - > edict ) ;
2011-12-05 15:23:40 +00:00
if ( pr_global_ptrs - > ClientDisconnect )
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > ClientDisconnect ) ;
2012-01-17 07:57:46 +00:00
sv . spawned_client_slots - - ;
2007-09-02 19:55:17 +00:00
}
2013-03-12 22:35:33 +00:00
else
2007-09-02 19:55:17 +00:00
{
2013-03-12 22:35:33 +00:00
// call the prog function for removing a client
// this will set the body to a dead frame, among other things
2007-09-02 19:55:17 +00:00
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , drop - > edict ) ;
2013-03-12 22:35:33 +00:00
if ( SpectatorDisconnect )
PR_ExecuteProgram ( svprogfuncs , SpectatorDisconnect ) ;
sv . spawned_observer_slots - - ;
2007-09-02 19:55:17 +00:00
}
2005-08-26 22:56:51 +00:00
}
2008-11-09 22:29:28 +00:00
if ( progstype = = PROG_NQ )
2009-11-04 21:16:50 +00:00
ED_Clear ( svprogfuncs , drop - > edict ) ;
2004-08-23 00:15:46 +00:00
}
2014-03-30 08:55:06 +00:00
if ( svprogfuncs & & drop - > edict & & drop - > edict - > v )
2013-03-12 22:57:40 +00:00
drop - > edict - > v - > frags = 0 ;
drop - > edict = NULL ;
2005-08-26 22:56:51 +00:00
if ( drop - > spawninfo )
Z_Free ( drop - > spawninfo ) ;
drop - > spawninfo = NULL ;
}
break ;
2007-08-07 19:16:32 +00:00
case GT_QUAKE2 :
# ifdef Q2SERVER
if ( ge )
ge - > ClientDisconnect ( drop - > q2edict ) ;
# endif
break ;
case GT_QUAKE3 :
# ifdef Q3SERVER
SVQ3_DropClient ( drop ) ;
2009-03-03 01:52:30 +00:00
# endif
break ;
case GT_HALFLIFE :
# ifdef HLSERVER
SVHL_DropClient ( drop ) ;
2007-08-07 19:16:32 +00:00
# endif
break ;
2004-08-23 00:15:46 +00:00
}
2010-08-21 22:12:43 +00:00
if ( drop - > centerprintstring )
Z_Free ( drop - > centerprintstring ) ;
drop - > centerprintstring = NULL ;
2013-03-12 22:57:40 +00:00
if ( ! drop - > redirect & & drop - > state > cs_zombie )
2011-09-06 20:53:38 +00:00
{
if ( drop - > spectator )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Spectator \" %s \" removed \n " , drop - > name ) ;
2011-09-06 20:53:38 +00:00
else
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Client \" %s \" removed \n " , drop - > name ) ;
2011-09-06 20:53:38 +00:00
}
2004-08-23 00:15:46 +00:00
if ( drop - > download )
{
2005-12-21 03:07:33 +00:00
VFS_CLOSE ( drop - > download ) ;
2004-08-23 00:15:46 +00:00
drop - > download = NULL ;
}
if ( drop - > upload )
{
2005-12-21 03:07:33 +00:00
VFS_CLOSE ( drop - > upload ) ;
2004-08-23 00:15:46 +00:00
drop - > upload = NULL ;
}
* drop - > uploadfn = 0 ;
# ifndef SERVERONLY
if ( drop - > netchan . remote_address . type = = NA_LOOPBACK )
{
2004-10-19 16:10:14 +00:00
Netchan_Transmit ( & drop - > netchan , 0 , " " , SV_RateForClient ( drop ) ) ;
2011-10-27 16:16:29 +00:00
# ifdef warningmsg
2013-10-08 14:28:11 +00:00
# pragma warningmsg("This means that we may not see the reason we kicked ourselves.")
2011-05-29 04:26:29 +00:00
# endif
2004-08-23 00:15:46 +00:00
drop - > state = cs_free ; //don't do zombie stuff
2014-03-30 08:55:06 +00:00
CL_BeginServerReconnect ( ) ;
2004-08-23 00:15:46 +00:00
}
else
# endif
2014-03-30 08:55:06 +00:00
if ( drop - > state = = cs_spawned | | drop - > istobeloaded )
2004-08-23 00:15:46 +00:00
{
2014-03-30 08:55:06 +00:00
drop - > istobeloaded = false ;
2004-08-23 00:15:46 +00:00
drop - > state = cs_zombie ; // become free in a few seconds
drop - > connection_started = realtime ; // for zombie timeout
}
2014-03-30 08:55:06 +00:00
else
drop - > state = cs_free ; //skip zombie state if qc couldn't access it anyway.
2004-08-23 00:15:46 +00:00
drop - > istobeloaded = false ;
drop - > old_frags = 0 ;
2005-11-03 23:40:51 +00:00
# ifdef SVRANKING
2004-08-23 00:15:46 +00:00
drop - > kills = 0 ;
drop - > deaths = 0 ;
2005-11-03 23:40:51 +00:00
# endif
2006-01-02 22:33:23 +00:00
drop - > namebuf [ 0 ] = 0 ;
drop - > name = drop - > namebuf ;
2004-08-23 00:15:46 +00:00
memset ( drop - > userinfo , 0 , sizeof ( drop - > userinfo ) ) ;
2007-08-30 20:45:01 +00:00
while ( ( lp = drop - > laggedpacket ) )
{
drop - > laggedpacket = lp - > next ;
lp - > next = svs . free_lagged_packet ;
svs . free_lagged_packet = lp ;
}
drop - > laggedpacket_last = NULL ;
2013-03-12 22:35:33 +00:00
drop - > pendingentbits = NULL ;
2006-02-17 02:51:59 +00:00
if ( drop - > frameunion . frames ) //union of the same sort of structure
2004-08-23 00:15:46 +00:00
{
2006-02-17 02:51:59 +00:00
Z_Free ( drop - > frameunion . frames ) ;
drop - > frameunion . frames = NULL ;
2004-08-23 00:15:46 +00:00
}
2012-02-12 05:18:31 +00:00
if ( drop - > sentents . entities )
{
Z_Free ( drop - > sentents . entities ) ;
memset ( & drop - > sentents . entities , 0 , sizeof ( drop - > sentents . entities ) ) ;
}
2004-08-23 00:15:46 +00:00
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( drop - > csqcentversions )
Z_Free ( drop - > csqcentversions ) ;
drop - > csqcentversions = NULL ;
if ( drop - > csqcentsequence )
Z_Free ( drop - > csqcentsequence ) ;
drop - > csqcentsequence = NULL ;
drop - > csqcactive = false ;
2013-05-03 04:28:08 +00:00
memset ( & termmsg , 0 , sizeof ( termmsg ) ) ;
termmsg . data = termbuf ;
termmsg . maxsize = sizeof ( termbuf ) ;
termmsg . cursize = 0 ;
2014-03-30 08:55:06 +00:00
if ( drop - > netchan . remote_address . type = = NA_LOOPBACK )
{
}
else if ( ISQWCLIENT ( drop ) | | ISNQCLIENT ( drop ) )
2013-05-03 04:28:08 +00:00
{
MSG_WriteByte ( & termmsg , svc_disconnect ) ;
}
else if ( ISQ2CLIENT ( drop ) )
{
MSG_WriteByte ( & termmsg , svcq2_disconnect ) ;
}
else if ( ISQ3CLIENT ( drop ) )
{
}
2013-05-14 12:56:26 +00:00
if ( drop - > netchan . remote_address . type ! = NA_INVALID )
{
//send twice, to cover packetloss a little.
Netchan_Transmit ( & drop - > netchan , termmsg . cursize , termmsg . data , 10000 ) ;
Netchan_Transmit ( & drop - > netchan , termmsg . cursize , termmsg . data , 10000 ) ;
}
2013-05-03 04:28:08 +00:00
2007-09-02 19:55:17 +00:00
if ( svs . gametype = = GT_PROGS | | svs . gametype = = GT_Q1QVM ) //gamecode should do it all for us.
2006-10-05 22:10:09 +00:00
{
2004-08-23 00:15:46 +00:00
// send notification to all remaining clients
2013-03-31 04:21:08 +00:00
SV_FullClientUpdate ( drop , NULL ) ;
2011-06-05 01:36:14 +00:00
SV_MVD_FullClientUpdate ( NULL , drop ) ;
2006-10-05 22:10:09 +00:00
}
2004-08-23 00:15:46 +00:00
if ( drop - > controlled )
{
drop - > controlled - > controller = NULL ;
SV_DropClient ( drop - > controlled ) ;
2010-12-23 03:55:10 +00:00
drop - > controlled = NULL ;
2004-08-23 00:15:46 +00:00
}
}
2005-12-15 19:15:39 +00:00
//====================================================================
typedef struct pinnedmessages_s {
struct pinnedmessages_s * next ;
char setby [ 64 ] ;
char message [ 1024 ] ;
} pinnedmessages_t ;
pinnedmessages_t * pinned ;
qboolean dopinnedload = true ;
void PIN_DeleteOldestMessage ( void ) ;
void PIN_MakeMessage ( char * from , char * msg ) ;
void PIN_LoadMessages ( void )
{
char setby [ 64 ] ;
char message [ 1024 ] ;
int i ;
2009-05-24 10:11:17 +00:00
char * file , * end ;
2005-12-15 19:15:39 +00:00
char * lstart ;
2009-05-24 10:11:17 +00:00
int len ;
2005-12-15 19:15:39 +00:00
dopinnedload = false ;
while ( pinned )
PIN_DeleteOldestMessage ( ) ;
2009-05-24 10:11:17 +00:00
len = FS_LoadFile ( " pinned.txt " , ( void * * ) & file ) ;
2005-12-15 19:15:39 +00:00
if ( ! file )
return ;
2009-05-24 10:11:17 +00:00
end = file + len ;
2006-03-04 15:47:58 +00:00
2005-12-15 19:15:39 +00:00
lstart = file ;
for ( ; ; )
{
2009-05-24 10:11:17 +00:00
while ( lstart < end & & * lstart < = ' ' )
2005-12-15 19:15:39 +00:00
lstart + + ;
2009-05-24 10:11:17 +00:00
for ( i = 0 ; lstart < end & & i < sizeof ( message ) - 1 ; i + + )
2005-12-15 19:15:39 +00:00
{
if ( * lstart = = ' \n ' | | * lstart = = ' \r ' )
break ;
message [ i ] = * lstart + + ;
}
message [ i ] = ' \0 ' ;
2009-05-24 10:11:17 +00:00
while ( lstart < end & & * lstart < = ' ' )
2005-12-15 19:15:39 +00:00
lstart + + ;
2009-05-24 10:11:17 +00:00
for ( i = 0 ; lstart < end & & i < sizeof ( setby ) - 1 ; i + + )
2005-12-15 19:15:39 +00:00
{
if ( * lstart = = ' \n ' | | * lstart = = ' \r ' )
break ;
setby [ i ] = * lstart + + ;
}
setby [ i ] = ' \0 ' ;
if ( ! * setby )
break ;
PIN_MakeMessage ( setby , message ) ;
}
2009-05-24 10:11:17 +00:00
FS_FreeFile ( file ) ;
2005-12-15 19:15:39 +00:00
}
void PIN_SaveMessages ( void )
{
pinnedmessages_t * p ;
2012-09-30 05:52:03 +00:00
vfsfile_t * f ;
2005-12-15 19:15:39 +00:00
2013-03-31 04:21:08 +00:00
f = FS_OpenVFS ( " pinned.txt " , " wb " , FS_GAMEONLY ) ;
2005-12-15 19:15:39 +00:00
if ( ! f )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " couldn't write to %s \n " , " pinned.txt " ) ;
2005-12-15 19:15:39 +00:00
return ;
}
for ( p = pinned ; p ; p = p - > next )
2012-09-30 05:52:03 +00:00
VFS_PRINTF ( f , " %s \r \n \t %s \r \n \n " , p - > message , p - > setby ) ;
2005-12-15 19:15:39 +00:00
2012-09-30 05:52:03 +00:00
VFS_CLOSE ( f ) ;
2005-12-15 19:15:39 +00:00
}
void PIN_DeleteOldestMessage ( void )
{
2013-03-31 04:21:08 +00:00
pinnedmessages_t * old ;
if ( dopinnedload )
PIN_LoadMessages ( ) ;
old = pinned ;
2006-02-22 23:30:38 +00:00
if ( old )
{
pinned = pinned - > next ;
Z_Free ( old ) ;
}
2005-12-15 19:15:39 +00:00
}
void PIN_MakeMessage ( char * from , char * msg )
{
pinnedmessages_t * p ;
2006-06-02 17:42:36 +00:00
pinnedmessages_t * newp ;
2005-12-15 19:15:39 +00:00
2013-03-31 04:21:08 +00:00
if ( dopinnedload )
PIN_LoadMessages ( ) ;
2006-06-02 17:42:36 +00:00
newp = BZ_Malloc ( sizeof ( pinnedmessages_t ) ) ;
Q_strncpyz ( newp - > setby , from , sizeof ( newp - > setby ) ) ;
Q_strncpyz ( newp - > message , msg , sizeof ( newp - > message ) ) ;
newp - > next = NULL ;
2005-12-15 19:15:39 +00:00
if ( ! pinned )
2006-06-02 17:42:36 +00:00
pinned = newp ;
2005-12-15 19:15:39 +00:00
else
{
for ( p = pinned ; ; p = p - > next )
{
if ( ! p - > next )
{
2006-06-02 17:42:36 +00:00
p - > next = newp ;
2005-12-15 19:15:39 +00:00
break ;
}
}
}
}
void PIN_ShowMessages ( client_t * cl )
{
pinnedmessages_t * p ;
if ( dopinnedload )
PIN_LoadMessages ( ) ;
if ( ! pinned )
return ;
2006-03-04 15:47:58 +00:00
SV_ClientPrintf ( cl , PRINT_HIGH , " \n \n \n " ) ;
2005-12-15 19:15:39 +00:00
for ( p = pinned ; p ; p = p - > next )
{
2006-03-04 15:47:58 +00:00
SV_ClientPrintf ( cl , PRINT_HIGH , " %s \n \n %s \n " , p - > message , p - > setby ) ;
SV_ClientPrintf ( cl , PRINT_HIGH , " \n \n \n " ) ;
2005-12-15 19:15:39 +00:00
}
}
2004-08-23 00:15:46 +00:00
//====================================================================
/*
= = = = = = = = = = = = = = = = = = =
SV_CalcPing
= = = = = = = = = = = = = = = = = = =
*/
2010-02-06 01:25:04 +00:00
int SV_CalcPing ( client_t * cl , qboolean forcecalc )
2004-08-23 00:15:46 +00:00
{
float ping ;
int i ;
int count ;
2006-02-17 02:51:59 +00:00
if ( ! cl - > frameunion . frames )
2004-08-23 00:15:46 +00:00
return 0 ;
2005-05-26 12:55:34 +00:00
switch ( cl - > protocol )
2004-08-23 00:15:46 +00:00
{
2013-07-14 12:22:51 +00:00
default :
2007-08-07 19:16:32 +00:00
case SCP_BAD :
break ;
2013-07-14 12:22:51 +00:00
# ifdef Q2SERVER
2007-08-07 19:16:32 +00:00
case SCP_QUAKE2 :
2013-03-12 22:53:23 +00:00
{
q2client_frame_t * frame ;
ping = 0 ;
count = 0 ;
for ( frame = cl - > frameunion . q2frames , i = 0 ; i < Q2UPDATE_BACKUP ; i + + , frame + + )
{
if ( frame - > ping_time > 0 )
{
ping + = frame - > ping_time ;
count + + ;
}
}
if ( ! count )
return 9999 ;
ping / = count ;
}
return ping ;
2013-07-14 12:22:51 +00:00
# endif
2007-08-07 19:16:32 +00:00
case SCP_QUAKE3 :
break ;
2005-05-27 05:41:07 +00:00
case SCP_DARKPLACES6 :
case SCP_DARKPLACES7 :
2007-08-07 19:16:32 +00:00
case SCP_NETQUAKE :
2012-10-01 14:29:44 +00:00
case SCP_PROQUAKE :
2011-10-27 16:16:29 +00:00
case SCP_FITZ666 :
2005-05-26 12:55:34 +00:00
case SCP_QUAKEWORLD :
2004-08-23 00:15:46 +00:00
{
2013-03-12 22:53:23 +00:00
register client_frame_t * frame ;
ping = 0 ;
count = 0 ;
for ( frame = cl - > frameunion . frames , i = 0 ; i < UPDATE_BACKUP ; i + + , frame + + )
2005-05-26 12:55:34 +00:00
{
2013-03-12 22:53:23 +00:00
if ( frame - > ping_time > 0 )
{
ping + = frame - > ping_time ;
count + + ;
}
2005-05-26 12:55:34 +00:00
}
2013-03-12 22:53:23 +00:00
if ( ! count )
return 9999 ;
ping / = count ;
2004-08-23 00:15:46 +00:00
}
2005-05-26 12:55:34 +00:00
return ping * 1000 ;
}
return 0 ;
2004-08-23 00:15:46 +00:00
}
2013-07-13 12:14:32 +00:00
//generate whatever public userinfo is supported by the client.
//private keys like _ prefixes and the password key are stripped out here.
//password needs to be stripped in case the password key doesn't actually relate to this server.
void SV_GeneratePublicUserInfo ( int pext , client_t * cl , char * info , int infolength )
2005-12-15 19:15:39 +00:00
{
char * key , * s ;
int i ;
2013-07-13 12:14:32 +00:00
//FIXME: we should probably use some sort of priority system instead if I'm honest about it
if ( pext & PEXT_BIGUSERINFOS )
2013-07-14 16:39:21 +00:00
Q_strncpyz ( info , cl - > userinfo , infolength ) ;
2013-07-13 12:14:32 +00:00
else
2005-12-15 19:15:39 +00:00
{
2013-07-13 12:14:32 +00:00
if ( infolength > = BASIC_INFO_STRING )
infolength = BASIC_INFO_STRING ;
2013-07-14 16:39:21 +00:00
* info = 0 ;
2013-07-13 12:14:32 +00:00
for ( i = 0 ; ( key = Info_KeyForNumber ( cl - > userinfo , i ) ) ; i + + )
{
if ( ! * key )
break ;
if ( ! SV_UserInfoIsBasic ( key ) )
continue ;
2005-12-15 19:15:39 +00:00
2013-07-13 12:14:32 +00:00
s = Info_ValueForKey ( cl - > userinfo , key ) ;
Info_SetValueForStarKey ( info , key , s , infolength ) ;
}
2005-12-15 19:15:39 +00:00
}
2013-07-13 12:14:32 +00:00
Info_RemovePrefixedKeys ( info , ' _ ' ) ; // server passwords, etc
Info_RemoveKey ( info , " password " ) ;
Info_RemoveKey ( info , " *ip " ) ;
2005-12-15 19:15:39 +00:00
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = = =
SV_FullClientUpdate
2013-03-31 04:21:08 +00:00
Writes all update values to client . use to = NULL to broadcast .
2004-08-23 00:15:46 +00:00
= = = = = = = = = = = = = = = = = = =
*/
2013-03-31 04:21:08 +00:00
void SV_FullClientUpdate ( client_t * client , client_t * to )
2004-08-23 00:15:46 +00:00
{
int i ;
2013-07-13 12:14:32 +00:00
char info [ EXTENDED_INFO_STRING ] ;
2004-08-23 00:15:46 +00:00
2013-03-31 04:21:08 +00:00
if ( ! to )
{
for ( i = 0 ; i < sv . allocated_client_slots ; i + + )
{
SV_FullClientUpdate ( client , & svs . clients [ i ] ) ;
}
2013-07-13 12:14:32 +00:00
if ( sv . mvdrecording )
2013-07-14 16:39:21 +00:00
SV_FullClientUpdate ( client , & demo . recorder ) ;
2013-03-31 04:21:08 +00:00
return ;
}
2013-06-23 02:17:02 +00:00
if ( to - > controller & & to - > controller ! = to )
return ;
2004-08-23 00:15:46 +00:00
i = client - svs . clients ;
2013-06-23 02:17:02 +00:00
if ( i > = to - > max_net_clients )
return ; //most clients will crash if they see too high a player index. some even segfault.
2013-03-31 04:21:08 +00:00
//Sys_Printf("SV_FullClientUpdate: Updated frags for client %d\n", i);
if ( ISQWCLIENT ( to ) )
2004-08-23 00:15:46 +00:00
{
2014-02-07 08:38:40 +00:00
int ping = SV_CalcPing ( client , false ) ;
if ( ping > 0xffff )
ping = 0xffff ;
2013-03-31 04:21:08 +00:00
ClientReliableWrite_Begin ( to , svc_updatefrags , 4 ) ;
ClientReliableWrite_Byte ( to , i ) ;
ClientReliableWrite_Short ( to , client - > old_frags ) ;
2005-07-03 15:16:20 +00:00
2013-03-31 04:21:08 +00:00
ClientReliableWrite_Begin ( to , svc_updateping , 4 ) ;
ClientReliableWrite_Byte ( to , i ) ;
2014-02-07 08:38:40 +00:00
ClientReliableWrite_Short ( to , ping ) ;
2005-07-03 15:16:20 +00:00
2013-03-31 04:21:08 +00:00
ClientReliableWrite_Begin ( to , svc_updatepl , 3 ) ;
ClientReliableWrite_Byte ( to , i ) ;
ClientReliableWrite_Byte ( to , client - > lossage ) ;
2005-07-03 15:16:20 +00:00
2013-03-31 04:21:08 +00:00
ClientReliableWrite_Begin ( to , svc_updateentertime , 6 ) ;
ClientReliableWrite_Byte ( to , i ) ;
ClientReliableWrite_Float ( to , realtime - client - > connection_started ) ;
2004-08-23 00:15:46 +00:00
2013-07-13 12:14:32 +00:00
SV_GeneratePublicUserInfo ( to - > fteprotocolextensions , client , info , sizeof ( info ) ) ;
2004-08-23 00:15:46 +00:00
2013-03-31 04:21:08 +00:00
ClientReliableWrite_Begin ( to , svc_updateuserinfo , 7 + strlen ( info ) ) ;
ClientReliableWrite_Byte ( to , i ) ;
ClientReliableWrite_Long ( to , client - > userid ) ;
ClientReliableWrite_String ( to , info ) ;
2004-08-23 00:15:46 +00:00
}
2013-03-31 04:21:08 +00:00
else if ( ISNQCLIENT ( to ) )
{
int top , bottom , playercolor ;
char * nam = Info_ValueForKey ( client - > userinfo , " name " ) ;
2004-08-23 00:15:46 +00:00
2013-03-31 04:21:08 +00:00
ClientReliableWrite_Begin ( to , svc_updatefrags , 4 ) ;
ClientReliableWrite_Byte ( to , i ) ;
ClientReliableWrite_Short ( to , client - > old_frags ) ;
2005-07-03 15:16:20 +00:00
2013-03-31 04:21:08 +00:00
ClientReliableWrite_Begin ( to , svc_updatename , 3 + strlen ( nam ) ) ;
ClientReliableWrite_Byte ( to , i ) ;
ClientReliableWrite_String ( to , nam ) ;
2004-08-23 00:15:46 +00:00
2013-03-31 04:21:08 +00:00
top = atoi ( Info_ValueForKey ( client - > userinfo , " topcolor " ) ) ;
bottom = atoi ( Info_ValueForKey ( client - > userinfo , " bottomcolor " ) ) ;
top & = 15 ;
if ( top > 13 )
top = 13 ;
bottom & = 15 ;
if ( bottom > 13 )
bottom = 13 ;
playercolor = top * 16 + bottom ;
2004-08-23 00:15:46 +00:00
2013-03-31 04:21:08 +00:00
ClientReliableWrite_Begin ( to , svc_updatecolors , 3 ) ;
ClientReliableWrite_Byte ( to , i ) ;
ClientReliableWrite_Byte ( to , playercolor ) ;
2004-08-23 00:15:46 +00:00
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
CONNECTIONLESS COMMANDS
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2005-10-07 16:48:12 +00:00
# define STATUS_OLDSTYLE 0
# define STATUS_SERVERINFO 1
# define STATUS_PLAYERS 2
# define STATUS_SPECTATORS 4
# define STATUS_SPECTATORS_AS_PLAYERS 8 //for ASE - change only frags: show as "S"
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = =
SVC_Status
Responds with all the info that qplug or qspy can see
This message can be up to around 5 k with worst case string lengths .
= = = = = = = = = = = = = = = =
*/
void SVC_Status ( void )
{
2005-10-07 16:27:40 +00:00
int displayflags ;
2004-08-23 00:15:46 +00:00
int i ;
client_t * cl ;
2005-10-07 16:48:12 +00:00
char * name ;
2004-08-23 00:15:46 +00:00
int ping ;
int top , bottom ;
2005-10-07 16:48:12 +00:00
char frags [ 64 ] ;
2004-08-23 00:15:46 +00:00
int slots = 0 ;
2005-10-07 16:48:12 +00:00
displayflags = atoi ( Cmd_Argv ( 1 ) ) ;
if ( displayflags = = STATUS_OLDSTYLE )
displayflags = STATUS_SERVERINFO | STATUS_PLAYERS ;
2005-10-07 16:27:40 +00:00
2004-12-08 04:14:52 +00:00
Cmd_TokenizeString ( " status " , false , false ) ;
2013-11-29 14:36:47 +00:00
SV_BeginRedirect ( RD_PACKET , TL_FindLanguage ( " " ) ) ;
2005-10-07 16:48:12 +00:00
if ( displayflags & STATUS_SERVERINFO )
2005-10-07 16:27:40 +00:00
Con_Printf ( " %s \n " , svs . info ) ;
2013-12-02 14:30:30 +00:00
for ( i = 0 ; i < svs . allocated_client_slots ; i + + )
2004-08-23 00:15:46 +00:00
{
cl = & svs . clients [ i ] ;
2005-10-07 16:48:12 +00:00
if ( ( cl - > state = = cs_connected | | cl - > state = = cs_spawned | | cl - > name [ 0 ] ) & & ( ( cl - > spectator & & displayflags & STATUS_SPECTATORS ) | | ( ! cl - > spectator & & displayflags & STATUS_PLAYERS ) ) )
2004-08-23 00:15:46 +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 ) ;
2010-02-06 01:25:04 +00:00
ping = SV_CalcPing ( cl , false ) ;
2005-10-07 16:48:12 +00:00
name = cl - > name ;
2004-08-23 00:15:46 +00:00
if ( ! cl - > state ) //show bots differently. Just to be courteous.
2005-07-03 15:16:20 +00:00
Con_Printf ( " %i %i %i %i \" BOT:%s \" \" %s \" %i %i \n " , cl - > userid ,
2004-08-23 00:15:46 +00:00
cl - > old_frags , ( int ) ( realtime - cl - > connection_started ) / 60 ,
ping , cl - > name , Info_ValueForKey ( cl - > userinfo , " skin " ) , top , bottom ) ;
else
2005-10-07 16:48:12 +00:00
{
if ( cl - > spectator )
{ //silly mvdsv stuff
if ( displayflags & STATUS_SPECTATORS_AS_PLAYERS )
{
frags [ 0 ] = ' S ' ;
frags [ 1 ] = ' \0 ' ;
}
else
{
ping = - ping ;
sprintf ( frags , " %i " , - 9999 ) ;
name = va ( " \\ s \\ %s " , name ) ;
}
}
else
sprintf ( frags , " %i " , cl - > old_frags ) ;
Con_Printf ( " %i %s %i %i \" %s \" \" %s \" %i %i \n " , cl - > userid ,
frags , ( int ) ( realtime - cl - > connection_started ) / 60 ,
ping , name , Info_ValueForKey ( cl - > userinfo , " skin " ) , top , bottom ) ;
}
2004-08-23 00:15:46 +00:00
}
else
slots + + ;
}
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
SV_EndRedirect ( ) ;
}
2005-07-03 15:16:20 +00:00
# ifdef NQPROT
2009-04-01 22:03:56 +00:00
void SVC_GetInfo ( char * challenge , int fullstatus )
2005-05-26 12:55:34 +00:00
{
//dpmaster support
2009-04-01 22:03:56 +00:00
char response [ MAX_UDP_PACKET ] ;
2005-05-26 12:55:34 +00:00
client_t * cl ;
int numclients = 0 ;
int i ;
char * resp ;
2014-03-30 08:55:06 +00:00
const char * gamestatus ;
2009-04-01 22:03:56 +00:00
eval_t * v ;
2005-05-26 12:55:34 +00:00
2012-01-28 10:30:44 +00:00
if ( ! sv_listen_nq . ival & & ! sv_listen_dp . ival )
return ;
2013-12-02 14:30:30 +00:00
for ( i = 0 ; i < svs . allocated_client_slots ; i + + )
2005-05-26 12:55:34 +00:00
{
cl = & svs . clients [ i ] ;
if ( ( cl - > state = = cs_connected | | cl - > state = = cs_spawned | | cl - > name [ 0 ] ) & & ! cl - > spectator )
numclients + + ;
}
2009-04-01 22:03:56 +00:00
if ( svprogfuncs )
{
2011-05-20 04:10:46 +00:00
v = PR_FindGlobal ( svprogfuncs , " worldstatus " , PR_ANY , NULL ) ;
2009-04-01 22:03:56 +00:00
if ( v )
gamestatus = PR_GetString ( svprogfuncs , v - > string ) ;
else
gamestatus = " " ;
}
else
gamestatus = " " ;
resp = response ;
//response packet header
* resp + + = 0xff ;
* resp + + = 0xff ;
* resp + + = 0xff ;
* resp + + = 0xff ;
if ( fullstatus )
Q_strncpyz ( resp , " statusResponse " , sizeof ( response ) - ( resp - response ) - 1 ) ;
else
Q_strncpyz ( resp , " infoResponse " , sizeof ( response ) - ( resp - response ) - 1 ) ;
resp + = strlen ( resp ) ;
* resp + + = ' \n ' ;
//first line is the serverinfo
Q_strncpyz ( resp , svs . info , sizeof ( response ) - ( resp - response ) ) ;
2012-01-28 10:30:44 +00:00
//this is a DP protocol query, so some QW fields are not needed
2009-04-01 22:03:56 +00:00
Info_RemoveKey ( resp , " maxclients " ) ;
Info_RemoveKey ( resp , " map " ) ;
2011-07-30 14:14:56 +00:00
Info_SetValueForKey ( resp , " gamename " , com_protocolname . string , sizeof ( response ) - ( resp - response ) ) ;
2009-04-01 22:03:56 +00:00
Info_SetValueForKey ( resp , " modname " , com_modname . string , sizeof ( response ) - ( resp - response ) ) ;
Info_SetValueForKey ( resp , " protocol " , va ( " %d " , NET_PROTOCOL_VERSION ) , sizeof ( response ) - ( resp - response ) ) ;
Info_SetValueForKey ( resp , " clients " , va ( " %d " , numclients ) , sizeof ( response ) - ( resp - response ) ) ;
Info_SetValueForKey ( resp , " sv_maxclients " , maxclients . string , sizeof ( response ) - ( resp - response ) ) ;
Info_SetValueForKey ( resp , " mapname " , Info_ValueForKey ( svs . info , " map " ) , sizeof ( response ) - ( resp - response ) ) ;
Info_SetValueForKey ( resp , " qcstatus " , gamestatus , sizeof ( response ) - ( resp - response ) ) ;
Info_SetValueForKey ( resp , " challenge " , challenge , sizeof ( response ) - ( resp - response ) ) ;
resp + = strlen ( resp ) ;
* resp + + = 0 ; //there's already a null, but hey
if ( fullstatus )
{
client_t * cl ;
char * start = resp ;
if ( resp ! = response + sizeof ( response ) )
{
resp [ - 1 ] = ' \n ' ; //replace the null terminator that we already wrote
//on the following lines we have an entry for each client
2013-12-02 14:30:30 +00:00
for ( i = 0 ; i < svs . allocated_client_slots ; i + + )
2009-04-01 22:03:56 +00:00
{
cl = & svs . clients [ i ] ;
if ( ( cl - > state = = cs_connected | | cl - > state = = cs_spawned | | cl - > name [ 0 ] ) & & ! cl - > spectator )
{
Q_strncpyz ( resp , va (
" %d %d \" %s \" \" %s \" \n "
,
cl - > old_frags ,
2010-02-06 01:25:04 +00:00
SV_CalcPing ( cl , false ) ,
2009-04-01 22:03:56 +00:00
cl - > team ,
cl - > name
) , sizeof ( response ) - ( resp - response ) ) ;
resp + = strlen ( resp ) ;
}
}
* resp + + = 0 ; //this might not be a null
if ( resp = = response + sizeof ( response ) )
{
//we're at the end of the buffer, it's full. bummer
//replace 12 bytes with infoResponse
memcpy ( response + 4 , " infoResponse " , 12 ) ;
//move down by len(statusResponse)-len(infoResponse) bytes
memmove ( response + 4 + 12 , response + 4 + 14 , resp - response - ( 4 + 14 ) ) ;
start - = 14 - 12 ; //fix this pointer
resp = start ;
resp [ - 1 ] = 0 ; //reset the \n
}
}
}
2005-05-26 12:55:34 +00:00
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , resp - response , response , & net_from ) ;
2005-05-26 12:55:34 +00:00
}
2005-07-03 15:16:20 +00:00
# endif
2005-05-26 12:55:34 +00:00
2005-07-03 15:16:20 +00:00
# ifdef Q2SERVER
2004-08-23 00:15:46 +00:00
void SVC_InfoQ2 ( void )
{
char string [ 64 ] ;
int i , count ;
int version ;
if ( maxclients . value = = 1 )
return ; // ignore in single player
version = atoi ( Cmd_Argv ( 1 ) ) ;
if ( version ! = PROTOCOL_VERSION_Q2 )
2006-03-06 01:41:09 +00:00
snprintf ( string , sizeof ( string ) , " %s: wrong version \n " , hostname . string ) ;
2004-08-23 00:15:46 +00:00
else
{
count = 0 ;
2013-12-02 14:30:30 +00:00
for ( i = 0 ; i < svs . allocated_client_slots ; i + + )
2004-08-23 00:15:46 +00:00
if ( svs . clients [ i ] . state > = cs_connected )
count + + ;
2006-03-06 01:41:09 +00:00
snprintf ( string , sizeof ( string ) , " %16s %8s %2i/%2i \n " , hostname . string , sv . name , count , ( int ) maxclients . value ) ;
2004-08-23 00:15:46 +00:00
}
2013-05-03 04:28:08 +00:00
Netchan_OutOfBandPrint ( NS_SERVER , & net_from , " info \n %s " , string ) ;
2004-08-23 00:15:46 +00:00
}
2005-07-03 15:16:20 +00:00
# endif
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = = =
SV_CheckLog
= = = = = = = = = = = = = = = = = = =
*/
# define LOG_FLUSH 10*60
void SV_CheckLog ( void )
{
sizebuf_t * sz ;
2014-04-24 01:53:01 +00:00
sz = & svs . log [ svs . logsequence & ( FRAGLOG_BUFFERS - 1 ) ] ;
2004-08-23 00:15:46 +00:00
2014-04-24 01:53:01 +00:00
// bump sequence ten minutes have passed and
2004-08-23 00:15:46 +00:00
// there is something still sitting there
2014-04-24 01:53:01 +00:00
//logfrag does the rotation for a full log.
if ( realtime - svs . logtime > LOG_FLUSH & & sz - > cursize )
2004-08-23 00:15:46 +00:00
{
// swap buffers and bump sequence
svs . logtime = realtime ;
svs . logsequence + + ;
2014-04-24 01:53:01 +00:00
sz = & svs . log [ svs . logsequence & ( FRAGLOG_BUFFERS - 1 ) ] ;
2004-08-23 00:15:46 +00:00
sz - > cursize = 0 ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " beginning fraglog sequence %i \n " , svs . logsequence ) ;
2004-08-23 00:15:46 +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 .
= = = = = = = = = = = = = = = =
*/
void SVC_Log ( void )
{
2014-04-24 01:53:01 +00:00
unsigned int seq ;
2004-08-23 00:15:46 +00:00
char data [ MAX_DATAGRAM + 64 ] ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2004-08-23 00:15:46 +00:00
if ( Cmd_Argc ( ) = = 2 )
2014-04-24 01:53:01 +00:00
{
seq = strtoul ( Cmd_Argv ( 1 ) , NULL , 0 ) ;
//seq is the last one that the client already has
if ( seq < svs . logsequence - ( FRAGLOG_BUFFERS - 1 ) )
seq = svs . logsequence - ( FRAGLOG_BUFFERS - 1 ) ; //send them this sequence
else if ( seq = = svs . logsequence )
{ //current log isn't available as its not complete yet.
data [ 0 ] = A2A_NACK ;
NET_SendPacket ( NS_SERVER , 1 , data , & net_from ) ;
return ;
}
else if ( seq > svs . logsequence ) //future logs are not valid either. reply with the last that was. this is for compat, just in case.
seq = svs . logsequence - 1 ;
else
seq = seq + 1 ; //they will get the next sequence from the one they already have
}
2004-08-23 00:15:46 +00:00
else
2014-04-24 01:53:01 +00:00
seq = 0 ;
2004-08-23 00:15:46 +00:00
2014-04-24 01:53:01 +00:00
if ( ! fraglog_public . ival )
{ //frag logs are not public (for DoS protection perhaps?.
2004-08-23 00:15:46 +00:00
data [ 0 ] = A2A_NACK ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , 1 , data , & net_from ) ;
2004-08-23 00:15:46 +00:00
return ;
}
2014-04-24 01:53:01 +00:00
Con_DPrintf ( " sending log %i to %s \n " , seq , NET_AdrToString ( adr , sizeof ( adr ) , & net_from ) ) ;
2004-08-23 00:15:46 +00:00
2014-04-24 01:53:01 +00:00
Q_snprintfz ( data , sizeof ( data ) , " stdlog %i \n %s " , seq , ( char * ) svs . log_buf [ seq & ( FRAGLOG_BUFFERS - 1 ) ] ) ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , strlen ( data ) + 1 , data , & net_from ) ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = =
SVC_Ping
Just responds with an acknowledgement
= = = = = = = = = = = = = = = =
*/
void SVC_Ping ( void )
{
char data ;
data = A2A_ACK ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , 1 , & data , & net_from ) ;
2004-08-23 00:15:46 +00:00
}
2005-05-26 12:55:34 +00:00
//from net_from
int SV_NewChallenge ( void )
{
int i ;
int oldest ;
int oldestTime ;
oldest = 0 ;
oldestTime = 0x7fffffff ;
// see if we already have a challenge for this ip
for ( i = 0 ; i < MAX_CHALLENGES ; i + + )
{
2013-05-03 04:28:08 +00:00
if ( NET_CompareBaseAdr ( & net_from , & svs . challenges [ i ] . adr ) )
2005-05-26 12:55:34 +00:00
return svs . challenges [ i ] . challenge ;
if ( svs . challenges [ i ] . time < oldestTime )
{
oldestTime = svs . challenges [ i ] . time ;
oldest = i ;
}
}
// overwrite the oldest
svs . challenges [ oldest ] . challenge = ( rand ( ) < < 16 ) ^ rand ( ) ;
svs . challenges [ oldest ] . adr = net_from ;
svs . challenges [ oldest ] . time = realtime ;
return svs . challenges [ oldest ] . challenge ;
}
2004-08-23 00:15:46 +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 .
= = = = = = = = = = = = = = = = =
*/
void SVC_GetChallenge ( void )
{
# ifdef HUFFNETWORK
int compressioncrc ;
# endif
int i ;
int oldest ;
int oldestTime ;
2008-11-09 22:29:28 +00:00
if ( ! sv_listen_qw . value & & ! sv_listen_dp . value & & ! sv_listen_q3 . value )
return ;
2004-08-23 00:15:46 +00:00
oldest = 0 ;
oldestTime = 0x7fffffff ;
// see if we already have a challenge for this ip
for ( i = 0 ; i < MAX_CHALLENGES ; i + + )
{
2013-05-03 04:28:08 +00:00
if ( NET_CompareBaseAdr ( & net_from , & svs . challenges [ i ] . adr ) )
2004-08-23 00:15:46 +00:00
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 ;
}
// send it back
{
char * buf ;
int lng ;
2005-03-07 08:58:26 +00:00
char * over ;
# ifdef Q3SERVER
if ( svs . gametype = = GT_QUAKE3 ) //q3 servers
buf = va ( " challengeResponse %i " , svs . challenges [ i ] . challenge ) ;
else
# endif
# ifdef Q2SERVER
if ( svs . gametype = = GT_QUAKE2 ) //quake 2 servers give a different challenge responce
2004-08-23 00:15:46 +00:00
buf = va ( " challenge %i " , svs . challenges [ i ] . challenge ) ;
else
2005-03-07 08:58:26 +00:00
# endif
2004-08-23 00:15:46 +00:00
buf = va ( " %c%i " , S2C_CHALLENGE , svs . challenges [ i ] . challenge ) ;
over = buf + strlen ( buf ) + 1 ;
2004-11-20 00:51:57 +00:00
2007-09-02 19:55:17 +00:00
if ( svs . gametype = = GT_PROGS | | svs . gametype = = GT_Q1QVM )
2004-08-23 00:15:46 +00:00
{
2004-11-20 00:51:57 +00:00
# ifdef PROTOCOL_VERSION_FTE
2012-02-12 05:18:31 +00:00
unsigned int mask ;
2004-11-20 00:51:57 +00:00
//tell the client what fte extensions we support
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
mask = Net_PextMask ( 1 , false ) ;
2012-02-12 05:18:31 +00:00
if ( mask )
2004-11-20 00:51:57 +00:00
{
lng = LittleLong ( PROTOCOL_VERSION_FTE ) ;
2008-02-05 02:44:01 +00:00
memcpy ( over , & lng , sizeof ( lng ) ) ;
over + = sizeof ( lng ) ;
2004-08-23 00:15:46 +00:00
2012-02-12 05:18:31 +00:00
lng = LittleLong ( mask ) ;
2008-02-05 02:44:01 +00:00
memcpy ( over , & lng , sizeof ( lng ) ) ;
over + = sizeof ( lng ) ;
2004-11-20 00:51:57 +00:00
}
2009-11-04 21:16:50 +00:00
//tell the client what fte extensions we support
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
mask = Net_PextMask ( 2 , false ) ;
2012-02-12 05:18:31 +00:00
if ( mask )
2009-11-04 21:16:50 +00:00
{
lng = LittleLong ( PROTOCOL_VERSION_FTE2 ) ;
memcpy ( over , & lng , sizeof ( lng ) ) ;
over + = sizeof ( lng ) ;
2012-02-12 05:18:31 +00:00
lng = LittleLong ( mask ) ;
2009-11-04 21:16:50 +00:00
memcpy ( over , & lng , sizeof ( lng ) ) ;
over + = sizeof ( lng ) ;
}
2004-08-23 00:15:46 +00:00
# endif
2012-02-12 05:18:31 +00:00
mask = net_mtu . ival & ~ 7 ;
if ( mask > 64 )
{
lng = LittleLong ( PROTOCOL_VERSION_FRAGMENT ) ;
memcpy ( over , & lng , sizeof ( lng ) ) ;
over + = sizeof ( lng ) ;
lng = LittleLong ( mask ) ;
memcpy ( over , & lng , sizeof ( lng ) ) ;
over + = sizeof ( lng ) ;
}
2004-08-23 00:15:46 +00:00
# ifdef HUFFNETWORK
2004-11-20 00:51:57 +00:00
compressioncrc = Huff_PreferedCompressionCRC ( ) ;
if ( compressioncrc )
{
2014-04-27 23:16:07 +00:00
lng = LittleLong ( PROTOCOL_VERSION_HUFFMAN ) ;
2008-02-05 02:44:01 +00:00
memcpy ( over , & lng , sizeof ( lng ) ) ;
over + = sizeof ( lng ) ;
2004-08-23 00:15:46 +00:00
2004-11-20 00:51:57 +00:00
lng = LittleLong ( compressioncrc ) ;
2008-02-05 02:44:01 +00:00
memcpy ( over , & lng , sizeof ( lng ) ) ;
over + = sizeof ( lng ) ;
2004-11-20 00:51:57 +00:00
}
2004-08-23 00:15:46 +00:00
# endif
2004-11-20 00:51:57 +00:00
}
2007-09-02 19:55:17 +00:00
if ( sv_listen_qw . value | | ( svs . gametype ! = GT_PROGS & & svs . gametype ! = GT_Q1QVM ) )
2013-05-03 04:28:08 +00:00
Netchan_OutOfBand ( NS_SERVER , & net_from , over - buf , buf ) ;
2004-08-23 00:15:46 +00:00
2007-07-27 21:24:31 +00:00
if ( sv_listen_dp . value & & ( sv_listen_nq . value | | sv_bigcoords . value | | ! sv_listen_qw . value ) )
2005-06-14 04:52:10 +00:00
{
2007-06-10 05:14:38 +00:00
//dp (protocol6 upwards) can respond to this (and fte won't get confused because the challenge will be wrong)
2005-11-26 21:15:39 +00:00
buf = va ( " challenge " DISTRIBUTION " %i " , svs . challenges [ i ] . challenge ) ;
2013-05-03 04:28:08 +00:00
Netchan_OutOfBand ( NS_SERVER , & net_from , strlen ( buf ) + 1 , buf ) ;
2005-06-14 04:52:10 +00:00
}
2008-11-09 22:29:28 +00:00
# ifdef Q3SERVER
if ( svs . gametype = = GT_PROGS | | svs . gametype = = GT_Q1QVM )
{
if ( sv_listen_q3 . value )
{
buf = va ( " challengeResponse %i " , svs . challenges [ i ] . challenge ) ;
2013-05-03 04:28:08 +00:00
Netchan_OutOfBand ( NS_SERVER , & net_from , strlen ( buf ) , buf ) ;
2013-05-14 12:56:26 +00:00
}
2008-11-09 22:29:28 +00:00
}
# endif
2004-08-23 00:15:46 +00:00
}
2005-07-03 15:16:20 +00:00
// Netchan_OutOfBandPrint (net_from, "%c%i", S2C_CHALLENGE,
2004-08-23 00:15:46 +00:00
// svs.challenges[i].challenge);
}
void SV_GetNewSpawnParms ( client_t * cl )
{
int i ;
2014-03-30 08:55:06 +00:00
2004-08-23 00:15:46 +00:00
if ( svprogfuncs ) //q2 dlls don't use parms in this mannor. It's all internal to the dll.
{
// call the progs to get default spawn parms for the new client
2007-09-02 19:55:17 +00:00
# ifdef VM_Q1
if ( svs . gametype = = GT_Q1QVM )
Q1QVM_SetNewParms ( ) ;
else
# endif
{
2011-10-27 16:16:29 +00:00
if ( pr_global_ptrs - > SetNewParms )
2007-09-02 19:55:17 +00:00
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > SetNewParms ) ;
}
2004-08-23 00:15:46 +00:00
for ( i = 0 ; i < NUM_SPAWN_PARMS ; i + + )
2005-06-22 17:10:13 +00:00
{
2011-10-27 16:16:29 +00:00
if ( pr_global_ptrs - > spawnparamglobals [ i ] )
cl - > spawn_parms [ i ] = * pr_global_ptrs - > spawnparamglobals [ i ] ;
2005-06-22 17:10:13 +00:00
else
cl - > spawn_parms [ i ] = 0 ;
}
2004-08-23 00:15:46 +00:00
}
}
2013-05-03 04:28:08 +00:00
void VARGS SV_OutOfBandPrintf ( int q2 , netadr_t * adr , char * format , . . . )
2004-08-23 00:15:46 +00:00
{
va_list argptr ;
2008-02-05 02:44:01 +00:00
char string [ 8192 ] ;
2004-08-23 00:15:46 +00:00
va_start ( argptr , format ) ;
if ( q2 )
{
strcpy ( string , " print \n " ) ;
2006-03-06 01:41:09 +00:00
vsnprintf ( string + 6 , sizeof ( string ) - 1 - 6 , format + 1 , argptr ) ;
2004-08-23 00:15:46 +00:00
}
else
{
string [ 0 ] = A2C_PRINT ;
string [ 1 ] = ' \n ' ;
2006-03-06 01:41:09 +00:00
vsnprintf ( string + 2 , sizeof ( string ) - 1 - 2 , format , argptr ) ;
2004-08-23 00:15:46 +00:00
}
va_end ( argptr ) ;
Netchan_OutOfBand ( NS_SERVER , adr , strlen ( string ) , ( qbyte * ) string ) ;
}
2013-05-03 04:28:08 +00:00
void VARGS SV_OutOfBandTPrintf ( int q2 , netadr_t * adr , int language , translation_t text , . . . )
2004-08-23 00:15:46 +00:00
{
va_list argptr ;
2008-02-05 02:44:01 +00:00
char string [ 8192 ] ;
2013-11-29 14:36:47 +00:00
const char * format = langtext ( text , language ) ;
2004-08-23 00:15:46 +00:00
va_start ( argptr , text ) ;
if ( q2 )
{
strcpy ( string , " print \n " ) ;
2006-03-06 01:41:09 +00:00
vsnprintf ( string + 6 , sizeof ( string ) - 1 - 6 , format + 1 , argptr ) ;
2004-08-23 00:15:46 +00:00
}
else
{
string [ 0 ] = A2C_PRINT ;
2006-03-06 01:41:09 +00:00
vsnprintf ( string + 1 , sizeof ( string ) - 1 - 1 , format , argptr ) ;
2004-08-23 00:15:46 +00:00
}
va_end ( argptr ) ;
Netchan_OutOfBand ( NS_SERVER , adr , strlen ( string ) , ( qbyte * ) string ) ;
}
2005-03-07 08:58:26 +00:00
qboolean SV_ChallengePasses ( int challenge )
{
int i ;
for ( i = 0 ; i < MAX_CHALLENGES ; i + + )
{ //one per ip.
2013-05-03 04:28:08 +00:00
if ( NET_CompareBaseAdr ( & net_from , & svs . challenges [ i ] . adr ) )
2005-03-07 08:58:26 +00:00
{
if ( challenge = = svs . challenges [ i ] . challenge )
return true ;
return false ;
}
}
return false ;
}
2005-08-03 23:14:59 +00:00
void VARGS SV_RejectMessage ( int protocol , char * format , . . . )
2005-05-26 12:55:34 +00:00
{
va_list argptr ;
char string [ 8192 ] ;
int len ;
va_start ( argptr , format ) ;
switch ( protocol )
{
# ifdef NQPROT
case SCP_NETQUAKE :
2011-10-27 16:16:29 +00:00
case SCP_FITZ666 :
2012-10-01 14:29:44 +00:00
case SCP_PROQUAKE :
2005-05-26 12:55:34 +00:00
string [ 4 ] = CCREP_REJECT ;
2006-03-06 01:41:09 +00:00
vsnprintf ( string + 5 , sizeof ( string ) - 1 - 5 , format , argptr ) ;
2005-05-26 12:55:34 +00:00
len = strlen ( string + 4 ) + 1 + 4 ;
* ( int * ) string = BigLong ( NETFLAG_CTL | len ) ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , len , string , & net_from ) ;
2005-05-26 12:55:34 +00:00
return ;
2005-05-27 05:41:07 +00:00
case SCP_DARKPLACES6 :
case SCP_DARKPLACES7 :
2005-05-26 12:55:34 +00:00
strcpy ( string , " reject " ) ;
2006-03-06 01:41:09 +00:00
vsnprintf ( string + 7 , sizeof ( string ) - 1 - 7 , format , argptr ) ;
2005-05-26 12:55:34 +00:00
len = strlen ( string ) ;
break ;
# endif
case SCP_QUAKE2 :
2008-11-09 22:29:28 +00:00
case SCP_QUAKE3 :
2005-05-26 12:55:34 +00:00
default :
strcpy ( string , " print \n " ) ;
2006-03-06 01:41:09 +00:00
vsnprintf ( string + 6 , sizeof ( string ) - 1 - 6 , format , argptr ) ;
2005-05-26 12:55:34 +00:00
len = strlen ( string ) ;
break ;
case SCP_QUAKEWORLD :
string [ 0 ] = A2C_PRINT ;
string [ 1 ] = ' \n ' ;
2006-03-06 01:41:09 +00:00
vsnprintf ( string + 2 , sizeof ( string ) - 1 - 2 , format , argptr ) ;
2005-05-26 12:55:34 +00:00
len = strlen ( string ) ;
break ;
}
va_end ( argptr ) ;
2013-05-03 04:28:08 +00:00
Netchan_OutOfBand ( NS_SERVER , & net_from , len , ( qbyte * ) string ) ;
2005-05-26 12:55:34 +00:00
}
void SV_AcceptMessage ( int protocol )
{
char string [ 8192 ] ;
sizebuf_t sb ;
int len ;
2008-11-09 22:29:28 +00:00
# ifdef NQPROT
netadr_t localaddr ;
# endif
2005-05-26 12:55:34 +00:00
memset ( & sb , 0 , sizeof ( sb ) ) ;
sb . maxsize = sizeof ( string ) ;
sb . data = string ;
switch ( protocol )
{
# ifdef NQPROT
case SCP_NETQUAKE :
2011-10-27 16:16:29 +00:00
case SCP_FITZ666 :
2012-10-01 14:29:44 +00:00
case SCP_PROQUAKE :
// if (net_from.type != NA_LOOPBACK)
2011-10-27 16:16:29 +00:00
{
SZ_Clear ( & sb ) ;
MSG_WriteLong ( & sb , 0 ) ;
MSG_WriteByte ( & sb , CCREP_ACCEPT ) ;
NET_LocalAddressForRemote ( svs . sockets , & net_from , & localaddr , 0 ) ;
MSG_WriteLong ( & sb , ShortSwap ( localaddr . port ) ) ;
2013-03-12 22:53:23 +00:00
MSG_WriteByte ( & sb , ( protocol = = SCP_NETQUAKE ) ? 0 : 1 /*MOD_PROQUAKE*/ ) ;
2012-10-01 14:29:44 +00:00
MSG_WriteByte ( & sb , 10 * 3.50 /*MOD_PROQUAKE_VERSION*/ ) ;
2011-10-27 16:16:29 +00:00
* ( int * ) sb . data = BigLong ( NETFLAG_CTL | sb . cursize ) ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , sb . cursize , sb . data , & net_from ) ;
2011-10-27 16:16:29 +00:00
return ;
}
2005-05-27 05:41:07 +00:00
case SCP_DARKPLACES6 :
case SCP_DARKPLACES7 :
2005-05-26 12:55:34 +00:00
strcpy ( string , " accept " ) ;
len = strlen ( string ) ;
break ;
# endif
2008-11-09 22:29:28 +00:00
case SCP_QUAKE3 :
strcpy ( string , " connectResponse " ) ;
len = strlen ( string ) ;
break ;
2005-05-26 12:55:34 +00:00
case SCP_QUAKE2 :
default :
2005-07-14 01:57:34 +00:00
strcpy ( string , " client_connect \n " ) ;
2005-05-26 12:55:34 +00:00
len = strlen ( string ) ;
break ;
case SCP_QUAKEWORLD :
string [ 0 ] = S2C_CONNECTION ;
string [ 1 ] = ' \n ' ;
string [ 2 ] = ' \0 ' ;
len = strlen ( string ) ;
break ;
}
2013-05-03 04:28:08 +00:00
Netchan_OutOfBand ( NS_SERVER , & net_from , len , ( qbyte * ) string ) ;
2005-05-26 12:55:34 +00:00
}
2011-06-06 01:41:33 +00:00
# ifndef _WIN32
# include <sys/stat.h>
static void SV_CheckRecentCrashes ( client_t * tellclient )
{
2013-08-07 14:20:24 +00:00
# ifndef FTE_TARGET_WEB
2011-06-06 01:41:33 +00:00
struct stat sb ;
if ( - 1 ! = stat ( " crash.log " , & sb ) )
{
2013-09-12 06:55:52 +00:00
if ( ( time ( NULL ) - sb . st_mtime ) > 2 * 24 * 60 * 60 )
2013-09-09 01:16:03 +00:00
return ; //after 2 days, we stop advertising that we once crashed.
2011-06-06 01:41:33 +00:00
SV_ClientPrintf ( tellclient , PRINT_HIGH , " \1 WARNING: crash.log exists, dated %s \n " , ctime ( & sb . st_mtime ) ) ;
}
2013-08-07 14:20:24 +00:00
# endif
2011-06-06 01:41:33 +00:00
}
# else
static void SV_CheckRecentCrashes ( client_t * tellclient )
{
}
# endif
2013-03-12 22:35:33 +00:00
void SV_ClientProtocolExtensionsChanged ( client_t * client )
{
int i ;
int maxpacketentities ;
extern cvar_t pr_maxedicts ;
2013-12-29 22:48:28 +00:00
//some gamecode can't cope with some extensions for some reasons... and I'm too lazy to fix the code to cope.
if ( svs . gametype = = GT_HALFLIFE )
client - > fteprotocolextensions2 & = ~ PEXT2_REPLACEMENTDELTAS ;
//
client - > maxmodels = 256 ;
2013-03-12 22:35:33 +00:00
if ( client - > fteprotocolextensions & PEXT_256PACKETENTITIES )
maxpacketentities = MAX_EXTENDED_PACKET_ENTITIES ;
else
maxpacketentities = MAX_STANDARD_PACKET_ENTITIES ; //true for qw,q2
2013-03-12 23:24:15 +00:00
if ( client - > fteprotocolextensions2 & PEXT2_REPLACEMENTDELTAS )
2013-03-12 22:35:33 +00:00
{
2013-06-23 02:17:02 +00:00
client - > max_net_clients = ISQWCLIENT ( client ) ? QWMAX_CLIENTS : NQMAX_CLIENTS ;
2013-03-12 23:24:15 +00:00
//you need to reconnect for this to update, of course. so make sure its not *too* low...
client - > max_net_ents = bound ( 512 , pr_maxedicts . ival , MAX_EDICTS ) ;
client - > maxmodels = MAX_MODELS ; //protocol limited to 14 bits.
}
else if ( ISQWCLIENT ( client ) ) //readd?
{
2013-06-23 02:17:02 +00:00
client - > max_net_clients = QWMAX_CLIENTS ;
2013-03-12 23:24:15 +00:00
client - > max_net_ents = 512 ;
if ( client - > fteprotocolextensions & PEXT_ENTITYDBL )
client - > max_net_ents + = 512 ;
if ( client - > fteprotocolextensions & PEXT_ENTITYDBL2 )
client - > max_net_ents + = 1024 ;
2013-03-12 22:35:33 +00:00
if ( client - > fteprotocolextensions & PEXT_MODELDBL )
client - > maxmodels = MAX_MODELS ;
}
else if ( ISDPCLIENT ( client ) )
{
2013-06-23 02:17:02 +00:00
client - > max_net_clients = 255 ;
2013-03-12 22:35:33 +00:00
client - > max_net_ents = bound ( 512 , pr_maxedicts . ival , 32768 ) ;
client - > maxmodels = 1024 ; //protocol limit of 16 bits. 15 bits for late precaches. client limit of 1k
client - > datagram . maxsize = sizeof ( host_client - > datagram_buf ) ;
}
else if ( client - > protocol = = SCP_FITZ666 )
{
2013-06-23 02:17:02 +00:00
client - > max_net_clients = NQMAX_CLIENTS ;
2014-03-30 08:55:06 +00:00
client - > max_net_ents = bound ( 512 , pr_maxedicts . ival , 32768 ) ; //fitzquake supports 65535, but our writeentity builtin works differently, which causes problems.
2013-03-12 22:35:33 +00:00
client - > maxmodels = 1024 ;
maxpacketentities = 512 ;
client - > datagram . maxsize = sizeof ( host_client - > datagram_buf ) ;
}
else
{
2013-06-23 02:17:02 +00:00
client - > max_net_clients = NQMAX_CLIENTS ;
2013-03-12 22:35:33 +00:00
client - > datagram . maxsize = MAX_NQDATAGRAM ; //vanilla limit
client - > max_net_ents = bound ( 512 , pr_maxedicts . ival , 600 ) ;
}
2013-06-23 02:17:02 +00:00
if ( client - > fteprotocolextensions2 & PEXT2_MAXPLAYERS )
client - > max_net_clients = MAX_CLIENTS ;
client - > max_net_clients = min ( client - > max_net_clients , MAX_CLIENTS ) ;
2013-03-12 22:35:33 +00:00
client - > pendingentbits = NULL ;
//initialise the client's frames, based on that client's protocol
switch ( client - > protocol )
{
# ifdef Q3SERVER
case SCP_QUAKE3 :
if ( client - > frameunion . q3frames )
Z_Free ( client - > frameunion . q3frames ) ;
client - > frameunion . q3frames = Z_Malloc ( Q3UPDATE_BACKUP * sizeof ( * client - > frameunion . q3frames ) ) ;
break ;
# endif
# ifdef Q2SERVER
case SCP_QUAKE2 :
// build a new connection
// accept the new client
// this is the only place a client_t is ever initialized
client - > frameunion . q2frames = client - > frameunion . q2frames ; //don't touch these.
if ( client - > frameunion . q2frames )
Z_Free ( client - > frameunion . q2frames ) ;
client - > frameunion . q2frames = Z_Malloc ( sizeof ( q2client_frame_t ) * Q2UPDATE_BACKUP ) ;
break ;
# endif
default :
if ( client - > frameunion . frames )
Z_Free ( client - > frameunion . frames ) ;
if ( ( client - > fteprotocolextensions2 & PEXT2_REPLACEMENTDELTAS ) ) // || ISDPCLIENT(&temp))
{
char * ptr ;
int maxents = client - > max_net_ents ; //maxpacketentities; /*this is the max number of ents updated per frame. we can't track more, so...*/
ptr = Z_Malloc ( sizeof ( client_frame_t ) * UPDATE_BACKUP +
sizeof ( * client - > pendingentbits ) * client - > max_net_ents +
sizeof ( unsigned int ) * maxents * UPDATE_BACKUP +
sizeof ( unsigned int ) * maxents * UPDATE_BACKUP ) ;
client - > frameunion . frames = ( void * ) ptr ;
ptr + = sizeof ( * client - > frameunion . frames ) * UPDATE_BACKUP ;
client - > pendingentbits = ( void * ) ptr ;
ptr + = sizeof ( * client - > pendingentbits ) * client - > max_net_ents ;
for ( i = 0 ; i < UPDATE_BACKUP ; i + + )
{
client - > frameunion . frames [ i ] . entities . max_entities = maxents ;
client - > frameunion . frames [ i ] . resendentnum = ( void * ) ptr ;
ptr + = sizeof ( * client - > frameunion . frames [ i ] . resendentnum ) * maxents ;
client - > frameunion . frames [ i ] . resendentbits = ( void * ) ptr ;
ptr + = sizeof ( * client - > frameunion . frames [ i ] . resendentbits ) * maxents ;
}
//make sure the reset is sent.
client - > pendingentbits [ 0 ] = UF_REMOVE ;
}
else
{
client - > frameunion . frames = Z_Malloc ( ( sizeof ( client_frame_t ) + sizeof ( entity_state_t ) * maxpacketentities ) * UPDATE_BACKUP ) ;
for ( i = 0 ; i < UPDATE_BACKUP ; i + + )
{
client - > frameunion . frames [ i ] . entities . max_entities = maxpacketentities ;
client - > frameunion . frames [ i ] . entities . entities = ( entity_state_t * ) ( client - > frameunion . frames + UPDATE_BACKUP ) + i * client - > frameunion . frames [ i ] . entities . max_entities ;
}
}
break ;
}
}
2014-03-30 08:55:06 +00:00
# ifdef SUBSERVERS
void MSV_UpdatePlayerStats ( qboolean initial , unsigned int playerid , unsigned int serverid , int numstats , float * stats ) ;
static char * knownmaps [ ] =
{
" " ,
" start "
} ;
static pubsubserver_t * subservers ;
qboolean isClusterSlave ;
unsigned int nextserverid ;
pubsubserver_t * MSV_StartSubServer ( unsigned int id , const char * mapname )
{
sizebuf_t send ;
char send_buf [ 64 ] ;
pubsubserver_t * s = Sys_ForkServer ( ) ;
if ( s )
{
if ( ! id )
{
if ( nextserverid < sizeof ( knownmaps ) / sizeof ( knownmaps [ 0 ] ) )
nextserverid = sizeof ( knownmaps ) / sizeof ( knownmaps [ 0 ] ) ;
id = nextserverid + + ;
}
s - > id = id ;
s - > next = subservers ;
subservers = s ;
Q_strncpyz ( s - > name , mapname , sizeof ( s - > name ) ) ;
memset ( & send , 0 , sizeof ( send ) ) ;
send . data = send_buf ;
send . maxsize = sizeof ( send_buf ) ;
send . cursize = 2 ;
MSG_WriteByte ( & send , ccmd_acceptserver ) ;
MSG_WriteLong ( & send , s - > id ) ;
MSG_WriteString ( & send , s - > name ) ;
Sys_InstructSlave ( s , & send ) ;
}
return s ;
}
pubsubserver_t * MSV_FindSubServer ( unsigned int id )
{
pubsubserver_t * s ;
for ( s = subservers ; s ; s = s - > next )
{
if ( id = = s - > id )
return s ;
}
if ( ! s & & id > = 1 & & id < sizeof ( knownmaps ) / sizeof ( knownmaps [ 0 ] ) )
s = MSV_StartSubServer ( id , knownmaps [ id ] ) ;
return s ;
}
pubsubserver_t * MSV_FindSubServerName ( const char * mapname )
{
pubsubserver_t * s ;
unsigned int to ;
for ( to = 1 ; to < sizeof ( knownmaps ) / sizeof ( knownmaps [ 0 ] ) ; to + + )
{
if ( ! strcmp ( knownmaps [ to ] , mapname ) )
return MSV_FindSubServer ( to ) ;
}
for ( s = subservers ; s ; s = s - > next )
{
if ( ! strcmp ( s - > name , mapname ) )
return s ;
}
return MSV_StartSubServer ( 0 , mapname ) ;
}
qboolean MSV_AddressForMap ( netadr_t * ret , int natype , int serverid )
{
pubsubserver_t * s = MSV_FindSubServer ( serverid ) ;
if ( s )
{
if ( natype = = s - > addrv6 . type )
* ret = s - > addrv6 ;
else
* ret = s - > addrv4 ;
return true ;
}
return false ;
}
void MSV_InstructSlave ( unsigned int id , sizebuf_t * cmd )
{
pubsubserver_t * s ;
if ( ! id )
{
for ( s = subservers ; s ; s = s - > next )
Sys_InstructSlave ( s , cmd ) ;
}
else
{
s = MSV_FindSubServer ( id ) ;
if ( s )
Sys_InstructSlave ( s , cmd ) ;
}
}
void MSV_MapCluster_f ( void )
{
SV_SpawnClusterMode ( ) ;
}
void SSV_PrintToMaster ( char * s )
{
sizebuf_t send ;
char send_buf [ 8192 ] ;
memset ( & send , 0 , sizeof ( send ) ) ;
send . data = send_buf ;
send . maxsize = sizeof ( send_buf ) ;
send . cursize = 2 ;
MSG_WriteByte ( & send , ccmd_print ) ;
MSG_WriteString ( & send , s ) ;
SSV_InstructMaster ( & send ) ;
}
void MSV_SubServerCommand_f ( void )
{
sizebuf_t buf ;
char bufmem [ 1024 ] ;
pubsubserver_t * s ;
int id ;
char * c ;
if ( Cmd_Argc ( ) = = 1 )
{
Con_Printf ( " Active servers on this cluster: \n " ) ;
for ( s = subservers ; s ; s = s - > next )
{
Con_Printf ( " %i: %s " , s - > id , s - > name ) ;
if ( s - > addrv4 . type ! = NA_INVALID )
Con_Printf ( " %s " , NET_AdrToString ( bufmem , sizeof ( bufmem ) , & s - > addrv4 ) ) ;
if ( s - > addrv6 . type ! = NA_INVALID )
Con_Printf ( " %s " , NET_AdrToString ( bufmem , sizeof ( bufmem ) , & s - > addrv6 ) ) ;
Con_Printf ( " \n " ) ;
}
return ;
}
if ( ! strcmp ( Cmd_Argv ( 0 ) , " ssv_all " ) )
id = 0 ;
else
{
id = atoi ( Cmd_Argv ( 1 ) ) ;
Cmd_ShiftArgs ( 1 , false ) ;
}
buf . data = bufmem ;
buf . maxsize = sizeof ( bufmem ) ;
buf . cursize = 2 ;
buf . packing = SZ_RAWBYTES ;
c = Cmd_Args ( ) ;
MSG_WriteByte ( & buf , ccmd_stuffcmd ) ;
MSG_WriteString ( & buf , c ) ;
buf . data [ 0 ] = buf . cursize & 0xff ;
buf . data [ 1 ] = ( buf . cursize > > 8 ) & 0xff ;
MSV_InstructSlave ( id , & buf ) ;
}
void MSV_ReadFromSubServer ( pubsubserver_t * s )
{
sizebuf_t send ;
qbyte send_buf [ MAX_QWMSGLEN ] ;
netadr_t adr ;
char * str ;
int c ;
c = MSG_ReadByte ( ) ;
switch ( c )
{
default :
case ccmd_bad :
Sys_Error ( " Corrupt message (%i) from SubServer %i:%s " , c , s - > id , s - > name ) ;
break ;
case ccmd_print :
Con_Printf ( " %s " , MSG_ReadString ( ) ) ;
break ;
case ccmd_saveplayer :
{
float stats [ NUM_SPAWN_PARMS ] ;
int i , numstats ;
unsigned int lastserver = MSG_ReadLong ( ) ;
int plid = MSG_ReadLong ( ) ;
numstats = MSG_ReadByte ( ) ;
for ( i = 0 ; i < numstats ; i + + )
stats [ i ] = MSG_ReadFloat ( ) ;
MSV_UpdatePlayerStats ( lastserver , plid , s - > id , numstats , stats ) ;
}
break ;
case ccmd_transferplayer :
{
char guid [ 64 ] ;
char mapname [ 64 ] ;
int plid = MSG_ReadLong ( ) ;
char * newmap = MSG_ReadStringBuffer ( mapname , sizeof ( mapname ) ) ;
char * claddr = MSG_ReadString ( ) ;
char * clguid = MSG_ReadStringBuffer ( guid , sizeof ( guid ) ) ;
pubsubserver_t * toptr ;
memset ( & send , 0 , sizeof ( send ) ) ;
send . data = send_buf ;
send . maxsize = sizeof ( send_buf ) ;
send . cursize = 2 ;
if ( NULL ! = ( toptr = MSV_FindSubServerName ( newmap ) ) )
{
Con_Printf ( " Transfer to %i:%s \n " , toptr - > id , toptr - > name ) ;
MSG_WriteByte ( & send , ccmd_takeplayer ) ;
MSG_WriteLong ( & send , plid ) ;
MSG_WriteLong ( & send , s - > id ) ;
MSG_WriteString ( & send , claddr ) ;
MSG_WriteString ( & send , clguid ) ;
c = MSG_ReadByte ( ) ;
MSG_WriteByte ( & send , c ) ;
Con_Printf ( " Transfer %i stats \n " , c ) ;
while ( c - - )
MSG_WriteFloat ( & send , MSG_ReadFloat ( ) ) ;
Sys_InstructSlave ( toptr , & send ) ;
}
else
{
//suck up the stats
c = MSG_ReadByte ( ) ;
while ( c - - )
MSG_ReadFloat ( ) ;
Con_Printf ( " Transfer abort \n " ) ;
MSG_WriteByte ( & send , ccmd_tookplayer ) ;
MSG_WriteLong ( & send , s - > id ) ;
MSG_WriteLong ( & send , plid ) ;
MSG_WriteString ( & send , " " ) ;
Sys_InstructSlave ( s , & send ) ;
}
}
break ;
case ccmd_tookplayer :
{
int to = MSG_ReadLong ( ) ;
int plid = MSG_ReadLong ( ) ;
char * claddr = MSG_ReadString ( ) ;
char * rmsg ;
netadr_t cladr ;
netadr_t svadr ;
char adrbuf [ 256 ] ;
Con_Printf ( " Took player \n " ) ;
memset ( & send , 0 , sizeof ( send ) ) ;
send . data = send_buf ;
send . maxsize = sizeof ( send_buf ) ;
send . cursize = 2 ;
NET_StringToAdr ( claddr , 0 , & cladr ) ;
MSV_AddressForMap ( & svadr , cladr . type , s - > id ) ;
if ( ! to )
{
if ( svadr . type ! = NA_INVALID )
{
rmsg = va ( " fredir \n %s " , NET_AdrToString ( adrbuf , sizeof ( adrbuf ) , & svadr ) ) ;
Netchan_OutOfBand ( NS_SERVER , & cladr , strlen ( rmsg ) , ( qbyte * ) rmsg ) ;
}
}
else
{
MSG_WriteByte ( & send , ccmd_tookplayer ) ;
MSG_WriteLong ( & send , s - > id ) ;
MSG_WriteLong ( & send , plid ) ;
MSG_WriteString ( & send , NET_AdrToString ( adrbuf , sizeof ( adrbuf ) , & svadr ) ) ;
MSV_InstructSlave ( to , & send ) ;
}
}
break ;
case ccmd_serveraddress :
s - > addrv4 . type = NA_INVALID ;
s - > addrv6 . type = NA_INVALID ;
str = MSG_ReadString ( ) ;
Q_strncpyz ( s - > name , str , sizeof ( s - > name ) ) ;
for ( ; ; )
{
str = MSG_ReadString ( ) ;
if ( ! * str )
break ;
if ( NET_StringToAdr ( str , 0 , & adr ) )
{
if ( adr . type = = NA_IP & & s - > addrv4 . type = = NA_INVALID )
s - > addrv4 = adr ;
if ( adr . type = = NA_IPV6 & & s - > addrv6 . type = = NA_INVALID )
s - > addrv6 = adr ;
}
}
Con_Printf ( " %i:%s: restarted \n " , s - > id , s - > name ) ;
break ;
}
if ( msg_readcount ! = net_message . cursize | | msg_badread )
Sys_Error ( " Master: Readcount isn't right (%i) \n " , net_message . data [ 0 ] ) ;
}
void MSV_PollSlaves ( void )
{
pubsubserver_t * * link , * s ;
for ( link = & subservers ; ( s = * link ) ; )
{
switch ( Sys_SubServerRead ( s ) )
{
case - 1 :
//error - server is dead and needs to be freed.
* link = s - > next ;
Z_Free ( s ) ;
break ;
case 0 :
//no messages
link = & s - > next ;
break ;
case 1 :
//got a message. read it and see if there's more.
MSV_ReadFromSubServer ( s ) ;
break ;
}
}
}
void SSV_ReadFromControlServer ( void )
{
int c ;
char * s ;
c = MSG_ReadByte ( ) ;
switch ( c )
{
case ccmd_bad :
default :
SV_Error ( " Invalid message from cluster (%i) \n " , c ) ;
break ;
case ccmd_stuffcmd :
s = MSG_ReadString ( ) ;
SV_BeginRedirect ( RD_MASTER , 0 ) ;
Cmd_ExecuteString ( s , RESTRICT_LOCAL ) ;
SV_EndRedirect ( ) ;
break ;
case ccmd_acceptserver :
svs . clusterserverid = MSG_ReadLong ( ) ;
s = MSG_ReadString ( ) ;
if ( * s & & ! strchr ( s , ' ; ' ) & & ! strchr ( s , ' \n ' ) & & ! strchr ( s , ' \" ' ) ) //sanity check the argument
Cmd_ExecuteString ( va ( " map \" %s \" " , s ) , RESTRICT_LOCAL ) ;
if ( svprogfuncs & & pr_global_ptrs - > serverid )
* pr_global_ptrs - > serverid = svs . clusterserverid ;
break ;
case ccmd_tookplayer :
{
client_t * cl = NULL ;
int to = MSG_ReadLong ( ) ;
int plid = MSG_ReadLong ( ) ;
char * addr = MSG_ReadString ( ) ;
int i ;
Con_Printf ( " %s: got tookplayer \n " , sv . name ) ;
for ( i = 0 ; i < svs . allocated_client_slots ; i + + )
{
if ( svs . clients [ i ] . state & & svs . clients [ i ] . userid = = plid )
{
cl = & svs . clients [ i ] ;
break ;
}
}
if ( cl )
{
if ( ! * addr )
{
Con_Printf ( " %s: tookplayer: failed \n " , sv . name ) ;
Info_SetValueForStarKey ( cl - > userinfo , " *transfer " , " " , sizeof ( cl - > userinfo ) ) ;
}
else
{
Con_Printf ( " %s: tookplayer: do transfer \n " , sv . name ) ;
// SV_StuffcmdToClient(cl, va("connect \"%s\"\n", addr));
SV_StuffcmdToClient ( cl , va ( " cl_transfer \" %s \" \n " , addr ) ) ;
cl - > redirect = 2 ;
}
}
else
Con_Printf ( " %s: tookplayer: invalid player. \n " , sv . name ) ;
}
break ;
case ccmd_transferedplayer :
{
client_t * cl ;
char * to ;
int toserver = MSG_ReadLong ( ) ;
int playerid = MSG_ReadLong ( ) ;
int i ;
for ( i = 0 ; i < svs . allocated_client_slots ; i + + )
{
if ( svs . clients [ i ] . userid = = playerid & & svs . clients [ i ] . state > = cs_loadzombie )
{
cl = & svs . clients [ i ] ;
cl - > drop = true ;
to = Info_ValueForKey ( cl - > userinfo , " *transfer " ) ;
Con_Printf ( " %s transfered to %s \n " , cl - > name , to ) ;
break ;
}
}
}
break ;
case ccmd_takeplayer :
{
client_t * cl = NULL ;
int i , j ;
float stat ;
char guid [ 64 ] ;
int plid = MSG_ReadLong ( ) ;
int fromsv = MSG_ReadLong ( ) ;
char * claddr = MSG_ReadString ( ) ;
char * clguid = MSG_ReadStringBuffer ( guid , sizeof ( guid ) ) ;
if ( sv . state > = ss_active )
{
for ( i = 0 ; i < svs . allocated_client_slots ; i + + )
{
if ( ! svs . clients [ i ] . state | | ( svs . clients [ i ] . userid = = plid & & svs . clients [ i ] . state > = cs_loadzombie ) )
{
cl = & svs . clients [ i ] ;
break ;
}
}
}
Con_Printf ( " %s: takeplayer \n " , sv . name ) ;
if ( cl )
{
cl - > userid = plid ;
if ( cl - > state = = cs_loadzombie & & cl - > istobeloaded )
cl - > connection_started = realtime + 20 ; //renew the slot
else if ( ! cl - > state )
{ //allocate a new pending player.
cl - > previousserver = fromsv ;
cl - > state = cs_loadzombie ;
cl - > connection_started = realtime + 20 ;
Q_strncpyz ( cl - > guid , clguid , sizeof ( cl - > guid ) ) ;
sv . spawned_client_slots + + ;
memset ( & cl - > netchan , 0 , sizeof ( cl - > netchan ) ) ;
SV_GetNewSpawnParms ( cl ) ;
}
}
j = MSG_ReadByte ( ) ;
Con_Printf ( " %s: %i stats \n " , sv . name , j ) ;
for ( i = 0 ; i < j ; i + + )
{
stat = MSG_ReadFloat ( ) ;
if ( cl & & cl - > state = = cs_loadzombie & & i < NUM_SPAWN_PARMS )
cl - > spawn_parms [ i ] = stat ;
}
{
sizebuf_t send ;
qbyte send_buf [ MAX_QWMSGLEN ] ;
if ( fromsv )
Con_Printf ( " %s: send tookplayer \n " , sv . name ) ;
else
Con_Printf ( " %s: from master \n " , sv . name ) ;
memset ( & send , 0 , sizeof ( send ) ) ;
send . data = send_buf ;
send . maxsize = sizeof ( send_buf ) ;
send . cursize = 2 ;
if ( cl )
{
MSG_WriteByte ( & send , ccmd_tookplayer ) ;
MSG_WriteLong ( & send , fromsv ) ;
MSG_WriteLong ( & send , plid ) ;
MSG_WriteString ( & send , claddr ) ;
SSV_InstructMaster ( & send ) ;
}
}
}
break ;
}
if ( msg_readcount ! = net_message . cursize | | msg_badread )
Sys_Error ( " Subserver: Readcount isn't right (%i) \n " , net_message . data [ 0 ] ) ;
}
void SSV_UpdateAddresses ( void )
{
char buf [ 256 ] ;
netadr_t addr [ 64 ] ;
struct ftenet_generic_connection_s * con [ sizeof ( addr ) / sizeof ( addr [ 0 ] ) ] ;
int flags [ sizeof ( addr ) / sizeof ( addr [ 0 ] ) ] ;
int count ;
sizebuf_t send ;
qbyte send_buf [ MAX_QWMSGLEN ] ;
int i ;
if ( ! SSV_IsSubServer ( ) )
return ;
count = NET_EnumerateAddresses ( svs . sockets , con , flags , addr , sizeof ( addr ) / sizeof ( addr [ 0 ] ) ) ;
if ( * sv_serverip . string )
{
for ( i = 0 ; i < count ; i + + )
{
if ( addr [ i ] . type = = NA_IP )
{
NET_StringToAdr ( sv_serverip . string , BigShort ( addr [ i ] . port ) , & addr [ 0 ] ) ;
count = 1 ;
break ;
}
}
}
memset ( & send , 0 , sizeof ( send ) ) ;
send . data = send_buf ;
send . maxsize = sizeof ( send_buf ) ;
send . cursize = 2 ;
MSG_WriteByte ( & send , ccmd_serveraddress ) ;
MSG_WriteString ( & send , sv . name ) ;
for ( i = 0 ; i < count ; i + + )
MSG_WriteString ( & send , NET_AdrToString ( buf , sizeof ( buf ) , & addr [ i ] ) ) ;
MSG_WriteByte ( & send , 0 ) ;
SSV_InstructMaster ( & send ) ;
}
void SSV_SavePlayerStats ( client_t * cl , unsigned int previousserver )
{
//called when the *transfer userinfo gets set to the new map
sizebuf_t send ;
qbyte send_buf [ MAX_QWMSGLEN ] ;
int i ;
if ( ! SSV_IsSubServer ( ) )
return ;
if ( ! previousserver )
SV_SaveSpawnparmsClient ( cl , NULL ) ;
memset ( & send , 0 , sizeof ( send ) ) ;
send . data = send_buf ;
send . maxsize = sizeof ( send_buf ) ;
send . cursize = 2 ;
MSG_WriteByte ( & send , ccmd_saveplayer ) ;
MSG_WriteLong ( & send , previousserver ) ;
MSG_WriteLong ( & send , cl - > userid ) ;
MSG_WriteByte ( & send , NUM_SPAWN_PARMS ) ;
for ( i = 0 ; i < NUM_SPAWN_PARMS ; i + + )
{
MSG_WriteFloat ( & send , cl - > spawn_parms [ i ] ) ;
}
SSV_InstructMaster ( & send ) ;
}
void SSV_InitiatePlayerTransfer ( client_t * cl , const char * newserver )
{
//called when the *transfer userinfo gets set to the new map
sizebuf_t send ;
qbyte send_buf [ MAX_QWMSGLEN ] ;
int i ;
char tmpbuf [ 256 ] ;
float parms [ NUM_SPAWN_PARMS ] ;
SV_SaveSpawnparmsClient ( cl , parms ) ;
memset ( & send , 0 , sizeof ( send ) ) ;
send . data = send_buf ;
send . maxsize = sizeof ( send_buf ) ;
send . cursize = 2 ;
MSG_WriteByte ( & send , ccmd_transferplayer ) ;
MSG_WriteLong ( & send , cl - > userid ) ;
MSG_WriteString ( & send , newserver ) ;
MSG_WriteString ( & send , NET_AdrToString ( tmpbuf , sizeof ( tmpbuf ) , & cl - > netchan . remote_address ) ) ;
MSG_WriteString ( & send , cl - > guid ) ;
//stats
MSG_WriteByte ( & send , NUM_SPAWN_PARMS ) ;
for ( i = 0 ; i < NUM_SPAWN_PARMS ; i + + )
{
MSG_WriteFloat ( & send , parms [ i ] ) ;
}
SSV_InstructMaster ( & send ) ;
}
# ifdef SQL
# include "sv_sql.h"
int pendinglookups = 0 ;
struct logininfo_s
{
netadr_t clientaddr ;
char guid [ 64 ] ;
} ;
# endif
qboolean SV_IgnoreSQLResult ( queryrequest_t * req , int firstrow , int numrows , int numcols , qboolean eof )
{
return false ;
}
void MSV_UpdatePlayerStats ( unsigned int lastserver , unsigned int playerid , unsigned int serverid , int numstats , float * stats )
{
queryrequest_t * req ;
sqlserver_t * srv ;
static char hex [ 16 ] = " 0123456789abcdef " ;
char sql [ 2048 ] , * sqle ;
union { float * f ; qbyte * b ; } blob ;
Q_snprintfz ( sql , sizeof ( sql ) , " UPDATE accounts SET stats=x' " ) ;
sqle = sql + strlen ( sql ) ;
for ( blob . f = stats , numstats * = 4 ; numstats - - ; blob . b + + )
{
* sqle + + = hex [ * blob . b > > 4 ] ;
* sqle + + = hex [ * blob . b & 15 ] ;
}
if ( lastserver )
Q_snprintfz ( sqle , sizeof ( sql ) - ( sqle - sql ) , " ', serverid=%u WHERE playerid = %u; " , serverid , playerid ) ;
else
Q_snprintfz ( sqle , sizeof ( sql ) - ( sqle - sql ) , " ' WHERE playerid = %u AND serverid = %u; " , playerid , serverid ) ;
srv = SQL_GetServer ( sv . logindatabase , false ) ;
if ( srv )
SQL_NewQuery ( srv , SV_IgnoreSQLResult , sql , & req ) ;
if ( lastserver )
{
sizebuf_t send ;
qbyte send_buf [ 64 ] ;
memset ( & send , 0 , sizeof ( send ) ) ;
send . data = send_buf ;
send . maxsize = sizeof ( send_buf ) ;
send . cursize = 2 ;
MSG_WriteByte ( & send , ccmd_transferedplayer ) ;
MSG_WriteLong ( & send , serverid ) ;
MSG_WriteLong ( & send , playerid ) ;
MSV_InstructSlave ( lastserver , & send ) ;
}
}
qboolean MSV_ClusterLoginReply ( netadr_t * legacyclientredirect , unsigned int serverid , unsigned int playerid , char * clientguid , netadr_t * clientaddr , void * statsblob , size_t statsblobsize )
{
char tmpbuf [ 256 ] ;
netadr_t serveraddr ;
if ( ! serverid )
serverid = 1 ;
if ( ! MSV_AddressForMap ( & serveraddr , clientaddr - > type , serverid ) & & ! MSV_AddressForMap ( & serveraddr , clientaddr - > type , serverid = 1 ) )
SV_RejectMessage ( SCP_QUAKEWORLD , " Unable to find lobby. \n " ) ;
else
{
sizebuf_t send ;
qbyte send_buf [ MAX_QWMSGLEN ] ;
memset ( & send , 0 , sizeof ( send ) ) ;
send . data = send_buf ;
send . maxsize = sizeof ( send_buf ) ;
send . cursize = 2 ;
MSG_WriteByte ( & send , ccmd_takeplayer ) ;
MSG_WriteLong ( & send , playerid ) ;
MSG_WriteLong ( & send , 0 ) ; //from server
MSG_WriteString ( & send , NET_AdrToString ( tmpbuf , sizeof ( tmpbuf ) , & net_from ) ) ;
MSG_WriteString ( & send , clientguid ) ;
MSG_WriteByte ( & send , statsblobsize / 4 ) ;
SZ_Write ( & send , statsblob , statsblobsize & ~ 3 ) ;
MSV_InstructSlave ( serverid , & send ) ;
if ( serveraddr . type = = NA_INVALID )
{
if ( net_from . type ! = NA_LOOPBACK )
SV_RejectMessage ( SCP_QUAKEWORLD , " Starting instance. \n " ) ;
}
else if ( legacyclientredirect )
{
* legacyclientredirect = serveraddr ;
return true ;
}
else
{
char * s = va ( " fredir \n %s " , NET_AdrToString ( tmpbuf , sizeof ( tmpbuf ) , & serveraddr ) ) ;
Netchan_OutOfBand ( NS_SERVER , clientaddr , strlen ( s ) , ( qbyte * ) s ) ;
return true ;
}
}
return false ;
}
qboolean MSV_ClusterLoginSQLResult ( queryrequest_t * req , int firstrow , int numrows , int numcols , qboolean eof )
{
sqlserver_t * sql = SQL_GetServer ( req - > srvid , true ) ;
queryresult_t * res = SQL_GetQueryResult ( sql , req - > num , 0 ) ;
struct logininfo_s * info = req - > user . thread ;
char * s ;
int playerid , serverid ;
char * statsblob ;
size_t blobsize ;
res = SQL_GetQueryResult ( sql , req - > num , 0 ) ;
if ( ! res )
{
playerid = 0 ;
statsblob = NULL ;
blobsize = 0 ;
serverid = 0 ;
}
else
{
s = SQL_ReadField ( sql , res , 0 , 0 , true , NULL ) ;
playerid = atoi ( s ) ;
statsblob = SQL_ReadField ( sql , res , 0 , 2 , true , & blobsize ) ;
s = SQL_ReadField ( sql , res , 0 , 1 , true , NULL ) ;
serverid = s ? atoi ( s ) : 0 ;
}
net_from = info - > clientaddr ; //okay, that's a bit stupid, rewrite rejectmessage to accept an arg?
if ( ! playerid )
SV_RejectMessage ( SCP_QUAKEWORLD , " Bad username or password. \n " ) ;
else
MSV_ClusterLoginReply ( NULL , serverid , playerid , info - > guid , & info - > clientaddr , statsblob , blobsize ) ;
Z_Free ( info ) ;
pendinglookups - - ;
return false ;
}
//returns true to block entry to this server.
qboolean MSV_ClusterLogin ( char * guid , char * userinfo , size_t userinfosize )
{
char escname [ 64 ] , escpasswd [ 64 ] ;
sqlserver_t * sql ;
queryrequest_t * req ;
struct logininfo_s * info ;
char * sqlparams [ ] =
{
" " ,
" " ,
" " ,
" login " ,
} ;
if ( sv . state ! = ss_clustermode )
return false ;
if ( sv . logindatabase ! = - 1 )
{
if ( pendinglookups > 10 )
return true ;
sql = SQL_GetServer ( sv . logindatabase , false ) ;
if ( ! sql )
return true ;
SQL_Escape ( sql , Info_ValueForKey ( userinfo , " name " ) , escname , sizeof ( escname ) ) ;
SQL_Escape ( sql , Info_ValueForKey ( userinfo , " password " ) , escpasswd , sizeof ( escpasswd ) ) ;
if ( SQL_NewQuery ( sql , MSV_ClusterLoginSQLResult , va ( " SELECT playerid,serverid,stats FROM accounts WHERE name='%s' AND password='%s'; " , escname , escpasswd ) , & req ) ! = - 1 )
{
pendinglookups + + ;
req - > user . thread = info = Z_Malloc ( sizeof ( * info ) ) ;
Q_strncpyz ( info - > guid , guid , sizeof ( info - > guid ) ) ;
info - > clientaddr = net_from ;
}
}
else if ( 0 )
{
char tmpbuf [ 256 ] ;
netadr_t redir ;
if ( MSV_ClusterLoginReply ( & redir , 0 , nextuserid + + , guid , & net_from , NULL , 0 ) )
{
Info_SetValueForStarKey ( userinfo , " *redirect " , NET_AdrToString ( tmpbuf , sizeof ( tmpbuf ) , & redir ) , userinfosize ) ;
return false ;
}
return true ;
}
else
MSV_ClusterLoginReply ( NULL , 0 , nextuserid + + , guid , & net_from , NULL , 0 ) ;
return true ;
}
# endif
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = =
SVC_DirectConnect
A connection request that did not come from the master
= = = = = = = = = = = = = = = = = =
2012-11-27 03:23:19 +00:00
arguments must be tokenized first
Q3 : connect " \ key \v al "
DP : connect \ key \ val
QW : connect $ VER $ QPORT $ CHALLENGE " \ key \v al "
SS : connect2 $ VER $ QPORT $ CHALLENGE " \ key \v al " " \ key \v al "
NQ : hacked to take the form of QW
extension flags follow it .
2004-08-23 00:15:46 +00:00
*/
2005-05-26 12:55:34 +00:00
client_t * SVC_DirectConnect ( void )
2004-08-23 00:15:46 +00:00
{
2012-11-27 03:23:19 +00:00
char userinfo [ MAX_SPLITS ] [ 2048 ] ;
2004-08-23 00:15:46 +00:00
netadr_t adr ;
int i ;
client_t * cl , * newcl ;
client_t temp ;
edict_t * ent ;
# ifdef Q2SERVER
q2edict_t * q2ent ;
# endif
int edictnum ;
char * s ;
int clients , spectators ;
qboolean spectator ;
int qport ;
int version ;
int challenge ;
int huffcrc = 0 ;
2012-02-12 05:18:31 +00:00
int mtu = 0 ;
2011-07-30 14:14:56 +00:00
char guid [ 128 ] = " " ;
2011-10-27 16:16:29 +00:00
char basic [ 80 ] ;
2011-09-06 20:53:38 +00:00
qboolean redirect = false ;
2014-03-30 08:55:06 +00:00
qboolean preserveparms = false ;
2004-08-23 00:15:46 +00:00
2005-05-26 12:55:34 +00:00
int numssclients = 1 ;
2004-08-23 00:15:46 +00:00
2005-05-26 12:55:34 +00:00
int protocol ;
2004-08-23 00:15:46 +00:00
unsigned int protextsupported = 0 ;
2009-11-04 21:16:50 +00:00
unsigned int protextsupported2 = 0 ;
2014-04-27 23:16:07 +00:00
extern cvar_t sv_protocol_nq , net_compress ;
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
char * name ;
2008-06-08 14:37:57 +00:00
char adrbuf [ MAX_ADR_SIZE ] ;
2004-08-23 00:15:46 +00:00
2008-11-09 22:29:28 +00:00
if ( * Cmd_Argv ( 1 ) = = ' \\ ' )
{ //connect "\key\val"
//this is used by q3 (note, we already decrypted the huffman connection packet in a hack)
if ( ! sv_listen_q3 . value )
2014-05-10 13:42:13 +00:00
{
if ( ! sv_listen_nq . value )
SV_RejectMessage ( SCP_DARKPLACES6 , " Server is not accepting quake3 clients at this time. \n " , version_string ( ) ) ;
Con_TPrintf ( " * rejected connect from q3 client \n " ) ;
2008-11-09 22:29:28 +00:00
return NULL ;
2014-05-10 13:42:13 +00:00
}
2008-11-09 22:29:28 +00:00
numssclients = 1 ;
protocol = SCP_QUAKE3 ;
Q_strncpyz ( userinfo [ 0 ] , Cmd_Argv ( 1 ) , sizeof ( userinfo [ 0 ] ) - 1 ) ;
switch ( atoi ( Info_ValueForKey ( userinfo [ 0 ] , " protocol " ) ) )
2009-07-18 20:09:07 +00:00
{
2008-11-09 22:29:28 +00:00
case 68 : //regular q3 1.32
break ;
// case 43: //q3 1.11 (most 'recent' demo)
// break;
default :
2011-03-30 15:17:55 +00:00
SV_RejectMessage ( SCP_BAD , " Server is %s. \n " , version_string ( ) ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " * rejected connect from incompatable client \n " ) ;
2008-11-09 22:29:28 +00:00
return NULL ;
}
s = Info_ValueForKey ( userinfo [ 0 ] , " challenge " ) ;
challenge = atoi ( s ) ;
s = Info_ValueForKey ( userinfo [ 0 ] , " qport " ) ;
qport = atoi ( s ) ;
2011-05-29 04:26:29 +00:00
2008-11-09 22:29:28 +00:00
s = Info_ValueForKey ( userinfo [ 0 ] , " name " ) ;
if ( ! * s )
Info_SetValueForKey ( userinfo [ 0 ] , " name " , " UnnamedQ3 " , sizeof ( userinfo [ 0 ] ) ) ;
2014-05-10 13:42:13 +00:00
# ifdef HUFFNETWORK
huffcrc = HUFFCRC_QUAKE3 ;
# endif
2008-11-09 22:29:28 +00:00
}
else if ( * ( Cmd_Argv ( 0 ) + 7 ) = = ' \\ ' )
{ //DP has the userinfo attached directly to the end of the connect command
2007-06-10 05:14:38 +00:00
if ( ! sv_listen_dp . value )
2014-05-10 13:42:13 +00:00
{
if ( ! sv_listen_nq . value )
SV_RejectMessage ( SCP_DARKPLACES6 , " Server is not accepting darkplaces clients at this time. \n " , version_string ( ) ) ;
Con_TPrintf ( " * rejected connect from dp client \n " ) ;
2005-06-14 04:52:10 +00:00
return NULL ;
2014-05-10 13:42:13 +00:00
}
2005-05-26 12:55:34 +00:00
Q_strncpyz ( userinfo [ 0 ] , net_message . data + 11 , sizeof ( userinfo [ 0 ] ) - 1 ) ;
if ( strcmp ( Info_ValueForKey ( userinfo [ 0 ] , " protocol " ) , " darkplaces 3 " ) )
2004-08-23 00:15:46 +00:00
{
2011-03-30 15:17:55 +00:00
SV_RejectMessage ( SCP_BAD , " Server is %s. \n " , version_string ( ) ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " * rejected connect from incompatible client \n " ) ;
2005-05-26 12:55:34 +00:00
return NULL ;
2004-08-23 00:15:46 +00:00
}
2005-05-27 05:41:07 +00:00
//it's a darkplaces client.
2004-08-23 00:15:46 +00:00
2005-05-27 05:41:07 +00:00
s = Info_ValueForKey ( userinfo [ 0 ] , " protocols " ) ;
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
if ( svs . netprim . coordsize ! = 4 )
2007-06-10 05:14:38 +00:00
{ //we allow nq with sv_listen_nq 0...
//reason: dp is too similar for concerns about unsupported code, while the main reason why we disable nq is because of the lack of challenges
//(and no, this isn't a way to bypass invalid challenges)
protocol = SCP_NETQUAKE ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " * DP without sv_bigcoords 1 \n " ) ;
2007-06-10 05:14:38 +00:00
}
else if ( strstr ( s , " DP7 " ) )
2005-05-27 05:41:07 +00:00
protocol = SCP_DARKPLACES7 ;
else
protocol = SCP_DARKPLACES6 ;
2004-08-23 00:15:46 +00:00
2005-06-14 04:52:10 +00:00
s = Info_ValueForKey ( userinfo [ 0 ] , " challenge " ) ;
2005-11-14 01:32:21 +00:00
if ( ! strncmp ( s , DISTRIBUTION , strlen ( DISTRIBUTION ) ) )
2013-11-21 23:02:28 +00:00
challenge = atoi ( s + strlen ( DISTRIBUTION ) ) ;
2005-06-14 04:52:10 +00:00
else
challenge = atoi ( s ) ;
2008-11-09 22:29:28 +00:00
Info_RemoveKey ( userinfo [ 0 ] , " protocol " ) ;
Info_RemoveKey ( userinfo [ 0 ] , " protocols " ) ;
Info_RemoveKey ( userinfo [ 0 ] , " challenge " ) ;
2005-06-14 04:52:10 +00:00
s = Info_ValueForKey ( userinfo [ 0 ] , " name " ) ;
if ( ! * s )
Info_SetValueForKey ( userinfo [ 0 ] , " name " , " CONNECTING " , sizeof ( userinfo [ 0 ] ) ) ;
2005-05-26 12:55:34 +00:00
qport = 0 ;
2004-08-23 00:15:46 +00:00
}
2005-05-26 12:55:34 +00:00
else
2004-08-23 00:15:46 +00:00
{
2005-05-26 12:55:34 +00:00
if ( atoi ( Cmd_Argv ( 0 ) + 7 ) )
{
2005-05-27 05:41:07 +00:00
numssclients = atoi ( Cmd_Argv ( 0 ) + 7 ) ;
2012-11-27 03:23:19 +00:00
if ( numssclients < 1 | | numssclients > MAX_SPLITS )
2005-05-26 12:55:34 +00:00
{
2011-03-30 15:17:55 +00:00
SV_RejectMessage ( SCP_BAD , " Server is %s. \n " , version_string ( ) ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " * rejected connect from broken client \n " ) ;
2005-05-26 12:55:34 +00:00
return NULL ;
}
}
2004-08-23 00:15:46 +00:00
2005-05-26 12:55:34 +00:00
version = atoi ( Cmd_Argv ( 1 ) ) ;
if ( version > = 31 & & version < = 34 )
{
numssclients = 1 ;
protocol = SCP_QUAKE2 ;
}
else if ( version = = 3 )
{
numssclients = 1 ;
2008-11-09 22:29:28 +00:00
protocol = SCP_NETQUAKE ; //because we can
2012-10-01 14:29:44 +00:00
if ( atoi ( Info_ValueForKey ( Cmd_Argv ( 4 ) , " mod " ) ) = = 1 )
protocol = SCP_PROQUAKE ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
else if ( atoi ( Info_ValueForKey ( Cmd_Argv ( 4 ) , " mod " ) ) = = 666 )
protocol = SCP_FITZ666 ;
2005-05-26 12:55:34 +00:00
}
2008-04-12 23:24:19 +00:00
else if ( version ! = PROTOCOL_VERSION_QW )
2005-05-26 12:55:34 +00:00
{
2008-04-12 23:24:19 +00:00
SV_RejectMessage ( SCP_BAD , " Server is protocol version %i, received %i \n " , PROTOCOL_VERSION_QW , version ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " * rejected connect from version %i \n " , version ) ;
2005-05-26 12:55:34 +00:00
return NULL ;
}
else
protocol = SCP_QUAKEWORLD ;
2004-08-23 00:15:46 +00:00
2005-05-26 12:55:34 +00:00
qport = atoi ( Cmd_Argv ( 2 ) ) ;
2004-08-23 00:15:46 +00:00
2005-05-26 12:55:34 +00:00
challenge = atoi ( Cmd_Argv ( 3 ) ) ;
2004-08-23 00:15:46 +00:00
2005-05-26 12:55:34 +00:00
// note an extra qbyte is needed to replace spectator key
for ( i = 0 ; i < numssclients ; i + + )
Q_strncpyz ( userinfo [ i ] , Cmd_Argv ( 4 + i ) , sizeof ( userinfo [ i ] ) - 1 ) ;
}
2009-07-18 20:09:07 +00:00
{
2014-05-30 16:37:20 +00:00
char * banreason = SV_BannedReason ( & net_from ) ;
2014-03-30 08:55:06 +00:00
if ( banreason )
{
if ( * banreason )
SV_RejectMessage ( protocol , " You were banned. \n Reason: %s \n " , banreason ) ;
else
SV_RejectMessage ( protocol , " You were banned. \n " ) ;
return NULL ;
}
2009-07-18 20:09:07 +00:00
}
2005-05-26 12:55:34 +00:00
if ( protocol = = SCP_QUAKEWORLD ) //readd?
2004-08-23 00:15:46 +00:00
{
2007-06-10 21:33:24 +00:00
if ( ! sv_listen_qw . value & & net_from . type ! = NA_LOOPBACK )
{
2013-10-08 14:28:11 +00:00
SV_RejectMessage ( protocol , " QuakeWorld protocols are not permitted on this server. \n " ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " * rejected connect from quakeworld \n " ) ;
2007-06-10 21:33:24 +00:00
return NULL ;
}
2012-02-12 05:18:31 +00:00
}
2013-10-08 14:28:11 +00:00
if ( sv_banproxies . ival )
{
//FIXME: allow them to spectate but not join
if ( * Info_ValueForKey ( userinfo [ 0 ] , " *qwfwd " ) )
{
SV_RejectMessage ( protocol , " Proxies are not permitted on this server. \n " ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " * rejected connect from qwfwd proxy \n " ) ;
2013-10-08 14:28:11 +00:00
return NULL ;
}
if ( * Info_ValueForKey ( userinfo [ 0 ] , " Qizmo " ) )
{
SV_RejectMessage ( protocol , " Proxies are not permitted on this server. \n " ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " * rejected connect from qizmo proxy \n " ) ;
2013-10-08 14:28:11 +00:00
return NULL ;
}
if ( * Info_ValueForKey ( userinfo [ 0 ] , " *qtv " ) )
{
SV_RejectMessage ( protocol , " Proxies are not permitted on this server. \n " ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " * rejected connect from qtv proxy (udp) \n " ) ;
2013-10-08 14:28:11 +00:00
return NULL ;
}
}
2007-06-10 21:33:24 +00:00
2012-02-12 05:18:31 +00:00
while ( ! msg_badread )
{
Cmd_TokenizeString ( MSG_ReadStringLine ( ) , false , false ) ;
switch ( Q_atoi ( Cmd_Argv ( 0 ) ) )
2004-08-23 00:15:46 +00:00
{
2012-02-12 05:18:31 +00:00
case PROTOCOL_VERSION_FTE :
if ( protocol = = SCP_QUAKEWORLD )
2004-08-23 00:15:46 +00:00
{
protextsupported = Q_atoi ( Cmd_Argv ( 1 ) ) ;
Con_DPrintf ( " Client supports 0x%x fte extensions \n " , protextsupported ) ;
2012-02-12 05:18:31 +00:00
}
break ;
case PROTOCOL_VERSION_FTE2 :
if ( protocol = = SCP_QUAKEWORLD )
{
2009-11-04 21:16:50 +00:00
protextsupported2 = Q_atoi ( Cmd_Argv ( 1 ) ) ;
2010-12-18 17:02:47 +00:00
Con_DPrintf ( " Client supports 0x%x fte2 extensions \n " , protextsupported2 ) ;
2004-08-23 00:15:46 +00:00
}
2012-02-12 05:18:31 +00:00
break ;
case PROTOCOL_VERSION_HUFFMAN :
2014-05-10 13:42:13 +00:00
# ifdef HUFFNETWORK
2012-02-12 05:18:31 +00:00
huffcrc = Q_atoi ( Cmd_Argv ( 1 ) ) ;
Con_DPrintf ( " Client supports huffman compression. crc 0x%x \n " , huffcrc ) ;
2014-04-27 23:16:07 +00:00
if ( ! net_compress . ival | | ! Huff_CompressionCRC ( huffcrc ) )
{
SV_RejectMessage ( protocol , " Compression should not have been enabled. \n " ) ; //buggy/exploiting client. can also happen from timing when changing the setting, but whatever
Con_TPrintf ( " * rejected - bad compression state \n " ) ;
return NULL ;
}
2014-05-10 13:42:13 +00:00
# endif
2012-02-12 05:18:31 +00:00
break ;
case PROTOCOL_VERSION_FRAGMENT :
mtu = Q_atoi ( Cmd_Argv ( 1 ) ) & ~ 7 ;
if ( mtu < 64 )
2012-02-15 13:53:30 +00:00
mtu = 0 ;
2012-02-12 05:18:31 +00:00
Con_DPrintf ( " Client supports fragmentation. mtu %i. \n " , mtu ) ;
break ;
case PROTOCOL_INFO_GUID :
Q_strncpyz ( guid , Cmd_Argv ( 1 ) , sizeof ( guid ) ) ;
Con_DPrintf ( " GUID %s \n " , Cmd_Argv ( 1 ) ) ;
break ;
2004-08-23 00:15:46 +00:00
}
}
2012-02-12 05:18:31 +00:00
msg_badread = false ;
2010-08-14 00:15:07 +00:00
/*allow_splitscreen applies only to non-local clients, so that clients have only one enabler*/
if ( ! sv_allow_splitscreen . ival & & net_from . type ! = NA_LOOPBACK )
2004-08-23 00:15:46 +00:00
numssclients = 1 ;
if ( ! ( protextsupported & PEXT_SPLITSCREEN ) )
numssclients = 1 ;
if ( sv . msgfromdemo | | net_from . type = = NA_LOOPBACK ) //normal rules don't apply
i = 0 ;
else
2005-03-07 08:58:26 +00:00
{
2004-08-23 00:15:46 +00:00
// see if the challenge is valid
2005-03-07 08:58:26 +00:00
if ( ! SV_ChallengePasses ( challenge ) )
2004-08-23 00:15:46 +00:00
{
2005-05-26 12:55:34 +00:00
SV_RejectMessage ( protocol , " Bad challenge. \n " ) ;
return NULL ;
2004-08-23 00:15:46 +00:00
}
2005-03-07 08:58:26 +00:00
}
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
if ( MSV_ClusterLogin ( guid , userinfo [ 0 ] , sizeof ( userinfo [ 0 ] ) ) )
return NULL ;
2004-08-23 00:15:46 +00:00
// check for password or spectator_password
if ( svprogfuncs )
{
s = Info_ValueForKey ( userinfo [ 0 ] , " spectator " ) ;
if ( s [ 0 ] & & strcmp ( s , " 0 " ) )
{
2005-07-03 15:16:20 +00:00
if ( spectator_password . string [ 0 ] & &
2004-08-23 00:15:46 +00:00
stricmp ( spectator_password . string , " none " ) & &
strcmp ( spectator_password . string , s ) )
{ // failed
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " %s:spectator password failed \n " , NET_AdrToString ( adrbuf , sizeof ( adrbuf ) , & net_from ) ) ;
2005-05-26 12:55:34 +00:00
SV_RejectMessage ( protocol , " requires a spectator password \n \n " ) ;
return NULL ;
2004-08-23 00:15:46 +00:00
}
Info_RemoveKey ( userinfo [ 0 ] , " spectator " ) ; // remove key
2005-03-07 08:58:26 +00:00
Info_SetValueForStarKey ( userinfo [ 0 ] , " *spectator " , " 1 " , sizeof ( userinfo [ 0 ] ) ) ;
2004-08-23 00:15:46 +00:00
spectator = true ;
}
else
{
s = Info_ValueForKey ( userinfo [ 0 ] , " password " ) ;
2005-07-03 15:16:20 +00:00
if ( password . string [ 0 ] & &
2004-08-23 00:15:46 +00:00
stricmp ( password . string , " none " ) & &
strcmp ( password . string , s ) )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " %s:password failed \n " , NET_AdrToString ( adrbuf , sizeof ( adrbuf ) , & net_from ) ) ;
2005-05-26 12:55:34 +00:00
SV_RejectMessage ( protocol , " server requires a password \n \n " ) ;
return NULL ;
2004-08-23 00:15:46 +00:00
}
spectator = false ;
Info_RemoveKey ( userinfo [ 0 ] , " password " ) ; // remove passwd
Info_RemoveKey ( userinfo [ 0 ] , " *spectator " ) ; // remove key
}
}
else
spectator = false ; //q2 does all of it's checks internally, and deals with spectator ship too
adr = net_from ;
nextuserid + + ; // so every client gets a unique id
newcl = & temp ;
memset ( newcl , 0 , sizeof ( client_t ) ) ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( protocol > = SCP_NETQUAKE & & protocol < SCP_DARKPLACES6 )
{ //NQ protocols lack stuff like protocol extensions.
//its the wild west where nothing is known about the client and everything breaks.
switch ( sv_protocol_nq . ival )
{
case RMQ_PROTOCOL_VERSION :
case FITZ_PROTOCOL_VERSION :
protocol = SCP_FITZ666 ;
break ;
case 15 :
//don't trip up on proquake's angle change.
protocol = ( protocol = = SCP_PROQUAKE ) ? SCP_PROQUAKE : SCP_NETQUAKE ;
break ;
case DP6_PROTOCOL_VERSION :
protocol = SCP_DARKPLACES6 ;
break ;
case DP7_PROTOCOL_VERSION :
protocol = SCP_DARKPLACES7 ;
break ;
default :
Con_Printf ( " sv_protocol_nq set incorrectly \n " ) ;
case 0 :
//change nothing
break ;
}
}
2004-08-23 00:15:46 +00:00
newcl - > userid = nextuserid ;
newcl - > fteprotocolextensions = protextsupported ;
2009-11-04 21:16:50 +00:00
newcl - > fteprotocolextensions2 = protextsupported2 ;
2005-05-26 12:55:34 +00:00
newcl - > protocol = protocol ;
2011-07-30 14:14:56 +00:00
Q_strncpyz ( newcl - > guid , guid , sizeof ( newcl - > guid ) ) ;
2004-08-23 00:15:46 +00:00
if ( sv . msgfromdemo )
newcl - > wasrecorded = true ;
// works properly
if ( ! sv_highchars . value )
{
qbyte * p , * q ;
for ( p = ( qbyte * ) newcl - > userinfo , q = ( qbyte * ) userinfo ;
* q & & p < ( qbyte * ) newcl - > userinfo + sizeof ( newcl - > userinfo ) - 1 ; q + + )
if ( * q > 31 & & * q < = 127 )
* p + + = * q ;
}
else
Q_strncpyS ( newcl - > userinfo , userinfo [ 0 ] , sizeof ( newcl - > userinfo ) - 1 ) ;
newcl - > userinfo [ sizeof ( newcl - > userinfo ) - 1 ] = ' \0 ' ;
2014-03-30 08:55:06 +00:00
// Con_TPrintf("%s:%s:connect\n", sv.name, NET_AdrToString (adrbuf, sizeof(adrbuf), &adr));
2005-07-28 15:22:15 +00:00
// if there is already a slot for this ip, drop it
2013-10-29 17:38:22 +00:00
for ( i = 0 , cl = svs . clients ; i < svs . allocated_client_slots ; i + + , cl + + )
2004-08-23 00:15:46 +00:00
{
if ( cl - > state = = cs_free )
continue ;
2013-05-03 04:28:08 +00:00
if ( NET_CompareBaseAdr ( & adr , & cl - > netchan . remote_address )
2005-07-03 15:16:20 +00:00
& & ( cl - > netchan . qport = = qport
2004-08-23 00:15:46 +00:00
| | adr . port = = cl - > netchan . remote_address . port ) )
{
2007-06-10 05:14:38 +00:00
if ( cl - > state = = cs_connected )
{
if ( cl - > protocol ! = protocol )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " %s: diff prot connect \n " , NET_AdrToString ( adrbuf , sizeof ( adrbuf ) , & adr ) ) ;
2007-06-10 05:14:38 +00:00
else
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " %s:dup connect \n " , NET_AdrToString ( adrbuf , sizeof ( adrbuf ) , & adr ) ) ;
2004-08-23 00:15:46 +00:00
}
2013-06-23 02:17:02 +00:00
/*else if (cl->state == cs_zombie)
2008-11-09 22:29:28 +00:00
{
2013-05-03 04:28:08 +00:00
Con_Printf ( " %s:reconnect \n " , NET_AdrToString ( adrbuf , sizeof ( adrbuf ) , & adr ) ) ;
2013-06-23 02:17:02 +00:00
} */
2008-11-09 22:29:28 +00:00
else
2014-06-16 16:21:28 +00:00
Con_TPrintf ( " %s:%s:reconnect \n " , sv . name , NET_AdrToString ( adrbuf , sizeof ( adrbuf ) , & adr ) ) ;
//silently drop the old connection, without causing the old client to get a disconnect or anything stupid like that.
cl - > protocol = SCP_BAD ;
SV_DropClient ( cl ) ;
cl - > protocol = protocol ;
2004-08-23 00:15:46 +00:00
break ;
}
}
name = Info_ValueForKey ( temp . userinfo , " name " ) ;
2014-03-30 08:55:06 +00:00
if ( sv . world . worldmodel & & protocol = = SCP_QUAKEWORLD & & ! atoi ( Info_ValueForKey ( temp . userinfo , " iknow " ) ) )
2004-08-23 00:15:46 +00:00
{
2009-11-04 21:16:50 +00:00
if ( sv . world . worldmodel - > fromgame = = fg_halflife & & ! ( newcl - > fteprotocolextensions & PEXT_HLBSP ) )
2004-08-23 00:15:46 +00:00
{
if ( atof ( Info_ValueForKey ( temp . userinfo , " *FuhQuake " ) ) < 0.3 )
{
2007-10-05 18:08:47 +00:00
SV_RejectMessage ( protocol , " The server is using a halflife level and we don't think your client supports this \n use 'setinfo iknow 1' to ignore this check \n You can go to " ENGINEWEBSITE " to get a compatible client \n \n You may need to enable an option \n \n " ) ;
// Con_Printf("player %s was dropped due to incompatible client\n", name);
2005-02-06 02:47:36 +00:00
// return;
2004-08-23 00:15:46 +00:00
}
}
# ifdef PEXT_Q2BSP
2009-11-04 21:16:50 +00:00
else if ( sv . world . worldmodel - > fromgame = = fg_quake2 & & ! ( newcl - > fteprotocolextensions & PEXT_Q2BSP ) )
2004-08-23 00:15:46 +00:00
{
2007-10-05 18:08:47 +00:00
SV_RejectMessage ( protocol , " The server is using a quake 2 level and we don't think your client supports this \n use 'setinfo iknow 1' to ignore this check \n You can go to " ENGINEWEBSITE " to get a compatible client \n \n You may need to enable an option \n \n " ) ;
// Con_Printf("player %s was dropped due to incompatible client\n", name);
2005-02-06 02:47:36 +00:00
// return;
2004-08-23 00:15:46 +00:00
}
# endif
# ifdef PEXT_Q3BSP
2009-11-04 21:16:50 +00:00
else if ( sv . world . worldmodel - > fromgame = = fg_quake3 & & ! ( newcl - > fteprotocolextensions & PEXT_Q3BSP ) )
2004-08-23 00:15:46 +00:00
{
2007-10-05 18:08:47 +00:00
SV_RejectMessage ( protocol , " The server is using a quake 3 level and we don't think your client supports this \n use 'setinfo iknow 1' to ignore this check \n You can go to " ENGINEWEBSITE " to get a compatible client \n \n You may need to enable an option \n \n " ) ;
// Con_Printf("player %s was dropped due to incompatible client\n", name);
2005-02-06 02:47:36 +00:00
// return;
2004-08-23 00:15:46 +00:00
}
# endif
}
2009-04-19 00:50:42 +00:00
SV_FixupName ( name , temp . namebuf , sizeof ( temp . namebuf ) ) ;
name = temp . namebuf ;
2004-08-23 00:15:46 +00:00
2011-10-27 16:16:29 +00:00
deleetstring ( basic , name ) ;
if ( ! * basic | | strstr ( basic , " console " ) )
name = " unnamed " ; //have fun dudes.
2004-08-23 00:15:46 +00:00
// count up the clients and spectators
clients = 0 ;
spectators = 0 ;
newcl = NULL ;
if ( ! sv . allocated_client_slots )
2010-11-06 23:05:29 +00:00
{
2004-08-23 00:15:46 +00:00
Con_Printf ( " Apparently, there are no client slots allocated. This shouldn't be happening \n " ) ;
2010-11-06 23:05:29 +00:00
return NULL ;
}
2004-08-23 00:15:46 +00:00
for ( i = 0 , cl = svs . clients ; i < sv . allocated_client_slots ; i + + , cl + + )
{
if ( cl - > state = = cs_free )
continue ;
if ( cl - > spectator )
spectators + + ;
else
clients + + ;
2014-03-30 08:55:06 +00:00
if ( cl - > state = = cs_loadzombie )
2004-08-23 00:15:46 +00:00
{
if ( ! newcl )
{
2014-03-30 08:55:06 +00:00
if ( ( ( ! strcmp ( cl - > name , name ) | | ! * cl - > name ) & & ( ! * cl - > guid | | ! strcmp ( guid , cl - > guid ) ) ) | | sv . allocated_client_slots < = 1 ) //named, or first come first serve.
2004-08-23 00:15:46 +00:00
{
2014-03-30 08:55:06 +00:00
if ( cl - > istobeloaded )
2014-03-31 17:06:41 +00:00
Con_DPrintf ( " %s:Using loadzombie \n " , sv . name ) ;
2014-03-30 08:55:06 +00:00
else
2014-03-31 17:06:41 +00:00
Con_DPrintf ( " %s:Using parmzombie \n " , sv . name ) ;
2004-08-23 00:15:46 +00:00
newcl = cl ;
2014-03-30 08:55:06 +00:00
preserveparms = true ;
2004-08-23 00:15:46 +00:00
temp . istobeloaded = cl - > istobeloaded ;
2014-03-30 08:55:06 +00:00
memcpy ( temp . spawn_parms , cl - > spawn_parms , sizeof ( temp . spawn_parms ) ) ;
# ifdef SUBSERVERS
temp . previousserver = cl - > previousserver ;
# endif
2004-08-23 00:15:46 +00:00
break ;
}
}
}
}
if ( ! newcl ) //client has no slot. It's possible to bipass this if server is loading a game. (or a duplicated qsocket)
{
2014-03-30 08:55:06 +00:00
if ( SSV_IsSubServer ( ) )
{
SV_RejectMessage ( protocol , " Direct connections are not permitted. \n " ) ;
return NULL ;
}
2010-11-06 23:05:29 +00:00
/*single player logic*/
2010-08-14 03:17:33 +00:00
if ( sv . allocated_client_slots = = 1 & & net_from . type = = NA_LOOPBACK )
2012-04-24 07:59:11 +00:00
if ( svs . clients [ 0 ] . state > = cs_connected )
2014-06-16 16:21:28 +00:00
{
Con_Printf ( " Kicking %s to make space for local client \n " , svs . clients [ 0 ] . name ) ;
2010-08-14 03:17:33 +00:00
SV_DropClient ( svs . clients ) ;
2014-06-16 16:21:28 +00:00
}
2010-08-14 03:17:33 +00:00
2004-08-23 00:15:46 +00:00
// if at server limits, refuse connection
2010-07-11 02:22:39 +00:00
if ( maxclients . ival > MAX_CLIENTS )
2004-08-23 00:15:46 +00:00
Cvar_SetValue ( & maxclients , MAX_CLIENTS ) ;
2010-07-11 02:22:39 +00:00
if ( maxspectators . ival > MAX_CLIENTS )
2004-08-23 00:15:46 +00:00
Cvar_SetValue ( & maxspectators , MAX_CLIENTS ) ;
2010-11-06 23:05:29 +00:00
// find a free client slot
2013-06-23 02:17:02 +00:00
for ( i = 0 ; i < sv . allocated_client_slots ; i + + )
2004-08-23 00:15:46 +00:00
{
2013-06-23 02:17:02 +00:00
cl = svs . clients + i ;
2004-08-23 00:15:46 +00:00
if ( cl - > state = = cs_free )
{
newcl = cl ;
break ;
}
}
2010-11-06 23:05:29 +00:00
2014-03-30 08:55:06 +00:00
/*only q1/h2 has a maxclients/maxspectators separation. q2 or q3 the gamecode enforces any such clienttype limits*/
2010-11-06 23:05:29 +00:00
if ( svprogfuncs )
{
if ( spectator & & spectators > = maxspectators . ival )
2011-09-06 20:53:38 +00:00
redirect = true ;
2010-11-06 23:05:29 +00:00
if ( ! spectator & & clients > = maxclients . ival )
2011-09-06 20:53:38 +00:00
redirect = true ;
}
else
{
if ( clients > = maxclients . ival )
redirect = true ;
}
if ( redirect )
{
extern cvar_t sv_fullredirect ;
if ( ! * sv_fullredirect . string )
2010-11-06 23:05:29 +00:00
newcl = NULL ;
}
2004-08-23 00:15:46 +00:00
if ( ! newcl )
{
2010-11-06 23:05:29 +00:00
if ( ! svprogfuncs )
2004-08-23 00:15:46 +00:00
{
2010-11-06 23:05:29 +00:00
SV_RejectMessage ( protocol , " \n server is full \n \n " ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " %s:full connect \n " , NET_AdrToString ( adrbuf , sizeof ( adrbuf ) , & adr ) ) ;
2010-11-06 23:05:29 +00:00
}
else
{
if ( spectator & & spectators > = maxspectators . ival )
{
SV_RejectMessage ( protocol , " \n server is full (%i of %i spectators) \n \n " , spectators , maxspectators . ival ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " %s:full connect \n " , NET_AdrToString ( adrbuf , sizeof ( adrbuf ) , & adr ) ) ;
2010-11-06 23:05:29 +00:00
}
else if ( ! spectator & & clients > = maxclients . ival )
SV_RejectMessage ( protocol , " \n server is full (%i of %i players) \n \n " , clients , maxclients . ival ) ;
else
SV_RejectMessage ( protocol , " \n server is full (%i of %i connections) \n \n " , clients + spectators , sv . allocated_client_slots ) ;
2004-08-23 00:15:46 +00:00
}
2005-05-26 12:55:34 +00:00
return NULL ;
2004-08-23 00:15:46 +00:00
}
}
2009-03-03 01:52:30 +00:00
//set up the gamecode for this player, optionally drop them here
2004-08-23 00:15:46 +00:00
edictnum = ( newcl - svs . clients ) + 1 ;
2005-10-16 03:49:04 +00:00
switch ( svs . gametype )
2004-08-23 00:15:46 +00:00
{
2009-03-03 01:52:30 +00:00
# ifdef HLSERVER
//fallthrough
case GT_HALFLIFE :
{
char reject [ 128 ] ;
if ( ! SVHL_ClientConnect ( newcl , adr , reject ) )
{
SV_RejectMessage ( protocol , " %s " , reject ) ;
return NULL ;
}
}
break ;
# endif
2007-09-02 19:55:17 +00:00
# ifdef VM_Q1
case GT_Q1QVM :
2014-03-30 08:55:06 +00:00
# endif
# ifdef VM_LUA
case GT_LUA :
2007-09-02 19:55:17 +00:00
# endif
2005-10-16 03:49:04 +00:00
case GT_PROGS :
2014-05-10 13:42:13 +00:00
if ( protocol = = SCP_QUAKE2 )
{
SV_RejectMessage ( protocol , " This is a Quake server. " ) ;
Con_DPrintf ( " * Rejected q2 client. \n " ) ;
return NULL ;
}
2014-03-30 08:55:06 +00:00
if ( svprogfuncs )
ent = EDICT_NUM ( svprogfuncs , edictnum ) ;
else
ent = NULL ;
2004-08-23 00:15:46 +00:00
# ifdef Q2SERVER
temp . q2edict = NULL ;
# endif
temp . edict = ent ;
2013-03-12 22:44:00 +00:00
{
2014-03-30 08:55:06 +00:00
const char * reject = SV_CheckRejectConnection ( & adr , userinfo [ 0 ] , protocol , protextsupported , protextsupported2 , guid ) ;
2013-03-12 22:44:00 +00:00
if ( reject )
{
SV_RejectMessage ( protocol , " %s " , reject ) ;
2014-05-10 13:42:13 +00:00
Con_DPrintf ( " * Game rejected a connection. \n " ) ;
2013-03-12 22:44:00 +00:00
return NULL ;
}
}
2005-10-16 03:49:04 +00:00
break ;
2004-08-23 00:15:46 +00:00
# ifdef Q2SERVER
2005-10-16 03:49:04 +00:00
case GT_QUAKE2 :
2014-05-10 13:42:13 +00:00
if ( protocol ! = SCP_QUAKE2 )
{
SV_RejectMessage ( protocol , " This is a Quake2 server. " ) ;
Con_DPrintf ( " * Rejected non-q2 client. \n " ) ;
return NULL ;
}
2005-07-03 15:16:20 +00:00
q2ent = Q2EDICT_NUM ( edictnum ) ;
2004-08-23 00:15:46 +00:00
temp . edict = NULL ;
temp . q2edict = q2ent ;
if ( ! ge - > ClientConnect ( q2ent , temp . userinfo ) )
2014-05-10 13:42:13 +00:00
{
const char * reject = Info_ValueForKey ( temp . userinfo , " rejmsg " ) ;
if ( * reject )
SV_RejectMessage ( protocol , " %s \n Connection Refused. " , reject ) ;
else
SV_RejectMessage ( protocol , " Connection Refused. " ) ;
Con_DPrintf ( " Game rejected a connection. \n " ) ;
2005-05-26 12:55:34 +00:00
return NULL ;
2014-05-10 13:42:13 +00:00
}
2004-08-23 00:15:46 +00:00
2005-03-20 02:57:11 +00:00
ge - > ClientUserinfoChanged ( q2ent , temp . userinfo ) ;
2004-08-23 00:15:46 +00:00
2009-03-03 01:52:30 +00:00
break ;
# endif
default :
Sys_Error ( " Bad svs.gametype in SVC_DirectConnect " ) ;
break ;
}
2013-03-12 22:35:33 +00:00
if ( newcl - > frameunion . frames )
2009-03-03 01:52:30 +00:00
{
2013-03-12 22:35:33 +00:00
Con_Printf ( " Client frame info was set \n " ) ;
Z_Free ( newcl - > frameunion . frames ) ;
2005-10-16 03:49:04 +00:00
}
2005-07-03 15:16:20 +00:00
2013-06-23 02:17:02 +00:00
temp . name = newcl - > name ;
temp . team = newcl - > team ;
* newcl = temp ;
2004-08-23 00:15:46 +00:00
2008-11-09 22:29:28 +00:00
newcl - > challenge = challenge ;
2004-08-23 00:15:46 +00:00
newcl - > zquake_extensions = atoi ( Info_ValueForKey ( newcl - > userinfo , " *z_ext " ) ) ;
2007-02-23 00:21:33 +00:00
if ( * Info_ValueForKey ( newcl - > userinfo , " *fuhquake " ) ) //fuhquake doesn't claim to support z_ext but does look at our z_ext serverinfo key.
{ //so switch on the bits that it should be sending.
newcl - > zquake_extensions | = Z_EXT_PM_TYPE | Z_EXT_PM_TYPE_NEW ;
}
2009-06-21 17:45:33 +00:00
newcl - > zquake_extensions & = SUPPORTED_Z_EXTENSIONS ;
2004-08-23 00:15:46 +00:00
2013-09-09 01:16:03 +00:00
//ezquake's download mechanism is so smegging buggy.
//its causing far far far too many connectivity issues. seriously. its beyond a joke. I cannot stress that enough.
//as the client needs to listen for the serverinfo to know which extensions will actually be used (yay demos), we can just forget that it supports svc-level extensions, at least for anything that isn't spammed via clc_move etc before the serverinfo.
s = Info_ValueForKey ( newcl - > userinfo , " *client " ) ;
if ( ! strncmp ( s , " ezQuake " , 7 ) & & ( newcl - > fteprotocolextensions & PEXT_CHUNKEDDOWNLOADS ) )
{
if ( pext_ezquake_nochunks . ival )
{
newcl - > fteprotocolextensions & = ~ PEXT_CHUNKEDDOWNLOADS ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " %s: ignoring ezquake chunked downloads extension. \n " , NET_AdrToString ( adrbuf , sizeof ( adrbuf ) , & adr ) ) ;
2013-09-09 01:16:03 +00:00
}
}
2013-05-03 04:28:08 +00:00
Netchan_Setup ( NS_SERVER , & newcl - > netchan , & adr , qport ) ;
2004-08-23 00:15:46 +00:00
2014-05-10 13:42:13 +00:00
# ifdef HUFFNETWORK
2004-08-23 00:15:46 +00:00
if ( huffcrc )
2014-05-10 13:42:13 +00:00
newcl - > netchan . compresstable = Huff_CompressionCRC ( huffcrc ) ;
2004-08-23 00:15:46 +00:00
else
2014-05-10 13:42:13 +00:00
# endif
newcl - > netchan . compresstable = NULL ;
2012-02-15 13:53:30 +00:00
if ( mtu > = 64 )
2012-04-24 07:59:11 +00:00
{
2012-02-12 05:18:31 +00:00
newcl - > netchan . fragmentsize = mtu ;
2012-04-24 07:59:11 +00:00
newcl - > netchan . message . maxsize = sizeof ( newcl - > netchan . message_buf ) ;
}
2004-08-23 00:15:46 +00:00
2005-05-26 12:55:34 +00:00
newcl - > protocol = protocol ;
2005-07-16 00:53:08 +00:00
# ifdef NQPROT
2005-05-26 12:55:34 +00:00
newcl - > netchan . isnqprotocol = ISNQCLIENT ( newcl ) ;
2005-07-03 15:16:20 +00:00
# endif
2005-05-26 12:55:34 +00:00
2004-08-23 00:15:46 +00:00
newcl - > state = cs_connected ;
2008-11-09 22:29:28 +00:00
# ifdef Q3SERVER
newcl - > gamestatesequence = - 1 ;
# endif
2004-08-23 00:15:46 +00:00
newcl - > datagram . allowoverflow = true ;
newcl - > datagram . data = newcl - > datagram_buf ;
2013-03-12 22:13:26 +00:00
if ( mtu > = 64 )
newcl - > datagram . maxsize = sizeof ( newcl - > datagram_buf ) ;
else
newcl - > datagram . maxsize = MAX_DATAGRAM ;
2004-08-23 00:15:46 +00:00
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
newcl - > netchan . netprim = svs . netprim ;
newcl - > datagram . prim = svs . netprim ;
newcl - > netchan . message . prim = svs . netprim ;
2013-03-12 22:35:33 +00:00
SV_ClientProtocolExtensionsChanged ( newcl ) ;
2004-08-23 00:15:46 +00:00
// spectator mode can ONLY be set at join time
newcl - > spectator = spectator ;
2005-07-03 15:16:20 +00:00
2008-05-26 21:58:26 +00:00
newcl - > realip_ping = ( ( ( rand ( ) ^ ( rand ( ) < < 8 ) ^ * ( int * ) & realtime ) & 0xffffff ) < < 8 ) | ( newcl - svs . clients ) ;
2013-12-02 14:30:30 +00:00
if ( newcl - > istobeloaded & & newcl - > edict )
2012-01-24 04:24:14 +00:00
newcl - > playerclass = newcl - > edict - > xv - > playerclass ;
2004-08-23 00:15:46 +00:00
// parse some info from the info strings
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
SV_ExtractFromUserinfo ( newcl , true ) ;
2004-08-23 00:15:46 +00:00
// JACK: Init the floodprot stuff.
2006-05-29 06:12:12 +00:00
newcl - > floodprotmessage = 0.0 ;
newcl - > lastspoke = 0.0 ;
2004-08-23 00:15:46 +00:00
newcl - > lockedtill = 0 ;
# ifdef SVRANKING
if ( svs . demorecording | | ( svs . demoplayback & & newcl - > wasrecorded ) ) //disable rankings. Could cock things up.
{
SV_GetNewSpawnParms ( newcl ) ;
}
else
{
//rankid is figured out in extract from user info
if ( ! newcl - > rankid ) //failed to get a userid
{
if ( rank_needlogin . value )
{
2005-05-26 12:55:34 +00:00
SV_RejectMessage ( protocol , " Bad password/username \n This server requires logins. Please see the serverinfo for website and info on how to register. \n " ) ;
2004-08-23 00:15:46 +00:00
newcl - > state = cs_free ;
2005-05-26 12:55:34 +00:00
return NULL ;
2004-08-23 00:15:46 +00:00
}
// SV_OutOfBandPrintf (isquake2client, adr, "\nWARNING: You have not got a place on the ranking system, probably because a user with the same name has already connected and your pwds differ.\n\n");
2014-03-30 08:55:06 +00:00
if ( ! preserveparms )
SV_GetNewSpawnParms ( newcl ) ;
2004-08-23 00:15:46 +00:00
}
else
{
rankstats_t rs ;
if ( ! Rank_GetPlayerStats ( newcl - > rankid , & rs ) )
{
2005-05-26 12:55:34 +00:00
SV_RejectMessage ( protocol , " Rankings/Account system failed \n " ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " banned player %s is trying to connect \n " , newcl - > name ) ;
2005-03-12 23:40:42 +00:00
newcl - > name [ 0 ] = 0 ;
memset ( newcl - > userinfo , 0 , sizeof ( newcl - > userinfo ) ) ;
2004-08-23 00:15:46 +00:00
newcl - > state = cs_free ;
2005-05-26 12:55:34 +00:00
return NULL ;
2004-08-23 00:15:46 +00:00
}
if ( rs . flags1 & RANK_MUTED )
{
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_MEDIUM , " %s is muted (still) \n " , newcl - > name ) ;
2004-08-23 00:15:46 +00:00
}
if ( rs . flags1 & RANK_CUFFED )
{
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_LOW , " %s is now cuffed permanently \n " , newcl - > name ) ;
2004-08-23 00:15:46 +00:00
}
if ( rs . flags1 & RANK_CRIPPLED )
{
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s is still crippled \n " , newcl - > name ) ;
2005-07-03 15:16:20 +00:00
}
2004-08-23 00:15:46 +00:00
if ( rs . timeonserver )
{
2014-03-30 08:55:06 +00:00
if ( preserveparms )
2004-08-23 00:15:46 +00:00
{ //do nothing.
}
else if ( sv_resetparms . value )
{
SV_GetNewSpawnParms ( newcl ) ;
}
else
{
2011-09-03 03:49:43 +00:00
extern cvar_t rank_parms_first , rank_parms_last ;
for ( i = 0 ; i < NUM_SPAWN_PARMS ; i + + )
{
if ( i < NUM_RANK_SPAWN_PARMS & & i > = rank_parms_first . ival & & i < = rank_parms_last . ival )
newcl - > spawn_parms [ i ] = rs . parm [ i ] ;
else
newcl - > spawn_parms [ i ] = 0 ;
}
2004-08-23 00:15:46 +00:00
}
if ( rs . timeonserver > 3 * 60 ) //woo. Ages.
2013-11-29 14:36:47 +00:00
s = va ( langtext ( " Welcome back %s. You have previously spent %i:%i hours connected \n " , newcl - > language ) , newcl - > name , ( int ) ( rs . timeonserver / ( 60 * 60 ) ) , ( int ) ( ( int ) ( rs . timeonserver / 60 ) % ( 60 ) ) ) ;
2004-08-23 00:15:46 +00:00
else //measure this guy in minuites.
2013-11-29 14:36:47 +00:00
s = va ( langtext ( " Welcome back %s. You have previously spent %i mins connected \n " , newcl - > language ) , newcl - > name , ( int ) ( rs . timeonserver / 60 ) ) ;
2004-08-23 00:15:46 +00:00
2013-05-03 04:28:08 +00:00
SV_OutOfBandPrintf ( protocol = = SCP_QUAKE2 , & adr , s ) ;
2004-08-23 00:15:46 +00:00
}
2014-03-30 08:55:06 +00:00
else if ( ! preserveparms )
2004-08-23 00:15:46 +00:00
{
SV_GetNewSpawnParms ( newcl ) ;
2013-11-29 14:36:47 +00:00
SV_OutOfBandTPrintf ( protocol = = SCP_QUAKE2 , & adr , newcl - > language , " Welcome %s. Your time on this server is being logged and ranked \n " , newcl - > name , ( int ) rs . timeonserver ) ;
2004-08-23 00:15:46 +00:00
}
2007-10-05 17:43:26 +00:00
//else loaded players already have their initial parms set
2004-08-23 00:15:46 +00:00
}
}
# else
// call the progs to get default spawn parms for the new client
2014-03-30 08:55:06 +00:00
if ( ! preserveparms )
2004-08-23 00:15:46 +00:00
{
SV_GetNewSpawnParms ( newcl ) ;
}
# endif
if ( ! newcl - > wasrecorded )
{
2005-05-26 12:55:34 +00:00
SV_AcceptMessage ( protocol ) ;
2004-08-23 00:15:46 +00:00
2013-12-09 01:18:27 +00:00
newcl - > state = cs_free ;
2013-03-12 22:35:33 +00:00
if ( ISNQCLIENT ( newcl ) )
{
2013-03-12 22:47:42 +00:00
//FIXME: we should delay this until we actually have a name, because right now they'll be called unnamed or unconnected or something
SV_BroadcastPrintf ( PRINT_LOW , " New client connected \n " ) ;
2013-03-12 22:35:33 +00:00
}
else if ( redirect )
2011-09-06 20:53:38 +00:00
{
}
else if ( newcl - > spectator )
2004-08-23 00:15:46 +00:00
{
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_LOW , " spectator %s connected \n " , newcl - > name ) ;
2004-08-23 00:15:46 +00:00
// Con_Printf ("Spectator %s connected\n", newcl->name);
}
else
{
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_LOW , " client %s connected \n " , newcl - > name ) ;
2004-08-23 00:15:46 +00:00
// Con_DPrintf ("Client %s connected\n", newcl->name);
}
2013-12-09 01:18:27 +00:00
newcl - > state = cs_connected ;
2004-08-23 00:15:46 +00:00
}
else
{
if ( newcl - > spectator )
{
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_LOW , " recorded spectator %s connected \n " , newcl - > name ) ;
2004-08-23 00:15:46 +00:00
// Con_Printf ("Recorded spectator %s connected\n", newcl->name);
}
else
{
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_LOW , " recorded client %s connected \n " , newcl - > name ) ;
2004-08-23 00:15:46 +00:00
// Con_DPrintf ("Recorded client %s connected\n", newcl->name);
}
}
newcl - > sendinfo = true ;
2011-09-06 20:53:38 +00:00
if ( redirect )
numssclients = 1 ;
else
2004-08-23 00:15:46 +00:00
{
2011-09-06 20:53:38 +00:00
for ( i = 0 ; i < sizeof ( sv_motd ) / sizeof ( sv_motd [ 0 ] ) ; i + + )
{
if ( * sv_motd [ i ] . string )
SV_ClientPrintf ( newcl , PRINT_CHAT , " %s \n " , sv_motd [ i ] . string ) ;
}
2004-08-23 00:15:46 +00:00
}
2011-06-06 01:41:33 +00:00
SV_CheckRecentCrashes ( newcl ) ;
2011-09-05 01:48:23 +00:00
# ifdef VOICECHAT
2010-11-15 02:40:31 +00:00
SV_VoiceInitClient ( newcl ) ;
# endif
2014-03-30 08:55:06 +00:00
SV_EvaluatePenalties ( newcl ) ;
2004-08-23 00:15:46 +00:00
newcl - > fteprotocolextensions & = ~ PEXT_SPLITSCREEN ;
for ( clients = 1 ; clients < numssclients ; clients + + )
{
for ( i = 0 , cl = svs . clients ; i < sv . allocated_client_slots ; i + + , cl + + )
{
if ( cl - > state = = cs_free )
{
break ;
}
}
if ( i = = sv . allocated_client_slots )
break ;
newcl - > fteprotocolextensions | = PEXT_SPLITSCREEN ;
2006-02-17 02:51:59 +00:00
temp . frameunion . frames = cl - > frameunion . frames ; //don't touch these.
2004-08-23 00:15:46 +00:00
temp . edict = cl - > edict ;
memcpy ( cl , newcl , sizeof ( client_t ) ) ;
2013-06-23 02:17:02 +00:00
Q_strncatz ( cl - > guid , va ( " %s:%i " , guid , clients ) , sizeof ( cl - > guid ) ) ;
2010-08-12 09:04:05 +00:00
cl - > name = cl - > namebuf ;
cl - > team = cl - > teambuf ;
nextuserid + + ; // so every client gets a unique id
cl - > userid = nextuserid ;
cl - > playerclass = 0 ;
2006-02-17 02:51:59 +00:00
cl - > frameunion . frames = temp . frameunion . frames ;
2013-06-23 02:17:02 +00:00
cl - > pendingentbits = NULL ;
cl - > edict = EDICT_NUM ( svprogfuncs , i + 1 ) ;
2004-08-23 00:15:46 +00:00
cl - > fteprotocolextensions | = PEXT_SPLITSCREEN ;
if ( newcl - > controller )
{
newcl - > controller - > controlled = cl ;
newcl - > controller = cl ;
}
else
{
newcl - > controlled = cl ;
newcl - > controller = cl ;
}
cl - > controller = newcl ;
cl - > controlled = NULL ;
Q_strncpyS ( cl - > userinfo , userinfo [ clients ] , sizeof ( cl - > userinfo ) - 1 ) ;
cl - > userinfo [ sizeof ( cl - > userinfo ) - 1 ] = ' \0 ' ;
if ( spectator )
{
Info_RemoveKey ( cl - > userinfo , " spectator " ) ;
2005-03-07 08:58:26 +00:00
Info_SetValueForStarKey ( cl - > userinfo , " *spectator " , " 1 " , sizeof ( cl - > userinfo ) ) ;
2004-08-23 00:15:46 +00:00
}
else
Info_RemoveKey ( cl - > userinfo , " *spectator " ) ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
SV_ExtractFromUserinfo ( cl , true ) ;
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
// if (!preserveparms)
SV_GetNewSpawnParms ( cl ) ;
SV_EvaluatePenalties ( cl ) ;
2004-08-23 00:15:46 +00:00
}
newcl - > controller = NULL ;
2011-09-06 20:53:38 +00:00
if ( ! redirect )
{
Sys_ServerActivity ( ) ;
2004-08-23 00:15:46 +00:00
2011-09-06 20:53:38 +00:00
PIN_ShowMessages ( newcl ) ;
}
2005-12-15 19:15:39 +00:00
2005-05-26 12:55:34 +00:00
if ( ISNQCLIENT ( newcl ) )
2004-08-23 00:15:46 +00:00
{
2005-05-26 12:55:34 +00:00
newcl - > netchan . message . maxsize = sizeof ( newcl - > netchan . message_buf ) ;
host_client = newcl ;
SVNQ_New_f ( ) ;
}
2004-08-23 00:15:46 +00:00
2011-09-06 20:53:38 +00:00
newcl - > redirect = redirect ;
2005-12-15 19:15:39 +00:00
2014-03-30 08:55:06 +00:00
# ifdef SUBSERVERS
SSV_SavePlayerStats ( newcl , newcl - > previousserver ) ;
newcl - > previousserver = 0 ;
# endif
2005-12-15 19:15:39 +00:00
2005-05-26 12:55:34 +00:00
return newcl ;
}
2004-08-23 00:15:46 +00:00
int Rcon_Validate ( void )
{
if ( ! strlen ( rcon_password . string ) )
return 0 ;
if ( strcmp ( Cmd_Argv ( 1 ) , rcon_password . string ) )
return 0 ;
return 1 ;
}
/*
= = = = = = = = = = = = = = =
SVC_RemoteCommand
A client issued an rcon command .
Shift down the remaining args
Redirect all printfs
= = = = = = = = = = = = = = =
*/
void SVC_RemoteCommand ( void )
{
int i ;
char remaining [ 1024 ] ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2004-08-23 00:15:46 +00:00
2006-05-25 04:47:03 +00:00
{
2009-07-14 23:42:54 +00:00
char * br = SV_BannedReason ( & net_from ) ;
if ( br )
2006-05-25 04:47:03 +00:00
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Rcon from banned ip %s: %s \n " , NET_AdrToString ( adr , sizeof ( adr ) , & net_from ) , br ) ;
2006-05-25 04:47:03 +00:00
return ;
}
}
2004-08-23 00:15:46 +00:00
if ( ! Rcon_Validate ( ) )
{
2005-11-03 23:40:51 +00:00
# ifdef SVRANKING
2005-03-12 23:40:42 +00:00
if ( cmd_allowaccess . value ) //try and find a username, match the numeric password
2004-08-23 00:15:46 +00:00
{
2005-03-12 23:40:42 +00:00
int rid ;
char * s = Cmd_Argv ( 1 ) ;
char * colon = NULL , * c2 ;
rankstats_t stats ;
c2 = s ;
for ( ; ; )
2004-08-23 00:15:46 +00:00
{
2005-03-12 23:40:42 +00:00
c2 = strchr ( c2 , ' : ' ) ;
if ( ! c2 )
break ;
colon = c2 ;
c2 + + ;
}
if ( colon ) //oh, could this be a specific username?
{
* colon = ' \0 ' ;
colon + + ;
2011-09-03 03:49:43 +00:00
rid = Rank_GetPlayerID ( NULL , s , atoi ( colon ) , false , true ) ;
2005-03-12 23:40:42 +00:00
if ( rid )
{
if ( ! Rank_GetPlayerStats ( rid , & stats ) )
return ;
2004-08-23 00:15:46 +00:00
2005-07-03 15:16:20 +00:00
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Rcon from %s: \n %s \n "
2013-05-03 04:28:08 +00:00
, NET_AdrToString ( adr , sizeof ( adr ) , & net_from ) , net_message . data + 4 ) ;
2004-08-23 00:15:46 +00:00
2013-11-29 14:36:47 +00:00
SV_BeginRedirect ( RD_PACKET , svs . language ) ;
2004-08-23 00:15:46 +00:00
2005-03-12 23:40:42 +00:00
remaining [ 0 ] = 0 ;
2004-08-23 00:15:46 +00:00
2005-03-12 23:40:42 +00:00
for ( i = 2 ; i < Cmd_Argc ( ) ; i + + )
2004-08-23 00:15:46 +00:00
{
2005-03-12 23:40:42 +00:00
if ( strlen ( remaining ) + strlen ( Cmd_Argv ( i ) ) > = sizeof ( remaining ) - 2 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Rcon was too long \n " ) ;
2005-03-12 23:40:42 +00:00
SV_EndRedirect ( ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Rcon from %s: \n %s \n "
2013-05-03 04:28:08 +00:00
, NET_AdrToString ( adr , sizeof ( adr ) , & net_from ) , " Was too long - possible buffer overflow attempt " ) ;
2005-03-12 23:40:42 +00:00
return ;
}
strcat ( remaining , Cmd_Argv ( i ) ) ;
strcat ( remaining , " " ) ;
2004-08-23 00:15:46 +00:00
}
2005-03-12 23:40:42 +00:00
Cmd_ExecuteString ( remaining , stats . trustlevel ) ;
2004-08-23 00:15:46 +00:00
2005-03-12 23:40:42 +00:00
SV_EndRedirect ( ) ;
return ;
}
2004-08-23 00:15:46 +00:00
}
}
2005-11-03 23:40:51 +00:00
# endif
2004-08-23 00:15:46 +00:00
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Bad rcon from %s: \n %s \n "
2013-05-03 04:28:08 +00:00
, NET_AdrToString ( adr , sizeof ( adr ) , & net_from ) , net_message . data + 4 ) ;
2004-08-23 00:15:46 +00:00
2013-11-29 14:36:47 +00:00
SV_BeginRedirect ( RD_PACKET , svs . language ) ;
2004-08-23 00:15:46 +00:00
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Bad rcon_password. \n " ) ;
2004-08-23 00:15:46 +00:00
}
else
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Rcon from %s: \n %s \n "
2013-05-03 04:28:08 +00:00
, NET_AdrToString ( adr , sizeof ( adr ) , & net_from ) , net_message . data + 4 ) ;
2004-08-23 00:15:46 +00:00
2013-11-29 14:36:47 +00:00
SV_BeginRedirect ( RD_PACKET , svs . language ) ;
2004-08-23 00:15:46 +00:00
remaining [ 0 ] = 0 ;
for ( i = 2 ; i < Cmd_Argc ( ) ; i + + )
{
if ( strlen ( remaining ) + strlen ( Cmd_Argv ( i ) ) > = sizeof ( remaining ) - 2 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Rcon was too long \n " ) ;
2004-08-23 00:15:46 +00:00
SV_EndRedirect ( ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Rcon from %s: \n %s \n "
2013-05-03 04:28:08 +00:00
, NET_AdrToString ( adr , sizeof ( adr ) , & net_from ) , " Was too long - possible buffer overflow attempt " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
strcat ( remaining , Cmd_Argv ( i ) ) ;
strcat ( remaining , " " ) ;
}
2009-11-04 21:16:50 +00:00
Cmd_ExecuteString ( remaining , rcon_level . ival ) ;
2004-08-23 00:15:46 +00:00
}
SV_EndRedirect ( ) ;
}
2006-09-17 00:59:22 +00:00
void SVC_RealIP ( void )
{
unsigned int slotnum ;
int cookie ;
2009-07-14 23:42:54 +00:00
char * banreason ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2008-05-25 22:23:43 +00:00
2006-09-17 00:59:22 +00:00
slotnum = atoi ( Cmd_Argv ( 1 ) ) ;
cookie = atoi ( Cmd_Argv ( 2 ) ) ;
2013-12-02 14:30:30 +00:00
if ( slotnum > = svs . allocated_client_slots )
2006-09-17 00:59:22 +00:00
{
//a malitious user
return ;
}
if ( cookie ! = svs . clients [ slotnum ] . realip_num )
{
//could be someone trying to kick someone else
//so we can't kick, as much as we might like to.
return ;
}
if ( svs . clients [ slotnum ] . realip_status )
return ;
2013-05-03 04:28:08 +00:00
if ( NET_AddressSmellsFunny ( & net_from ) )
2008-05-25 22:23:43 +00:00
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " funny realip address: %s, " , NET_AdrToString ( adr , sizeof ( adr ) , & net_from ) ) ;
Con_TPrintf ( " proxy address: %s \n " , NET_AdrToString ( adr , sizeof ( adr ) , & svs . clients [ slotnum ] . netchan . remote_address ) ) ;
2008-05-25 22:23:43 +00:00
return ;
}
2009-07-14 23:42:54 +00:00
banreason = SV_BannedReason ( & net_from ) ;
if ( banreason )
2008-05-25 22:23:43 +00:00
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " %s has a banned realip \n " , svs . clients [ slotnum ] . name ) ;
2009-07-14 23:42:54 +00:00
if ( * banreason )
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( & svs . clients [ slotnum ] , PRINT_CHAT , " You were banned. \n Reason: %s \n " , banreason ) ;
2008-05-25 22:23:43 +00:00
else
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( & svs . clients [ slotnum ] , PRINT_CHAT , " You were banned. \n " ) ;
2008-05-25 22:23:43 +00:00
SV_DropClient ( & svs . clients [ slotnum ] ) ;
return ;
}
2006-09-17 00:59:22 +00:00
svs . clients [ slotnum ] . realip_status = 1 ;
svs . clients [ slotnum ] . realip = net_from ;
}
void SVC_ACK ( void )
{
int slotnum ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2013-10-29 17:38:22 +00:00
for ( slotnum = 0 ; slotnum < svs . allocated_client_slots ; slotnum + + )
2006-09-17 00:59:22 +00:00
{
if ( svs . clients [ slotnum ] . state )
{
2013-05-03 04:28:08 +00:00
if ( svs . clients [ slotnum ] . realip_status = = 1 & & NET_CompareAdr ( & svs . clients [ slotnum ] . realip , & net_from ) )
2006-09-17 00:59:22 +00:00
{
if ( ! * Cmd_Argv ( 1 ) )
svs . clients [ slotnum ] . realip_status = 2 ;
else if ( atoi ( Cmd_Argv ( 1 ) ) = = svs . clients [ slotnum ] . realip_ping & &
atoi ( Cmd_Argv ( 2 ) ) = = svs . clients [ slotnum ] . realip_num )
{
svs . clients [ slotnum ] . realip_status = 3 ;
}
else
{
2013-05-03 04:28:08 +00:00
Netchan_OutOfBandPrint ( NS_SERVER , & net_from , " realip not accepted. Please stop hacking. \n " ) ;
2006-09-17 00:59:22 +00:00
}
return ;
}
}
}
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " A2A_ACK from %s \n " , NET_AdrToString ( adr , sizeof ( adr ) , & net_from ) ) ;
2006-09-17 00:59:22 +00:00
}
2012-04-24 07:59:11 +00:00
//returns false to block replies
//this is to mitigate wasted bandwidth if we're used as a udp escilation
qboolean SVC_ThrottleInfo ( void )
{
# define THROTTLE_PPS 20
static unsigned int blockuntil ;
unsigned int curtime = Sys_Milliseconds ( ) ;
unsigned int inc = 1000 / THROTTLE_PPS ;
/*don't go too far back*/
//if (blockuntil < curtime - 1000)
if ( 1000 < curtime - blockuntil )
blockuntil = curtime - 1000 ;
/*don't allow it to go beyond curtime or we get issues with the logic above*/
if ( inc > curtime - blockuntil )
2013-03-12 22:13:26 +00:00
return false ;
2012-04-24 07:59:11 +00:00
blockuntil + = inc ;
2013-03-12 22:13:26 +00:00
return true ;
2012-04-24 07:59:11 +00:00
}
2004-08-23 00:15:46 +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 .
= = = = = = = = = = = = = = = = =
*/
qboolean SV_ConnectionlessPacket ( void )
{
char * s ;
char * c ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2004-08-23 00:15:46 +00:00
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
MSG_BeginReading ( svs . netprim ) ;
2004-08-23 00:15:46 +00:00
if ( net_message . cursize > = MAX_QWMSGLEN ) //add a null term in message space
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Oversized packet from %s \n " , NET_AdrToString ( adr , sizeof ( adr ) , & net_from ) ) ;
2004-08-23 00:15:46 +00:00
net_message . cursize = MAX_QWMSGLEN - 1 ;
}
net_message . data [ net_message . cursize ] = ' \0 ' ; //terminate it properly. Just in case.
MSG_ReadLong ( ) ; // skip the -1 marker
s = MSG_ReadStringLine ( ) ;
2004-12-08 04:14:52 +00:00
Cmd_TokenizeString ( s , false , false ) ;
2004-08-23 00:15:46 +00:00
c = Cmd_Argv ( 0 ) ;
if ( ! strcmp ( c , " ping " ) | | ( c [ 0 ] = = A2A_PING & & ( c [ 1 ] = = 0 | | c [ 1 ] = = ' \n ' ) ) )
SVC_Ping ( ) ;
else if ( c [ 0 ] = = A2A_ACK & & ( c [ 1 ] = = 0 | | c [ 1 ] = = ' \n ' ) )
2006-09-17 00:59:22 +00:00
SVC_ACK ( ) ;
2004-08-23 00:15:46 +00:00
else if ( ! strcmp ( c , " status " ) )
2012-04-24 07:59:11 +00:00
{
if ( SVC_ThrottleInfo ( ) )
SVC_Status ( ) ;
}
2004-08-23 00:15:46 +00:00
else if ( ! strcmp ( c , " log " ) )
2012-04-24 07:59:11 +00:00
{
if ( SVC_ThrottleInfo ( ) )
SVC_Log ( ) ;
}
2005-07-03 15:16:20 +00:00
# ifdef Q2SERVER
2004-08-23 00:15:46 +00:00
else if ( ! strcmp ( c , " info " ) )
2012-04-24 07:59:11 +00:00
{
if ( SVC_ThrottleInfo ( ) )
SVC_InfoQ2 ( ) ;
}
2005-07-03 15:16:20 +00:00
# endif
2004-08-23 00:15:46 +00:00
else if ( ! strncmp ( c , " connect " , 7 ) )
{
2005-03-07 08:58:26 +00:00
# ifdef Q3SERVER
if ( svs . gametype = = GT_QUAKE3 )
{
SVQ3_DirectConnect ( ) ;
return true ;
}
2008-11-09 22:29:28 +00:00
if ( sv_listen_q3 . value )
{
if ( ! strstr ( s , " \\ name \\ " ) )
{ //if name isn't in the string, assume they're q3
//this isn't quite true though, hence the listen check. but users shouldn't be connecting with an empty name anyway. more fool them.
2014-05-10 13:42:13 +00:00
# ifdef HUFFNETWORK
2008-11-09 22:29:28 +00:00
Huff_DecryptPacket ( & net_message , 12 ) ;
2014-05-10 13:42:13 +00:00
# endif
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
MSG_BeginReading ( svs . netprim ) ;
2008-11-09 22:29:28 +00:00
MSG_ReadLong ( ) ;
s = MSG_ReadStringLine ( ) ;
Cmd_TokenizeString ( s , false , false ) ;
}
}
2005-03-07 08:58:26 +00:00
# endif
if ( secure . value ) //FIXME: possible problem for nq clients when enabled
2008-11-09 22:29:28 +00:00
{
2013-11-29 14:36:47 +00:00
Netchan_OutOfBandTPrintf ( NS_SERVER , & net_from , svs . language , " %c \n This server requires client validation. \n Please use the " DISTRIBUTION " validation program \n " , A2C_PRINT ) ;
2008-11-09 22:29:28 +00:00
}
2004-08-23 00:15:46 +00:00
else
{
SVC_DirectConnect ( ) ;
return true ;
}
}
2005-08-03 23:14:59 +00:00
else if ( ! strcmp ( c , " \xad \xad \xad \xad " " getchallenge " ) )
{
SVC_GetChallenge ( ) ;
}
2004-08-23 00:15:46 +00:00
else if ( ! strcmp ( c , " getchallenge " ) )
{
2005-05-26 12:55:34 +00:00
SVC_GetChallenge ( ) ;
2004-08-23 00:15:46 +00:00
}
2005-07-03 15:16:20 +00:00
# ifdef NQPROT
2010-11-07 02:17:45 +00:00
/*for DP*/
2009-04-01 22:03:56 +00:00
else if ( ! strcmp ( c , " getstatus " ) )
2012-04-24 07:59:11 +00:00
{
if ( SVC_ThrottleInfo ( ) )
SVC_GetInfo ( Cmd_Args ( ) , true ) ;
}
2005-05-26 12:55:34 +00:00
else if ( ! strcmp ( c , " getinfo " ) )
2012-04-24 07:59:11 +00:00
{
if ( SVC_ThrottleInfo ( ) )
SVC_GetInfo ( Cmd_Args ( ) , false ) ;
}
2005-07-03 15:16:20 +00:00
# endif
2004-08-23 00:15:46 +00:00
else if ( ! strcmp ( c , " rcon " ) )
SVC_RemoteCommand ( ) ;
2006-09-17 00:59:22 +00:00
else if ( ! strcmp ( c , " realip " ) )
SVC_RealIP ( ) ;
2006-01-21 00:06:49 +00:00
else if ( ! PR_GameCodePacket ( net_message . data + 4 ) )
2011-10-27 16:16:29 +00:00
{
static unsigned int lt ;
unsigned int ct = Sys_Milliseconds ( ) ;
if ( ct - lt > 5 * 1000 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " bad connectionless packet from %s: \" %s \" \n " , NET_AdrToString ( adr , sizeof ( adr ) , & net_from ) , c ) ;
2011-10-27 16:16:29 +00:00
lt = ct ;
}
}
2004-08-23 00:15:46 +00:00
return false ;
}
2005-06-14 04:52:10 +00:00
# ifdef NQPROT
2013-03-31 04:21:08 +00:00
qboolean SVNQ_ConnectionlessPacket ( void )
2005-05-26 12:55:34 +00:00
{
sizebuf_t sb ;
int header ;
int length ;
2010-11-07 02:17:45 +00:00
int active , i ;
2011-06-16 02:03:57 +00:00
int mod , modver , flags ;
unsigned int passwd ;
2005-05-26 12:55:34 +00:00
char * str ;
2010-11-07 02:17:45 +00:00
char buffer [ 256 ] , buffer2 [ 256 ] ;
netadr_t localaddr ;
2014-03-30 08:55:06 +00:00
char * banreason ;
2005-06-04 04:20:20 +00:00
if ( net_from . type = = NA_LOOPBACK )
2013-03-31 04:21:08 +00:00
return false ;
2005-06-04 04:20:20 +00:00
2007-06-10 05:14:38 +00:00
if ( ! sv_listen_nq . value )
2013-03-31 04:21:08 +00:00
return false ;
2005-05-26 12:55:34 +00:00
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
MSG_BeginReading ( svs . netprim ) ;
2005-07-29 22:26:43 +00:00
header = LongSwap ( MSG_ReadLong ( ) ) ;
2005-05-26 12:55:34 +00:00
if ( ! ( header & NETFLAG_CTL ) )
2011-12-05 15:23:40 +00:00
{
2013-03-31 04:21:08 +00:00
//this nasty chunk of code is to try to handle challenges with nq's challengeless protocol, by using stringcmds. woo. evil hacks.
2011-12-05 15:23:40 +00:00
if ( sv_listen_nq . ival = = 2 )
if ( ( header & ( NETFLAG_DATA | NETFLAG_EOM ) ) = = ( NETFLAG_DATA | NETFLAG_EOM ) )
{
int sequence ;
2014-03-30 08:55:06 +00:00
if ( SV_BannedReason ( & net_from ) )
return false ; //just in case.
2011-12-05 15:23:40 +00:00
sequence = LongSwap ( MSG_ReadLong ( ) ) ;
if ( sequence < = 1 )
{
int numnops = 0 ;
int numnonnops = 0 ;
/*make it at least robust enough to ignore any other stringcmds*/
while ( 1 )
{
switch ( MSG_ReadByte ( ) )
{
case clc_nop :
numnops + + ;
continue ;
case clc_stringcmd :
numnonnops + + ;
2013-03-12 22:44:00 +00:00
if ( msg_readcount + 17 < = net_message . cursize & & ! strncmp ( " challengeconnect " , & net_message . data [ msg_readcount ] , 17 ) )
2011-12-05 15:23:40 +00:00
{
client_t * newcl ;
2013-03-12 22:44:00 +00:00
Cmd_TokenizeString ( MSG_ReadStringLine ( ) , false , false ) ;
2011-12-05 15:23:40 +00:00
/*okay, so this is a reliable packet from a client, containing a 'cmd challengeconnect $challenge' response*/
2013-03-12 22:13:26 +00:00
str = va ( " connect %i %i %s \" \\ name \\ unconnected \\ mod \\ %s \\ modver \\ %s \\ flags \\ %s \\ password \\ %s \" " , NET_PROTOCOL_VERSION , 0 , Cmd_Argv ( 1 ) , Cmd_Argv ( 2 ) , Cmd_Argv ( 3 ) , Cmd_Argv ( 4 ) , Cmd_Argv ( 5 ) ) ;
2011-12-05 15:23:40 +00:00
Cmd_TokenizeString ( str , false , false ) ;
newcl = SVC_DirectConnect ( ) ;
if ( newcl )
newcl - > netchan . incoming_reliable_sequence = sequence ;
/*if there is anything else in the packet, we don't actually care. its reliable, so they'll resend*/
2013-03-31 04:21:08 +00:00
return true ;
2011-12-05 15:23:40 +00:00
}
2013-03-12 22:44:00 +00:00
else
MSG_ReadString ( ) ;
2011-12-05 15:23:40 +00:00
continue ;
case - 1 :
break ;
default :
numnonnops + + ;
break ;
}
break ;
}
if ( numnops & & ! numnonnops )
{
sb . maxsize = sizeof ( buffer ) ;
sb . data = buffer ;
/*ack it, so dumb proquake clones can actually send the proper packet*/
SZ_Clear ( & sb ) ;
MSG_WriteLong ( & sb , BigLong ( NETFLAG_ACK | 8 ) ) ;
MSG_WriteLong ( & sb , sequence ) ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , sb . cursize , sb . data , & net_from ) ;
2011-12-05 15:23:40 +00:00
2012-10-01 14:29:44 +00:00
/*resend the cmd request, cos if they didn't send it then it must have gotten dropped.
at this point , we assume its a proquake clone and that it already thinks that we are proquake
a vanilla client will not start spamming nops until it has received the server info , so its only the proquake clients + clones that will send a nop before a challengeconnect
unfortunatly we don ' t know the modver + flags + password any more . I hope its not needed . if it does , server admins will be forced to use sv_listen_nq 1 instead of 2 */
2011-12-05 15:23:40 +00:00
SZ_Clear ( & sb ) ;
MSG_WriteLong ( & sb , 0 ) ;
MSG_WriteLong ( & sb , 0 ) ;
MSG_WriteByte ( & sb , svc_stufftext ) ;
2012-10-01 14:29:44 +00:00
MSG_WriteString ( & sb , va ( " cmd challengeconnect %i %i \n " , SV_NewChallenge ( ) , 1 /*MOD_PROQUAKE*/ ) ) ;
2011-12-05 15:23:40 +00:00
* ( int * ) sb . data = BigLong ( NETFLAG_UNRELIABLE | sb . cursize ) ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , sb . cursize , sb . data , & net_from ) ;
2013-03-31 04:21:08 +00:00
return true ;
2011-12-05 15:23:40 +00:00
}
}
}
2013-03-31 04:21:08 +00:00
return false ; //no idea what it is.
2011-12-05 15:23:40 +00:00
}
2005-05-26 12:55:34 +00:00
length = header & NETFLAG_LENGTH_MASK ;
if ( length ! = net_message . cursize )
2013-03-31 04:21:08 +00:00
return false ; //corrupt or not ours
2005-05-26 12:55:34 +00:00
switch ( MSG_ReadByte ( ) )
{
case CCREQ_CONNECT :
sb . maxsize = sizeof ( buffer ) ;
sb . data = buffer ;
if ( strcmp ( MSG_ReadString ( ) , NET_GAMENAME_NQ ) )
{
SZ_Clear ( & sb ) ;
MSG_WriteLong ( & sb , 0 ) ;
MSG_WriteByte ( & sb , CCREP_REJECT ) ;
MSG_WriteString ( & sb , " Incorrect game \n " ) ;
* ( int * ) sb . data = BigLong ( NETFLAG_CTL + sb . cursize ) ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , sb . cursize , sb . data , & net_from ) ;
2013-03-31 04:21:08 +00:00
return false ; //not our game.
2005-05-26 12:55:34 +00:00
}
if ( MSG_ReadByte ( ) ! = NET_PROTOCOL_VERSION )
{
SZ_Clear ( & sb ) ;
MSG_WriteLong ( & sb , 0 ) ;
MSG_WriteByte ( & sb , CCREP_REJECT ) ;
MSG_WriteString ( & sb , " Incorrect version \n " ) ;
* ( int * ) sb . data = BigLong ( NETFLAG_CTL + sb . cursize ) ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , sb . cursize , sb . data , & net_from ) ;
2013-03-31 04:21:08 +00:00
return false ; //not our version...
2005-05-26 12:55:34 +00:00
}
2014-03-30 08:55:06 +00:00
banreason = SV_BannedReason ( & net_from ) ;
if ( banreason )
{
SZ_Clear ( & sb ) ;
MSG_WriteLong ( & sb , 0 ) ;
MSG_WriteByte ( & sb , CCREP_REJECT ) ;
MSG_WriteString ( & sb , * banreason ? va ( " You are banned: %s \n " , banreason ) : " You are banned \n " ) ;
* ( int * ) sb . data = BigLong ( NETFLAG_CTL + sb . cursize ) ;
NET_SendPacket ( NS_SERVER , sb . cursize , sb . data , & net_from ) ;
return false ; //not our version...
}
2011-06-16 02:03:57 +00:00
mod = MSG_ReadByte ( ) ;
modver = MSG_ReadByte ( ) ;
flags = MSG_ReadByte ( ) ;
passwd = MSG_ReadLong ( ) ;
2005-05-26 12:55:34 +00:00
2013-09-06 22:57:44 +00:00
if ( ! strncmp ( MSG_ReadString ( ) , " getchallenge " , 12 ) & & ( sv_listen_qw . ival | | sv_listen_dp . ival ) )
2011-06-16 02:03:57 +00:00
{
/*dual-stack client, supporting either DP or QW protocols*/
SVC_GetChallenge ( ) ;
}
else
{
2011-12-05 15:23:40 +00:00
if ( sv_listen_nq . ival = = 2 )
{
SZ_Clear ( & sb ) ;
MSG_WriteLong ( & sb , 0 ) ;
MSG_WriteByte ( & sb , CCREP_ACCEPT ) ;
NET_LocalAddressForRemote ( svs . sockets , & net_from , & localaddr , 0 ) ;
MSG_WriteLong ( & sb , ShortSwap ( localaddr . port ) ) ;
2012-10-01 14:29:44 +00:00
MSG_WriteByte ( & sb , 1 /*MOD_PROQUAKE*/ ) ;
MSG_WriteByte ( & sb , 10 * 3.50 /*MOD_PROQUAKE_VERSION*/ ) ;
2011-12-05 15:23:40 +00:00
* ( int * ) sb . data = BigLong ( NETFLAG_CTL | sb . cursize ) ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , sb . cursize , sb . data , & net_from ) ;
2011-06-16 02:03:57 +00:00
2011-12-05 15:23:40 +00:00
SZ_Clear ( & sb ) ;
MSG_WriteLong ( & sb , 0 ) ;
MSG_WriteLong ( & sb , 0 ) ;
MSG_WriteByte ( & sb , svc_stufftext ) ;
2012-10-01 14:29:44 +00:00
MSG_WriteString ( & sb , va ( " cmd challengeconnect %i %i %i %i %i \n " , SV_NewChallenge ( ) , mod , modver , flags , passwd ) ) ;
2011-12-05 15:23:40 +00:00
* ( int * ) sb . data = BigLong ( NETFLAG_UNRELIABLE | sb . cursize ) ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , sb . cursize , sb . data , & net_from ) ;
2011-12-05 15:23:40 +00:00
/*don't worry about repeating, the nop case above will recover it*/
}
else
{
2012-10-01 14:29:44 +00:00
str = va ( " connect %i %i %i \" \\ name \\ unconnected \\ mod \\ %i \\ modver \\ %i \\ flags \\ %i \\ password \\ %i \" " , NET_PROTOCOL_VERSION , 0 , SV_NewChallenge ( ) , mod , modver , flags , passwd ) ;
2011-12-05 15:23:40 +00:00
Cmd_TokenizeString ( str , false , false ) ;
SVC_DirectConnect ( ) ;
}
2011-06-16 02:03:57 +00:00
}
2013-03-31 04:21:08 +00:00
return true ;
2010-11-07 02:17:45 +00:00
case CCREQ_SERVER_INFO :
2014-03-30 08:55:06 +00:00
if ( SV_BannedReason ( & net_from ) )
return false ;
2010-11-07 02:17:45 +00:00
if ( Q_strcmp ( MSG_ReadString ( ) , NET_GAMENAME_NQ ) ! = 0 )
2013-03-31 04:21:08 +00:00
return false ;
2010-11-07 02:17:45 +00:00
sb . maxsize = sizeof ( buffer ) ;
sb . data = buffer ;
SZ_Clear ( & sb ) ;
// save space for the header, filled in later
MSG_WriteLong ( & sb , 0 ) ;
MSG_WriteByte ( & sb , CCREP_SERVER_INFO ) ;
if ( NET_LocalAddressForRemote ( svs . sockets , & net_from , & localaddr , 0 ) )
2013-05-03 04:28:08 +00:00
MSG_WriteString ( & sb , NET_AdrToString ( buffer2 , sizeof ( buffer2 ) , & localaddr ) ) ;
2010-11-07 02:17:45 +00:00
else
MSG_WriteString ( & sb , " unknown " ) ;
active = 0 ;
for ( i = 0 ; i < sv . allocated_client_slots ; i + + )
if ( svs . clients [ i ] . state )
active + + ;
MSG_WriteString ( & sb , hostname . string ) ;
MSG_WriteString ( & sb , sv . name ) ;
MSG_WriteByte ( & sb , active ) ;
MSG_WriteByte ( & sb , maxclients . value ) ;
MSG_WriteByte ( & sb , NET_PROTOCOL_VERSION ) ;
* ( int * ) sb . data = BigLong ( NETFLAG_CTL + sb . cursize ) ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , sb . cursize , sb . data , & net_from ) ;
2013-03-31 04:21:08 +00:00
return true ;
2010-11-28 19:12:50 +00:00
case CCREQ_PLAYER_INFO :
2014-03-30 08:55:06 +00:00
if ( SV_BannedReason ( & net_from ) )
return false ;
2010-11-28 19:12:50 +00:00
/*one request per player, ouch ouch ouch, what will it make of 32 players, I wonder*/
sb . maxsize = sizeof ( buffer ) ;
sb . data = buffer ;
// save space for the header, filled in later
SZ_Clear ( & sb ) ;
MSG_WriteLong ( & sb , 0 ) ;
{
unsigned int pno ;
client_t * cl ;
pno = MSG_ReadByte ( ) ;
if ( pno > = sv . allocated_client_slots )
break ;
cl = & svs . clients [ pno ] ;
if ( cl - > state < = cs_zombie )
break ;
MSG_WriteByte ( & sb , CCREP_PLAYER_INFO ) ;
MSG_WriteByte ( & sb , pno ) ;
MSG_WriteString ( & sb , cl - > name ) ;
MSG_WriteLong ( & sb , cl - > playercolor ) ;
MSG_WriteLong ( & sb , cl - > old_frags ) ;
MSG_WriteLong ( & sb , realtime - cl - > connection_started ) ;
MSG_WriteString ( & sb , " " ) ; /*player's address, leave blank, don't spam that info as it can result in personal attacks exploits*/
}
* ( int * ) sb . data = BigLong ( NETFLAG_CTL + sb . cursize ) ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , sb . cursize , sb . data , & net_from ) ;
2013-03-31 04:21:08 +00:00
return true ;
2010-11-28 19:12:50 +00:00
case CCREQ_RULE_INFO :
2014-03-30 08:55:06 +00:00
if ( SV_BannedReason ( & net_from ) )
return false ;
2010-11-28 19:12:50 +00:00
/*lol, nq is evil*/
sb . maxsize = sizeof ( buffer ) ;
sb . data = buffer ;
// save space for the header, filled in later
SZ_Clear ( & sb ) ;
MSG_WriteLong ( & sb , 0 ) ;
{
char * rname , * rval , * kname ;
rname = MSG_ReadString ( ) ;
if ( ! * rname )
rname = Info_KeyForNumber ( svs . info , 0 ) ;
else
{
int i = 0 ;
for ( ; ; )
{
kname = Info_KeyForNumber ( svs . info , i ) ;
if ( ! * kname )
{
rname = NULL ;
break ;
}
i + + ;
if ( ! strcmp ( kname , rname ) )
{
rname = Info_KeyForNumber ( svs . info , i ) ;
break ;
}
}
}
rval = Info_ValueForKey ( svs . info , rname ) ;
MSG_WriteByte ( & sb , CCREP_RULE_INFO ) ;
MSG_WriteString ( & sb , rname ) ;
MSG_WriteString ( & sb , rval ) ;
}
* ( int * ) sb . data = BigLong ( NETFLAG_CTL + sb . cursize ) ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , sb . cursize , sb . data , & net_from ) ;
2013-03-31 04:21:08 +00:00
return true ;
2005-05-26 12:55:34 +00:00
}
2013-03-31 04:21:08 +00:00
return false ;
2005-05-26 12:55:34 +00:00
}
2005-06-14 04:52:10 +00:00
# endif
2005-05-26 12:55:34 +00:00
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
PACKET FILTERING
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
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 " .
Removeip will only remove an address specified exactly the same way . 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 you easily set up a private game , or a game that only allows players from your local network .
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2014-03-30 08:55:06 +00:00
cvar_t filterban = CVARD ( " filterban " , " 1 " , " If 0, players will be kicked by default unless there is a rule that allows them. Also affects the default action of addip. " ) ;
2006-05-25 04:47:03 +00:00
2004-08-23 00:15:46 +00:00
//send a network packet to a new non-connected client.
//this is to combat tunneling
void SV_OpenRoute_f ( void )
{
netadr_t to ;
char data [ 64 ] ;
2013-03-12 22:53:23 +00:00
NET_StringToAdr ( Cmd_Argv ( 1 ) , PORT_QWCLIENT , & to ) ;
2004-08-23 00:15:46 +00:00
sprintf ( data , " \xff \xff \xff \xff %c " , S2C_CONNECTION ) ;
2013-05-03 04:28:08 +00:00
Netchan_OutOfBandPrint ( NS_SERVER , & to , " hello " ) ;
2004-08-23 00:15:46 +00:00
// NET_SendPacket (strlen(data)+1, data, to);
}
//============================================================================
/*
= = = = = = = = = = = = = = = = =
SV_ReadPackets
= = = = = = = = = = = = = = = = =
*/
2014-03-30 08:55:06 +00:00
void SV_KillExpiredBans ( void ) ;
2009-11-07 13:29:15 +00:00
# ifdef SERVER_DEMO_PLAYBACK
2004-08-23 00:15:46 +00:00
//FIMXE: move to header
qboolean SV_GetPacket ( void ) ;
2009-11-07 13:29:15 +00:00
# endif
2011-06-05 23:53:33 +00:00
qboolean SV_ReadPackets ( float * delay )
2004-08-23 00:15:46 +00:00
{
int i ;
client_t * cl ;
int qport ;
2007-08-30 20:45:01 +00:00
laggedpacket_t * lp ;
2009-07-14 23:42:54 +00:00
char * banreason ;
2009-11-04 21:16:50 +00:00
qboolean received = false ;
2011-10-27 16:16:29 +00:00
int giveup = 5000 ; /*we're fucked if we need this to be this high, but at least we can retain some clients if we're really running that slow*/
int cookie = 0 ;
2007-08-30 20:45:01 +00:00
2014-03-30 08:55:06 +00:00
SV_KillExpiredBans ( ) ;
2013-10-29 17:38:22 +00:00
for ( i = 0 ; i < svs . allocated_client_slots ; i + + ) //fixme: shouldn't we be using svs.allocated_client_slots ?
2007-08-30 20:45:01 +00:00
{
cl = & svs . clients [ i ] ;
2011-06-05 23:53:33 +00:00
while ( cl - > laggedpacket )
2007-08-30 20:45:01 +00:00
{
2011-06-05 23:53:33 +00:00
//schedule a wakeup so minping is more consistant
if ( cl - > laggedpacket - > time > realtime )
{
if ( * delay > cl - > laggedpacket - > time - realtime )
* delay = cl - > laggedpacket - > time - realtime ;
break ;
}
else
{
lp = cl - > laggedpacket ;
cl - > laggedpacket = lp - > next ;
if ( cl - > laggedpacket_last = = lp )
cl - > laggedpacket_last = lp - > next ;
2011-05-29 04:26:29 +00:00
2011-06-05 23:53:33 +00:00
lp - > next = svs . free_lagged_packet ;
svs . free_lagged_packet = lp ;
2007-08-30 20:45:01 +00:00
2011-06-05 23:53:33 +00:00
SZ_Clear ( & net_message ) ;
memcpy ( net_message . data , lp - > data , lp - > length ) ;
net_message . cursize = lp - > length ;
2011-05-29 04:26:29 +00:00
2011-06-05 23:53:33 +00:00
net_from = cl - > netchan . remote_address ; //not sure if anything depends on this, but lets not screw them up willynilly
2007-08-30 20:45:01 +00:00
2012-02-12 05:18:31 +00:00
if ( ISNQCLIENT ( cl ) )
{
2014-03-30 08:55:06 +00:00
if ( cl - > state > = cs_connected )
2012-02-12 05:18:31 +00:00
{
if ( NQNetChan_Process ( & cl - > netchan ) )
{
received + + ;
svs . stats . packets + + ;
SVNQ_ExecuteClientMessage ( cl ) ;
}
}
}
else
{
/*QW*/
if ( Netchan_Process ( & cl - > netchan ) )
{ // this is a valid, sequenced packet, so process it
received + + ;
svs . stats . packets + + ;
2014-03-30 08:55:06 +00:00
if ( cl - > state > = cs_connected )
2012-02-12 05:18:31 +00:00
{ //make sure they didn't already disconnect
if ( cl - > send_message )
cl - > chokecount + + ;
else
cl - > send_message = true ; // reply at end of frame
# ifdef Q2SERVER
if ( cl - > protocol = = SCP_QUAKE2 )
SVQ2_ExecuteClientMessage ( cl ) ;
else
# endif
SV_ExecuteClientMessage ( cl ) ;
}
2011-06-05 23:53:33 +00:00
}
2007-08-30 20:45:01 +00:00
}
}
}
}
2004-08-23 00:15:46 +00:00
2009-11-07 13:29:15 +00:00
# ifdef SERVER_DEMO_PLAYBACK
2011-10-27 16:16:29 +00:00
while ( giveup - - > 0 & & SV_GetPacket ( ) )
2009-11-07 13:29:15 +00:00
# else
2011-10-27 16:16:29 +00:00
while ( giveup - - > 0 & & ( cookie = NET_GetPacket ( NS_SERVER , cookie ) ) > = 0 )
2009-11-07 13:29:15 +00:00
# endif
2004-08-23 00:15:46 +00:00
{
// check for connectionless packet (0xffffffff) first
if ( * ( int * ) net_message . data = = - 1 )
{
2014-03-30 08:55:06 +00:00
banreason = SV_BannedReason ( & net_from ) ;
if ( banreason )
{
static unsigned int lt ;
unsigned int ct = Sys_Milliseconds ( ) ;
if ( ct - lt > 5 * 1000 )
{
if ( * banreason )
Netchan_OutOfBandTPrintf ( NS_SERVER , & net_from , svs . language , " You are banned: %s \n " , banreason ) ;
else
Netchan_OutOfBandTPrintf ( NS_SERVER , & net_from , svs . language , " You are banned \n " ) ;
}
continue ;
}
2005-05-26 12:55:34 +00:00
SV_ConnectionlessPacket ( ) ;
2004-08-23 00:15:46 +00:00
continue ;
}
2005-03-07 08:58:26 +00:00
# ifdef Q3SERVER
if ( svs . gametype = = GT_QUAKE3 )
{
2009-11-04 21:16:50 +00:00
received + + ;
2005-03-07 08:58:26 +00:00
SVQ3_HandleClient ( ) ;
continue ;
}
# endif
2004-08-23 00:15:46 +00:00
// read the qport out of the message so we can fix up
// stupid address translating routers
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
MSG_BeginReading ( svs . netprim ) ;
2004-08-23 00:15:46 +00:00
MSG_ReadLong ( ) ; // sequence number
MSG_ReadLong ( ) ; // sequence number
qport = MSG_ReadShort ( ) & 0xffff ;
// check for packets from connected clients
2013-10-29 17:38:22 +00:00
for ( i = 0 , cl = svs . clients ; i < svs . allocated_client_slots ; i + + , cl + + )
2004-08-23 00:15:46 +00:00
{
if ( cl - > state = = cs_free )
continue ;
2013-05-03 04:28:08 +00:00
if ( ! NET_CompareBaseAdr ( & net_from , & cl - > netchan . remote_address ) )
2004-08-23 00:15:46 +00:00
continue ;
2005-05-26 12:55:34 +00:00
# ifdef NQPROT
if ( ISNQCLIENT ( cl ) & & cl - > netchan . remote_address . port = = net_from . port )
{
2014-03-30 08:55:06 +00:00
if ( cl - > state > = cs_connected )
2005-05-26 12:55:34 +00:00
{
2012-02-12 05:18:31 +00:00
if ( cl - > delay > 0 )
goto dominping ;
2005-05-26 12:55:34 +00:00
if ( NQNetChan_Process ( & cl - > netchan ) )
{
2009-11-04 21:16:50 +00:00
received + + ;
2005-05-26 12:55:34 +00:00
svs . stats . packets + + ;
SVNQ_ExecuteClientMessage ( cl ) ;
}
}
break ;
}
# endif
2008-11-09 22:29:28 +00:00
# ifdef Q3SERVER
if ( ISQ3CLIENT ( cl ) )
2012-02-12 05:18:31 +00:00
continue ;
2008-11-09 22:29:28 +00:00
# endif
2004-08-23 00:15:46 +00:00
if ( cl - > netchan . qport ! = qport )
continue ;
if ( cl - > netchan . remote_address . port ! = net_from . port )
{
Con_DPrintf ( " SV_ReadPackets: fixing up a translated port \n " ) ;
cl - > netchan . remote_address . port = net_from . port ;
}
2007-08-30 20:45:01 +00:00
if ( cl - > delay > 0 )
{
2012-02-12 05:18:31 +00:00
dominping :
2014-03-30 08:55:06 +00:00
if ( cl - > state < cs_connected )
2007-08-30 20:45:01 +00:00
break ;
if ( net_message . cursize > sizeof ( svs . free_lagged_packet - > data ) )
{
Con_Printf ( " minping code is screwy \n " ) ;
break ; //drop this packet
}
if ( ! svs . free_lagged_packet ) //kinda nasty
svs . free_lagged_packet = Z_Malloc ( sizeof ( * svs . free_lagged_packet ) ) ;
if ( ! cl - > laggedpacket )
cl - > laggedpacket_last = cl - > laggedpacket = svs . free_lagged_packet ;
else
cl - > laggedpacket_last = cl - > laggedpacket_last - > next = svs . free_lagged_packet ;
cl - > laggedpacket_last - > next = NULL ;
svs . free_lagged_packet = svs . free_lagged_packet - > next ;
cl - > laggedpacket_last - > time = realtime + cl - > delay ;
memcpy ( cl - > laggedpacket_last - > data , net_message . data , net_message . cursize ) ;
cl - > laggedpacket_last - > length = net_message . cursize ;
break ;
}
2011-05-29 04:26:29 +00:00
2007-08-30 20:45:01 +00:00
2004-08-23 00:15:46 +00:00
if ( Netchan_Process ( & cl - > netchan ) )
{ // this is a valid, sequenced packet, so process it
2009-11-04 21:16:50 +00:00
received + + ;
2004-08-23 00:15:46 +00:00
svs . stats . packets + + ;
2014-03-30 08:55:06 +00:00
if ( cl - > state > = cs_connected )
2004-08-23 00:15:46 +00:00
{
2011-04-20 03:34:32 +00:00
if ( cl - > send_message )
cl - > chokecount + + ;
else
cl - > send_message = true ; // reply at end of frame
2004-08-23 00:15:46 +00:00
# ifdef Q2SERVER
2005-05-26 12:55:34 +00:00
if ( cl - > protocol = = SCP_QUAKE2 )
2004-08-23 00:15:46 +00:00
SVQ2_ExecuteClientMessage ( cl ) ;
else
# endif
SV_ExecuteClientMessage ( cl ) ;
}
}
break ;
}
2005-07-03 15:16:20 +00:00
2013-10-29 17:38:22 +00:00
if ( i ! = svs . allocated_client_slots )
2004-08-23 00:15:46 +00:00
continue ;
2005-05-26 12:55:34 +00:00
2012-02-12 05:18:31 +00:00
# ifdef Q3SERVER
if ( sv_listen_q3 . ival & & SVQ3_HandleClient ( ) )
{
received + + ;
continue ;
}
# endif
2005-05-26 12:55:34 +00:00
# ifdef NQPROT
2013-03-31 04:21:08 +00:00
if ( SVNQ_ConnectionlessPacket ( ) )
continue ;
2005-05-26 12:55:34 +00:00
# endif
2014-03-30 08:55:06 +00:00
if ( SV_BannedReason ( & net_from ) )
continue ;
2005-07-03 15:16:20 +00:00
2013-06-23 02:17:02 +00:00
if ( NET_WasSpecialPacket ( NS_SERVER ) )
2013-03-31 04:21:08 +00:00
continue ;
2004-08-23 00:15:46 +00:00
// packet is not from a known client
// Con_Printf ("%s:sequenced packet without connection\n"
// ,NET_AdrToString(net_from));
}
2009-11-04 21:16:50 +00:00
return received ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
SV_CheckTimeouts
If a packet has not been received from a client in timeout . value
seconds , drop the conneciton .
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
= = = = = = = = = = = = = = = = = =
*/
void SV_CheckTimeouts ( void )
{
int i ;
client_t * cl ;
float droptime ;
int nclients ;
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
droptime = realtime - timeout . value ;
nclients = 0 ;
2013-10-29 17:38:22 +00:00
for ( i = 0 , cl = svs . clients ; i < svs . allocated_client_slots ; i + + , cl + + )
2004-08-23 00:15:46 +00:00
{
2014-03-30 08:55:06 +00:00
if ( cl - > state = = cs_connected | | cl - > state = = cs_spawned )
{
2004-08-23 00:15:46 +00:00
if ( ! cl - > spectator )
nclients + + ;
2013-11-29 14:36:47 +00:00
if ( cl - > netchan . last_received < droptime & & cl - > netchan . remote_address . type ! = NA_LOOPBACK & & cl - > protocol ! = SCP_BAD )
{
SV_BroadcastTPrintf ( PRINT_HIGH , " Client %s timed out \n " , cl - > name ) ;
2005-07-03 15:16:20 +00:00
SV_DropClient ( cl ) ;
2012-01-24 04:24:14 +00:00
cl - > state = cs_free ; // don't bother with zombie state for local player.
2004-08-23 00:15:46 +00:00
}
}
2014-03-30 08:55:06 +00:00
if ( cl - > state = = cs_zombie & & realtime - cl - > connection_started > zombietime . value )
2004-08-23 00:15:46 +00:00
cl - > state = cs_free ; // can now be reused
2014-03-30 08:55:06 +00:00
if ( cl - > state = = cs_loadzombie & & realtime - cl - > connection_started > zombietime . value )
{
2004-08-23 00:15:46 +00:00
if ( cl - > istobeloaded )
{
2014-03-30 08:55:06 +00:00
if ( cl - > istobeloaded = = 1 )
{
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , cl - > edict ) ;
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > ClientDisconnect ) ;
if ( * cl - > name )
SV_BroadcastTPrintf ( PRINT_HIGH , " LoadZombie %s timed out \n " , cl - > name ) ;
else
SV_BroadcastTPrintf ( PRINT_HIGH , " LoadZombie timed out \n " , cl - > name ) ;
}
2012-01-17 07:57:46 +00:00
sv . spawned_client_slots - - ;
2004-08-23 00:15:46 +00:00
2012-01-24 04:24:14 +00:00
cl - > istobeloaded = false ;
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
//must go through a zombie phase for 2 secs when the zombie gets removed.
cl - > state = cs_zombie ; // the real zombieness starts now
cl - > connection_started = realtime ;
}
else
{
//no entity, just free them.
cl - > state = cs_free ;
2004-08-23 00:15:46 +00:00
}
2014-03-30 08:55:06 +00:00
cl - > netchan . remote_address . type = NA_INVALID ; //don't mess up from not knowing their address.
2004-08-23 00:15:46 +00:00
}
}
2010-08-18 21:56:46 +00:00
if ( ( sv . paused & 1 ) & & ! nclients )
2009-11-04 21:16:50 +00:00
{
2004-08-23 00:15:46 +00:00
// nobody left, unpause the server
2006-01-21 00:06:49 +00:00
if ( SV_TogglePause ( NULL ) )
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " pause released due to empty server \n " ) ;
2004-08-23 00:15:46 +00:00
}
}
/*
= = = = = = = = = = = = = = = = = = =
SV_GetConsoleCommands
Add them exactly as if they had been typed at the console
= = = = = = = = = = = = = = = = = = =
*/
void SV_GetConsoleCommands ( void )
{
char * cmd ;
while ( 1 )
{
cmd = Sys_ConsoleInput ( ) ;
if ( ! cmd )
break ;
2014-02-07 08:38:40 +00:00
Log_String ( LOG_CONSOLE , cmd ) ;
2004-08-23 00:15:46 +00:00
Cbuf_AddText ( cmd , RESTRICT_LOCAL ) ;
}
}
2011-10-27 16:16:29 +00:00
# define MINDRATE 500
# define MINRATE 500
2004-10-19 16:10:14 +00:00
int SV_RateForClient ( client_t * cl )
{
int rate ;
2011-10-27 16:16:29 +00:00
if ( cl - > download )
2004-10-19 16:10:14 +00:00
{
rate = cl - > drate ;
2011-10-27 16:16:29 +00:00
if ( sv_maxdrate . ival )
{
if ( ! rate | | rate > sv_maxdrate . value )
rate = sv_maxdrate . value ;
else if ( rate < MINDRATE )
rate = MINDRATE ;
}
else if ( rate > = 1 & & rate < MINDRATE )
rate = MINDRATE ;
2004-10-19 16:10:14 +00:00
}
else
{
rate = cl - > rate ;
2011-10-27 16:16:29 +00:00
if ( sv_maxrate . ival )
{
if ( rate > sv_maxrate . value )
rate = sv_maxrate . value ;
else if ( rate < MINRATE )
rate = MINRATE ;
}
else if ( rate > = 1 & & rate < MINRATE )
rate = MINRATE ;
2004-10-19 16:10:14 +00:00
}
return rate ;
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = = =
SV_CheckVars
= = = = = = = = = = = = = = = = = = =
*/
void SV_CheckVars ( void )
{
static char * pw , * spw ;
int v ;
if ( password . string = = pw & & spectator_password . string = = spw )
return ;
pw = password . string ;
spw = spectator_password . string ;
v = 0 ;
if ( pw & & pw [ 0 ] & & strcmp ( pw , " none " ) )
v | = 1 ;
if ( spw & & spw [ 0 ] & & strcmp ( spw , " none " ) )
v | = 2 ;
Con_DPrintf ( " Updated needpass. \n " ) ;
if ( ! v )
Info_SetValueForKey ( svs . info , " needpass " , " " , MAX_SERVERINFO_STRING ) ;
else
Info_SetValueForKey ( svs . info , " needpass " , va ( " %i " , v ) , MAX_SERVERINFO_STRING ) ;
}
# ifdef Q2SERVER
void SVQ2_ClearEvents ( void )
{
q2edict_t * ent ;
int i ;
for ( i = 0 ; i < ge - > num_edicts ; i + + , ent + + )
{
ent = Q2EDICT_NUM ( i ) ;
// events only last for a single message
ent - > s . event = 0 ;
}
}
# endif
/*
= = = = = = = = = = = = = = = = = =
SV_Impulse_f
Spawns a client , uses an impulse , uses that clients think then removes the client .
= = = = = = = = = = = = = = = = = =
*/
void SV_Impulse_f ( void )
{
int i ;
2007-09-03 22:37:13 +00:00
if ( svs . gametype ! = GT_PROGS )
{
Con_Printf ( " Not supported in this game type \n " ) ;
return ;
}
2004-08-23 00:15:46 +00:00
for ( i = 0 ; i < sv . allocated_client_slots ; i + + )
{
if ( svs . clients [ i ] . state = = cs_free )
{
break ;
}
}
if ( i = = sv . allocated_client_slots )
{
Con_Printf ( " No empty player slots \n " ) ;
return ;
}
2005-03-18 06:13:11 +00:00
if ( ! svprogfuncs )
return ;
2004-08-23 00:15:46 +00:00
2009-11-04 21:16:50 +00:00
pr_global_struct - > time = sv . world . physicstime ;
2004-08-23 00:15:46 +00:00
2005-10-04 21:19:00 +00:00
svs . clients [ i ] . state = cs_connected ;
2005-10-07 16:27:40 +00:00
SV_SetUpClientEdict ( & svs . clients [ i ] , svs . clients [ i ] . edict ) ;
2004-10-03 22:52:02 +00:00
2005-03-28 00:11:59 +00:00
svs . clients [ i ] . edict - > v - > netname = PR_SetString ( svprogfuncs , " Console " ) ;
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
sv . skipbprintclient = & svs . clients [ i ] ;
2004-08-23 00:15:46 +00:00
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , svs . clients [ i ] . edict ) ;
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > ClientConnect ) ;
2014-03-30 08:55:06 +00:00
sv . skipbprintclient = NULL ;
2004-08-23 00:15:46 +00:00
2009-11-04 21:16:50 +00:00
pr_global_struct - > time = sv . world . physicstime ;
2005-07-03 15:16:20 +00:00
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , svs . clients [ i ] . edict ) ;
2004-08-23 00:15:46 +00:00
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > PutClientInServer ) ;
2012-01-17 07:57:46 +00:00
sv . spawned_client_slots + + ;
2004-08-23 00:15:46 +00:00
2005-01-04 08:04:42 +00:00
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , svs . clients [ i ] . edict ) ;
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > PlayerPreThink ) ;
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , svs . clients [ i ] . edict ) ;
2005-03-28 00:11:59 +00:00
PR_ExecuteProgram ( svprogfuncs , svs . clients [ i ] . edict - > v - > think ) ;
2005-01-04 08:04:42 +00:00
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , svs . clients [ i ] . edict ) ;
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > PlayerPostThink ) ;
2005-03-28 00:11:59 +00:00
svs . clients [ i ] . edict - > v - > impulse = atoi ( Cmd_Argv ( 1 ) ) ;
2004-08-23 00:15:46 +00:00
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , svs . clients [ i ] . edict ) ;
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > PlayerPreThink ) ;
2004-10-03 22:52:02 +00:00
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , svs . clients [ i ] . edict ) ;
2005-03-28 00:11:59 +00:00
PR_ExecuteProgram ( svprogfuncs , svs . clients [ i ] . edict - > v - > think ) ;
2004-08-23 00:15:46 +00:00
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , svs . clients [ i ] . edict ) ;
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > PlayerPostThink ) ;
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , svs . clients [ i ] . edict ) ;
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > ClientDisconnect ) ;
2012-01-17 07:57:46 +00:00
sv . spawned_client_slots - - ;
2005-10-04 21:19:00 +00:00
svs . clients [ i ] . state = cs_free ;
2004-08-23 00:15:46 +00:00
}
2010-08-16 02:03:02 +00:00
static void SV_PauseChanged ( void )
{
int i ;
client_t * cl ;
// send notification to all clients
2013-10-29 17:38:22 +00:00
for ( i = 0 , cl = svs . clients ; i < svs . allocated_client_slots ; i + + , cl + + )
2010-08-16 02:03:02 +00:00
{
if ( ! cl - > state )
continue ;
if ( ( ISQWCLIENT ( cl ) | | ISNQCLIENT ( cl ) ) & & ! cl - > controller )
{
ClientReliableWrite_Begin ( cl , svc_setpause , 2 ) ;
ClientReliableWrite_Byte ( cl , sv . paused ! = 0 ) ;
}
}
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = =
SV_Frame
= = = = = = = = = = = = = = = = = =
*/
2011-06-05 23:53:33 +00:00
float SV_Frame ( void )
2004-08-23 00:15:46 +00:00
{
2005-07-01 19:23:00 +00:00
extern cvar_t pr_imitatemvdsv ;
2011-01-04 02:56:16 +00:00
static double start , end , idletime ;
2005-08-07 18:08:13 +00:00
float oldtime ;
2009-11-04 21:16:50 +00:00
qboolean isidle ;
2010-08-16 02:03:02 +00:00
static int oldpaused ;
2011-01-04 02:56:16 +00:00
float timedelta ;
2011-06-05 23:53:33 +00:00
float delay ;
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
start = Sys_DoubleTime ( ) ;
svs . stats . idle + = start - end ;
end = start ;
2011-04-20 03:34:32 +00:00
//qw qc uses this for newmis handling
2006-12-26 18:19:35 +00:00
svs . framenum + + ;
2010-10-02 02:25:39 +00:00
if ( svs . framenum > 0x10000 )
svs . framenum = 0 ;
2005-07-03 15:16:20 +00:00
2011-06-05 23:53:33 +00:00
delay = sv_maxtic . value ;
2004-08-23 00:15:46 +00:00
// keep the random time dependent
rand ( ) ;
2005-03-20 02:57:11 +00:00
if ( ! sv . gamespeed )
sv . gamespeed = 1 ;
2010-08-16 02:03:02 +00:00
# ifndef SERVERONLY
2013-10-08 14:28:11 +00:00
isidle = ! isDedicated & & sv . allocated_client_slots = = 1 & & Key_Dest_Has ( ~ kdm_game ) & & cls . state = = ca_active ;
2012-01-17 07:57:46 +00:00
/*server is effectively paused if there are no clients*/
2013-03-12 22:35:33 +00:00
if ( sv . spawned_client_slots = = 0 & & sv . spawned_observer_slots = = 0 & & ( cls . state ! = ca_connected ) )
2012-01-17 07:57:46 +00:00
isidle = true ;
if ( ( sv . paused & 4 ) ! = ( isidle ? 4 : 0 ) )
2010-08-18 21:56:46 +00:00
sv . paused ^ = 4 ;
2010-08-16 02:03:02 +00:00
# endif
if ( oldpaused ! = sv . paused )
{
SV_PauseChanged ( ) ;
oldpaused = sv . paused ;
}
2012-02-27 12:23:15 +00:00
//work out the gamespeed
if ( sv . gamespeed ! = sv_gamespeed . value )
{
char * newspeed ;
sv . gamespeed = sv_gamespeed . value ;
if ( sv . gamespeed < 0.1 | | sv . gamespeed = = 1 )
sv_gamespeed . value = sv . gamespeed = 1 ;
if ( sv . gamespeed = = 1 )
newspeed = " " ;
else
newspeed = va ( " %g " , sv . gamespeed * 100 ) ;
Info_SetValueForStarKey ( svs . info , " *gamespeed " , newspeed , MAX_SERVERINFO_STRING ) ;
SV_SendServerInfoChange ( " *gamespeed " , newspeed ) ;
//correct sv.starttime
sv . starttime = Sys_DoubleTime ( ) - ( sv . time / sv . gamespeed ) ;
}
2004-08-23 00:15:46 +00:00
// decide the simulation time
2005-08-07 18:08:13 +00:00
{
oldtime = sv . time ;
sv . time = ( Sys_DoubleTime ( ) - sv . starttime ) * sv . gamespeed ;
2011-01-04 02:56:16 +00:00
timedelta = sv . time - oldtime ;
2005-08-07 18:08:13 +00:00
if ( sv . time < oldtime )
2011-01-04 02:56:16 +00:00
{
2005-08-07 18:08:13 +00:00
sv . time = oldtime ; //urm
2011-01-04 02:56:16 +00:00
timedelta = 0 ;
}
2005-08-07 18:08:13 +00:00
2012-01-17 07:57:46 +00:00
if ( isDedicated )
realtime + = sv . time - oldtime ;
2010-08-21 22:12:43 +00:00
if ( sv . paused & & sv . time > 1.5 )
2005-08-07 18:08:13 +00:00
{
2012-02-27 12:23:15 +00:00
sv . starttime + = ( sv . time - oldtime ) / sv . gamespeed ; //move the offset
2005-08-07 18:08:13 +00:00
sv . time = oldtime ; //and keep time as it was.
}
2004-08-23 00:15:46 +00:00
}
2005-08-07 18:08:13 +00:00
2010-03-14 14:35:56 +00:00
# ifdef WEBSERVER
2004-08-23 00:15:46 +00:00
IWebRun ( ) ;
# endif
2009-11-04 21:16:50 +00:00
if ( sv_master . ival )
2004-08-23 00:15:46 +00:00
{
2009-11-04 21:16:50 +00:00
if ( sv_masterport . ival )
SVM_Think ( sv_masterport . ival ) ;
2004-08-23 00:15:46 +00:00
else
2011-06-16 02:03:57 +00:00
SVM_Think ( PORT_QWMASTER ) ;
2004-08-23 00:15:46 +00:00
}
2004-12-08 04:14:52 +00:00
{
void SV_MVDStream_Poll ( void ) ;
SV_MVDStream_Poll ( ) ;
}
2013-07-13 12:14:32 +00:00
# ifdef PLUGINS
if ( isDedicated )
Plug_Tick ( ) ;
# endif
2009-11-04 21:16:50 +00:00
if ( sv . state < ss_active | | ! sv . world . worldmodel )
2004-08-23 00:15:46 +00:00
{
2014-03-30 08:55:06 +00:00
# ifdef SUBSERVERS
if ( sv . state = = ss_clustermode )
{
MSV_PollSlaves ( ) ;
isidle = ! SV_ReadPackets ( & delay ) ;
# ifdef SQL
PR_SQLCycle ( ) ;
# endif
SV_SendClientMessages ( ) ;
}
# endif
2004-08-23 00:15:46 +00:00
# ifndef SERVERONLY
// check for commands typed to the host
if ( isDedicated )
# endif
{
SV_GetConsoleCommands ( ) ;
Cbuf_Execute ( ) ;
}
2011-06-05 23:53:33 +00:00
return delay ;
2004-08-23 00:15:46 +00:00
}
// check timeouts
SV_CheckTimeouts ( ) ;
SV_CheckTimer ( ) ;
// toggle the log buffer if full
SV_CheckLog ( ) ;
// get packets
2011-06-05 23:53:33 +00:00
isidle = ! SV_ReadPackets ( & delay ) ;
2004-08-23 00:15:46 +00:00
2009-11-04 21:16:50 +00:00
if ( pr_imitatemvdsv . ival )
2005-07-01 19:23:00 +00:00
{
Cbuf_Execute ( ) ;
if ( sv . state < ss_active ) //whoops...
2011-06-05 23:53:33 +00:00
return delay ;
2005-07-01 19:23:00 +00:00
}
2004-08-23 00:15:46 +00:00
if ( sv . multicast . cursize )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Unterminated multicast \n " ) ;
2004-08-23 00:15:46 +00:00
sv . multicast . cursize = 0 ;
}
// move autonomous things around if enough time has passed
2012-01-17 07:57:46 +00:00
if ( ! sv . paused | | ( sv . world . physicstime < 1 & & sv . spawned_client_slots ) )
2006-01-21 00:06:49 +00:00
{
2009-11-04 21:16:50 +00:00
# ifdef Q2SERVER
//q2 is idle even if clients sent packets.
if ( svs . gametype = = GT_QUAKE2 )
isidle = true ;
# endif
2004-08-23 00:15:46 +00:00
if ( SV_Physics ( ) )
2009-11-04 21:16:50 +00:00
isidle = false ;
2006-01-21 00:06:49 +00:00
}
else
{
2011-04-20 03:34:32 +00:00
isidle = idletime < 0.1 ;
2009-07-14 23:42:54 +00:00
# ifdef VM_Q1
if ( svs . gametype = = GT_Q1QVM )
{
Q1QVM_GameCodePausedTic ( Sys_DoubleTime ( ) - sv . pausedstart ) ;
}
else
# endif
{
PR_GameCodePausedTic ( Sys_DoubleTime ( ) - sv . pausedstart ) ;
}
2006-01-21 00:06:49 +00:00
}
2004-08-23 00:15:46 +00:00
2011-04-20 03:34:32 +00:00
if ( ! isidle | | idletime > 0.15 )
2009-11-04 21:16:50 +00:00
{
2011-04-20 03:34:32 +00:00
//this is the q2 frame number found in the q2 protocol. each packet should contain a new frame or interpolation gets confused
sv . framenum + + ;
2009-11-04 21:16:50 +00:00
2008-04-14 07:47:30 +00:00
# ifdef SQL
2009-11-04 21:16:50 +00:00
PR_SQLCycle ( ) ;
2008-04-14 07:47:30 +00:00
# endif
2009-11-07 13:29:15 +00:00
# ifdef SERVER_DEMO_PLAYBACK
2009-11-04 21:16:50 +00:00
while ( SV_ReadMVD ( ) ) ;
2009-11-07 13:29:15 +00:00
# endif
2004-08-23 00:15:46 +00:00
2009-11-04 21:16:50 +00:00
if ( sv . multicast . cursize )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Unterminated multicast \n " ) ;
2009-11-04 21:16:50 +00:00
sv . multicast . cursize = 0 ;
}
2004-08-23 00:15:46 +00:00
# ifndef SERVERONLY
// check for commands typed to the host
2009-11-04 21:16:50 +00:00
if ( isDedicated )
2004-08-23 00:15:46 +00:00
# endif
2009-11-04 21:16:50 +00:00
{
2013-06-29 16:01:07 +00:00
NET_Tick ( ) ;
2005-12-15 19:15:39 +00:00
2014-03-30 08:55:06 +00:00
if ( sv . framenum ! = 1 )
SV_GetConsoleCommands ( ) ;
2004-08-23 00:15:46 +00:00
// process console commands
2009-11-04 21:16:50 +00:00
if ( ! pr_imitatemvdsv . value )
Cbuf_Execute ( ) ;
}
2005-07-01 19:23:00 +00:00
2009-11-04 21:16:50 +00:00
if ( sv . state < ss_active ) //whoops...
2011-06-05 23:53:33 +00:00
return delay ;
2004-08-23 00:15:46 +00:00
2009-11-04 21:16:50 +00:00
SV_CheckVars ( ) ;
2004-08-23 00:15:46 +00:00
// send messages back to the clients that had packets read this frame
2009-11-04 21:16:50 +00:00
SV_SendClientMessages ( ) ;
2004-08-23 00:15:46 +00:00
// demo_start = Sys_DoubleTime ();
2009-11-04 21:16:50 +00:00
SV_SendMVDMessage ( ) ;
2004-08-23 00:15:46 +00:00
// demo_end = Sys_DoubleTime ();
// svs.stats.demo += demo_end - demo_start;
// send a heartbeat to the master if needed
2009-11-04 21:16:50 +00:00
Master_Heartbeat ( ) ;
2004-08-23 00:15:46 +00:00
# ifdef Q2SERVER
2009-11-04 21:16:50 +00:00
if ( ge & & ge - > edicts )
SVQ2_ClearEvents ( ) ;
2004-08-23 00:15:46 +00:00
# endif
2011-01-04 02:56:16 +00:00
idletime = 0 ;
2009-11-04 21:16:50 +00:00
}
2011-01-04 02:56:16 +00:00
idletime + = timedelta ;
2004-08-23 00:15:46 +00:00
// 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 ;
svs . stats . active = 0 ;
svs . stats . idle = 0 ;
svs . stats . packets = 0 ;
svs . stats . count = 0 ;
}
2011-06-05 23:53:33 +00:00
return delay ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = =
SV_InitLocal
= = = = = = = = = = = = = = =
*/
2005-10-05 02:16:28 +00:00
extern void Log_Init ( void ) ;
2004-08-23 00:15:46 +00:00
void SV_InitLocal ( void )
{
2013-04-13 08:15:18 +00:00
int i ;
2004-08-31 09:05:42 +00:00
extern cvar_t pr_allowbutton1 ;
2011-10-29 19:01:33 +00:00
extern cvar_t sv_aim ;
2004-08-23 00:15:46 +00:00
extern cvar_t pm_bunnyspeedcap ;
extern cvar_t pm_ktjump ;
extern cvar_t pm_slidefix ;
extern cvar_t pm_airstep ;
2005-01-04 08:04:42 +00:00
extern cvar_t pm_walljump ;
2005-05-17 02:36:54 +00:00
extern cvar_t pm_slidyslopes ;
2014-04-06 15:16:39 +00:00
extern cvar_t pm_watersinkspeed ;
2014-06-21 17:58:17 +00:00
extern cvar_t pm_flyfriction ;
2004-08-23 00:15:46 +00:00
SV_InitOperatorCommands ( ) ;
SV_UserInit ( ) ;
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
# ifndef SERVERONLY
if ( isDedicated )
# endif
{
Cvar_Register ( & developer , cvargroup_servercontrol ) ;
Cvar_Register ( & password , cvargroup_servercontrol ) ;
Cvar_Register ( & rcon_password , cvargroup_servercontrol ) ;
2005-10-05 02:16:28 +00:00
Log_Init ( ) ;
2004-08-23 00:15:46 +00:00
}
2005-07-03 15:16:20 +00:00
rcon_password . restriction = RESTRICT_MAX ; //no cheatie rconers changing rcon passwords...
2004-08-23 00:15:46 +00:00
Cvar_Register ( & spectator_password , cvargroup_servercontrol ) ;
Cvar_Register ( & sv_mintic , cvargroup_servercontrol ) ;
Cvar_Register ( & sv_maxtic , cvargroup_servercontrol ) ;
2009-11-15 03:20:17 +00:00
Cvar_Register ( & sv_limittics , cvargroup_servercontrol ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & fraglimit , cvargroup_serverinfo ) ;
Cvar_Register ( & timelimit , cvargroup_serverinfo ) ;
Cvar_Register ( & teamplay , cvargroup_serverinfo ) ;
Cvar_Register ( & coop , cvargroup_serverinfo ) ;
Cvar_Register ( & skill , cvargroup_serverinfo ) ;
Cvar_Register ( & samelevel , cvargroup_serverinfo ) ;
Cvar_Register ( & maxclients , cvargroup_serverinfo ) ;
Cvar_Register ( & maxspectators , cvargroup_serverinfo ) ;
2013-06-23 02:17:02 +00:00
Cvar_Register ( & sv_playerslots , cvargroup_serverinfo ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & hostname , cvargroup_serverinfo ) ;
Cvar_Register ( & deathmatch , cvargroup_serverinfo ) ;
Cvar_Register ( & spawn , cvargroup_servercontrol ) ;
//arguably cheats. Must be switched on to use.
Cvar_Register ( & watervis , cvargroup_serverinfo ) ;
Cvar_Register ( & rearview , cvargroup_serverinfo ) ;
Cvar_Register ( & mirrors , cvargroup_serverinfo ) ;
2005-07-03 15:16:20 +00:00
Cvar_Register ( & allow_skybox , cvargroup_serverinfo ) ;
Cvar_Register ( & sv_allow_splitscreen , cvargroup_serverinfo ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & fbskins , cvargroup_serverinfo ) ;
Cvar_Register ( & timeout , cvargroup_servercontrol ) ;
Cvar_Register ( & zombietime , cvargroup_servercontrol ) ;
2010-08-17 02:44:21 +00:00
Cvar_Register ( & sv_pupglow , cvargroup_serverinfo ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & sv_loadentfiles , cvargroup_servercontrol ) ;
2004-11-17 17:43:07 +00:00
Cvar_Register ( & sv_bigcoords , cvargroup_serverphysics ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & pm_bunnyspeedcap , cvargroup_serverphysics ) ;
2014-04-06 15:16:39 +00:00
Cvar_Register ( & pm_watersinkspeed , cvargroup_serverphysics ) ;
2014-06-21 17:58:17 +00:00
Cvar_Register ( & pm_flyfriction , cvargroup_serverphysics ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & pm_ktjump , cvargroup_serverphysics ) ;
Cvar_Register ( & pm_slidefix , cvargroup_serverphysics ) ;
2005-05-17 02:36:54 +00:00
Cvar_Register ( & pm_slidyslopes , cvargroup_serverphysics ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & pm_airstep , cvargroup_serverphysics ) ;
2005-01-04 08:04:42 +00:00
Cvar_Register ( & pm_walljump , cvargroup_serverphysics ) ;
2004-08-23 00:15:46 +00:00
2007-10-05 18:08:47 +00:00
Cvar_Register ( & sv_compatiblehulls , cvargroup_serverphysics ) ;
2012-11-27 03:23:19 +00:00
Cvar_Register ( & dpcompat_stats , " Darkplaces compatibility " ) ;
2004-08-23 00:15:46 +00:00
for ( i = 0 ; i < sizeof ( sv_motd ) / sizeof ( sv_motd [ 0 ] ) ; i + + )
Cvar_Register ( & sv_motd [ i ] , cvargroup_serverinfo ) ;
Cvar_Register ( & sv_aim , cvargroup_servercontrol ) ;
Cvar_Register ( & sv_resetparms , cvargroup_servercontrol ) ;
2014-03-30 08:55:06 +00:00
Cvar_Register ( & sv_serverip , cvargroup_servercontrol ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & sv_public , cvargroup_servercontrol ) ;
2007-06-10 05:14:38 +00:00
Cvar_Register ( & sv_listen_qw , cvargroup_servercontrol ) ;
Cvar_Register ( & sv_listen_nq , cvargroup_servercontrol ) ;
Cvar_Register ( & sv_listen_dp , cvargroup_servercontrol ) ;
2008-11-09 22:29:28 +00:00
Cvar_Register ( & sv_listen_q3 , cvargroup_servercontrol ) ;
2007-06-10 05:14:38 +00:00
sv_listen_qw . restriction = RESTRICT_MAX ;
2014-04-24 01:53:01 +00:00
Cvar_Register ( & fraglog_public , cvargroup_servercontrol ) ;
2007-06-10 05:14:38 +00:00
2013-03-31 04:21:08 +00:00
SVNET_RegisterCvars ( ) ;
2006-05-09 00:02:05 +00:00
2005-06-09 16:29:32 +00:00
Cvar_Register ( & sv_reportheartbeats , cvargroup_servercontrol ) ;
2004-08-23 00:15:46 +00:00
# ifndef SERVERONLY
if ( isDedicated )
# endif
Cvar_Set ( & sv_public , " 1 " ) ;
2013-10-08 14:28:11 +00:00
Cvar_Register ( & sv_banproxies , " Server Permissions " ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & sv_master , cvargroup_servercontrol ) ;
Cvar_Register ( & sv_masterport , cvargroup_servercontrol ) ;
Cvar_Register ( & filterban , cvargroup_servercontrol ) ;
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
Cvar_Register ( & allow_download , cvargroup_serverpermissions ) ;
Cvar_Register ( & allow_download_skins , cvargroup_serverpermissions ) ;
Cvar_Register ( & allow_download_models , cvargroup_serverpermissions ) ;
Cvar_Register ( & allow_download_sounds , cvargroup_serverpermissions ) ;
Cvar_Register ( & allow_download_maps , cvargroup_serverpermissions ) ;
2004-08-30 05:34:41 +00:00
Cvar_Register ( & allow_download_demos , cvargroup_serverpermissions ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & allow_download_anymap , cvargroup_serverpermissions ) ;
2005-03-24 18:32:44 +00:00
Cvar_Register ( & allow_download_pakcontents , cvargroup_serverpermissions ) ;
2004-09-22 15:27:48 +00:00
Cvar_Register ( & allow_download_textures , cvargroup_serverpermissions ) ;
2005-12-21 03:07:33 +00:00
Cvar_Register ( & allow_download_configs , cvargroup_serverpermissions ) ;
2011-10-27 16:16:29 +00:00
Cvar_Register ( & allow_download_packages , cvargroup_serverpermissions ) ;
2013-06-23 02:17:02 +00:00
Cvar_Register ( & allow_download_refpackages , cvargroup_serverpermissions ) ;
2004-09-22 15:27:48 +00:00
Cvar_Register ( & allow_download_wads , cvargroup_serverpermissions ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & allow_download_root , cvargroup_serverpermissions ) ;
2012-01-17 07:57:46 +00:00
Cvar_Register ( & allow_download_copyrighted , cvargroup_serverpermissions ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & secure , cvargroup_serverpermissions ) ;
Cvar_Register ( & sv_highchars , cvargroup_servercontrol ) ;
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
Cvar_Register ( & sv_calcphs , cvargroup_servercontrol ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & sv_phs , cvargroup_servercontrol ) ;
2007-08-30 18:55:44 +00:00
Cvar_Register ( & sv_cullplayers_trace , cvargroup_servercontrol ) ;
Cvar_Register ( & sv_cullentities_trace , cvargroup_servercontrol ) ;
2004-08-23 00:15:46 +00:00
2012-05-09 15:30:53 +00:00
Cvar_Register ( & sv_csqc_progname , cvargroup_servercontrol ) ;
2005-03-20 02:57:11 +00:00
Cvar_Register ( & sv_csqcdebug , cvargroup_servercontrol ) ;
Cvar_Register ( & sv_gamespeed , cvargroup_serverphysics ) ;
2013-03-12 22:53:23 +00:00
Cvar_Register ( & sv_nqplayerphysics , cvargroup_serverphysics ) ;
2004-08-31 09:05:42 +00:00
Cvar_Register ( & pr_allowbutton1 , cvargroup_servercontrol ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & pausable , cvargroup_servercontrol ) ;
Cvar_Register ( & sv_maxrate , cvargroup_servercontrol ) ;
2004-11-17 17:43:07 +00:00
Cvar_Register ( & sv_maxdrate , cvargroup_servercontrol ) ;
2007-08-30 20:45:01 +00:00
Cvar_Register ( & sv_minping , cvargroup_servercontrol ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & sv_nailhack , cvargroup_servercontrol ) ;
2014-01-13 02:42:25 +00:00
Cvar_Register ( & sv_nopvs , cvargroup_servercontrol ) ;
2013-09-09 01:16:03 +00:00
Cvar_Register ( & pext_ezquake_nochunks , cvargroup_servercontrol ) ;
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " sv_impulse " , SV_Impulse_f ) ;
2014-03-30 08:55:06 +00:00
# ifdef SUBSERVERS
Cmd_AddCommand ( " ssv " , MSV_SubServerCommand_f ) ;
Cmd_AddCommand ( " ssv_all " , MSV_SubServerCommand_f ) ;
Cmd_AddCommand ( " mapcluster " , MSV_MapCluster_f ) ;
# endif
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " openroute " , SV_OpenRoute_f ) ;
2014-03-31 17:06:41 +00:00
Cmd_AddCommand ( " savegame_legacy " , SV_LegacySavegame_f ) ;
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " savegame " , SV_Savegame_f ) ;
Cmd_AddCommand ( " loadgame " , SV_Loadgame_f ) ;
Cmd_AddCommand ( " save " , SV_Savegame_f ) ;
Cmd_AddCommand ( " load " , SV_Loadgame_f ) ;
SV_MVDInit ( ) ;
for ( i = 0 ; i < MAX_MODELS ; i + + )
sprintf ( localmodels [ i ] , " *%i " , i ) ;
2011-03-30 15:17:55 +00:00
Info_SetValueForStarKey ( svs . info , " *version " , version_string ( ) , MAX_SERVERINFO_STRING ) ;
2004-08-23 00:15:46 +00:00
2005-01-16 02:23:31 +00:00
Info_SetValueForStarKey ( svs . info , " *z_ext " , va ( " %i " , SUPPORTED_Z_EXTENSIONS ) , MAX_SERVERINFO_STRING ) ;
2004-08-23 00:15:46 +00:00
// init fraglog stuff
svs . logsequence = 1 ;
svs . logtime = realtime ;
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 ;
2006-05-13 21:11:06 +00:00
2012-02-12 05:18:31 +00:00
svs . free_lagged_packet = NULL ;
2004-08-23 00:15:46 +00:00
}
//============================================================================
2006-05-07 05:31:01 +00:00
void SV_Masterlist_Callback ( struct cvar_s * var , char * oldvalue )
{
int i ;
for ( i = 0 ; sv_masterlist [ i ] . cv . name ; i + + )
{
if ( var = = & sv_masterlist [ i ] . cv )
break ;
}
if ( ! sv_masterlist [ i ] . cv . name )
return ;
2006-05-25 21:32:32 +00:00
if ( ! * var - > string )
2006-05-07 05:31:01 +00:00
{
sv_masterlist [ i ] . adr . port = 0 ;
return ;
}
2009-02-08 19:05:28 +00:00
sv_masterlist [ i ] . needsresolve = true ;
2006-05-07 05:31:01 +00:00
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = =
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 ] ;
int active ;
2005-06-14 04:52:10 +00:00
int i , j ;
2005-05-26 12:55:34 +00:00
qboolean madeqwstring = false ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2005-05-26 12:55:34 +00:00
2011-07-08 19:07:05 +00:00
if ( ! sv_public . ival )
2005-05-26 12:55:34 +00:00
return ;
2004-08-23 00:15:46 +00:00
2009-02-08 19:05:28 +00:00
if ( realtime - HEARTBEAT_SECONDS - svs . last_heartbeat < HEARTBEAT_SECONDS )
2004-08-23 00:15:46 +00:00
return ; // not time to send yet
2009-02-08 19:05:28 +00:00
svs . last_heartbeat = realtime - HEARTBEAT_SECONDS ;
2004-08-23 00:15:46 +00:00
svs . heartbeat_sequence + + ;
// send to group master
2005-05-26 12:55:34 +00:00
for ( i = 0 ; sv_masterlist [ i ] . cv . name ; i + + )
{
2009-02-08 19:05:28 +00:00
if ( sv_masterlist [ i ] . needsresolve )
{
2009-02-21 22:27:51 +00:00
sv_masterlist [ i ] . needsresolve = false ;
2009-02-08 19:05:28 +00:00
if ( ! * sv_masterlist [ i ] . cv . string )
sv_masterlist [ i ] . adr . port = 0 ;
2013-03-12 22:53:23 +00:00
else if ( ! NET_StringToAdr ( sv_masterlist [ i ] . cv . string , 0 , & sv_masterlist [ i ] . adr ) )
2009-02-08 19:05:28 +00:00
{
sv_masterlist [ i ] . adr . port = 0 ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Couldn't resolve master \" %s \" \n " , sv_masterlist [ i ] . cv . string ) ;
2009-02-08 19:05:28 +00:00
}
else
{
2014-03-30 08:55:06 +00:00
if ( sv_masterlist [ i ] . adr . type = = NA_TCP | | sv_masterlist [ i ] . adr . type = = NA_TCPV6 | | sv_masterlist [ i ] . adr . type = = NA_TLSV4 | | sv_masterlist [ i ] . adr . type = = NA_TLSV6 )
2009-07-05 18:45:53 +00:00
NET_EnsureRoute ( svs . sockets , sv_masterlist [ i ] . cv . name , sv_masterlist [ i ] . cv . string , false ) ;
2009-02-08 19:05:28 +00:00
//choose default port
switch ( sv_masterlist [ i ] . protocol )
{
case MP_DARKPLACES :
if ( sv_masterlist [ i ] . adr . port = = 0 )
sv_masterlist [ i ] . adr . port = BigShort ( 27950 ) ;
break ;
case MP_QUAKEWORLD :
if ( sv_masterlist [ i ] . adr . port = = 0 )
sv_masterlist [ i ] . adr . port = BigShort ( 27000 ) ;
//qw does this for some reason, keep the behaviour even though its unreliable thus pointless
string [ 0 ] = A2A_PING ;
string [ 1 ] = 0 ;
if ( sv . state )
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , 2 , string , & sv_masterlist [ i ] . adr ) ;
2009-02-08 19:05:28 +00:00
break ;
default :
break ;
}
}
}
2005-05-26 12:55:34 +00:00
if ( sv_masterlist [ i ] . adr . port )
2004-08-23 00:15:46 +00:00
{
2009-02-08 19:05:28 +00:00
switch ( sv_masterlist [ i ] . protocol )
2005-05-26 12:55:34 +00:00
{
2009-02-08 19:05:28 +00:00
case MP_QUAKEWORLD :
if ( sv_listen_qw . value )
2005-05-26 12:55:34 +00:00
{
2009-02-08 19:05:28 +00:00
if ( ! madeqwstring )
{
// count active users
active = 0 ;
2013-12-02 14:30:30 +00:00
for ( j = 0 ; j < svs . allocated_client_slots ; j + + )
2009-02-08 19:05:28 +00:00
if ( svs . clients [ j ] . state = = cs_connected | |
svs . clients [ j ] . state = = cs_spawned )
active + + ;
2005-05-26 12:55:34 +00:00
2009-02-08 19:05:28 +00:00
sprintf ( string , " %c \n %i \n %i \n " , S2M_HEARTBEAT ,
svs . heartbeat_sequence , active ) ;
2005-05-26 12:55:34 +00:00
2009-02-08 19:05:28 +00:00
madeqwstring = true ;
}
2005-06-09 16:29:32 +00:00
2009-02-08 19:05:28 +00:00
if ( sv_reportheartbeats . value )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Sending heartbeat to %s (%s) \n " , NET_AdrToString ( adr , sizeof ( adr ) , & sv_masterlist [ i ] . adr ) , sv_masterlist [ i ] . cv . string ) ;
2005-06-09 16:29:32 +00:00
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , strlen ( string ) , string , & sv_masterlist [ i ] . adr ) ;
2009-02-08 19:05:28 +00:00
}
2005-05-26 12:55:34 +00:00
break ;
2009-02-08 19:05:28 +00:00
case MP_DARKPLACES :
2012-01-28 10:30:44 +00:00
if ( sv_listen_dp . value | | sv_listen_nq . value ) //set listen to 1 to allow qw connections, 2 to allow nq connections too.
2005-05-26 12:55:34 +00:00
{
2005-06-09 16:29:32 +00:00
if ( sv_reportheartbeats . value )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Sending heartbeat to %s (%s) \n " , NET_AdrToString ( adr , sizeof ( adr ) , & sv_masterlist [ i ] . adr ) , sv_masterlist [ i ] . cv . string ) ;
2005-06-09 16:29:32 +00:00
2005-06-04 04:20:20 +00:00
{
char * str = " \377 \377 \377 \377 heartbeat DarkPlaces \x0A " ;
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , strlen ( str ) , str , & sv_masterlist [ i ] . adr ) ;
2005-06-04 04:20:20 +00:00
}
2005-05-26 12:55:34 +00:00
}
break ;
2009-02-08 19:05:28 +00:00
default :
break ;
2005-05-26 12:55:34 +00:00
}
2004-08-23 00:15:46 +00:00
}
2005-05-26 12:55:34 +00:00
}
}
void Master_Add ( char * stringadr )
{
int i ;
for ( i = 0 ; sv_masterlist [ i ] . cv . name ; i + + )
{
if ( ! * sv_masterlist [ i ] . cv . string )
break ;
}
if ( ! sv_masterlist [ i ] . cv . name )
{
Con_Printf ( " Too many masters \n " ) ;
return ;
}
Cvar_Set ( & sv_masterlist [ i ] . cv , stringadr ) ;
svs . last_heartbeat = - 99999 ;
}
2009-04-01 22:03:56 +00:00
void Master_ReResolve ( void )
{
int i ;
for ( i = 0 ; sv_masterlist [ i ] . cv . name ; i + + )
{
sv_masterlist [ i ] . needsresolve = true ;
}
}
2005-05-26 12:55:34 +00:00
void Master_ClearAll ( void )
{
int i ;
for ( i = 0 ; sv_masterlist [ i ] . cv . name ; i + + )
{
Cvar_Set ( & sv_masterlist [ i ] . cv , " " ) ;
}
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = = =
Master_Shutdown
Informs all masters that this server is going down
= = = = = = = = = = = = = = = = =
*/
void Master_Shutdown ( void )
{
char string [ 2048 ] ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2004-08-23 00:15:46 +00:00
int i ;
2009-04-01 22:03:56 +00:00
//note that if a master server actually blindly listens to this then its exploitable.
//we send it out anyway as for us its all good.
//master servers ought to try and check up on the status of the server first, if they listen to this.
2004-08-23 00:15:46 +00:00
sprintf ( string , " %c \n " , S2M_SHUTDOWN ) ;
// send to group master
2005-05-26 12:55:34 +00:00
for ( i = 0 ; sv_masterlist [ i ] . cv . name ; i + + )
2009-02-08 19:05:28 +00:00
{
2005-05-26 12:55:34 +00:00
if ( sv_masterlist [ i ] . adr . port )
2004-08-23 00:15:46 +00:00
{
2009-02-08 19:05:28 +00:00
switch ( sv_masterlist [ i ] . protocol )
2005-05-26 12:55:34 +00:00
{
2009-02-08 19:05:28 +00:00
case MP_QUAKEWORLD :
2005-06-09 16:29:32 +00:00
if ( sv_reportheartbeats . value )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Sending shutdown to %s \n " , NET_AdrToString ( adr , sizeof ( adr ) , & sv_masterlist [ i ] . adr ) ) ;
2005-06-09 16:29:32 +00:00
2013-05-03 04:28:08 +00:00
NET_SendPacket ( NS_SERVER , strlen ( string ) , string , & sv_masterlist [ i ] . adr ) ;
2005-05-26 12:55:34 +00:00
break ;
2009-02-08 19:05:28 +00:00
//dp has no shutdown
default :
2007-08-07 19:16:32 +00:00
break ;
2005-05-26 12:55:34 +00:00
}
2004-08-23 00:15:46 +00:00
}
2009-02-08 19:05:28 +00:00
}
2004-08-23 00:15:46 +00:00
}
2012-09-30 05:52:03 +00:00
# define iswhite(c) ((c) == ' ' || (unsigned char)(c) == (unsigned char)INVIS_CHAR1 || (unsigned char)(c) == (unsigned char)INVIS_CHAR2 || (unsigned char)(c) == (unsigned char)INVIS_CHAR3)
# define isinvalid(c) ((c) == ':' || (c) == '\r' || (c) == '\n' || (unsigned char)(c) == (unsigned char)0xff)
2009-05-24 10:11:17 +00:00
//colon is so clients can't get confused while parsing chats
//255 is so fuhquake/ezquake don't end up with nameless players
2004-08-23 00:15:46 +00:00
//is allowed to shorten, out must be as long as in and min of "unnamed"+1
2008-08-23 19:17:19 +00:00
void SV_FixupName ( char * in , char * out , unsigned int outlen )
2004-08-23 00:15:46 +00:00
{
char * s , * p ;
2008-08-23 19:17:19 +00:00
unsigned int len ;
2012-10-13 00:56:31 +00:00
conchar_t testbuf [ 1024 ] , * t , * e ;
2008-08-23 19:17:19 +00:00
if ( outlen = = 0 )
return ;
len = outlen ;
2004-08-23 00:15:46 +00:00
s = out ;
2009-05-24 10:11:17 +00:00
while ( iswhite ( * in ) | | isinvalid ( * in ) | | * in = = ' \1 ' | | * in = = ' \2 ' ) //1 and 2 are to stop clients from printing the entire line as chat. only do that for the leading charater.
2004-08-23 00:15:46 +00:00
in + + ;
2008-08-23 19:17:19 +00:00
while ( * in & & len > 0 )
2004-08-23 00:15:46 +00:00
{
if ( isinvalid ( * in ) )
{
in + + ;
continue ;
}
* s + + = * in + + ;
2008-08-23 19:17:19 +00:00
len - - ;
2004-08-23 00:15:46 +00:00
}
* s = ' \0 ' ;
2012-10-13 00:56:31 +00:00
/*note: clients are not guarenteed to parse things the same as the server. utf-8 surrogates may be awkward here*/
e = COM_ParseFunString ( CON_WHITEMASK , out , testbuf , sizeof ( testbuf ) , false ) ;
for ( t = testbuf ; t < e ; t + + )
{
/*reject anything hidden in names*/
if ( * t & CON_HIDDEN )
break ;
/*reject pictograms*/
if ( ( * t & CON_CHARMASK ) > = 0xe100 & & ( * t & CON_CHARMASK ) < 0xe200 )
break ;
/*FIXME: should we try to ensure that the chars are in most fonts? that might annoy speakers of more exotic languages I suppose. cvar it?*/
}
if ( ! * out | | ( t < e ) | | e = = testbuf )
2007-06-20 00:02:54 +00:00
{ //reached end and it was all whitespace
2004-08-23 00:15:46 +00:00
//white space only
2008-08-23 19:17:19 +00:00
strncpy ( out , " unnamed " , outlen ) ;
out [ outlen - 1 ] = 0 ;
2004-08-23 00:15:46 +00:00
p = out ;
}
for ( p = out + strlen ( out ) - 1 ; p ! = out & & iswhite ( * p ) ; p - - )
;
p [ 1 ] = 0 ;
}
2014-03-30 08:55:06 +00:00
qboolean ReloadRanking ( client_t * cl , const char * newname )
2004-08-23 00:15:46 +00:00
{
2005-11-03 23:40:51 +00:00
# ifdef SVRANKING
2004-08-23 00:15:46 +00:00
int newid ;
int j ;
rankstats_t rs ;
2011-09-03 03:49:43 +00:00
newid = Rank_GetPlayerID ( cl - > guid , newname , atoi ( Info_ValueForKey ( cl - > userinfo , " _pwd " ) ) , true , false ) ; //'_' keys are always stripped. On any server. So try and use that so persistant data won't give out the password when connecting to a different server
2004-08-23 00:15:46 +00:00
if ( ! newid )
2011-09-03 03:49:43 +00:00
newid = Rank_GetPlayerID ( cl - > guid , newname , atoi ( Info_ValueForKey ( cl - > userinfo , " password " ) ) , true , false ) ;
2004-08-23 00:15:46 +00:00
if ( newid )
{
if ( cl - > rankid & & cl - > state > = cs_spawned ) //apply current stats
{
if ( ! Rank_GetPlayerStats ( cl - > rankid , & rs ) )
return false ;
rs . timeonserver + = realtime - cl - > stats_started ;
cl - > stats_started = realtime ;
rs . kills + = cl - > kills ;
rs . deaths + = cl - > deaths ;
rs . flags1 & = ~ ( RANK_CUFFED | RANK_MUTED | RANK_CRIPPLED ) ;
if ( cl - > iscuffed = = 2 )
rs . flags1 | = RANK_CUFFED ;
if ( cl - > ismuted = = 2 )
rs . flags1 | = RANK_MUTED ;
if ( cl - > iscrippled = = 2 )
rs . flags1 | = RANK_CRIPPLED ;
cl - > kills = 0 ;
cl - > deaths = 0 ;
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , cl - > edict ) ;
2011-10-27 16:16:29 +00:00
if ( pr_global_ptrs - > SetChangeParms )
2004-08-23 00:15:46 +00:00
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > SetChangeParms ) ;
2009-11-05 03:07:52 +00:00
for ( j = 0 ; j < NUM_RANK_SPAWN_PARMS ; j + + )
2011-10-27 16:16:29 +00:00
if ( pr_global_ptrs - > spawnparamglobals [ j ] )
rs . parm [ j ] = * pr_global_ptrs - > spawnparamglobals [ j ] ;
2004-08-23 00:15:46 +00:00
Rank_SetPlayerStats ( cl - > rankid , & rs ) ;
2011-09-03 03:49:43 +00:00
cl - > rankid = 0 ;
2004-08-23 00:15:46 +00:00
}
if ( ! Rank_GetPlayerStats ( newid , & rs ) )
return false ;
cl - > rankid = newid ;
if ( rs . flags1 & RANK_CUFFED )
cl - > iscuffed = 2 ;
else if ( cl - > iscuffed ) //continue being cuffed, but don't inflict the new user with persistant cuffing.
cl - > iscuffed = 1 ;
if ( rs . flags1 & RANK_MUTED )
cl - > ismuted = 2 ;
else if ( cl - > ismuted )
cl - > ismuted = 1 ;
if ( rs . flags1 & RANK_CRIPPLED )
cl - > iscrippled = 2 ;
else if ( cl - > iscrippled )
cl - > iscrippled = 1 ;
cl - > trustlevel = rs . trustlevel ;
return true ;
}
2005-11-03 23:40:51 +00:00
# endif
2004-08-23 00:15:46 +00:00
return false ;
}
/*
= = = = = = = = = = = = = = = = =
SV_ExtractFromUserinfo
Pull specific info from a newly changed userinfo string
into a more C freindly form .
= = = = = = = = = = = = = = = = =
*/
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
void SV_ExtractFromUserinfo ( client_t * cl , qboolean verbose )
2004-08-23 00:15:46 +00:00
{
char * val , * p ;
int i ;
client_t * client ;
int dupc = 1 ;
2011-10-27 16:16:29 +00:00
char newname [ 80 ] , basic [ 80 ] ;
2012-01-24 04:24:14 +00:00
extern cvar_t rank_filename ;
2004-08-23 00:15:46 +00:00
val = Info_ValueForKey ( cl - > userinfo , " team " ) ;
2005-05-17 02:36:54 +00:00
Q_strncpyz ( cl - > team , val , sizeof ( cl - > teambuf ) ) ;
2004-08-23 00:15:46 +00:00
// name for C code
val = Info_ValueForKey ( cl - > userinfo , " name " ) ;
2007-06-20 00:02:54 +00:00
if ( cl - > protocol ! = SCP_BAD | | * val )
2007-09-08 20:28:59 +00:00
{
2008-08-23 19:17:19 +00:00
SV_FixupName ( val , newname , sizeof ( newname ) ) ;
2007-09-08 20:28:59 +00:00
if ( strlen ( newname ) > 40 )
newname [ 40 ] = 0 ;
}
2007-06-20 00:02:54 +00:00
else
newname [ 0 ] = 0 ;
2004-08-23 00:15:46 +00:00
2011-10-27 16:16:29 +00:00
deleetstring ( basic , newname ) ;
if ( ( ! basic [ 0 ] & & cl - > protocol ! = SCP_BAD ) | | strstr ( basic , " console " ) )
2008-01-08 19:36:30 +00:00
strcpy ( newname , " unnamed " ) ;
2004-08-23 00:15:46 +00:00
// check to see if another user by the same name exists
2013-10-29 17:38:22 +00:00
while ( 1 )
{
for ( i = 0 , client = svs . clients ; i < svs . allocated_client_slots ; i + + , client + + )
{
2006-01-04 00:46:51 +00:00
if ( client - > state < cs_connected | | client = = cl )
2004-08-23 00:15:46 +00:00
continue ;
if ( ! stricmp ( client - > name , newname ) )
break ;
}
2013-10-29 17:38:22 +00:00
if ( i ! = svs . allocated_client_slots )
{ // dup name
2005-05-17 02:36:54 +00:00
if ( strlen ( newname ) > sizeof ( cl - > namebuf ) - 1 )
newname [ sizeof ( cl - > namebuf ) - 4 ] = 0 ;
2004-08-23 00:15:46 +00:00
p = newname ;
if ( newname [ 0 ] = = ' ( ' )
{
if ( newname [ 2 ] = = ' ) ' )
p = newname + 3 ;
else if ( val [ 3 ] = = ' ) ' )
p = newname + 4 ;
}
memmove ( newname + 10 , p , strlen ( p ) + 1 ) ;
sprintf ( newname , " (%d)%-.40s " , dupc + + , newname + 10 ) ;
2013-10-29 17:38:22 +00:00
}
else
2004-08-23 00:15:46 +00:00
break ;
}
2005-07-03 15:16:20 +00:00
2005-05-17 02:36:54 +00:00
if ( strncmp ( newname , cl - > name , sizeof ( cl - > namebuf ) - 1 ) )
2005-07-03 15:16:20 +00:00
{
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( cl - > ismuted & & * cl - > name & & verbose ) //!verbose is a gamecode-forced update, where the gamecode is expected to know what its doing.
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( cl , PRINT_HIGH , " Muted players may not change their names \n " ) ;
2004-08-23 00:15:46 +00:00
else
{
2005-03-07 08:58:26 +00:00
Info_SetValueForKey ( cl - > userinfo , " name " , newname , sizeof ( cl - > userinfo ) ) ;
2006-10-05 22:10:09 +00:00
if ( ! sv . paused & & * cl - > name )
{
if ( ! cl - > lastnametime | | realtime - cl - > lastnametime > 5 )
{
2004-08-23 00:15:46 +00:00
cl - > lastnamecount = 0 ;
cl - > lastnametime = realtime ;
2006-10-05 22:10:09 +00:00
}
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
else if ( cl - > lastnamecount + + > 4 & & verbose )
2006-10-05 22:10:09 +00:00
{
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s was kicked for name spamming \n " , cl - > name ) ;
SV_ClientTPrintf ( cl , PRINT_HIGH , " You were kicked for name spamming \n " ) ;
2005-07-03 15:16:20 +00:00
SV_DropClient ( cl ) ;
2004-08-23 00:15:46 +00:00
return ;
}
}
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( * cl - > name & & cl - > state > = cs_spawned & & ! cl - > spectator & & verbose )
2005-07-03 15:16:20 +00:00
{
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s changed their name to %s \n " , cl - > name , newname ) ;
2004-08-23 00:15:46 +00:00
}
2005-05-17 02:36:54 +00:00
Q_strncpyz ( cl - > name , newname , sizeof ( cl - > namebuf ) ) ;
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
if ( svprogfuncs )
svprogfuncs - > SetStringField ( svprogfuncs , cl - > edict , & cl - > edict - > v - > netname , cl - > name , true ) ;
2004-08-23 00:15:46 +00:00
# ifdef SVRANKING
if ( ReloadRanking ( cl , newname ) )
{
# endif
# ifdef SVRANKING
}
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
else if ( cl - > state > = cs_spawned & & * rank_filename . string & & verbose )
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( cl , PRINT_HIGH , " Your rankings name has not been changed \n " ) ;
2004-08-23 00:15:46 +00:00
# endif
}
}
2005-03-07 08:58:26 +00:00
Info_SetValueForKey ( cl - > userinfo , " name " , newname , sizeof ( cl - > userinfo ) ) ;
2004-08-23 00:15:46 +00:00
val = Info_ValueForKey ( cl - > userinfo , " lang " ) ;
2013-11-29 14:36:47 +00:00
cl - > language = * val ? TL_FindLanguage ( val ) : svs . language ;
2004-08-23 00:15:46 +00:00
val = Info_ValueForKey ( cl - > userinfo , " nogib " ) ;
2013-11-29 14:36:47 +00:00
cl - > gibfilter = ! ! atoi ( val ) ;
2004-08-23 00:15:46 +00:00
// rate command
val = Info_ValueForKey ( cl - > userinfo , " rate " ) ;
if ( strlen ( val ) )
2004-10-19 16:10:14 +00:00
cl - > rate = atoi ( val ) ;
else
2013-11-29 14:36:47 +00:00
cl - > rate = ISNQCLIENT ( cl ) ? 10000 : 2500 ; //an nq client cannot cope with quakeworld's default rate, and typically doesn't have rate set either.
2004-10-19 16:10:14 +00:00
val = Info_ValueForKey ( cl - > userinfo , " drate " ) ;
if ( strlen ( val ) )
cl - > drate = atoi ( val ) ;
else
2011-10-27 16:16:29 +00:00
cl - > drate = cl - > rate ; //0 disables the downloading check
2004-08-23 00:15:46 +00:00
2006-03-23 19:22:12 +00:00
val = Info_ValueForKey ( cl - > userinfo , " cl_playerclass " ) ;
if ( val )
{
2010-05-01 22:47:47 +00:00
PRH2_SetPlayerClass ( cl , atoi ( val ) , false ) ;
2006-03-23 19:22:12 +00:00
}
2004-08-23 00:15:46 +00:00
// msg command
val = Info_ValueForKey ( cl - > userinfo , " msg " ) ;
if ( strlen ( val ) )
{
cl - > messagelevel = atoi ( val ) ;
}
2014-03-30 08:55:06 +00:00
2004-08-23 00:15:46 +00:00
# ifdef NQPROT
{
2005-09-08 22:52:46 +00:00
int top = atoi ( Info_ValueForKey ( cl - > userinfo , " topcolor " ) ) ;
int bottom = atoi ( Info_ValueForKey ( cl - > userinfo , " bottomcolor " ) ) ;
top & = 15 ;
if ( top > 13 )
top = 13 ;
bottom & = 15 ;
if ( bottom > 13 )
bottom = 13 ;
cl - > playercolor = top * 16 + bottom ;
2007-09-02 19:55:17 +00:00
if ( svs . gametype = = GT_PROGS | | svs . gametype = = GT_Q1QVM )
2005-09-08 22:52:46 +00:00
{
2014-03-30 08:55:06 +00:00
if ( cl - > edict )
cl - > edict - > xv - > clientcolors = cl - > playercolor ;
2005-09-08 22:52:46 +00:00
MSG_WriteByte ( & sv . nqreliable_datagram , svc_updatecolors ) ;
MSG_WriteByte ( & sv . nqreliable_datagram , cl - svs . clients ) ;
MSG_WriteByte ( & sv . nqreliable_datagram , cl - > playercolor ) ;
}
2004-08-23 00:15:46 +00:00
}
# endif
}
//============================================================================
/*
= = = = = = = = = = = = = = = = = = = =
SV_InitNet
= = = = = = = = = = = = = = = = = = = =
*/
void SV_InitNet ( void )
{
2005-05-26 12:55:34 +00:00
int i ;
2004-08-23 00:15:46 +00:00
# ifndef SERVERONLY
if ( isDedicated )
# endif
{
Netchan_Init ( ) ;
}
2005-05-26 12:55:34 +00:00
for ( i = 0 ; sv_masterlist [ i ] . cv . name ; i + + )
Cvar_Register ( & sv_masterlist [ i ] . cv , " master servers " ) ;
2011-07-08 19:07:05 +00:00
Master_ReResolve ( ) ;
2005-05-26 12:55:34 +00:00
2005-07-28 15:33:27 +00:00
// heartbeats will always be sent to the id master
2004-08-23 00:15:46 +00:00
svs . last_heartbeat = - 99999 ; // send immediately
// NET_StringToAdr ("192.246.40.70:27000", &idmaster_adr);
}
2008-11-09 22:29:28 +00:00
void SV_IgnoreCommand_f ( void )
{
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = = = =
SV_Init
= = = = = = = = = = = = = = = = = = = =
*/
2009-11-07 13:29:15 +00:00
# ifdef SERVER_DEMO_PLAYBACK
2004-08-23 00:15:46 +00:00
//FIXME: move to header
void SV_Demo_Init ( void ) ;
2009-11-07 13:29:15 +00:00
# endif
2013-06-23 02:17:02 +00:00
void SV_ExecInitialConfigs ( char * defaultexec )
{
if ( COM_FileSize ( " server.cfg " ) ! = - 1 )
Cbuf_InsertText ( " exec server.cfg \n exec ftesrv.cfg \n " , RESTRICT_LOCAL , false ) ;
else
Cbuf_InsertText ( " cl_warncmd 0 \n exec quake.rc \n exec ftesrv.cfg \n cl_warncmd 1 \n " , RESTRICT_LOCAL , false ) ;
// process command line arguments
Cbuf_Execute ( ) ;
}
2004-08-23 00:15:46 +00:00
void SV_Init ( quakeparms_t * parms )
{
if ( isDedicated )
{
COM_InitArgv ( parms - > argc , parms - > argv ) ;
host_parms = * parms ;
2010-07-11 02:22:39 +00:00
Cvar_Init ( ) ;
2013-07-14 12:22:51 +00:00
Memory_Init ( ) ;
2004-08-23 00:15:46 +00:00
2007-06-20 00:02:54 +00:00
Sys_Init ( ) ;
2005-01-16 02:23:31 +00:00
COM_ParsePlusSets ( ) ;
2004-08-23 00:15:46 +00:00
Cbuf_Init ( ) ;
Cmd_Init ( ) ;
# ifndef SERVERONLY
2010-02-06 01:25:04 +00:00
R_SetRenderer ( NULL ) ;
2004-08-23 00:15:46 +00:00
# endif
2013-06-23 02:17:02 +00:00
NET_Init ( ) ;
2004-08-23 00:15:46 +00:00
COM_Init ( ) ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
# ifdef Q2BSPS
CM_Init ( ) ;
# endif
# ifdef TERRAIN
Terr_Init ( ) ;
# endif
2013-10-29 17:38:22 +00:00
Mod_Init ( true ) ;
Mod_Init ( false ) ;
2006-05-09 00:02:05 +00:00
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
PF_Common_RegisterCvars ( ) ;
}
else
{
2012-05-11 01:57:00 +00:00
# if defined(SERVERONLY) || !(defined(CSQC_DAT) || defined(MENU_DAT))
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
PF_Common_RegisterCvars ( ) ;
2012-05-10 19:14:25 +00:00
# endif
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
}
2012-05-10 19:14:25 +00:00
2005-07-03 15:16:20 +00:00
PR_Init ( ) ;
2004-08-23 00:15:46 +00:00
SV_InitNet ( ) ;
SV_InitLocal ( ) ;
2010-03-14 14:35:56 +00:00
# ifdef WEBSERVER
2004-08-23 00:15:46 +00:00
IWebInit ( ) ;
# endif
2005-07-03 15:16:20 +00:00
2009-11-07 13:29:15 +00:00
# ifdef SERVER_DEMO_PLAYBACK
2004-08-23 00:15:46 +00:00
SV_Demo_Init ( ) ;
2009-11-07 13:29:15 +00:00
# endif
2004-08-23 00:15:46 +00:00
2009-11-05 01:22:27 +00:00
# ifdef USEODE
2011-09-03 03:49:43 +00:00
World_ODE_Init ( ) ;
2009-11-05 01:22:27 +00:00
# endif
2004-08-23 00:15:46 +00:00
# ifdef SVRANKING
Rank_RegisterCommands ( ) ;
# endif
2013-12-29 22:48:28 +00:00
Cbuf_AddText ( " alias restart \" map . \" \n alias startmap_sp \" map start \" \n " , RESTRICT_LOCAL ) ;
2004-08-23 00:15:46 +00:00
# ifndef SERVERONLY
if ( isDedicated )
# endif
{
PM_Init ( ) ;
2005-12-15 19:15:39 +00:00
# ifdef PLUGINS
2013-05-03 04:28:08 +00:00
Plug_Initialise ( true ) ;
2005-12-15 19:15:39 +00:00
# endif
2004-08-23 00:15:46 +00:00
host_initialized = true ;
2005-07-03 15:16:20 +00:00
2005-12-15 19:15:39 +00:00
2013-06-23 02:17:02 +00:00
FS_ChangeGame ( NULL , true ) ;
2004-08-23 00:15:46 +00:00
2013-06-23 02:17:02 +00:00
Cmd_StuffCmds ( ) ;
2004-08-23 00:15:46 +00:00
Cbuf_Execute ( ) ;
2005-01-16 02:23:31 +00:00
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Exe: %s %s \n " , __DATE__ , __TIME__ ) ;
2005-03-07 08:58:26 +00:00
2013-06-23 02:17:02 +00:00
Con_Printf ( " %s \n " , version_string ( ) ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " ======== %s Initialized ======== \n " , * fs_gamename . string ? fs_gamename . string : " Nothing " ) ;
2008-11-09 22:29:28 +00:00
2014-03-30 08:55:06 +00:00
# ifdef SUBSERVERS
if ( SSV_IsSubServer ( ) )
{
NET_InitServer ( ) ;
return ;
}
# endif
2013-06-23 02:17:02 +00:00
// if a map wasn't specified on the command line, spawn start.map
//aliases require that we flush the cbuf in order to actually see the results.
2009-04-01 22:03:56 +00:00
if ( sv . state = = ss_dead & & Cmd_AliasExist ( " startmap_dm " , RESTRICT_LOCAL ) )
{
Cbuf_AddText ( " startmap_dm " , RESTRICT_LOCAL ) ; //DP extension
Cbuf_Execute ( ) ;
}
if ( sv . state = = ss_dead & & Cmd_AliasExist ( " startmap_sp " , RESTRICT_LOCAL ) )
2005-07-01 19:23:00 +00:00
{
2009-04-01 22:03:56 +00:00
Cbuf_AddText ( " startmap_sp " , RESTRICT_LOCAL ) ; //DP extension
Cbuf_Execute ( ) ;
2005-07-01 19:23:00 +00:00
}
2011-05-29 04:26:29 +00:00
if ( sv . state = = ss_dead & & COM_FCheckExists ( " maps/start.bsp " ) )
2009-04-01 22:03:56 +00:00
Cmd_ExecuteString ( " map start " , RESTRICT_LOCAL ) ; //regular q1
2011-05-29 04:26:29 +00:00
if ( sv . state = = ss_dead & & COM_FCheckExists ( " maps/demo1.bsp " ) )
2009-04-01 22:03:56 +00:00
Cmd_ExecuteString ( " map demo1 " , RESTRICT_LOCAL ) ; //regular h2 sp
2013-06-23 02:17:02 +00:00
# ifdef Q2SERVER
2011-05-29 04:26:29 +00:00
if ( sv . state = = ss_dead & & COM_FCheckExists ( " maps/base1.bsp " ) )
2009-04-01 22:03:56 +00:00
Cmd_ExecuteString ( " map base1 " , RESTRICT_LOCAL ) ; //regular q2 sp
2013-06-23 02:17:02 +00:00
# endif
# ifdef Q3SERVER
2011-05-29 04:26:29 +00:00
if ( sv . state = = ss_dead & & COM_FCheckExists ( " maps/q3dm1.bsp " ) )
2009-04-01 22:03:56 +00:00
Cmd_ExecuteString ( " map q3dm1 " , RESTRICT_LOCAL ) ; //regular q3 'sp'
2013-06-23 02:17:02 +00:00
# endif
# ifdef HLSERVER
2009-04-01 22:03:56 +00:00
if ( sv . state = = ss_dead & & COM_FCheckExists ( " maps/c0a0.bsp " ) )
Cmd_ExecuteString ( " map c0a0 " , RESTRICT_LOCAL ) ; //regular hl sp
2013-06-23 02:17:02 +00:00
# endif
2009-04-01 22:03:56 +00:00
2004-08-23 00:15:46 +00:00
if ( sv . state = = ss_dead )
2013-06-23 02:17:02 +00:00
SV_Error ( " Couldn't load a map " ) ;
2004-08-23 00:15:46 +00:00
}
}
2004-11-29 01:21:00 +00:00
# endif
2010-02-06 01:25:04 +00:00