2004-08-23 00:15:46 +00:00
/*
Copyright ( C ) 1996 - 1997 Id Software , Inc .
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
2005-07-03 15:16:20 +00:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
2004-08-23 00:15:46 +00:00
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
2013-03-31 04:21:08 +00:00
# include "quakedef.h"
2004-08-23 00:15:46 +00:00
2004-11-29 01:21:00 +00:00
# ifndef CLIENTONLY
2007-10-25 07:29:59 +00:00
# ifndef INVALID_SOCKET
2005-12-21 03:07:33 +00:00
# define INVALID_SOCKET -1
# endif
2010-08-14 03:17:33 +00:00
int sv_allow_cheats ;
qboolean SV_MayCheat ( void )
{
if ( sv_allow_cheats = = 2 )
return sv . allocated_client_slots = = 1 ;
return sv_allow_cheats ! = 0 ;
}
2004-08-23 00:15:46 +00:00
extern cvar_t cl_warncmd ;
2006-02-11 02:09:43 +00:00
cvar_t sv_cheats = SCVARF ( " sv_cheats " , " 0 " , CVAR_LATCH ) ;
2004-08-23 00:15:46 +00:00
extern redirect_t sv_redirected ;
extern cvar_t sv_public ;
//generic helper function for naming players.
client_t * SV_GetClientForString ( char * name , int * id )
{
int i ;
2009-10-06 00:41:42 +00:00
char * s ;
2004-08-23 00:15:46 +00:00
char nicename [ 80 ] ;
2009-10-06 00:41:42 +00:00
char niceclname [ 80 ] ;
2004-08-23 00:15:46 +00:00
client_t * cl ;
int first = 0 ;
if ( id & & * id ! = - 1 )
first = * id ;
if ( ! strcmp ( name , " * " ) ) //match with all
{
for ( i = first , cl = svs . clients + first ; i < sv . allocated_client_slots ; i + + , cl + + )
{
if ( cl - > state < = cs_zombie )
continue ;
* id = i + 1 ;
return cl ;
}
* id = sv . allocated_client_slots ;
return NULL ;
}
//check to make sure it's all an int
for ( s = name ; * s ; s + + )
{
if ( * s < ' 0 ' | | * s > ' 9 ' )
break ;
}
//we got to the end of the string and found only numbers. - it's a uid.
if ( ! * s )
{
int uid = Q_atoi ( name ) ;
for ( i = first , cl = svs . clients ; i < sv . allocated_client_slots ; i + + , cl + + )
{
if ( cl - > state < = cs_zombie )
continue ;
if ( cl - > userid = = uid )
{
2006-04-02 23:47:27 +00:00
if ( id )
* id = sv . allocated_client_slots ;
2004-08-23 00:15:46 +00:00
return cl ;
}
}
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
return NULL ;
2005-07-03 15:16:20 +00:00
}
2004-08-23 00:15:46 +00:00
for ( i = first , cl = svs . clients + first ; i < sv . allocated_client_slots ; i + + , cl + + )
{
if ( cl - > state < = cs_zombie )
continue ;
2009-10-06 00:41:42 +00:00
deleetstring ( niceclname , cl - > name ) ;
deleetstring ( nicename , name ) ;
2004-08-23 00:15:46 +00:00
2009-10-06 00:41:42 +00:00
if ( strstr ( niceclname , nicename ) )
2004-08-23 00:15:46 +00:00
{
2006-04-02 23:47:27 +00:00
if ( id )
* id = i + 1 ;
2004-08-23 00:15:46 +00:00
return cl ;
}
}
return NULL ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
OPERATOR CONSOLE ONLY COMMANDS
These commands can only be entered from stdin or by a remote operator datagram
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
/*
= = = = = = = = = = = = = = = = = = = =
SV_SetMaster_f
Make a master server current
= = = = = = = = = = = = = = = = = = = =
*/
2005-09-26 08:07:26 +00:00
void Master_ClearAll ( void ) ;
2009-11-04 21:16:50 +00:00
void Master_ReResolve ( void ) ;
2005-09-26 08:07:26 +00:00
void Master_Add ( char * stringadr ) ;
2004-08-23 00:15:46 +00:00
void SV_SetMaster_f ( void )
{
int i ;
Cvar_Set ( & sv_public , " 1 " ) ; //go public.
2005-05-26 12:55:34 +00:00
Master_ClearAll ( ) ;
2004-08-23 00:15:46 +00:00
2005-05-26 12:55:34 +00:00
if ( ! strcmp ( Cmd_Argv ( 1 ) , " none " ) )
2004-08-23 00:15:46 +00:00
{
2005-05-26 12:55:34 +00:00
Con_Printf ( " Entering no-master mode \n " ) ;
return ;
}
2004-08-23 00:15:46 +00:00
2005-05-26 12:55:34 +00:00
for ( i = 1 ; i < Cmd_Argc ( ) ; i + + )
{
Master_Add ( Cmd_Argv ( i ) ) ;
2004-08-23 00:15:46 +00:00
}
svs . last_heartbeat = - 99999 ;
}
/*
= = = = = = = = = = = = = = = = = =
SV_Quit_f
= = = = = = = = = = = = = = = = = =
*/
void SV_Quit_f ( void )
{
SV_FinalMessage ( " server shutdown \n " ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Shutting down. \n " ) ;
2004-08-23 00:15:46 +00:00
SV_Shutdown ( ) ;
Sys_Quit ( ) ;
}
/*
= = = = = = = = = = = =
SV_Fraglogfile_f
= = = = = = = = = = = =
*/
void SV_Fraglogfile_f ( void )
{
char name [ MAX_OSPATH ] ;
int i ;
if ( sv_fraglogfile )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Frag file logging off. \n " ) ;
2005-12-21 03:07:33 +00:00
VFS_CLOSE ( sv_fraglogfile ) ;
2004-08-23 00:15:46 +00:00
sv_fraglogfile = NULL ;
return ;
}
// find an unused name
for ( i = 0 ; i < 1000 ; i + + )
{
2005-12-21 03:07:33 +00:00
sprintf ( name , " frag_%i.log " , i ) ;
2006-01-02 22:33:23 +00:00
sv_fraglogfile = FS_OpenVFS ( name , " rb " , FS_GAME ) ;
2004-08-23 00:15:46 +00:00
if ( ! sv_fraglogfile )
{ // can't read it, so create this one
2006-01-02 22:33:23 +00:00
sv_fraglogfile = FS_OpenVFS ( name , " wb " , FS_GAME ) ;
2004-08-23 00:15:46 +00:00
if ( ! sv_fraglogfile )
i = 1000 ; // give error
break ;
}
2005-12-21 03:07:33 +00:00
VFS_CLOSE ( sv_fraglogfile ) ;
2004-08-23 00:15:46 +00:00
}
if ( i = = 1000 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Can't open any logfiles. \n " ) ;
2004-08-23 00:15:46 +00:00
sv_fraglogfile = NULL ;
return ;
}
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Logging frags to %s. \n " , name ) ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
SV_SetPlayer
Sets host_client and sv_player to the player with idnum Cmd_Argv ( 1 )
= = = = = = = = = = = = = = = = = =
*/
qboolean SV_SetPlayer ( void )
{
client_t * cl ;
int i ;
int idnum ;
idnum = atoi ( Cmd_Argv ( 1 ) ) ;
2011-04-25 03:25:22 +00:00
for ( i = 0 , cl = svs . clients ; i < sv . allocated_client_slots ; i + + , cl + + )
2004-08-23 00:15:46 +00:00
{
if ( ! cl - > state )
continue ;
if ( cl - > userid = = idnum )
{
host_client = cl ;
sv_player = host_client - > edict ;
return true ;
}
}
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Userid %i is not on the server \n " , idnum ) ;
2004-08-23 00:15:46 +00:00
return false ;
}
/*
= = = = = = = = = = = = = = = = = =
SV_God_f
Sets client to godmode
= = = = = = = = = = = = = = = = = =
*/
void SV_God_f ( void )
{
2010-08-14 03:17:33 +00:00
if ( ! SV_MayCheat ( ) )
2004-08-23 00:15:46 +00:00
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " You must run the server with +sv_cheats 1 to enable this command. \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
if ( ! SV_SetPlayer ( ) )
return ;
2007-07-27 21:24:31 +00:00
SV_LogPlayer ( host_client , " god cheat " ) ;
2005-03-28 00:11:59 +00:00
sv_player - > v - > flags = ( int ) sv_player - > v - > flags ^ FL_GODMODE ;
if ( ( int ) sv_player - > v - > flags & FL_GODMODE )
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( host_client , PRINT_HIGH , " godmode ON \n " ) ;
2004-08-23 00:15:46 +00:00
else
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( host_client , PRINT_HIGH , " godmode OFF \n " ) ;
2004-08-23 00:15:46 +00:00
}
void SV_Noclip_f ( void )
{
2010-08-14 03:17:33 +00:00
if ( ! SV_MayCheat ( ) )
2004-08-23 00:15:46 +00:00
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " You must run the server with +sv_cheats 1 to enable this command. \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
if ( ! SV_SetPlayer ( ) )
return ;
2007-07-27 21:24:31 +00:00
SV_LogPlayer ( host_client , " noclip cheat " ) ;
2005-03-28 00:11:59 +00:00
if ( sv_player - > v - > movetype ! = MOVETYPE_NOCLIP )
2004-08-23 00:15:46 +00:00
{
2005-03-28 00:11:59 +00:00
sv_player - > v - > movetype = MOVETYPE_NOCLIP ;
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( host_client , PRINT_HIGH , " noclip ON \n " ) ;
2004-08-23 00:15:46 +00:00
}
else
{
2005-03-28 00:11:59 +00:00
sv_player - > v - > movetype = MOVETYPE_WALK ;
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( host_client , PRINT_HIGH , " noclip OFF \n " ) ;
2004-08-23 00:15:46 +00:00
}
}
/*
= = = = = = = = = = = = = = = = = =
SV_Give_f
= = = = = = = = = = = = = = = = = =
*/
void SV_Give_f ( void )
{
char * t ;
int v ;
2005-07-03 15:16:20 +00:00
2013-08-21 07:14:39 +00:00
if ( ! svprogfuncs )
return ;
2010-08-14 03:17:33 +00:00
if ( ! SV_MayCheat ( ) )
2004-08-23 00:15:46 +00:00
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " You must run the server with +sv_cheats 1 to enable this command. \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
2005-07-03 15:16:20 +00:00
2008-11-09 22:29:28 +00:00
if ( developer . value )
2005-01-04 08:01:03 +00:00
{
int oldself ;
oldself = pr_global_struct - > self ;
2009-11-04 21:16:50 +00:00
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , sv . world . edicts ) ;
2005-01-04 08:01:03 +00:00
Con_Printf ( " Result: %s \n " , svprogfuncs - > EvaluateDebugString ( svprogfuncs , Cmd_Args ( ) ) ) ;
pr_global_struct - > self = oldself ;
2008-11-09 22:29:28 +00:00
}
if ( ! SV_SetPlayer ( ) )
{
2004-08-23 00:15:46 +00:00
return ;
2005-01-04 08:01:03 +00:00
}
2004-08-23 00:15:46 +00:00
2007-07-27 21:24:31 +00:00
SV_LogPlayer ( host_client , " give cheat " ) ;
2004-08-23 00:15:46 +00:00
t = Cmd_Argv ( 2 ) ;
v = atoi ( Cmd_Argv ( 3 ) ) ;
2005-07-03 15:16:20 +00:00
2008-11-09 22:29:28 +00:00
switch ( ( t [ 1 ] = = 0 ) ? t [ 0 ] : 0 )
2004-08-23 00:15:46 +00:00
{
case ' 2 ' :
case ' 3 ' :
case ' 4 ' :
case ' 5 ' :
case ' 6 ' :
case ' 7 ' :
case ' 8 ' :
case ' 9 ' :
2005-03-28 00:11:59 +00:00
sv_player - > v - > items = ( int ) sv_player - > v - > items | IT_SHOTGUN < < ( t [ 0 ] - ' 2 ' ) ;
2004-08-23 00:15:46 +00:00
break ;
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
case ' s ' :
2005-03-28 00:11:59 +00:00
sv_player - > v - > ammo_shells = v ;
2005-07-03 15:16:20 +00:00
break ;
2004-08-23 00:15:46 +00:00
case ' n ' :
2005-03-28 00:11:59 +00:00
sv_player - > v - > ammo_nails = v ;
2005-07-03 15:16:20 +00:00
break ;
2004-08-23 00:15:46 +00:00
case ' r ' :
2005-03-28 00:11:59 +00:00
sv_player - > v - > ammo_rockets = v ;
2005-07-03 15:16:20 +00:00
break ;
2004-08-23 00:15:46 +00:00
case ' h ' :
2005-03-28 00:11:59 +00:00
sv_player - > v - > health = v ;
2005-07-03 15:16:20 +00:00
break ;
2004-08-23 00:15:46 +00:00
case ' c ' :
2005-03-28 00:11:59 +00:00
sv_player - > v - > ammo_cells = v ;
2005-01-04 08:01:03 +00:00
break ;
default :
{
int oldself ;
oldself = pr_global_struct - > self ;
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , sv_player ) ;
2008-11-09 22:29:28 +00:00
Cmd_ShiftArgs ( 1 , false ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Result: %s \n " , svprogfuncs - > EvaluateDebugString ( svprogfuncs , Cmd_Args ( ) ) ) ;
2005-01-04 08:01:03 +00:00
pr_global_struct - > self = oldself ;
}
2004-08-23 00:15:46 +00:00
}
}
2013-06-23 03:59:48 +00:00
int QDECL ShowMapList ( const char * name , int flags , void * parm , searchpathfuncs_t * spath )
2004-08-23 00:15:46 +00:00
{
if ( name [ 5 ] = = ' b ' & & name [ 6 ] = = ' _ ' ) //skip box models
return true ;
Con_Printf ( " %s \n " , name + 5 ) ;
return true ;
}
void SV_MapList_f ( void )
{
COM_EnumerateFiles ( " maps/*.bsp " , ShowMapList , NULL ) ;
2011-12-05 15:23:40 +00:00
COM_EnumerateFiles ( " maps/*.cm " , ShowMapList , NULL ) ;
COM_EnumerateFiles ( " maps/*.hmp " , ShowMapList , NULL ) ;
2004-08-23 00:15:46 +00:00
}
2007-02-23 00:21:33 +00:00
void gtcallback ( struct cvar_s * var , char * oldvalue )
{
Con_Printf ( " g_gametype changed \n " ) ;
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = =
SV_Map_f
2005-07-03 15:16:20 +00:00
handle a
2004-08-23 00:15:46 +00:00
map < mapname >
command from the console or progs .
2011-06-29 18:39:11 +00:00
quirks :
a leading ' * ' means new unit , meaning all old state is flushed regardless of startspot
a ' + ' means ' set nextmap cvar to the following value and otherwise ignore , for q2 compat . only applies if there ' s also a ' . ' and the specified bsp doesn ' t exist , for q1 compat .
just a ' . ' is taken to mean ' restart ' . parms are not changed from their current values , startspot is also unchanged .
' map ' will change map , for most games . note that NQ kicks everyone ( NQ expects you to use changelevel for that ) .
' changelevel ' will not flush the level cache , for h2 compat ( won ' t save current level state in such a situation , as nq would prefer not )
' gamemap ' will save the game to ' save0 ' after loading , for q2 compat
' spmap ' is for q3 and sets ' gametype ' to ' 2 ' , otherwise identical to ' map ' . all other map commands will reset it to ' 0 ' if its ' 2 ' at the time .
2004-08-23 00:15:46 +00:00
= = = = = = = = = = = = = = = = = = = = = =
*/
void SV_Map_f ( void )
{
char level [ MAX_QPATH ] ;
char spot [ MAX_QPATH ] ;
char expanded [ MAX_QPATH ] ;
char * nextserver ;
qboolean issamelevel = false ;
qboolean newunit = false ;
qboolean cinematic = false ;
2005-05-13 10:42:48 +00:00
qboolean waschangelevel = false ;
2005-09-08 01:47:12 +00:00
qboolean wasspmap = false ;
2011-06-29 18:39:11 +00:00
qboolean wasgamemap = false ;
2004-08-23 00:15:46 +00:00
int i ;
char * startspot ;
2007-12-03 11:40:18 +00:00
nextserver = 0 ;
2006-10-15 03:34:05 +00:00
# ifndef SERVERONLY
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
if ( ! Renderer_Started ( ) & & ! isDedicated )
2006-10-15 03:34:05 +00:00
{
Cbuf_AddText ( va ( " wait;map %s \n " , Cmd_Args ( ) ) , Cmd_ExecLevel ) ;
return ;
}
# endif
2004-08-23 00:15:46 +00:00
if ( Cmd_Argc ( ) ! = 2 & & Cmd_Argc ( ) ! = 3 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " map <levelname> : continue game on a new level \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
2005-03-18 06:13:11 +00:00
2007-03-04 19:17:16 +00:00
sv . mapchangelocked = false ;
2006-05-25 21:32:32 +00:00
Q_strncpyz ( level , Cmd_Argv ( 1 ) , sizeof ( level ) ) ;
2004-08-23 00:15:46 +00:00
startspot = ( ( Cmd_Argc ( ) = = 2 ) ? NULL : Cmd_Argv ( 2 ) ) ;
2005-05-13 10:42:48 +00:00
waschangelevel = ! strcmp ( Cmd_Argv ( 0 ) , " changelevel " ) ;
2005-09-08 01:47:12 +00:00
wasspmap = ! strcmp ( Cmd_Argv ( 0 ) , " spmap " ) ;
2011-06-29 18:39:11 +00:00
wasgamemap = ! strcmp ( Cmd_Argv ( 0 ) , " gamemap " ) ;
2005-05-13 10:42:48 +00:00
2009-04-01 22:03:56 +00:00
if ( strcmp ( level , " . " ) ) //restart current
2004-08-23 00:15:46 +00:00
{
2009-04-01 22:03:56 +00:00
snprintf ( expanded , sizeof ( expanded ) , " maps/%s.bsp " , level ) ; // this function and the if statement below, is a quake bugfix which stopped a map called "dm6++.bsp" from loading because of the + sign, quake2 map syntax interprets + character as "intro.cin+base1.bsp", to play a cinematic then load a map after
if ( ! COM_FCheckExists ( expanded ) )
2007-10-25 07:29:59 +00:00
{
2009-04-01 22:03:56 +00:00
nextserver = strchr ( level , ' + ' ) ;
if ( nextserver )
{
* nextserver = ' \0 ' ;
nextserver + + ;
}
2007-10-25 07:29:59 +00:00
}
2004-08-23 00:15:46 +00:00
}
if ( startspot )
{
strcpy ( spot , startspot ) ;
startspot = spot ;
}
else if ( ( startspot = strchr ( level , ' $ ' ) ) )
{
strcpy ( spot , startspot + 1 ) ;
* startspot = ' \0 ' ;
startspot = spot ;
}
else
startspot = NULL ;
if ( ! strcmp ( level , " . " ) ) //restart current
2005-07-03 15:16:20 +00:00
{
2009-04-01 22:03:56 +00:00
//grab the current map name
2006-03-11 03:12:10 +00:00
COM_StripExtension ( COM_SkipPath ( sv . modelname ) , level , sizeof ( level ) ) ;
2004-08-23 00:15:46 +00:00
issamelevel = true ;
2009-04-01 22:03:56 +00:00
if ( ! * level )
2011-10-27 16:16:29 +00:00
{
sv . mapchangelocked = true ;
if ( Cmd_AliasExist ( " startmap_dm " , RESTRICT_LOCAL ) )
{
Cbuf_AddText ( " startmap_dm " , Cmd_ExecLevel ) ;
return ;
}
2009-04-01 22:03:56 +00:00
Q_strncpyz ( level , " start " , sizeof ( level ) ) ;
2011-10-27 16:16:29 +00:00
}
2009-04-01 22:03:56 +00:00
//override the startspot
2004-08-23 00:15:46 +00:00
Q_strncpyz ( spot , Info_ValueForKey ( svs . info , " *startspot " ) , sizeof ( spot ) ) ;
startspot = spot ;
}
// check to make sure the level exists
if ( * level = = ' * ' )
{
memmove ( level , level + 1 , strlen ( level ) ) ;
newunit = true ;
}
2006-09-17 00:59:22 +00:00
# ifndef SERVERONLY
SCR_ImageName ( level ) ;
2012-05-09 15:30:53 +00:00
SCR_SetLoadingStage ( LS_SERVER ) ;
SCR_SetLoadingFile ( " finalize server " ) ;
# else
# define SCR_SetLoadingFile(s)
2006-09-17 00:59:22 +00:00
# endif
COM_FlushFSCache ( ) ;
2004-08-23 00:15:46 +00:00
2011-12-23 03:12:29 +00:00
if ( strlen ( level ) > 4 & &
( ! strcmp ( level + strlen ( level ) - 4 , " .cin " ) | |
! strcmp ( level + strlen ( level ) - 4 , " .roq " ) | |
! strcmp ( level + strlen ( level ) - 4 , " .avi " ) ) )
2004-08-23 00:15:46 +00:00
{
cinematic = true ;
}
else
{
2011-05-20 04:10:46 +00:00
char * exts [ ] = { " maps/%s.bsp " , " maps/%s.cm " , " maps/%s.hmp " , NULL } ;
int i , j ;
for ( i = 0 ; exts [ i ] ; i + + )
2004-08-23 00:15:46 +00:00
{
2011-05-20 04:10:46 +00:00
snprintf ( expanded , sizeof ( expanded ) , exts [ i ] , level ) ;
if ( COM_FCheckExists ( expanded ) )
break ;
}
if ( ! exts [ i ] )
{
for ( i = 0 ; exts [ i ] ; i + + )
2005-09-08 01:47:12 +00:00
{
2011-05-20 04:10:46 +00:00
//doesn't exist, so try lowercase. Q3 does this.
for ( j = 0 ; j < sizeof ( level ) & & level [ j ] ; j + + )
2011-02-25 04:22:14 +00:00
{
2011-05-20 04:10:46 +00:00
if ( level [ j ] > = ' A ' & & level [ j ] < = ' Z ' )
level [ j ] = level [ j ] - ' A ' + ' a ' ;
2011-02-25 04:22:14 +00:00
}
2011-05-20 04:10:46 +00:00
snprintf ( expanded , sizeof ( expanded ) , exts [ i ] , level ) ;
if ( COM_FCheckExists ( expanded ) )
break ;
}
if ( ! exts [ i ] )
{
// FTE is still a Quake engine so report BSP missing
snprintf ( expanded , sizeof ( expanded ) , exts [ 0 ] , level ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Can't find %s \n " , expanded ) ;
2013-06-23 02:17:02 +00:00
# ifndef SERVERONLY
SCR_SetLoadingStage ( LS_NONE ) ;
# endif
2011-05-20 04:10:46 +00:00
return ;
2005-09-08 01:47:12 +00:00
}
2004-08-23 00:15:46 +00:00
}
}
if ( sv . mvdrecording )
SV_MVDStop_f ( ) ;
# ifndef SERVERONLY
if ( ! isDedicated ) //otherwise, info used on map loading isn't present
2005-01-07 02:32:32 +00:00
Cmd_ExecuteString ( va ( " fullserverinfo \" %s \" \n " , svs . info ) , RESTRICT_SERVER ) ;
2004-08-23 00:15:46 +00:00
if ( ! sv . state & & cls . state )
CL_Disconnect ( ) ;
# endif
SV_SaveSpawnparms ( issamelevel ) ;
if ( startspot & & ! issamelevel & & ! newunit )
2005-03-18 06:13:11 +00:00
{
2005-07-03 15:16:20 +00:00
# ifdef Q2SERVER
2005-03-18 06:13:11 +00:00
if ( ge )
{
qboolean savedinuse [ MAX_CLIENTS ] ;
for ( i = 0 ; i < sv . allocated_client_slots ; i + + )
{
savedinuse [ i ] = svs . clients [ i ] . q2edict - > inuse ;
svs . clients [ i ] . q2edict - > inuse = false ;
}
2010-07-25 15:06:38 +00:00
SV_SaveLevelCache ( NULL , false ) ;
2005-03-18 06:13:11 +00:00
for ( i = 0 ; i < sv . allocated_client_slots ; i + + )
{
svs . clients [ i ] . q2edict - > inuse = savedinuse [ i ] ;
}
}
else
2005-07-03 15:16:20 +00:00
# endif
2010-07-25 15:06:38 +00:00
SV_SaveLevelCache ( NULL , false ) ;
2005-03-18 06:13:11 +00:00
}
2004-08-23 00:15:46 +00:00
2005-09-08 01:47:12 +00:00
# ifdef Q3SERVER
{
cvar_t * gametype ;
2007-02-23 00:21:33 +00:00
2009-05-24 10:11:17 +00:00
gametype = Cvar_Get ( " mapname " , " " , CVAR_LATCH | CVAR_SERVERINFO , " Q3 compatability " ) ;
2007-02-23 00:21:33 +00:00
gametype - > flags | = CVAR_SERVERINFO ;
Cvar_ForceSet ( gametype , level ) ;
2013-03-12 22:35:33 +00:00
gametype = Cvar_Get ( " g_gametype " , " " , CVAR_LATCH | CVAR_SERVERINFO , " Q3 compatability " ) ;
2007-02-23 00:21:33 +00:00
gametype - > callback = gtcallback ;
2005-09-08 01:47:12 +00:00
if ( wasspmap )
2007-03-04 19:17:16 +00:00
Cvar_ForceSet ( gametype , " 2 " ) ; //singleplayer
else if ( gametype - > value = = 2 )
2013-03-12 22:35:33 +00:00
Cvar_ForceSet ( gametype , " " ) ; //force to ffa deathmatch
2005-09-08 01:47:12 +00:00
}
# endif
2013-10-29 17:38:22 +00:00
for ( i = 0 ; i < svs . allocated_client_slots ; i + + ) //we need to drop all q2 clients. We don't mix q1w with q2.
2004-08-23 00:15:46 +00:00
{
if ( svs . clients [ i ] . state > cs_connected ) //so that we don't send a datagram
svs . clients [ i ] . state = cs_connected ;
}
# ifndef SERVERONLY
S_StopAllSounds ( true ) ;
2006-09-17 00:59:22 +00:00
// SCR_BeginLoadingPlaque();
SCR_ImageName ( level ) ;
2004-08-23 00:15:46 +00:00
# endif
2013-10-29 17:38:22 +00:00
for ( i = 0 , host_client = svs . clients ; i < svs . allocated_client_slots ; i + + , host_client + + )
2011-12-05 15:23:40 +00:00
{
/*pass the new map's name as an extension, so appropriate loading screens can be shown*/
if ( ISNQCLIENT ( host_client ) )
2013-03-12 22:35:33 +00:00
SV_StuffcmdToClient ( host_client , va ( " reconnect \" %s \" \n " , level ) ) ;
2011-12-05 15:23:40 +00:00
else
SV_StuffcmdToClient ( host_client , va ( " changing \" %s \" \n " , level ) ) ;
2013-08-21 07:14:39 +00:00
host_client - > prespawn_stage = PRESPAWN_INVALID ;
host_client - > prespawn_idx = 0 ;
2011-12-05 15:23:40 +00:00
}
2006-09-17 00:59:22 +00:00
SV_SendMessagesToAll ( ) ;
2012-05-09 15:30:53 +00:00
SCR_SetLoadingFile ( " spawnserver " ) ;
2011-12-23 03:12:29 +00:00
if ( newunit | | ! startspot | | cinematic | | ! SV_LoadLevelCache ( NULL , level , startspot , false ) )
2005-05-13 10:42:48 +00:00
{
if ( waschangelevel & & ! startspot )
startspot = " " ;
2004-08-23 00:15:46 +00:00
SV_SpawnServer ( level , startspot , false , cinematic ) ;
2005-05-13 10:42:48 +00:00
}
2012-05-09 15:30:53 +00:00
SCR_SetLoadingFile ( " server spawned " ) ;
2004-08-23 00:15:46 +00:00
2007-06-20 00:02:54 +00:00
//SV_BroadcastCommand ("cmd new\n");
2013-10-29 17:38:22 +00:00
for ( i = 0 , host_client = svs . clients ; i < svs . allocated_client_slots ; i + + , host_client + + )
2007-06-20 00:02:54 +00:00
{ //this expanded code cuts out a packet when changing maps...
//but more usefully, it stops dp(and probably nq too) from timing out.
2013-03-12 22:35:33 +00:00
//make sure its all reset.
host_client - > sentents . num_entities = 0 ;
host_client - > ratetime = 0 ;
if ( host_client - > pendingentbits )
host_client - > pendingentbits [ 0 ] = UF_REMOVE ;
2007-06-20 00:02:54 +00:00
if ( host_client - > controller )
continue ;
if ( host_client - > state > = cs_connected )
{
2008-11-09 22:29:28 +00:00
if ( host_client - > protocol = = SCP_QUAKE3 )
continue ;
2009-07-25 11:05:06 +00:00
if ( host_client - > protocol = = SCP_BAD )
continue ;
2008-11-09 22:29:28 +00:00
2007-06-20 00:02:54 +00:00
if ( ISNQCLIENT ( host_client ) )
SVNQ_New_f ( ) ;
else
SV_New_f ( ) ;
}
}
2004-08-23 00:15:46 +00:00
if ( ! issamelevel )
{
cvar_t * nsv ;
nsv = Cvar_Get ( " nextserver " , " " , 0 , " " ) ;
if ( nextserver )
2004-08-27 00:43:28 +00:00
Cvar_Set ( nsv , va ( " gamemap \" %s \" " , nextserver ) ) ;
2004-08-23 00:15:46 +00:00
else
Cvar_Set ( nsv , " " ) ;
}
2011-06-29 18:39:11 +00:00
if ( wasgamemap )
{
SV_Savegame ( " s0 " ) ;
}
2013-07-14 12:22:51 +00:00
if ( isDedicated )
2013-10-29 17:38:22 +00:00
Mod_Purge ( MP_MAPCHANGED ) ;
2004-08-23 00:15:46 +00:00
}
void SV_KillServer_f ( void )
{
SV_UnspawnServer ( ) ;
}
/*
= = = = = = = = = = = = = = = = = =
SV_Kick_f
Kick a user off of the server
= = = = = = = = = = = = = = = = = =
*/
void SV_Kick_f ( void )
2005-07-03 15:16:20 +00:00
{
2004-08-23 00:15:46 +00:00
client_t * cl ;
int clnum = - 1 ;
2009-10-06 00:41:42 +00:00
if ( ! sv . state )
return ;
2004-08-23 00:15:46 +00:00
while ( ( cl = SV_GetClientForString ( Cmd_Argv ( 1 ) , & clnum ) ) )
{
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s was kicked \n " , cl - > name ) ;
2004-08-23 00:15:46 +00:00
// print directly, because the dropped client won't get the
// SV_BroadcastPrintf message
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( cl , PRINT_HIGH , " You were kicked \n " ) ;
2007-07-27 21:24:31 +00:00
SV_LogPlayer ( cl , " kicked " ) ;
2005-07-03 15:16:20 +00:00
SV_DropClient ( cl ) ;
}
2004-08-23 00:15:46 +00:00
if ( clnum = = - 1 )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Couldn't find user number %s \n " , Cmd_Argv ( 1 ) ) ;
2004-08-23 00:15:46 +00:00
}
2009-10-06 00:41:42 +00:00
/*for q3's kick bot menu*/
void SV_KickSlot_f ( void )
{
client_t * cl ;
int clnum = atoi ( Cmd_Argv ( 1 ) ) ;
if ( ! sv . state )
return ;
if ( clnum < sv . allocated_client_slots & & svs . clients [ clnum ] . state )
{
cl = & svs . clients [ clnum ] ;
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s was kicked \n " , cl - > name ) ;
2009-10-06 00:41:42 +00:00
// print directly, because the dropped client won't get the
// SV_BroadcastPrintf message
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( cl , PRINT_HIGH , " You were kicked \n " ) ;
2009-10-06 00:41:42 +00:00
SV_LogPlayer ( cl , " kicked " ) ;
SV_DropClient ( cl ) ;
}
else
Con_Printf ( " Client %i is not active \n " , clnum ) ;
}
2006-05-22 22:51:14 +00:00
void SV_BanName_f ( void )
2004-08-23 00:15:46 +00:00
{
client_t * cl ;
int clnum = - 1 ;
2006-05-25 04:47:03 +00:00
char * reason = NULL ;
int reasonsize = 0 ;
2004-08-23 00:15:46 +00:00
2006-05-22 22:51:14 +00:00
if ( Cmd_Argc ( ) < 2 )
{
2006-05-25 04:47:03 +00:00
Con_Printf ( " %s userid|nick [reason] \n " , Cmd_Argv ( 0 ) ) ;
2006-05-22 22:51:14 +00:00
return ;
}
2006-05-25 04:47:03 +00:00
if ( Cmd_Argc ( ) > 2 )
{
reason = Cmd_Argv ( 2 ) ;
reasonsize = strlen ( reason ) ;
}
2004-08-23 00:15:46 +00:00
while ( ( cl = SV_GetClientForString ( Cmd_Argv ( 1 ) , & clnum ) ) )
if ( cl )
{
bannedips_t * nb ;
2006-05-22 22:51:14 +00:00
2013-05-03 04:28:08 +00:00
if ( NET_IsLoopBackAddress ( & cl - > netchan . remote_address ) )
2006-05-22 22:51:14 +00:00
{
Con_Printf ( " You're not allowed to ban loopback! \n " ) ;
continue ;
}
2006-05-25 04:47:03 +00:00
nb = Z_Malloc ( sizeof ( bannedips_t ) + reasonsize ) ;
2004-08-23 00:15:46 +00:00
nb - > next = svs . bannedips ;
nb - > adr = cl - > netchan . remote_address ;
2006-05-22 22:51:14 +00:00
NET_IntegerToMask ( & nb - > adr , & nb - > adrmask , - 1 ) ; // fill mask
2004-08-23 00:15:46 +00:00
if ( * Cmd_Argv ( 2 ) ) //explicit blocking of all ports of a client ip
nb - > adr . port = 0 ;
svs . bannedips = nb ;
2006-05-25 04:47:03 +00:00
if ( reasonsize )
Q_strcpy ( nb - > reason , reason ) ;
2004-08-23 00:15:46 +00:00
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s was banned \n " , cl - > name ) ;
2004-08-23 00:15:46 +00:00
// print directly, because the dropped client won't get the
// SV_BroadcastPrintf message
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( cl , PRINT_HIGH , " You were banned \n " ) ;
2007-07-27 21:24:31 +00:00
SV_LogPlayer ( cl , " banned name " ) ;
2004-08-23 00:15:46 +00:00
SV_DropClient ( cl ) ;
}
if ( clnum = = - 1 )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Couldn't find user number %s \n " , Cmd_Argv ( 1 ) ) ;
2004-08-23 00:15:46 +00:00
}
2013-05-03 04:28:08 +00:00
void SV_KickBanIP ( netadr_t * banadr , netadr_t * banmask , char * reason )
2008-05-25 22:23:43 +00:00
{
qboolean shouldkick ;
client_t * cl ;
int i ;
unsigned int reasonsize ;
bannedips_t * nb ;
if ( reason )
reasonsize = strlen ( reason ) ;
else
reasonsize = 0 ;
// loop through clients and kick the ones that match
for ( i = 0 , cl = svs . clients ; i < sv . allocated_client_slots ; i + + , cl + + )
{
if ( cl - > state < = cs_zombie )
continue ;
shouldkick = false ;
2013-05-03 04:28:08 +00:00
if ( NET_CompareAdrMasked ( & cl - > netchan . remote_address , banadr , banmask ) )
2008-05-25 22:23:43 +00:00
shouldkick = true ;
else if ( cl - > realip_status > = 1 )
2013-05-03 04:28:08 +00:00
if ( NET_CompareAdrMasked ( & cl - > realip , banadr , banmask ) )
2008-05-25 22:23:43 +00:00
shouldkick = true ;
if ( shouldkick )
{
// match, so kick
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s was banned \n " , cl - > name ) ;
2008-05-25 22:23:43 +00:00
// print directly, because the dropped client won't get the
// SV_BroadcastPrintf message
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( cl , PRINT_HIGH , " You were banned \n " ) ;
2008-05-25 22:23:43 +00:00
SV_LogPlayer ( cl , " banned ip " ) ;
SV_DropClient ( cl ) ;
}
}
// add IP and mask to ban list
nb = Z_Malloc ( sizeof ( bannedips_t ) + reasonsize ) ;
nb - > next = svs . bannedips ;
2013-05-03 04:28:08 +00:00
nb - > adr = * banadr ;
nb - > adrmask = * banmask ;
2008-05-25 22:23:43 +00:00
svs . bannedips = nb ;
if ( reasonsize )
Q_strcpy ( nb - > reason , reason ) ;
}
2006-05-22 22:51:14 +00:00
void SV_BanIP_f ( void )
2004-08-23 00:15:46 +00:00
{
2006-05-22 22:51:14 +00:00
netadr_t banadr ;
netadr_t banmask ;
2006-05-25 04:47:03 +00:00
char * reason = NULL ;
2004-08-23 00:15:46 +00:00
2006-05-22 22:51:14 +00:00
if ( Cmd_Argc ( ) < 2 )
{
2006-05-25 04:47:03 +00:00
Con_Printf ( " %s address/mask|adress/maskbits [reason] \n " , Cmd_Argv ( 0 ) ) ;
2006-05-22 22:51:14 +00:00
return ;
}
2004-08-23 00:15:46 +00:00
2006-05-22 22:51:14 +00:00
if ( ! NET_StringToAdrMasked ( Cmd_Argv ( 1 ) , & banadr , & banmask ) )
2004-08-23 00:15:46 +00:00
{
2006-05-22 22:51:14 +00:00
Con_Printf ( " invalid address or mask \n " ) ;
return ;
}
2013-05-03 04:28:08 +00:00
if ( NET_IsLoopBackAddress ( & banadr ) )
2006-05-22 22:51:14 +00:00
{
Con_Printf ( " You're not allowed to ban loopback! \n " ) ;
return ;
}
2006-05-25 04:47:03 +00:00
if ( Cmd_Argc ( ) > 2 )
reason = Cmd_Argv ( 2 ) ;
2013-05-03 04:28:08 +00:00
SV_KickBanIP ( & banadr , & banmask , reason ) ;
2008-05-25 22:23:43 +00:00
}
void SV_BanClientIP_f ( void )
{
netadr_t banmask ;
client_t * cl ;
char * reason = NULL ;
int clnum = - 1 ;
while ( ( cl = SV_GetClientForString ( Cmd_Argv ( 1 ) , & clnum ) ) )
2006-05-22 22:51:14 +00:00
{
2013-05-03 04:28:08 +00:00
if ( NET_IsLoopBackAddress ( & cl - > netchan . remote_address ) )
2008-05-25 22:23:43 +00:00
{
Con_Printf ( " You're not allowed to ban loopback! \n " ) ;
2006-05-22 22:51:14 +00:00
continue ;
2008-05-25 22:23:43 +00:00
}
2006-05-22 22:51:14 +00:00
2008-05-25 22:23:43 +00:00
if ( cl - > realip_status > 0 )
2004-08-23 00:15:46 +00:00
{
2008-05-25 22:23:43 +00:00
memset ( & banmask . address , 0xff , sizeof ( banmask . address ) ) ;
banmask . type = cl - > netchan . remote_address . type ;
2013-05-03 04:28:08 +00:00
SV_KickBanIP ( & cl - > realip , & banmask , reason ) ;
2008-05-25 22:23:43 +00:00
}
else
{
memset ( & banmask . address , 0xff , sizeof ( banmask . address ) ) ;
banmask . type = cl - > netchan . remote_address . type ;
2013-05-03 04:28:08 +00:00
SV_KickBanIP ( & cl - > netchan . remote_address , & banmask , reason ) ;
2004-08-23 00:15:46 +00:00
}
}
2006-05-25 04:47:03 +00:00
}
void SV_FilterIP_f ( void )
{
netadr_t banadr ;
netadr_t banmask ;
int i ;
client_t * cl ;
2009-07-14 23:42:54 +00:00
bannedips_t * nb ;
2006-05-25 04:47:03 +00:00
extern cvar_t filterban ;
if ( Cmd_Argc ( ) < 2 )
{
Con_Printf ( " %s address/mask|adress/maskbits \n " , Cmd_Argv ( 0 ) ) ;
return ;
}
if ( ! NET_StringToAdrMasked ( Cmd_Argv ( 1 ) , & banadr , & banmask ) )
{
Con_Printf ( " invalid address or mask \n " ) ;
return ;
}
2013-05-03 04:28:08 +00:00
if ( NET_IsLoopBackAddress ( & banadr ) )
2006-05-25 04:47:03 +00:00
{
Con_Printf ( " You're not allowed to filter loopback! \n " ) ;
return ;
}
2010-01-10 15:15:20 +00:00
nb = svs . bannedips ;
while ( nb )
{
2013-05-03 04:28:08 +00:00
if ( NET_CompareAdr ( & nb - > adr , & banadr ) & & NET_CompareAdr ( & nb - > adrmask , & banmask ) )
2010-01-10 15:15:20 +00:00
{
Con_Printf ( " %s is already banned \n " , Cmd_Argv ( 1 ) ) ;
break ;
}
nb = nb - > next ;
}
2006-05-25 04:47:03 +00:00
// loop through clients and kick the ones that match
for ( i = 0 , cl = svs . clients ; i < sv . allocated_client_slots ; i + + , cl + + )
{
if ( cl - > state < = cs_zombie )
continue ;
2013-05-03 04:28:08 +00:00
if ( filterban . value & & NET_CompareAdrMasked ( & cl - > netchan . remote_address , & banadr , & banmask ) )
2006-05-25 04:47:03 +00:00
SV_DropClient ( cl ) ;
}
// add IP and mask to filter list
2009-07-14 23:42:54 +00:00
nb = Z_Malloc ( sizeof ( bannedips_t ) ) ;
nb - > next = svs . bannedips ;
2006-05-25 04:47:03 +00:00
nb - > adr = banadr ;
nb - > adrmask = banmask ;
2009-07-14 23:42:54 +00:00
nb - > type = BAN_FILTER ;
* nb - > reason = 0 ;
svs . bannedips = nb ;
2006-05-22 22:51:14 +00:00
}
void SV_BanList_f ( void )
{
int bancount = 0 ;
bannedips_t * nb = svs . bannedips ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2006-05-22 22:51:14 +00:00
while ( nb )
{
2006-05-25 04:47:03 +00:00
if ( nb - > reason [ 0 ] )
2013-05-03 04:28:08 +00:00
Con_Printf ( " %s, %s \n " , NET_AdrToStringMasked ( adr , sizeof ( adr ) , & nb - > adr , & nb - > adrmask ) , nb - > reason ) ;
2006-05-25 04:47:03 +00:00
else
2013-05-03 04:28:08 +00:00
Con_Printf ( " %s \n " , NET_AdrToStringMasked ( adr , sizeof ( adr ) , & nb - > adr , & nb - > adrmask ) ) ;
2006-05-22 22:51:14 +00:00
bancount + + ;
nb = nb - > next ;
}
Con_Printf ( " %i total entries in ban list \n " , bancount ) ;
}
2006-05-25 04:47:03 +00:00
void SV_FilterList_f ( void )
{
int filtercount = 0 ;
2009-07-14 23:42:54 +00:00
bannedips_t * nb = svs . bannedips ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2006-05-25 04:47:03 +00:00
while ( nb )
{
2013-05-03 04:28:08 +00:00
Con_Printf ( " %s \n " , NET_AdrToStringMasked ( adr , sizeof ( adr ) , & nb - > adr , & nb - > adrmask ) ) ;
2006-05-25 04:47:03 +00:00
filtercount + + ;
nb = nb - > next ;
}
Con_Printf ( " %i total entries in filter list \n " , filtercount ) ;
}
2006-05-22 22:51:14 +00:00
void SV_Unban_f ( void )
{
qboolean all = false ;
2013-08-27 18:09:14 +00:00
bannedips_t * * link ;
bannedips_t * nb ;
2006-05-22 22:51:14 +00:00
netadr_t unbanadr = { 0 } ;
netadr_t unbanmask = { 0 } ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2006-05-22 22:51:14 +00:00
if ( Cmd_Argc ( ) < 2 )
{
Con_Printf ( " %s address/mask|address/maskbits|all \n " , Cmd_Argv ( 0 ) ) ;
return ;
}
if ( ! Q_strcasecmp ( Cmd_Argv ( 1 ) , " all " ) )
all = true ;
else if ( ! NET_StringToAdrMasked ( Cmd_Argv ( 1 ) , & unbanadr , & unbanmask ) )
{
Con_Printf ( " invalid address or mask \n " ) ;
return ;
}
2013-08-27 18:09:14 +00:00
for ( link = & svs . bannedips ; ( nb = * link ) ; )
2006-05-22 22:51:14 +00:00
{
2013-05-03 04:28:08 +00:00
if ( all | | ( NET_CompareAdr ( & nb - > adr , & unbanadr ) & & NET_CompareAdr ( & nb - > adrmask , & unbanmask ) ) )
2006-05-22 22:51:14 +00:00
{
if ( ! all )
2013-05-03 04:28:08 +00:00
Con_Printf ( " unbanned %s \n " , NET_AdrToStringMasked ( adr , sizeof ( adr ) , & nb - > adr , & nb - > adrmask ) ) ;
2013-08-27 18:09:14 +00:00
* link = nb - > next ;
2006-05-22 22:51:14 +00:00
Z_Free ( nb ) ;
2009-04-28 15:49:20 +00:00
if ( ! all )
break ;
2006-05-22 22:51:14 +00:00
}
2013-08-27 18:09:14 +00:00
else
{
link = & ( * link ) - > next ;
}
2006-05-22 22:51:14 +00:00
}
2004-08-23 00:15:46 +00:00
}
2006-05-25 04:47:03 +00:00
void SV_Unfilter_f ( void )
{
qboolean all = false ;
2009-07-14 23:42:54 +00:00
bannedips_t * nb = svs . bannedips ;
bannedips_t * nbnext ;
2006-05-25 04:47:03 +00:00
netadr_t unbanadr = { 0 } ;
netadr_t unbanmask = { 0 } ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2006-05-25 04:47:03 +00:00
if ( Cmd_Argc ( ) < 2 )
{
Con_Printf ( " %s address/mask|address/maskbits|all \n " , Cmd_Argv ( 0 ) ) ;
return ;
}
if ( ! Q_strcasecmp ( Cmd_Argv ( 1 ) , " all " ) )
all = true ;
else if ( ! NET_StringToAdrMasked ( Cmd_Argv ( 1 ) , & unbanadr , & unbanmask ) )
{
Con_Printf ( " invalid address or mask \n " ) ;
return ;
}
while ( nb )
{
nbnext = nb - > next ;
2013-05-03 04:28:08 +00:00
if ( all | | ( NET_CompareAdr ( & nb - > adr , & unbanadr ) & & NET_CompareAdr ( & nb - > adrmask , & unbanmask ) ) )
2006-05-25 04:47:03 +00:00
{
if ( ! all )
2013-05-03 04:28:08 +00:00
Con_Printf ( " unfiltered %s \n " , NET_AdrToStringMasked ( adr , sizeof ( adr ) , & nb - > adr , & nb - > adrmask ) ) ;
2009-07-14 23:42:54 +00:00
if ( svs . bannedips = = nb )
svs . bannedips = nbnext ;
2006-05-25 04:47:03 +00:00
Z_Free ( nb ) ;
2006-05-29 16:12:21 +00:00
break ;
2006-05-25 04:47:03 +00:00
}
nb = nbnext ;
}
}
2006-05-29 16:12:21 +00:00
void SV_WriteIP_f ( void )
{
vfsfile_t * f ;
char name [ MAX_OSPATH ] ;
bannedips_t * bi ;
char * s ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2006-05-29 16:12:21 +00:00
strcpy ( name , " listip.cfg " ) ;
Con_Printf ( " Writing %s. \n " , name ) ;
f = FS_OpenVFS ( name , " wb " , FS_GAME ) ;
if ( ! f )
{
Con_Printf ( " Couldn't open %s \n " , name ) ;
return ;
}
bi = svs . bannedips ;
while ( bi )
{
2009-07-14 23:42:54 +00:00
if ( bi - > type = = BAN_BAN )
s = " banip " ;
else
s = " addip " ;
2006-05-29 16:12:21 +00:00
if ( bi - > reason [ 0 ] )
2013-05-03 04:28:08 +00:00
s = va ( " %s %s \" %s \" \n " , s , NET_AdrToStringMasked ( adr , sizeof ( adr ) , & bi - > adr , & bi - > adrmask ) , bi - > reason ) ;
2006-05-29 16:12:21 +00:00
else
2013-05-03 04:28:08 +00:00
s = va ( " %s %s \n " , s , NET_AdrToStringMasked ( adr , sizeof ( adr ) , & bi - > adr , & bi - > adrmask ) ) ;
2006-05-29 16:12:21 +00:00
VFS_WRITE ( f , s , strlen ( s ) ) ;
bi = bi - > next ;
}
VFS_CLOSE ( f ) ;
}
2004-08-23 00:15:46 +00:00
void SV_ForceName_f ( void )
{
client_t * cl ;
int clnum = - 1 ;
int i ;
while ( ( cl = SV_GetClientForString ( Cmd_Argv ( 1 ) , & clnum ) ) )
{
2013-07-13 12:14:32 +00:00
Info_SetValueForKey ( cl - > userinfo , " name " , Cmd_Argv ( 2 ) , EXTENDED_INFO_STRING ) ;
2007-07-27 21:24:31 +00:00
SV_LogPlayer ( cl , " name forced " ) ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
SV_ExtractFromUserinfo ( cl , true ) ;
2005-09-27 05:53:31 +00:00
Q_strncpyz ( cl - > name , Cmd_Argv ( 2 ) , sizeof ( cl - > namebuf ) ) ;
2004-08-23 00:15:46 +00:00
i = cl - svs . clients ;
MSG_WriteByte ( & sv . reliable_datagram , svc_setinfo ) ;
MSG_WriteByte ( & sv . reliable_datagram , i ) ;
MSG_WriteString ( & sv . reliable_datagram , " name " ) ;
MSG_WriteString ( & sv . reliable_datagram , cl - > name ) ;
return ;
}
if ( clnum = = - 1 )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Couldn't find user number %s \n " , Cmd_Argv ( 1 ) ) ;
2004-08-23 00:15:46 +00:00
}
void SV_CripplePlayer_f ( void )
{
client_t * cl ;
int clnum = - 1 ;
int persist = * Cmd_Argv ( 2 ) ;
while ( ( cl = SV_GetClientForString ( Cmd_Argv ( 1 ) , & clnum ) ) )
{
if ( ! cl - > iscrippled )
{
2007-07-27 21:24:31 +00:00
SV_LogPlayer ( cl , " crippled " ) ;
2011-09-03 03:49:43 +00:00
if ( persist & & cl - > rankid )
2004-08-23 00:15:46 +00:00
{
cl - > iscrippled = 2 ;
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s is now crippled permanently \n " , cl - > name ) ;
2004-08-23 00:15:46 +00:00
}
else
{
cl - > iscrippled = true ;
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s is crippled \n " , cl - > name ) ;
2004-08-23 00:15:46 +00:00
}
}
else
{
2007-07-27 21:24:31 +00:00
SV_LogPlayer ( cl , " uncrippled " ) ;
2004-08-23 00:15:46 +00:00
cl - > iscrippled = false ;
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( cl , PRINT_HIGH , " You are no longer crippled \n " ) ;
2005-07-03 15:16:20 +00:00
}
2004-08-23 00:15:46 +00:00
}
if ( clnum = = - 1 )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Couldn't find user number %s \n " , Cmd_Argv ( 1 ) ) ;
2004-08-23 00:15:46 +00:00
}
void SV_Mute_f ( void )
{
client_t * cl ;
int clnum = - 1 ;
int persist = * Cmd_Argv ( 2 ) ;
while ( ( cl = SV_GetClientForString ( Cmd_Argv ( 1 ) , & clnum ) ) )
{
if ( ! cl - > ismuted )
{
2007-07-27 21:24:31 +00:00
SV_LogPlayer ( cl , " muted " ) ;
2011-09-03 03:49:43 +00:00
if ( persist & & cl - > rankid )
2004-08-23 00:15:46 +00:00
{
cl - > ismuted = 2 ;
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s was muted permanently \n " , cl - > name ) ;
2004-08-23 00:15:46 +00:00
}
else
{
cl - > ismuted = true ;
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s was muted \n " , cl - > name ) ;
2004-08-23 00:15:46 +00:00
}
}
else
{
2007-07-27 21:24:31 +00:00
SV_LogPlayer ( cl , " unmuted " ) ;
2004-08-23 00:15:46 +00:00
cl - > ismuted = false ;
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( cl , PRINT_HIGH , " You are no longer muted \n " ) ;
2004-08-23 00:15:46 +00:00
}
}
if ( clnum = = - 1 )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Couldn't find user number %s \n " , Cmd_Argv ( 1 ) ) ;
2004-08-23 00:15:46 +00:00
}
void SV_Cuff_f ( void )
{
client_t * cl ;
int clnum = - 1 ;
int persist = * Cmd_Argv ( 2 ) ;
while ( ( cl = SV_GetClientForString ( Cmd_Argv ( 1 ) , & clnum ) ) )
{
if ( ! cl - > iscuffed )
{
2007-07-27 21:24:31 +00:00
SV_LogPlayer ( cl , " cuffed " ) ;
2011-09-03 03:49:43 +00:00
if ( persist & & cl - > rankid )
2004-08-23 00:15:46 +00:00
{
cl - > iscuffed = 2 ;
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s is still cuffed \n " , cl - > name ) ;
2004-08-23 00:15:46 +00:00
}
else
{
cl - > iscuffed = true ;
2013-11-29 14:36:47 +00:00
SV_BroadcastTPrintf ( PRINT_HIGH , " %s is cuffed \n " , cl - > name ) ;
2004-08-23 00:15:46 +00:00
}
}
else
{
2007-07-27 21:24:31 +00:00
SV_LogPlayer ( cl , " uncuffed " ) ;
2004-08-23 00:15:46 +00:00
cl - > iscuffed = false ;
2013-11-29 14:36:47 +00:00
SV_ClientTPrintf ( cl , PRINT_HIGH , " You are no longer cuffed \n " ) ;
2004-08-23 00:15:46 +00:00
}
}
if ( clnum = = - 1 )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Couldn't find user number %s \n " , Cmd_Argv ( 1 ) ) ;
2004-08-23 00:15:46 +00:00
}
2006-05-30 04:00:24 +00:00
void SV_Floodprot_f ( void )
{
extern cvar_t sv_floodprotect ;
extern cvar_t sv_floodprotect_messages ;
extern cvar_t sv_floodprotect_interval ;
extern cvar_t sv_floodprotect_silencetime ;
if ( Cmd_Argc ( ) = = 1 )
{
if ( sv_floodprotect_messages . value < = 0 | | ! sv_floodprotect . value )
Con_Printf ( " Flood protection is off. \n " ) ;
else
Con_Printf ( " Current flood protection settings: \n After %g msgs for %g seconds, silence for %g seconds \n " ,
sv_floodprotect_messages . value ,
sv_floodprotect_interval . value ,
sv_floodprotect_silencetime . value ) ;
return ;
}
if ( Cmd_Argc ( ) ! = 4 )
{
Con_Printf ( " Usage: %s <messagerate> <ratepersecond> <silencetime> \n " , Cmd_Argv ( 0 ) ) ;
return ;
}
Cvar_SetValue ( & sv_floodprotect_messages , atof ( Cmd_Argv ( 1 ) ) ) ;
Cvar_SetValue ( & sv_floodprotect_interval , atof ( Cmd_Argv ( 2 ) ) ) ;
Cvar_SetValue ( & sv_floodprotect_silencetime , atof ( Cmd_Argv ( 3 ) ) ) ;
}
2004-08-23 00:15:46 +00:00
void SV_StuffToClient_f ( void )
{ //with this we emulate the progs 'stuffcmds' builtin
client_t * cl ;
int clnum = - 1 ;
char * clientname = Cmd_Argv ( 1 ) ;
char * str ;
char * c ;
char * key ;
2004-12-08 04:14:52 +00:00
Cmd_ShiftArgs ( 1 , Cmd_ExecLevel = = RESTRICT_LOCAL ) ;
2004-08-23 00:15:46 +00:00
if ( ! strcmp ( Cmd_Argv ( 1 ) , " bind " ) )
{
key = Z_Malloc ( strlen ( Cmd_Argv ( 2 ) ) + 1 ) ;
strcpy ( key , Cmd_Argv ( 2 ) ) ;
2004-12-08 04:14:52 +00:00
Cmd_ShiftArgs ( 2 , Cmd_ExecLevel = = RESTRICT_LOCAL ) ;
2004-08-23 00:15:46 +00:00
}
else
key = NULL ;
str = Cmd_Args ( ) ;
while ( * str < = ' ' ) //strim leading spaces
{
if ( ! * str )
break ;
str + + ;
}
//a list of safe, allowed commands. Allows any extention of this.
if ( strchr ( str , ' \n ' ) | | strchr ( str , ' ; ' ) | | (
2006-06-12 22:05:41 +00:00
! strncmp ( str , " setinfo " , 7 ) & &
! strncmp ( str , " quit " , 4 ) & &
! strncmp ( str , " gl_fb " , 5 ) & &
! strncmp ( str , " r_fb " , 4 ) & &
2006-06-15 21:40:54 +00:00
! strncmp ( str , " say " , 3 ) & & //note that the say parsing could be useful here.
2006-06-12 22:05:41 +00:00
! strncmp ( str , " echo " , 4 ) & &
! strncmp ( str , " name " , 4 ) & &
! strncmp ( str , " skin " , 4 ) & &
! strncmp ( str , " color " , 5 ) & &
! strncmp ( str , " cmd " , 3 ) & &
! strncmp ( str , " fov " , 3 ) & &
! strncmp ( str , " connect " , 7 ) & &
! strncmp ( str , " rate " , 4 ) & &
! strncmp ( str , " cd " , 2 ) & &
! strncmp ( str , " easyrecord " , 10 ) & &
! strncmp ( str , " leftisright " , 11 ) & &
! strncmp ( str , " menu_ " , 5 ) & &
! strncmp ( str , " r_fullbright " , 12 ) & &
! strncmp ( str , " toggleconsole " , 13 ) & &
! strncmp ( str , " v_i " , 3 ) & & //idlescale vars
! strncmp ( str , " bf " , 2 ) & &
! strncmp ( str , " + " , 1 ) & &
! strncmp ( str , " - " , 1 ) & &
! strncmp ( str , " impulse " , 7 ) & &
2004-08-23 00:15:46 +00:00
1 ) )
{
Con_Printf ( " You're not allowed to stuffcmd that \n " ) ;
if ( key )
Z_Free ( key ) ;
return ;
}
while ( ( cl = SV_GetClientForString ( clientname , & clnum ) ) )
{
2005-05-26 12:55:34 +00:00
if ( cl - > protocol = = SCP_QUAKE2 )
2004-08-23 00:15:46 +00:00
ClientReliableWrite_Begin ( cl , svcq2_stufftext , 3 + strlen ( str ) + ( key ? strlen ( key ) + 6 : 0 ) ) ;
else
ClientReliableWrite_Begin ( cl , svc_stufftext , 3 + strlen ( str ) + ( key ? strlen ( key ) + 6 : 0 ) ) ;
if ( key )
{
for ( c = " bind " ; * c ; c + + )
ClientReliableWrite_Byte ( cl , * c ) ;
for ( c = key ; * c ; c + + )
ClientReliableWrite_Byte ( cl , * c ) ;
ClientReliableWrite_Byte ( cl , ' ' ) ;
}
for ( c = str ; * c ; c + + )
ClientReliableWrite_Byte ( cl , * c ) ;
ClientReliableWrite_Byte ( cl , ' \n ' ) ;
ClientReliableWrite_Byte ( cl , ' \0 ' ) ;
}
if ( key )
Z_Free ( key ) ;
}
2009-04-01 22:03:56 +00:00
char * ShowTime ( unsigned int seconds )
{
char buf [ 1024 ] ;
char * b = buf ;
* b = 0 ;
if ( seconds > 60 )
{
if ( seconds > 60 * 60 )
{
if ( seconds > 24 * 60 * 60 )
{
strcpy ( b , va ( " %id " , seconds / ( 24 * 60 * 60 ) ) ) ;
b + = strlen ( b ) ;
seconds % = 24 * 60 * 60 ;
}
strcpy ( b , va ( " %ih " , seconds / ( 60 * 60 ) ) ) ;
b + = strlen ( b ) ;
seconds % = 60 * 60 ;
}
strcpy ( b , va ( " %im " , seconds / 60 ) ) ;
b + = strlen ( b ) ;
seconds % = 60 ;
}
strcpy ( b , va ( " %is " , seconds ) ) ;
b + = strlen ( b ) ;
return va ( " %s " , buf ) ;
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = =
SV_Status_f
= = = = = = = = = = = = = = = =
*/
void SV_Status_f ( void )
{
int i , j , l ;
client_t * cl ;
float cpu , avg , pak ;
char * s ;
2008-06-08 14:37:57 +00:00
char adr [ MAX_ADR_SIZE ] ;
2004-08-23 00:15:46 +00:00
int columns = 80 ;
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
extern cvar_t sv_listen_qw , sv_listen_nq , sv_listen_dp , sv_listen_q3 ;
2004-08-23 00:15:46 +00:00
if ( sv_redirected ! = RD_OBLIVION & & ( sv_redirected ! = RD_NONE
# ifndef SERVERONLY
| | ( vid . width < 68 * 8 & & qrenderer ! = QR_NONE )
# endif
) )
columns = 40 ;
if ( ! sv . state )
{
Con_Printf ( " Server is not running \n " ) ;
return ;
}
if ( Cmd_Argc ( ) > 1 )
columns = atoi ( Cmd_Argv ( 1 ) ) ;
cpu = ( svs . stats . latched_active + svs . stats . latched_idle ) ;
if ( cpu )
cpu = 100 * svs . stats . latched_active / cpu ;
avg = 1000 * svs . stats . latched_active / STATFRAMES ;
pak = ( float ) svs . stats . latched_packets / STATFRAMES ;
2008-11-09 22:29:28 +00:00
NET_PrintAddresses ( svs . sockets ) ;
2005-11-30 01:20:53 +00:00
2011-09-03 03:49:43 +00:00
Con_Printf ( " cpu utilization : %3i%% \n " , ( int ) cpu ) ;
Con_Printf ( " avg response time: %i ms \n " , ( int ) avg ) ;
Con_Printf ( " packets/frame : %5.2f \n " , pak ) ; //not relevent as a limit.
Con_Printf ( " server uptime : %s \n " , ShowTime ( realtime ) ) ;
Con_Printf ( " map uptime : %s \n " , ShowTime ( sv . world . physicstime ) ) ;
2009-04-01 22:03:56 +00:00
//show the current map+name (but hide name if its too long or would be ugly)
if ( columns > = 80 & & * sv . mapname & & strlen ( sv . mapname ) < 45 & & ! strchr ( sv . mapname , ' \n ' ) )
Con_Printf ( " current map : %s (%s) \n " , sv . name , sv . mapname ) ;
else
Con_Printf ( " current map : %s \n " , sv . name ) ;
2013-03-31 04:21:08 +00:00
if ( svs . gametype = = GT_PROGS )
{
int count = 0 ;
2013-06-23 02:17:02 +00:00
Con_Printf ( " entities : %i/%i (mem: %i/%i) \n " , sv . world . num_edicts , sv . world . max_edicts , sv . world . progs - > stringtablesize , sv . world . progs - > stringtablemaxsize ) ;
2013-03-31 04:21:08 +00:00
for ( count = 1 ; count < MAX_MODELS ; count + + )
if ( ! sv . strings . model_precache [ count ] )
break ;
Con_Printf ( " models : %i/%i \n " , count , MAX_MODELS ) ;
for ( count = 1 ; count < MAX_SOUNDS ; count + + )
if ( ! * sv . strings . sound_precache [ count ] )
break ;
Con_Printf ( " sounds : %i/%i \n " , count , MAX_SOUNDS ) ;
}
2011-09-03 03:49:43 +00:00
Con_Printf ( " gamedir : %s \n " , FS_GetGamedir ( ) ) ;
2009-04-01 22:03:56 +00:00
if ( sv . csqcdebug )
Con_Printf ( " csqc debug : true \n " ) ;
2011-09-03 03:49:43 +00:00
if ( sv . mvdrecording )
Con_Printf ( " recording : %s \n " , SV_Demo_CurrentOutput ( ) ) ;
2009-04-01 22:03:56 +00:00
Con_Printf ( " public : %s \n " , sv_public . value ? " yes " : " no " ) ;
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
Con_Printf ( " client types :%s%s%s%s \n " , sv_listen_qw . ival ? " QW " : " " , sv_listen_nq . ival ? " NQ " : " " , sv_listen_dp . ival ? " DP " : " " , sv_listen_q3 . ival ? " Q3 " : " " ) ;
2008-06-01 22:06:22 +00:00
2004-08-23 00:15:46 +00:00
// min fps lat drp
if ( columns < 80 )
{
// most remote clients are 40 columns
// 0123456789012345678901234567890123456789
Con_Printf ( " name userid frags \n " ) ;
Con_Printf ( " address rate ping drop \n " ) ;
Con_Printf ( " ---------------- ---- ---- ----- \n " ) ;
2013-12-02 14:30:30 +00:00
for ( i = 0 , cl = svs . clients ; i < svs . allocated_client_slots ; i + + , cl + + )
2004-08-23 00:15:46 +00:00
{
if ( ! cl - > state )
continue ;
Con_Printf ( " %-16.16s " , cl - > name ) ;
Con_Printf ( " %6i %5i " , cl - > userid , ( int ) cl - > old_frags ) ;
if ( cl - > spectator )
Con_Printf ( " (s) \n " ) ;
2005-07-03 15:16:20 +00:00
else
2004-08-23 00:15:46 +00:00
Con_Printf ( " \n " ) ;
2005-09-08 01:47:12 +00:00
if ( cl - > istobeloaded & & cl - > state = = cs_zombie )
s = " LoadZombie " ;
else if ( cl - > protocol = = SCP_BAD )
s = " bot " ;
else
2013-05-03 04:28:08 +00:00
s = NET_BaseAdrToString ( adr , sizeof ( adr ) , & cl - > netchan . remote_address ) ;
2004-08-23 00:15:46 +00:00
Con_Printf ( " %-16.16s " , s ) ;
if ( cl - > state = = cs_connected )
{
Con_Printf ( " CONNECTING \n " ) ;
continue ;
}
if ( cl - > state = = cs_zombie )
{
Con_Printf ( " ZOMBIE \n " ) ;
continue ;
}
Con_Printf ( " %4i %4i %5.2f \n "
, ( int ) ( 1000 * cl - > netchan . frame_rate )
2010-02-06 01:25:04 +00:00
, ( int ) SV_CalcPing ( cl , false )
2004-08-23 00:15:46 +00:00
, 100.0 * cl - > netchan . drop_count / cl - > netchan . incoming_sequence ) ;
}
}
else
{
Con_Printf ( " frags userid address name rate ping drop qport dl%% dls \n " ) ;
Con_Printf ( " ----- ------ --------------- --------------- ---- ---- ----- ----- --- ---- \n " ) ;
2013-10-29 17:38:22 +00:00
for ( i = 0 , cl = svs . clients ; i < svs . allocated_client_slots ; i + + , cl + + )
2004-08-23 00:15:46 +00:00
{
if ( ! cl - > state )
continue ;
Con_Printf ( " %5i %6i " , ( int ) cl - > old_frags , cl - > userid ) ;
if ( cl - > istobeloaded & & cl - > state = = cs_zombie )
s = " LoadZombie " ;
2005-09-08 01:47:12 +00:00
else if ( cl - > protocol = = SCP_BAD )
s = " bot " ;
2004-08-23 00:15:46 +00:00
else
2013-05-03 04:28:08 +00:00
s = NET_BaseAdrToString ( adr , sizeof ( adr ) , & cl - > netchan . remote_address ) ;
2004-08-23 00:15:46 +00:00
Con_Printf ( " %s " , s ) ;
l = 16 - strlen ( s ) ;
for ( j = 0 ; j < l ; j + + )
Con_Printf ( " " ) ;
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
Con_Printf ( " %s " , cl - > name ) ;
l = 16 - strlen ( cl - > name ) ;
for ( j = 0 ; j < l ; j + + )
Con_Printf ( " " ) ;
if ( cl - > state = = cs_connected )
{
Con_Printf ( " CONNECTING " ) ;
}
else if ( cl - > state = = cs_zombie )
{
Con_Printf ( " ZOMBIE " ) ;
}
else
Con_Printf ( " %4i %4i %5.1f %4i "
, ( int ) ( 1000 * cl - > netchan . frame_rate )
2010-02-06 01:25:04 +00:00
, ( int ) SV_CalcPing ( cl , false )
2004-08-23 00:15:46 +00:00
, 100.0 * cl - > netchan . drop_count / cl - > netchan . incoming_sequence
, cl - > netchan . qport ) ;
if ( cl - > download )
{
Con_Printf ( " %3i %4i " , ( cl - > downloadcount * 100 ) / cl - > downloadsize , cl - > downloadsize / 1024 ) ;
}
if ( cl - > spectator )
Con_Printf ( " (s) \n " ) ;
2005-07-03 15:16:20 +00:00
else
2004-08-23 00:15:46 +00:00
Con_Printf ( " \n " ) ;
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
}
}
Con_Printf ( " \n " ) ;
}
/*
= = = = = = = = = = = = = = = = = =
SV_ConSay_f
= = = = = = = = = = = = = = = = = =
*/
void SV_ConSay_f ( void )
{
client_t * client ;
int j ;
char * p ;
char text [ 1024 ] ;
if ( Cmd_Argc ( ) < 2 )
return ;
Q_strcpy ( text , " console: " ) ;
p = Cmd_Args ( ) ;
if ( * p = = ' " ' )
{
p + + ;
p [ Q_strlen ( p ) - 1 ] = 0 ;
}
Q_strcat ( text , p ) ;
2013-10-29 17:38:22 +00:00
for ( j = 0 , client = svs . clients ; j < svs . allocated_client_slots ; j + + , client + + )
2004-08-23 00:15:46 +00:00
{
if ( client - > state = = cs_free )
continue ;
SV_ClientPrintf ( client , PRINT_CHAT , " %s \n " , text ) ;
}
if ( sv . mvdrecording )
{
2012-08-04 01:35:52 +00:00
sizebuf_t * msg ;
msg = MVDWrite_Begin ( dem_all , 0 , strlen ( text ) + 4 ) ;
MSG_WriteByte ( msg , svc_print ) ;
MSG_WriteByte ( msg , PRINT_CHAT ) ;
2011-06-05 01:36:14 +00:00
for ( j = 0 ; text [ j ] ; j + + )
2012-08-04 01:35:52 +00:00
MSG_WriteChar ( msg , text [ j ] ) ;
MSG_WriteChar ( msg , ' \n ' ) ;
MSG_WriteChar ( msg , 0 ) ;
2004-08-23 00:15:46 +00:00
}
}
void SV_ConSayOne_f ( void )
{
char text [ 2048 ] ;
client_t * to ;
int i ;
char * s ;
int clnum = - 1 ;
if ( Cmd_Argc ( ) < 3 )
return ;
while ( ( to = SV_GetClientForString ( Cmd_Argv ( 1 ) , & clnum ) ) )
{
Q_strcpy ( text , " {console}: " ) ;
for ( i = 2 ; ; i + + )
{
s = Cmd_Argv ( i ) ;
if ( ! * s )
break ;
if ( strlen ( text ) + strlen ( s ) + 2 > = sizeof ( text ) - 1 )
break ;
strcat ( text , " " ) ;
strcat ( text , s ) ;
}
strcat ( text , " \n " ) ;
SV_ClientPrintf ( to , PRINT_CHAT , " %s " , text ) ;
}
if ( ! clnum )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Couldn't find user number %s \n " , Cmd_Argv ( 1 ) ) ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
SV_Heartbeat_f
= = = = = = = = = = = = = = = = = =
*/
void SV_Heartbeat_f ( void )
{
2009-04-01 22:03:56 +00:00
Master_ReResolve ( ) ;
2004-08-23 00:15:46 +00:00
svs . last_heartbeat = - 9999 ;
}
2013-09-06 22:57:44 +00:00
# define FOREACHCLIENT(i,cl) \
for ( i = sv . mvdrecording ? - 1 : 0 ; i < sv . allocated_client_slots ; i + + ) \
if ( cl = ( i = = - 1 ? & demo . recorder : & svs . clients [ i ] ) ) \
if ( ( i = = - 1 ) | | cl - > state > cs_zombie )
2005-03-28 00:11:59 +00:00
void SV_SendServerInfoChange ( char * key , const char * value )
2004-08-23 00:15:46 +00:00
{
2013-09-06 22:57:44 +00:00
int i ;
client_t * cl ;
2004-08-23 00:15:46 +00:00
if ( ! sv . state )
return ;
2009-08-29 13:41:22 +00:00
2004-08-23 00:15:46 +00:00
# ifdef Q2SERVER
2009-08-29 13:41:22 +00:00
if ( svs . gametype = = GT_QUAKE2 )
return ; //FIXME!!!
# endif
# ifdef Q3SERVER
if ( svs . gametype = = GT_QUAKE3 )
2004-08-23 00:15:46 +00:00
return ; //FIXME!!!
# endif
2013-09-06 22:57:44 +00:00
FOREACHCLIENT ( i , cl )
{
if ( ISQWCLIENT ( cl ) )
{
ClientReliableWrite_Begin ( cl , svc_serverinfo , strlen ( key ) + strlen ( value ) + 3 ) ;
ClientReliableWrite_String ( cl , key ) ;
ClientReliableWrite_String ( cl , value ) ;
}
else if ( ISNQCLIENT ( cl ) & & ( cl - > fteprotocolextensions2 & PEXT2_PREDINFO ) )
{
ClientReliableWrite_Begin ( cl , svc_stufftext , 1 + 6 + strlen ( key ) + 2 + strlen ( value ) + 3 ) ;
ClientReliableWrite_SZ ( cl , " //svi " , 6 ) ;
ClientReliableWrite_SZ ( cl , key , strlen ( key ) ) ;
ClientReliableWrite_SZ ( cl , " \" " , 2 ) ;
ClientReliableWrite_SZ ( cl , value , strlen ( value ) ) ;
ClientReliableWrite_String ( cl , " \" \n " ) ;
}
}
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = =
SV_Serverinfo_f
Examine or change the serverinfo string
= = = = = = = = = = =
*/
2005-10-05 02:44:40 +00:00
extern char * Info_KeyForNumber ( char * s , int num ) ;
2004-08-23 00:15:46 +00:00
void SV_Serverinfo_f ( void )
{
cvar_t * var ;
char value [ 512 ] ;
int i ;
if ( Cmd_Argc ( ) = = 1 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Server info settings: \n " ) ;
2013-06-23 02:17:02 +00:00
Info_Print ( svs . info , " " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
if ( Cmd_Argc ( ) < 3 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " usage: serverinfo [ <key> <value> ] \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
if ( Cmd_Argv ( 1 ) [ 0 ] = = ' * ' )
{
2005-10-01 03:09:17 +00:00
if ( ! strcmp ( Cmd_Argv ( 1 ) , " * " ) )
if ( ! strcmp ( Cmd_Argv ( 2 ) , " " ) )
{ //clear it out
char * k ;
for ( i = 0 ; ; )
{
k = Info_KeyForNumber ( svs . info , i ) ;
if ( ! * k )
break ; //no more.
else if ( * k = = ' * ' )
i + + ; //can't remove * keys
else if ( ( var = Cvar_FindVar ( k ) ) & & var - > flags & CVAR_SERVERINFO )
i + + ; //this one is a cvar.
else
Info_RemoveKey ( svs . info , k ) ; //we can remove this one though, so yay.
}
2005-11-03 23:40:51 +00:00
2005-10-01 03:09:17 +00:00
return ;
}
2013-11-21 23:02:28 +00:00
Con_Printf ( " Can't set * keys \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
Q_strncpyz ( value , Cmd_Argv ( 2 ) , sizeof ( value ) ) ;
value [ sizeof ( value ) - 1 ] = ' \0 ' ;
for ( i = 3 ; i < Cmd_Argc ( ) ; i + + )
{
strncat ( value , " " , sizeof ( value ) - 1 ) ;
strncat ( value , Cmd_Argv ( i ) , sizeof ( value ) - 1 ) ;
}
Info_SetValueForKey ( svs . info , Cmd_Argv ( 1 ) , value , MAX_SERVERINFO_STRING ) ;
2005-07-03 15:16:20 +00:00
// if this is a cvar, change it too
2004-08-23 00:15:46 +00:00
var = Cvar_FindVar ( Cmd_Argv ( 1 ) ) ;
if ( var )
{
Cvar_Set ( var , value ) ;
2005-07-03 15:16:20 +00:00
/* Z_Free (var->string); // free the old value string
2013-08-27 13:18:09 +00:00
var - > string = Z_StrDup ( value ) ;
2004-08-23 00:15:46 +00:00
var - > value = Q_atof ( var - > string ) ;
*/ }
SV_SendServerInfoChange ( Cmd_Argv ( 1 ) , value ) ;
}
/*
= = = = = = = = = = =
SV_Serverinfo_f
Examine or change the serverinfo string
= = = = = = = = = = =
*/
void SV_Localinfo_f ( void )
{
char * old ;
if ( Cmd_Argc ( ) = = 1 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Local info settings: \n " ) ;
2013-06-23 02:17:02 +00:00
Info_Print ( localinfo , " " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
if ( Cmd_Argc ( ) ! = 3 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " usage: localinfo [ <key> <value> ] \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
if ( Cmd_Argv ( 1 ) [ 0 ] = = ' * ' )
{
2005-10-01 03:09:17 +00:00
if ( ! strcmp ( Cmd_Argv ( 1 ) , " * " ) )
if ( ! strcmp ( Cmd_Argv ( 2 ) , " " ) )
{ //clear it out
Info_RemoveNonStarKeys ( localinfo ) ;
return ;
}
2013-11-21 23:02:28 +00:00
Con_Printf ( " Can't set * keys \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
old = Info_ValueForKey ( localinfo , Cmd_Argv ( 1 ) ) ;
Info_SetValueForKey ( localinfo , Cmd_Argv ( 1 ) , Cmd_Argv ( 2 ) , MAX_LOCALINFO_STRING ) ;
PR_LocalInfoChanged ( Cmd_Argv ( 1 ) , old , Cmd_Argv ( 2 ) ) ;
2005-07-01 19:23:00 +00:00
Con_DPrintf ( " Localinfo %s changed (%s -> %s) \n " , Cmd_Argv ( 1 ) , old , Cmd_Argv ( 2 ) ) ;
2004-08-23 00:15:46 +00:00
}
2005-12-21 03:07:33 +00:00
void SV_SaveInfos ( vfsfile_t * f )
2004-11-17 17:42:28 +00:00
{
2005-12-21 03:07:33 +00:00
VFS_WRITE ( f , " \n " , 1 ) ;
VFS_WRITE ( f , " serverinfo * \" \" \n " , 16 ) ;
2005-11-30 01:20:53 +00:00
Info_WriteToFile ( f , svs . info , " serverinfo " , CVAR_SERVERINFO ) ;
2005-12-21 03:07:33 +00:00
VFS_WRITE ( f , " \n " , 1 ) ;
VFS_WRITE ( f , " localinfo * \" \" \n " , 15 ) ;
2005-11-30 01:20:53 +00:00
Info_WriteToFile ( f , localinfo , " localinfo " , 0 ) ;
2004-11-17 17:42:28 +00:00
}
2004-08-23 00:15:46 +00:00
2005-09-26 08:07:26 +00:00
/*
void SV_ResetInfos ( void )
{
// TODO: add me
}
*/
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = =
SV_User_f
Examine a users info strings
= = = = = = = = = = =
*/
void SV_User_f ( void )
{
2013-06-23 02:17:02 +00:00
double ftime , minf , maxf ;
int frames ;
2010-08-12 09:04:05 +00:00
client_t * cl ;
int clnum = - 1 ;
2013-06-23 02:17:02 +00:00
unsigned int u ;
char buf [ 256 ] ;
static const char * pext1names [ 32 ] = { " setview " , " scale " , " lightstylecol " , " trans " , " view2 " , " builletens " , " accuratetimings " , " sounddbl " ,
" fatness " , " hlbsp " , " bullet " , " hullsize " , " modeldbl " , " entitydbl " , " entitydbl2 " , " floatcoords " ,
" OLD vweap " , " q2bsp " , " q3bsp " , " colormod " , " splitscreen " , " hexen2 " , " spawnstatic2 " , " customtempeffects " ,
" packents " , " UNKNOWN " , " showpic " , " setattachment " , " UNKNOWN " , " chunkeddls " , " csqc " , " dpflags " } ;
static const char * pext2names [ 32 ] = { " prydoncursor " , " voip " , " setangledelta " , " rplcdeltas " , " maxplayers " , " predinfo " , " UNKNOWN " , " UNKNOWN " ,
" UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " ,
" UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " ,
" UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " , " UNKNOWN " } ;
2010-08-12 09:04:05 +00:00
2004-08-23 00:15:46 +00:00
if ( Cmd_Argc ( ) ! = 2 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Usage: info <userid> \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
2013-06-23 02:17:02 +00:00
Con_Printf ( " Userinfo: \n " ) ;
2010-08-12 09:04:05 +00:00
while ( ( cl = SV_GetClientForString ( Cmd_Argv ( 1 ) , & clnum ) ) )
{
2013-06-23 02:17:02 +00:00
Info_Print ( cl - > userinfo , " " ) ;
switch ( cl - > protocol )
{
case SCP_BAD :
Con_Printf ( " protocol: bot/invalid \n " ) ;
break ;
case SCP_QUAKEWORLD :
Con_Printf ( " protocol: quakeworld \n " ) ;
break ;
case SCP_QUAKE2 :
Con_Printf ( " protocol: quake2 \n " ) ;
break ;
case SCP_QUAKE3 :
Con_Printf ( " protocol: quake3 \n " ) ;
break ;
case SCP_NETQUAKE :
Con_Printf ( " protocol: (net)quake \n " ) ;
break ;
case SCP_PROQUAKE :
Con_Printf ( " protocol: (pro)quake \n " ) ;
break ;
case SCP_FITZ666 :
Con_Printf ( " protocol: fitzquake 666 \n " ) ;
break ;
case SCP_DARKPLACES6 :
Con_Printf ( " protocol: dpp6 \n " ) ;
break ;
case SCP_DARKPLACES7 :
Con_Printf ( " protocol: dpp7 \n " ) ;
break ;
default :
Con_Printf ( " protocol: other (fixme) \n " ) ;
break ;
}
Con_Printf ( " pext1: " ) ;
for ( u = 0 ; u < 32 ; u + + )
if ( cl - > fteprotocolextensions & ( 1u < < u ) )
Con_Printf ( " %s " , pext1names [ u ] ) ;
Con_Printf ( " \n " ) ;
Con_Printf ( " pext2: " ) ;
for ( u = 0 ; u < 32 ; u + + )
if ( cl - > fteprotocolextensions2 & ( 1u < < u ) )
Con_Printf ( " %s " , pext2names [ u ] ) ;
2013-06-23 03:59:48 +00:00
Con_Printf ( " \n " ) ;
2013-06-23 02:17:02 +00:00
Con_Printf ( " ip: %s \n " , NET_AdrToString ( buf , sizeof ( buf ) , & cl - > netchan . remote_address ) ) ;
switch ( cl - > realip_status )
{
case 1 :
Con_Printf ( " realip: %s ( " CON_WARNING " unverified " CON_DEFAULT " ) \n " , NET_AdrToString ( buf , sizeof ( buf ) , & cl - > realip ) ) ;
break ;
case 2 :
Con_Printf ( " realip: %s ( " CON_ERROR " unverifiable " CON_DEFAULT " ) \n " , NET_AdrToString ( buf , sizeof ( buf ) , & cl - > realip ) ) ;
break ;
case 3 :
Con_Printf ( " realip: %s (verified) \n " , NET_AdrToString ( buf , sizeof ( buf ) , & cl - > realip ) ) ;
break ;
}
if ( * cl - > guid )
Con_Printf ( " guid: %s \n " , cl - > guid ) ;
if ( cl - > download )
Con_Printf ( " download: \" %s \" %ik/%ik (%i%%) " , cl - > downloadfn , cl - > downloadcount / 1024 , cl - > downloadsize / 1024 , ( cl - > downloadcount * 100 ) / cl - > downloadsize ) ;
SV_CalcNetRates ( cl , & ftime , & frames , & minf , & maxf ) ;
if ( frames )
Con_Printf ( " net: %gfps (min%g max %g), c2s: %ibps, s2c: %ibps \n " , ftime / frames , minf , maxf , ( int ) cl - > inrate , ( int ) cl - > outrate ) ;
else
Con_Printf ( " net: unknown framerate, c2s: %ibps, s2c: %ibps \n " , ( int ) cl - > inrate , ( int ) cl - > outrate ) ;
2010-08-12 09:04:05 +00:00
}
2004-08-23 00:15:46 +00:00
2010-08-12 09:04:05 +00:00
if ( clnum = = - 1 )
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Userid %i is not on the server \n " , atoi ( Cmd_Argv ( 1 ) ) ) ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = =
SV_Floodport_f
Sets the gamedir and path to a different directory .
= = = = = = = = = = = = = = = =
*/
/*
= = = = = = = = = = = = = = = =
SV_Gamedir
Sets the fake * gamedir to a different directory .
= = = = = = = = = = = = = = = =
*/
void SV_Gamedir ( void )
{
char * dir ;
if ( Cmd_Argc ( ) = = 1 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Current gamedir: %s \n " , Info_ValueForKey ( svs . info , " *gamedir " ) ) ;
2004-08-23 00:15:46 +00:00
return ;
}
if ( Cmd_Argc ( ) ! = 2 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Usage: sv_gamedir <newgamedir> \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
dir = Cmd_Argv ( 1 ) ;
if ( strstr ( dir , " .. " ) | | strstr ( dir , " / " )
| | strstr ( dir , " \\ " ) | | strstr ( dir , " : " ) )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " %s should be a single filename, not a path \n " , Cmd_Argv ( 0 ) ) ;
2004-08-23 00:15:46 +00:00
return ;
}
Info_SetValueForStarKey ( svs . info , " *gamedir " , dir , MAX_SERVERINFO_STRING ) ;
}
/*
= = = = = = = = = = = = = = = =
SV_Gamedir_f
Sets the gamedir and path to a different directory .
= = = = = = = = = = = = = = = =
*/
void SV_Gamedir_f ( void )
{
char * dir ;
if ( Cmd_Argc ( ) = = 1 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Current gamedir: %s \n " , FS_GetGamedir ( ) ) ;
2004-08-23 00:15:46 +00:00
return ;
}
if ( Cmd_Argc ( ) ! = 2 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Usage: gamedir <newgamedir> \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
dir = Cmd_Argv ( 1 ) ;
if ( strstr ( dir , " .. " ) | | strstr ( dir , " / " )
| | strstr ( dir , " \\ " ) | | strstr ( dir , " : " ) )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " %s should be a single filename, not a path \n " , Cmd_Argv ( 0 ) ) ;
2004-08-23 00:15:46 +00:00
return ;
}
2013-06-23 02:17:02 +00:00
dir = Z_StrDup ( dir ) ;
2004-08-23 00:15:46 +00:00
COM_Gamedir ( dir ) ;
Info_SetValueForStarKey ( svs . info , " *gamedir " , dir , MAX_SERVERINFO_STRING ) ;
2013-06-23 02:17:02 +00:00
Z_Free ( dir ) ;
2004-08-23 00:15:46 +00:00
}
extern char gamedirfile [ MAX_OSPATH ] ;
/*
= = = = = = = = = = = = = = = =
SV_Snap
= = = = = = = = = = = = = = = =
*/
void SV_Snap ( int uid )
{
client_t * cl ;
2005-07-03 15:16:20 +00:00
char pcxname [ 80 ] ;
2004-08-23 00:15:46 +00:00
char checkname [ MAX_OSPATH ] ;
int i ;
2013-10-29 17:38:22 +00:00
for ( i = 0 , cl = svs . clients ; i < svs . allocated_client_slots ; i + + , cl + + )
2004-08-23 00:15:46 +00:00
{
if ( ! cl - > state )
continue ;
if ( cl - > userid = = uid )
break ;
}
2013-12-02 14:30:30 +00:00
if ( i > = svs . allocated_client_slots )
2009-11-04 21:16:50 +00:00
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Couldn't find user number %i \n " , uid ) ;
2004-08-23 00:15:46 +00:00
return ;
}
2005-07-01 19:23:00 +00:00
if ( ! ISQWCLIENT ( cl ) )
{
Con_Printf ( " Can only snap QW clients \n " ) ;
return ;
}
2004-08-23 00:15:46 +00:00
sprintf ( pcxname , " %d-00.pcx " , uid ) ;
2009-11-04 21:16:50 +00:00
strcpy ( checkname , " snap " ) ;
2004-08-23 00:15:46 +00:00
Sys_mkdir ( gamedirfile ) ;
Sys_mkdir ( checkname ) ;
2005-07-03 15:16:20 +00:00
for ( i = 0 ; i < = 99 ; i + + )
{
pcxname [ strlen ( pcxname ) - 6 ] = i / 10 + ' 0 ' ;
pcxname [ strlen ( pcxname ) - 5 ] = i % 10 + ' 0 ' ;
2013-03-12 22:53:23 +00:00
Q_snprintfz ( checkname , sizeof ( checkname ) , " snap/%s " , pcxname ) ;
2009-11-04 21:16:50 +00:00
if ( ! COM_FCheckExists ( checkname ) )
2004-08-23 00:15:46 +00:00
break ; // file doesn't exist
2005-07-03 15:16:20 +00:00
}
if ( i = = 100 )
2004-08-23 00:15:46 +00:00
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Snap: Couldn't create a file, clean some out. \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
strcpy ( cl - > uploadfn , checkname ) ;
memcpy ( & cl - > snap_from , & net_from , sizeof ( net_from ) ) ;
if ( sv_redirected ! = RD_NONE )
cl - > remote_snap = true ;
else
cl - > remote_snap = false ;
ClientReliableWrite_Begin ( cl , svc_stufftext , 24 ) ;
2005-07-01 19:23:00 +00:00
ClientReliableWrite_String ( cl , " cmd snap \n " ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Requesting snap from user %d... \n " , uid ) ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = =
SV_Snap_f
= = = = = = = = = = = = = = = =
*/
void SV_Snap_f ( void )
{
int uid ;
if ( Cmd_Argc ( ) ! = 2 )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Usage: snap <userid> \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
uid = atoi ( Cmd_Argv ( 1 ) ) ;
SV_Snap ( uid ) ;
}
/*
= = = = = = = = = = = = = = = =
SV_Snap
= = = = = = = = = = = = = = = =
*/
void SV_SnapAll_f ( void )
{
client_t * cl ;
int i ;
2013-10-29 17:38:22 +00:00
for ( i = 0 , cl = svs . clients ; i < svs . allocated_client_slots ; i + + , cl + + )
2004-08-23 00:15:46 +00:00
{
if ( cl - > state < cs_connected | | cl - > spectator )
continue ;
SV_Snap ( cl - > userid ) ;
}
}
2005-11-29 11:30:13 +00:00
float mytimer ;
2004-08-23 00:15:46 +00:00
float lasttimer ;
int ticsleft ;
float timerinterval ;
int timerlevel ;
cvar_t * timercommand ;
void SV_CheckTimer ( void )
{
float ctime = Sys_DoubleTime ( ) ;
// if (ctime < lasttimer) //new map? (shouldn't happen)
2005-11-29 11:30:13 +00:00
// mytimer = ctime+5; //trigger in a few secs
2004-08-23 00:15:46 +00:00
lasttimer = ctime ;
if ( ticsleft )
{
2005-11-29 11:30:13 +00:00
if ( mytimer < ctime )
2004-08-23 00:15:46 +00:00
{
2005-11-29 11:30:13 +00:00
mytimer + = timerinterval ;
2004-08-23 00:15:46 +00:00
if ( ticsleft > 0 )
ticsleft - - ;
if ( timercommand )
{
Cbuf_AddText ( timercommand - > string , timerlevel ) ;
Cbuf_AddText ( " \n " , timerlevel ) ;
}
}
}
}
void SV_SetTimer_f ( void )
{
int count ;
float interval ;
char * command ;
if ( Cmd_Argc ( ) < 2 )
{
2004-12-21 04:39:47 +00:00
Con_Printf ( " %s <count> <interval> <command> \n " , Cmd_Argv ( 0 ) ) ;
2004-08-23 00:15:46 +00:00
return ;
}
count = atoi ( Cmd_Argv ( 1 ) ) ;
interval = atof ( Cmd_Argv ( 2 ) ) ;
if ( ! count & & Cmd_Argc ( ) = = 2 )
{
ticsleft = 0 ;
return ;
}
if ( interval < = 0 | | ( count < = 0 & & count ! = - 1 ) ) //makes sure the args are right. :)
{
Con_Printf ( " %s count interval command \n " , Cmd_Argv ( 0 ) ) ;
return ;
}
2004-12-08 04:14:52 +00:00
Cmd_ShiftArgs ( 2 , Cmd_ExecLevel = = RESTRICT_LOCAL ) ; //strip the two vars
2004-08-23 00:15:46 +00:00
command = Cmd_Args ( ) ;
timercommand = Cvar_Get ( " sv_timer " , " " , CVAR_NOSET , NULL ) ;
Cvar_ForceSet ( timercommand , command ) ;
2005-11-29 11:30:13 +00:00
mytimer = Sys_DoubleTime ( ) + interval ;
2004-08-23 00:15:46 +00:00
ticsleft = count ;
timerinterval = interval ;
timerlevel = Cmd_ExecLevel ;
}
void SV_SendGameCommand_f ( void )
{
2005-09-08 01:47:12 +00:00
# ifdef Q3SERVER
if ( SVQ3_ConsoleCommand ( ) )
return ;
# endif
2007-09-03 22:37:13 +00:00
# ifdef VM_Q1
if ( Q1QVM_GameConsoleCommand ( ) )
return ;
# endif
2013-08-21 07:14:39 +00:00
if ( PR_ConsoleCmd ( Cmd_Args ( ) ) )
return ;
2004-08-23 00:15:46 +00:00
# ifdef Q2SERVER
if ( ge )
{
ge - > ServerCommand ( ) ;
}
else
# endif
Con_Printf ( " This command requires a Q2 sever \n " ) ;
}
2005-12-15 19:15:39 +00:00
void PIN_LoadMessages ( void ) ;
void PIN_SaveMessages ( void ) ;
void PIN_DeleteOldestMessage ( void ) ;
void PIN_MakeMessage ( char * from , char * msg ) ;
void SV_Pin_Save_f ( void )
{
PIN_SaveMessages ( ) ;
}
void SV_Pin_Reload_f ( void )
{
PIN_LoadMessages ( ) ;
}
void SV_Pin_Delete_f ( void )
{
PIN_DeleteOldestMessage ( ) ;
}
void SV_Pin_Add_f ( void )
{
2006-02-22 23:31:51 +00:00
PIN_MakeMessage ( Cmd_Argv ( 1 ) , Cmd_Argv ( 2 ) ) ;
2005-12-15 19:15:39 +00:00
}
2013-06-23 02:17:02 +00:00
/*
void SV_ReallyEvilHack_f ( void )
{
int clnum = - 1 ;
client_t * cl ;
while ( ( cl = SV_GetClientForString ( Cmd_Argv ( 1 ) , & clnum ) ) )
if ( cl )
{
//kick them back to map selection, ish.
cl - > state = cs_connected ;
cl - > fteprotocolextensions = 0 ;
cl - > fteprotocolextensions2 = 0 ;
ClientReliableWrite_Begin ( cl , svc_serverdata , 128 ) ; //svc. dur.
ClientReliableWrite_Long ( cl , PROTOCOL_VERSION_QW ) ; //protocol
ClientReliableWrite_Long ( cl , svs . spawncount ) ; //servercount
ClientReliableWrite_String ( cl , " . " ) ; //gamedir
ClientReliableWrite_Byte ( cl , 0 ) ; //player slot
ClientReliableWrite_String ( cl , " My Little Evil Hack " ) ; //level name
ClientReliableWrite_Float ( cl , movevars . gravity ) ;
ClientReliableWrite_Float ( cl , movevars . stopspeed ) ;
ClientReliableWrite_Float ( cl , movevars . maxspeed ) ;
ClientReliableWrite_Float ( cl , movevars . spectatormaxspeed ) ;
ClientReliableWrite_Float ( cl , movevars . accelerate ) ;
ClientReliableWrite_Float ( cl , movevars . airaccelerate ) ;
ClientReliableWrite_Float ( cl , movevars . wateraccelerate ) ;
ClientReliableWrite_Float ( cl , movevars . friction ) ;
ClientReliableWrite_Float ( cl , movevars . waterfriction ) ;
ClientReliableWrite_Float ( cl , movevars . entgravity ) ;
ClientReliableWrite_Begin ( cl , svc_stufftext , 128 ) ;
ClientReliableWrite_String ( cl , " download \" ezquake-security.dll \" \n " ) ;
}
}
*/
2005-12-15 19:15:39 +00:00
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = =
SV_InitOperatorCommands
= = = = = = = = = = = = = = = = = =
*/
void SV_InitOperatorCommands ( void )
{
# ifndef SERVERONLY
if ( isDedicated )
# endif
{
Cmd_AddCommand ( " quit " , SV_Quit_f ) ;
Cmd_AddCommand ( " say " , SV_ConSay_f ) ;
Cmd_AddCommand ( " sayone " , SV_ConSayOne_f ) ;
2010-11-06 14:22:33 +00:00
Cmd_AddCommand ( " tell " , SV_ConSayOne_f ) ;
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " serverinfo " , SV_Serverinfo_f ) ; //commands that conflict with client commands.
Cmd_AddCommand ( " user " , SV_User_f ) ;
Cmd_AddCommand ( " god " , SV_God_f ) ;
Cmd_AddCommand ( " give " , SV_Give_f ) ;
Cmd_AddCommand ( " noclip " , SV_Noclip_f ) ;
}
Cvar_Register ( & sv_cheats , " Server Permissions " ) ;
if ( COM_CheckParm ( " -cheats " ) )
{
Cvar_Set ( & sv_cheats , " 1 " ) ;
}
Cmd_AddCommand ( " fraglogfile " , SV_Fraglogfile_f ) ;
2009-07-14 23:42:54 +00:00
//ask clients to take a remote screenshot
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " snap " , SV_Snap_f ) ;
Cmd_AddCommand ( " snapall " , SV_SnapAll_f ) ;
2009-07-14 23:42:54 +00:00
//various punishments
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " kick " , SV_Kick_f ) ;
2009-10-06 00:41:42 +00:00
Cmd_AddCommand ( " clientkick " , SV_KickSlot_f ) ;
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " mute " , SV_Mute_f ) ;
Cmd_AddCommand ( " cuff " , SV_Cuff_f ) ;
Cmd_AddCommand ( " renameclient " , SV_ForceName_f ) ;
Cmd_AddCommand ( " cripple " , SV_CripplePlayer_f ) ;
Cmd_AddCommand ( " banname " , SV_BanName_f ) ;
2006-05-22 22:51:14 +00:00
Cmd_AddCommand ( " banlist " , SV_BanList_f ) ;
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " banip " , SV_BanIP_f ) ;
2008-05-25 22:23:43 +00:00
Cmd_AddCommand ( " ban " , SV_BanClientIP_f ) ;
2006-05-22 22:51:14 +00:00
Cmd_AddCommand ( " unban " , SV_Unban_f ) ;
2004-08-23 00:15:46 +00:00
// Cmd_AddCommand ("ban", SV_BanName_f);
Cmd_AddCommand ( " status " , SV_Status_f ) ;
2006-05-25 04:47:03 +00:00
Cmd_AddCommand ( " addip " , SV_FilterIP_f ) ;
Cmd_AddCommand ( " removeip " , SV_Unfilter_f ) ;
Cmd_AddCommand ( " listip " , SV_FilterList_f ) ;
2006-05-29 16:12:21 +00:00
Cmd_AddCommand ( " writeip " , SV_WriteIP_f ) ;
2006-05-25 04:47:03 +00:00
2006-05-30 04:00:24 +00:00
Cmd_AddCommand ( " floodprot " , SV_Floodprot_f ) ;
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " sv " , SV_SendGameCommand_f ) ;
2007-09-03 22:37:13 +00:00
Cmd_AddCommand ( " mod " , SV_SendGameCommand_f ) ;
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " killserver " , SV_KillServer_f ) ;
Cmd_AddCommand ( " map " , SV_Map_f ) ;
2005-09-08 01:47:12 +00:00
# ifdef Q3SERVER
Cmd_AddCommand ( " spmap " , SV_Map_f ) ;
# endif
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " gamemap " , SV_Map_f ) ;
Cmd_AddCommand ( " changelevel " , SV_Map_f ) ;
Cmd_AddCommand ( " listmaps " , SV_MapList_f ) ;
Cmd_AddCommand ( " setmaster " , SV_SetMaster_f ) ;
Cmd_AddCommand ( " heartbeat " , SV_Heartbeat_f ) ;
2005-07-03 15:16:20 +00:00
Cmd_AddCommand ( " localinfo " , SV_Localinfo_f ) ;
2004-08-23 00:15:46 +00:00
Cmd_AddCommand ( " gamedir " , SV_Gamedir_f ) ;
Cmd_AddCommand ( " sv_gamedir " , SV_Gamedir ) ;
Cmd_AddCommand ( " sv_settimer " , SV_SetTimer_f ) ;
Cmd_AddCommand ( " stuffcmd " , SV_StuffToClient_f ) ;
2005-12-15 19:15:39 +00:00
Cmd_AddCommand ( " pin_save " , SV_Pin_Save_f ) ;
Cmd_AddCommand ( " pin_reload " , SV_Pin_Reload_f ) ;
Cmd_AddCommand ( " pin_delete " , SV_Pin_Delete_f ) ;
Cmd_AddCommand ( " pin_add " , SV_Pin_Add_f ) ;
2013-06-23 02:17:02 +00:00
// Cmd_AddCommand ("reallyevilhack", SV_ReallyEvilHack_f);
2012-11-29 13:37:48 +00:00
if ( isDedicated )
cl_warncmd . value = 1 ;
2004-08-23 00:15:46 +00:00
}
2004-11-29 01:21:00 +00:00
# endif