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-06-15 04:45:26 +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 .
*/
// cl_main.c -- client main loop
2005-08-03 23:14:59 +00:00
# include <ctype.h>
2004-08-23 00:15:46 +00:00
# include "quakedef.h"
# include "winquake.h"
2005-04-18 03:21:16 +00:00
# include <sys/types.h>
2005-12-02 01:14:20 +00:00
# include "netinc.h"
2006-02-11 14:51:36 +00:00
# include "cl_master.h"
# include "cl_ignore.h"
2004-08-23 00:15:46 +00:00
2006-04-15 06:57:13 +00:00
// callbacks
void CL_Sbar_Callback ( struct cvar_s * var , char * oldvalue ) ;
2006-05-06 02:53:36 +00:00
void Name_Callback ( struct cvar_s * var , char * oldvalue ) ;
2006-04-15 06:57:13 +00:00
2004-08-23 00:15:46 +00:00
// we need to declare some mouse variables here, because the menu system
// references them even when on a unix system.
qboolean noclip_anglehack ; // remnant from old quake
2006-06-12 22:05:41 +00:00
cvar_t rcon_password = SCVARF ( " rcon_password " , " " , CVAR_NOUNSAFEEXPAND ) ;
2004-08-23 00:15:46 +00:00
2006-06-12 22:05:41 +00:00
cvar_t rcon_address = SCVARF ( " rcon_address " , " " , CVAR_NOUNSAFEEXPAND ) ;
2004-08-23 00:15:46 +00:00
2006-02-11 02:09:43 +00:00
cvar_t cl_timeout = SCVAR ( " cl_timeout " , " 60 " ) ;
2004-08-23 00:15:46 +00:00
2006-02-11 02:09:43 +00:00
cvar_t cl_shownet = SCVAR ( " cl_shownet " , " 0 " ) ; // can be 0, 1, or 2
2004-08-23 00:15:46 +00:00
2006-04-15 06:57:13 +00:00
cvar_t cl_sbar = SCVARFC ( " cl_sbar " , " 0 " , CVAR_ARCHIVE , CL_Sbar_Callback ) ;
2006-02-11 02:09:43 +00:00
cvar_t cl_hudswap = SCVARF ( " cl_hudswap " , " 0 " , CVAR_ARCHIVE ) ;
cvar_t cl_maxfps = SCVARF ( " cl_maxfps " , " 1000 " , CVAR_ARCHIVE ) ;
cvar_t cl_nopext = SCVARF ( " cl_nopext " , " 0 " , CVAR_ARCHIVE ) ;
cvar_t cl_nolerp = SCVAR ( " cl_nolerp " , " 1 " ) ;
cvar_t hud_tracking_show = SCVAR ( " hud_tracking_show " , " 1 " ) ;
2004-08-23 00:15:46 +00:00
2006-02-11 02:09:43 +00:00
cvar_t cfg_save_name = SCVARF ( " cfg_save_name " , " fte " , CVAR_ARCHIVE ) ;
2004-08-23 00:15:46 +00:00
2006-02-11 02:09:43 +00:00
cvar_t cl_splitscreen = SCVAR ( " cl_splitscreen " , " 0 " ) ;
2004-08-23 00:15:46 +00:00
2006-02-11 02:09:43 +00:00
cvar_t lookspring = SCVARF ( " lookspring " , " 0 " , CVAR_ARCHIVE ) ;
cvar_t lookstrafe = SCVARF ( " lookstrafe " , " 0 " , CVAR_ARCHIVE ) ;
cvar_t sensitivity = SCVARF ( " sensitivity " , " 10 " , CVAR_ARCHIVE ) ;
2004-08-23 00:15:46 +00:00
2006-02-11 02:09:43 +00:00
cvar_t cl_staticsounds = SCVAR ( " cl_staticsounds " , " 1 " ) ;
2005-01-13 16:29:20 +00:00
2006-02-11 02:09:43 +00:00
cvar_t m_pitch = SCVARF ( " m_pitch " , " 0.022 " , CVAR_ARCHIVE ) ;
cvar_t m_yaw = SCVAR ( " m_yaw " , " 0.022 " ) ;
cvar_t m_forward = SCVAR ( " m_forward " , " 1 " ) ;
cvar_t m_side = SCVAR ( " m_side " , " 0.8 " ) ;
2004-08-23 00:15:46 +00:00
2006-02-11 02:09:43 +00:00
cvar_t entlatency = SCVAR ( " entlatency " , " 20 " ) ;
cvar_t cl_predict_players = SCVAR ( " cl_predict_players " , " 1 " ) ;
cvar_t cl_predict_players2 = SCVAR ( " cl_predict_players2 " , " 1 " ) ;
cvar_t cl_solid_players = SCVAR ( " cl_solid_players " , " 1 " ) ;
cvar_t cl_noblink = SCVAR ( " cl_noblink " , " 0 " ) ;
2007-02-23 00:21:33 +00:00
cvar_t cl_servername = SCVAR ( " cl_servername " , " none " ) ;
2004-08-23 00:15:46 +00:00
2006-04-21 06:02:06 +00:00
cvar_t cl_demospeed = FCVAR ( " cl_demospeed " , " demo_setspeed " , " 1 " , 0 ) ;
2004-12-24 08:45:56 +00:00
2005-03-12 23:40:42 +00:00
2006-02-11 02:09:43 +00:00
cvar_t cl_indepphysics = SCVAR ( " cl_indepphysics " , " 0 " ) ;
2005-03-12 23:40:42 +00:00
2006-02-11 02:09:43 +00:00
cvar_t localid = SCVAR ( " localid " , " " ) ;
2004-08-23 00:15:46 +00:00
2006-02-11 02:09:43 +00:00
cvar_t cl_antibunch = SCVAR ( " cl_antibunch " , " 0 " ) ;
2005-10-01 03:09:17 +00:00
2006-03-05 04:46:10 +00:00
cvar_t r_drawflame = SCVAR ( " r_drawflame " , " 1 " ) ;
2004-08-23 00:15:46 +00:00
static qboolean allowremotecmd = true ;
2006-05-07 20:57:30 +00:00
extern int total_loading_size , current_loading_size , loading_stage ;
2004-08-23 00:15:46 +00:00
//
// info mirrors
//
2006-06-12 22:05:41 +00:00
cvar_t password = SCVARF ( " password " , " " , CVAR_USERINFO | CVAR_NOUNSAFEEXPAND ) ; //this is parhaps slightly dodgy...
2006-02-11 02:09:43 +00:00
cvar_t spectator = SCVARF ( " spectator " , " " , CVAR_USERINFO ) ;
2006-05-06 02:53:36 +00:00
cvar_t name = SCVARFC ( " name " , " unnamed " , CVAR_ARCHIVE | CVAR_USERINFO , Name_Callback ) ;
2006-02-11 02:09:43 +00:00
cvar_t team = SCVARF ( " team " , " " , CVAR_ARCHIVE | CVAR_USERINFO ) ;
cvar_t skin = SCVARF ( " skin " , " " , CVAR_ARCHIVE | CVAR_USERINFO ) ;
cvar_t model = SCVARF ( " model " , " " , CVAR_ARCHIVE | CVAR_USERINFO ) ;
cvar_t topcolor = SCVARF ( " topcolor " , " " , CVAR_ARCHIVE | CVAR_USERINFO ) ;
cvar_t bottomcolor = SCVARF ( " bottomcolor " , " " , CVAR_ARCHIVE | CVAR_USERINFO ) ;
cvar_t rate = SCVARF ( " rate " , " 2500 " , CVAR_ARCHIVE | CVAR_USERINFO ) ;
cvar_t drate = SCVARF ( " drate " , " 100000 " , CVAR_ARCHIVE | CVAR_USERINFO ) ; // :)
cvar_t noaim = SCVARF ( " noaim " , " " , CVAR_ARCHIVE | CVAR_USERINFO ) ;
cvar_t msg = SCVARF ( " msg " , " 1 " , CVAR_ARCHIVE | CVAR_USERINFO ) ;
2007-09-21 11:15:12 +00:00
cvar_t b_switch = SCVARF ( " b_switch " , " " , CVAR_ARCHIVE | CVAR_USERINFO ) ;
cvar_t w_switch = SCVARF ( " w_switch " , " " , CVAR_ARCHIVE | CVAR_USERINFO ) ;
2006-02-11 02:09:43 +00:00
cvar_t cl_nofake = SCVAR ( " cl_nofake " , " 2 " ) ;
cvar_t cl_chatsound = SCVAR ( " cl_chatsound " , " 1 " ) ;
2007-09-21 11:15:12 +00:00
cvar_t cl_enemychatsound = SCVAR ( " cl_enemychatsound " , " misc/talk.wav " ) ;
cvar_t cl_teamchatsound = SCVAR ( " cl_teamchatsound " , " misc/talk.wav " ) ;
2006-02-11 02:09:43 +00:00
2006-04-21 05:23:51 +00:00
cvar_t r_rocketlight = SCVARC ( " r_rocketlight " , " 1 " , Cvar_Limiter_ZeroToOne_Callback ) ;
2006-02-11 02:09:43 +00:00
cvar_t r_lightflicker = SCVAR ( " r_lightflicker " , " 1 " ) ;
cvar_t cl_r2g = SCVAR ( " cl_r2g " , " 0 " ) ;
cvar_t r_powerupglow = SCVAR ( " r_powerupglow " , " 1 " ) ;
cvar_t v_powerupshell = SCVAR ( " v_powerupshell " , " 0 " ) ;
cvar_t cl_gibfilter = SCVAR ( " cl_gibfilter " , " 0 " ) ;
cvar_t cl_deadbodyfilter = SCVAR ( " cl_deadbodyfilter " , " 0 " ) ;
2006-05-17 23:01:06 +00:00
cvar_t cl_gunx = SCVAR ( " cl_gunx " , " 0 " ) ;
cvar_t cl_guny = SCVAR ( " cl_guny " , " 0 " ) ;
cvar_t cl_gunz = SCVAR ( " cl_gunz " , " 0 " ) ;
2006-05-17 23:16:26 +00:00
cvar_t cl_gunanglex = SCVAR ( " cl_gunanglex " , " 0 " ) ;
cvar_t cl_gunangley = SCVAR ( " cl_gunangley " , " 0 " ) ;
cvar_t cl_gunanglez = SCVAR ( " cl_gunanglez " , " 0 " ) ;
2006-02-11 02:09:43 +00:00
cvar_t allow_download_csprogs = SCVAR ( " allow_download_csprogs " , " 0 " ) ;
cvar_t cl_muzzleflash = SCVAR ( " cl_muzzleflash " , " 1 " ) ;
cvar_t cl_item_bobbing = SCVAR ( " cl_model_bobbing " , " 0 " ) ;
2006-04-02 23:52:05 +00:00
cvar_t cl_countpendingpl = SCVAR ( " cl_countpendingpl " , " 0 " ) ;
2006-02-11 02:09:43 +00:00
cvar_t requiredownloads = SCVARF ( " requiredownloads " , " 1 " , CVAR_ARCHIVE ) ;
2006-03-06 01:41:09 +00:00
cvar_t cl_standardchat = SCVARF ( " cl_standardchat " , " 0 " , CVAR_ARCHIVE ) ;
2006-02-11 02:09:43 +00:00
cvar_t msg_filter = SCVAR ( " msg_filter " , " 0 " ) ; //0 for neither, 1 for mm1, 2 for mm2, 3 for both
2006-03-06 01:41:09 +00:00
cvar_t cl_standardmsg = SCVARF ( " cl_standardmsg " , " 0 " , CVAR_ARCHIVE ) ;
2006-04-03 03:29:17 +00:00
cvar_t cl_parsewhitetext = SCVAR ( " cl_parsewhitetext " , " 1 " ) ;
2006-02-11 02:09:43 +00:00
2006-08-02 05:34:17 +00:00
cvar_t cl_dlemptyterminate = SCVAR ( " cl_dlemptyterminate " , " 1 " ) ;
2007-02-23 00:21:33 +00:00
cvar_t host_mapname = FCVAR ( " mapname " , " host_mapname " , " " , 0 ) ;
2004-08-23 00:15:46 +00:00
2007-09-21 11:15:12 +00:00
cvar_t ruleset_allow_playercount = SCVAR ( " ruleset_allow_playercount " , " 1 " ) ;
cvar_t ruleset_allow_frj = SCVAR ( " ruleset_allow_frj " , " 1 " ) ;
cvar_t ruleset_allow_semicheats = SCVAR ( " ruleset_allow_semicheats " , " 1 " ) ;
cvar_t ruleset_allow_packet = SCVAR ( " ruleset_allow_packet " , " 1 " ) ;
cvar_t ruleset_allow_particle_lightning = SCVAR ( " ruleset_allow_particle_lightning " , " 1 " ) ;
cvar_t ruleset_allow_overlongsounds = SCVAR ( " ruleset_allow_overlong_sounds " , " 1 " ) ;
cvar_t ruleset_allow_larger_models = SCVAR ( " ruleset_allow_larger_models " , " 1 " ) ;
2007-08-23 21:25:18 +00:00
2004-08-23 00:15:46 +00:00
extern cvar_t cl_hightrack ;
char cl_screengroup [ ] = " Screen options " ;
char cl_controlgroup [ ] = " client operation options " ;
char cl_inputgroup [ ] = " client input controls " ;
char cl_predictiongroup [ ] = " Client side prediction " ;
client_static_t cls ;
client_state_t cl ;
2005-09-09 02:01:30 +00:00
// alot of this should probably be dynamically allocated
2006-07-24 04:24:41 +00:00
entity_state_t * cl_baselines ;
2004-08-23 00:15:46 +00:00
efrag_t cl_efrags [ MAX_EFRAGS ] ;
entity_t cl_static_entities [ MAX_STATIC_ENTITIES ] ;
2005-09-09 02:01:30 +00:00
trailstate_t * cl_static_emit [ MAX_STATIC_ENTITIES ] ;
2004-08-23 00:15:46 +00:00
lightstyle_t cl_lightstyle [ MAX_LIGHTSTYLES ] ;
//lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
dlight_t cl_dlights [ MAX_DLIGHTS ] ;
2006-07-24 04:24:41 +00:00
int cl_baselines_count ;
2006-05-11 03:14:41 +00:00
int dlights_running , dlights_software ;
2004-08-23 00:15:46 +00:00
// refresh list
// this is double buffered so the last frame
// can be scanned for oldorigins of trailing objects
int cl_numvisedicts , cl_oldnumvisedicts ;
entity_t * cl_visedicts , * cl_oldvisedicts ;
entity_t cl_visedicts_list [ 2 ] [ MAX_VISEDICTS ] ;
double connect_time = - 1 ; // for connection retransmits
int connect_type = 0 ;
2005-05-26 12:55:34 +00:00
int connect_tries = 0 ; //increased each try, every fourth trys nq connect packets.
2004-08-23 00:15:46 +00:00
quakeparms_t host_parms ;
qboolean host_initialized ; // true if into command execution
qboolean nomaster ;
double host_frametime ;
double realtime ; // without any filtering or bounding
double oldrealtime ; // last frame run
int host_framecount ;
int host_hunklevel ;
qbyte * host_basepal ;
qbyte * host_colormap ;
2006-02-11 02:09:43 +00:00
cvar_t host_speeds = SCVAR ( " host_speeds " , " 0 " ) ; // set for running times
2004-10-10 06:32:29 +00:00
# ifdef CRAZYDEBUGGING
2006-02-11 02:09:43 +00:00
cvar_t developer = SCVAR ( " developer " , " 1 " ) ;
2004-10-10 06:32:29 +00:00
# else
2006-02-11 02:09:43 +00:00
cvar_t developer = SCVAR ( " developer " , " 0 " ) ;
2004-10-10 06:32:29 +00:00
# endif
2004-08-23 00:15:46 +00:00
int fps_count ;
jmp_buf host_abort ;
void Master_Connect_f ( void ) ;
float server_version = 0 ; // version of server we connected to
2005-06-15 04:45:26 +00:00
char emodel_name [ ] =
2004-08-23 00:15:46 +00:00
{ ' e ' ^ 0xff , ' m ' ^ 0xff , ' o ' ^ 0xff , ' d ' ^ 0xff , ' e ' ^ 0xff , ' l ' ^ 0xff , 0 } ;
2005-06-15 04:45:26 +00:00
char pmodel_name [ ] =
2004-08-23 00:15:46 +00:00
{ ' p ' ^ 0xff , ' m ' ^ 0xff , ' o ' ^ 0xff , ' d ' ^ 0xff , ' e ' ^ 0xff , ' l ' ^ 0xff , 0 } ;
2005-06-15 04:45:26 +00:00
char prespawn_name [ ] =
2004-08-23 00:15:46 +00:00
{ ' p ' ^ 0xff , ' r ' ^ 0xff , ' e ' ^ 0xff , ' s ' ^ 0xff , ' p ' ^ 0xff , ' a ' ^ 0xff , ' w ' ^ 0xff , ' n ' ^ 0xff ,
' ' ^ 0xff , ' % ' ^ 0xff , ' i ' ^ 0xff , ' ' ^ 0xff , ' 0 ' ^ 0xff , ' ' ^ 0xff , ' % ' ^ 0xff , ' i ' ^ 0xff , 0 } ;
2005-06-15 04:45:26 +00:00
char modellist_name [ ] =
{ ' m ' ^ 0xff , ' o ' ^ 0xff , ' d ' ^ 0xff , ' e ' ^ 0xff , ' l ' ^ 0xff , ' l ' ^ 0xff , ' i ' ^ 0xff , ' s ' ^ 0xff , ' t ' ^ 0xff ,
2004-08-23 00:15:46 +00:00
' ' ^ 0xff , ' % ' ^ 0xff , ' i ' ^ 0xff , ' ' ^ 0xff , ' % ' ^ 0xff , ' i ' ^ 0xff , 0 } ;
2005-06-15 04:45:26 +00:00
char soundlist_name [ ] =
{ ' s ' ^ 0xff , ' o ' ^ 0xff , ' u ' ^ 0xff , ' n ' ^ 0xff , ' d ' ^ 0xff , ' l ' ^ 0xff , ' i ' ^ 0xff , ' s ' ^ 0xff , ' t ' ^ 0xff ,
2004-08-23 00:15:46 +00:00
' ' ^ 0xff , ' % ' ^ 0xff , ' i ' ^ 0xff , ' ' ^ 0xff , ' % ' ^ 0xff , ' i ' ^ 0xff , 0 } ;
2005-07-14 01:57:34 +00:00
void CL_MakeActive ( char * gamename )
{
cls . state = ca_active ;
if ( VID_SetWindowCaption )
VID_SetWindowCaption ( va ( " FTE %s: %s " , gamename , cls . servername ) ) ;
SCR_EndLoadingPlaque ( ) ;
TP_ExecTrigger ( " f_spawn " ) ;
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = =
CL_Quit_f
= = = = = = = = = = = = = = = = = =
*/
void CL_Quit_f ( void )
{
2006-04-02 23:25:03 +00:00
2005-07-14 01:57:34 +00:00
TP_ExecTrigger ( " f_quit " ) ;
Cbuf_Execute ( ) ;
2004-11-29 01:21:00 +00:00
# ifndef CLIENTONLY
2004-08-23 00:15:46 +00:00
if ( ! isDedicated )
2004-11-29 01:21:00 +00:00
# endif
2004-08-23 00:15:46 +00:00
{
M_Menu_Quit_f ( ) ;
return ;
}
CL_Disconnect ( ) ;
Sys_Quit ( ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = =
CL_Version_f
= = = = = = = = = = = = = = = = = = = = = =
*/
void CL_Version_f ( void )
{
2005-10-04 21:08:06 +00:00
Con_TPrintf ( TLC_VERSIONST , DISTRIBUTION , build_number ( ) ) ;
2004-08-23 00:15:46 +00:00
Con_TPrintf ( TL_EXEDATETIME , __DATE__ , __TIME__ ) ;
}
2004-11-20 01:12:02 +00:00
void CL_ConnectToDarkPlaces ( char * challenge , netadr_t adr )
{
char data [ 2048 ] ;
cls . fteprotocolextensions = 0 ;
cls . resendinfo = false ;
connect_time = realtime ; // for retransmit requests
sprintf ( data , " %c%c%c%cconnect \\ protocol \\ darkplaces 3 \\ challenge \\ %s " , 255 , 255 , 255 , 255 , challenge ) ;
NET_SendPacket ( NS_CLIENT , strlen ( data ) , data , adr ) ;
cl . splitclients = 0 ;
}
2004-08-23 00:15:46 +00:00
# ifdef PROTOCOL_VERSION_FTE
2005-11-30 01:20:53 +00:00
unsigned int CL_SupportedFTEExtensions ( void )
2005-06-15 04:45:26 +00:00
{
2005-11-30 01:20:53 +00:00
unsigned int fteprotextsupported = 0 ;
2004-08-23 00:15:46 +00:00
# ifdef PEXT_SCALE //dmw - protocol extensions
fteprotextsupported | = PEXT_SCALE ;
# endif
# ifdef PEXT_LIGHTSTYLECOL
fteprotextsupported | = PEXT_LIGHTSTYLECOL ;
# endif
# ifdef PEXT_TRANS
fteprotextsupported | = PEXT_TRANS ;
# endif
2005-06-15 04:45:26 +00:00
# ifdef PEXT_VIEW2
2004-08-23 00:15:46 +00:00
fteprotextsupported | = PEXT_VIEW2 ;
# endif
# ifdef PEXT_BULLETENS
fteprotextsupported | = PEXT_BULLETENS ;
# endif
2005-11-30 01:20:53 +00:00
# ifdef PEXT_ACCURATETIMINGS
fteprotextsupported | = PEXT_ACCURATETIMINGS ;
# endif
2004-08-23 00:15:46 +00:00
# ifdef PEXT_ZLIBDL
fteprotextsupported | = PEXT_ZLIBDL ;
# endif
# ifdef PEXT_LIGHTUPDATES
fteprotextsupported | = PEXT_LIGHTUPDATES ;
# endif
# ifdef PEXT_FATNESS
fteprotextsupported | = PEXT_FATNESS ;
# endif
# ifdef PEXT_HLBSP
fteprotextsupported | = PEXT_HLBSP ;
# endif
# ifdef PEXT_Q2BSP
fteprotextsupported | = PEXT_Q2BSP ;
# endif
# ifdef PEXT_Q3BSP
fteprotextsupported | = PEXT_Q3BSP ;
# endif
# ifdef PEXT_TE_BULLET
fteprotextsupported | = PEXT_TE_BULLET ;
# endif
# ifdef PEXT_HULLSIZE
fteprotextsupported | = PEXT_HULLSIZE ;
# endif
# ifdef PEXT_SETVIEW
fteprotextsupported | = PEXT_SETVIEW ;
# endif
# ifdef PEXT_MODELDBL
fteprotextsupported | = PEXT_MODELDBL ;
# endif
# ifdef PEXT_VWEAP
fteprotextsupported | = PEXT_VWEAP ;
# endif
2004-11-17 17:56:27 +00:00
# ifdef PEXT_FLOATCOORDS
fteprotextsupported | = PEXT_FLOATCOORDS ;
2004-08-23 00:15:46 +00:00
# endif
fteprotextsupported | = PEXT_SPAWNSTATIC2 ;
2006-02-27 00:42:25 +00:00
fteprotextsupported | = PEXT_COLOURMOD ;
2004-08-23 00:15:46 +00:00
fteprotextsupported | = PEXT_SPLITSCREEN ;
fteprotextsupported | = PEXT_HEXEN2 ;
fteprotextsupported | = PEXT_CUSTOMTEMPEFFECTS ;
fteprotextsupported | = PEXT_256PACKETENTITIES ;
2005-10-20 00:07:48 +00:00
fteprotextsupported | = PEXT_ENTITYDBL ;
fteprotextsupported | = PEXT_ENTITYDBL2 ;
2004-09-01 00:01:08 +00:00
// fteprotextsupported |= PEXT_64PLAYERS;
fteprotextsupported | = PEXT_SHOWPIC ;
2004-10-10 06:32:29 +00:00
fteprotextsupported | = PEXT_SETATTACHMENT ;
2005-01-16 02:25:35 +00:00
# ifdef PEXT_CHUNKEDDOWNLOADS
fteprotextsupported | = PEXT_CHUNKEDDOWNLOADS ;
# endif
2005-02-28 07:16:19 +00:00
# ifdef PEXT_CSQC
fteprotextsupported | = PEXT_CSQC ;
# endif
2005-08-07 18:08:13 +00:00
# ifdef PEXT_DPFLAGS
fteprotextsupported | = PEXT_DPFLAGS ;
# endif
2004-08-23 00:15:46 +00:00
2005-11-30 01:20:53 +00:00
return fteprotextsupported ;
}
# endif
/*
= = = = = = = = = = = = = = = = = = = = = = =
CL_SendConnectPacket
called by CL_Connect_f and CL_CheckResend
= = = = = = = = = = = = = = = = = = = = = =
*/
void CL_SendConnectPacket (
# ifdef PROTOCOL_VERSION_FTE
int ftepext ,
# endif
int compressioncrc
/*, ...*/ ) //dmw new parms
{
netadr_t adr ;
char data [ 2048 ] ;
char playerinfo2 [ MAX_INFO_STRING ] ;
double t1 , t2 ;
# ifdef PROTOCOL_VERSION_FTE
int fteprotextsupported = 0 ;
# endif
int clients ;
int c ;
// JACK: Fixed bug where DNS lookups would cause two connects real fast
// Now, adds lookup time to the connect time.
// Should I add it to realtime instead?!?!
if ( cls . state ! = ca_disconnected )
return ;
if ( cl_nopext . value ) //imagine it's an unenhanced server
{
ftepext = 0 ;
compressioncrc = 0 ;
}
# ifdef PROTOCOL_VERSION_FTE
fteprotextsupported = CL_SupportedFTEExtensions ( ) ;
2004-08-23 00:15:46 +00:00
fteprotextsupported & = ftepext ;
2005-04-16 16:21:27 +00:00
# ifdef Q2CLIENT
2005-11-30 01:20:53 +00:00
if ( cls . protocol ! = CP_QUAKEWORLD )
2005-03-18 06:14:07 +00:00
fteprotextsupported = 0 ;
2005-04-16 16:21:27 +00:00
# endif
2005-03-18 06:14:07 +00:00
2004-08-23 00:15:46 +00:00
cls . fteprotocolextensions = fteprotextsupported ;
# endif
t1 = Sys_DoubleTime ( ) ;
2005-05-26 12:55:34 +00:00
if ( ! NET_StringToAdr ( cls . servername , & adr ) )
2004-08-23 00:15:46 +00:00
{
Con_TPrintf ( TLC_BADSERVERADDRESS ) ;
connect_time = - 1 ;
return ;
}
if ( ! NET_IsClientLegal ( & adr ) )
{
Con_TPrintf ( TLC_ILLEGALSERVERADDRESS ) ;
connect_time = - 1 ;
return ;
}
if ( adr . port = = 0 )
adr . port = BigShort ( 27500 ) ;
t2 = Sys_DoubleTime ( ) ;
cls . resendinfo = false ;
connect_time = realtime + t2 - t1 ; // for retransmit requests
cls . qport = Cvar_VariableValue ( " qport " ) ;
// Info_SetValueForStarKey (cls.userinfo, "*ip", NET_AdrToString(adr), MAX_INFO_STRING);
Q_strncpyz ( playerinfo2 , cls . userinfo , sizeof ( playerinfo2 ) - 1 ) ;
Info_SetValueForStarKey ( playerinfo2 , " name " , " Second player " , MAX_INFO_STRING ) ;
clients = 1 ;
2005-07-01 19:23:00 +00:00
if ( cl_splitscreen . value & & ( fteprotextsupported & PEXT_SPLITSCREEN ) )
2004-08-23 00:15:46 +00:00
{
2005-06-29 21:20:34 +00:00
// if (adr.type == NA_LOOPBACK)
2004-08-23 00:15:46 +00:00
clients = cl_splitscreen . value + 1 ;
2005-06-29 21:20:34 +00:00
// else
// Con_Printf("Split screens are still under development\n");
2004-08-23 00:15:46 +00:00
}
if ( clients < 1 )
clients = 1 ;
if ( clients > MAX_SPLITS )
clients = MAX_SPLITS ;
# ifdef Q2CLIENT
2005-05-26 12:55:34 +00:00
if ( cls . protocol = = CP_QUAKE2 ) //sorry - too lazy.
2004-08-23 00:15:46 +00:00
clients = 1 ;
# endif
2004-12-24 08:45:56 +00:00
# ifdef Q3CLIENT
2005-06-04 04:20:20 +00:00
if ( cls . protocol = = CP_QUAKE3 )
2004-12-24 08:45:56 +00:00
{ //q3 requires some very strange things.
CLQ3_SendConnectPacket ( adr ) ;
return ;
}
# endif
2004-08-23 00:15:46 +00:00
sprintf ( data , " %c%c%c%cconnect " , 255 , 255 , 255 , 255 ) ;
2004-12-24 08:45:56 +00:00
2004-08-23 00:15:46 +00:00
if ( clients > 1 ) //splitscreen 'connect' command specifies the number of userinfos sent.
2007-08-30 02:15:25 +00:00
Q_strncatz ( data , va ( " %i " , clients ) , sizeof ( data ) ) ;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
# ifdef Q2CLIENT
2005-05-26 12:55:34 +00:00
if ( cls . protocol = = CP_QUAKE2 )
2007-08-30 02:15:25 +00:00
Q_strncatz ( data , va ( " %i " , PROTOCOL_VERSION_Q2 ) , sizeof ( data ) ) ;
2004-08-23 00:15:46 +00:00
else
# endif
2007-08-30 02:15:25 +00:00
Q_strncatz ( data , va ( " %i " , PROTOCOL_VERSION ) , sizeof ( data ) ) ;
2004-08-23 00:15:46 +00:00
2007-08-30 02:15:25 +00:00
Q_strncatz ( data , va ( " %i %i " , cls . qport , cls . challenge ) , sizeof ( data ) ) ;
2004-08-23 00:15:46 +00:00
//userinfo 0 + zquake extension info.
2007-08-30 02:15:25 +00:00
Q_strncatz ( data , va ( " \" %s \\ *z_ext \\ %i \" " , cls . userinfo , SUPPORTED_Z_EXTENSIONS ) , sizeof ( data ) ) ;
2004-08-23 00:15:46 +00:00
for ( c = 1 ; c < clients ; c + + )
{
Info_SetValueForStarKey ( playerinfo2 , " name " , va ( " %s%i " , name . string , c + 1 ) , MAX_INFO_STRING ) ;
2007-08-30 02:15:25 +00:00
Q_strncatz ( data , va ( " \" %s \" " , playerinfo2 , SUPPORTED_Z_EXTENSIONS ) , sizeof ( data ) ) ;
2004-08-23 00:15:46 +00:00
}
2007-08-30 02:15:25 +00:00
Q_strncatz ( data , " \n " , sizeof ( data ) ) ;
2004-08-23 00:15:46 +00:00
# ifdef PROTOCOL_VERSION_FTE
if ( ftepext )
2007-08-30 02:15:25 +00:00
Q_strncatz ( data , va ( " 0x%x 0x%x \n " , PROTOCOL_VERSION_FTE , fteprotextsupported ) , sizeof ( data ) ) ;
2004-08-23 00:15:46 +00:00
# endif
# ifdef HUFFNETWORK
if ( compressioncrc & & Huff_CompressionCRC ( compressioncrc ) )
{
2007-08-30 02:15:25 +00:00
Q_strncatz ( data , va ( " 0x%x 0x%x \n " , PROTOCOL_VERSION_HUFFMAN , LittleLong ( compressioncrc ) ) , sizeof ( data ) ) ;
2004-08-23 00:15:46 +00:00
cls . netchan . compress = true ;
}
else
# endif
cls . netchan . compress = false ;
2005-05-26 12:55:34 +00:00
NET_SendPacket ( NS_CLIENT , strlen ( data ) , data , adr ) ;
2004-08-23 00:15:46 +00:00
cl . splitclients = 0 ;
2005-05-13 10:42:48 +00:00
CL_RegisterSplitCommands ( ) ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = = =
CL_CheckForResend
Resend a connect message if the last one has timed out
= = = = = = = = = = = = = = = = =
*/
void CL_CheckForResend ( void )
{
netadr_t adr ;
char data [ 2048 ] ;
double t1 , t2 ;
# ifndef CLIENTONLY
if ( ! cls . state & & sv . state )
{
Q_strncpyz ( cls . servername , " internalserver " , sizeof ( cls . servername ) ) ;
2007-02-23 00:21:33 +00:00
Cvar_ForceSet ( & cl_servername , cls . servername ) ;
2004-08-23 00:15:46 +00:00
cls . state = ca_disconnected ;
2005-03-12 23:40:42 +00:00
switch ( svs . gametype )
{
# ifdef Q3CLIENT
case GT_QUAKE3 :
2005-06-04 04:20:20 +00:00
cls . protocol = CP_QUAKE3 ;
2005-03-12 23:40:42 +00:00
break ;
# endif
2004-08-23 00:15:46 +00:00
# ifdef Q2CLIENT
2005-03-12 23:40:42 +00:00
case GT_QUAKE2 :
2005-05-26 12:55:34 +00:00
cls . protocol = CP_QUAKE2 ;
2005-03-12 23:40:42 +00:00
break ;
2004-08-23 00:15:46 +00:00
# endif
2005-03-12 23:40:42 +00:00
default :
2005-05-26 12:55:34 +00:00
cls . protocol = CP_QUAKEWORLD ;
2005-03-12 23:40:42 +00:00
break ;
}
2005-05-26 12:55:34 +00:00
2005-10-16 03:50:39 +00:00
CL_FlushClientCommands ( ) ; //clear away all client->server clientcommands.
2004-08-23 00:15:46 +00:00
CL_SendConnectPacket ( svs . fteprotocolextensions , false ) ;
return ;
}
# endif
if ( connect_time = = - 1 )
return ;
if ( cls . state ! = ca_disconnected )
return ;
2005-05-26 12:55:34 +00:00
/*
2004-08-23 00:15:46 +00:00
# ifdef NQPROT
if ( connect_type )
{
if ( ! connect_time | | ! ( realtime - connect_time < 5.0 ) )
{
connect_time = realtime ;
NQ_BeginConnect ( cls . servername ) ;
NQ_ContinueConnect ( cls . servername ) ;
}
else
NQ_ContinueConnect ( cls . servername ) ;
return ;
}
# endif
2005-05-26 12:55:34 +00:00
*/
2004-08-23 00:15:46 +00:00
if ( connect_time & & realtime - connect_time < 5.0 )
return ;
t1 = Sys_DoubleTime ( ) ;
if ( ! NET_StringToAdr ( cls . servername , & adr ) )
{
Con_TPrintf ( TLC_BADSERVERADDRESS ) ;
connect_time = - 1 ;
return ;
}
if ( ! NET_IsClientLegal ( & adr ) )
{
Con_TPrintf ( TLC_ILLEGALSERVERADDRESS ) ;
connect_time = - 1 ;
return ;
}
if ( adr . port = = 0 )
2006-01-21 00:06:49 +00:00
{
if ( connect_type )
adr . port = BigShort ( 26000 ) ; //assume a different port for nq
else
adr . port = BigShort ( 27500 ) ;
}
2004-08-23 00:15:46 +00:00
t2 = Sys_DoubleTime ( ) ;
connect_time = realtime + t2 - t1 ; // for retransmit requests
2007-02-23 00:21:33 +00:00
Cvar_ForceSet ( & cl_servername , cls . servername ) ;
2005-08-26 22:56:51 +00:00
# ifdef Q3CLIENT
//Q3 clients send thier cdkey to the q3 authorize server.
//they send this packet with the challenge.
//and the server will refuse the client if it hasn't sent it.
CLQ3_SendAuthPacket ( adr ) ;
# endif
2004-08-23 00:15:46 +00:00
# ifdef NQPROT
2005-05-26 12:55:34 +00:00
if ( connect_type | | ( ( connect_tries & 3 ) = = 3 ) )
2004-08-23 00:15:46 +00:00
{
2005-05-26 12:55:34 +00:00
sizebuf_t sb ;
memset ( & sb , 0 , sizeof ( sb ) ) ;
sb . data = data ;
sb . maxsize = sizeof ( data ) ;
Con_TPrintf ( TLC_CONNECTINGTO , cls . servername ) ;
2005-07-29 22:26:43 +00:00
MSG_WriteLong ( & sb , LongSwap ( NETFLAG_CTL | ( strlen ( NET_GAMENAME_NQ ) + 7 ) ) ) ;
2005-05-26 12:55:34 +00:00
MSG_WriteByte ( & sb , CCREQ_CONNECT ) ;
MSG_WriteString ( & sb , NET_GAMENAME_NQ ) ;
MSG_WriteByte ( & sb , NET_PROTOCOL_VERSION ) ;
NET_SendPacket ( NS_CLIENT , sb . cursize , sb . data , adr ) ;
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
# endif
2005-05-26 12:55:34 +00:00
{
Con_TPrintf ( TLC_CONNECTINGTO , cls . servername ) ;
sprintf ( data , " %c%c%c%cgetchallenge \n " , 255 , 255 , 255 , 255 ) ;
NET_SendPacket ( NS_CLIENT , strlen ( data ) , data , adr ) ;
}
connect_tries + + ;
}
void CL_BeginServerConnect ( void )
{
2004-08-23 00:15:46 +00:00
connect_time = 0 ;
2005-05-26 12:55:34 +00:00
connect_type = 0 ;
connect_tries = 0 ;
2004-08-23 00:15:46 +00:00
CL_CheckForResend ( ) ;
}
# ifdef NQPROT
void CLNQ_BeginServerConnect ( void )
{
connect_time = 0 ;
2005-05-26 12:55:34 +00:00
connect_type = 1 ;
connect_tries = 0 ;
2004-08-23 00:15:46 +00:00
CL_CheckForResend ( ) ;
}
# endif
void CL_BeginServerReconnect ( void )
{
2004-11-29 01:21:00 +00:00
# ifndef CLIENTONLY
2004-08-23 00:15:46 +00:00
if ( isDedicated )
{
Con_TPrintf ( TLC_DEDICATEDCANNOTCONNECT ) ;
return ;
}
2005-06-04 04:20:20 +00:00
# endif
2005-06-15 04:45:26 +00:00
connect_time = 0 ;
2004-08-23 00:15:46 +00:00
CL_CheckForResend ( ) ;
}
/*
= = = = = = = = = = = = = = = =
CL_Connect_f
= = = = = = = = = = = = = = = =
*/
void CL_Connect_f ( void )
{
char * server ;
if ( Cmd_Argc ( ) ! = 2 )
{
Con_TPrintf ( TLC_SYNTAX_CONNECT ) ;
2005-06-15 04:45:26 +00:00
return ;
2004-08-23 00:15:46 +00:00
}
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
server = Cmd_Argv ( 1 ) ;
CL_Disconnect_f ( ) ;
Q_strncpyz ( cls . servername , server , sizeof ( cls . servername ) ) ;
CL_BeginServerConnect ( ) ;
}
2005-01-13 23:33:00 +00:00
void CL_Join_f ( void )
{
char * server ;
if ( Cmd_Argc ( ) ! = 2 )
{
if ( cls . state )
{ //Hmm. This server sucks.
if ( cls . z_ext & Z_EXT_JOIN_OBSERVE )
Cmd_ForwardToServer ( ) ;
else
Cbuf_AddText ( " \n spectator 0;reconnect \n " , RESTRICT_LOCAL ) ;
return ;
}
Con_Printf ( " join requires a connection or servername/ip \n " ) ;
2005-06-15 04:45:26 +00:00
return ;
2005-01-13 23:33:00 +00:00
}
2005-06-15 04:45:26 +00:00
2005-01-13 23:33:00 +00:00
server = Cmd_Argv ( 1 ) ;
CL_Disconnect_f ( ) ;
Cvar_Set ( & spectator , " 0 " ) ;
Q_strncpyz ( cls . servername , server , sizeof ( cls . servername ) ) ;
CL_BeginServerConnect ( ) ;
}
void CL_Observe_f ( void )
{
char * server ;
if ( Cmd_Argc ( ) ! = 2 )
{
if ( cls . state )
{ //Hmm. This server sucks.
if ( cls . z_ext & Z_EXT_JOIN_OBSERVE )
Cmd_ForwardToServer ( ) ;
else
Cbuf_AddText ( " \n spectator 1;reconnect \n " , RESTRICT_LOCAL ) ;
return ;
}
Con_Printf ( " observe requires a connection or servername/ip \n " ) ;
2005-06-15 04:45:26 +00:00
return ;
2005-01-13 23:33:00 +00:00
}
2005-06-15 04:45:26 +00:00
2005-01-13 23:33:00 +00:00
server = Cmd_Argv ( 1 ) ;
CL_Disconnect_f ( ) ;
Cvar_Set ( & spectator , " 1 " ) ;
Q_strncpyz ( cls . servername , server , sizeof ( cls . servername ) ) ;
CL_BeginServerConnect ( ) ;
}
2004-08-23 00:15:46 +00:00
# ifdef NQPROT
void CLNQ_Connect_f ( void )
{
char * server ;
if ( Cmd_Argc ( ) ! = 2 )
{
Con_TPrintf ( TLC_SYNTAX_CONNECT ) ;
2005-06-15 04:45:26 +00:00
return ;
2004-08-23 00:15:46 +00:00
}
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
server = Cmd_Argv ( 1 ) ;
CL_Disconnect_f ( ) ;
Q_strncpyz ( cls . servername , server , sizeof ( cls . servername ) ) ;
2005-06-15 04:45:26 +00:00
CLNQ_BeginServerConnect ( ) ;
2004-08-23 00:15:46 +00:00
}
# endif
2005-11-30 01:20:53 +00:00
# ifdef TCPCONNECT
void CL_TCPConnect_f ( void )
{
char buffer [ 6 ] ;
int newsocket ;
int len ;
int _true = true ;
float giveuptime ;
char * server ;
if ( Cmd_Argc ( ) ! = 2 )
{
Con_TPrintf ( TLC_SYNTAX_CONNECT ) ;
return ;
}
server = Cmd_Argv ( 1 ) ;
CL_Disconnect_f ( ) ;
Q_strncpyz ( cls . servername , server , sizeof ( cls . servername ) ) ;
NET_StringToAdr ( cls . servername , & cls . sockettcpdest ) ;
if ( cls . sockettcp ! = INVALID_SOCKET )
closesocket ( cls . sockettcp ) ;
cls . sockettcp = INVALID_SOCKET ;
cls . tcpinlen = 0 ;
newsocket = TCP_OpenStream ( cls . sockettcpdest ) ;
if ( newsocket = = INVALID_SOCKET )
{
//failed
Con_Printf ( " Failed to connect, server is either down, firewalled, or on a different port \n " ) ;
return ;
}
Con_Printf ( " Waiting for confirmation of server (10 secs) \n " ) ;
giveuptime = Sys_DoubleTime ( ) + 10 ;
while ( giveuptime > Sys_DoubleTime ( ) )
{
len = recv ( newsocket , buffer , sizeof ( buffer ) , 0 ) ;
if ( ! strncmp ( buffer , " qizmo \n " , 6 ) )
{
cls . sockettcp = newsocket ;
break ;
}
SCR_UpdateScreen ( ) ;
}
if ( cls . sockettcp = = INVALID_SOCKET )
{
Con_Printf ( " Timeout - wrong server type \n " ) ;
closesocket ( newsocket ) ;
return ;
}
Con_Printf ( " Confirmed \n " ) ;
send ( cls . sockettcp , buffer , sizeof ( buffer ) , 0 ) ;
setsockopt ( cls . sockettcp , IPPROTO_TCP , TCP_NODELAY , ( char * ) & _true , sizeof ( _true ) ) ;
CL_BeginServerConnect ( ) ;
}
# endif
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = = = = =
CL_Rcon_f
Send the rest of the command line over as
an unconnected command .
= = = = = = = = = = = = = = = = = = = = =
*/
void CL_Rcon_f ( void )
{
char message [ 1024 ] ;
2007-08-22 16:52:13 +00:00
char * password ;
2004-08-23 00:15:46 +00:00
int i ;
netadr_t to ;
2007-08-22 16:52:13 +00:00
i = 1 ;
password = rcon_password . string ;
if ( ! * password ) //FIXME: this is strange...
2004-08-23 00:15:46 +00:00
{
2007-08-21 17:16:52 +00:00
if ( Cmd_Argc ( ) < 3 )
{
2007-08-22 16:52:13 +00:00
Con_TPrintf ( TLC_NORCONPASSWORD ) ;
2007-08-21 17:16:52 +00:00
Con_Printf ( " usage: rcon (password) <command> \n " ) ;
return ;
}
2007-08-22 16:52:13 +00:00
password = Cmd_Argv ( 1 ) ;
2007-08-21 17:16:52 +00:00
i = 2 ;
}
else
{
if ( Cmd_Argc ( ) < 2 )
{
2007-08-22 16:52:13 +00:00
Con_Printf ( " usage: rcon <command> \n " ) ;
2007-08-21 17:16:52 +00:00
return ;
}
2004-08-23 00:15:46 +00:00
}
message [ 0 ] = 255 ;
message [ 1 ] = 255 ;
message [ 2 ] = 255 ;
message [ 3 ] = 255 ;
message [ 4 ] = 0 ;
2007-08-21 17:16:52 +00:00
Q_strncatz ( message , " rcon " , sizeof ( message ) ) ;
Q_strncatz ( message , password , sizeof ( message ) ) ;
Q_strncatz ( message , " " , sizeof ( message ) ) ;
2004-08-23 00:15:46 +00:00
2007-08-21 17:16:52 +00:00
for ( ; i < Cmd_Argc ( ) ; i + + )
2004-08-23 00:15:46 +00:00
{
2007-08-21 17:16:52 +00:00
Q_strncatz ( message , Cmd_Argv ( i ) , sizeof ( message ) ) ;
Q_strncatz ( message , " " , sizeof ( message ) ) ;
2004-08-23 00:15:46 +00:00
}
if ( cls . state > = ca_connected )
to = cls . netchan . remote_address ;
else
{
if ( ! strlen ( rcon_address . string ) )
{
Con_TPrintf ( TLC_NORCONDEST ) ;
return ;
}
NET_StringToAdr ( rcon_address . string , & to ) ;
}
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
NET_SendPacket ( NS_CLIENT , strlen ( message ) + 1 , message
, to ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = =
CL_ClearState
= = = = = = = = = = = = = = = = = = = = =
*/
void CL_ClearState ( void )
{
int i ;
# ifndef CLIENTONLY
# define serverrunning (sv.state != ss_dead)
# define tolocalserver NET_IsLoopBackAddress(cls.netchan.remote_address)
# else
# define serverrunning false
# define tolocalserver false
# define SV_UnspawnServer()
# endif
2005-02-28 07:16:19 +00:00
CL_AllowIndependantSendCmd ( false ) ; //model stuff could be a problem.
2004-08-23 00:15:46 +00:00
S_StopAllSounds ( true ) ;
2006-10-05 22:11:17 +00:00
S_ResetFailedLoad ( ) ;
2004-08-23 00:15:46 +00:00
Cvar_ApplyLatches ( CVAR_SERVEROVERRIDE ) ;
2005-06-15 04:45:26 +00:00
Con_DPrintf ( " Clearing memory \n " ) ;
2004-08-23 00:15:46 +00:00
# ifdef PEXT_BULLETENS
WipeBulletenTextures ( ) ;
# endif
if ( ! serverrunning | | ! tolocalserver )
{
if ( serverrunning )
SV_UnspawnServer ( ) ;
D_FlushCaches ( ) ;
Mod_ClearAll ( ) ;
2005-06-15 04:45:26 +00:00
if ( host_hunklevel ) // FIXME: check this...
2004-08-23 00:15:46 +00:00
Hunk_FreeToLowMark ( host_hunklevel ) ;
Cvar_ApplyLatches ( CVAR_LATCH ) ;
}
CL_ClearTEnts ( ) ;
CL_ClearCustomTEnts ( ) ;
2004-09-01 00:01:08 +00:00
SCR_ShowPic_Clear ( ) ;
2004-08-23 00:15:46 +00:00
if ( cl . playernum [ 0 ] = = - 1 )
{ //left over from q2 connect.
Media_PlayFilm ( " " ) ;
}
2005-10-01 03:09:17 +00:00
for ( i = 0 ; i < UPDATE_BACKUP ; i + + )
{
if ( cl . frames [ i ] . packet_entities . entities )
Z_Free ( cl . frames [ i ] . packet_entities . entities ) ;
}
2005-08-26 22:56:51 +00:00
if ( cl . lerpents )
BZ_Free ( cl . lerpents ) ;
2006-01-13 06:27:18 +00:00
{
downloadlist_t * next ;
while ( cl . downloadlist )
{
next = cl . downloadlist - > next ;
Z_Free ( cl . downloadlist ) ;
cl . downloadlist = next ;
}
while ( cl . faileddownloads )
{
next = cl . faileddownloads - > next ;
Z_Free ( cl . faileddownloads ) ;
cl . faileddownloads = next ;
}
}
2004-08-23 00:15:46 +00:00
// wipe the entire cl structure
memset ( & cl , 0 , sizeof ( cl ) ) ;
SZ_Clear ( & cls . netchan . message ) ;
2006-01-28 19:04:13 +00:00
r_worldentity . model = NULL ;
2005-06-15 04:45:26 +00:00
// clear other arrays
2004-08-23 00:15:46 +00:00
memset ( cl_efrags , 0 , sizeof ( cl_efrags ) ) ;
2006-05-11 03:14:41 +00:00
// memset (cl_dlights, 0, sizeof(cl_dlights));
2004-08-23 00:15:46 +00:00
memset ( cl_lightstyle , 0 , sizeof ( cl_lightstyle ) ) ;
2006-05-11 03:14:41 +00:00
dlights_running = 0 ;
2006-07-24 04:24:41 +00:00
if ( cl_baselines )
2005-07-01 19:23:00 +00:00
{
2006-07-24 04:24:41 +00:00
BZ_Free ( cl_baselines ) ;
cl_baselines = NULL ;
2005-07-01 19:23:00 +00:00
}
2006-07-24 04:24:41 +00:00
cl_baselines_count = 0 ;
2005-07-01 19:23:00 +00:00
2004-08-23 00:15:46 +00:00
//
// allocate the efrags and chain together into a free list
//
cl . free_efrags = cl_efrags ;
for ( i = 0 ; i < MAX_EFRAGS - 1 ; i + + )
cl . free_efrags [ i ] . entnext = & cl . free_efrags [ i + 1 ] ;
cl . free_efrags [ i ] . entnext = NULL ;
for ( i = 0 ; i < MAX_SPLITS ; i + + )
cl . viewheight [ i ] = DEFAULT_VIEWHEIGHT ;
cl . minpitch = - 70 ;
cl . maxpitch = 80 ;
2005-05-26 12:55:34 +00:00
cl . oldgametime = 0 ;
cl . gametime = 0 ;
cl . gametimemark = 0 ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = =
CL_Disconnect
Sends a disconnect message to the server
This is also called on Host_Error , so it shouldn ' t cause any errors
= = = = = = = = = = = = = = = = = = = = =
*/
void CL_Disconnect ( void )
{
2006-03-12 04:33:22 +00:00
qbyte final [ 12 ] ;
2004-08-23 00:15:46 +00:00
connect_time = - 1 ;
2006-11-03 15:53:04 +00:00
connect_tries = 0 ;
2004-08-23 00:15:46 +00:00
Cvar_ApplyLatches ( CVAR_SERVEROVERRIDE ) ;
2004-12-09 23:31:48 +00:00
if ( VID_SetWindowCaption )
2005-11-14 01:32:21 +00:00
VID_SetWindowCaption ( FULLENGINENAME " : disconnected " ) ;
2004-08-23 00:15:46 +00:00
// stop sounds (especially looping!)
S_StopAllSounds ( true ) ;
2004-12-29 03:24:21 +00:00
# ifdef VM_CG
2004-12-24 08:45:56 +00:00
CG_Stop ( ) ;
# endif
2005-02-09 19:32:09 +00:00
# ifdef CSQC_DAT
CSQC_Shutdown ( ) ;
# endif
// if running a local server, shut it down
2004-08-23 00:15:46 +00:00
if ( cls . demoplayback ! = DPB_NONE )
CL_StopPlayback ( ) ;
else if ( cls . state ! = ca_disconnected )
{
if ( cls . demorecording )
CL_Stop_f ( ) ;
2005-05-26 12:55:34 +00:00
switch ( cls . protocol )
2004-08-23 00:15:46 +00:00
{
2005-05-26 12:55:34 +00:00
case CP_NETQUAKE :
2007-08-07 19:16:32 +00:00
# ifdef NQPROT
2005-06-15 04:45:26 +00:00
final [ 0 ] = clc_disconnect ;
2006-02-22 23:36:03 +00:00
final [ 1 ] = clc_stringcmd ;
strcpy ( final + 2 , " drop " ) ;
Netchan_Transmit ( & cls . netchan , strlen ( final ) + 1 , final , 250000 ) ;
Netchan_Transmit ( & cls . netchan , strlen ( final ) + 1 , final , 250000 ) ;
Netchan_Transmit ( & cls . netchan , strlen ( final ) + 1 , final , 250000 ) ;
2004-08-23 00:15:46 +00:00
# endif
2007-08-07 19:16:32 +00:00
break ;
case CP_PLUGIN :
break ;
2005-05-26 12:55:34 +00:00
case CP_QUAKE2 :
2007-08-07 19:16:32 +00:00
# ifdef Q2CLIENT
2005-05-26 12:55:34 +00:00
final [ 0 ] = clcq2_stringcmd ;
strcpy ( final + 1 , " disconnect " ) ;
Netchan_Transmit ( & cls . netchan , strlen ( final ) + 1 , final , 2500 ) ;
Netchan_Transmit ( & cls . netchan , strlen ( final ) + 1 , final , 2500 ) ;
Netchan_Transmit ( & cls . netchan , strlen ( final ) + 1 , final , 2500 ) ;
2004-08-23 00:15:46 +00:00
# endif
2007-08-07 19:16:32 +00:00
break ;
case CP_QUAKE3 :
break ;
2005-05-26 12:55:34 +00:00
case CP_QUAKEWORLD :
final [ 0 ] = clc_stringcmd ;
strcpy ( final + 1 , " drop " ) ;
2004-10-19 16:10:14 +00:00
Netchan_Transmit ( & cls . netchan , strlen ( final ) + 1 , final , 2500 ) ;
Netchan_Transmit ( & cls . netchan , strlen ( final ) + 1 , final , 2500 ) ;
Netchan_Transmit ( & cls . netchan , strlen ( final ) + 1 , final , 2500 ) ;
2005-05-26 12:55:34 +00:00
break ;
2007-08-07 19:16:32 +00:00
case CP_UNKNOWN :
break ;
2004-08-23 00:15:46 +00:00
}
cls . state = ca_disconnected ;
cls . demoplayback = DPB_NONE ;
cls . demorecording = cls . timedemo = false ;
# ifndef CLIENTONLY
//running a server, and it's our own
2006-01-02 23:01:54 +00:00
if ( serverrunning & & ! tolocalserver )
SV_UnspawnServer ( ) ;
2004-08-23 00:15:46 +00:00
# endif
}
Cam_Reset ( ) ;
if ( cl . worldmodel )
2005-06-15 04:45:26 +00:00
{
2004-08-23 00:15:46 +00:00
# if defined(RUNTIMELIGHTING) && defined(RGLQUAKE)
extern model_t * lightmodel ;
lightmodel = NULL ;
# endif
cl . worldmodel - > needload = true ;
cl . worldmodel = NULL ;
}
2005-01-13 23:33:00 +00:00
if ( cls . downloadmethod < = DL_QWPENDING )
cls . downloadmethod = DL_NONE ;
2004-08-23 00:15:46 +00:00
if ( cls . downloadqw )
{
2006-01-02 23:01:54 +00:00
VFS_CLOSE ( cls . downloadqw ) ;
2004-08-23 00:15:46 +00:00
cls . downloadqw = NULL ;
}
if ( ! cls . downloadmethod )
* cls . downloadname = ' \0 ' ;
2006-01-13 06:27:18 +00:00
2004-08-23 00:15:46 +00:00
{
downloadlist_t * next ;
while ( cl . downloadlist )
{
next = cl . downloadlist - > next ;
Z_Free ( cl . downloadlist ) ;
cl . downloadlist = next ;
}
while ( cl . faileddownloads )
{
next = cl . faileddownloads - > next ;
Z_Free ( cl . faileddownloads ) ;
cl . faileddownloads = next ;
}
}
COM_FlushTempoaryPacks ( ) ;
2006-01-28 19:04:13 +00:00
r_worldentity . model = NULL ;
2005-04-16 16:21:27 +00:00
cl . spectator = 0 ;
2006-01-10 18:50:23 +00:00
cl . sendprespawn = false ;
2005-04-16 16:21:27 +00:00
2004-08-23 00:15:46 +00:00
# ifdef NQPROT
cls . signon = 0 ;
# endif
CL_StopUpload ( ) ;
2004-11-29 01:21:00 +00:00
# ifndef CLIENTONLY
2004-08-23 00:15:46 +00:00
if ( ! isDedicated )
2004-11-29 01:21:00 +00:00
# endif
2004-08-23 00:15:46 +00:00
SCR_EndLoadingPlaque ( ) ;
2004-12-24 08:45:56 +00:00
2005-05-26 12:55:34 +00:00
cls . protocol = CP_UNKNOWN ;
2005-06-04 04:20:20 +00:00
cl . servercount = 0 ;
2005-11-30 01:20:53 +00:00
cls . findtrack = false ;
2007-09-17 20:35:39 +00:00
Validation_DelatchRulesets ( ) ;
2005-11-30 01:20:53 +00:00
# ifdef TCPCONNECT
if ( cls . sockettcp ! = INVALID_SOCKET )
{
closesocket ( cls . sockettcp ) ;
cls . sockettcp = INVALID_SOCKET ;
}
# endif
2005-12-06 02:24:36 +00:00
cls . qport + + ; //a hack I picked up from qizmo
2007-02-23 00:21:33 +00:00
Cvar_ForceSet ( & cl_servername , " none " ) ;
2004-08-23 00:15:46 +00:00
}
# undef serverrunning
# undef tolocalserver
void CL_Disconnect_f ( void )
{
# ifndef CLIENTONLY
if ( sv . state )
SV_UnspawnServer ( ) ;
# endif
2005-07-01 19:23:00 +00:00
CL_Disconnect ( ) ;
2004-08-23 00:15:46 +00:00
Alias_WipeStuffedAliaes ( ) ;
}
/*
= = = = = = = = = = = = = = = = = = = =
CL_User_f
user < name or userid >
Dump userdata / masterdata for a user
= = = = = = = = = = = = = = = = = = = =
*/
void CL_User_f ( void )
{
int uid ;
int i ;
# ifndef CLIENTONLY
2005-06-14 04:52:10 +00:00
if ( sv . state )
2004-08-23 00:15:46 +00:00
{
SV_User_f ( ) ;
return ;
}
# endif
if ( Cmd_Argc ( ) ! = 2 )
{
Con_TPrintf ( TLC_SYNTAX_USER ) ;
return ;
}
uid = atoi ( Cmd_Argv ( 1 ) ) ;
for ( i = 0 ; i < MAX_CLIENTS ; i + + )
{
if ( ! cl . players [ i ] . name [ 0 ] )
continue ;
if ( cl . players [ i ] . userid = = uid
| | ! strcmp ( cl . players [ i ] . name , Cmd_Argv ( 1 ) ) )
{
Info_Print ( cl . players [ i ] . userinfo ) ;
return ;
}
}
Con_TPrintf ( TLC_USER_NOUSER ) ;
}
/*
= = = = = = = = = = = = = = = = = = = =
CL_Users_f
Dump userids for all current players
= = = = = = = = = = = = = = = = = = = =
*/
void CL_Users_f ( void )
{
int i ;
int c ;
c = 0 ;
Con_TPrintf ( TLC_USERBANNER ) ;
Con_TPrintf ( TLC_USERBANNER2 ) ;
for ( i = 0 ; i < MAX_CLIENTS ; i + + )
{
if ( cl . players [ i ] . name [ 0 ] )
{
Con_TPrintf ( TLC_USERLINE , cl . players [ i ] . userid , cl . players [ i ] . frags , cl . players [ i ] . name ) ;
c + + ;
}
}
Con_TPrintf ( TLC_USERTOTAL , c ) ;
}
void CL_Color_f ( void )
{
// just for quake compatability...
int top , bottom ;
char num [ 16 ] ;
qboolean server_owns_colour ;
if ( Cmd_Argc ( ) = = 1 )
{
Con_TPrintf ( TLC_COLOURCURRENT ,
Info_ValueForKey ( cls . userinfo , " topcolor " ) ,
Info_ValueForKey ( cls . userinfo , " bottomcolor " ) ) ;
Con_TPrintf ( TLC_SYNTAX_COLOUR ) ;
return ;
}
2005-04-16 16:21:27 +00:00
if ( Cmd_FromGamecode ( ) )
2004-08-23 00:15:46 +00:00
server_owns_colour = true ;
else
server_owns_colour = false ;
if ( Cmd_Argc ( ) = = 2 )
top = bottom = atoi ( Cmd_Argv ( 1 ) ) ;
else
{
top = atoi ( Cmd_Argv ( 1 ) ) ;
bottom = atoi ( Cmd_Argv ( 2 ) ) ;
}
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
top & = 15 ;
if ( top > 13 )
top = 13 ;
bottom & = 15 ;
if ( bottom > 13 )
bottom = 13 ;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
sprintf ( num , " %i " , top ) ;
if ( top = = 0 )
* num = ' \0 ' ;
if ( Cmd_ExecLevel > RESTRICT_SERVER ) //colour command came from server for a split client
Cbuf_AddText ( va ( " cmd %i setinfo topcolor %i \n " , Cmd_ExecLevel - RESTRICT_SERVER - 1 , top ) , Cmd_ExecLevel ) ;
// else if (server_owns_colour)
// Cvar_LockFromServer(&topcolor, num);
else
Cvar_Set ( & topcolor , num ) ;
sprintf ( num , " %i " , bottom ) ;
if ( bottom = = 0 )
* num = ' \0 ' ;
if ( Cmd_ExecLevel > RESTRICT_SERVER ) //colour command came from server for a split client
Cbuf_AddText ( va ( " cmd %i setinfo bottomcolor %i \n " , Cmd_ExecLevel - RESTRICT_SERVER - 1 , bottom ) , Cmd_ExecLevel ) ;
else if ( server_owns_colour )
Cvar_LockFromServer ( & bottomcolor , num ) ;
else
Cvar_Set ( & bottomcolor , num ) ;
# ifdef NQPROT
2005-05-26 12:55:34 +00:00
if ( cls . protocol = = CP_NETQUAKE )
2004-08-23 00:15:46 +00:00
Cmd_ForwardToServer ( ) ;
# endif
}
void CL_CheckServerInfo ( void )
{
char * s ;
unsigned int allowed ;
2006-03-06 01:41:09 +00:00
int oldstate ;
2006-03-11 03:12:10 +00:00
qboolean oldallowshaders ;
oldallowshaders = cls . allow_shaders ;
2004-08-23 00:15:46 +00:00
cl . teamplay = atoi ( Info_ValueForKey ( cl . serverinfo , " teamplay " ) ) ;
cl . deathmatch = atoi ( Info_ValueForKey ( cl . serverinfo , " deathmatch " ) ) ;
cls . allow_cheats = false ;
cls . allow_semicheats = true ;
cls . allow_rearview = false ;
cls . allow_watervis = false ;
cls . allow_skyboxes = false ;
cls . allow_mirrors = false ;
cls . allow_shaders = false ;
cls . allow_luma = true ;
cls . allow_bump = false ;
# ifdef FISH
cls . allow_fish = false ;
# endif
2006-05-11 02:30:13 +00:00
cls . allow_fbskins = 1 ;
2005-01-05 08:01:19 +00:00
// cls.allow_fbskins = 0;
2004-08-23 00:15:46 +00:00
// cls.allow_overbrightlight;
2004-10-13 07:24:59 +00:00
if ( cls . demoplayback | | atoi ( Info_ValueForKey ( cl . serverinfo , " rearview " ) ) )
2004-08-23 00:15:46 +00:00
cls . allow_rearview = true ;
2004-10-13 07:24:59 +00:00
if ( cls . demoplayback | | atoi ( Info_ValueForKey ( cl . serverinfo , " watervis " ) ) )
2004-08-23 00:15:46 +00:00
cls . allow_watervis = true ;
2004-10-13 07:24:59 +00:00
if ( cls . demoplayback | | atoi ( Info_ValueForKey ( cl . serverinfo , " allow_skybox " ) ) | | atoi ( Info_ValueForKey ( cl . serverinfo , " allow_skyboxes " ) ) )
2004-08-23 00:15:46 +00:00
cls . allow_skyboxes = true ;
2004-10-13 07:24:59 +00:00
if ( cls . demoplayback | | atoi ( Info_ValueForKey ( cl . serverinfo , " mirrors " ) ) )
2004-08-23 00:15:46 +00:00
cls . allow_mirrors = true ;
2004-10-13 07:24:59 +00:00
if ( cls . demoplayback | | atoi ( Info_ValueForKey ( cl . serverinfo , " allow_shaders " ) ) )
2004-08-23 00:15:46 +00:00
cls . allow_shaders = true ;
2004-10-13 07:24:59 +00:00
if ( cls . demoplayback | | ! atoi ( Info_ValueForKey ( cl . serverinfo , " allow_luma " ) ) )
2004-08-23 00:15:46 +00:00
cls . allow_luma = false ;
2004-10-13 07:24:59 +00:00
if ( cls . demoplayback | | atoi ( Info_ValueForKey ( cl . serverinfo , " allow_lmgamma " ) ) )
2004-08-23 00:15:46 +00:00
cls . allow_lightmapgamma = true ;
s = Info_ValueForKey ( cl . serverinfo , " allow_bump " ) ;
2004-10-13 07:24:59 +00:00
if ( cls . demoplayback | | atoi ( s ) | | ! * s ) //admin doesn't care.
2004-08-23 00:15:46 +00:00
cls . allow_bump = true ;
# ifdef FISH
2004-10-13 07:24:59 +00:00
if ( cls . demoplayback | | atoi ( Info_ValueForKey ( cl . serverinfo , " allow_fish " ) ) )
2005-06-15 04:45:26 +00:00
cls . allow_fish = true ;
2004-08-23 00:15:46 +00:00
# endif
s = Info_ValueForKey ( cl . serverinfo , " fbskins " ) ;
2006-05-11 02:30:13 +00:00
if ( * s )
2004-08-23 00:15:46 +00:00
cls . allow_fbskins = atof ( s ) ;
2006-05-11 02:30:13 +00:00
else if ( cl . teamfortress )
cls . allow_fbskins = 0 ;
2004-08-23 00:15:46 +00:00
s = Info_ValueForKey ( cl . serverinfo , " *cheats " ) ;
2004-10-13 07:24:59 +00:00
if ( cls . demoplayback | | ! stricmp ( s , " on " ) )
2004-08-23 00:15:46 +00:00
cls . allow_cheats = true ;
s = Info_ValueForKey ( cl . serverinfo , " strict " ) ;
2007-08-23 21:25:18 +00:00
if ( ( ! cls . demoplayback & & * s & & strcmp ( s , " 0 " ) ) | | ! ruleset_allow_semicheats . value )
2004-08-23 00:15:46 +00:00
{
cls . allow_semicheats = false ;
cls . allow_cheats = false ;
}
2006-03-11 03:12:10 +00:00
cls . allow_shaders = cls . allow_cheats ;
if ( cls . demoplayback | | atoi ( Info_ValueForKey ( cl . serverinfo , " allow_shaders " ) ) )
cls . allow_shaders = true ;
2004-08-23 00:15:46 +00:00
cls . maxfps = atof ( Info_ValueForKey ( cl . serverinfo , " maxfps " ) ) ;
2005-04-16 16:21:27 +00:00
if ( cls . maxfps < 20 )
cls . maxfps = 72 ;
2004-08-23 00:15:46 +00:00
if ( ! atoi ( Info_ValueForKey ( cl . serverinfo , " deathmatch " ) ) )
cls . gamemode = GAME_COOP ;
else
cls . gamemode = GAME_DEATHMATCH ;
cls . z_ext = atoi ( Info_ValueForKey ( cl . serverinfo , " *z_ext " ) ) ;
// movement vars for prediction
cl . bunnyspeedcap = Q_atof ( Info_ValueForKey ( cl . serverinfo , " pm_bunnyspeedcap " ) ) ;
movevars . slidefix = ( Q_atof ( Info_ValueForKey ( cl . serverinfo , " pm_slidefix " ) ) ! = 0 ) ;
movevars . airstep = ( Q_atof ( Info_ValueForKey ( cl . serverinfo , " pm_airstep " ) ) ! = 0 ) ;
2005-01-13 16:29:20 +00:00
movevars . walljump = ( Q_atof ( Info_ValueForKey ( cl . serverinfo , " pm_walljump " ) ) ) ;
2004-08-23 00:15:46 +00:00
movevars . ktjump = Q_atof ( Info_ValueForKey ( cl . serverinfo , " pm_ktjump " ) ) ;
2007-06-20 00:02:54 +00:00
s = Info_ValueForKey ( cl . serverinfo , " pm_stepheight " ) ;
if ( * s )
movevars . stepheight = Q_atof ( s ) ;
else
movevars . stepheight = PM_DEFAULTSTEPHEIGHT ;
2004-08-23 00:15:46 +00:00
// Initialize cl.maxpitch & cl.minpitch
s = ( cls . z_ext & Z_EXT_PITCHLIMITS ) ? Info_ValueForKey ( cl . serverinfo , " maxpitch " ) : " " ;
cl . maxpitch = * s ? Q_atof ( s ) : 80.0f ;
s = ( cls . z_ext & Z_EXT_PITCHLIMITS ) ? Info_ValueForKey ( cl . serverinfo , " minpitch " ) : " " ;
cl . minpitch = * s ? Q_atof ( s ) : - 70.0f ;
allowed = atoi ( Info_ValueForKey ( cl . serverinfo , " allow " ) ) ;
if ( allowed & 1 )
cls . allow_watervis = true ;
if ( allowed & 2 )
cls . allow_rearview = true ;
if ( allowed & 4 )
cls . allow_skyboxes = true ;
if ( allowed & 8 )
cls . allow_mirrors = true ;
if ( allowed & 16 )
cls . allow_shaders = true ;
if ( allowed & 32 )
cls . allow_luma = true ;
if ( allowed & 64 )
cls . allow_bump = true ;
# ifdef FISH
if ( allowed & 128 )
cls . allow_fish = true ;
# endif
if ( allowed & 256 )
cls . allow_lightmapgamma = true ;
if ( allowed & 512 )
cls . allow_cheats = true ;
if ( cls . allow_semicheats )
cls . allow_anyparticles = true ;
else
cls . allow_anyparticles = false ;
2006-03-06 01:41:09 +00:00
2007-07-23 12:03:33 +00:00
if ( cls . demoplayback )
cl . fpd = 0 ;
else
cl . fpd = atoi ( Info_ValueForKey ( cl . serverinfo , " fpd " ) ) ;
2006-03-06 01:41:09 +00:00
s = Info_ValueForKey ( cl . serverinfo , " status " ) ;
oldstate = cl . ktprostate ;
if ( ! stricmp ( s , " standby " ) )
cl . ktprostate = KTPRO_STANDBY ;
else if ( ! stricmp ( s , " countdown " ) )
cl . ktprostate = KTPRO_COUNTDOWN ;
else
cl . ktprostate = KTPRO_DONTKNOW ;
if ( oldstate ! = cl . ktprostate )
cl . ktprogametime = 0 ;
2004-08-23 00:15:46 +00:00
Cvar_ForceCheatVars ( cls . allow_semicheats , cls . allow_cheats ) ;
2005-06-15 04:45:26 +00:00
2006-03-11 03:12:10 +00:00
if ( oldallowshaders ! = cls . allow_shaders )
Cache_Flush ( ) ; //this will cause all models to be reloaded.
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
CL_FullServerinfo_f
2005-03-10 03:55:18 +00:00
Sent by server just after the svc_serverdata
2004-08-23 00:15:46 +00:00
= = = = = = = = = = = = = = = = = =
*/
void CL_FullServerinfo_f ( void )
{
char * p ;
float v ;
2005-04-16 16:21:27 +00:00
if ( ! Cmd_FromGamecode ( ) )
2005-01-07 02:44:12 +00:00
{
Con_Printf ( " Hey! fullserverinfo is meant to come from the server! \n " ) ;
return ;
}
2004-08-23 00:15:46 +00:00
if ( Cmd_Argc ( ) ! = 2 )
{
Con_TPrintf ( TLC_SYNTAX_FULLSERVERINFO ) ;
return ;
}
2005-03-07 08:55:30 +00:00
Q_strncpyz ( cl . serverinfo , Cmd_Argv ( 1 ) , sizeof ( cl . serverinfo ) ) ;
2004-08-23 00:15:46 +00:00
if ( ( p = Info_ValueForKey ( cl . serverinfo , " *version " ) ) & & * p ) {
v = Q_atof ( p ) ;
if ( v ) {
if ( ! server_version )
Con_TPrintf ( TLC_SERVER_VERSION , v ) ;
server_version = v ;
}
}
CL_CheckServerInfo ( ) ;
2005-03-10 03:55:18 +00:00
2005-03-20 02:57:11 +00:00
cl . gamespeed = atof ( Info_ValueForKey ( cl . serverinfo , " *gamespeed " ) ) / 100.f ;
if ( cl . gamespeed < 0.1 )
cl . gamespeed = 1 ;
cl . csqcdebug = atoi ( Info_ValueForKey ( cl . serverinfo , " *csqcdebug " ) ) ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
CL_FullInfo_f
Allow clients to change userinfo
= = = = = = = = = = = = = = = = = =
*/
void CL_FullInfo_f ( void )
{
char key [ 512 ] ;
char value [ 512 ] ;
char * o ;
char * s ;
if ( Cmd_Argc ( ) ! = 2 )
{
Con_TPrintf ( TLC_SYNTAX_FULLINFO ) ;
return ;
}
s = Cmd_Argv ( 1 ) ;
if ( * s = = ' \\ ' )
s + + ;
while ( * s )
{
o = key ;
while ( * s & & * s ! = ' \\ ' )
* o + + = * s + + ;
* o = 0 ;
if ( ! * s )
{
Con_TPrintf ( TL_KEYHASNOVALUE ) ;
return ;
}
o = value ;
s + + ;
while ( * s & & * s ! = ' \\ ' )
* o + + = * s + + ;
* o = 0 ;
if ( * s )
s + + ;
if ( ! stricmp ( key , pmodel_name ) | | ! stricmp ( key , emodel_name ) )
continue ;
Info_SetValueForKey ( cls . userinfo , key , value , MAX_INFO_STRING ) ;
}
}
2007-02-23 00:21:33 +00:00
void CL_SetInfo ( char * key , char * value )
{
cvar_t * var ;
var = Cvar_FindVar ( key ) ;
if ( var & & ( var - > flags & CVAR_USERINFO ) )
{ //get the cvar code to set it. the server might have locked it.
Cvar_Set ( var , value ) ;
return ;
}
Info_SetValueForStarKey ( cls . userinfo , key , value , MAX_INFO_STRING ) ;
if ( cls . state > = ca_connected )
{
# ifdef Q2CLIENT
if ( cls . protocol = = CP_QUAKE2 | | cls . protocol = = CP_QUAKE3 )
cls . resendinfo = true ;
else
# endif
Cmd_ForwardToServer ( ) ;
}
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = =
CL_SetInfo_f
Allow clients to change userinfo
= = = = = = = = = = = = = = = = = =
*/
void CL_SetInfo_f ( void )
{
cvar_t * var ;
if ( Cmd_Argc ( ) = = 1 )
{
Info_Print ( cls . userinfo ) ;
return ;
}
if ( Cmd_Argc ( ) ! = 3 )
{
Con_TPrintf ( TLC_SYNTAX_SETINFO ) ;
return ;
}
if ( ! stricmp ( Cmd_Argv ( 1 ) , pmodel_name ) | | ! strcmp ( Cmd_Argv ( 1 ) , emodel_name ) )
return ;
2005-11-30 01:20:53 +00:00
if ( Cmd_Argv ( 1 ) [ 0 ] = = ' * ' )
{
int i ;
if ( ! strcmp ( Cmd_Argv ( 1 ) , " * " ) )
if ( ! strcmp ( Cmd_Argv ( 2 ) , " " ) )
{ //clear it out
char * k ;
for ( i = 0 ; ; )
{
k = Info_KeyForNumber ( cls . userinfo , i ) ;
if ( ! * k )
break ; //no more.
else if ( * k = = ' * ' )
i + + ; //can't remove * keys
2007-02-23 00:21:33 +00:00
else if ( ( var = Cvar_FindVar ( k ) ) & & var - > flags & CVAR_USERINFO )
2005-11-30 01:20:53 +00:00
i + + ; //this one is a cvar.
else
Info_RemoveKey ( cls . userinfo , k ) ; //we can remove this one though, so yay.
}
return ;
}
Con_TPrintf ( TL_STARKEYPROTECTED ) ;
return ;
}
2004-08-23 00:15:46 +00:00
2007-02-23 00:21:33 +00:00
CL_SetInfo ( Cmd_Argv ( 1 ) , Cmd_Argv ( 2 ) ) ;
2004-08-23 00:15:46 +00:00
}
2005-12-21 03:07:33 +00:00
void CL_SaveInfo ( vfsfile_t * f )
2005-11-30 01:20:53 +00:00
{
2005-12-21 03:07:33 +00:00
VFS_WRITE ( f , " \n " , 1 ) ;
VFS_WRITE ( f , " setinfo * \" \" \n " , 13 ) ;
2005-11-30 01:20:53 +00:00
Info_WriteToFile ( f , cls . userinfo , " setinfo " , CVAR_USERINFO ) ;
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = = = =
CL_Packet_f
packet < destination > < contents >
Contents allows \ n escape character
= = = = = = = = = = = = = = = = = = = =
*/
void CL_Packet_f ( void )
{
char send [ 2048 ] ;
int i , l ;
char * in , * out ;
netadr_t adr ;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
if ( Cmd_Argc ( ) ! = 3 )
{
Con_TPrintf ( TLC_PACKET_SYNTAX ) ;
return ;
}
if ( ! NET_StringToAdr ( Cmd_Argv ( 1 ) , & adr ) )
{
Con_TPrintf ( TLC_BADADDRESS ) ;
return ;
}
2006-09-17 00:59:22 +00:00
2005-04-16 16:21:27 +00:00
if ( Cmd_FromGamecode ( ) ) //some mvd servers stuffcmd a packet command which lets them know which ip the client is from.
2004-12-08 04:14:52 +00:00
{ //unfortunatly, 50% of servers are badly configured.
2004-09-14 21:39:18 +00:00
if ( adr . type = = NA_IP )
2006-02-17 02:51:59 +00:00
if ( adr . address . ip [ 0 ] = = 127 )
if ( adr . address . ip [ 1 ] = = 0 )
if ( adr . address . ip [ 2 ] = = 0 )
if ( adr . address . ip [ 3 ] = = 1 )
2004-09-14 21:39:18 +00:00
{
2006-02-17 02:51:59 +00:00
adr . address . ip [ 0 ] = cls . netchan . remote_address . address . ip [ 0 ] ;
adr . address . ip [ 1 ] = cls . netchan . remote_address . address . ip [ 1 ] ;
adr . address . ip [ 2 ] = cls . netchan . remote_address . address . ip [ 2 ] ;
adr . address . ip [ 3 ] = cls . netchan . remote_address . address . ip [ 3 ] ;
2005-02-28 07:16:19 +00:00
adr . port = cls . netchan . remote_address . port ;
2007-09-23 15:28:06 +00:00
Con_Printf ( CON_WARNING " Server is broken. Trying to send to server instead. \n " ) ;
2005-02-28 07:16:19 +00:00
2004-09-14 21:39:18 +00:00
}
2004-12-08 04:14:52 +00:00
2005-01-29 02:22:43 +00:00
Con_DPrintf ( " Sending realip packet \n " ) ;
2004-09-14 21:39:18 +00:00
}
2007-08-23 21:25:18 +00:00
else if ( ! ruleset_allow_packet . value )
{
Con_Printf ( " Sorry, the %s command is disallowed \n " , Cmd_Argv ( 0 ) ) ;
return ;
}
2004-12-15 19:54:09 +00:00
cls . lastarbiatarypackettime = Sys_DoubleTime ( ) ; //prevent the packet command from causing a reconnect on badly configured mvdsv servers.
2004-09-14 21:39:18 +00:00
2004-08-23 00:15:46 +00:00
in = Cmd_Argv ( 2 ) ;
out = send + 4 ;
send [ 0 ] = send [ 1 ] = send [ 2 ] = send [ 3 ] = 0xff ;
l = strlen ( in ) ;
for ( i = 0 ; i < l ; i + + )
{
if ( in [ i ] = = ' \\ ' & & in [ i + 1 ] = = ' n ' )
{
* out + + = ' \n ' ;
i + + ;
}
else
* out + + = in [ i ] ;
}
* out = 0 ;
2005-11-30 01:20:53 +00:00
# ifdef TCPCONNECT
{
int tcpsock ; //extra code to stop the packet command from sending to the server via tcp
tcpsock = cls . sockettcp ;
cls . sockettcp = - 1 ;
NET_SendPacket ( NS_CLIENT , out - send , send , adr ) ;
cls . sockettcp = tcpsock ;
}
# else
2004-08-23 00:15:46 +00:00
NET_SendPacket ( NS_CLIENT , out - send , send , adr ) ;
2005-11-30 01:20:53 +00:00
# endif
2006-09-17 00:59:22 +00:00
if ( Cmd_FromGamecode ( ) )
{
//realip
2007-09-27 10:48:16 +00:00
char * temp = Z_Malloc ( strlen ( in ) + 1 ) ;
strcpy ( temp , in ) ;
Cmd_TokenizeString ( temp , false , false ) ;
2006-09-17 00:59:22 +00:00
cls . realip_ident = atoi ( Cmd_Argv ( 2 ) ) ;
2007-09-27 10:48:16 +00:00
Z_Free ( temp ) ;
2006-09-17 00:59:22 +00:00
}
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = =
CL_NextDemo
Called to play the next demo in the demo loop
= = = = = = = = = = = = = = = = = = = = =
*/
void CL_NextDemo ( void )
{
char str [ 1024 ] ;
if ( cls . demonum = = - 1 )
return ; // don't play demos
if ( ! cls . demos [ cls . demonum ] [ 0 ] | | cls . demonum = = MAX_DEMOS )
{
cls . demonum = 0 ;
if ( ! cls . demos [ cls . demonum ] [ 0 ] )
{
// Con_Printf ("No demos listed with startdemos\n");
cls . demonum = - 1 ;
return ;
}
}
sprintf ( str , " playdemo %s \n " , cls . demos [ cls . demonum ] ) ;
2006-02-06 01:06:17 +00:00
Cbuf_InsertText ( str , RESTRICT_LOCAL , false ) ;
2004-08-23 00:15:46 +00:00
cls . demonum + + ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
DEMO LOOP CONTROL
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
/*
= = = = = = = = = = = = = = = = = =
CL_Startdemos_f
= = = = = = = = = = = = = = = = = =
*/
void CL_Startdemos_f ( void )
{
int i , c ;
c = Cmd_Argc ( ) - 1 ;
if ( c > MAX_DEMOS )
{
Con_Printf ( " Max %i demos in demoloop \n " , MAX_DEMOS ) ;
c = MAX_DEMOS ;
}
Con_Printf ( " %i demo(s) in loop \n " , c ) ;
for ( i = 1 ; i < c + 1 ; i + + )
Q_strncpyz ( cls . demos [ i - 1 ] , Cmd_Argv ( i ) , sizeof ( cls . demos [ 0 ] ) ) ;
2004-11-29 01:21:00 +00:00
if (
# ifndef CLIENTONLY
2005-06-15 04:45:26 +00:00
! sv . state & &
2004-11-29 01:21:00 +00:00
# endif
2006-03-06 01:41:09 +00:00
cls . demonum ! = - 1 & & cls . demoplayback = = DPB_NONE & & ! Media_PlayingFullScreen ( ) & & COM_CheckParm ( " -demos " ) )
2004-08-23 00:15:46 +00:00
{
cls . demonum = 0 ;
CL_NextDemo ( ) ;
}
else
cls . demonum = - 1 ;
}
/*
= = = = = = = = = = = = = = = = = =
CL_Demos_f
Return to looping demos
= = = = = = = = = = = = = = = = = =
*/
void CL_Demos_f ( void )
{
if ( cls . demonum = = - 1 )
cls . demonum = 1 ;
CL_Disconnect_f ( ) ;
CL_NextDemo ( ) ;
}
/*
= = = = = = = = = = = = = = = = = =
CL_Stopdemo_f
stop demo
= = = = = = = = = = = = = = = = = =
*/
void CL_Stopdemo_f ( void )
{
if ( cls . demoplayback = = DPB_NONE )
return ;
CL_StopPlayback ( ) ;
CL_Disconnect ( ) ;
}
/*
= = = = = = = = = = = = = = = = =
CL_Changing_f
Just sent as a hint to the client that they should
drop to full console
= = = = = = = = = = = = = = = = =
*/
void CL_Changing_f ( void )
{
2006-09-17 00:59:22 +00:00
char * mapname = Cmd_Argv ( 1 ) ;
2004-08-23 00:15:46 +00:00
if ( cls . downloadqw ) // don't change when downloading
return ;
2006-09-17 00:59:22 +00:00
if ( * mapname )
SCR_ImageName ( mapname ) ;
else
SCR_BeginLoadingPlaque ( ) ;
2004-08-23 00:15:46 +00:00
S_StopAllSounds ( true ) ;
cl . intermission = 0 ;
cls . state = ca_connected ; // not active anymore, but not disconnected
Con_TPrintf ( TLC_CHANGINGMAP ) ;
# ifdef NQPROT
cls . signon = 0 ;
# endif
}
/*
= = = = = = = = = = = = = = = = =
CL_Reconnect_f
The server is changing levels
= = = = = = = = = = = = = = = = =
*/
void CL_Reconnect_f ( void )
{
if ( cls . downloadqw ) // don't change when downloading
return ;
# ifdef NQPROT
2005-05-26 12:55:34 +00:00
if ( cls . protocol = = CP_NETQUAKE )
2004-08-23 00:15:46 +00:00
{
CL_Changing_f ( ) ;
return ;
}
# endif
S_StopAllSounds ( true ) ;
if ( cls . state = = ca_connected )
{
Con_TPrintf ( TLC_RECONNECTING ) ;
2005-03-23 22:14:08 +00:00
CL_SendClientCommand ( true , " new " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
if ( ! * cls . servername )
{
Con_TPrintf ( TLC_RECONNECT_NOSERVER ) ;
return ;
}
CL_Disconnect ( ) ;
CL_BeginServerReconnect ( ) ;
}
/*
= = = = = = = = = = = = = = = = =
CL_ConnectionlessPacket
Responses to broadcasts , etc
= = = = = = = = = = = = = = = = =
*/
void CL_ConnectionlessPacket ( void )
{
char * s ;
int c ;
MSG_BeginReading ( ) ;
MSG_ReadLong ( ) ; // skip the -1
2005-08-03 23:14:59 +00:00
Cmd_TokenizeString ( net_message . data + 4 , false , false ) ;
if ( net_message . cursize = = sizeof ( net_message_buffer ) )
net_message . data [ sizeof ( net_message_buffer ) - 1 ] = ' \0 ' ;
else
net_message . data [ net_message . cursize ] = ' \0 ' ;
2005-08-06 07:18:29 +00:00
# ifdef PLUGINS
2005-08-03 23:14:59 +00:00
if ( Plug_ConnectionlessClientPacket ( net_message . data + 4 , net_message . cursize - 4 ) )
return ;
2005-08-06 07:18:29 +00:00
# endif
2005-08-03 23:14:59 +00:00
2004-08-23 00:15:46 +00:00
c = MSG_ReadByte ( ) ;
2006-09-17 00:59:22 +00:00
// ping from somewhere
if ( c = = A2A_PING )
{
char data [ 256 ] ;
data [ 0 ] = 0xff ;
data [ 1 ] = 0xff ;
data [ 2 ] = 0xff ;
data [ 3 ] = 0xff ;
data [ 4 ] = A2A_ACK ;
data [ 5 ] = 0 ;
if ( ! cls . state | | ! NET_CompareAdr ( cls . netchan . remote_address , net_from ) )
{
Con_TPrintf ( TL_ST_COLON , NET_AdrToString ( net_from ) ) ;
Con_TPrintf ( TLC_A2A_PING ) ;
}
else
{
//ack needs two parameters to work with realip properly.
//firstly it needs an auth message, so it can't be spoofed.
//secondly, it needs a copy of the realip ident, so you can't report a different player's client (you would need access to thier ip).
data [ 5 ] = ' ' ;
sprintf ( data + 6 , " %i %i " , atoi ( MSG_ReadString ( ) ) , cls . realip_ident ) ;
}
NET_SendPacket ( NS_CLIENT , 6 , & data , net_from ) ;
return ;
}
2004-08-23 00:15:46 +00:00
if ( cls . demoplayback = = DPB_NONE )
Con_TPrintf ( TL_ST_COLON , NET_AdrToString ( net_from ) ) ;
2004-12-24 08:45:56 +00:00
// Con_DPrintf ("%s", net_message.data + 4);
2004-08-23 00:15:46 +00:00
2004-12-24 08:45:56 +00:00
if ( c = = S2C_CHALLENGE )
{
2004-08-23 00:15:46 +00:00
unsigned long pext = 0 , huffcrc = 0 ;
Con_TPrintf ( TLC_S2C_CHALLENGE ) ;
s = MSG_ReadString ( ) ;
COM_Parse ( s ) ;
2004-12-24 08:45:56 +00:00
if ( ! strcmp ( com_token , " hallengeResponse " ) )
{
# ifdef Q3CLIENT
2006-07-29 21:38:05 +00:00
if ( cls . protocol = = CP_QUAKE3 | | cls . protocol = = CP_UNKNOWN )
{
cls . protocol = CP_QUAKE3 ;
cls . challenge = atoi ( s + 17 ) ;
CL_SendConnectPacket ( 0 , 0 /*, ...*/ ) ;
}
else
{
Con_Printf ( " \n Challange from another protocol, ignoring Q3 challange \n " ) ;
return ;
}
2004-12-24 08:45:56 +00:00
return ;
# else
Con_Printf ( " \n Unable to connect to Quake3 \n " ) ;
return ;
# endif
}
else if ( ! strcmp ( com_token , " hallenge " ) )
2004-08-23 00:15:46 +00:00
{
2004-11-20 01:12:02 +00:00
char * s2 ;
2004-12-24 08:45:56 +00:00
for ( s2 = s + 9 ; * s2 ; s2 + + )
2004-11-20 01:12:02 +00:00
{
2004-12-24 08:45:56 +00:00
if ( ( * s2 < ' 0 ' | | * s2 > ' 9 ' ) & & * s2 ! = ' - ' )
2004-11-20 01:12:02 +00:00
break ;
}
2004-12-24 08:45:56 +00:00
if ( * s2 )
2004-11-20 01:12:02 +00:00
{ //and if it's not, we're unlikly to be compatable with whatever it is that's talking at us.
# ifdef NQPROT
2006-07-29 21:38:05 +00:00
if ( cls . protocol = = CP_NETQUAKE | | cls . protocol = = CP_UNKNOWN )
{
cls . protocol = CP_NETQUAKE ;
CL_ConnectToDarkPlaces ( s + 9 , net_from ) ;
}
else
Con_Printf ( " \n Challange from another protocol, ignoring DP challange \n " ) ;
2004-11-20 01:12:02 +00:00
# else
2004-12-24 08:45:56 +00:00
Con_Printf ( " \n Unable connect to DarkPlaces \n " ) ;
2004-11-20 01:12:02 +00:00
# endif
return ;
}
# ifdef Q2CLIENT
2006-07-29 21:38:05 +00:00
if ( cls . protocol = = CP_QUAKE2 | | cls . protocol = = CP_UNKNOWN )
cls . protocol = CP_QUAKE2 ;
else
{
Con_Printf ( " \n Challange from another protocol, ignoring Q2 challange \n " ) ;
return ;
}
2004-12-24 08:45:56 +00:00
# else
Con_Printf ( " \n Unable to connect to Quake2 \n " ) ;
2004-11-20 01:12:02 +00:00
# endif
2004-08-23 00:15:46 +00:00
s + = 9 ;
}
2004-12-24 08:45:56 +00:00
# ifdef Q3CLIENT
else if ( ! strcmp ( com_token , " onnectResponse " ) )
{
goto client_connect ;
}
# endif
2004-11-20 01:12:02 +00:00
# ifdef Q2CLIENT
2004-08-23 00:15:46 +00:00
else if ( ! strcmp ( com_token , " lient_connect " ) )
{
goto client_connect ;
}
2005-06-04 04:20:20 +00:00
# endif
2006-07-29 21:38:05 +00:00
else if ( cls . protocol = = CP_QUAKEWORLD | | cls . protocol = = CP_UNKNOWN )
2005-05-26 12:55:34 +00:00
cls . protocol = CP_QUAKEWORLD ;
2006-07-29 21:38:05 +00:00
else
{
2007-10-02 15:56:16 +00:00
Con_Printf ( " \n Challenge from another protocol, ignoring QW challenge \n " ) ;
2006-07-29 21:38:05 +00:00
return ;
}
2004-08-23 00:15:46 +00:00
cls . challenge = atoi ( s ) ;
for ( ; ; )
{
c = MSG_ReadLong ( ) ;
if ( msg_badread )
break ;
if ( c = = PROTOCOL_VERSION_FTE )
pext = MSG_ReadLong ( ) ;
# ifdef HUFFNETWORK
else if ( c = = ( ( ' H ' < < 0 ) + ( ' U ' < < 8 ) + ( ' F ' < < 16 ) + ( ' F ' < < 24 ) ) )
huffcrc = MSG_ReadLong ( ) ;
# endif
//else if (c == PROTOCOL_VERSION_...)
else
MSG_ReadLong ( ) ;
}
CL_SendConnectPacket ( pext , huffcrc /*, ...*/ ) ;
return ;
}
# ifdef Q2CLIENT
2005-05-26 12:55:34 +00:00
if ( cls . protocol = = CP_QUAKE2 )
2004-08-23 00:15:46 +00:00
{
char * nl ;
msg_readcount - - ;
c = msg_readcount ;
s = MSG_ReadString ( ) ;
nl = strchr ( s , ' \n ' ) ;
if ( nl )
{
msg_readcount = c + nl - s + 1 ;
* nl = ' \0 ' ;
}
if ( ! strcmp ( s , " print " ) )
{
Con_TPrintf ( TLC_A2C_PRINT ) ;
s = MSG_ReadString ( ) ;
2005-09-26 08:07:26 +00:00
Con_Printf ( " %s " , s ) ;
2004-08-23 00:15:46 +00:00
return ;
}
else if ( ! strcmp ( s , " client_connect " ) )
{
goto client_connect ;
}
2004-12-24 08:45:56 +00:00
else if ( ! strcmp ( s , " disconnect " ) )
{
if ( NET_CompareAdr ( net_from , cls . netchan . remote_address ) )
{
Con_Printf ( " disconnect \n " ) ;
CL_Disconnect_f ( ) ;
return ;
}
else
{
Con_Printf ( " Ignoring random disconnect command \n " ) ;
return ;
}
}
2004-08-23 00:15:46 +00:00
else
{
Con_TPrintf ( TLC_Q2CONLESSPACKET_UNKNOWN , s ) ;
msg_readcount = c ;
c = MSG_ReadByte ( ) ;
}
}
# endif
2005-06-15 04:45:26 +00:00
2004-11-20 01:12:02 +00:00
# ifdef NQPROT
if ( c = = ' a ' )
{
s = MSG_ReadString ( ) ;
COM_Parse ( s ) ;
if ( ! strcmp ( com_token , " ccept " ) )
{
2006-02-22 23:36:03 +00:00
Con_Printf ( " accept \n " ) ;
2007-09-17 20:35:39 +00:00
Validation_Apply_Ruleset ( ) ;
2005-05-26 12:55:34 +00:00
Netchan_Setup ( NS_CLIENT , & cls . netchan , net_from , cls . qport ) ;
2004-11-20 01:12:02 +00:00
Con_DPrintf ( " CL_EstablishConnection: connected to %s \n " , cls . servername ) ;
2005-06-15 04:45:26 +00:00
2004-11-20 01:12:02 +00:00
cls . netchan . isnqprotocol = true ;
2005-05-26 12:55:34 +00:00
cls . protocol = CP_NETQUAKE ;
2005-06-15 04:45:26 +00:00
2004-11-20 01:12:02 +00:00
cls . demonum = - 1 ; // not in the demo loop now
cls . state = ca_connected ;
SCR_BeginLoadingPlaque ( ) ;
return ;
}
}
# endif
2004-12-24 08:45:56 +00:00
if ( c = = ' d ' ) //note - this conflicts with qw masters, our browser uses a different socket.
{
2005-08-26 22:56:51 +00:00
Con_Printf ( " d \n " ) ;
2005-06-04 04:20:20 +00:00
if ( cls . demoplayback ! = DPB_NONE )
{
Con_Printf ( " Disconnect \n " ) ;
CL_Disconnect_f ( ) ;
}
2004-12-24 08:45:56 +00:00
return ;
}
2004-08-23 00:15:46 +00:00
if ( c = = S2C_CONNECTION )
{
int compress ;
# ifdef Q2CLIENT
client_connect : //fixme: make function
# endif
Con_TPrintf ( TLC_GOTCONNECTION ) ;
if ( cls . state > = ca_connected )
{
if ( cls . demoplayback = = DPB_NONE )
Con_TPrintf ( TLC_DUPCONNECTION ) ;
return ;
}
compress = cls . netchan . compress ;
Netchan_Setup ( NS_CLIENT , & cls . netchan , net_from , cls . qport ) ;
cls . netchan . compress = compress ;
2005-04-16 16:21:27 +00:00
# ifdef Q3CLIENT
2005-06-04 04:20:20 +00:00
if ( cls . protocol ! = CP_QUAKE3 )
2005-04-16 16:21:27 +00:00
# endif
2005-03-23 22:14:08 +00:00
CL_SendClientCommand ( true , " new " ) ;
2004-08-23 00:15:46 +00:00
cls . state = ca_connected ;
Con_TPrintf ( TLC_CONNECTED ) ;
allowremotecmd = false ; // localid required now for remote cmds
2006-05-07 20:57:30 +00:00
total_loading_size = 100 ;
current_loading_size = 0 ;
loading_stage = 2 ;
2007-09-17 20:35:39 +00:00
Validation_Apply_Ruleset ( ) ;
2004-08-23 00:15:46 +00:00
return ;
}
// remote command from gui front end
2004-12-25 02:06:27 +00:00
if ( c = = A2C_CLIENT_COMMAND ) //man I hate this.
2004-08-23 00:15:46 +00:00
{
char cmdtext [ 2048 ] ;
Con_TPrintf ( TLC_CONLESS_CONCMD ) ;
2005-05-26 12:55:34 +00:00
if ( net_from . type ! = net_local_cl_ipadr . type
2006-02-17 02:51:59 +00:00
| | ( ( * ( unsigned * ) net_from . address . ip ! = * ( unsigned * ) net_local_cl_ipadr . address . ip ) & & ( * ( unsigned * ) net_from . address . ip ! = htonl ( INADDR_LOOPBACK ) ) ) )
2004-08-23 00:15:46 +00:00
{
Con_TPrintf ( TLC_CMDFROMREMOTE ) ;
return ;
}
# ifdef _WIN32
ShowWindow ( mainwindow , SW_RESTORE ) ;
SetForegroundWindow ( mainwindow ) ;
# endif
s = MSG_ReadString ( ) ;
Q_strncpyz ( cmdtext , s , sizeof ( cmdtext ) ) ;
s = MSG_ReadString ( ) ;
while ( * s & & isspace ( * s ) )
s + + ;
while ( * s & & isspace ( s [ strlen ( s ) - 1 ] ) )
s [ strlen ( s ) - 1 ] = 0 ;
if ( ! allowremotecmd & & ( ! * localid . string | | strcmp ( localid . string , s ) ) ) {
if ( ! * localid . string ) {
Con_TPrintf ( TLC_LOCALID_NOTSET ) ;
return ;
}
Con_TPrintf ( TLC_LOCALID_BAD ,
s , localid . string ) ;
Cvar_Set ( & localid , " " ) ;
return ;
}
2004-12-25 02:06:27 +00:00
Cbuf_AddText ( cmdtext , RESTRICT_SERVER ) ;
2004-08-23 00:15:46 +00:00
allowremotecmd = false ;
return ;
}
// print command from somewhere
2004-12-24 08:45:56 +00:00
if ( c = = ' p ' )
{
if ( ! strncmp ( net_message . data + 4 , " print \n " , 6 ) )
{
Con_TPrintf ( TLC_A2C_PRINT ) ;
2005-09-26 08:07:26 +00:00
Con_Printf ( " %s " , net_message . data + 10 ) ;
2004-12-24 08:45:56 +00:00
return ;
}
}
2004-08-23 00:15:46 +00:00
if ( c = = A2C_PRINT )
{
Con_TPrintf ( TLC_A2C_PRINT ) ;
s = MSG_ReadString ( ) ;
2005-09-26 08:07:26 +00:00
Con_Printf ( " %s " , s ) ;
2004-08-23 00:15:46 +00:00
return ;
}
2005-06-04 04:20:20 +00:00
if ( c = = ' r ' ) //dp's reject
{
s = MSG_ReadString ( ) ;
Con_Printf ( " r%s \n " , s ) ;
return ;
}
2004-08-23 00:15:46 +00:00
//happens in demos
if ( c = = svc_disconnect & & cls . demoplayback ! = DPB_NONE )
{
Host_EndGame ( " End of Demo " ) ;
return ;
}
Con_TPrintf ( TLC_CONLESSPACKET_UNKNOWN , c ) ;
}
2005-05-26 12:55:34 +00:00
# ifdef NQPROT
void CLNQ_ConnectionlessPacket ( void )
{
char * s ;
int length ;
MSG_BeginReading ( ) ;
2005-07-29 22:26:43 +00:00
length = LongSwap ( MSG_ReadLong ( ) ) ;
2005-05-26 12:55:34 +00:00
if ( ! ( length & NETFLAG_CTL ) )
return ; //not an nq control packet.
length & = NETFLAG_LENGTH_MASK ;
if ( length ! = net_message . cursize )
return ; //not an nq packet.
switch ( MSG_ReadByte ( ) )
{
case CCREP_ACCEPT :
if ( cls . state > = ca_connected )
{
if ( cls . demoplayback = = DPB_NONE )
Con_TPrintf ( TLC_DUPCONNECTION ) ;
return ;
}
2005-06-14 04:52:10 +00:00
net_from . port = htons ( ( short ) MSG_ReadLong ( ) ) ;
2005-10-16 03:50:39 +00:00
if ( MSG_ReadByte ( ) = = 1 ) //a proquake server adds a little extra info
{
int ver = MSG_ReadByte ( ) ;
Con_Printf ( " ProQuake server %i.%i \n " , ver / 10 , ver % 10 ) ;
if ( MSG_ReadByte ( ) = = 1 )
{
Con_Printf ( " ProQuake sucks \n Go play on a decent server. \n " ) ;
return ;
}
}
2007-09-17 20:35:39 +00:00
Validation_Apply_Ruleset ( ) ;
2005-05-26 12:55:34 +00:00
Netchan_Setup ( NS_CLIENT , & cls . netchan , net_from , cls . qport ) ;
cls . netchan . isnqprotocol = true ;
cls . netchan . compress = 0 ;
cls . protocol = CP_NETQUAKE ;
cls . state = ca_connected ;
Con_TPrintf ( TLC_CONNECTED ) ;
2006-05-07 20:57:30 +00:00
total_loading_size = 100 ;
current_loading_size = 0 ;
loading_stage = 2 ;
2005-05-26 12:55:34 +00:00
allowremotecmd = false ; // localid required now for remote cmds
2005-08-03 23:14:59 +00:00
//send a dummy packet.
//this makes our local nat think we initialised the conversation.
2005-10-16 03:50:39 +00:00
NET_SendPacket ( NS_CLIENT , 0 , " " , net_from ) ;
2005-05-26 12:55:34 +00:00
return ;
case CCREP_REJECT :
s = MSG_ReadString ( ) ;
2005-06-04 04:20:20 +00:00
Con_Printf ( " Connect failed \n %s \n " , s ) ;
2005-05-26 12:55:34 +00:00
return ;
}
}
# endif
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = =
CL_ReadPackets
= = = = = = = = = = = = = = = = =
*/
void CL_ReadPackets ( void )
{
// while (NET_GetPacket ())
2005-10-01 03:09:17 +00:00
for ( ; ; )
2004-08-23 00:15:46 +00:00
{
2005-10-01 03:09:17 +00:00
if ( cl . oldgametime & & cl_antibunch . value )
{
float want ;
static float clamp ;
want = cl . oldgametime + realtime - cl . gametimemark - clamp ;
if ( want > cl . time ) //don't decrease
{
clamp = 0 ;
cl . time = want ;
}
if ( cl . time > cl . gametime )
{
clamp + = cl . time - cl . gametime ;
cl . time = cl . gametime ;
}
if ( cl . time < cl . oldgametime )
{
clamp - = cl . time - cl . gametime ;
cl . time = cl . oldgametime ;
}
if ( cl . time < cl . gametime - ( 1 / cl_antibunch . value ) )
{
// if (cl.gametime - 2 > cl.time)
// cl.gametime = 0;
break ;
}
}
if ( ! CL_GetMessage ( ) )
break ;
2004-08-23 00:15:46 +00:00
# ifdef NQPROT
if ( cls . demoplayback = = DPB_NETQUAKE )
{
2005-05-26 12:55:34 +00:00
MSG_BeginReading ( ) ;
2004-08-23 00:15:46 +00:00
cls . netchan . last_received = realtime ;
CLNQ_ParseServerMessage ( ) ;
2005-10-01 03:09:17 +00:00
if ( ! cls . demoplayback )
CL_NextDemo ( ) ;
2004-08-23 00:15:46 +00:00
continue ;
}
# endif
# ifdef Q2CLIENT
if ( cls . demoplayback = = DPB_QUAKE2 )
{
MSG_BeginReading ( ) ;
cls . netchan . last_received = realtime ;
CLQ2_ParseServerMessage ( ) ;
continue ;
}
# endif
//
// remote command packet
//
if ( * ( int * ) net_message . data = = - 1 )
{
CL_ConnectionlessPacket ( ) ;
continue ;
}
2005-09-08 02:05:36 +00:00
if ( net_message . cursize < 6 & & cls . demoplayback ! = DPB_MVD ) //MVDs don't have the whole sequence header thing going on
2004-08-23 00:15:46 +00:00
{
Con_TPrintf ( TL_RUNTPACKET , NET_AdrToString ( net_from ) ) ;
continue ;
}
2005-05-26 12:55:34 +00:00
if ( cls . state = = ca_disconnected )
{ //connect to nq servers, but don't get confused with sequenced packets.
# ifdef NQPROT
CLNQ_ConnectionlessPacket ( ) ;
# endif
continue ; //ignore it. We arn't connected.
}
2004-08-23 00:15:46 +00:00
//
// packet from server
//
2005-06-15 04:45:26 +00:00
if ( ! cls . demoplayback & &
2004-08-23 00:15:46 +00:00
! NET_CompareAdr ( net_from , cls . netchan . remote_address ) )
{
2005-05-26 12:55:34 +00:00
Con_DPrintf ( " %s:sequenced packet from wrong server \n "
2004-08-23 00:15:46 +00:00
, NET_AdrToString ( net_from ) ) ;
continue ;
}
2005-05-26 12:55:34 +00:00
switch ( cls . protocol )
2004-12-24 08:45:56 +00:00
{
2005-05-26 12:55:34 +00:00
case CP_NETQUAKE :
2007-08-07 19:16:32 +00:00
# ifdef NQPROT
2005-05-26 12:55:34 +00:00
switch ( NQNetChan_Process ( & cls . netchan ) )
{
2007-08-30 02:05:50 +00:00
case NQP_ERROR :
2005-05-26 12:55:34 +00:00
break ;
2007-08-30 02:05:50 +00:00
case NQP_DATAGRAM : //datagram
2005-05-26 12:55:34 +00:00
cls . netchan . incoming_sequence = cls . netchan . outgoing_sequence - 3 ;
2007-08-30 02:05:50 +00:00
case NQP_RELIABLE : //reliable
2005-05-26 12:55:34 +00:00
CLNQ_ParseServerMessage ( ) ;
break ;
}
2004-12-24 08:45:56 +00:00
# endif
2007-08-07 19:16:32 +00:00
break ;
case CP_PLUGIN :
break ;
2005-05-26 12:55:34 +00:00
case CP_QUAKE2 :
2007-08-07 19:16:32 +00:00
# ifdef Q2CLIENT
2005-05-26 12:55:34 +00:00
if ( ! Netchan_Process ( & cls . netchan ) )
continue ; // wasn't accepted for some reason
2004-08-23 00:15:46 +00:00
CLQ2_ParseServerMessage ( ) ;
# endif
2007-08-07 19:16:32 +00:00
case CP_QUAKE3 :
# ifdef Q3CLIENT
CLQ3_ParseServerMessage ( ) ;
# endif
break ;
break ;
2005-05-26 12:55:34 +00:00
case CP_QUAKEWORLD :
if ( cls . demoplayback = = DPB_MVD )
2005-12-21 03:07:33 +00:00
{
2005-05-26 12:55:34 +00:00
MSG_BeginReading ( ) ;
2005-12-21 03:07:33 +00:00
cls . netchan . last_received = realtime ;
}
2005-05-26 12:55:34 +00:00
else if ( ! Netchan_Process ( & cls . netchan ) )
continue ; // wasn't accepted for some reason
2007-02-23 00:21:33 +00:00
2007-07-23 12:03:33 +00:00
if ( cls . netchan . incoming_sequence > cls . netchan . outgoing_sequence )
{ //server should not be responding to packets we have not sent yet
Con_Printf ( " Server is from the future! (%i packets) \n " , cls . netchan . incoming_sequence - cls . netchan . outgoing_sequence ) ;
cls . netchan . outgoing_sequence = cls . netchan . incoming_sequence ;
2007-02-23 00:21:33 +00:00
}
2004-08-23 00:15:46 +00:00
CL_ParseServerMessage ( ) ;
2005-05-26 12:55:34 +00:00
break ;
2007-08-07 19:16:32 +00:00
case CP_UNKNOWN :
break ;
2005-05-26 12:55:34 +00:00
}
2004-08-23 00:15:46 +00:00
// if (cls.demoplayback && cls.state >= ca_active && !CL_DemoBehind())
// return;
}
//
// check timeout
//
if ( cls . state > = ca_connected
& & realtime - cls . netchan . last_received > cl_timeout . value )
{
Con_TPrintf ( TLC_SERVERTIMEOUT ) ;
CL_Disconnect ( ) ;
return ;
}
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
if ( cls . demoplayback = = DPB_MVD )
MVD_Interpolate ( ) ;
}
//=============================================================================
/*
= = = = = = = = = = = = = = = = = = = = =
CL_Download_f
= = = = = = = = = = = = = = = = = = = = =
*/
void CL_Download_f ( void )
{
2005-01-17 17:40:37 +00:00
// char *p, *q;
char * url ;
2004-08-23 00:15:46 +00:00
url = Cmd_Argv ( 1 ) ;
# ifdef WEBCLIENT
if ( ! strnicmp ( url , " http:// " , 7 ) | | ! strnicmp ( url , " ftp:// " , 6 ) )
{
2005-04-16 16:21:27 +00:00
if ( Cmd_IsInsecure ( ) )
2004-08-23 00:15:46 +00:00
return ;
2005-05-26 12:55:34 +00:00
HTTP_CL_Get ( url , Cmd_Argv ( 2 ) , NULL ) ; //"test.txt");
2004-08-23 00:15:46 +00:00
return ;
}
# endif
if ( ! strnicmp ( url , " qw:// " , 5 ) | | ! strnicmp ( url , " q2:// " , 5 ) )
{
url + = 5 ;
}
if ( cls . state = = ca_disconnected | | cls . demoplayback )
{
Con_TPrintf ( TLC_CONNECTFIRST ) ;
return ;
}
if ( cls . netchan . remote_address . type = = NA_LOOPBACK )
{
Con_TPrintf ( TLC_CONNECTFIRST ) ;
return ;
}
if ( Cmd_Argc ( ) ! = 2 )
{
Con_TPrintf ( TLC_SYNTAX_DOWNLOAD ) ;
return ;
}
2005-04-16 16:21:27 +00:00
if ( Cmd_IsInsecure ( ) ) //mark server specified downloads.
2004-08-23 00:15:46 +00:00
{
2005-08-07 18:08:13 +00:00
if ( ! strnicmp ( url , " game " , 4 ) | | ! stricmp ( url , " progs.dat " ) | | ! stricmp ( url , " menu.dat " ) | | ! stricmp ( url , " csprogs.dat " ) | | ! stricmp ( url , " qwprogs.dat " ) | | strstr ( url , " .. " ) | | strstr ( url , " .dll " ) | | strstr ( url , " .so " ) )
2004-08-23 00:15:46 +00:00
{ //yes, I know the user can use a different progs from the one that is specified. If you leave it blank there will be no problem. (server isn't allowed to stuff progs cvar)
Con_Printf ( " Ignoring stuffed download of \" %s \" due to possible security risk \n " , url ) ;
return ;
}
2006-01-04 00:44:34 +00:00
CL_CheckOrEnqueDownloadFile ( url , url ) ;
2004-08-23 00:15:46 +00:00
return ;
}
2006-01-04 00:44:34 +00:00
CL_EnqueDownload ( url , url , true , true ) ;
2005-01-16 02:25:35 +00:00
/*
strcpy ( cls . downloadname , url ) ;
2004-08-23 00:15:46 +00:00
_snprintf ( cls . downloadname , sizeof ( cls . downloadname ) , " %s/%s " , com_gamedir , url ) ;
p = cls . downloadname ;
for ( ; ; )
{
if ( ( q = strchr ( p , ' / ' ) ) ! = NULL )
{
* q = 0 ;
Sys_mkdir ( cls . downloadname ) ;
* q = ' / ' ;
p = q + 1 ;
} else
break ;
}
2005-01-16 02:25:35 +00:00
COM_StripExtension ( cls . downloadname , cls . downloadtempname ) ;
COM_DefaultExtension ( cls . downloadtempname , " .tmp " ) ;
if ( cls . down
2004-09-20 23:25:38 +00:00
// cls.downloadqw = fopen (cls.downloadname, "wb");
2005-01-16 02:25:35 +00:00
cls . downloadmethod = DL_QWPENDING ;
2004-08-23 00:15:46 +00:00
2005-02-28 07:16:19 +00:00
CL_SendClientCommand ( " download %s \n " , url ) ; */
2004-08-23 00:15:46 +00:00
}
2006-08-02 21:48:07 +00:00
void CL_FinishDownload ( char * filename , char * tempname ) ;
void CL_ForceStopDownload ( qboolean finish )
{
if ( Cmd_IsInsecure ( ) )
{
2007-09-23 15:28:06 +00:00
Con_Printf ( CON_WARNING " Execution from server rejected for %s \n " , Cmd_Argv ( 0 ) ) ;
2006-08-02 21:48:07 +00:00
return ;
}
if ( ! cls . downloadqw )
{
Con_Printf ( " No files downloading by QW protocol \n " ) ;
return ;
}
VFS_CLOSE ( cls . downloadqw ) ;
if ( finish )
CL_FinishDownload ( cls . downloadname , cls . downloadtempname ) ;
else
{
char * tempname ;
if ( * cls . downloadtempname )
tempname = cls . downloadtempname ;
else
tempname = cls . downloadname ;
if ( strncmp ( tempname , " skins/ " , 6 ) )
FS_Remove ( tempname , FS_GAME ) ;
else
FS_Remove ( tempname + 6 , FS_SKINS ) ;
}
* cls . downloadname = ' \0 ' ;
cls . downloadqw = NULL ;
cls . downloadpercent = 0 ;
// get another file if needed
CL_RequestNextDownload ( ) ;
}
void CL_SkipDownload_f ( void )
{
CL_ForceStopDownload ( false ) ;
}
void CL_FinishDownload_f ( void )
{
CL_ForceStopDownload ( true ) ;
}
2007-09-22 22:09:42 +00:00
# ifdef _WIN32
2006-04-02 03:47:06 +00:00
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
2004-08-23 00:15:46 +00:00
# include <windows.h>
/*
= = = = = = = = = = = = = = = = =
CL_Minimize_f
= = = = = = = = = = = = = = = = =
*/
2004-12-09 23:31:48 +00:00
void CL_Windows_f ( void )
{
if ( ! mainwindow )
{
Con_Printf ( " Cannot comply \n " ) ;
return ;
}
2004-08-23 00:15:46 +00:00
// if (modestate == MS_WINDOWED)
// ShowWindow(mainwindow, SW_MINIMIZE);
// else
SendMessage ( mainwindow , WM_SYSKEYUP , VK_TAB , 1 | ( 0x0F < < 16 ) | ( 1 < < 29 ) ) ;
}
# endif
# ifndef CLIENTONLY
void CL_ServerInfo_f ( void )
{
if ( ! sv . state & & cls . state )
2006-02-11 02:09:43 +00:00
{
if ( cls . demoplayback )
{
Info_Print ( cl . serverinfo ) ;
}
else
Cmd_ForwardToServer ( ) ;
}
2004-08-23 00:15:46 +00:00
else
{
SV_Serverinfo_f ( ) ; //allow it to be set... (whoops)
}
}
# endif
# ifdef WEBCLIENT
void CL_FTP_f ( void )
2005-06-15 04:45:26 +00:00
{
FTP_Client_Command ( Cmd_Args ( ) , NULL ) ;
2004-08-23 00:15:46 +00:00
}
2004-09-24 02:45:41 +00:00
# endif
2004-08-23 00:15:46 +00:00
2005-01-13 16:29:20 +00:00
void SCR_ShowPic_Script_f ( void ) ;
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = =
CL_Init
= = = = = = = = = = = = = = = = =
*/
void CL_Init ( void )
{
extern void CL_Say_f ( void ) ;
2004-11-17 17:56:27 +00:00
extern void CL_SayMe_f ( void ) ;
2004-11-13 17:27:34 +00:00
extern void CL_SayTeam_f ( void ) ;
2004-08-23 00:15:46 +00:00
extern cvar_t baseskin ;
extern cvar_t noskins ;
char st [ 80 ] ;
cls . state = ca_disconnected ;
2005-10-04 21:08:06 +00:00
sprintf ( st , " %s %i " , DISTRIBUTION , build_number ( ) ) ;
2004-08-23 00:15:46 +00:00
Info_SetValueForStarKey ( cls . userinfo , " *ver " , st , MAX_INFO_STRING ) ;
InitValidation ( ) ;
CL_InitInput ( ) ;
CL_InitTEnts ( ) ;
CL_InitPrediction ( ) ;
CL_InitCam ( ) ;
PM_Init ( ) ;
TP_Init ( ) ;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
//
// register our commands
//
2005-01-23 17:49:42 +00:00
CLSCR_Init ( ) ;
2005-08-16 18:35:43 +00:00
# ifdef MENU_DAT
MP_RegisterCvarsAndCmds ( ) ;
# endif
2005-03-20 02:57:11 +00:00
# ifdef CSQC_DAT
CSQC_RegisterCvarsAndThings ( ) ;
# endif
2004-08-23 00:15:46 +00:00
Cvar_Register ( & host_speeds , cl_controlgroup ) ;
Cvar_Register ( & developer , cl_controlgroup ) ;
2004-09-22 15:25:58 +00:00
Cvar_Register ( & cfg_save_name , cl_controlgroup ) ;
2007-02-23 00:21:33 +00:00
Cvar_Register ( & cl_servername , cl_controlgroup ) ;
2004-12-24 08:45:56 +00:00
Cvar_Register ( & cl_demospeed , " Demo playback " ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & cl_warncmd , " Warnings " ) ;
Cvar_Register ( & cl_upspeed , cl_inputgroup ) ;
Cvar_Register ( & cl_forwardspeed , cl_inputgroup ) ;
Cvar_Register ( & cl_backspeed , cl_inputgroup ) ;
Cvar_Register ( & cl_sidespeed , cl_inputgroup ) ;
Cvar_Register ( & cl_movespeedkey , cl_inputgroup ) ;
Cvar_Register ( & cl_yawspeed , cl_inputgroup ) ;
Cvar_Register ( & cl_pitchspeed , cl_inputgroup ) ;
Cvar_Register ( & cl_anglespeedkey , cl_inputgroup ) ;
Cvar_Register ( & cl_shownet , cl_screengroup ) ;
Cvar_Register ( & cl_sbar , cl_screengroup ) ;
Cvar_Register ( & cl_hudswap , cl_screengroup ) ;
Cvar_Register ( & cl_maxfps , cl_screengroup ) ;
Cvar_Register ( & cl_timeout , cl_controlgroup ) ;
Cvar_Register ( & lookspring , cl_inputgroup ) ;
Cvar_Register ( & lookstrafe , cl_inputgroup ) ;
Cvar_Register ( & sensitivity , cl_inputgroup ) ;
Cvar_Register ( & m_pitch , cl_inputgroup ) ;
Cvar_Register ( & m_yaw , cl_inputgroup ) ;
Cvar_Register ( & m_forward , cl_inputgroup ) ;
Cvar_Register ( & m_side , cl_inputgroup ) ;
Cvar_Register ( & rcon_password , cl_controlgroup ) ;
Cvar_Register ( & rcon_address , cl_controlgroup ) ;
Cvar_Register ( & entlatency , cl_predictiongroup ) ;
Cvar_Register ( & cl_predict_players2 , cl_predictiongroup ) ;
Cvar_Register ( & cl_predict_players , cl_predictiongroup ) ;
Cvar_Register ( & cl_solid_players , cl_predictiongroup ) ;
Cvar_Register ( & localid , cl_controlgroup ) ;
2005-01-13 16:29:20 +00:00
Cvar_Register ( & cl_muzzleflash , cl_controlgroup ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & baseskin , " Teamplay " ) ;
Cvar_Register ( & noskins , " Teamplay " ) ;
2005-10-30 23:54:29 +00:00
Cvar_Register ( & cl_noblink , " Console controls " ) ; //for lack of a better group
2004-08-23 00:15:46 +00:00
Cvar_Register ( & cl_item_bobbing , " Item effects " ) ;
2005-01-13 16:29:20 +00:00
Cvar_Register ( & cl_staticsounds , " Item effects " ) ;
2005-01-17 17:40:37 +00:00
Cvar_Register ( & r_rocketlight , " Item effects " ) ;
Cvar_Register ( & r_lightflicker , " Item effects " ) ;
Cvar_Register ( & cl_r2g , " Item effects " ) ;
Cvar_Register ( & r_powerupglow , " Item effects " ) ;
2005-04-26 16:04:12 +00:00
Cvar_Register ( & v_powerupshell , " Item effects " ) ;
2005-01-17 17:40:37 +00:00
2005-01-18 20:15:20 +00:00
Cvar_Register ( & cl_gibfilter , " Item effects " ) ;
Cvar_Register ( & cl_deadbodyfilter , " Item effects " ) ;
2005-04-26 16:04:12 +00:00
Cvar_Register ( & cl_nolerp , " Item effects " ) ;
2006-03-05 04:46:10 +00:00
Cvar_Register ( & r_drawflame , " Item effects " ) ;
2005-08-11 04:14:33 +00:00
Cvar_Register ( & allow_download_csprogs , cl_controlgroup ) ;
2004-08-23 00:15:46 +00:00
//
// info mirrors
//
2007-09-21 11:15:12 +00:00
Cvar_Register ( & name , cl_controlgroup ) ;
Cvar_Register ( & password , cl_controlgroup ) ;
Cvar_Register ( & spectator , cl_controlgroup ) ;
Cvar_Register ( & skin , cl_controlgroup ) ;
Cvar_Register ( & model , cl_controlgroup ) ;
Cvar_Register ( & team , cl_controlgroup ) ;
Cvar_Register ( & topcolor , cl_controlgroup ) ;
Cvar_Register ( & bottomcolor , cl_controlgroup ) ;
Cvar_Register ( & rate , cl_controlgroup ) ;
Cvar_Register ( & drate , cl_controlgroup ) ;
Cvar_Register ( & msg , cl_controlgroup ) ;
Cvar_Register ( & noaim , cl_controlgroup ) ;
Cvar_Register ( & b_switch , cl_controlgroup ) ;
Cvar_Register ( & w_switch , cl_controlgroup ) ;
Cvar_Register ( & cl_nofake , cl_controlgroup ) ;
Cvar_Register ( & cl_chatsound , cl_controlgroup ) ;
Cvar_Register ( & cl_enemychatsound , cl_controlgroup ) ;
Cvar_Register ( & cl_teamchatsound , cl_controlgroup ) ;
Cvar_Register ( & requiredownloads , cl_controlgroup ) ;
Cvar_Register ( & cl_standardchat , cl_controlgroup ) ;
Cvar_Register ( & msg_filter , cl_controlgroup ) ;
Cvar_Register ( & cl_standardmsg , cl_controlgroup ) ;
Cvar_Register ( & cl_parsewhitetext , cl_controlgroup ) ;
Cvar_Register ( & cl_nopext , cl_controlgroup ) ;
Cvar_Register ( & cl_splitscreen , cl_controlgroup ) ;
Cvar_Register ( & host_mapname , " Scripting " ) ;
Cvar_Register ( & cl_countpendingpl , cl_controlgroup ) ;
Cvar_Register ( & cl_indepphysics , cl_controlgroup ) ;
Cvar_Register ( & cl_antibunch , " evil hacks " ) ;
Cvar_Register ( & hud_tracking_show , " statusbar " ) ;
Cvar_Register ( & cl_dlemptyterminate , cl_controlgroup ) ;
Cvar_Register ( & cl_gunx , cl_controlgroup ) ;
Cvar_Register ( & cl_guny , cl_controlgroup ) ;
Cvar_Register ( & cl_gunz , cl_controlgroup ) ;
Cvar_Register ( & cl_gunanglex , cl_controlgroup ) ;
Cvar_Register ( & cl_gunangley , cl_controlgroup ) ;
Cvar_Register ( & cl_gunanglez , cl_controlgroup ) ;
Cvar_Register ( & ruleset_allow_playercount , cl_controlgroup ) ;
Cvar_Register ( & ruleset_allow_frj , cl_controlgroup ) ;
Cvar_Register ( & ruleset_allow_semicheats , cl_controlgroup ) ;
Cvar_Register ( & ruleset_allow_packet , cl_controlgroup ) ;
Cvar_Register ( & ruleset_allow_particle_lightning , cl_controlgroup ) ;
Cvar_Register ( & ruleset_allow_overlongsounds , cl_controlgroup ) ;
Cvar_Register ( & ruleset_allow_larger_models , cl_controlgroup ) ;
2004-08-23 00:15:46 +00:00
# ifdef WEBCLIENT
Cmd_AddCommand ( " ftp " , CL_FTP_f ) ;
# endif
Cmd_AddCommand ( " version " , CL_Version_f ) ;
Cmd_AddCommand ( " changing " , CL_Changing_f ) ;
Cmd_AddCommand ( " disconnect " , CL_Disconnect_f ) ;
Cmd_AddCommand ( " record " , CL_Record_f ) ;
Cmd_AddCommand ( " rerecord " , CL_ReRecord_f ) ;
Cmd_AddCommand ( " stop " , CL_Stop_f ) ;
Cmd_AddCommand ( " playdemo " , CL_PlayDemo_f ) ;
2006-09-17 00:59:22 +00:00
Cmd_AddCommand ( " qtvplay " , CL_QTVPlay_f ) ;
Cmd_AddCommand ( " qtvlist " , CL_QTVList_f ) ;
2007-05-25 22:16:29 +00:00
Cmd_AddCommand ( " qtvdemos " , CL_QTVDemos_f ) ;
2005-12-21 03:07:33 +00:00
Cmd_AddCommand ( " demo_jump " , CL_DemoJump_f ) ;
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " timedemo " , CL_TimeDemo_f ) ;
2005-01-13 16:29:20 +00:00
Cmd_AddCommand ( " showpic " , SCR_ShowPic_Script_f ) ;
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " startdemos " , CL_Startdemos_f ) ;
Cmd_AddCommand ( " demos " , CL_Demos_f ) ;
Cmd_AddCommand ( " stopdemo " , CL_Stopdemo_f ) ;
Cmd_AddCommand ( " skins " , Skin_Skins_f ) ;
Cmd_AddCommand ( " allskins " , Skin_AllSkins_f ) ;
Cmd_AddCommand ( " quit " , CL_Quit_f ) ;
Cmd_AddCommand ( " connect " , CL_Connect_f ) ;
2005-11-30 01:20:53 +00:00
# ifdef TCPCONNECT
Cmd_AddCommand ( " tcpconnect " , CL_TCPConnect_f ) ;
# endif
2004-08-23 00:15:46 +00:00
# ifdef NQPROT
Cmd_AddCommand ( " nqconnect " , CLNQ_Connect_f ) ;
# endif
Cmd_AddCommand ( " reconnect " , CL_Reconnect_f ) ;
2005-01-13 23:33:00 +00:00
Cmd_AddCommand ( " join " , CL_Join_f ) ;
Cmd_AddCommand ( " observe " , CL_Observe_f ) ;
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " rcon " , CL_Rcon_f ) ;
Cmd_AddCommand ( " packet " , CL_Packet_f ) ;
Cmd_AddCommand ( " user " , CL_User_f ) ;
Cmd_AddCommand ( " users " , CL_Users_f ) ;
Cmd_AddCommand ( " setinfo " , CL_SetInfo_f ) ;
Cmd_AddCommand ( " fullinfo " , CL_FullInfo_f ) ;
Cmd_AddCommand ( " fullserverinfo " , CL_FullServerinfo_f ) ;
Cmd_AddCommand ( " color " , CL_Color_f ) ;
Cmd_AddCommand ( " download " , CL_Download_f ) ;
Cmd_AddCommand ( " nextul " , CL_NextUpload ) ;
Cmd_AddCommand ( " stopul " , CL_StopUpload ) ;
2006-08-02 21:48:07 +00:00
Cmd_AddCommand ( " skipdl " , CL_SkipDownload_f ) ;
Cmd_AddCommand ( " finishdl " , CL_FinishDownload_f ) ;
2004-08-23 00:15:46 +00:00
//
// forward to server commands
//
Cmd_AddCommand ( " god " , NULL ) ; //cheats
Cmd_AddCommand ( " give " , NULL ) ;
Cmd_AddCommand ( " noclip " , NULL ) ;
Cmd_AddCommand ( " fly " , NULL ) ;
Cmd_AddCommand ( " setpos " , NULL ) ;
Cmd_AddCommand ( " topten " , NULL ) ;
Cmd_AddCommand ( " kill " , NULL ) ;
Cmd_AddCommand ( " pause " , NULL ) ;
Cmd_AddCommand ( " say " , CL_Say_f ) ;
2004-11-17 17:56:27 +00:00
Cmd_AddCommand ( " me " , CL_SayMe_f ) ;
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " sayone " , CL_Say_f ) ;
2004-11-13 17:27:34 +00:00
Cmd_AddCommand ( " say_team " , CL_SayTeam_f ) ;
2004-08-23 00:15:46 +00:00
# ifdef CLIENTONLY
Cmd_AddCommand ( " serverinfo " , NULL ) ;
# else
Cmd_AddCommand ( " serverinfo " , CL_ServerInfo_f ) ;
# endif
//
// Windows commands
//
# ifdef _WINDOWS
Cmd_AddCommand ( " windows " , CL_Windows_f ) ;
# endif
2005-11-30 01:20:53 +00:00
Ignore_Init ( ) ;
2005-06-15 04:45:26 +00:00
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = =
Host_EndGame
Call this to drop to a console without exiting the qwcl
= = = = = = = = = = = = = = = =
*/
void VARGS Host_EndGame ( char * message , . . . )
{
va_list argptr ;
char string [ 1024 ] ;
SCR_EndLoadingPlaque ( ) ;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
va_start ( argptr , message ) ;
2006-03-06 01:41:09 +00:00
vsnprintf ( string , sizeof ( string ) - 1 , message , argptr ) ;
2004-08-23 00:15:46 +00:00
va_end ( argptr ) ;
2006-03-04 22:37:28 +00:00
Con_TPrintf ( TLC_CLIENTCON_ERROR_ENDGAME , string ) ;
2004-08-23 00:15:46 +00:00
Con_TPrintf ( TL_NL ) ;
SCR_EndLoadingPlaque ( ) ;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
CL_Disconnect ( ) ;
2006-01-02 23:01:54 +00:00
SV_UnspawnServer ( ) ;
2004-08-23 00:15:46 +00:00
Cvar_Set ( & cl_shownet , " 0 " ) ;
longjmp ( host_abort , 1 ) ;
}
/*
= = = = = = = = = = = = = = = =
Host_Error
This shuts down the client and exits qwcl
= = = = = = = = = = = = = = = =
*/
void VARGS Host_Error ( char * error , . . . )
{
va_list argptr ;
char string [ 1024 ] ;
static qboolean inerror = false ;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
if ( inerror )
Sys_Error ( " Host_Error: recursively entered " ) ;
inerror = true ;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
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 ) ;
2006-02-22 01:24:22 +00:00
Con_TPrintf ( TLC_HOSTFATALERROR , string ) ;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
CL_Disconnect ( ) ;
cls . demonum = - 1 ;
inerror = false ;
// FIXME
Sys_Error ( " Host_Error: %s \n " , string ) ;
}
/*
= = = = = = = = = = = = = = =
Host_WriteConfiguration
Writes key bindings and archived cvars to config . cfg
= = = = = = = = = = = = = = =
*/
void Host_WriteConfiguration ( void )
{
2005-12-21 03:07:33 +00:00
vfsfile_t * f ;
2004-08-23 00:15:46 +00:00
if ( host_initialized & & cfg_save_name . string & & * cfg_save_name . string )
{
if ( strchr ( cfg_save_name . string , ' . ' ) )
{
Con_TPrintf ( TLC_CONFIGCFG_WRITEFAILED ) ;
return ;
}
2006-01-02 23:01:54 +00:00
f = FS_OpenVFS ( va ( " %s.cfg " , cfg_save_name . string ) , " wb " , FS_GAMEONLY ) ;
2004-08-23 00:15:46 +00:00
if ( ! f )
{
Con_TPrintf ( TLC_CONFIGCFG_WRITEFAILED ) ;
return ;
}
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
Key_WriteBindings ( f ) ;
Cvar_WriteVariables ( f , false ) ;
2005-12-21 03:07:33 +00:00
VFS_CLOSE ( f ) ;
2004-08-23 00:15:46 +00:00
}
}
//============================================================================
#if 0
/*
= = = = = = = = = = = = = = = = = =
Host_SimulationTime
This determines if enough time has passed to run a simulation frame
= = = = = = = = = = = = = = = = = =
*/
qboolean Host_SimulationTime ( float time )
{
float fps ;
if ( oldrealtime > realtime )
oldrealtime = 0 ;
if ( cl_maxfps . value )
fps = max ( 30.0 , min ( cl_maxfps . value , 72.0 ) ) ;
else
fps = max ( 30.0 , min ( rate . value / 80.0 , 72.0 ) ) ;
if ( ! cls . timedemo & & ( realtime + time ) - oldrealtime < 1.0 / fps )
return false ; // framerate is too high
return true ;
}
# endif
/*
= = = = = = = = = = = = = = = = = =
Host_Frame
Runs all active servers
= = = = = = = = = = = = = = = = = =
*/
2005-02-28 07:16:19 +00:00
extern cvar_t cl_netfps ;
2004-08-23 00:15:46 +00:00
int nopacketcount ;
void SNDDMA_SetUnderWater ( qboolean underwater ) ;
2005-04-16 16:21:27 +00:00
float CL_FilterTime ( double time , float wantfps ) ;
2005-08-07 18:08:13 +00:00
void Host_Frame ( double time )
2004-08-23 00:15:46 +00:00
{
static double time1 = 0 ;
static double time2 = 0 ;
static double time3 = 0 ;
int pass1 , pass2 , pass3 ;
// float fps;
2006-11-03 15:53:04 +00:00
double realframetime ;
2005-08-07 18:08:13 +00:00
static double spare ;
2004-12-15 19:54:09 +00:00
RSpeedLocals ( ) ;
2004-08-23 00:15:46 +00:00
if ( setjmp ( host_abort ) )
return ; // something bad happened, or the server disconnected
2006-11-03 15:53:04 +00:00
realframetime = time = Media_TweekCaptureFrameTime ( time ) ;
2004-08-23 00:15:46 +00:00
2005-12-21 03:07:33 +00:00
// if (cls.demoplayback && cl_demospeed.value>0)
// realframetime *= cl_demospeed.value; // this probably screws up other timings
2004-12-24 08:45:56 +00:00
2004-08-23 00:15:46 +00:00
# ifndef CLIENTONLY
2004-12-15 19:54:09 +00:00
RSpeedRemark ( ) ;
2005-08-10 22:38:41 +00:00
SV_Frame ( ) ;
2004-12-15 19:54:09 +00:00
RSpeedEnd ( RSPEED_SERVER ) ;
2004-08-23 00:15:46 +00:00
# endif
2006-09-17 00:59:22 +00:00
2005-03-20 02:57:11 +00:00
if ( cl . gamespeed < 0.1 )
cl . gamespeed = 1 ;
time * = cl . gamespeed ;
2004-08-23 00:15:46 +00:00
# ifdef WEBCLIENT
FTP_ClientThink ( ) ;
HTTP_CL_Think ( ) ;
# endif
2004-09-30 22:42:34 +00:00
# ifdef PLUGINS
2004-09-24 02:45:41 +00:00
Plug_Tick ( ) ;
2004-09-30 22:42:34 +00:00
# endif
2004-09-24 02:45:41 +00:00
2004-08-23 00:15:46 +00:00
// decide the simulation time
2005-03-22 02:08:01 +00:00
realtime + = realframetime ;
2004-08-23 00:15:46 +00:00
if ( oldrealtime > realtime )
oldrealtime = 0 ;
2004-10-03 10:16:15 +00:00
if ( cl . paused )
cl . gametimemark + = time ;
2004-08-23 00:15:46 +00:00
# ifdef VOICECHAT
CLVC_Poll ( ) ;
# endif
/*
if ( cl_maxfps . value )
fps = cl_maxfps . value ; //max(30.0, min(cl_maxfps.value, 72.0));
else
fps = max ( 30.0 , min ( rate . value / 80.0 , 72.0 ) ) ;
if ( ! cls . timedemo & & realtime - oldrealtime < 1.0 / fps )
return ; // framerate is too high
*/
2004-12-29 03:24:21 +00:00
Mod_Think ( ) ; //think even on idle (which means small walls and a fast cpu can get more surfaces done.
2006-11-03 15:53:04 +00:00
if ( ( cl_netfps . value > 0 | | cls . demoplayback | | cl_indepphysics . value ) )
2005-02-28 07:16:19 +00:00
{ //limit the fps freely, and expect the netfps to cope.
2006-11-03 15:53:04 +00:00
if ( cl_maxfps . value > 0 )
if ( ( realtime - oldrealtime ) < 1 / cl_maxfps . value )
return ;
2005-02-28 07:16:19 +00:00
}
else
{
2005-04-16 16:21:27 +00:00
realtime + = spare / 1000 ; //don't use it all!
2005-12-21 03:07:33 +00:00
spare = CL_FilterTime ( ( realtime - oldrealtime ) * 1000 , ( cl_maxfps . value > 0 | | cls . protocol ! = CP_QUAKEWORLD ) ? cl_maxfps . value : cl_netfps . value ) ;
2005-04-16 16:21:27 +00:00
if ( ! spare )
2005-02-28 07:16:19 +00:00
return ;
2005-04-16 16:21:27 +00:00
if ( spare < 0 | | cls . state < ca_onserver )
spare = 0 ; //uncapped.
if ( spare > 10 )
spare = 10 ;
realtime - = spare / 1000 ; //don't use it all!
2005-02-28 07:16:19 +00:00
}
2004-08-23 00:15:46 +00:00
2005-03-22 02:08:01 +00:00
host_frametime = ( realtime - oldrealtime ) * cl . gamespeed ;
2006-03-06 01:41:09 +00:00
if ( ! cl . paused )
{
cl . ktprogametime + = host_frametime ;
}
2004-08-23 00:15:46 +00:00
oldrealtime = realtime ;
2005-04-16 16:21:27 +00:00
2005-12-21 03:07:33 +00:00
CL_ProgressDemoTime ( ) ;
2005-04-16 16:21:27 +00:00
2005-05-26 12:55:34 +00:00
# if defined(Q2CLIENT)
if ( cls . protocol = = CP_QUAKE2 )
2005-04-16 16:21:27 +00:00
cl . time + = host_frametime ;
# endif
2004-08-23 00:15:46 +00:00
// if (host_frametime > 0.2)
// host_frametime = 0.2;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
// get new key events
Sys_SendKeyEvents ( ) ;
// allow mice or other external controllers to add commands
IN_Commands ( ) ;
// process console commands
Cbuf_Execute ( ) ;
2004-11-29 01:21:00 +00:00
# ifndef CLIENTONLY
2004-08-23 00:15:46 +00:00
if ( isDedicated ) //someone changed it.
return ;
2004-11-29 01:21:00 +00:00
# endif
2004-08-23 00:15:46 +00:00
2004-12-29 03:24:21 +00:00
cls . framecount + + ;
2005-05-08 05:56:03 +00:00
RSpeedRemark ( ) ;
2005-03-12 23:40:42 +00:00
CL_UseIndepPhysics ( ! ! cl_indepphysics . value ) ;
2005-02-28 07:16:19 +00:00
CL_AllowIndependantSendCmd ( false ) ;
2004-08-23 00:15:46 +00:00
// fetch results from server
CL_ReadPackets ( ) ;
2005-02-28 07:16:19 +00:00
CL_AllowIndependantSendCmd ( true ) ;
2004-08-23 00:15:46 +00:00
// send intentions now
// resend a connection request if necessary
if ( cls . state = = ca_disconnected )
{
IN_Move ( NULL , 0 ) ;
CL_CheckForResend ( ) ;
}
else
{
2005-03-12 23:40:42 +00:00
extern qboolean runningindepphys ;
if ( ! runningindepphys )
2005-03-22 02:08:01 +00:00
CL_SendCmd ( host_frametime / cl . gamespeed ) ;
2004-08-23 00:15:46 +00:00
2005-02-12 18:56:04 +00:00
if ( cls . state = = ca_onserver & & cl . validsequence & & cl . worldmodel )
{ // first update is the final signon stage
2005-07-14 01:57:34 +00:00
CL_MakeActive ( " QuakeWorld " ) ;
2004-08-23 00:15:46 +00:00
}
}
2005-04-16 16:21:27 +00:00
RSpeedEnd ( RSPEED_PROTOCOL ) ;
2004-12-15 19:54:09 +00:00
2004-08-23 00:15:46 +00:00
// update video
if ( host_speeds . value )
time1 = Sys_DoubleTime ( ) ;
if ( SCR_UpdateScreen )
{
extern mleaf_t * r_viewleaf ;
2005-04-16 16:21:27 +00:00
extern cvar_t scr_chatmodecvar ;
if ( scr_chatmodecvar . value & & ! cl . intermission )
scr_chatmode = ( cl . spectator & & cl . splitclients < 2 & & cls . state = = ca_active ) ? 2 : 1 ;
else
scr_chatmode = 0 ;
2004-08-23 00:15:46 +00:00
SCR_UpdateScreen ( ) ;
if ( cls . state > = ca_active & & r_viewleaf )
SNDDMA_SetUnderWater ( r_viewleaf - > contents < = Q1CONTENTS_WATER ) ;
else
SNDDMA_SetUnderWater ( false ) ;
}
if ( host_speeds . value )
time2 = Sys_DoubleTime ( ) ;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
// update audio
2005-08-19 17:01:55 +00:00
# ifdef CSQC_DAT
2005-08-11 04:14:33 +00:00
if ( CSQC_SettingListener ( ) )
S_ExtraUpdate ( ) ;
2005-08-19 17:01:55 +00:00
else
# endif
if ( cls . state = = ca_active )
2007-02-23 00:21:33 +00:00
{
if ( cls . protocol = = CP_QUAKE3 )
S_ExtraUpdate ( ) ;
else
S_Update ( r_origin , vpn , vright , vup ) ;
}
2004-08-23 00:15:46 +00:00
else
S_Update ( vec3_origin , vec3_origin , vec3_origin , vec3_origin ) ;
CDAudio_Update ( ) ;
if ( host_speeds . value )
{
pass1 = ( time1 - time3 ) * 1000 ;
time3 = Sys_DoubleTime ( ) ;
pass2 = ( time2 - time1 ) * 1000 ;
pass3 = ( time3 - time2 ) * 1000 ;
Con_TPrintf ( TLC_HOSTSPEEDSOUTPUT ,
pass1 + pass2 + pass3 , pass1 , pass2 , pass3 ) ;
}
host_framecount + + ;
fps_count + + ;
IN_Commands ( ) ;
// process console commands
Cbuf_Execute ( ) ;
2006-01-04 00:44:34 +00:00
CL_RequestNextDownload ( ) ;
2006-09-17 00:59:22 +00:00
CL_QTVPoll ( ) ;
2004-08-23 00:15:46 +00:00
}
static void simple_crypt ( char * buf , int len )
{
while ( len - - )
* buf + + ^ = 0xff ;
}
void Host_FixupModelNames ( void )
{
simple_crypt ( emodel_name , sizeof ( emodel_name ) - 1 ) ;
simple_crypt ( pmodel_name , sizeof ( pmodel_name ) - 1 ) ;
simple_crypt ( prespawn_name , sizeof ( prespawn_name ) - 1 ) ;
simple_crypt ( modellist_name , sizeof ( modellist_name ) - 1 ) ;
simple_crypt ( soundlist_name , sizeof ( soundlist_name ) - 1 ) ;
}
2005-11-30 01:20:53 +00:00
# ifdef Q3CLIENT
void CL_ReadCDKey ( void )
{ //q3 cdkey
//you don't need one, just use a server without sv_strictauth set to 0.
char * buffer ;
buffer = COM_LoadTempFile ( " q3key " ) ;
if ( buffer ) //a cdkey is meant to be 16 chars
{
cvar_t * var ;
char * chr ;
for ( chr = buffer ; * chr ; chr + + )
{
if ( * ( unsigned char * ) chr < ' ' )
{
* chr = ' \0 ' ; //don't get more than one line.
break ;
}
}
2006-06-12 22:05:41 +00:00
var = Cvar_Get ( " cl_cdkey " , buffer , CVAR_LATCH | CVAR_NOUNSAFEEXPAND , " Q3 compatability " ) ;
2005-11-30 01:20:53 +00:00
}
}
# endif
2004-08-23 00:15:46 +00:00
//============================================================================
/*
= = = = = = = = = = = = = = = = = = = =
Host_Init
= = = = = = = = = = = = = = = = = = = =
*/
void Host_Init ( quakeparms_t * parms )
{
2005-02-06 02:47:36 +00:00
int i ;
2005-01-05 08:01:19 +00:00
int qrc , hrc , def ;
2004-08-23 00:15:46 +00:00
extern cvar_t vid_renderer ;
COM_InitArgv ( parms - > argc , parms - > argv ) ;
2004-11-23 01:10:10 +00:00
if ( setjmp ( host_abort ) )
Sys_Error ( " Host_Init: An error occured. Try the -condebug commandline parameter \n " ) ;
2004-08-23 00:15:46 +00:00
if ( COM_CheckParm ( " -minmemory " ) )
parms - > memsize = MINIMUM_MEMORY ;
host_parms = * parms ;
if ( parms - > memsize < MINIMUM_MEMORY )
Sys_Error ( " Only %4.1f megs of memory reported, can't execute game " , parms - > memsize / ( float ) 0x100000 ) ;
Memory_Init ( parms - > membase , parms - > memsize ) ;
2005-01-07 02:44:12 +00:00
2007-06-20 00:02:54 +00:00
Sys_Init ( ) ;
2005-01-07 02:44:12 +00:00
COM_ParsePlusSets ( ) ;
2004-08-23 00:15:46 +00:00
Cbuf_Init ( ) ;
Cmd_Init ( ) ;
V_Init ( ) ;
COM_Init ( ) ;
# ifdef Q2BSPS
CM_Init ( ) ;
# endif
Host_FixupModelNames ( ) ;
NET_Init ( ) ;
NET_InitClient ( ) ;
Netchan_Init ( ) ;
Renderer_Init ( ) ;
// W_LoadWadFile ("gfx.wad");
Key_Init ( ) ;
2005-06-15 04:45:26 +00:00
Con_Init ( ) ;
M_Init ( ) ;
2005-04-18 17:12:18 +00:00
# ifndef _WIN32
2004-08-23 00:15:46 +00:00
IN_Init ( ) ;
CDAudio_Init ( ) ;
// VID_Init (host_basepal);
// Draw_Init ();
// SCR_Init ();
// R_Init ();
S_Init ( ) ;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
cls . state = ca_disconnected ;
Sbar_Init ( ) ;
CL_Init ( ) ;
# else
S_Init ( ) ;
cls . state = ca_disconnected ;
CDAudio_Init ( ) ;
Sbar_Init ( ) ;
CL_Init ( ) ;
IN_Init ( ) ;
# endif
TranslateInit ( ) ;
# ifndef CLIENTONLY
SV_Init ( parms ) ;
# endif
# ifdef TEXTEDITOR
Editor_Init ( ) ;
# endif
2005-01-15 17:37:11 +00:00
# ifdef PLUGINS
Plug_Init ( ) ;
# endif
2005-11-03 23:49:49 +00:00
# ifdef CL_MASTER
2005-10-07 16:27:20 +00:00
Master_SetupSockets ( ) ;
2005-11-03 23:49:49 +00:00
# endif
2005-09-08 02:05:36 +00:00
2005-11-30 01:20:53 +00:00
# ifdef Q3CLIENT
CL_ReadCDKey ( ) ;
# endif
2004-08-23 00:15:46 +00:00
// Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
Con_TPrintf ( TL_HEAPSIZE , parms - > memsize / ( 1024 * 1024.0 ) ) ;
2005-04-26 16:04:12 +00:00
Cbuf_AddText ( " cl_warncmd 0 \n " , RESTRICT_LOCAL ) ;
2004-08-23 00:15:46 +00:00
Cbuf_AddText ( " +mlook \n " , RESTRICT_LOCAL ) ; //fixme: this is bulky, only exec one of these.
2005-01-05 08:01:19 +00:00
2005-02-06 02:47:36 +00:00
//who should we imitate?
qrc = COM_FDepthFile ( " quake.rc " , true ) ; //q1
hrc = COM_FDepthFile ( " hexen.rc " , true ) ; //h2
def = COM_FDepthFile ( " default.cfg " , true ) ; //q2/q3
2005-01-05 08:01:19 +00:00
2005-07-02 00:15:19 +00:00
if ( qrc < = def & & qrc < = hrc & & qrc ! = 0x7fffffff )
2005-01-07 02:44:12 +00:00
Cbuf_AddText ( " exec quake.rc \n " , RESTRICT_LOCAL ) ;
2005-07-02 00:15:19 +00:00
else if ( hrc < = def & & hrc ! = 0x7fffffff )
2005-01-07 02:44:12 +00:00
Cbuf_AddText ( " exec hexen.rc \n " , RESTRICT_LOCAL ) ;
else
2005-01-05 08:01:19 +00:00
{ //they didn't give us an rc file!
2005-08-26 22:56:51 +00:00
Cbuf_AddText ( " bind ~ toggleconsole \n " , RESTRICT_LOCAL ) ; //we expect default.cfg to not exist. :(
2005-01-05 08:01:19 +00:00
Cbuf_AddText ( " exec default.cfg \n " , RESTRICT_LOCAL ) ;
Cbuf_AddText ( " exec config.cfg \n " , RESTRICT_LOCAL ) ;
2005-09-08 02:05:36 +00:00
if ( COM_FCheckExists ( " q3config.cfg " ) )
Cbuf_AddText ( " exec q3config.cfg \n " , RESTRICT_LOCAL ) ;
2005-01-05 08:01:19 +00:00
Cbuf_AddText ( " exec autoexec.cfg \n " , RESTRICT_LOCAL ) ;
}
2004-08-23 00:15:46 +00:00
Cbuf_AddText ( " exec fte.cfg \n " , RESTRICT_LOCAL ) ;
2005-01-05 08:01:19 +00:00
Cbuf_AddText ( " cl_warncmd 1 \n " , RESTRICT_LOCAL ) ; //and then it's allowed to start moaning.
2004-08-23 00:15:46 +00:00
Hunk_AllocName ( 0 , " -HOST_HUNKLEVEL- " ) ;
host_hunklevel = Hunk_LowMark ( ) ;
2005-03-20 02:57:11 +00:00
2005-06-14 04:52:10 +00:00
R_SetRenderer ( - 1 ) ; //set the renderer stuff to unset...
2004-08-23 00:15:46 +00:00
host_initialized = true ;
2005-07-01 19:23:00 +00:00
Cbuf_Execute ( ) ; //if the server initialisation causes a problem, give it a place to abort to
2005-01-07 02:44:12 +00:00
Cmd_StuffCmds ( ) ;
2005-03-20 02:57:11 +00:00
2005-01-07 02:44:12 +00:00
Cbuf_Execute ( ) ; //if the server initialisation causes a problem, give it a place to abort to
2005-03-20 02:57:11 +00:00
2005-09-08 02:05:36 +00:00
2005-02-06 02:47:36 +00:00
//assuming they didn't use any waits in thier config (fools)
//the configs should be fully loaded.
//so convert the backwards compable commandline parameters in cvar sets.
if ( COM_CheckParm ( " -window " ) | | COM_CheckParm ( " -startwindowed " ) )
Cvar_Set ( Cvar_FindVar ( " vid_fullscreen " ) , " 0 " ) ;
if ( COM_CheckParm ( " -fullscreen " ) )
Cvar_Set ( Cvar_FindVar ( " vid_fullscreen " ) , " 1 " ) ;
2005-03-20 02:57:11 +00:00
2005-02-06 02:47:36 +00:00
if ( ( i = COM_CheckParm ( " -width " ) ) ) //width on it's own also sets height
2004-08-23 00:15:46 +00:00
{
2005-02-06 02:47:36 +00:00
Cvar_Set ( Cvar_FindVar ( " vid_width " ) , com_argv [ i + 1 ] ) ;
2005-08-08 01:10:42 +00:00
Cvar_SetValue ( Cvar_FindVar ( " vid_height " ) , ( atoi ( com_argv [ i + 1 ] ) / 4 ) * 3 ) ;
2004-08-23 00:15:46 +00:00
}
2005-02-06 02:47:36 +00:00
if ( ( i = COM_CheckParm ( " -height " ) ) )
Cvar_Set ( Cvar_FindVar ( " vid_height " ) , com_argv [ i + 1 ] ) ;
if ( ( i = COM_CheckParm ( " -conwidth " ) ) ) //width on it's own also sets height
{
Cvar_Set ( Cvar_FindVar ( " vid_conwidth " ) , com_argv [ i + 1 ] ) ;
2005-08-08 01:10:42 +00:00
Cvar_SetValue ( Cvar_FindVar ( " vid_conheight " ) , ( atoi ( com_argv [ i + 1 ] ) / 4 ) * 3 ) ;
2005-02-06 02:47:36 +00:00
}
if ( ( i = COM_CheckParm ( " -conheight " ) ) )
Cvar_Set ( Cvar_FindVar ( " vid_conheight " ) , com_argv [ i + 1 ] ) ;
if ( ( i = COM_CheckParm ( " -bpp " ) ) )
Cvar_Set ( Cvar_FindVar ( " vid_bpp " ) , com_argv [ i + 1 ] ) ;
2006-04-15 03:31:23 +00:00
if ( COM_CheckParm ( " -current " ) )
Cvar_Set ( Cvar_FindVar ( " vid_desktopsettings " ) , " 1 " ) ;
2005-07-02 00:15:19 +00:00
Cvar_ApplyLatches ( CVAR_RENDERERLATCH ) ;
2005-06-15 04:45:26 +00:00
//-1 means 'never set'
if ( qrenderer = = - 1 & & * vid_renderer . string )
2004-08-23 00:15:46 +00:00
{
Cmd_ExecuteString ( " vid_restart \n " , RESTRICT_LOCAL ) ;
}
2005-06-15 04:45:26 +00:00
if ( qrenderer = = - 1 )
{ //we still failed. Try again, but use the default renderer.
Cvar_Set ( & vid_renderer , " " ) ;
2004-08-23 00:15:46 +00:00
Cmd_ExecuteString ( " vid_restart \n " , RESTRICT_LOCAL ) ;
}
2005-06-15 04:45:26 +00:00
if ( qrenderer = = - 1 )
Sys_Error ( " No renderer was set! \n " ) ;
2004-08-23 00:15:46 +00:00
2005-06-14 04:52:10 +00:00
if ( qrenderer = = QR_NONE )
Con_Printf ( " Use the setrenderer command to use a gui \n " ) ;
2005-09-09 23:40:55 +00:00
# ifdef VM_UI
2004-08-23 00:15:46 +00:00
UI_Init ( ) ;
2005-09-09 23:40:55 +00:00
# endif
2004-08-23 00:15:46 +00:00
2005-02-06 02:47:36 +00:00
# ifndef NOMEDIA
2006-03-06 01:41:09 +00:00
if ( ! cls . demofile & & ! cls . state & & ! Media_PlayingFullScreen ( ) )
2005-02-06 02:47:36 +00:00
{
2005-04-26 16:04:12 +00:00
int ol_depth ;
int idcin_depth ;
int idroq_depth ;
idcin_depth = COM_FDepthFile ( " video/idlog.cin " , true ) ; //q2
idroq_depth = COM_FDepthFile ( " video/idlogo.roq " , true ) ; //q2
ol_depth = COM_FDepthFile ( " video/openinglogos.roq " , true ) ; //jk2
2005-06-29 21:20:34 +00:00
if ( ol_depth ! = 0x7fffffff & & ( ol_depth < = idroq_depth | | ol_depth < = idcin_depth ) )
2005-04-26 16:04:12 +00:00
Media_PlayFilm ( " video/openinglogos.roq " ) ;
2005-06-29 21:20:34 +00:00
else if ( idroq_depth ! = 0x7fffffff & & idroq_depth < = idcin_depth )
2005-06-15 04:45:26 +00:00
Media_PlayFilm ( " video/idlogo.roq " ) ;
2005-06-29 21:20:34 +00:00
else if ( idcin_depth ! = 0x7fffffff )
2005-04-26 16:04:12 +00:00
Media_PlayFilm ( " video/idlog.cin " ) ;
2005-02-06 02:47:36 +00:00
}
# endif
2004-08-23 00:15:46 +00:00
Con_TPrintf ( TL_NL ) ;
2005-10-04 21:08:06 +00:00
Con_TPrintf ( TL_VERSION , DISTRIBUTION , build_number ( ) ) ;
2004-08-23 00:15:46 +00:00
Con_TPrintf ( TL_NL ) ;
Con_TPrintf ( TLC_QUAKEWORLD_INITED ) ;
2005-01-05 08:01:19 +00:00
Con_DPrintf ( " This program is free software; you can redistribute it and/or "
2004-08-23 00:15:46 +00:00
" 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. "
" \n "
" This program is distributed in the hope that it will be useful, "
" but WITHOUT ANY WARRANTY; without even the implied warranty of "
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
" \n "
" See the GNU General Public License for more details. \n " ) ;
}
/*
= = = = = = = = = = = = = = =
Host_Shutdown
FIXME : this is a callback from Sys_Quit and Sys_Error . It would be better
to run quit through here before the final handoff to the sys code .
= = = = = = = = = = = = = = =
*/
void Host_Shutdown ( void )
{
static qboolean isdown = false ;
2005-06-15 04:45:26 +00:00
2004-08-23 00:15:46 +00:00
if ( isdown )
{
Sys_Printf ( " recursive shutdown \n " ) ;
return ;
}
isdown = true ;
2005-09-09 23:40:55 +00:00
# ifdef VM_UI
2004-08-23 00:15:46 +00:00
UI_Stop ( ) ;
2005-09-09 23:40:55 +00:00
# endif
2004-08-23 00:15:46 +00:00
2005-06-15 04:45:26 +00:00
Host_WriteConfiguration ( ) ;
2004-08-23 00:15:46 +00:00
CDAudio_Shutdown ( ) ;
S_Shutdown ( ) ;
IN_Shutdown ( ) ;
if ( VID_DeInit )
VID_DeInit ( ) ;
2004-11-29 01:21:00 +00:00
# ifndef CLIENTONLY
2004-08-23 00:15:46 +00:00
SV_Shutdown ( ) ;
# else
NET_Shutdown ( ) ;
# endif
Cvar_Shutdown ( ) ;
Validation_FlushFileList ( ) ;
}
2004-11-29 01:21:00 +00:00
# ifdef CLIENTONLY
void SV_EndRedirect ( void )
{
}
2004-12-09 23:31:48 +00:00
# endif