diff options
-rw-r--r-- | source/anorms.h | 181 | ||||
-rw-r--r-- | source/cl_main.c | 8 | ||||
-rw-r--r-- | source/cl_null.c | 69 | ||||
-rw-r--r-- | source/cl_parse.c | 3 | ||||
-rw-r--r-- | source/cl_public.h | 7 | ||||
-rw-r--r-- | source/cmd.c | 14 | ||||
-rw-r--r-- | source/com_local.h | 20 | ||||
-rw-r--r-- | source/common.c | 41 | ||||
-rw-r--r-- | source/cvar.c | 4 | ||||
-rw-r--r-- | source/files.c | 12 | ||||
-rw-r--r-- | source/files.h | 2 | ||||
-rw-r--r-- | source/mvd_parse.c | 7 | ||||
-rw-r--r-- | source/net_chan.c | 34 | ||||
-rw-r--r-- | source/q_msg.c | 58 | ||||
-rw-r--r-- | source/q_msg.h | 175 | ||||
-rw-r--r-- | source/q_shared.c | 362 | ||||
-rw-r--r-- | source/q_shared.h | 4 | ||||
-rw-r--r-- | source/sv_ccmds.c | 4 | ||||
-rw-r--r-- | source/sv_game.c | 2 | ||||
-rw-r--r-- | source/sv_init.c | 6 | ||||
-rw-r--r-- | source/sv_main.c | 24 | ||||
-rw-r--r-- | source/sv_user.c | 6 | ||||
-rw-r--r-- | source/sw_local.h | 2 | ||||
-rw-r--r-- | source/sw_main.c | 2 | ||||
-rw-r--r-- | source/sw_misc.c | 125 |
25 files changed, 623 insertions, 549 deletions
diff --git a/source/anorms.h b/source/anorms.h new file mode 100644 index 0000000..011582e --- /dev/null +++ b/source/anorms.h @@ -0,0 +1,181 @@ +/* +Copyright (C) 1997-2001 Id Software, Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +{-0.525731, 0.000000, 0.850651}, +{-0.442863, 0.238856, 0.864188}, +{-0.295242, 0.000000, 0.955423}, +{-0.309017, 0.500000, 0.809017}, +{-0.162460, 0.262866, 0.951056}, +{0.000000, 0.000000, 1.000000}, +{0.000000, 0.850651, 0.525731}, +{-0.147621, 0.716567, 0.681718}, +{0.147621, 0.716567, 0.681718}, +{0.000000, 0.525731, 0.850651}, +{0.309017, 0.500000, 0.809017}, +{0.525731, 0.000000, 0.850651}, +{0.295242, 0.000000, 0.955423}, +{0.442863, 0.238856, 0.864188}, +{0.162460, 0.262866, 0.951056}, +{-0.681718, 0.147621, 0.716567}, +{-0.809017, 0.309017, 0.500000}, +{-0.587785, 0.425325, 0.688191}, +{-0.850651, 0.525731, 0.000000}, +{-0.864188, 0.442863, 0.238856}, +{-0.716567, 0.681718, 0.147621}, +{-0.688191, 0.587785, 0.425325}, +{-0.500000, 0.809017, 0.309017}, +{-0.238856, 0.864188, 0.442863}, +{-0.425325, 0.688191, 0.587785}, +{-0.716567, 0.681718, -0.147621}, +{-0.500000, 0.809017, -0.309017}, +{-0.525731, 0.850651, 0.000000}, +{0.000000, 0.850651, -0.525731}, +{-0.238856, 0.864188, -0.442863}, +{0.000000, 0.955423, -0.295242}, +{-0.262866, 0.951056, -0.162460}, +{0.000000, 1.000000, 0.000000}, +{0.000000, 0.955423, 0.295242}, +{-0.262866, 0.951056, 0.162460}, +{0.238856, 0.864188, 0.442863}, +{0.262866, 0.951056, 0.162460}, +{0.500000, 0.809017, 0.309017}, +{0.238856, 0.864188, -0.442863}, +{0.262866, 0.951056, -0.162460}, +{0.500000, 0.809017, -0.309017}, +{0.850651, 0.525731, 0.000000}, +{0.716567, 0.681718, 0.147621}, +{0.716567, 0.681718, -0.147621}, +{0.525731, 0.850651, 0.000000}, +{0.425325, 0.688191, 0.587785}, +{0.864188, 0.442863, 0.238856}, +{0.688191, 0.587785, 0.425325}, +{0.809017, 0.309017, 0.500000}, +{0.681718, 0.147621, 0.716567}, +{0.587785, 0.425325, 0.688191}, +{0.955423, 0.295242, 0.000000}, +{1.000000, 0.000000, 0.000000}, +{0.951056, 0.162460, 0.262866}, +{0.850651, -0.525731, 0.000000}, +{0.955423, -0.295242, 0.000000}, +{0.864188, -0.442863, 0.238856}, +{0.951056, -0.162460, 0.262866}, +{0.809017, -0.309017, 0.500000}, +{0.681718, -0.147621, 0.716567}, +{0.850651, 0.000000, 0.525731}, +{0.864188, 0.442863, -0.238856}, +{0.809017, 0.309017, -0.500000}, +{0.951056, 0.162460, -0.262866}, +{0.525731, 0.000000, -0.850651}, +{0.681718, 0.147621, -0.716567}, +{0.681718, -0.147621, -0.716567}, +{0.850651, 0.000000, -0.525731}, +{0.809017, -0.309017, -0.500000}, +{0.864188, -0.442863, -0.238856}, +{0.951056, -0.162460, -0.262866}, +{0.147621, 0.716567, -0.681718}, +{0.309017, 0.500000, -0.809017}, +{0.425325, 0.688191, -0.587785}, +{0.442863, 0.238856, -0.864188}, +{0.587785, 0.425325, -0.688191}, +{0.688191, 0.587785, -0.425325}, +{-0.147621, 0.716567, -0.681718}, +{-0.309017, 0.500000, -0.809017}, +{0.000000, 0.525731, -0.850651}, +{-0.525731, 0.000000, -0.850651}, +{-0.442863, 0.238856, -0.864188}, +{-0.295242, 0.000000, -0.955423}, +{-0.162460, 0.262866, -0.951056}, +{0.000000, 0.000000, -1.000000}, +{0.295242, 0.000000, -0.955423}, +{0.162460, 0.262866, -0.951056}, +{-0.442863, -0.238856, -0.864188}, +{-0.309017, -0.500000, -0.809017}, +{-0.162460, -0.262866, -0.951056}, +{0.000000, -0.850651, -0.525731}, +{-0.147621, -0.716567, -0.681718}, +{0.147621, -0.716567, -0.681718}, +{0.000000, -0.525731, -0.850651}, +{0.309017, -0.500000, -0.809017}, +{0.442863, -0.238856, -0.864188}, +{0.162460, -0.262866, -0.951056}, +{0.238856, -0.864188, -0.442863}, +{0.500000, -0.809017, -0.309017}, +{0.425325, -0.688191, -0.587785}, +{0.716567, -0.681718, -0.147621}, +{0.688191, -0.587785, -0.425325}, +{0.587785, -0.425325, -0.688191}, +{0.000000, -0.955423, -0.295242}, +{0.000000, -1.000000, 0.000000}, +{0.262866, -0.951056, -0.162460}, +{0.000000, -0.850651, 0.525731}, +{0.000000, -0.955423, 0.295242}, +{0.238856, -0.864188, 0.442863}, +{0.262866, -0.951056, 0.162460}, +{0.500000, -0.809017, 0.309017}, +{0.716567, -0.681718, 0.147621}, +{0.525731, -0.850651, 0.000000}, +{-0.238856, -0.864188, -0.442863}, +{-0.500000, -0.809017, -0.309017}, +{-0.262866, -0.951056, -0.162460}, +{-0.850651, -0.525731, 0.000000}, +{-0.716567, -0.681718, -0.147621}, +{-0.716567, -0.681718, 0.147621}, +{-0.525731, -0.850651, 0.000000}, +{-0.500000, -0.809017, 0.309017}, +{-0.238856, -0.864188, 0.442863}, +{-0.262866, -0.951056, 0.162460}, +{-0.864188, -0.442863, 0.238856}, +{-0.809017, -0.309017, 0.500000}, +{-0.688191, -0.587785, 0.425325}, +{-0.681718, -0.147621, 0.716567}, +{-0.442863, -0.238856, 0.864188}, +{-0.587785, -0.425325, 0.688191}, +{-0.309017, -0.500000, 0.809017}, +{-0.147621, -0.716567, 0.681718}, +{-0.425325, -0.688191, 0.587785}, +{-0.162460, -0.262866, 0.951056}, +{0.442863, -0.238856, 0.864188}, +{0.162460, -0.262866, 0.951056}, +{0.309017, -0.500000, 0.809017}, +{0.147621, -0.716567, 0.681718}, +{0.000000, -0.525731, 0.850651}, +{0.425325, -0.688191, 0.587785}, +{0.587785, -0.425325, 0.688191}, +{0.688191, -0.587785, 0.425325}, +{-0.955423, 0.295242, 0.000000}, +{-0.951056, 0.162460, 0.262866}, +{-1.000000, 0.000000, 0.000000}, +{-0.850651, 0.000000, 0.525731}, +{-0.955423, -0.295242, 0.000000}, +{-0.951056, -0.162460, 0.262866}, +{-0.864188, 0.442863, -0.238856}, +{-0.951056, 0.162460, -0.262866}, +{-0.809017, 0.309017, -0.500000}, +{-0.864188, -0.442863, -0.238856}, +{-0.951056, -0.162460, -0.262866}, +{-0.809017, -0.309017, -0.500000}, +{-0.681718, 0.147621, -0.716567}, +{-0.681718, -0.147621, -0.716567}, +{-0.850651, 0.000000, -0.525731}, +{-0.688191, 0.587785, -0.425325}, +{-0.587785, 0.425325, -0.688191}, +{-0.425325, 0.688191, -0.587785}, +{-0.425325, -0.688191, -0.587785}, +{-0.587785, -0.425325, -0.688191}, +{-0.688191, -0.587785, -0.425325}, diff --git a/source/cl_main.c b/source/cl_main.c index 245e826..86d8246 100644 --- a/source/cl_main.c +++ b/source/cl_main.c @@ -250,14 +250,14 @@ void CL_ClientCommand( const char *string ) { /* =================== -Cmd_ForwardToServer +CL_ForwardToServer adds the current command line as a clc_stringcmd to the client message. things like godmode, noclip, etc, are commands directed to the server, so when they are typed in at the console, they will need to be forwarded. =================== */ -qboolean Cmd_ForwardToServer( void ) { +qboolean CL_ForwardToServer( void ) { char *cmd; cmd = Cmd_Argv( 0 ); @@ -2659,10 +2659,6 @@ void CL_Frame( unsigned msec ) { time_after_ref = time_before_ref = 0; if( !cl_running->integer ) { - // still run cmd buffer in dedicated mode - if( cmd_buffer.waitCount > 0 ) { - cmd_buffer.waitCount--; - } return; } diff --git a/source/cl_null.c b/source/cl_null.c index 875c584..e70fe11 100644 --- a/source/cl_null.c +++ b/source/cl_null.c @@ -24,56 +24,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "com_local.h" #include "files.h" -cvar_t *cl_paused; - -void Key_Bind_Null_f( void ) { -} - -void CL_Init( void ) { - cl_paused = Cvar_Get( "cl_paused", "0", CVAR_ROM ); -} - -void CL_Drop( void ) { -} - -void CL_Disconnect( comErrorType_t type, const char *text ) { -} - -void CL_Shutdown( void ) { -} - -void CL_Frame( int msec ) { - if( cmd_buffer.waitCount > 0 ) { - cmd_buffer.waitCount--; - } -} - -void Con_Init( void ) { -} - -void Con_Print( const char *text ) { -} - qboolean CL_CheatsOK( void ) { - return qtrue; -} - -void CL_UpdateUserinfo( cvar_t *var, cvarSetSource_t source ) { -} - -qboolean Cmd_ForwardToServer( void ) { - return qfalse; + // developer option + if( Cvar_VariableInteger( "cheats" ) ) { + return qtrue; + } + return qfalse; } void SCR_DebugGraph( float value, int color ) { } -void SCR_BeginLoadingPlaque( void ) { -} - -void SCR_EndLoadingPlaque( void ) { -} - void CL_RestartFilesystem( void ) { FS_Restart(); } @@ -84,25 +45,7 @@ void CL_LocalConnect( void ) { } } -void CL_PumpEvents( void ) { -} - -void CL_AppActivate( qboolean active ) { -} - -void Key_WriteBindings( fileHandle_t f ) { -} - -void Key_Event( unsigned key, qboolean down, unsigned time ) { -} - -void Key_CharEvent( int key ) { -} - -void CL_MouseEvent( int x, int y ) { -} - -void CL_InputFrame( void ) { +static void Key_Bind_Null_f( void ) { } void Key_Init( void ) { diff --git a/source/cl_parse.c b/source/cl_parse.c index f0b0f45..b5f2b08 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -557,7 +557,8 @@ static void CL_ParseFrame( int extrabits ) { if( length > sizeof( frame.areabits ) ) { Com_Error( ERR_DROP, "%s: invalid areabits length", __func__ ); } - MSG_ReadData( frame.areabits, length ); + memcpy( frame.areabits, msg_read.data + msg_read.readcount, length ); + msg_read.readcount += length; frame.areabytes = length; } else { frame.areabytes = 0; diff --git a/source/cl_public.h b/source/cl_public.h index 42e07fc..cd44e62 100644 --- a/source/cl_public.h +++ b/source/cl_public.h @@ -59,6 +59,12 @@ void CL_UpdateUserinfo( cvar_t *var, cvarSetSource_t source ); qboolean CL_SendStatusRequest( char *buffer, size_t size ); demoInfo_t *CL_GetDemoInfo( const char *path, demoInfo_t *info ); +qboolean CL_ForwardToServer( void ); +// adds the current command line as a clc_stringcmd to the client message. +// things like godmode, noclip, etc, are commands directed to the server, +// so when they are typed in at the console, they will need to be forwarded. + +void Con_Init( void ); void Con_Print( const char *text ); void Con_Printf( const char *fmt, ... ); void Con_Close( void ); @@ -66,6 +72,7 @@ void Con_Close( void ); // this is in the client code, but can be used for debugging from server void SCR_DebugGraph (float value, int color); void SCR_BeginLoadingPlaque (void); +void SCR_EndLoadingPlaque( void ); void SCR_ModeChanged( void ); void SCR_UpdateScreen( void ); diff --git a/source/cmd.c b/source/cmd.c index 0d57654..485de10 100644 --- a/source/cmd.c +++ b/source/cmd.c @@ -22,6 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "com_local.h" #include "files.h" #include "q_list.h" +#if USE_CLIENT +#include "cl_public.h" +#endif #define Cmd_Malloc( size ) Z_TagMalloc( size, TAG_CMD ) #define Cmd_CopyString( string ) Z_TagCopyString( string, TAG_CMD ) @@ -1262,7 +1265,11 @@ void Cmd_ExecuteString( const char *text ) { if( cmd ) { if( cmd->function ) { cmd->function(); - } else if( !Cmd_ForwardToServer() ) { + } else +#if USE_CLIENT + if( !CL_ForwardToServer() ) +#endif + { Com_Printf( "Can't \"%s\", not connected\n", cmd_argv[0] ); } return; @@ -1290,8 +1297,11 @@ void Cmd_ExecuteString( const char *text ) { return; } +#if USE_CLIENT // send it as a server command if we are connected - if( !Cmd_ForwardToServer() ) { + if( !CL_ForwardToServer() ) +#endif + { Com_Printf( "Unknown command \"%s\"\n", cmd_argv[0] ); } } diff --git a/source/com_local.h b/source/com_local.h index 27b785e..d940aac 100644 --- a/source/com_local.h +++ b/source/com_local.h @@ -166,11 +166,6 @@ void Cmd_ExecuteString( const char *text ); // Parses a single line of text into arguments and tries to execute it // as if it was typed at the console -qboolean Cmd_ForwardToServer( void ); -// adds the current command line as a clc_stringcmd to the client message. -// things like godmode, noclip, etc, are commands directed to the server, -// so when they are typed in at the console, they will need to be forwarded. - char *Cmd_MacroExpandString( const char *text, qboolean aliasHack ); void Cbuf_ExecuteText( cbufExecWhen_t exec_when, const char *text ); @@ -444,7 +439,9 @@ void Com_ProcessEvents( void ); void Com_Address_g( genctx_t *ctx ); void Com_Generic_c( genctx_t *ctx, int argnum ); +#if USE_CLIENT void Com_Color_g( genctx_t *ctx ); +#endif qboolean Prompt_AddMatch( genctx_t *ctx, const char *s ); @@ -453,16 +450,23 @@ size_t Com_Uptime_m( char *buffer, size_t size ); uint32_t Com_BlockChecksum( void *buffer, size_t len ); +#if USE_CLIENT +#define Com_IsDedicated() ( dedicated->integer != 0 ) +#else +#define Com_IsDedicated() 1 +#endif + extern cvar_t *developer; extern cvar_t *dedicated; extern cvar_t *host_speeds; extern cvar_t *com_version; -extern cvar_t *mvd_running; +#if USE_CLIENT +extern cvar_t *cl_running; +extern cvar_t *cl_paused; +#endif extern cvar_t *sv_running; extern cvar_t *sv_paused; -extern cvar_t *cl_running; -extern cvar_t *cl_paused; extern cvar_t *com_timedemo; extern cvar_t *com_sleep; diff --git a/source/common.c b/source/common.c index 00461ff..e5ec0c3 100644 --- a/source/common.c +++ b/source/common.c @@ -31,6 +31,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "q_list.h" #include "bsp.h" #include "cmodel.h" +#include "q_field.h" +#include "prompt.h" #include <setjmp.h> #if USE_ZLIB #include <zlib.h> @@ -54,10 +56,12 @@ cvar_t *logfile_flush; // 1 = flush after each print cvar_t *logfile_name; cvar_t *logfile_prefix; -cvar_t *sv_running; -cvar_t *sv_paused; +#if USE_CLIENT cvar_t *cl_running; cvar_t *cl_paused; +#endif +cvar_t *sv_running; +cvar_t *sv_paused; cvar_t *com_timedemo; cvar_t *com_date_format; cvar_t *com_time_format; @@ -82,10 +86,6 @@ unsigned time_before_ref; unsigned time_after_ref; #endif -void Con_Init( void ); -void Prompt_Init( void ); -void SCR_EndLoadingPlaque( void ); - /* ============================================================================ @@ -285,8 +285,10 @@ void Com_Printf( const char *fmt, ... ) { if( rd_target ) { Com_Redirect( msg, len ); } else { +#if USE_CLIENT // graphical console Con_Print( msg ); +#endif // debugging console Sys_ConsoleOutput( msg ); @@ -393,7 +395,9 @@ void Com_Error( comErrorType_t code, const char *fmt, ... ) { if( code == ERR_DISCONNECT || code == ERR_SILENT ) { SV_Shutdown( va( "Server was killed: %s", com_errorMsg ), KILL_DISCONNECT ); +#if USE_CLIENT CL_Disconnect( code, com_errorMsg ); +#endif Com_Printf( S_COLOR_YELLOW "%s\n", com_errorMsg ); recursive = qfalse; longjmp( abortframe, -1 ); @@ -413,7 +417,9 @@ void Com_Error( comErrorType_t code, const char *fmt, ... ) { "ERROR: %s\n" "********************\n", com_errorMsg ); SV_Shutdown( va( "Server crashed: %s\n", com_errorMsg ), KILL_DROP ); +#if USE_CLIENT CL_Disconnect( ERR_DROP, com_errorMsg ); +#endif recursive = qfalse; longjmp( abortframe, -1 ); } @@ -423,7 +429,9 @@ void Com_Error( comErrorType_t code, const char *fmt, ... ) { } SV_Shutdown( va( "Server fatal crashed: %s\n", com_errorMsg ), KILL_DROP ); +#if USE_CLIENT CL_Shutdown(); +#endif Qcommon_Shutdown( qtrue ); Sys_Error( "%s", com_errorMsg ); @@ -478,7 +486,9 @@ void Com_Quit( const char *reason ) { } else { SV_Shutdown( "Server quit\n", KILL_DROP ); } +#if USE_CLIENT CL_Shutdown(); +#endif Qcommon_Shutdown( qfalse ); Sys_Quit(); @@ -1171,6 +1181,7 @@ void Com_Generic_c( genctx_t *ctx, int argnum ) { } } +#if USE_CLIENT void Com_Color_g( genctx_t *ctx ) { int color; @@ -1180,6 +1191,7 @@ void Com_Color_g( genctx_t *ctx ) { } } } +#endif /* =============== @@ -1288,7 +1300,9 @@ void Qcommon_Init( int argc, char **argv ) { Cvar_Init(); Key_Init(); Prompt_Init(); +#if USE_CLIENT Con_Init(); +#endif // // init commands and vars @@ -1306,13 +1320,13 @@ void Qcommon_Init( int argc, char **argv ) { logfile_prefix = Cvar_Get( "logfile_prefix", "[%Y-%m-%d %H:%M] ", 0 ); #if USE_CLIENT dedicated = Cvar_Get ("dedicated", "0", CVAR_NOSET); + cl_running = Cvar_Get( "cl_running", "0", CVAR_ROM ); + cl_paused = Cvar_Get( "cl_paused", "0", CVAR_ROM ); #else dedicated = Cvar_Get ("dedicated", "1", CVAR_ROM); #endif sv_running = Cvar_Get( "sv_running", "0", CVAR_ROM ); sv_paused = Cvar_Get( "sv_paused", "0", CVAR_ROM ); - cl_running = Cvar_Get( "cl_running", "0", CVAR_ROM ); - cl_paused = Cvar_Get( "cl_paused", "0", CVAR_ROM ); com_timedemo = Cvar_Get( "timedemo", "0", CVAR_CHEAT ); com_date_format = Cvar_Get( "com_date_format", "%Y-%m-%d", 0 ); #ifdef _WIN32 @@ -1390,30 +1404,35 @@ void Qcommon_Init( int argc, char **argv ) { BSP_Init(); CM_Init(); SV_Init(); +#if USE_CLIENT CL_Init(); +#endif Sys_RunConsole(); // add + commands from command line if( !Com_AddLateCommands() ) { // if the user didn't give any commands, run default action - if( dedicated->integer ) { + if( Com_IsDedicated() ) { Cbuf_AddText( "dedicated_start\n" ); } else { // TODO //Cbuf_AddText( "d1\n" ); } Cbuf_Execute(); - } else { + } +#if USE_CLIENT + else { // the user asked for something explicit // so drop the loading plaque SCR_EndLoadingPlaque(); } +#endif // even not given a starting map, dedicated server starts // listening for rcon commands (create socket after all configs // are executed to make sure port number is properly set) - if( dedicated->integer ) { + if( Com_IsDedicated() ) { NET_Config( NET_SERVER ); } diff --git a/source/cvar.c b/source/cvar.c index 162a5e4..bbf1dda 100644 --- a/source/cvar.c +++ b/source/cvar.c @@ -160,9 +160,11 @@ static void Cvar_ChangeString( cvar_t *var, const char *value, cvarSetSource_t s Cvar_ParseString( var ); if( var->flags & CVAR_INFOMASK ) { +#if USE_CLIENT if( var->flags & CVAR_USERINFO ) { CL_UpdateUserinfo( var, source ); } +#endif } var->modified = qtrue; @@ -446,11 +448,13 @@ cvar_t *Cvar_FullSet( const char *var_name, const char *value, int flags, cvarSe Cvar_SetByVar( var, value, source ); +#if USE_CLIENT // force retransmit of userinfo variables // needed for compatibility with q2admin if( ( var->flags | flags ) & CVAR_USERINFO ) { CL_UpdateUserinfo( var, source ); } +#endif var->flags &= ~CVAR_INFOMASK; var->flags |= flags; diff --git a/source/files.c b/source/files.c index 39d67bd..c297c9f 100644 --- a/source/files.c +++ b/source/files.c @@ -48,15 +48,15 @@ QUAKE FILESYSTEM // macros for dealing portably with files at OS level #ifdef _WIN32 -#define FS_strcmp Q_strcasecmp +#define FS_strcmp Q_strcasecmp #define FS_strncmp Q_strncasecmp #else -#define FS_strcmp strcmp +#define FS_strcmp strcmp #define FS_strncmp strncmp #endif -#define MAX_READ 0x40000 // read in blocks of 256k -#define MAX_WRITE 0x40000 // write in blocks of 256k +#define MAX_READ 0x40000 // read in blocks of 256k +#define MAX_WRITE 0x40000 // write in blocks of 256k // @@ -1176,6 +1176,8 @@ void FS_FreeFile( void *buffer ) { } } +#if USE_CLIENT + /* ================ FS_RenameFile @@ -1218,6 +1220,8 @@ qboolean FS_RenameFile( const char *from, const char *to ) { return qtrue; } +#endif // USE_CLIENT + /* ================ FS_FPrintf diff --git a/source/files.h b/source/files.h index 16c2e81..319e5e7 100644 --- a/source/files.h +++ b/source/files.h @@ -81,7 +81,9 @@ qboolean FS_NeedRestart( void ); void FS_Restart( void ); qboolean FS_SafeToRestart( void ); +#if USE_CLIENT qboolean FS_RenameFile( const char *from, const char *to ); +#endif char *FS_CopyExtraInfo( const char *name, const fsFileInfo_t *info ); diff --git a/source/mvd_parse.c b/source/mvd_parse.c index 0de9a47..4a8a336 100644 --- a/source/mvd_parse.c +++ b/source/mvd_parse.c @@ -25,10 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sv_local.h" #include "mvd_local.h" -#define MVD_ShowSVC( cmd ) do { \ +#define MVD_ShowSVC( cmd ) \ Com_Printf( "%3"PRIz":%s\n", msg_read.readcount - 1, \ - MVD_ServerCommandString( cmd ) ); \ - } while( 0 ) + MVD_ServerCommandString( cmd ) ) static const char mvd_strings[mvd_num_types][20] = { "mvd_bad", @@ -52,7 +51,7 @@ static const char mvd_strings[mvd_num_types][20] = { "mvd_stufftext" }; -const char *MVD_ServerCommandString( int cmd ) { +static const char *MVD_ServerCommandString( int cmd ) { const char *s; if( cmd == -1 ) { diff --git a/source/net_chan.c b/source/net_chan.c index b34097f..666ce44 100644 --- a/source/net_chan.c +++ b/source/net_chan.c @@ -141,7 +141,7 @@ neterr_t Netchan_OutOfBandPrint( netsrc_t sock, const netadr_t *address, // ============================================================================ static size_t NetchanOld_TransmitNextFragment( netchan_t *netchan ) { - Com_Error( ERR_FATAL, "NetchanOld_TransmitNextFragment: not implemented" ); + Com_Error( ERR_FATAL, "%s: not implemented", __func__ ); return 0; } @@ -205,6 +205,7 @@ static size_t NetchanOld_Transmit( netchan_t *netchan, size_t length, const void SZ_WriteLong( &send, w1 ); SZ_WriteLong( &send, w2 ); +#if USE_CLIENT // send the qport if we are a client if( netchan->sock == NS_CLIENT ) { if( netchan->protocol < PROTOCOL_VERSION_R1Q2 ) { @@ -213,6 +214,7 @@ static size_t NetchanOld_Transmit( netchan_t *netchan, size_t length, const void SZ_WriteByte( &send, netchan->qport ); } } +#endif // copy the reliable message to the packet first if( send_reliable ) { @@ -227,6 +229,7 @@ static size_t NetchanOld_Transmit( netchan_t *netchan, size_t length, const void Com_WPrintf( "%s: dumped unreliable\n", NET_AdrToString( &netchan->remote_address ) ); +#if USE_CLIENT if( showpackets->integer ) { Com_Printf( "send %4"PRIz" : s=%d ack=%d rack=%d", send.cursize, @@ -238,6 +241,7 @@ static size_t NetchanOld_Transmit( netchan_t *netchan, size_t length, const void } Com_Printf( "\n" ); } +#endif // send the datagram ret = NET_SendPacket( netchan->sock, &netchan->remote_address, @@ -268,13 +272,16 @@ static qboolean NetchanOld_Process( netchan_t *netchan ) { sequence_ack = MSG_ReadLong(); // read the qport if we are a server - if( netchan->sock == NS_SERVER ) { +#if USE_CLIENT + if( netchan->sock == NS_SERVER ) +#endif + { if( netchan->protocol < PROTOCOL_VERSION_R1Q2 ) { MSG_ReadShort(); } else if( netchan->qport ) { MSG_ReadByte(); } - } + } reliable_message = sequence >> 31; reliable_ack = sequence_ack >> 31; @@ -282,6 +289,7 @@ static qboolean NetchanOld_Process( netchan_t *netchan ) { sequence &= ~( 1 << 31 ); sequence_ack &= ~( 1 << 31 ); +#if USE_CLIENT if( showpackets->integer ) { Com_Printf( "recv %4"PRIz" : s=%d ack=%d rack=%d", msg_read.cursize, @@ -293,6 +301,7 @@ static qboolean NetchanOld_Process( netchan_t *netchan ) { } Com_Printf( "\n" ); } +#endif // // discard stale or duplicated packets @@ -430,10 +439,12 @@ static size_t NetchanNew_TransmitNextFragment( netchan_t *netchan ) { SZ_WriteLong( &send, w1 ); SZ_WriteLong( &send, w2 ); +#if USE_CLIENT // send the qport if we are a client if( netchan->sock == NS_CLIENT && netchan->qport ) { SZ_WriteByte( &send, netchan->qport ); } +#endif fragment_length = chan->fragment_out.cursize - chan->fragment_out.readcount; if( fragment_length > netchan->maxpacketlen ) { @@ -456,6 +467,7 @@ static size_t NetchanNew_TransmitNextFragment( netchan_t *netchan ) { SZ_Write( &send, chan->fragment_out.data + chan->fragment_out.readcount, fragment_length ); +#if USE_CLIENT if( showpackets->integer ) { Com_Printf( "send %4"PRIz" : s=%d ack=%d rack=%d " "fragment_offset=%"PRIz" more_fragments=%d", @@ -470,6 +482,7 @@ static size_t NetchanNew_TransmitNextFragment( netchan_t *netchan ) { } Com_Printf( "\n" ); } +#endif chan->fragment_out.readcount += fragment_length; netchan->fragment_pending = more_fragments; @@ -566,10 +579,12 @@ static size_t NetchanNew_Transmit( netchan_t *netchan, size_t length, const void SZ_WriteLong( &send, w1 ); SZ_WriteLong( &send, w2 ); +#if USE_CLIENT // send the qport if we are a client if( netchan->sock == NS_CLIENT && netchan->qport ) { SZ_WriteByte( &send, netchan->qport ); } +#endif // copy the reliable message to the packet first if( send_reliable ) { @@ -580,6 +595,7 @@ static size_t NetchanNew_Transmit( netchan_t *netchan, size_t length, const void // add the unreliable part SZ_Write( &send, data, length ); +#if USE_CLIENT if( showpackets->integer ) { Com_Printf( "send %4"PRIz" : s=%d ack=%d rack=%d", send.cursize, @@ -591,6 +607,7 @@ static size_t NetchanNew_Transmit( netchan_t *netchan, size_t length, const void } Com_Printf( "\n" ); } +#endif // send the datagram ret = NET_SendPacket( netchan->sock, &netchan->remote_address, @@ -620,9 +637,12 @@ static qboolean NetchanNew_Process( netchan_t *netchan ) { sequence_ack = MSG_ReadLong(); // read the qport if we are a server - if( netchan->sock == NS_SERVER && netchan->qport ) { - MSG_ReadByte(); - } +#if USE_CLIENT + if( netchan->sock == NS_SERVER ) +#endif + if( netchan->qport ) { + MSG_ReadByte(); + } reliable_message = sequence >> 31; reliable_ack = sequence_ack >> 31; @@ -639,6 +659,7 @@ static qboolean NetchanNew_Process( netchan_t *netchan ) { fragment_offset &= 0x7FFF; } +#if USE_CLIENT if( showpackets->integer ) { Com_Printf( "recv %4"PRIz" : s=%d ack=%d rack=%d", msg_read.cursize, sequence, sequence_ack, reliable_ack ); @@ -651,6 +672,7 @@ static qboolean NetchanNew_Process( netchan_t *netchan ) { } Com_Printf( "\n" ); } +#endif // // discard stale or duplicated packets diff --git a/source/q_msg.c b/source/q_msg.c index 96f8f76..15a59b7 100644 --- a/source/q_msg.c +++ b/source/q_msg.c @@ -166,7 +166,7 @@ void MSG_WriteString( const char *string ) { MSG_WriteCoord ============= */ -void MSG_WriteCoord( float f ) { +static inline void MSG_WriteCoord( float f ) { MSG_WriteShort( ( int )( f * 8 ) ); } @@ -195,10 +195,12 @@ void MSG_WriteAngle( float f ) { MSG_WriteAngle16 ============= */ -void MSG_WriteAngle16( float f ) { +static inline void MSG_WriteAngle16( float f ) { MSG_WriteShort( ANGLE2SHORT( f ) ); } +#if USE_CLIENT + /* ============= MSG_WriteDeltaUsercmd @@ -434,6 +436,8 @@ int MSG_WriteDeltaUsercmd_Enhanced( const usercmd_t *from, return bits; } +#endif // USE_CLIENT + void MSG_WriteDir( const vec3_t dir ) { int best; @@ -1566,28 +1570,28 @@ size_t MSG_ReadStringLine( char *dest, size_t size ) { return l; } -float MSG_ReadCoord (void) -{ +static inline float MSG_ReadCoord (void) { return MSG_ReadShort() * (1.0/8); } -void MSG_ReadPos ( vec3_t pos) -{ +#if !USE_CLIENT +static inline +#endif +void MSG_ReadPos ( vec3_t pos) { pos[0] = MSG_ReadShort() * (1.0/8); pos[1] = MSG_ReadShort() * (1.0/8); pos[2] = MSG_ReadShort() * (1.0/8); } -float MSG_ReadAngle (void) -{ +static inline float MSG_ReadAngle (void) { return MSG_ReadChar() * (360.0/256); } -float MSG_ReadAngle16 (void) -{ +static inline float MSG_ReadAngle16 (void) { return SHORT2ANGLE(MSG_ReadShort()); } +#if USE_CLIENT void MSG_ReadDir( vec3_t dir ) { int b; @@ -1596,6 +1600,7 @@ void MSG_ReadDir( vec3_t dir ) { Com_Error( ERR_DROP, "MSG_ReadDir: out of range" ); VectorCopy( bytedirs[b], dir ); } +#endif void MSG_ReadDeltaUsercmd( const usercmd_t *from, usercmd_t *to ) { int bits; @@ -1826,14 +1831,25 @@ void MSG_ReadDeltaUsercmd_Enhanced( const usercmd_t *from, } } +#if 0 +size_t MSG_ReadData( void *data, size_t len ) { + size_t remaining; -void MSG_ReadData ( void *data, int len) -{ - int i; + if( msg_read.readcount >= msg_read.cursize ) { + return 0; + } - for (i=0 ; i<len ; i++) - ((byte *)data)[i] = MSG_ReadByte (); + remaining = msg_read.cursize - msg_read.readcount; + if( len > remaining ) { + len = remining; + } + + memcpy( data, msg_read.data + msg_read.readcount, len ); + msg_read.readcount += len; + + return len; } +#endif /* ================= @@ -1988,6 +2004,8 @@ void MSG_ParseDeltaEntity( const entity_state_t *from, } } +#if USE_CLIENT + /* =================== MSG_ParseDeltaPlayerstate_Default @@ -2232,6 +2250,8 @@ void MSG_ParseDeltaPlayerstate_Enhanced( const player_state_t *from, } +#endif // USE_CLIENT + /* =================== MSG_ParseDeltaPlayerstate_Packet @@ -2420,6 +2440,8 @@ void MSG_ShowDeltaEntityBits( int bits ) { } +#if USE_CLIENT + void MSG_ShowDeltaPlayerstateBits_Default( int flags ) { if( flags & PS_M_TYPE ) { SHOWBITS( "pmove.pm_type" ); @@ -2574,6 +2596,8 @@ void MSG_ShowDeltaPlayerstateBits_Enhanced( int flags ) { } } +#endif // USE_CLIENT + void MSG_ShowDeltaPlayerstateBits_Packet( int flags ) { if( flags & PPS_M_TYPE ) { SHOWBITS( "pmove.pm_type" ); @@ -2636,6 +2660,8 @@ void MSG_ShowDeltaPlayerstateBits_Packet( int flags ) { } } +#if USE_CLIENT + void MSG_ShowDeltaUsercmdBits_Enhanced( int bits ) { if( !bits ) { SHOWBITS( "<none>" ); @@ -2661,6 +2687,8 @@ void MSG_ShowDeltaUsercmdBits_Enhanced( int bits ) { SHOWBITS( "msec" ); } +#endif // USE_CLIENT + static const char *const svc_strings[svc_num_types] = { "svc_bad", diff --git a/source/q_msg.h b/source/q_msg.h index e94e2b7..1d0e227 100644 --- a/source/q_msg.h +++ b/source/q_msg.h @@ -32,13 +32,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef struct sizebuf_s { uint32_t tag; - qboolean allowoverflow; - qboolean overflowed; // set to qtrue if the buffer size failed - byte *data; - size_t maxsize; - size_t cursize; - size_t readcount; - size_t bitpos; + qboolean allowoverflow; + qboolean overflowed; // set to qtrue if the buffer size failed + byte *data; + size_t maxsize; + size_t cursize; + size_t readcount; + size_t bitpos; } sizebuf_t; void SZ_Init( sizebuf_t *buf, void *data, size_t length ); @@ -51,104 +51,105 @@ void SZ_WriteLong( sizebuf_t *sb, int c ); void SZ_WriteString( sizebuf_t *sb, const char *string ); static inline void *SZ_Write( sizebuf_t *buf, const void *data, size_t length ) { - return memcpy( SZ_GetSpace( buf, length ), data, length ); + return memcpy( SZ_GetSpace( buf, length ), data, length ); } //============================================================================ typedef enum { - MSG_PS_IGNORE_GUNINDEX = ( 1 << 0 ), - MSG_PS_IGNORE_GUNFRAMES = ( 1 << 1 ), - MSG_PS_IGNORE_BLEND = ( 1 << 2 ), - MSG_PS_IGNORE_VIEWANGLES = ( 1 << 3 ), - MSG_PS_IGNORE_DELTAANGLES = ( 1 << 4 ), - MSG_PS_IGNORE_PREDICTION = ( 1 << 5 ), // mutually exclusive with IGNORE_VIEWANGLES - MSG_PS_FORCE = ( 1 << 7 ), - MSG_PS_REMOVE = ( 1 << 8 ) + MSG_PS_IGNORE_GUNINDEX = ( 1 << 0 ), + MSG_PS_IGNORE_GUNFRAMES = ( 1 << 1 ), + MSG_PS_IGNORE_BLEND = ( 1 << 2 ), + MSG_PS_IGNORE_VIEWANGLES = ( 1 << 3 ), + MSG_PS_IGNORE_DELTAANGLES = ( 1 << 4 ), + MSG_PS_IGNORE_PREDICTION = ( 1 << 5 ), // mutually exclusive with IGNORE_VIEWANGLES + MSG_PS_FORCE = ( 1 << 7 ), + MSG_PS_REMOVE = ( 1 << 8 ) } msgPsFlags_t; typedef enum { - MSG_ES_FORCE = ( 1 << 0 ), - MSG_ES_NEWENTITY = ( 1 << 1 ), - MSG_ES_FIRSTPERSON = ( 1 << 2 ), - MSG_ES_LONGSOLID = ( 1 << 3 ), - MSG_ES_REMOVE = ( 1 << 4 ) + MSG_ES_FORCE = ( 1 << 0 ), + MSG_ES_NEWENTITY = ( 1 << 1 ), + MSG_ES_FIRSTPERSON = ( 1 << 2 ), + MSG_ES_LONGSOLID = ( 1 << 3 ), + MSG_ES_REMOVE = ( 1 << 4 ) } msgEsFlags_t; - -extern sizebuf_t msg_write; -extern byte msg_write_buffer[MAX_MSGLEN]; - -extern sizebuf_t msg_read; -extern byte msg_read_buffer[MAX_MSGLEN]; - -extern const entity_state_t nullEntityState; -extern const player_state_t nullPlayerState; -extern const usercmd_t nullUserCmd; - -void MSG_Init( void ); - -void MSG_BeginWriting( void ); -void MSG_WriteChar( int c ); -void MSG_WriteByte( int c ); -void MSG_WriteShort( int c ); -void MSG_WriteLong( int c ); -void MSG_WriteFloat( float f ); -void MSG_WriteString( const char *s ); -void MSG_WriteCoord( float f ); -void MSG_WritePos( const vec3_t pos ); -void MSG_WriteAngle( float f ); -void MSG_WriteAngle16( float f ); -void MSG_WriteBits( int value, int bits ); -int MSG_WriteDeltaUsercmd( const usercmd_t *from, const usercmd_t *cmd, int version ); -int MSG_WriteDeltaUsercmd_Enhanced( const usercmd_t *from, const usercmd_t *cmd, int version ); -void MSG_WriteDir ( const vec3_t vector); -void MSG_WriteDeltaEntity( const entity_state_t *from, const entity_state_t *to, msgEsFlags_t flags ); -void MSG_WriteDeltaPlayerstate_Default( const player_state_t *from, const player_state_t *to ); -int MSG_WriteDeltaPlayerstate_Enhanced( const player_state_t *from, player_state_t *to, msgPsFlags_t flags ); -void MSG_WriteDeltaPlayerstate_Packet( const player_state_t *from, const player_state_t *to, int number, msgPsFlags_t flags ); -void MSG_FlushTo( sizebuf_t *dest ); + +extern sizebuf_t msg_write; +extern byte msg_write_buffer[MAX_MSGLEN]; + +extern sizebuf_t msg_read; +extern byte msg_read_buffer[MAX_MSGLEN]; + +extern const entity_state_t nullEntityState; +extern const player_state_t nullPlayerState; +extern const usercmd_t nullUserCmd; + +void MSG_Init( void ); + +void MSG_BeginWriting( void ); +void MSG_WriteChar( int c ); +void MSG_WriteByte( int c ); +void MSG_WriteShort( int c ); +void MSG_WriteLong( int c ); +void MSG_WriteString( const char *s ); +void MSG_WritePos( const vec3_t pos ); +void MSG_WriteAngle( float f ); +#if USE_CLIENT +void MSG_WriteBits( int value, int bits ); +int MSG_WriteDeltaUsercmd( const usercmd_t *from, const usercmd_t *cmd, int version ); +int MSG_WriteDeltaUsercmd_Enhanced( const usercmd_t *from, const usercmd_t *cmd, int version ); +#endif +void MSG_WriteDir ( const vec3_t vector); +void MSG_WriteDeltaEntity( const entity_state_t *from, const entity_state_t *to, msgEsFlags_t flags ); +void MSG_WriteDeltaPlayerstate_Default( const player_state_t *from, const player_state_t *to ); +int MSG_WriteDeltaPlayerstate_Enhanced( const player_state_t *from, player_state_t *to, msgPsFlags_t flags ); +void MSG_WriteDeltaPlayerstate_Packet( const player_state_t *from, const player_state_t *to, int number, msgPsFlags_t flags ); +void MSG_FlushTo( sizebuf_t *dest ); void MSG_Printf( const char *fmt, ... ) q_printf( 1, 2 ); static inline void *MSG_WriteData( const void *data, size_t length ) { - return memcpy( SZ_GetSpace( &msg_write, length ), data, length ); + return memcpy( SZ_GetSpace( &msg_write, length ), data, length ); } -void MSG_BeginReading( void ); -int MSG_ReadChar( void ); -int MSG_ReadByte( void ); -int MSG_ReadShort( void ); +void MSG_BeginReading( void ); +int MSG_ReadChar( void ); +int MSG_ReadByte( void ); +int MSG_ReadShort( void ); int MSG_ReadWord( void ); -int MSG_ReadLong( void ); -float MSG_ReadFloat( void ); +int MSG_ReadLong( void ); size_t MSG_ReadString( char *dest, size_t size ); size_t MSG_ReadStringLine( char *dest, size_t size ); -float MSG_ReadCoord( void ); -void MSG_ReadPos( vec3_t pos ); -float MSG_ReadAngle( void ); -float MSG_ReadAngle16 ( void ); -int MSG_ReadBits( int bits ); -void MSG_ReadDeltaUsercmd( const usercmd_t *from, usercmd_t *cmd ); -void MSG_ReadDeltaUsercmd_Hacked( const usercmd_t *from, usercmd_t *to ); -void MSG_ReadDeltaUsercmd_Enhanced( const usercmd_t *from, usercmd_t *to, int version ); -void MSG_ReadDir( vec3_t vector ); -void MSG_ReadData( void *buffer, int size ); -int MSG_ParseEntityBits( int *bits ); -void MSG_ParseDeltaEntity( const entity_state_t *from, entity_state_t *to, int number, int bits ); -void MSG_ParseDeltaPlayerstate_Default( const player_state_t *from, player_state_t *to, int flags ); -void MSG_ParseDeltaPlayerstate_Enhanced( const player_state_t *from, player_state_t *to, int flags, int extraflags ); -void MSG_ParseDeltaPlayerstate_Packet( const player_state_t *from, player_state_t *to, int flags ); - -void MSG_ShowDeltaEntityBits( int bits ); -void MSG_ShowDeltaPlayerstateBits_Default( int flags ); -void MSG_ShowDeltaPlayerstateBits_Enhanced( int flags ); -void MSG_ShowDeltaPlayerstateBits_Packet( int flags ); -void MSG_ShowDeltaUsercmdBits_Enhanced( int bits ); +#if USE_CLIENT +void MSG_ReadPos( vec3_t pos ); +void MSG_ReadDir( vec3_t vector ); +#endif +int MSG_ReadBits( int bits ); +void MSG_ReadDeltaUsercmd( const usercmd_t *from, usercmd_t *cmd ); +void MSG_ReadDeltaUsercmd_Hacked( const usercmd_t *from, usercmd_t *to ); +void MSG_ReadDeltaUsercmd_Enhanced( const usercmd_t *from, usercmd_t *to, int version ); +//void MSG_ReadData( void *buffer, int size ); +int MSG_ParseEntityBits( int *bits ); +void MSG_ParseDeltaEntity( const entity_state_t *from, entity_state_t *to, int number, int bits ); +#if USE_CLIENT +void MSG_ParseDeltaPlayerstate_Default( const player_state_t *from, player_state_t *to, int flags ); +void MSG_ParseDeltaPlayerstate_Enhanced( const player_state_t *from, player_state_t *to, int flags, int extraflags ); +#endif +void MSG_ParseDeltaPlayerstate_Packet( const player_state_t *from, player_state_t *to, int flags ); + +void MSG_ShowDeltaEntityBits( int bits ); +#if USE_CLIENT +void MSG_ShowDeltaPlayerstateBits_Default( int flags ); +void MSG_ShowDeltaPlayerstateBits_Enhanced( int flags ); +#endif +void MSG_ShowDeltaPlayerstateBits_Packet( int flags ); +#if USE_CLIENT +void MSG_ShowDeltaUsercmdBits_Enhanced( int bits ); +#endif const char *MSG_ServerCommandString( int cmd ); -#define MSG_ShowSVC( cmd ) do { \ - Com_Printf( "%3"PRIz":%s\n", msg_read.readcount - 1, \ - MSG_ServerCommandString( cmd ) ); \ - } while( 0 ) - +#define MSG_ShowSVC( cmd ) \ + Com_Printf( "%3"PRIz":%s\n", msg_read.readcount - 1, \ + MSG_ServerCommandString( cmd ) ) diff --git a/source/q_shared.c b/source/q_shared.c index b410802..3d50803 100644 --- a/source/q_shared.c +++ b/source/q_shared.c @@ -21,10 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <config.h> #include "q_shared.h" -static const char hexchars[] = "0123456789ABCDEF"; - vec3_t vec3_origin = { 0, 0, 0 }; +#if USE_CLIENT const color_t colorBlack = { 0, 0, 0, 255 }; const color_t colorRed = { 255, 0, 0, 255 }; const color_t colorGreen = { 0, 255, 0, 255 }; @@ -50,170 +49,10 @@ const char colorNames[10][8] = { "blue", "cyan", "magenta", "white", "alt", "none" }; +#endif // USE_CLIENT const vec3_t bytedirs[NUMVERTEXNORMALS] = { -{-0.525731, 0.000000, 0.850651}, -{-0.442863, 0.238856, 0.864188}, -{-0.295242, 0.000000, 0.955423}, -{-0.309017, 0.500000, 0.809017}, -{-0.162460, 0.262866, 0.951056}, -{0.000000, 0.000000, 1.000000}, -{0.000000, 0.850651, 0.525731}, -{-0.147621, 0.716567, 0.681718}, -{0.147621, 0.716567, 0.681718}, -{0.000000, 0.525731, 0.850651}, -{0.309017, 0.500000, 0.809017}, -{0.525731, 0.000000, 0.850651}, -{0.295242, 0.000000, 0.955423}, -{0.442863, 0.238856, 0.864188}, -{0.162460, 0.262866, 0.951056}, -{-0.681718, 0.147621, 0.716567}, -{-0.809017, 0.309017, 0.500000}, -{-0.587785, 0.425325, 0.688191}, -{-0.850651, 0.525731, 0.000000}, -{-0.864188, 0.442863, 0.238856}, -{-0.716567, 0.681718, 0.147621}, -{-0.688191, 0.587785, 0.425325}, -{-0.500000, 0.809017, 0.309017}, -{-0.238856, 0.864188, 0.442863}, -{-0.425325, 0.688191, 0.587785}, -{-0.716567, 0.681718, -0.147621}, -{-0.500000, 0.809017, -0.309017}, -{-0.525731, 0.850651, 0.000000}, -{0.000000, 0.850651, -0.525731}, -{-0.238856, 0.864188, -0.442863}, -{0.000000, 0.955423, -0.295242}, -{-0.262866, 0.951056, -0.162460}, -{0.000000, 1.000000, 0.000000}, -{0.000000, 0.955423, 0.295242}, -{-0.262866, 0.951056, 0.162460}, -{0.238856, 0.864188, 0.442863}, -{0.262866, 0.951056, 0.162460}, -{0.500000, 0.809017, 0.309017}, -{0.238856, 0.864188, -0.442863}, -{0.262866, 0.951056, -0.162460}, -{0.500000, 0.809017, -0.309017}, -{0.850651, 0.525731, 0.000000}, -{0.716567, 0.681718, 0.147621}, -{0.716567, 0.681718, -0.147621}, -{0.525731, 0.850651, 0.000000}, -{0.425325, 0.688191, 0.587785}, -{0.864188, 0.442863, 0.238856}, -{0.688191, 0.587785, 0.425325}, -{0.809017, 0.309017, 0.500000}, -{0.681718, 0.147621, 0.716567}, -{0.587785, 0.425325, 0.688191}, -{0.955423, 0.295242, 0.000000}, -{1.000000, 0.000000, 0.000000}, -{0.951056, 0.162460, 0.262866}, -{0.850651, -0.525731, 0.000000}, -{0.955423, -0.295242, 0.000000}, -{0.864188, -0.442863, 0.238856}, -{0.951056, -0.162460, 0.262866}, -{0.809017, -0.309017, 0.500000}, -{0.681718, -0.147621, 0.716567}, -{0.850651, 0.000000, 0.525731}, -{0.864188, 0.442863, -0.238856}, -{0.809017, 0.309017, -0.500000}, -{0.951056, 0.162460, -0.262866}, -{0.525731, 0.000000, -0.850651}, -{0.681718, 0.147621, -0.716567}, -{0.681718, -0.147621, -0.716567}, -{0.850651, 0.000000, -0.525731}, -{0.809017, -0.309017, -0.500000}, -{0.864188, -0.442863, -0.238856}, -{0.951056, -0.162460, -0.262866}, -{0.147621, 0.716567, -0.681718}, -{0.309017, 0.500000, -0.809017}, -{0.425325, 0.688191, -0.587785}, -{0.442863, 0.238856, -0.864188}, -{0.587785, 0.425325, -0.688191}, -{0.688191, 0.587785, -0.425325}, -{-0.147621, 0.716567, -0.681718}, -{-0.309017, 0.500000, -0.809017}, -{0.000000, 0.525731, -0.850651}, -{-0.525731, 0.000000, -0.850651}, -{-0.442863, 0.238856, -0.864188}, -{-0.295242, 0.000000, -0.955423}, -{-0.162460, 0.262866, -0.951056}, -{0.000000, 0.000000, -1.000000}, -{0.295242, 0.000000, -0.955423}, -{0.162460, 0.262866, -0.951056}, -{-0.442863, -0.238856, -0.864188}, -{-0.309017, -0.500000, -0.809017}, -{-0.162460, -0.262866, -0.951056}, -{0.000000, -0.850651, -0.525731}, -{-0.147621, -0.716567, -0.681718}, -{0.147621, -0.716567, -0.681718}, -{0.000000, -0.525731, -0.850651}, -{0.309017, -0.500000, -0.809017}, -{0.442863, -0.238856, -0.864188}, -{0.162460, -0.262866, -0.951056}, -{0.238856, -0.864188, -0.442863}, -{0.500000, -0.809017, -0.309017}, -{0.425325, -0.688191, -0.587785}, -{0.716567, -0.681718, -0.147621}, -{0.688191, -0.587785, -0.425325}, -{0.587785, -0.425325, -0.688191}, -{0.000000, -0.955423, -0.295242}, -{0.000000, -1.000000, 0.000000}, -{0.262866, -0.951056, -0.162460}, -{0.000000, -0.850651, 0.525731}, -{0.000000, -0.955423, 0.295242}, -{0.238856, -0.864188, 0.442863}, -{0.262866, -0.951056, 0.162460}, -{0.500000, -0.809017, 0.309017}, -{0.716567, -0.681718, 0.147621}, -{0.525731, -0.850651, 0.000000}, -{-0.238856, -0.864188, -0.442863}, -{-0.500000, -0.809017, -0.309017}, -{-0.262866, -0.951056, -0.162460}, -{-0.850651, -0.525731, 0.000000}, -{-0.716567, -0.681718, -0.147621}, -{-0.716567, -0.681718, 0.147621}, -{-0.525731, -0.850651, 0.000000}, -{-0.500000, -0.809017, 0.309017}, -{-0.238856, -0.864188, 0.442863}, -{-0.262866, -0.951056, 0.162460}, -{-0.864188, -0.442863, 0.238856}, -{-0.809017, -0.309017, 0.500000}, -{-0.688191, -0.587785, 0.425325}, -{-0.681718, -0.147621, 0.716567}, -{-0.442863, -0.238856, 0.864188}, -{-0.587785, -0.425325, 0.688191}, -{-0.309017, -0.500000, 0.809017}, -{-0.147621, -0.716567, 0.681718}, -{-0.425325, -0.688191, 0.587785}, -{-0.162460, -0.262866, 0.951056}, -{0.442863, -0.238856, 0.864188}, -{0.162460, -0.262866, 0.951056}, -{0.309017, -0.500000, 0.809017}, -{0.147621, -0.716567, 0.681718}, -{0.000000, -0.525731, 0.850651}, -{0.425325, -0.688191, 0.587785}, -{0.587785, -0.425325, 0.688191}, -{0.688191, -0.587785, 0.425325}, -{-0.955423, 0.295242, 0.000000}, -{-0.951056, 0.162460, 0.262866}, -{-1.000000, 0.000000, 0.000000}, -{-0.850651, 0.000000, 0.525731}, -{-0.955423, -0.295242, 0.000000}, -{-0.951056, -0.162460, 0.262866}, -{-0.864188, 0.442863, -0.238856}, -{-0.951056, 0.162460, -0.262866}, -{-0.809017, 0.309017, -0.500000}, -{-0.864188, -0.442863, -0.238856}, -{-0.951056, -0.162460, -0.262866}, -{-0.809017, -0.309017, -0.500000}, -{-0.681718, 0.147621, -0.716567}, -{-0.681718, -0.147621, -0.716567}, -{-0.850651, 0.000000, -0.525731}, -{-0.688191, 0.587785, -0.425325}, -{-0.587785, 0.425325, -0.688191}, -{-0.425325, 0.688191, -0.587785}, -{-0.425325, -0.688191, -0.587785}, -{-0.587785, -0.425325, -0.688191}, -{-0.688191, -0.587785, -0.425325}, +#include "anorms.h" }; int DirToByte( const vec3_t dir ) { @@ -247,66 +86,10 @@ void ByteToDir( int index, vec3_t dir ) { //============================================================================ -void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ) -{ - float m[3][3]; - float im[3][3]; - float zrot[3][3]; - float tmpmat[3][3]; - float rot[3][3]; - int i; - vec3_t vr, vup, vf; - - vf[0] = dir[0]; - vf[1] = dir[1]; - vf[2] = dir[2]; - - PerpendicularVector( vr, dir ); - CrossProduct( vr, vf, vup ); - - m[0][0] = vr[0]; - m[1][0] = vr[1]; - m[2][0] = vr[2]; - - m[0][1] = vup[0]; - m[1][1] = vup[1]; - m[2][1] = vup[2]; - - m[0][2] = vf[0]; - m[1][2] = vf[1]; - m[2][2] = vf[2]; - - memcpy( im, m, sizeof( im ) ); - - im[0][1] = m[1][0]; - im[0][2] = m[2][0]; - im[1][0] = m[0][1]; - im[1][2] = m[2][1]; - im[2][0] = m[0][2]; - im[2][1] = m[1][2]; - - memset( zrot, 0, sizeof( zrot ) ); - zrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F; - - zrot[0][0] = cos( DEG2RAD( degrees ) ); - zrot[0][1] = sin( DEG2RAD( degrees ) ); - zrot[1][0] = -sin( DEG2RAD( degrees ) ); - zrot[1][1] = cos( DEG2RAD( degrees ) ); - - R_ConcatRotations( m, zrot, tmpmat ); - R_ConcatRotations( tmpmat, im, rot ); - - for ( i = 0; i < 3; i++ ) - { - dst[i] = rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] * point[2]; - } -} - void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) { float angle; float sr, sp, sy, cr, cp, cy; - // static to help MS compiler fp bugs angle = angles[YAW] * (M_PI*2 / 360); sy = sin(angle); @@ -395,68 +178,6 @@ void PerpendicularVector( vec3_t dst, const vec3_t src ) -/* -================ -R_ConcatRotations -================ -*/ -void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]) -{ - out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + - in1[0][2] * in2[2][0]; - out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + - in1[0][2] * in2[2][1]; - out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + - in1[0][2] * in2[2][2]; - out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + - in1[1][2] * in2[2][0]; - out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + - in1[1][2] * in2[2][1]; - out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + - in1[1][2] * in2[2][2]; - out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + - in1[2][2] * in2[2][0]; - out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + - in1[2][2] * in2[2][1]; - out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + - in1[2][2] * in2[2][2]; -} - - -/* -================ -R_ConcatTransforms -================ -*/ -void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]) -{ - out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + - in1[0][2] * in2[2][0]; - out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + - in1[0][2] * in2[2][1]; - out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + - in1[0][2] * in2[2][2]; - out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] + - in1[0][2] * in2[2][3] + in1[0][3]; - out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + - in1[1][2] * in2[2][0]; - out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + - in1[1][2] * in2[2][1]; - out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + - in1[1][2] * in2[2][2]; - out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] + - in1[1][2] * in2[2][3] + in1[1][3]; - out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + - in1[2][2] * in2[2][0]; - out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + - in1[2][2] * in2[2][1]; - out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + - in1[2][2] * in2[2][2]; - out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + - in1[2][2] * in2[2][3] + in1[2][3]; -} - - //============================================================================ /* @@ -522,37 +243,6 @@ dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; } #endif // USE_ASM -void ClearBounds (vec3_t mins, vec3_t maxs) -{ - mins[0] = mins[1] = mins[2] = 99999; - maxs[0] = maxs[1] = maxs[2] = -99999; -} - -void AddPointToBounds (const vec3_t v, vec3_t mins, vec3_t maxs) -{ - int i; - vec_t val; - - for (i=0 ; i<3 ; i++) - { - val = v[i]; - if (val < mins[i]) - mins[i] = val; - if (val > maxs[i]) - maxs[i] = val; - } -} - -void UnionBounds( vec3_t a[2], vec3_t b[2], vec3_t c[2] ) { - c[0][0] = b[0][0] < a[0][0] ? b[0][0] : a[0][0]; - c[0][1] = b[0][1] < a[0][1] ? b[0][1] : a[0][1]; - c[0][2] = b[0][2] < a[0][2] ? b[0][2] : a[0][2]; - - c[1][0] = b[1][0] > a[1][0] ? b[1][0] : a[1][0]; - c[1][1] = b[1][1] > a[1][1] ? b[1][1] : a[1][1]; - c[1][2] = b[1][2] > a[1][2] ? b[1][2] : a[1][2]; -} - vec_t VectorNormalize (vec3_t v) { float length, ilength; @@ -591,13 +281,41 @@ vec_t VectorNormalize2 (vec3_t v, vec3_t out) } +void ClearBounds (vec3_t mins, vec3_t maxs) { + mins[0] = mins[1] = mins[2] = 99999; + maxs[0] = maxs[1] = maxs[2] = -99999; +} + +void AddPointToBounds (const vec3_t v, vec3_t mins, vec3_t maxs) { + int i; + vec_t val; + + for (i=0 ; i<3 ; i++) + { + val = v[i]; + if (val < mins[i]) + mins[i] = val; + if (val > maxs[i]) + maxs[i] = val; + } +} + +void UnionBounds( vec3_t a[2], vec3_t b[2], vec3_t c[2] ) { + c[0][0] = b[0][0] < a[0][0] ? b[0][0] : a[0][0]; + c[0][1] = b[0][1] < a[0][1] ? b[0][1] : a[0][1]; + c[0][2] = b[0][2] < a[0][2] ? b[0][2] : a[0][2]; + + c[1][0] = b[1][0] > a[1][0] ? b[1][0] : a[1][0]; + c[1][1] = b[1][1] > a[1][1] ? b[1][1] : a[1][1]; + c[1][2] = b[1][2] > a[1][2] ? b[1][2] : a[1][2]; +} + /* ================= RadiusFromBounds ================= */ -vec_t RadiusFromBounds (const vec3_t mins, const vec3_t maxs) -{ +vec_t RadiusFromBounds (const vec3_t mins, const vec3_t maxs) { int i; vec3_t corner; vec_t a, b; @@ -612,14 +330,6 @@ vec_t RadiusFromBounds (const vec3_t mins, const vec3_t maxs) return VectorLength (corner); } -int Q_log2(int val) -{ - int answer=0; - while (val>>=1) - answer++; - return answer; -} - /* =============== Q_CeilPowerOfTwo @@ -645,7 +355,7 @@ float Com_CalcFov( float fov_x, float width, float height ) { float x; if( fov_x < 1 || fov_x > 179 ) - Com_Error( ERR_DROP, "Com_CalcFov: bad fov: %f", fov_x ); + Com_Error( ERR_DROP, "%s: bad fov: %f", __func__, fov_x ); x = width / tan( fov_x / 360 * M_PI ); @@ -693,6 +403,8 @@ void SetPlaneSignbits( cplane_t *plane ) { //==================================================================================== +static const char hexchars[] = "0123456789ABCDEF"; + /* ============ COM_SkipPath @@ -915,6 +627,7 @@ unsigned COM_ParseHex( const char *s ) { return result; } +#if USE_CLIENT qboolean COM_ParseColor( const char *s, color_t color ) { int i; int c[8]; @@ -960,6 +673,7 @@ qboolean COM_ParseColor( const char *s, color_t color ) { return qfalse; } } +#endif // USE_CLIENT /* ================= diff --git a/source/q_shared.h b/source/q_shared.h index 531c126..24c0cc8 100644 --- a/source/q_shared.h +++ b/source/q_shared.h @@ -179,6 +179,7 @@ extern vec3_t vec3_origin; extern const vec3_t bytedirs[NUMVERTEXNORMALS]; +#if USE_CLIENT extern const color_t colorBlack; extern const color_t colorRed; extern const color_t colorGreen; @@ -191,6 +192,7 @@ extern const color_t colorWhite; extern const color_t colorTable[8]; extern const char colorNames[10][8]; +#endif typedef struct vrect_s { int x, y, width, height; @@ -287,7 +289,6 @@ void UnionBounds( vec3_t a[2], vec3_t b[2], vec3_t c[2] ); vec_t VectorNormalize (vec3_t v); // returns vector length vec_t VectorNormalize2 (vec3_t v, vec3_t out); -int Q_log2(int val); int Q_CeilPowerOfTwo( int value ); float Com_CalcFov( float fov_x, float width, float height ); @@ -311,7 +312,6 @@ static inline float anglemod( float a ) { void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal ); void PerpendicularVector( vec3_t dst, const vec3_t src ); -void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ); int DirToByte( const vec3_t dir ); void ByteToDir( int index, vec3_t dir ); diff --git a/source/sv_ccmds.c b/source/sv_ccmds.c index 5694526..fd0550f 100644 --- a/source/sv_ccmds.c +++ b/source/sv_ccmds.c @@ -470,7 +470,7 @@ void SV_ConSay_f( void ) { SV_ClientPrintf( client, PRINT_CHAT, "console: %s\n", s ); } - if( dedicated->integer ) { + if( Com_IsDedicated() ) { Com_Printf( "console: %s\n", s ); } } @@ -1128,7 +1128,7 @@ SV_InitOperatorCommands void SV_InitOperatorCommands( void ) { Cmd_Register( c_server ); - if ( dedicated->integer ) + if ( Com_IsDedicated() ) Cmd_AddCommand( "say", SV_ConSay_f ); } diff --git a/source/sv_game.c b/source/sv_game.c index d526f93..355af5e 100644 --- a/source/sv_game.c +++ b/source/sv_game.c @@ -177,7 +177,7 @@ static void PF_bprintf( int level, const char *fmt, ... ) { MSG_WriteData( string, len + 1 ); // echo to console - if( dedicated->integer ) { + if( Com_IsDedicated() ) { // mask off high bits for( i = 0; i < len; i++ ) string[i] &= 127; diff --git a/source/sv_init.c b/source/sv_init.c index 8e22065..2164859 100644 --- a/source/sv_init.c +++ b/source/sv_init.c @@ -158,9 +158,11 @@ void SV_InitGame( qboolean ismvd ){ // cause any connected clients to reconnect SV_Shutdown( "Server restarted\n", KILL_RESTART ); } else { +#if USE_CLIENT // make sure the client is down CL_Disconnect( ERR_SILENT, NULL ); SCR_BeginLoadingPlaque(); +#endif CM_FreeMap( &sv.cm ); memset( &sv, 0, sizeof( sv ) ); @@ -184,7 +186,7 @@ void SV_InitGame( qboolean ismvd ){ // dedicated servers can't be single player and are usually DM // so unless they explicity set coop, force it to deathmatch - if( dedicated->integer ) { + if( Com_IsDedicated() ) { if( !Cvar_VariableInteger( "coop" ) ) Cvar_Set( "deathmatch", "1" ); } @@ -348,7 +350,9 @@ void SV_Map (const char *levelstring, qboolean restart) { sv.state = ss_loading; } +#if USE_CLIENT SCR_BeginLoadingPlaque(); // for local system +#endif SV_BroadcastCommand( "changing map=%s\n", level ); SV_SendClientMessages(); SV_SendAsyncPackets(); diff --git a/source/sv_main.c b/source/sv_main.c index 66a48dc..cf1af9b 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -187,7 +187,7 @@ void SV_DropClient( client_t *client, const char *reason ) { client->name, reason ); // print to server console - if( dedicated->integer ) { + if( Com_IsDedicated() ) { Com_Printf( "%s[%s] was dropped: %s\n", client->name, NET_AdrToString( &client->netchan->remote_address ), reason ); } @@ -1472,7 +1472,7 @@ static void SV_MasterHeartbeat( void ) { size_t len; int i; - if( !dedicated->integer ) + if( !Com_IsDedicated() ) return; // only dedicated servers send heartbeats if( !sv_public->integer ) @@ -1509,7 +1509,7 @@ Informs all masters that this server is going down static void SV_MasterShutdown( void ) { int i; - if( !dedicated->integer ) + if( !Com_IsDedicated() ) return; // only dedicated servers send heartbeats if( !sv_public->integer ) @@ -1544,8 +1544,9 @@ void SV_Frame( unsigned msec ) { // if server is not active, do nothing if( !svs.initialized ) { - if( dedicated->integer ) { + if( Com_IsDedicated() ) { Sys_Sleep( 1 ); + goto runbuf; } return; } @@ -1586,10 +1587,9 @@ void SV_Frame( unsigned msec ) { // move autonomous things around if enough time has passed sv.frametime += msec; if( !com_timedemo->integer && sv.frametime < 100 ) { -#if USE_CLIENT - if( dedicated->integer ) -#endif + if( Com_IsDedicated() ) { NET_Sleep( 100 - sv.frametime ); + } return; } @@ -1614,6 +1614,14 @@ void SV_Frame( unsigned msec ) { } else { SV_PrepWorldFrame(); } + + if( Com_IsDedicated() ) { +runbuf: + // run cmd buffer in dedicated mode + if( cmd_buffer.waitCount > 0 ) { + cmd_buffer.waitCount--; + } + } } //============================================================================ @@ -1698,7 +1706,7 @@ void SV_UserinfoChanged( client_t *cl ) { for( i = 0; i < len; i++ ) name[i] &= 127; if( cl->name[0] && strcmp( cl->name, name ) ) { - if( dedicated->integer ) { + if( Com_IsDedicated() ) { Com_Printf( "%s[%s] changed name to %s\n", cl->name, NET_AdrToString( &cl->netchan->remote_address ), name ); } diff --git a/source/sv_user.c b/source/sv_user.c index 2432509..5b4f221 100644 --- a/source/sv_user.c +++ b/source/sv_user.c @@ -477,7 +477,7 @@ void SV_Begin_f( void ) { } if( sv_force_reconnect->string[0] && !( sv_client->flags & CF_RECONNECTED ) ) { - if( dedicated->integer ) { + if( Com_IsDedicated() ) { Com_Printf( "%s[%s]: failed to reconnect\n", sv_client->name, NET_AdrToString( &sv_client->netchan->remote_address ) ); } @@ -702,7 +702,7 @@ The client is going to disconnect, so remove the connection immediately ================= */ static void SV_Disconnect_f( void ) { - if( dedicated->integer && sv_client->netchan ) { + if( Com_IsDedicated() && sv_client->netchan ) { Com_Printf( "%s[%s] disconnected\n", sv_client->name, NET_AdrToString( &sv_client->netchan->remote_address ) ); } @@ -738,7 +738,7 @@ static void SV_CvarResult_f( void ) { if( !strcmp( c, "version" ) ) { if( !sv_client->versionString ) { v = Cmd_RawArgsFrom( 2 ); - if( dedicated->integer ) { + if( Com_IsDedicated() ) { Com_Printf( "%s[%s]: %s\n", sv_client->name, NET_AdrToString( &sv_client->netchan->remote_address ), v ); } diff --git a/source/sw_local.h b/source/sw_local.h index 8ef587a..24b2548 100644 --- a/source/sw_local.h +++ b/source/sw_local.h @@ -665,6 +665,8 @@ extern surfcache_t *sc_rover, *sc_base; //==================================================================== +void R_RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ); + float R_DLightPoint (vec3_t p); void R_NewMap (void); diff --git a/source/sw_main.c b/source/sw_main.c index fe8cbe3..b8caeaf 100644 --- a/source/sw_main.c +++ b/source/sw_main.c @@ -1091,7 +1091,7 @@ void R_DrawBeam( entity_t *e ) for ( i = 0; i < NUM_BEAM_SEGS; i++ ) { - RotatePointAroundVector( start_points[i], normalized_direction, + R_RotatePointAroundVector( start_points[i], normalized_direction, perpvec, (360.0/NUM_BEAM_SEGS)*i ); VectorAdd( start_points[i], origin, start_points[i] ); VectorAdd( start_points[i], direction, end_points[i] ); diff --git a/source/sw_misc.c b/source/sw_misc.c index d16891b..0c9dc7f 100644 --- a/source/sw_misc.c +++ b/source/sw_misc.c @@ -458,6 +458,131 @@ void R_SetupFrame (void) /* ============================================================================== + MATH + +============================================================================== +*/ + +/* +================ +R_ConcatRotations +================ +*/ +void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]) +{ + out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + + in1[0][2] * in2[2][0]; + out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + + in1[0][2] * in2[2][1]; + out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + + in1[0][2] * in2[2][2]; + out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + + in1[1][2] * in2[2][0]; + out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + + in1[1][2] * in2[2][1]; + out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + + in1[1][2] * in2[2][2]; + out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + + in1[2][2] * in2[2][0]; + out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + + in1[2][2] * in2[2][1]; + out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + + in1[2][2] * in2[2][2]; +} + + +/* +================ +R_ConcatTransforms +================ +*/ +void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]) +{ + out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + + in1[0][2] * in2[2][0]; + out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + + in1[0][2] * in2[2][1]; + out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + + in1[0][2] * in2[2][2]; + out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] + + in1[0][2] * in2[2][3] + in1[0][3]; + out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + + in1[1][2] * in2[2][0]; + out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + + in1[1][2] * in2[2][1]; + out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + + in1[1][2] * in2[2][2]; + out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] + + in1[1][2] * in2[2][3] + in1[1][3]; + out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + + in1[2][2] * in2[2][0]; + out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + + in1[2][2] * in2[2][1]; + out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + + in1[2][2] * in2[2][2]; + out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + + in1[2][2] * in2[2][3] + in1[2][3]; +} + +void R_RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ) +{ + float m[3][3]; + float im[3][3]; + float zrot[3][3]; + float tmpmat[3][3]; + float rot[3][3]; + int i; + vec3_t vr, vup, vf; + + vf[0] = dir[0]; + vf[1] = dir[1]; + vf[2] = dir[2]; + + PerpendicularVector( vr, dir ); + CrossProduct( vr, vf, vup ); + + m[0][0] = vr[0]; + m[1][0] = vr[1]; + m[2][0] = vr[2]; + + m[0][1] = vup[0]; + m[1][1] = vup[1]; + m[2][1] = vup[2]; + + m[0][2] = vf[0]; + m[1][2] = vf[1]; + m[2][2] = vf[2]; + + memcpy( im, m, sizeof( im ) ); + + im[0][1] = m[1][0]; + im[0][2] = m[2][0]; + im[1][0] = m[0][1]; + im[1][2] = m[2][1]; + im[2][0] = m[0][2]; + im[2][1] = m[1][2]; + + memset( zrot, 0, sizeof( zrot ) ); + zrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F; + + zrot[0][0] = cos( DEG2RAD( degrees ) ); + zrot[0][1] = sin( DEG2RAD( degrees ) ); + zrot[1][0] = -sin( DEG2RAD( degrees ) ); + zrot[1][1] = cos( DEG2RAD( degrees ) ); + + R_ConcatRotations( m, zrot, tmpmat ); + R_ConcatRotations( tmpmat, im, rot ); + + for ( i = 0; i < 3; i++ ) + { + dst[i] = rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] * point[2]; + } +} + + +/* +============================================================================== + SCREEN SHOTS ============================================================================== |