diff options
author | Andrey Nazarov <skuller@skuller.net> | 2008-05-20 20:43:18 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2008-05-20 20:43:18 +0000 |
commit | ea1ed930673bb4063bb210a6b1a34364a9093d77 (patch) | |
tree | cb79a0b0871e6addeff6cfcdb599a52c6f618e60 | |
parent | cb43ed08c3cf6410fe4ce22dac3d07952db92893 (diff) |
Updated menu scripts syntax.
Updated client docs.
-rw-r--r-- | source/cl_console.c | 12 | ||||
-rw-r--r-- | source/cl_demo.c | 697 | ||||
-rw-r--r-- | source/cl_draw.c | 6 | ||||
-rw-r--r-- | source/cl_ents.c | 8 | ||||
-rw-r--r-- | source/cl_input.c | 2 | ||||
-rw-r--r-- | source/cl_keys.c | 2 | ||||
-rw-r--r-- | source/cl_local.h | 594 | ||||
-rw-r--r-- | source/cl_main.c | 65 | ||||
-rw-r--r-- | source/cl_parse.c | 1734 | ||||
-rw-r--r-- | source/cl_pred.c | 2 | ||||
-rw-r--r-- | source/cl_public.h | 8 | ||||
-rw-r--r-- | source/cl_scrn.c | 6 | ||||
-rw-r--r-- | source/cvar.c | 8 | ||||
-rw-r--r-- | source/q_shared.h | 5 | ||||
-rw-r--r-- | source/ui_local.h | 256 | ||||
-rw-r--r-- | source/ui_menu.c | 34 | ||||
-rw-r--r-- | source/ui_script.c | 24 | ||||
-rw-r--r-- | wiki/doc/client.mdwn | 76 | ||||
-rw-r--r-- | wiki/doc/q2pro.menu | 35 |
19 files changed, 1782 insertions, 1792 deletions
diff --git a/source/cl_console.c b/source/cl_console.c index 1417679..659a5f9 100644 --- a/source/cl_console.c +++ b/source/cl_console.c @@ -769,13 +769,13 @@ void Con_DrawSolidConsole( void ) { //ZOID // draw the download bar // figure out width - if( cls.download ) { + if( cls.download.file ) { int n, j; - if( ( text = strrchr( cls.downloadname, '/') ) != NULL ) + if( ( text = strrchr( cls.download.name, '/') ) != NULL ) text++; else - text = cls.downloadname; + text = cls.download.name; x = con.linewidth - ( ( con.linewidth * 7 ) / 40 ); y = x - strlen( text ) - 8; @@ -792,7 +792,7 @@ void Con_DrawSolidConsole( void ) { i = strlen( buffer ); buffer[i++] = '\x80'; // where's the dot go? - n = y * cls.downloadpercent / 100; + n = y * cls.download.percent / 100; for ( j = 0; j < y; j++ ) { if ( j == n ) { buffer[i++] = '\x83'; @@ -803,7 +803,7 @@ void Con_DrawSolidConsole( void ) { buffer[i++] = '\x82'; buffer[i] = 0; - sprintf( buffer + i, " %02d%%", cls.downloadpercent ); + sprintf( buffer + i, " %02d%%", cls.download.percent ); // draw it y = vislines - 10; @@ -884,7 +884,7 @@ void Con_RunConsole( void ) { } if( cls.state > ca_disconnected && cls.state < ca_active ) { -#if 1 +#if 0 // draw half-screen console con.destHeight = min( con.maxHeight, 0.5f ); con.currentHeight = con.destHeight; diff --git a/source/cl_demo.c b/source/cl_demo.c index 41f7466..ab5111f 100644 --- a/source/cl_demo.c +++ b/source/cl_demo.c @@ -24,6 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "cl_local.h" +static byte demo_buffer[MAX_PACKETLEN_WRITABLE_DEFAULT]; + // ========================================================================= /* @@ -34,7 +36,7 @@ Dumps the current demo message, prefixed by the length. ==================== */ void CL_WriteDemoMessage( sizebuf_t *buf ) { - uint32_t msglen; + uint32_t msglen; if( buf->overflowed ) { SZ_Clear( buf ); @@ -45,9 +47,9 @@ void CL_WriteDemoMessage( sizebuf_t *buf ) { return; } - msglen = LittleLong( buf->cursize ); - FS_Write( &msglen, 4, cls.demorecording ); - FS_Write( buf->data, buf->cursize, cls.demorecording ); + msglen = LittleLong( buf->cursize ); + FS_Write( &msglen, 4, cls.demo.recording ); + FS_Write( buf->data, buf->cursize, cls.demo.recording ); SZ_Clear( buf ); } @@ -60,63 +62,63 @@ Writes a delta update of an entity_state_t list to the message. ============= */ static void CL_EmitPacketEntities( server_frame_t *from, server_frame_t *to ) { - entity_state_t *oldent, *newent; - int oldindex, newindex; - int oldnum, newnum; - int i, from_num_entities; - - if( !from ) - from_num_entities = 0; - else - from_num_entities = from->numEntities; - - newindex = 0; - oldindex = 0; - oldent = newent = 0; - while( newindex < to->numEntities || oldindex < from_num_entities ) { - if( newindex >= to->numEntities ) { - newnum = 9999; - } else { + entity_state_t *oldent, *newent; + int oldindex, newindex; + int oldnum, newnum; + int i, from_num_entities; + + if( !from ) + from_num_entities = 0; + else + from_num_entities = from->numEntities; + + newindex = 0; + oldindex = 0; + oldent = newent = 0; + while( newindex < to->numEntities || oldindex < from_num_entities ) { + if( newindex >= to->numEntities ) { + newnum = 9999; + } else { i = ( to->firstEntity + newindex ) & PARSE_ENTITIES_MASK; - newent = &cl.entityStates[i]; - newnum = newent->number; - } + newent = &cl.entityStates[i]; + newnum = newent->number; + } - if( oldindex >= from_num_entities ) { - oldnum = 9999; - } else { + if( oldindex >= from_num_entities ) { + oldnum = 9999; + } else { i = ( from->firstEntity + oldindex ) & PARSE_ENTITIES_MASK; - oldent = &cl.entityStates[i]; - oldnum = oldent->number; - } - - if( newnum == oldnum ) { - // delta update from old position - // because the force parm is false, this will not result - // in any bytes being emited if the entity has not changed at all - MSG_WriteDeltaEntity( oldent, newent, 0 ); - oldindex++; - newindex++; - continue; - } - - if( newnum < oldnum ) { - // this is a new entity, send it from the baseline - MSG_WriteDeltaEntity( &cl.baselines[newnum], newent, + oldent = &cl.entityStates[i]; + oldnum = oldent->number; + } + + if( newnum == oldnum ) { + // delta update from old position + // because the force parm is false, this will not result + // in any bytes being emited if the entity has not changed at all + MSG_WriteDeltaEntity( oldent, newent, 0 ); + oldindex++; + newindex++; + continue; + } + + if( newnum < oldnum ) { + // this is a new entity, send it from the baseline + MSG_WriteDeltaEntity( &cl.baselines[newnum], newent, MSG_ES_FORCE|MSG_ES_NEWENTITY ); - newindex++; - continue; - } - - if( newnum > oldnum ) { - // the old entity isn't present in the new message - MSG_WriteDeltaEntity( oldent, NULL, MSG_ES_FORCE ); - oldindex++; - continue; - } - } - - MSG_WriteShort( 0 ); // end of packetentities + newindex++; + continue; + } + + if( newnum > oldnum ) { + // the old entity isn't present in the new message + MSG_WriteDeltaEntity( oldent, NULL, MSG_ES_FORCE ); + oldindex++; + continue; + } + } + + MSG_WriteShort( 0 ); // end of packetentities } /* @@ -127,11 +129,11 @@ Writes delta from the last frame we got to the current frame. ==================== */ void CL_EmitDemoFrame( void ) { - server_frame_t *oldframe; - player_state_t *oldstate; - int lastframe; + server_frame_t *oldframe; + player_state_t *oldstate; + int lastframe; - if( cls.demopaused ) { + if( cls.demo.paused ) { return; } @@ -143,8 +145,8 @@ void CL_EmitDemoFrame( void ) { oldframe = &cl.frames[cl.demoframe & UPDATE_MASK]; oldstate = &oldframe->ps; lastframe = cl.demoframe + cl.demodelta; - if( oldframe->number != cl.demoframe || !oldframe->valid || - cl.numEntityStates - oldframe->firstEntity > MAX_PARSE_ENTITIES ) + if( oldframe->number != cl.demoframe || !oldframe->valid || + cl.numEntityStates - oldframe->firstEntity > MAX_PARSE_ENTITIES ) { oldframe = NULL; oldstate = NULL; @@ -152,28 +154,28 @@ void CL_EmitDemoFrame( void ) { } } - MSG_WriteByte( svc_frame ); - MSG_WriteLong( cl.frame.number + cl.demodelta ); - MSG_WriteLong( lastframe ); // what we are delta'ing from - MSG_WriteByte( 0 ); // rate dropped packets + MSG_WriteByte( svc_frame ); + MSG_WriteLong( cl.frame.number + cl.demodelta ); + MSG_WriteLong( lastframe ); // what we are delta'ing from + MSG_WriteByte( 0 ); // rate dropped packets - // send over the areabits - MSG_WriteByte( cl.frame.areabytes ); - MSG_WriteData( cl.frame.areabits, cl.frame.areabytes ); + // send over the areabits + MSG_WriteByte( cl.frame.areabytes ); + MSG_WriteData( cl.frame.areabits, cl.frame.areabytes ); - // delta encode the playerstate - MSG_WriteByte( svc_playerinfo ); - MSG_WriteDeltaPlayerstate_Default( oldstate, &cl.frame.ps ); - - // delta encode the entities - MSG_WriteByte( svc_packetentities ); - CL_EmitPacketEntities( oldframe, &cl.frame ); + // delta encode the playerstate + MSG_WriteByte( svc_playerinfo ); + MSG_WriteDeltaPlayerstate_Default( oldstate, &cl.frame.ps ); + + // delta encode the entities + MSG_WriteByte( svc_packetentities ); + CL_EmitPacketEntities( oldframe, &cl.frame ); - if( cls.demobuff.cursize + msg_write.cursize > cls.demobuff.maxsize ) { + if( cls.demo.buffer.cursize + msg_write.cursize > cls.demo.buffer.maxsize ) { Com_WPrintf( "Oversize demo frame: %"PRIz" bytes\n", - cls.demobuff.cursize + msg_write.cursize ); + cls.demo.buffer.cursize + msg_write.cursize ); } else { - SZ_Write( &cls.demobuff, msg_write.data, msg_write.cursize ); + SZ_Write( &cls.demo.buffer, msg_write.data, msg_write.cursize ); cl.demoframe = cl.frame.number; } @@ -183,20 +185,20 @@ void CL_EmitDemoFrame( void ) { void CL_EmitZeroFrame( void ) { cl.demodelta++; // insert new zero frame - MSG_WriteByte( svc_frame ); - MSG_WriteLong( cl.frame.number + cl.demodelta ); - MSG_WriteLong( cl.frame.number + cl.demodelta - 1 ); // what we are delta'ing from - MSG_WriteByte( 0 ); // rate dropped packets + MSG_WriteByte( svc_frame ); + MSG_WriteLong( cl.frame.number + cl.demodelta ); + MSG_WriteLong( cl.frame.number + cl.demodelta - 1 ); // what we are delta'ing from + MSG_WriteByte( 0 ); // rate dropped packets - // send over the areabits - MSG_WriteByte( cl.frame.areabytes ); - MSG_WriteData( cl.frame.areabits, cl.frame.areabytes ); + // send over the areabits + MSG_WriteByte( cl.frame.areabytes ); + MSG_WriteData( cl.frame.areabits, cl.frame.areabytes ); - MSG_WriteByte( svc_playerinfo ); + MSG_WriteByte( svc_playerinfo ); MSG_WriteShort( 0 ); MSG_WriteLong( 0 ); - MSG_WriteByte( svc_packetentities ); + MSG_WriteByte( svc_packetentities ); MSG_WriteShort( 0 ); CL_WriteDemoMessage( &msg_write ); @@ -213,34 +215,34 @@ stop recording a demo ==================== */ void CL_Stop_f( void ) { - uint32_t msglen; + uint32_t msglen; - if( !cls.demorecording ) { - Com_Printf( "Not recording a demo.\n" ); - return; - } + if( !cls.demo.recording ) { + Com_Printf( "Not recording a demo.\n" ); + return; + } - if( cls.netchan && cls.serverProtocol >= PROTOCOL_VERSION_R1Q2 ) { - // tell the server we finished recording - MSG_WriteByte( clc_setting ); - MSG_WriteShort( CLS_RECORDING ); - MSG_WriteShort( 0 ); - MSG_FlushTo( &cls.netchan->message ); - } + if( cls.netchan && cls.serverProtocol >= PROTOCOL_VERSION_R1Q2 ) { + // tell the server we finished recording + MSG_WriteByte( clc_setting ); + MSG_WriteShort( CLS_RECORDING ); + MSG_WriteShort( 0 ); + MSG_FlushTo( &cls.netchan->message ); + } // finish up - msglen = ( uint32_t )-1; - FS_Write( &msglen, 4, cls.demorecording ); + msglen = ( uint32_t )-1; + FS_Write( &msglen, 4, cls.demo.recording ); - FS_Flush( cls.demorecording ); - msglen = FS_RawTell( cls.demorecording ); + FS_Flush( cls.demo.recording ); + msglen = FS_RawTell( cls.demo.recording ); // close demofile - FS_FCloseFile( cls.demorecording ); - cls.demorecording = 0; - cls.demopaused = qfalse; + FS_FCloseFile( cls.demo.recording ); + cls.demo.recording = 0; + cls.demo.paused = qfalse; - Com_Printf( "Stopped demo (%u bytes written).\n", msglen ); + Com_Printf( "Stopped demo (%u bytes written).\n", msglen ); } extern const cmd_option_t o_mvdrecord[]; @@ -254,25 +256,25 @@ record <demoname> Begins recording a demo from the current position ==================== */ -void CL_Record_f( void ) { - char name[MAX_OSPATH]; - int i; - size_t length; - entity_state_t *ent; - char *string; - fileHandle_t demofile; - qboolean gzip = qfalse; +static void CL_Record_f( void ) { + char name[MAX_OSPATH]; + int i; + size_t length; + entity_state_t *ent; + char *string; + fileHandle_t demofile; + qboolean gzip = qfalse; int c; - if( cls.demorecording ) { - Com_Printf( "Already recording.\n" ); - return; - } + if( cls.demo.recording ) { + Com_Printf( "Already recording.\n" ); + return; + } - if( cls.state != ca_active ) { - Com_Printf( "You must be in a level to record.\n" ); - return; - } + if( cls.state != ca_active ) { + Com_Printf( "You must be in a level to record.\n" ); + return; + } while( ( c = Cmd_ParseOptions( o_mvdrecord ) ) != -1 ) { switch( c ) { @@ -293,116 +295,118 @@ void CL_Record_f( void ) { return; } - // - // open the demo file - // - if( cmd_optarg[0] == '/' ) { - Q_strncpyz( name, cmd_optarg + 1, sizeof( name ) ); - } else { - Q_concat( name, sizeof( name ), "demos/", cmd_optarg, NULL ); - COM_AppendExtension( name, ".dm2", sizeof( name ) ); - if( gzip ) { - COM_AppendExtension( name, ".gz", sizeof( name ) ); - } - } - - FS_FOpenFile( name, &demofile, FS_MODE_WRITE ); - if( !demofile ) { - Com_EPrintf( "Couldn't open %s for writing.\n", name ); - return; - } - - Com_Printf( "Recording client demo to %s.\n", name ); - - if( gzip ) { + // + // open the demo file + // + if( cmd_optarg[0] == '/' ) { + Q_strncpyz( name, cmd_optarg + 1, sizeof( name ) ); + } else { + Q_concat( name, sizeof( name ), "demos/", cmd_optarg, NULL ); + COM_AppendExtension( name, ".dm2", sizeof( name ) ); + if( gzip ) { + COM_AppendExtension( name, ".gz", sizeof( name ) ); + } + } + + FS_FOpenFile( name, &demofile, FS_MODE_WRITE ); + if( !demofile ) { + Com_EPrintf( "Couldn't open %s for writing.\n", name ); + return; + } + + Com_Printf( "Recording client demo to %s.\n", name ); + + if( gzip ) { FS_FilterFile( demofile ); } - cls.demorecording = demofile; - cls.demopaused = qfalse; + cls.demo.recording = demofile; + cls.demo.paused = qfalse; + + SZ_Init( &cls.demo.buffer, demo_buffer, sizeof( demo_buffer ) ); // the first frame will be delta uncompressed cl.demoframe = -1; cl.demodelta = 0; - if( cls.netchan && cls.serverProtocol >= PROTOCOL_VERSION_R1Q2 ) { - // tell the server we are recording - MSG_WriteByte( clc_setting ); - MSG_WriteShort( CLS_RECORDING ); - MSG_WriteShort( 1 ); - MSG_FlushTo( &cls.netchan->message ); - } - - // - // write out messages to hold the startup information - // - - // send the serverdata - MSG_WriteByte( svc_serverdata ); - MSG_WriteLong( PROTOCOL_VERSION_DEFAULT ); - MSG_WriteLong( 0x10000 + cl.servercount ); - MSG_WriteByte( 1 ); // demos are always attract loops - MSG_WriteString( cl.gamedir ); + if( cls.netchan && cls.serverProtocol >= PROTOCOL_VERSION_R1Q2 ) { + // tell the server we are recording + MSG_WriteByte( clc_setting ); + MSG_WriteShort( CLS_RECORDING ); + MSG_WriteShort( 1 ); + MSG_FlushTo( &cls.netchan->message ); + } + + // + // write out messages to hold the startup information + // + + // send the serverdata + MSG_WriteByte( svc_serverdata ); + MSG_WriteLong( PROTOCOL_VERSION_DEFAULT ); + MSG_WriteLong( 0x10000 + cl.servercount ); + MSG_WriteByte( 1 ); // demos are always attract loops + MSG_WriteString( cl.gamedir ); MSG_WriteShort( cl.clientNum ); - MSG_WriteString( cl.configstrings[CS_NAME] ); - - // configstrings - for( i = 0; i < MAX_CONFIGSTRINGS; i++ ) { - string = cl.configstrings[i]; - if( !string[0] ) { - continue; - } - - length = strlen( string ); - if( length > MAX_QPATH ) { - length = MAX_QPATH; - } - + MSG_WriteString( cl.configstrings[CS_NAME] ); + + // configstrings + for( i = 0; i < MAX_CONFIGSTRINGS; i++ ) { + string = cl.configstrings[i]; + if( !string[0] ) { + continue; + } + + length = strlen( string ); + if( length > MAX_QPATH ) { + length = MAX_QPATH; + } + if( msg_write.cursize + length + 4 > MAX_PACKETLEN_WRITABLE_DEFAULT ) { CL_WriteDemoMessage( &msg_write ); } - MSG_WriteByte( svc_configstring ); - MSG_WriteShort( i ); - MSG_WriteData( string, length ); - MSG_WriteByte( 0 ); - } + MSG_WriteByte( svc_configstring ); + MSG_WriteShort( i ); + MSG_WriteData( string, length ); + MSG_WriteByte( 0 ); + } - // baselines - for( i = 1; i < MAX_EDICTS; i++ ) { - ent = &cl.baselines[i]; - if( !ent->number ) { - continue; - } + // baselines + for( i = 1; i < MAX_EDICTS; i++ ) { + ent = &cl.baselines[i]; + if( !ent->number ) { + continue; + } if( msg_write.cursize + 64 > MAX_PACKETLEN_WRITABLE_DEFAULT ) { CL_WriteDemoMessage( &msg_write ); } - MSG_WriteByte( svc_spawnbaseline ); - MSG_WriteDeltaEntity( NULL, ent, MSG_ES_FORCE ); - } + MSG_WriteByte( svc_spawnbaseline ); + MSG_WriteDeltaEntity( NULL, ent, MSG_ES_FORCE ); + } - MSG_WriteByte( svc_stufftext ); - MSG_WriteString( "precache\n" ); + MSG_WriteByte( svc_stufftext ); + MSG_WriteString( "precache\n" ); - // write it to the demo file + // write it to the demo file CL_WriteDemoMessage( &msg_write ); - // the rest of the demo file will be individual frames + // the rest of the demo file will be individual frames } static void CL_Suspend_f( void ) { int i, j, index; size_t length, total = 0; - if( !cls.demorecording ) { - Com_Printf( "Not recording a demo.\n" ); - return; - } - if( !cls.demopaused ) { - Com_Printf( "Suspended demo.\n" ); - cls.demopaused = qtrue; + if( !cls.demo.recording ) { + Com_Printf( "Not recording a demo.\n" ); + return; + } + if( !cls.demo.paused ) { + Com_Printf( "Suspended demo.\n" ); + cls.demo.paused = qtrue; return; } @@ -425,26 +429,26 @@ static void CL_Suspend_f( void ) { } MSG_WriteByte( svc_configstring ); MSG_WriteShort( index ); - MSG_WriteData( cl.configstrings[index], length ); - MSG_WriteByte( 0 ); + MSG_WriteData( cl.configstrings[index], length ); + MSG_WriteByte( 0 ); total += length + 4; } } - // write it to the demo file + // write it to the demo file CL_WriteDemoMessage( &msg_write ); Com_Printf( "Resumed demo (%"PRIz" bytes flushed).\n", total ); cl.demodelta += cl.demoframe - cl.frame.number; // do not create holes - cls.demopaused = qfalse; + cls.demo.paused = qfalse; // clear dirty configstrings memset( cl.dcs, 0, sizeof( cl.dcs ) ); } static int CL_ReadFirstDemoMessage( fileHandle_t f ) { - uint32_t ul; + uint32_t ul; uint16_t us; size_t msglen; int type; @@ -483,25 +487,25 @@ static int CL_ReadFirstDemoMessage( fileHandle_t f ) { Com_DPrintf( "%s: end of demo\n", __func__ ); return -1; } - msglen = LittleLong( ul ); + msglen = LittleLong( ul ); type = 0; } - if( msglen >= sizeof( msg_read_buffer ) ) { + if( msglen >= sizeof( msg_read_buffer ) ) { Com_DPrintf( "%s: bad msglen\n", __func__ ); - return -1; - } + return -1; + } SZ_Init( &msg_read, msg_read_buffer, sizeof( msg_read_buffer ) ); - msg_read.cursize = msglen; + msg_read.cursize = msglen; - // read packet data - if( FS_Read( msg_read.data, msglen, f ) != msglen ) { + // read packet data + if( FS_Read( msg_read.data, msglen, f ) != msglen ) { Com_DPrintf( "%s: short read of data\n", __func__ ); - return -1; - } + return -1; + } - return type; + return type; } /* @@ -510,35 +514,35 @@ CL_ReadNextDemoMessage ==================== */ static qboolean CL_ReadNextDemoMessage( fileHandle_t f ) { - uint32_t msglen; + uint32_t msglen; - // read msglen - if( FS_Read( &msglen, 4, f ) != 4 ) { + // read msglen + if( FS_Read( &msglen, 4, f ) != 4 ) { Com_DPrintf( "%s: short read of msglen\n", __func__ ); - return qfalse; - } + return qfalse; + } - if( msglen == ( uint32_t )-1 ) { + if( msglen == ( uint32_t )-1 ) { Com_DPrintf( "%s: end of demo\n", __func__ ); - return qfalse; - } + return qfalse; + } - msglen = LittleLong( msglen ); - if( msglen >= sizeof( msg_read_buffer ) ) { + msglen = LittleLong( msglen ); + if( msglen >= sizeof( msg_read_buffer ) ) { Com_DPrintf( "%s: bad msglen\n", __func__ ); - return qfalse; - } + return qfalse; + } SZ_Init( &msg_read, msg_read_buffer, sizeof( msg_read_buffer ) ); - msg_read.cursize = msglen; + msg_read.cursize = msglen; - // read packet data - if( FS_Read( msg_read.data, msglen, f ) != msglen ) { + // read packet data + if( FS_Read( msg_read.data, msglen, f ) != msglen ) { Com_DPrintf( "%s: short read of data\n", __func__ ); - return qfalse; - } + return qfalse; + } - return qtrue; + return qtrue; } /* @@ -547,30 +551,30 @@ CL_ParseNextDemoMessage ==================== */ static void CL_ParseNextDemoMessage( void ) { - int pos; - char *s; - - if( !CL_ReadNextDemoMessage( cls.demoplayback ) ) { - s = Cvar_VariableString( "nextserver" ); - if( !s[0] ) { - Com_Error( ERR_SILENT, "Demo finished" ); - } - Cbuf_AddText( s ); - Cbuf_AddText( "\n" ); - Cvar_Set( "nextserver", "" ); - cls.state = ca_connected; - return; - } - - CL_ParseServerMessage(); - - if( cls.demofileSize ) { - pos = FS_RawTell( cls.demoplayback ) - cls.demofileFrameOffset; - if( pos < 0 ) { - pos = 0; - } - cls.demofilePercent = pos * 100 / cls.demofileSize; - } + int pos; + char *s; + + if( !CL_ReadNextDemoMessage( cls.demo.playback ) ) { + s = Cvar_VariableString( "nextserver" ); + if( !s[0] ) { + Com_Error( ERR_SILENT, "Demo finished" ); + } + Cbuf_AddText( s ); + Cbuf_AddText( "\n" ); + Cvar_Set( "nextserver", "" ); + cls.state = ca_connected; + return; + } + + CL_ParseServerMessage(); + + if( cls.demo.file_size ) { + pos = FS_RawTell( cls.demo.playback ) - cls.demo.file_offset; + if( pos < 0 ) { + pos = 0; + } + cls.demo.file_percent = pos * 100 / cls.demo.file_size; + } } /* @@ -579,39 +583,36 @@ CL_PlayDemo_f ==================== */ static void CL_PlayDemo_f( void ) { - char name[MAX_OSPATH]; - fileHandle_t demofile; - char *arg; - size_t length; + char name[MAX_OSPATH]; + fileHandle_t demofile; + char *arg; + size_t length; int type, argc = Cmd_Argc(); - if( argc < 2 ) { - Com_Printf( "Usage: %s <filename> [...]\n", Cmd_Argv( 0 ) ); - return; - } - - demofile = 0; - length = 0; - - arg = Cmd_Argv( 1 ); - if( arg[0] == '/' ) { - // Assume full path is given - Q_strncpyz( name, arg + 1, sizeof( name ) ); - FS_FOpenFile( name, &demofile, FS_MODE_READ ); - } else { - // Search for matching extensions - Q_concat( name, sizeof( name ), "demos/", arg, NULL ); - FS_FOpenFile( name, &demofile, FS_MODE_READ ); + if( argc < 2 ) { + Com_Printf( "Usage: %s <filename> [...]\n", Cmd_Argv( 0 ) ); + return; + } + + arg = Cmd_Argv( 1 ); + if( arg[0] == '/' ) { + // Assume full path is given + Q_strncpyz( name, arg + 1, sizeof( name ) ); + FS_FOpenFile( name, &demofile, FS_MODE_READ ); + } else { + // Search for matching extensions + Q_concat( name, sizeof( name ), "demos/", arg, NULL ); + FS_FOpenFile( name, &demofile, FS_MODE_READ ); if( !demofile ) { - COM_AppendExtension( name, ".dm2", sizeof( name ) ); - FS_FOpenFile( name, &demofile, FS_MODE_READ ); + COM_AppendExtension( name, ".dm2", sizeof( name ) ); + FS_FOpenFile( name, &demofile, FS_MODE_READ ); } } - if( !demofile ) { - Com_Printf( "Couldn't open %s\n", name ); - return; - } + if( !demofile ) { + Com_Printf( "Couldn't open %s\n", name ); + return; + } #if 0 // add trailing filenames to play list @@ -625,53 +626,53 @@ static void CL_PlayDemo_f( void ) { type = CL_ReadFirstDemoMessage( demofile ); if( type == -1 ) { - Com_Printf( "%s is not a demo file\n", name ); + Com_Printf( "%s is not a demo file\n", name ); FS_FCloseFile( demofile ); return; } if( type == 1 ) { - Com_DPrintf( "%s is a MVD file\n", name ); + Com_DPrintf( "%s is a MVD file\n", name ); Cbuf_InsertText( va( "mvdplay /%s\n", name ) ); FS_FCloseFile( demofile ); return; } - if( sv_running->integer ) { - // if running a local server, kill it and reissue - SV_Shutdown( "Server was killed\n", KILL_DROP ); - } + if( sv_running->integer ) { + // if running a local server, kill it and reissue + SV_Shutdown( "Server was killed\n", KILL_DROP ); + } - CL_Disconnect( ERR_DISCONNECT, NULL ); - - Con_Close(); + CL_Disconnect( ERR_DISCONNECT, NULL ); + + Con_Close(); - cls.demoplayback = demofile; - cls.state = ca_connected; - Q_strncpyz( cls.servername, COM_SkipPath( name ), sizeof( cls.servername ) ); - cls.serverAddress.type = NA_LOOPBACK; + cls.demo.playback = demofile; + cls.state = ca_connected; + Q_strncpyz( cls.servername, COM_SkipPath( name ), sizeof( cls.servername ) ); + cls.serverAddress.type = NA_LOOPBACK; - SCR_UpdateScreen(); + SCR_UpdateScreen(); - CL_ParseServerMessage(); - while( cls.state == ca_connected ) { - Cbuf_Execute(); - CL_ParseNextDemoMessage(); + CL_ParseServerMessage(); + while( cls.state == ca_connected ) { + Cbuf_Execute(); + CL_ParseNextDemoMessage(); } - length = FS_GetFileLength( demofile ); + length = FS_GetFileLength( demofile ); if( length == INVALID_LENGTH ) { - cls.demofileFrameOffset = 0; - cls.demofileSize = 0; + cls.demo.file_offset = 0; + cls.demo.file_size = 0; } else { - cls.demofileFrameOffset = FS_Tell( demofile ); - cls.demofileSize = length - cls.demofileFrameOffset; + cls.demo.file_offset = FS_Tell( demofile ); + cls.demo.file_size = length - cls.demo.file_offset; } - if( com_timedemo->integer ) { - cls.timeDemoFrames = 0; - cls.timeDemoStart = Sys_Milliseconds(); - } + if( com_timedemo->integer ) { + cls.demo.time_frames = 0; + cls.demo.time_start = Sys_Milliseconds(); + } } static void CL_Demo_c( genctx_t *ctx, int argnum ) { @@ -706,15 +707,15 @@ CL_GetDemoInfo ==================== */ demoInfo_t *CL_GetDemoInfo( const char *path, demoInfo_t *info ) { - fileHandle_t f; - int c, index; - char *string; + fileHandle_t f; + int c, index; + char *string; int clientNum, type; - FS_FOpenFile( path, &f, FS_MODE_READ ); - if( !f ) { - return NULL; - } + FS_FOpenFile( path, &f, FS_MODE_READ ); + if( !f ) { + return NULL; + } type = CL_ReadFirstDemoMessage( f ); if( type == -1 ) { @@ -777,12 +778,12 @@ demoInfo_t *CL_GetDemoInfo( const char *path, demoInfo_t *info ) { } } - FS_FCloseFile( f ); - return info; + FS_FCloseFile( f ); + return info; fail: - FS_FCloseFile( f ); - return NULL; + FS_FCloseFile( f ); + return NULL; } @@ -795,27 +796,27 @@ CL_DemoFrame ==================== */ void CL_DemoFrame( void ) { - if( cls.state < ca_connected ) { + if( cls.state < ca_connected ) { return; } - if( cls.state != ca_active ) { - CL_ParseNextDemoMessage(); - return; - } - - if( com_timedemo->integer ) { - CL_ParseNextDemoMessage(); - cl.time = cl.servertime; - cls.timeDemoFrames++; - return; - } - - while( cl.servertime < cl.time ) { - CL_ParseNextDemoMessage(); - if( cls.state != ca_active ) { - break; - } - } + if( cls.state != ca_active ) { + CL_ParseNextDemoMessage(); + return; + } + + if( com_timedemo->integer ) { + CL_ParseNextDemoMessage(); + cl.time = cl.servertime; + cls.demo.time_frames++; + return; + } + + while( cl.servertime < cl.time ) { + CL_ParseNextDemoMessage(); + if( cls.state != ca_active ) { + break; + } + } } static const cmdreg_t c_demo[] = { @@ -833,7 +834,7 @@ CL_InitDemos ==================== */ void CL_InitDemos( void ) { - Cmd_Register( c_demo ); + Cmd_Register( c_demo ); } diff --git a/source/cl_draw.c b/source/cl_draw.c index 5d208c1..68dd0be 100644 --- a/source/cl_draw.c +++ b/source/cl_draw.c @@ -451,7 +451,7 @@ void SCR_DrawLoading( void ) { x = scr_glconfig.vidWidth / 2; y = 8; - s = va( "%s %s", cls.demoplayback ? "Playing back " : + s = va( "%s %s", cls.demo.playback ? "Playing back " : "Connecting to ", cls.servername ); SCR_DrawString( x, y, UI_CENTER|UI_DROPSHADOW, s ); y += 16; @@ -582,7 +582,7 @@ static void draw_following( void ) { return; } - if( !cls.demoplayback && cl.frame.clientNum == cl.clientNum ) { + if( !cls.demo.playback && cl.frame.clientNum == cl.clientNum ) { return; } if( cl.frame.ps.stats[STAT_LAYOUTS] ) { @@ -709,7 +709,7 @@ void SCR_Draw2D( void ) { } if( ( cl.frame.ps.stats[STAT_LAYOUTS] & 1 ) || - ( cls.demoplayback && Key_IsDown( K_F1 ) ) ) + ( cls.demo.playback && Key_IsDown( K_F1 ) ) ) { SCR_ExecuteLayoutString( cl.layout ); } diff --git a/source/cl_ents.c b/source/cl_ents.c index b828b3e..2dc8c46 100644 --- a/source/cl_ents.c +++ b/source/cl_ents.c @@ -121,7 +121,7 @@ void CL_DeltaFrame( void ) { } } - if( cls.demorecording ) { + if( cls.demo.recording ) { CL_EmitDemoFrame(); } @@ -837,7 +837,7 @@ static void CL_CalcViewValues( void ) { lerp = cl.lerpfrac; // calculate the origin - if( !cls.demoplayback && cl_predict->integer && !( ps->pmove.pm_flags & PMF_NO_PREDICTION ) ) { + if( !cls.demo.playback && cl_predict->integer && !( ps->pmove.pm_flags & PMF_NO_PREDICTION ) ) { // use predicted values unsigned delta = cls.realtime - cl.predicted_step_time; float backlerp = lerp - 1.0; @@ -862,7 +862,7 @@ static void CL_CalcViewValues( void ) { } // if not running a demo or on a locked frame, add the local angle movement - if( cls.demoplayback ) { + if( cls.demo.playback ) { if( cls.key_dest == KEY_GAME && Key_IsDown( K_SHIFT ) ) { VectorCopy( cl.viewangles, cl.refdef.viewangles ); } else { @@ -889,7 +889,7 @@ static void CL_CalcViewValues( void ) { cl.delta_angles[2] = LerpShort( ops->pmove.delta_angles[2], ps->pmove.delta_angles[2], lerp ); #endif - if( cls.demoplayback && ( info_uf->integer & UF_LOCALFOV ) ) { + if( cls.demo.playback && ( info_uf->integer & UF_LOCALFOV ) ) { fov = info_fov->value; if( fov < 1 ) { fov = 90; diff --git a/source/cl_input.c b/source/cl_input.c index 51136ea..007edcf 100644 --- a/source/cl_input.c +++ b/source/cl_input.c @@ -98,7 +98,7 @@ void IN_Activate( void ) { grab = IN_GRAB; } else if( cls.key_dest & KEY_MENU ) { grab = IN_SHOW; - } else if( ( cls.key_dest & KEY_CONSOLE ) || sv_paused->integer || cls.demoplayback || cl.frame.ps.pmove.pm_type == PM_FREEZE ) { + } else if( ( cls.key_dest & KEY_CONSOLE ) || sv_paused->integer || cls.demo.playback || cl.frame.ps.pmove.pm_type == PM_FREEZE ) { grab = IN_HIDE; if( !input.hideCursor ) { input.hideCursor = 1; diff --git a/source/cl_keys.c b/source/cl_keys.c index 79c2baa..7ccd659 100644 --- a/source/cl_keys.c +++ b/source/cl_keys.c @@ -703,7 +703,7 @@ void Key_Event( unsigned key, qboolean down, unsigned time ) { } if( cls.key_dest == KEY_GAME && - !cls.demoplayback && + !cls.demo.playback && cl.clientNum != -1 && cl.frame.ps.stats[STAT_LAYOUTS] && !cl.putaway ) diff --git a/source/cl_local.h b/source/cl_local.h index acffe4f..bd768c0 100644 --- a/source/cl_local.h +++ b/source/cl_local.h @@ -34,49 +34,49 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //============================================================================= typedef struct centity_s { - entity_state_t current; - entity_state_t prev; // will always be valid, but might just be a copy of current + entity_state_t current; + entity_state_t prev; // will always be valid, but might just be a copy of current - int serverframe; // if not current, this ent isn't in the frame + int serverframe; // if not current, this ent isn't in the frame - int trailcount; // for diminishing grenade trails - vec3_t lerp_origin; // for trails (variable hz) + int trailcount; // for diminishing grenade trails + vec3_t lerp_origin; // for trails (variable hz) - int fly_stoptime; + int fly_stoptime; } centity_t; -#define MAX_CLIENTWEAPONMODELS 20 // PGM -- upped from 16 to fit the chainfist vwep +#define MAX_CLIENTWEAPONMODELS 20 // PGM -- upped from 16 to fit the chainfist vwep typedef struct clientinfo_s { - char name[MAX_QPATH]; - qhandle_t skin; - qhandle_t icon; - char model_name[MAX_QPATH]; - char skin_name[MAX_QPATH]; - qhandle_t model; - qhandle_t weaponmodel[MAX_CLIENTWEAPONMODELS]; + char name[MAX_QPATH]; + qhandle_t skin; + qhandle_t icon; + char model_name[MAX_QPATH]; + char skin_name[MAX_QPATH]; + qhandle_t model; + qhandle_t weaponmodel[MAX_CLIENTWEAPONMODELS]; } clientinfo_t; typedef struct { - unsigned sent; // time sent, for calculating pings - unsigned rcvd; // time rcvd, for calculating pings - unsigned cmdNumber; // current cmdNumber for this frame + unsigned sent; // time sent, for calculating pings + unsigned rcvd; // time rcvd, for calculating pings + unsigned cmdNumber; // current cmdNumber for this frame } client_history_t; typedef struct { - qboolean valid; + qboolean valid; - int number; - int delta; + int number; + int delta; - byte areabits[MAX_MAP_AREAS / 8]; - int areabytes; + byte areabits[MAX_MAP_AREAS / 8]; + int areabytes; - player_state_t ps; + player_state_t ps; int clientNum; - int numEntities; - int firstEntity; + int numEntities; + int firstEntity; } server_frame_t; typedef enum { @@ -93,126 +93,126 @@ typedef enum { // server map change // typedef struct client_state_s { - int timeoutcount; + int timeoutcount; - unsigned lastTransmitTime; - unsigned lastTransmitCmdNumber; + unsigned lastTransmitTime; + unsigned lastTransmitCmdNumber; qboolean sendPacketNow; - usercmd_t cmd; - usercmd_t cmds[CMD_BACKUP]; // each mesage will send several old cmds - unsigned cmdNumber; - short predicted_origins[CMD_BACKUP][3]; // for debug comparing against server - client_history_t history[CMD_BACKUP]; + usercmd_t cmd; + usercmd_t cmds[CMD_BACKUP]; // each mesage will send several old cmds + unsigned cmdNumber; + short predicted_origins[CMD_BACKUP][3]; // for debug comparing against server + client_history_t history[CMD_BACKUP]; int initialSeq; - float predicted_step; // for stair up smoothing - unsigned predicted_step_time; - unsigned predicted_step_frame; - vec3_t move; + float predicted_step; // for stair up smoothing + unsigned predicted_step_time; + unsigned predicted_step_frame; + vec3_t move; - vec3_t predicted_origin; // generated by CL_PredictMovement - vec3_t predicted_angles; - vec3_t predicted_velocity; - vec3_t prediction_error; + vec3_t predicted_origin; // generated by CL_PredictMovement + vec3_t predicted_angles; + vec3_t predicted_velocity; + vec3_t prediction_error; // rebuilt each valid frame - entity_state_t *solidEntities[MAX_PACKET_ENTITIES]; - int numSolidEntities; + entity_state_t *solidEntities[MAX_PACKET_ENTITIES]; + int numSolidEntities; - entity_state_t baselines[MAX_EDICTS]; + entity_state_t baselines[MAX_EDICTS]; - entity_state_t entityStates[MAX_PARSE_ENTITIES]; - int numEntityStates; + entity_state_t entityStates[MAX_PARSE_ENTITIES]; + int numEntityStates; - server_frame_t frames[UPDATE_BACKUP]; - server_frame_t frame; // received from server - server_frame_t oldframe; - int servertime; - int serverdelta; - frameflags_t frameflags; + server_frame_t frames[UPDATE_BACKUP]; + server_frame_t frame; // received from server + server_frame_t oldframe; + int servertime; + int serverdelta; + frameflags_t frameflags; - int lastframe; + int lastframe; - int demoframe; - int demodelta; - byte dcs[CS_BITMAP_BYTES]; + int demoframe; + int demodelta; + byte dcs[CS_BITMAP_BYTES]; - // the client maintains its own idea of view angles, which are - // sent to the server each frame. It is cleared to 0 upon entering each level. - // the server sends a delta each frame which is added to the locally - // tracked view angles to account for standing on rotating objects, - // and teleport direction changes - vec3_t viewangles; + // the client maintains its own idea of view angles, which are + // sent to the server each frame. It is cleared to 0 upon entering each level. + // the server sends a delta each frame which is added to the locally + // tracked view angles to account for standing on rotating objects, + // and teleport direction changes + vec3_t viewangles; #if USE_SMOOTH_DELTA_ANGLES short delta_angles[3]; // interpolated #endif - int time; // this is the time value that the client - // is rendering at. always <= cls.realtime - float lerpfrac; // between oldframe and frame + int time; // this is the time value that the client + // is rendering at. always <= cls.realtime + float lerpfrac; // between oldframe and frame int frametime; // fixed server frame time float framefrac; - refdef_t refdef; - int lightlevel; + refdef_t refdef; + int lightlevel; - vec3_t v_forward, v_right, v_up; // set when refdef.angles is set + vec3_t v_forward, v_right, v_up; // set when refdef.angles is set - qboolean thirdPersonView; + qboolean thirdPersonView; - // predicted values, used for smooth player entity movement in thirdperson view - vec3_t playerEntityOrigin; - vec3_t playerEntityAngles; - - // - // transient data from server - // - char layout[MAX_STRING_CHARS]; // general 2D overlay - int inventory[MAX_ITEMS]; + // predicted values, used for smooth player entity movement in thirdperson view + vec3_t playerEntityOrigin; + vec3_t playerEntityAngles; + + // + // transient data from server + // + char layout[MAX_STRING_CHARS]; // general 2D overlay + int inventory[MAX_ITEMS]; qboolean putaway; - // - // server state information - // - gametype_t gametype; - int servercount; // server identification for prespawns - char gamedir[MAX_QPATH]; - int clientNum; // never changed during gameplay, set by serverdata packet - int maxclients; - pmoveParams_t pmp; + // + // server state information + // + gametype_t gametype; + int servercount; // server identification for prespawns + char gamedir[MAX_QPATH]; + int clientNum; // never changed during gameplay, set by serverdata packet + int maxclients; + pmoveParams_t pmp; - char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH]; - char mapname[MAX_QPATH]; // short format - q2dm1, etc + char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH]; + char mapname[MAX_QPATH]; // short format - q2dm1, etc #if USE_AUTOREPLY - unsigned reply_time; - unsigned reply_delta; + unsigned reply_time; + unsigned reply_delta; #endif - load_state_t load_state; + load_state_t load_state; unsigned load_time[ LOAD_FINISH + 1 ]; - // - // locally derived information from server state - // - cm_t cm; + // + // locally derived information from server state + // + cm_t cm; - qhandle_t model_draw[MAX_MODELS]; - cmodel_t *model_clip[MAX_MODELS]; + qhandle_t model_draw[MAX_MODELS]; + cmodel_t *model_clip[MAX_MODELS]; - qhandle_t sound_precache[MAX_SOUNDS]; - qhandle_t image_precache[MAX_IMAGES]; + qhandle_t sound_precache[MAX_SOUNDS]; + qhandle_t image_precache[MAX_IMAGES]; - clientinfo_t clientinfo[MAX_CLIENTS]; - clientinfo_t baseclientinfo; + clientinfo_t clientinfo[MAX_CLIENTS]; + clientinfo_t baseclientinfo; - char weaponModels[MAX_CLIENTWEAPONMODELS][MAX_QPATH]; - int numWeaponModels; + char weaponModels[MAX_CLIENTWEAPONMODELS][MAX_QPATH]; + int numWeaponModels; } client_state_t; -extern client_state_t cl; +extern client_state_t cl; int CL_GetSoundInfo( vec3_t origin, vec3_t forward, vec3_t right, vec3_t up ); @@ -228,148 +228,149 @@ of server connections #define CONNECT_DELAY 3000 typedef struct client_static_s { - connstate_t state; - keydest_t key_dest; + connstate_t state; + keydest_t key_dest; - active_t active; + active_t active; - qboolean ref_initialized; - qboolean _unused1; - qboolean _unused2; + qboolean ref_initialized; + qboolean _unused1; + qboolean _unused2; - int userinfo_modified; - cvar_t *userinfo_updates[MAX_PACKET_USERINFOS]; + int userinfo_modified; + cvar_t *userinfo_updates[MAX_PACKET_USERINFOS]; // this is set each time a CVAR_USERINFO variable is changed // so that the client knows to send it to the server - int framecount; - unsigned realtime; // always increasing, no clamping, etc - float frametime; // seconds since last frame + int framecount; + unsigned realtime; // always increasing, no clamping, etc + float frametime; // seconds since last frame - unsigned measureFramecount; - unsigned measureTime; - int fps, ping; + unsigned measureFramecount; + unsigned measureTime; + int fps, ping; // connection information - netadr_t serverAddress; - char servername[MAX_OSPATH]; // name of server from original connect - unsigned connect_time; // for connection retransmits - int connect_count; - char messageString[MAX_STRING_CHARS]; + netadr_t serverAddress; + char servername[MAX_OSPATH]; // name of server from original connect + unsigned connect_time; // for connection retransmits + int connect_count; + char messageString[MAX_STRING_CHARS]; qboolean passive; #if USE_ZLIB z_stream z; #endif - int quakePort; // a 16 bit value that allows quake servers - // to work around address translating routers - netchan_t *netchan; - int serverProtocol; // in case we are doing some kind of version hack + int quakePort; // a 16 bit value that allows quake servers + // to work around address translating routers + netchan_t *netchan; + int serverProtocol; // in case we are doing some kind of version hack int protocolVersion; // minor version - int challenge; // from the server to use for connecting + int challenge; // from the server to use for connecting - fileHandle_t download; // file transfer from server - char downloadtempname[MAX_QPATH]; - char downloadname[MAX_QPATH]; - int downloadnumber; - dltype_t downloadtype; - int downloadpercent; + struct { + fileHandle_t file; // file transfer from server + char temp[MAX_QPATH]; + char name[MAX_QPATH]; + int percent; + } download; // demo recording info must be here, so it isn't cleared on level change - fileHandle_t demoplayback; - fileHandle_t demorecording; - unsigned timeDemoStart; - unsigned timeDemoFrames; - int demofileSize; - int demofileFrameOffset; - int demofilePercent; - sizebuf_t demobuff; - qboolean demopaused; + struct { + fileHandle_t playback; + fileHandle_t recording; + unsigned time_start; + unsigned time_frames; + int file_size; + int file_offset; + int file_percent; + sizebuf_t buffer; + qboolean paused; + } demo; } client_static_t; -extern client_static_t cls; +extern client_static_t cls; //============================================================================= -#define NOPART_GRENADE_EXPLOSION 1 -#define NOPART_GRENADE_TRAIL 2 -#define NOPART_ROCKET_EXPLOSION 4 -#define NOPART_ROCKET_TRAIL 8 -#define NOPART_BLOOD 16 +#define NOPART_GRENADE_EXPLOSION 1 +#define NOPART_GRENADE_TRAIL 2 +#define NOPART_ROCKET_EXPLOSION 4 +#define NOPART_ROCKET_TRAIL 8 +#define NOPART_BLOOD 16 -#define NOEXP_GRENADE 1 -#define NOEXP_ROCKET 2 +#define NOEXP_GRENADE 1 +#define NOEXP_ROCKET 2 // // cvars // -extern cvar_t *cl_gun; -extern cvar_t *cl_add_blend; -extern cvar_t *cl_add_lights; -extern cvar_t *cl_add_particles; -extern cvar_t *cl_add_entities; -extern cvar_t *cl_predict; -extern cvar_t *cl_footsteps; -extern cvar_t *cl_noskins; -extern cvar_t *cl_kickangles; -extern cvar_t *cl_rollhack; +extern cvar_t *cl_gun; +extern cvar_t *cl_add_blend; +extern cvar_t *cl_add_lights; +extern cvar_t *cl_add_particles; +extern cvar_t *cl_add_entities; +extern cvar_t *cl_predict; +extern cvar_t *cl_footsteps; +extern cvar_t *cl_noskins; +extern cvar_t *cl_kickangles; +extern cvar_t *cl_rollhack; -extern cvar_t *cl_shownet; -extern cvar_t *cl_showmiss; -extern cvar_t *cl_showclamp; +extern cvar_t *cl_shownet; +extern cvar_t *cl_showmiss; +extern cvar_t *cl_showclamp; -extern cvar_t *cl_vwep; +extern cvar_t *cl_vwep; -extern cvar_t *cl_disable_particles; -extern cvar_t *cl_disable_explosions; +extern cvar_t *cl_disable_particles; +extern cvar_t *cl_disable_explosions; -extern cvar_t *cl_chat_notify; -extern cvar_t *cl_chat_sound; -extern cvar_t *cl_chat_filter; +extern cvar_t *cl_chat_notify; +extern cvar_t *cl_chat_sound; +extern cvar_t *cl_chat_filter; -extern cvar_t *cl_disconnectcmd; -extern cvar_t *cl_changemapcmd; -extern cvar_t *cl_beginmapcmd; +extern cvar_t *cl_disconnectcmd; +extern cvar_t *cl_changemapcmd; +extern cvar_t *cl_beginmapcmd; -extern cvar_t *cl_gibs; +extern cvar_t *cl_gibs; -extern cvar_t *cl_demo_local_fov; -extern cvar_t *cl_thirdperson; -extern cvar_t *cl_thirdperson_angle; -extern cvar_t *cl_thirdperson_range; +extern cvar_t *cl_demo_local_fov; +extern cvar_t *cl_thirdperson; +extern cvar_t *cl_thirdperson_angle; +extern cvar_t *cl_thirdperson_range; -extern cvar_t *cl_async; +extern cvar_t *cl_async; // // userinfo // -extern cvar_t *info_password; -extern cvar_t *info_spectator; -extern cvar_t *info_name; -extern cvar_t *info_skin; -extern cvar_t *info_rate; -extern cvar_t *info_fov; -extern cvar_t *info_msg; -extern cvar_t *info_hand; -extern cvar_t *info_gender; -extern cvar_t *info_uf; - - -typedef struct cdlight_s -{ - int key; // so entities can reuse same entry - vec3_t color; - vec3_t origin; - float radius; - float die; // stop lighting after this time - float decay; // drop this each second - float minlight; // don't add when contributing less +extern cvar_t *info_password; +extern cvar_t *info_spectator; +extern cvar_t *info_name; +extern cvar_t *info_skin; +extern cvar_t *info_rate; +extern cvar_t *info_fov; +extern cvar_t *info_msg; +extern cvar_t *info_hand; +extern cvar_t *info_gender; +extern cvar_t *info_uf; + + +typedef struct cdlight_s { + int key; // so entities can reuse same entry + vec3_t color; + vec3_t origin; + float radius; + float die; // stop lighting after this time + float decay; // drop this each second + float minlight; // don't add when contributing less } cdlight_t; -extern centity_t cl_entities[MAX_EDICTS]; -extern cdlight_t cl_dlights[MAX_DLIGHTS]; +extern centity_t cl_entities[MAX_EDICTS]; +extern cdlight_t cl_dlights[MAX_DLIGHTS]; //============================================================================= @@ -378,22 +379,21 @@ extern cdlight_t cl_dlights[MAX_DLIGHTS]; void CL_AddNetgraph (void); //ROGUE -typedef struct cl_sustain_s -{ - int id; - int type; - int endtime; - int nextthink; - int thinkinterval; - vec3_t org; - vec3_t dir; - int color; - int count; - int magnitude; - void (*think)(struct cl_sustain_s *self); +typedef struct cl_sustain_s { + int id; + int type; + int endtime; + int nextthink; + int thinkinterval; + vec3_t org; + vec3_t dir; + int color; + int count; + int magnitude; + void (*think)(struct cl_sustain_s *self); } cl_sustain_t; -#define MAX_SUSTAINS 32 +#define MAX_SUSTAINS 32 void CL_ParticleSteamEffect2(cl_sustain_t *self); void CL_TeleporterParticles (entity_state_t *ent); @@ -408,27 +408,26 @@ void CL_ParticleEffect3 (vec3_t org, vec3_t dir, int color, int count); // ======== // PGM -typedef struct cparticle_s -{ - struct cparticle_s *next; - - float time; - - vec3_t org; - vec3_t vel; - vec3_t accel; - float color; - float colorvel; - float alpha; - float alphavel; - color_t rgb; +typedef struct cparticle_s{ + struct cparticle_s *next; + + float time; + + vec3_t org; + vec3_t vel; + vec3_t accel; + float color; + float colorvel; + float alpha; + float alphavel; + color_t rgb; } cparticle_t; -#define PARTICLE_GRAVITY 40 -#define BLASTER_PARTICLE_COLOR 0xe0 +#define PARTICLE_GRAVITY 40 +#define BLASTER_PARTICLE_COLOR 0xe0 // PMM -#define INSTANT_PARTICLE -10000.0 +#define INSTANT_PARTICLE -10000.0 // PGM // ======== @@ -537,8 +536,8 @@ void CL_DeltaFrame( void ); // // cl_view.c // -extern int gun_frame; -extern qhandle_t gun_model; +extern int gun_frame; +extern qhandle_t gun_model; void V_Init( void ); void V_Shutdown( void ); @@ -556,20 +555,20 @@ void CL_RegisterTEntSounds (void); void CL_RegisterTEntModels (void); void CL_SmokeAndFlash(vec3_t origin); -#define LASER_FADE_NOT 1 -#define LASER_FADE_ALPHA 2 -#define LASER_FADE_RGBA 3 +#define LASER_FADE_NOT 1 +#define LASER_FADE_ALPHA 2 +#define LASER_FADE_RGBA 3 typedef struct laser_s { - entity_t ent; - vec3_t start; - vec3_t end; - int fadeType; - qboolean indexed; - color_t color; - float width; - int lifeTime; - int startTime; + entity_t ent; + vec3_t start; + vec3_t end; + int fadeType; + qboolean indexed; + color_t color; + float width; + int lifeTime; + int startTime; } laser_t; laser_t *CL_AllocLaser( void ); @@ -605,7 +604,6 @@ void CL_EmitZeroFrame( void ); void CL_WriteDemoMessage( sizebuf_t *buf ); void CL_EmitDemoFrame( void ); void CL_Stop_f( void ); -void CL_Record_f( void ); demoInfo_t *CL_GetDemoInfo( const char *path, demoInfo_t *info ); @@ -643,78 +641,78 @@ void Char_Message( int key ); // // cl_ref.c // -void CL_InitRefresh( void ); -void CL_ShutdownRefresh( void ); +void CL_InitRefresh( void ); +void CL_ShutdownRefresh( void ); // // cl_ui.c // -void CL_InitUI( void ); -void CL_ShutdownUI( void ); +void CL_InitUI( void ); +void CL_ShutdownUI( void ); // // cl_scrn.c // -extern cvar_t *scr_viewsize; -extern cvar_t *scr_draw2d; +extern cvar_t *scr_viewsize; +extern cvar_t *scr_draw2d; -extern cvar_t *crosshair; -extern qhandle_t crosshair_pic; -extern int crosshair_width, crosshair_height; +extern cvar_t *crosshair; +extern qhandle_t crosshair_pic; +extern int crosshair_width, crosshair_height; -extern qhandle_t scr_net; -extern qhandle_t scr_font; +extern qhandle_t scr_net; +extern qhandle_t scr_font; -extern glconfig_t scr_glconfig; -extern vrect_t scr_vrect; // position of render window +extern glconfig_t scr_glconfig; +extern vrect_t scr_vrect; // position of render window -extern int scr_hudWidth; -extern int scr_hudHeight; +extern int scr_hudWidth; +extern int scr_hudHeight; -void SCR_Init (void); +void SCR_Init (void); void SCR_Shutdown( void ); -void SCR_UpdateScreen (void); -void SCR_SizeUp( void ); -void SCR_SizeDown( void ); -void SCR_CenterPrint( const char *str ); -void SCR_BeginLoadingPlaque( void ); -void SCR_EndLoadingPlaque( void ); -void SCR_DebugGraph ( float value, int color ); -void SCR_TouchPics ( void ); -void SCR_RegisterMedia( void ); +void SCR_UpdateScreen (void); +void SCR_SizeUp( void ); +void SCR_SizeDown( void ); +void SCR_CenterPrint( const char *str ); +void SCR_BeginLoadingPlaque( void ); +void SCR_EndLoadingPlaque( void ); +void SCR_DebugGraph ( float value, int color ); +void SCR_TouchPics ( void ); +void SCR_RegisterMedia( void ); void SCR_ModeChanged( void ); -void SCR_RunConsole (void); -void SCR_ExecuteLayoutString( const char *s ); -void SCR_DrawInventory( void ); -void SCR_DrawPause( void ); -void SCR_DrawNet( void ); -void SCR_DrawCenterString( void ); +void SCR_RunConsole (void); +void SCR_ExecuteLayoutString( const char *s ); +void SCR_DrawInventory( void ); +void SCR_DrawPause( void ); +void SCR_DrawNet( void ); +void SCR_DrawCenterString( void ); // // cl_cin.c // -void SCR_PlayCinematic( const char *name ); -qboolean SCR_DrawCinematic( void ); -void SCR_RunCinematic( void ); -void SCR_StopCinematic( void ); -void SCR_FinishCinematic( void ); +void SCR_PlayCinematic( const char *name ); +qboolean SCR_DrawCinematic( void ); +void SCR_RunCinematic( void ); +void SCR_StopCinematic( void ); +void SCR_FinishCinematic( void ); // // cl_draw.c // -void SCR_InitDraw( void ); -void SCR_ShutdownDraw( void ); -void SCR_Draw2D( void ); +void SCR_InitDraw( void ); +void SCR_ShutdownDraw( void ); +void SCR_Draw2D( void ); void SCR_DrawLoading( void ); -float SCR_FadeAlpha( unsigned startTime, unsigned visTime, unsigned fadeTime ); +float SCR_FadeAlpha( unsigned startTime, unsigned visTime, unsigned fadeTime ); #if USE_CHATHUD -void SCR_ClearChatHUD_f( void ); -void SCR_AddToChatHUD( const char *string ); +void SCR_ClearChatHUD_f( void ); +void SCR_AddToChatHUD( const char *string ); #endif void SCR_LagSample( void ); -void SCR_LagClear( void ); +void SCR_LagClear( void ); int SCR_DrawStringEx( int x, int y, int flags, size_t maxlen, const char *s, qhandle_t font ); void SCR_DrawStringMulti( int x, int y, int flags, size_t maxlen, const char *s, qhandle_t font ); @@ -722,10 +720,10 @@ void SCR_DrawStringMulti( int x, int y, int flags, size_t maxlen, const char // // cl_keys.c // -void Key_Init( void ); -void Key_Event( unsigned key, qboolean down, unsigned time ); -void Key_CharEvent( int key ); -void Key_WriteBindings( fileHandle_t f ); +void Key_Init( void ); +void Key_Event( unsigned key, qboolean down, unsigned time ); +void Key_CharEvent( int key ); +void Key_WriteBindings( fileHandle_t f ); // @@ -733,7 +731,3 @@ void Key_WriteBindings( fileHandle_t f ); // void CL_InitAscii( void ); - - - - diff --git a/source/cl_main.c b/source/cl_main.c index c952b31..b1b7467 100644 --- a/source/cl_main.c +++ b/source/cl_main.c @@ -279,7 +279,7 @@ static void CL_ForwardToServer_f( void ) { return; } - if ( cls.demoplayback ) { + if ( cls.demo.playback ) { return; } @@ -320,7 +320,7 @@ static void CL_CheckForResend( void ) { char tail[MAX_QPATH]; char userinfo[MAX_INFO_STRING]; - if ( cls.demoplayback ) { + if ( cls.demo.playback ) { return; } @@ -602,35 +602,35 @@ This is also called on Com_Error, so it shouldn't cause any errors ===================== */ void CL_Disconnect( comErrorType_t type, const char *text ) { - if ( cls.state > ca_disconnected ) { + if( cls.state > ca_disconnected ) { EXEC_TRIGGER( cl_disconnectcmd ); } - if ( cls.ref_initialized ) + if( cls.ref_initialized ) ref.CinematicSetPalette( NULL ); cls.connect_time = 0; cls.connect_count = 0; cls.passive = qfalse; - if ( cls.demoplayback ) { - FS_FCloseFile( cls.demoplayback ); - cls.demoplayback = 0; + // stop demo + if( cls.demo.recording ) { + CL_Stop_f(); + } + if( cls.demo.playback ) { + FS_FCloseFile( cls.demo.playback ); - if ( com_timedemo->integer ) { + if( com_timedemo->integer ) { unsigned msec = Sys_Milliseconds(); - - float sec = ( msec - cls.timeDemoStart ) * 0.001f; - float fps = cls.timeDemoFrames / sec; + float sec = ( msec - cls.demo.time_start ) * 0.001f; + float fps = cls.demo.time_frames / sec; Com_Printf( "%u frames, %3.1f seconds: %3.1f fps\n", - cls.timeDemoFrames, sec, fps ); + cls.demo.time_frames, sec, fps ); } } + memset( &cls.demo, 0, sizeof( cls.demo ) ); - if ( cls.demorecording ) - CL_Stop_f(); - if( cls.netchan ) { // send a disconnect message to the server MSG_WriteByte( clc_stringcmd ); @@ -647,13 +647,10 @@ void CL_Disconnect( comErrorType_t type, const char *text ) { } // stop download - if ( cls.download ) { - FS_FCloseFile( cls.download ); - cls.download = 0; + if( cls.download.file ) { + FS_FCloseFile( cls.download.file ); } - - cls.downloadtempname[ 0 ] = 0; - cls.downloadname[ 0 ] = 0; + memset( &cls.download, 0, sizeof( cls.download ) ); CL_ClearState (); @@ -964,7 +961,7 @@ static void CL_Changing_f( void ) { return; } - if ( cls.demorecording ) + if ( cls.demo.recording ) CL_Stop_f(); S_StopAllSounds(); @@ -1006,10 +1003,10 @@ static void CL_Reconnect_f( void ) { if( cls.state >= ca_connected ) { cls.state = ca_connected; - if ( cls.demoplayback ) { + if( cls.demo.playback ) { return; } - if ( cls.download ) { + if( cls.download.file ) { return; // if we are downloading, we don't change! } @@ -1910,7 +1907,7 @@ static void CL_Precache_f( void ) { //Yet another hack to let old demos work //the old precache sequence - if( cls.demoplayback ) { + if( cls.demo.playback ) { CM_LoadMap( &cl.cm, cl.configstrings[ CS_MODELS + 1 ], CM_LOAD_CLIENT, NULL ); CL_RegisterModels(); @@ -2142,7 +2139,7 @@ static size_t CL_Ups_m( char *buffer, size_t size ) { return 0; } - if( !cls.demoplayback && cl.frame.clientNum == cl.clientNum && + if( !cls.demo.playback && cl.frame.clientNum == cl.clientNum && cl_predict->integer ) { VectorCopy( cl.predicted_velocity, vel ); @@ -2475,7 +2472,7 @@ CL_CheatsOK ================== */ qboolean CL_CheatsOK( void ) { - if( cls.state < ca_connected || cls.demoplayback ) { + if( cls.state < ca_connected || cls.demo.playback ) { return qtrue; } @@ -2692,8 +2689,8 @@ void CL_Frame( int msec ) { } if( ref_extra < ref_msec ) { if( !cl_async->integer && !cl.sendPacketNow ) { -#if 1 - if( cls.demoplayback || cl.frame.ps.pmove.pm_type == PM_FREEZE ) { +#if 0 + if( cls.demo.playback || cl.frame.ps.pmove.pm_type == PM_FREEZE ) { NET_Sleep( ref_msec - ref_extra ); } #endif @@ -2703,7 +2700,7 @@ void CL_Frame( int msec ) { } } - if ( cls.demoplayback ) { // FIXME: HACK + if ( cls.demo.playback ) { // FIXME: HACK if( cl_paused->integer ) { if( !sv_paused->integer ) { Cvar_Set( "sv_paused", "1" ); @@ -2728,8 +2725,8 @@ void CL_Frame( int msec ) { } // read next demo frame - if( cls.demoplayback ) { - if( cls.demorecording && cl_paused->integer == 2 && !cls.demopaused ) { + if( cls.demo.playback ) { + if( cls.demo.recording && cl_paused->integer == 2 && !cls.demo.paused ) { static int demo_extra; // XXX: record zero frames when manually paused @@ -2808,8 +2805,6 @@ void CL_Frame( int msec ) { //============================================================================ -static byte demo_buffer[MAX_PACKETLEN_WRITABLE_DEFAULT]; - /* ==================== CL_Init @@ -2846,8 +2841,6 @@ void CL_Init( void ) { } #endif - SZ_Init( &cls.demobuff, demo_buffer, sizeof( demo_buffer ) ); - UI_OpenMenu( UIMENU_MAIN ); Con_PostInit(); diff --git a/source/cl_parse.c b/source/cl_parse.c index abbe8b5..20df0b3 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -24,12 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //============================================================================= -static const char validExts[][4] = { - "pcx", "wal", "tga", "jpg", "png", - "md2", "md3", "sp2", "wav", "dm2", - "bsp", "txt", "loc", "ent", "" -}; - /* =============== CL_CheckOrDownloadFile @@ -39,84 +33,87 @@ to start a download from the server. =============== */ qboolean CL_CheckOrDownloadFile( const char *path ) { - fileHandle_t f; - int i, length; - char filename[MAX_QPATH]; - char *ext; - - Q_strncpyz( filename, path, sizeof( filename ) ); - Q_strlwr( filename ); - - length = strlen( filename ); - if( !length - || !Q_ispath( filename[0] ) - || !Q_ispath( filename[ length - 1 ] ) - || strchr( filename, '\\' ) - || strchr( filename, ':' ) - || !strchr( filename, '/' ) - || strstr( filename, ".." ) ) - { - Com_WPrintf( "Refusing to download file with invalid path.\n" ); - return qtrue; - } - - // a trivial attempt to prevent malicious server from - // uploading trojan executables to the win32 client - ext = COM_FileExtension( filename ); + static const char validExts[][4] = { + "pcx", "wal", "tga", "jpg", "png", + "md2", "md3", "sp2", "wav", "dm2", + "bsp", "txt", "loc", "ent", "" + }; + fileHandle_t f; + int i, length; + char filename[MAX_QPATH]; + char *ext; + + Q_strncpyz( filename, path, sizeof( filename ) ); + Q_strlwr( filename ); + + length = strlen( filename ); + if( !length + || !Q_ispath( filename[0] ) + || !Q_ispath( filename[ length - 1 ] ) + || strchr( filename, '\\' ) + || strchr( filename, ':' ) + || !strchr( filename, '/' ) + || strstr( filename, ".." ) ) + { + Com_WPrintf( "Refusing to download file with invalid path.\n" ); + return qtrue; + } + + // a trivial attempt to prevent malicious server from + // uploading trojan executables to the win32 client + ext = COM_FileExtension( filename ); if( *ext != '.' ) { - Com_WPrintf( "Refusing to download file without extension.\n" ); + Com_WPrintf( "Refusing to download file without extension.\n" ); return qtrue; } for( i = 0; validExts[i][0]; i++ ) { - if( !strcmp( ext + 1, validExts[i] ) ) { + if( !strcmp( ext + 1, validExts[i] ) ) { break; } - } + } if( !validExts[i][0] ) { - Com_WPrintf( "Refusing to download file with invalid extension.\n" ); - return qtrue; + Com_WPrintf( "Refusing to download file with invalid extension.\n" ); + return qtrue; } - if( FS_LoadFile( filename, NULL ) != INVALID_LENGTH ) { - // it exists, no need to download - return qtrue; - } + if( FS_LoadFile( filename, NULL ) != INVALID_LENGTH ) { + // it exists, no need to download + return qtrue; + } - strcpy( cls.downloadname, filename ); + strcpy( cls.download.name, filename ); - // download to a temp name, and only rename - // to the real name when done, so if interrupted - // a runt file wont be left - COM_StripExtension( cls.downloadname, cls.downloadtempname, MAX_QPATH ); - - if( strlen( cls.downloadtempname ) >= MAX_QPATH - 5 ) { - strcpy( cls.downloadtempname + MAX_QPATH - 5, ".tmp" ); - } else { - strcat( cls.downloadtempname, ".tmp" ); - } + // download to a temp name, and only rename + // to the real name when done, so if interrupted + // a runt file wont be left + COM_StripExtension( cls.download.name, cls.download.temp, MAX_QPATH ); + + if( strlen( cls.download.temp ) >= MAX_QPATH - 5 ) { + strcpy( cls.download.temp + MAX_QPATH - 5, ".tmp" ); + } else { + strcat( cls.download.temp, ".tmp" ); + } //ZOID - // check to see if we already have a tmp for this file, if so, try to resume - // open the file if not opened yet - length = FS_FOpenFile( cls.downloadtempname, &f, FS_MODE_RDWR ); - if( length < 0 && f ) { - Com_WPrintf( "Couldn't determine size of %s\n", cls.downloadtempname ); - FS_FCloseFile( f ); - f = 0; - } - if( f ) { // it exists - cls.download = f; - // give the server an offset to start the download - Com_Printf( "Resuming %s\n", cls.downloadname ); - CL_ClientCommand( va( "download \"%s\" %i", cls.downloadname, length ) ); - } else { - Com_Printf( "Downloading %s\n", cls.downloadname ); - CL_ClientCommand( va( "download \"%s\"", cls.downloadname ) ); - } - - cls.downloadnumber++; - - return qfalse; + // check to see if we already have a tmp for this file, if so, try to resume + // open the file if not opened yet + length = FS_FOpenFile( cls.download.temp, &f, FS_MODE_RDWR ); + if( length < 0 && f ) { + Com_WPrintf( "Couldn't determine size of %s\n", cls.download.temp ); + FS_FCloseFile( f ); + f = 0; + } + if( f ) { // it exists + cls.download.file = f; + // give the server an offset to start the download + Com_Printf( "Resuming %s\n", cls.download.name ); + CL_ClientCommand( va( "download \"%s\" %i", cls.download.name, length ) ); + } else { + Com_Printf( "Downloading %s\n", cls.download.name ); + CL_ClientCommand( va( "download \"%s\"", cls.download.name ) ); + } + + return qfalse; } /* @@ -127,40 +124,40 @@ Request a download from the server =============== */ void CL_Download_f( void ) { - char *path; + char *path; - if( cls.state < ca_connected ) { - Com_Printf( "Must be connected to a server.\n" ); - return; - } + if( cls.state < ca_connected ) { + Com_Printf( "Must be connected to a server.\n" ); + return; + } - if( Cmd_Argc() != 2 ) { - Com_Printf( "Usage: download <filename>\n" ); - return; - } + if( Cmd_Argc() != 2 ) { + Com_Printf( "Usage: download <filename>\n" ); + return; + } - path = Cmd_Argv( 1 ); + path = Cmd_Argv( 1 ); - if( !allow_download->integer ) { - Com_Printf( "Couldn't download '%s', " + if( !allow_download->integer ) { + Com_Printf( "Couldn't download '%s', " "downloading is locally disabled.\n", path ); - return; - } - - if( cls.downloadtempname[0] ) { - Com_Printf( "Already downloading.\n" ); - if( cls.serverProtocol == PROTOCOL_VERSION_Q2PRO ) { - Com_Printf( "Try using 'stopdl' command to abort the download.\n" ); - } - return; - } - - if( FS_LoadFile( path, NULL ) != INVALID_LENGTH ) { - Com_Printf( "File '%s' already exists.\n", path ); - return; - } - - CL_CheckOrDownloadFile( path ); + return; + } + + if( cls.download.temp[0] ) { + Com_Printf( "Already downloading.\n" ); + if( cls.serverProtocol == PROTOCOL_VERSION_Q2PRO ) { + Com_Printf( "Try using 'stopdl' command to abort the download.\n" ); + } + return; + } + + if( FS_LoadFile( path, NULL ) != INVALID_LENGTH ) { + Com_Printf( "File '%s' already exists.\n", path ); + return; + } + + CL_CheckOrDownloadFile( path ); } @@ -172,84 +169,73 @@ A download message has been received from the server ===================== */ static void CL_ParseDownload( void ) { - int size, percent; + int size, percent; - if( !cls.downloadtempname[0] ) { - Com_Error( ERR_DROP, "Server sending download, but " + if( !cls.download.temp[0] ) { + Com_Error( ERR_DROP, "Server sending download, but " "no download was requested" ); - } - - // read the data - size = MSG_ReadShort(); - percent = MSG_ReadByte(); - if( size == -1 ) { - if( !percent ) { - Com_Printf( "Server was unable to send this file.\n" ); - } else { - Com_Printf( "Server stopped the download.\n" ); - } - if( cls.download ) { - // if here, we tried to resume a file but the server said no - FS_FCloseFile( cls.download ); - cls.download = 0; - } - cls.downloadtempname[0] = 0; - cls.downloadname[0] = 0; - CL_RequestNextDownload(); - return; - } - - if( size < 0 ) { - Com_Error( ERR_DROP, "CL_ParseDownload: bad size: %d", size ); - } - - if( msg_read.readcount + size > msg_read.cursize ) { - Com_Error( ERR_DROP, "CL_ParseDownload: read past end of message" ); - } - - // open the file if not opened yet - if( !cls.download ) { - FS_FOpenFile( cls.downloadtempname, &cls.download, FS_MODE_WRITE ); - if( !cls.download ) { - msg_read.readcount += size; - Com_WPrintf( "Failed to open '%s' for writing\n", - cls.downloadtempname ); - cls.downloadtempname[0] = 0; - cls.downloadname[0] = 0; - CL_RequestNextDownload(); - return; - } - } - - FS_Write( msg_read.data + msg_read.readcount, size, cls.download ); - msg_read.readcount += size; - - if( percent != 100 ) { - // request next block - // change display routines by zoid - cls.downloadpercent = percent; - - CL_ClientCommand( "nextdl" ); - } else { - FS_FCloseFile( cls.download ); - - // rename the temp file to it's final name - if( !FS_RenameFile( cls.downloadtempname, cls.downloadname ) ) { - Com_WPrintf( "Failed to rename %s to %s\n", - cls.downloadtempname, cls.downloadname ); - } - - Com_Printf( "Downloaded successfully.\n" ); - - cls.downloadtempname[0] = 0; - cls.downloadname[0] = 0; - - cls.download = 0; - cls.downloadpercent = 0; - - // get another file if needed - CL_RequestNextDownload(); - } + } + + // read the data + size = MSG_ReadShort(); + percent = MSG_ReadByte(); + if( size == -1 ) { + if( !percent ) { + Com_Printf( "Server was unable to send this file.\n" ); + } else { + Com_Printf( "Server stopped the download.\n" ); + } + if( cls.download.file ) { + // if here, we tried to resume a file but the server said no + FS_FCloseFile( cls.download.file ); + } + goto another; + } + + if( size < 0 ) { + Com_Error( ERR_DROP, "CL_ParseDownload: bad size: %d", size ); + } + + if( msg_read.readcount + size > msg_read.cursize ) { + Com_Error( ERR_DROP, "CL_ParseDownload: read past end of message" ); + } + + // open the file if not opened yet + if( !cls.download.file ) { + FS_FOpenFile( cls.download.temp, &cls.download.file, FS_MODE_WRITE ); + if( !cls.download.file ) { + msg_read.readcount += size; + Com_WPrintf( "Failed to open '%s' for writing\n", + cls.download.temp ); + goto another; + } + } + + FS_Write( msg_read.data + msg_read.readcount, size, cls.download.file ); + msg_read.readcount += size; + + if( percent != 100 ) { + // request next block + // change display routines by zoid + cls.download.percent = percent; + + CL_ClientCommand( "nextdl" ); + } else { + FS_FCloseFile( cls.download.file ); + + // rename the temp file to it's final name + if( !FS_RenameFile( cls.download.temp, cls.download.name ) ) { + Com_WPrintf( "Failed to rename %s to %s\n", + cls.download.temp, cls.download.name ); + } + + Com_Printf( "Downloaded successfully.\n" ); + +another: + // get another file if needed + memset( &cls.download, 0, sizeof( cls.download ) ); + CL_RequestNextDownload(); + } } /* @@ -271,21 +257,21 @@ static inline void CL_ParseDeltaEntity( server_frame_t *frame, entity_state_t *old, int bits ) { - entity_state_t *state; + entity_state_t *state; - if( frame->numEntities == MAX_PACKET_ENTITIES ) { - Com_Error( ERR_DROP, "%s: MAX_PACKET_ENTITIES exceeded", __func__ ); - } + if( frame->numEntities == MAX_PACKET_ENTITIES ) { + Com_Error( ERR_DROP, "%s: MAX_PACKET_ENTITIES exceeded", __func__ ); + } - state = &cl.entityStates[cl.numEntityStates & PARSE_ENTITIES_MASK]; - cl.numEntityStates++; - frame->numEntities++; + state = &cl.entityStates[cl.numEntityStates & PARSE_ENTITIES_MASK]; + cl.numEntityStates++; + frame->numEntities++; - if( cl_shownet->integer > 2 ) { - MSG_ShowDeltaEntityBits( bits ); - } + if( cl_shownet->integer > 2 ) { + MSG_ShowDeltaEntityBits( bits ); + } - MSG_ParseDeltaEntity( old, state, newnum, bits ); + MSG_ParseDeltaEntity( old, state, newnum, bits ); } /* @@ -296,140 +282,140 @@ CL_ParsePacketEntities static void CL_ParsePacketEntities( server_frame_t *oldframe, server_frame_t *frame ) { - int newnum; - int bits; - entity_state_t *oldstate; - int oldindex, oldnum; - int i; - - frame->firstEntity = cl.numEntityStates; - frame->numEntities = 0; - - // delta from the entities present in oldframe - oldindex = 0; - oldstate = NULL; - if( !oldframe ) { - oldnum = 99999; - } else { - if( oldindex >= oldframe->numEntities ) { - oldnum = 99999; - } else { - i = oldframe->firstEntity + oldindex; - oldstate = &cl.entityStates[i & PARSE_ENTITIES_MASK]; - oldnum = oldstate->number; - } - } - - while( 1 ) { - newnum = MSG_ParseEntityBits( &bits ); - if( newnum < 0 || newnum >= MAX_EDICTS ) { - Com_Error( ERR_DROP, "%s: bad number: %d", __func__, newnum ); - } - - if( msg_read.readcount > msg_read.cursize ) { - Com_Error( ERR_DROP, "%s: read past end of message", __func__ ); - } - - if( !newnum ) { - break; - } - - while( oldnum < newnum ) { - // one or more entities from the old packet are unchanged - if( cl_shownet->integer > 2 ) { - Com_Printf( " unchanged: %i\n", oldnum ); - } - CL_ParseDeltaEntity( frame, oldnum, oldstate, 0 ); - - oldindex++; - - if( oldindex >= oldframe->numEntities ) { - oldnum = 99999; - } else { - i = oldframe->firstEntity + oldindex; - oldstate = &cl.entityStates[i & PARSE_ENTITIES_MASK]; - oldnum = oldstate->number; - } - } - - if( bits & U_REMOVE ) { - // the entity present in oldframe is not in the current frame - if( cl_shownet->integer > 2 ) { - Com_Printf( " remove: %i\n", newnum ); - } - if( oldnum != newnum ) { - Com_DPrintf( "U_REMOVE: oldnum != newnum\n" ); - } - if( !oldframe ) { - Com_Error( ERR_DROP, "U_REMOVE: NULL oldframe" ); - } - - oldindex++; - - if( oldindex >= oldframe->numEntities ) { - oldnum = 99999; - } else { - i = oldframe->firstEntity + oldindex; - oldstate = &cl.entityStates[i & PARSE_ENTITIES_MASK]; - oldnum = oldstate->number; - } - continue; - } - - if( oldnum == newnum ) { - // delta from previous state - if( cl_shownet->integer > 2 ) { - Com_Printf( " delta: %i ", newnum ); - } - CL_ParseDeltaEntity( frame, newnum, oldstate, bits ); - if( cl_shownet->integer > 2 ) { - Com_Printf( "\n" ); - } - - oldindex++; - - if( oldindex >= oldframe->numEntities ) { - oldnum = 99999; - } else { - i = oldframe->firstEntity + oldindex; - oldstate = &cl.entityStates[i & PARSE_ENTITIES_MASK]; - oldnum = oldstate->number; - } - continue; - } - - if( oldnum > newnum ) { - // delta from baseline - if( cl_shownet->integer > 2 ) { - Com_Printf( " baseline: %i ", newnum ); - } - CL_ParseDeltaEntity( frame, newnum, &cl.baselines[newnum], bits ); - if( cl_shownet->integer > 2 ) { - Com_Printf( "\n" ); - } - continue; - } - - } - - // any remaining entities in the old frame are copied over - while( oldnum != 99999 ) { - // one or more entities from the old packet are unchanged - if( cl_shownet->integer > 2 ) { - Com_Printf( " unchanged: %i\n", oldnum ); - } - CL_ParseDeltaEntity( frame, oldnum, oldstate, 0 ); - - oldindex++; - - if( oldindex >= oldframe->numEntities ) { - oldnum = 99999; - } else { - i = oldframe->firstEntity + oldindex; - oldstate = &cl.entityStates[i & PARSE_ENTITIES_MASK]; - oldnum = oldstate->number; - } - } + int newnum; + int bits; + entity_state_t *oldstate; + int oldindex, oldnum; + int i; + + frame->firstEntity = cl.numEntityStates; + frame->numEntities = 0; + + // delta from the entities present in oldframe + oldindex = 0; + oldstate = NULL; + if( !oldframe ) { + oldnum = 99999; + } else { + if( oldindex >= oldframe->numEntities ) { + oldnum = 99999; + } else { + i = oldframe->firstEntity + oldindex; + oldstate = &cl.entityStates[i & PARSE_ENTITIES_MASK]; + oldnum = oldstate->number; + } + } + + while( 1 ) { + newnum = MSG_ParseEntityBits( &bits ); + if( newnum < 0 || newnum >= MAX_EDICTS ) { + Com_Error( ERR_DROP, "%s: bad number: %d", __func__, newnum ); + } + + if( msg_read.readcount > msg_read.cursize ) { + Com_Error( ERR_DROP, "%s: read past end of message", __func__ ); + } + + if( !newnum ) { + break; + } + + while( oldnum < newnum ) { + // one or more entities from the old packet are unchanged + if( cl_shownet->integer > 2 ) { + Com_Printf( " unchanged: %i\n", oldnum ); + } + CL_ParseDeltaEntity( frame, oldnum, oldstate, 0 ); + + oldindex++; + + if( oldindex >= oldframe->numEntities ) { + oldnum = 99999; + } else { + i = oldframe->firstEntity + oldindex; + oldstate = &cl.entityStates[i & PARSE_ENTITIES_MASK]; + oldnum = oldstate->number; + } + } + + if( bits & U_REMOVE ) { + // the entity present in oldframe is not in the current frame + if( cl_shownet->integer > 2 ) { + Com_Printf( " remove: %i\n", newnum ); + } + if( oldnum != newnum ) { + Com_DPrintf( "U_REMOVE: oldnum != newnum\n" ); + } + if( !oldframe ) { + Com_Error( ERR_DROP, "U_REMOVE: NULL oldframe" ); + } + + oldindex++; + + if( oldindex >= oldframe->numEntities ) { + oldnum = 99999; + } else { + i = oldframe->firstEntity + oldindex; + oldstate = &cl.entityStates[i & PARSE_ENTITIES_MASK]; + oldnum = oldstate->number; + } + continue; + } + + if( oldnum == newnum ) { + // delta from previous state + if( cl_shownet->integer > 2 ) { + Com_Printf( " delta: %i ", newnum ); + } + CL_ParseDeltaEntity( frame, newnum, oldstate, bits ); + if( cl_shownet->integer > 2 ) { + Com_Printf( "\n" ); + } + + oldindex++; + + if( oldindex >= oldframe->numEntities ) { + oldnum = 99999; + } else { + i = oldframe->firstEntity + oldindex; + oldstate = &cl.entityStates[i & PARSE_ENTITIES_MASK]; + oldnum = oldstate->number; + } + continue; + } + + if( oldnum > newnum ) { + // delta from baseline + if( cl_shownet->integer > 2 ) { + Com_Printf( " baseline: %i ", newnum ); + } + CL_ParseDeltaEntity( frame, newnum, &cl.baselines[newnum], bits ); + if( cl_shownet->integer > 2 ) { + Com_Printf( "\n" ); + } + continue; + } + + } + + // any remaining entities in the old frame are copied over + while( oldnum != 99999 ) { + // one or more entities from the old packet are unchanged + if( cl_shownet->integer > 2 ) { + Com_Printf( " unchanged: %i\n", oldnum ); + } + CL_ParseDeltaEntity( frame, oldnum, oldstate, 0 ); + + oldindex++; + + if( oldindex >= oldframe->numEntities ) { + oldnum = 99999; + } else { + i = oldframe->firstEntity + oldindex; + oldstate = &cl.entityStates[i & PARSE_ENTITIES_MASK]; + oldnum = oldstate->number; + } + } } /* @@ -439,30 +425,30 @@ CL_SetActiveState */ static void CL_SetActiveState( void ) { cl.serverdelta = cl.frame.number; - cl.time = cl.servertime = 0; // set time, needed for demos - cls.state = ca_active; - cl.oldframe.valid = qfalse; + cl.time = cl.servertime = 0; // set time, needed for demos + cls.state = ca_active; + cl.oldframe.valid = qfalse; cl.frameflags = 0; cl.putaway = qfalse; if( cls.netchan ) { cl.initialSeq = cls.netchan->outgoing_sequence; } - if( !cls.demoplayback ) { + if( !cls.demo.playback ) { VectorScale( cl.frame.ps.pmove.origin, 0.125f, cl.predicted_origin ); - VectorCopy( cl.frame.ps.viewangles, cl.predicted_angles ); - } - - SCR_LagClear(); + VectorCopy( cl.frame.ps.viewangles, cl.predicted_angles ); + } + + SCR_LagClear(); #if USE_CHATHUD - SCR_ClearChatHUD_f(); + SCR_ClearChatHUD_f(); #endif - SCR_EndLoadingPlaque (); // get rid of loading plaque - Con_Close(); // close console + SCR_EndLoadingPlaque (); // get rid of loading plaque + Con_Close(); // close console EXEC_TRIGGER( cl_beginmapcmd ); - Cvar_Set( "cl_paused", "0" ); + Cvar_Set( "cl_paused", "0" ); } /* @@ -471,202 +457,202 @@ CL_ParseFrame ================ */ static void CL_ParseFrame( int extrabits ) { - uint32_t bits, extraflags; - int currentframe, deltaframe, + uint32_t bits, extraflags; + int currentframe, deltaframe, delta, surpressed; - server_frame_t frame, *oldframe; - player_state_t *from; - int length; - - memset( &frame, 0, sizeof( frame ) ); + server_frame_t frame, *oldframe; + player_state_t *from; + int length; + + memset( &frame, 0, sizeof( frame ) ); cl.frameflags = 0; surpressed = 0; - extraflags = 0; - if( cls.serverProtocol > PROTOCOL_VERSION_DEFAULT ) { - bits = MSG_ReadLong(); + extraflags = 0; + if( cls.serverProtocol > PROTOCOL_VERSION_DEFAULT ) { + bits = MSG_ReadLong(); - currentframe = bits & FRAMENUM_MASK; - delta = bits >> FRAMENUM_BITS; + currentframe = bits & FRAMENUM_MASK; + delta = bits >> FRAMENUM_BITS; - if( delta == 31 ) { - deltaframe = -1; - } else { - deltaframe = currentframe - delta; - } + if( delta == 31 ) { + deltaframe = -1; + } else { + deltaframe = currentframe - delta; + } - bits = MSG_ReadByte(); + bits = MSG_ReadByte(); - surpressed = bits & SURPRESSCOUNT_MASK; - if( cls.serverProtocol == PROTOCOL_VERSION_Q2PRO ) { + surpressed = bits & SURPRESSCOUNT_MASK; + if( cls.serverProtocol == PROTOCOL_VERSION_Q2PRO ) { cl.frameflags |= surpressed; } else if( surpressed ) { cl.frameflags |= FF_SURPRESSED; } - extraflags = ( extrabits << 4 ) | ( bits >> SURPRESSCOUNT_BITS ); - } else { - currentframe = MSG_ReadLong(); - deltaframe = MSG_ReadLong(); - - // BIG HACK to let old demos continue to work - if( cls.serverProtocol != PROTOCOL_VERSION_OLD ) { - surpressed = MSG_ReadByte(); + extraflags = ( extrabits << 4 ) | ( bits >> SURPRESSCOUNT_BITS ); + } else { + currentframe = MSG_ReadLong(); + deltaframe = MSG_ReadLong(); + + // BIG HACK to let old demos continue to work + if( cls.serverProtocol != PROTOCOL_VERSION_OLD ) { + surpressed = MSG_ReadByte(); if( surpressed ) { cl.frameflags |= FF_SURPRESSED; } - } - } + } + } - frame.number = currentframe; - frame.delta = deltaframe; + frame.number = currentframe; + frame.delta = deltaframe; if( cls.netchan && cls.netchan->dropped ) { cl.frameflags |= FF_SERVERDROP; } - /* If the frame is delta compressed from data that we - * no longer have available, we must suck up the rest of - * the frame, but not use it, then ask for a non-compressed - * message */ - if( deltaframe > 0 ) { - oldframe = &cl.frames[deltaframe & UPDATE_MASK]; - from = &oldframe->ps; - if( deltaframe == currentframe ) { + /* If the frame is delta compressed from data that we + * no longer have available, we must suck up the rest of + * the frame, but not use it, then ask for a non-compressed + * message */ + if( deltaframe > 0 ) { + oldframe = &cl.frames[deltaframe & UPDATE_MASK]; + from = &oldframe->ps; + if( deltaframe == currentframe ) { // old buggy q2 servers still cause this on map change - Com_DPrintf( "%s: delta from current frame\n", __func__ ); + Com_DPrintf( "%s: delta from current frame\n", __func__ ); cl.frameflags |= FF_BADFRAME; - } else if( oldframe->number != deltaframe ) { - // The frame that the server did the delta from - // is too old, so we can't reconstruct it properly. - Com_DPrintf( "%s: delta frame was never received or too old\n", __func__ ); + } else if( oldframe->number != deltaframe ) { + // The frame that the server did the delta from + // is too old, so we can't reconstruct it properly. + Com_DPrintf( "%s: delta frame was never received or too old\n", __func__ ); cl.frameflags |= FF_OLDFRAME; - } else if( !oldframe->valid ) { - // should never happen - Com_DPrintf( "%s: delta from invalid frame\n", __func__ ); + } else if( !oldframe->valid ) { + // should never happen + Com_DPrintf( "%s: delta from invalid frame\n", __func__ ); cl.frameflags |= FF_BADFRAME; - } else if( cl.numEntityStates - oldframe->firstEntity > - MAX_PARSE_ENTITIES - MAX_PACKET_ENTITIES ) - { - Com_DPrintf( "%s: delta entities too old\n", __func__ ); + } else if( cl.numEntityStates - oldframe->firstEntity > + MAX_PARSE_ENTITIES - MAX_PACKET_ENTITIES ) + { + Com_DPrintf( "%s: delta entities too old\n", __func__ ); cl.frameflags |= FF_OLDENT; - } else { - frame.valid = qtrue; // valid delta parse - } - if( !frame.valid && cl.frame.valid && cls.demoplayback ) { + } else { + frame.valid = qtrue; // valid delta parse + } + if( !frame.valid && cl.frame.valid && cls.demo.playback ) { Com_DPrintf( "%s: recovering broken demo\n", __func__ ); oldframe = &cl.frame; from = &oldframe->ps; frame.valid = qtrue; } - } else { - oldframe = NULL; - from = NULL; - frame.valid = qtrue; // uncompressed frame + } else { + oldframe = NULL; + from = NULL; + frame.valid = qtrue; // uncompressed frame //if( !cls.demowaiting ) { cl.frameflags |= FF_NODELTA; //} - //cls.demowaiting = qfalse; // we can start recording now - } - - // read areabits - length = MSG_ReadByte(); - if( length ) { - if( length < 0 || msg_read.readcount + length > msg_read.cursize ) { - Com_Error( ERR_DROP, "%s: read past end of message", __func__ ); - } - if( length > sizeof( frame.areabits ) ) { - Com_Error( ERR_DROP, "%s: invalid areabits length", __func__ ); - } - MSG_ReadData( frame.areabits, length ); - frame.areabytes = length; - } else { - frame.areabytes = 0; - } - - if( cls.serverProtocol <= PROTOCOL_VERSION_DEFAULT ) { - if( MSG_ReadByte() != svc_playerinfo ) { - Com_Error( ERR_DROP, "%s: not playerinfo", __func__ ); - } - } - - if( cl_shownet->integer > 2 ) { - Com_Printf( "%3"PRIz":playerinfo\n", msg_read.readcount - 1 ); - } - - // parse playerstate - bits = MSG_ReadShort(); - if( cls.serverProtocol > PROTOCOL_VERSION_DEFAULT ) { - MSG_ParseDeltaPlayerstate_Enhanced( from, &frame.ps, bits, extraflags ); - if( cl_shownet->integer > 2 ) { - MSG_ShowDeltaPlayerstateBits_Enhanced( bits ); - Com_Printf( "\n" ); - } - if( cls.serverProtocol == PROTOCOL_VERSION_Q2PRO ) { + //cls.demowaiting = qfalse; // we can start recording now + } + + // read areabits + length = MSG_ReadByte(); + if( length ) { + if( length < 0 || msg_read.readcount + length > msg_read.cursize ) { + Com_Error( ERR_DROP, "%s: read past end of message", __func__ ); + } + if( length > sizeof( frame.areabits ) ) { + Com_Error( ERR_DROP, "%s: invalid areabits length", __func__ ); + } + MSG_ReadData( frame.areabits, length ); + frame.areabytes = length; + } else { + frame.areabytes = 0; + } + + if( cls.serverProtocol <= PROTOCOL_VERSION_DEFAULT ) { + if( MSG_ReadByte() != svc_playerinfo ) { + Com_Error( ERR_DROP, "%s: not playerinfo", __func__ ); + } + } + + if( cl_shownet->integer > 2 ) { + Com_Printf( "%3"PRIz":playerinfo\n", msg_read.readcount - 1 ); + } + + // parse playerstate + bits = MSG_ReadShort(); + if( cls.serverProtocol > PROTOCOL_VERSION_DEFAULT ) { + MSG_ParseDeltaPlayerstate_Enhanced( from, &frame.ps, bits, extraflags ); + if( cl_shownet->integer > 2 ) { + MSG_ShowDeltaPlayerstateBits_Enhanced( bits ); + Com_Printf( "\n" ); + } + if( cls.serverProtocol == PROTOCOL_VERSION_Q2PRO ) { // parse clientNum - if( extraflags & EPS_CLIENTNUM ) { - frame.clientNum = MSG_ReadByte(); - } else if( oldframe ) { + if( extraflags & EPS_CLIENTNUM ) { + frame.clientNum = MSG_ReadByte(); + } else if( oldframe ) { frame.clientNum = oldframe->clientNum; } } else { - frame.clientNum = cl.clientNum; + frame.clientNum = cl.clientNum; } - } else { - MSG_ParseDeltaPlayerstate_Default( from, &frame.ps, bits ); - if( cl_shownet->integer > 2 ) { - MSG_ShowDeltaPlayerstateBits_Default( bits ); - Com_Printf( "\n" ); - } - frame.clientNum = cl.clientNum; - } - if( !frame.ps.fov ) { + } else { + MSG_ParseDeltaPlayerstate_Default( from, &frame.ps, bits ); + if( cl_shownet->integer > 2 ) { + MSG_ShowDeltaPlayerstateBits_Default( bits ); + Com_Printf( "\n" ); + } + frame.clientNum = cl.clientNum; + } + if( !frame.ps.fov ) { // fail out early to prevent spurious errors later Com_Error( ERR_DROP, "%s: bad fov", __func__ ); } - // parse packetentities - if( cls.serverProtocol <= PROTOCOL_VERSION_DEFAULT ) { - if( MSG_ReadByte() != svc_packetentities ) { - Com_Error( ERR_DROP, "%s: not packetentities", __func__ ); - } - } + // parse packetentities + if( cls.serverProtocol <= PROTOCOL_VERSION_DEFAULT ) { + if( MSG_ReadByte() != svc_packetentities ) { + Com_Error( ERR_DROP, "%s: not packetentities", __func__ ); + } + } - if( cl_shownet->integer > 2 ) { - Com_Printf( "%3"PRIz":packetentities\n", msg_read.readcount - 1 ); - } + if( cl_shownet->integer > 2 ) { + Com_Printf( "%3"PRIz":packetentities\n", msg_read.readcount - 1 ); + } - CL_ParsePacketEntities( oldframe, &frame ); + CL_ParsePacketEntities( oldframe, &frame ); - // save the frame off in the backup array for later delta comparisons - cl.frames[currentframe & UPDATE_MASK] = frame; + // save the frame off in the backup array for later delta comparisons + cl.frames[currentframe & UPDATE_MASK] = frame; - if( cl_shownet->integer > 2 ) { + if( cl_shownet->integer > 2 ) { int rtt = 0; - if( cls.netchan ) { + if( cls.netchan ) { int seq = cls.netchan->incoming_acknowledged & CMD_MASK; - rtt = cls.realtime - cl.history[seq].sent; - } - Com_Printf( "%3"PRIz":frame:%d delta:%d rtt:%d\n", - msg_read.readcount - 1, frame.number, frame.delta, rtt ); - } + rtt = cls.realtime - cl.history[seq].sent; + } + Com_Printf( "%3"PRIz":frame:%d delta:%d rtt:%d\n", + msg_read.readcount - 1, frame.number, frame.delta, rtt ); + } - if( !frame.valid ) { - cl.frame.valid = qfalse; - return; // do not change anything - } + if( !frame.valid ) { + cl.frame.valid = qfalse; + return; // do not change anything + } - cl.oldframe = cl.frame; - cl.frame = frame; + cl.oldframe = cl.frame; + cl.frame = frame; - // getting a valid frame message ends the connection process - if( cls.state == ca_precached ) { - CL_SetActiveState(); - } + // getting a valid frame message ends the connection process + if( cls.state == ca_precached ) { + CL_SetActiveState(); + } - CL_DeltaFrame(); + CL_DeltaFrame(); - CL_CheckPredictionError(); + CL_CheckPredictionError(); } @@ -679,7 +665,7 @@ static void CL_ParseFrame( int extrabits ) { */ static void CL_ConfigString( int index, const char *string, size_t length ) { - size_t maxlength; + size_t maxlength; if( index >= CS_STATUSBAR && index < CS_AIRACCEL ) { maxlength = MAX_QPATH * ( CS_AIRACCEL - index ); @@ -687,15 +673,15 @@ static void CL_ConfigString( int index, const char *string, size_t length ) { maxlength = MAX_QPATH; } if( length >= maxlength ) { - Com_Error( ERR_DROP, "%s: index %d overflowed", __func__, index ); + Com_Error( ERR_DROP, "%s: index %d overflowed", __func__, index ); } - memcpy( cl.configstrings[index], string, length + 1 ); + memcpy( cl.configstrings[index], string, length + 1 ); - // do something apropriate + // do something apropriate - if( index == CS_MAXCLIENTS ) { - cl.maxclients = atoi( string ); + if( index == CS_MAXCLIENTS ) { + cl.maxclients = atoi( string ); return; } if( index == CS_MODELS + 1 ) { @@ -706,34 +692,34 @@ static void CL_ConfigString( int index, const char *string, size_t length ) { cl.mapname[length - 9] = 0; // cut off ".bsp" return; } - if (index >= CS_LIGHTS && index < CS_LIGHTS+MAX_LIGHTSTYLES) { - CL_SetLightstyle( index - CS_LIGHTS, string, length ); + if (index >= CS_LIGHTS && index < CS_LIGHTS+MAX_LIGHTSTYLES) { + CL_SetLightstyle( index - CS_LIGHTS, string, length ); return; } - if( cls.state < ca_precached ) { + if( cls.state < ca_precached ) { return; } - if (index >= CS_MODELS && index < CS_MODELS+MAX_MODELS) { + if (index >= CS_MODELS && index < CS_MODELS+MAX_MODELS) { cl.model_draw[index-CS_MODELS] = ref.RegisterModel (string); if (*string == '*') cl.model_clip[index-CS_MODELS] = CM_InlineModel (&cl.cm, string); else cl.model_clip[index-CS_MODELS] = 0; - } else if (index >= CS_SOUNDS && index < CS_SOUNDS+MAX_MODELS) { - cl.sound_precache[index-CS_SOUNDS] = S_RegisterSound (string); - } else if (index >= CS_IMAGES && index < CS_IMAGES+MAX_MODELS) { - cl.image_precache[index-CS_IMAGES] = ref.RegisterPic (string); - } else if (index >= CS_PLAYERSKINS && index < CS_PLAYERSKINS+MAX_CLIENTS) { + } else if (index >= CS_SOUNDS && index < CS_SOUNDS+MAX_MODELS) { + cl.sound_precache[index-CS_SOUNDS] = S_RegisterSound (string); + } else if (index >= CS_IMAGES && index < CS_IMAGES+MAX_MODELS) { + cl.image_precache[index-CS_IMAGES] = ref.RegisterPic (string); + } else if (index >= CS_PLAYERSKINS && index < CS_PLAYERSKINS+MAX_CLIENTS) { CL_LoadClientinfo( &cl.clientinfo[index - CS_PLAYERSKINS], string ); - } else if( index == CS_AIRACCEL && !cl.pmp.qwmod ) { - cl.pmp.airaccelerate = atoi( string ) ? qtrue : qfalse; - } + } else if( index == CS_AIRACCEL && !cl.pmp.qwmod ) { + cl.pmp.airaccelerate = atoi( string ) ? qtrue : qfalse; + } } static void CL_ParseGamestate( void ) { - int index, bits; + int index, bits; char *string; size_t length; @@ -771,26 +757,26 @@ CL_ParseServerData ================== */ static void CL_ParseServerData( void ) { - char *str; - int i, protocol, attractloop; + char *str; + int i, protocol, attractloop; - Cbuf_Execute(); // make sure any stuffed commands are done - + Cbuf_Execute(); // make sure any stuffed commands are done + // wipe the client_state_t struct - CL_ClearState(); + CL_ClearState(); // parse protocol version number - protocol = MSG_ReadLong(); - cl.servercount = MSG_ReadLong(); - attractloop = MSG_ReadByte(); + protocol = MSG_ReadLong(); + cl.servercount = MSG_ReadLong(); + attractloop = MSG_ReadByte(); - Com_DPrintf( "Serverdata packet received (protocol=%d, servercount=%d, attractloop=%d)\n", - protocol, cl.servercount, attractloop ); + Com_DPrintf( "Serverdata packet received (protocol=%d, servercount=%d, attractloop=%d)\n", + protocol, cl.servercount, attractloop ); // check protocol - if( cls.serverProtocol != protocol ) { - if( !cls.demoplayback ) { - Com_Error( ERR_DROP, "Requested protocol version %d, but server returned %d.", + if( cls.serverProtocol != protocol ) { + if( !cls.demo.playback ) { + Com_Error( ERR_DROP, "Requested protocol version %d, but server returned %d.", cls.serverProtocol, protocol ); } @@ -800,38 +786,38 @@ static void CL_ParseServerData( void ) { } else if( protocol < PROTOCOL_VERSION_DEFAULT || protocol > PROTOCOL_VERSION_Q2PRO ) { Com_Error( ERR_DROP, "Demo uses unsupported protocol version %d.", protocol ); } - cls.serverProtocol = protocol; - } - - // game directory - str = MSG_ReadString(); - Q_strncpyz( cl.gamedir, str, sizeof( cl.gamedir ) ); + cls.serverProtocol = protocol; + } - // never allow demos to change gamedir - // do not set gamedir if connected to local sever, - // since it was already done by SV_InitGame - if( !cls.demoplayback && !sv_running->integer ) { - Cvar_UserSet( "game", cl.gamedir ); - if( FS_NeedRestart() ) { - CL_RestartFilesystem(); - } - } + // game directory + str = MSG_ReadString(); + Q_strncpyz( cl.gamedir, str, sizeof( cl.gamedir ) ); + + // never allow demos to change gamedir + // do not set gamedir if connected to local sever, + // since it was already done by SV_InitGame + if( !cls.demo.playback && !sv_running->integer ) { + Cvar_UserSet( "game", cl.gamedir ); + if( FS_NeedRestart() ) { + CL_RestartFilesystem(); + } + } - // parse player entity number - cl.clientNum = MSG_ReadShort(); + // parse player entity number + cl.clientNum = MSG_ReadShort(); - // get the full level name - str = MSG_ReadString(); + // get the full level name + str = MSG_ReadString(); // setup default pmove parameters - cl.pmp.speedMultiplier = 1; - cl.pmp.maxspeed = 300; -// cl.pmp.upspeed = 350; - cl.pmp.friction = 6; - cl.pmp.waterfriction = 1; + cl.pmp.speedMultiplier = 1; + cl.pmp.maxspeed = 300; +// cl.pmp.upspeed = 350; + cl.pmp.friction = 6; + cl.pmp.waterfriction = 1; cl.pmp.flyfriction = 9; - cl.pmp.airaccelerate = 0; - cl.gametype = GT_DEATHMATCH; + cl.pmp.airaccelerate = 0; + cl.gametype = GT_DEATHMATCH; #ifdef PMOVE_HACK cl.pmp.highprec = qtrue; #endif @@ -840,61 +826,61 @@ static void CL_ParseServerData( void ) { cl.frametime = 100; cl.framefrac = 0.01f; - if( cls.serverProtocol == PROTOCOL_VERSION_R1Q2 ) { - i = MSG_ReadByte(); - if( i ) { - Com_Error( ERR_DROP, "'Enhanced' R1Q2 servers are not supported" ); - } - i = MSG_ReadShort(); - if( !R1Q2_SUPPORTED( i ) ) { - Com_Error( ERR_DROP, "Unsupported R1Q2 protocol version %d.\n" + if( cls.serverProtocol == PROTOCOL_VERSION_R1Q2 ) { + i = MSG_ReadByte(); + if( i ) { + Com_Error( ERR_DROP, "'Enhanced' R1Q2 servers are not supported" ); + } + i = MSG_ReadShort(); + if( !R1Q2_SUPPORTED( i ) ) { + Com_Error( ERR_DROP, "Unsupported R1Q2 protocol version %d.\n" "Current client version is %d.", i, PROTOCOL_VERSION_R1Q2_CURRENT ); - } + } cls.protocolVersion = i; - i = MSG_ReadByte(); - if( i ) { // seems to be no longer used - Com_DPrintf( "R1Q2 advancedDeltas enabled\n" ); - } - cl.pmp.strafeHack = MSG_ReadByte(); - if( cl.pmp.strafeHack ) { - Com_DPrintf( "R1Q2 strafeHack enabled\n" ); - } - cl.pmp.speedMultiplier = 2; - } else if( cls.serverProtocol == PROTOCOL_VERSION_Q2PRO ) { - i = MSG_ReadShort(); - if( !Q2PRO_SUPPORTED( i ) ) { - Com_Error( ERR_DROP, "Unsupported Q2PRO protocol version %d.\n" + i = MSG_ReadByte(); + if( i ) { // seems to be no longer used + Com_DPrintf( "R1Q2 advancedDeltas enabled\n" ); + } + cl.pmp.strafeHack = MSG_ReadByte(); + if( cl.pmp.strafeHack ) { + Com_DPrintf( "R1Q2 strafeHack enabled\n" ); + } + cl.pmp.speedMultiplier = 2; + } else if( cls.serverProtocol == PROTOCOL_VERSION_Q2PRO ) { + i = MSG_ReadShort(); + if( !Q2PRO_SUPPORTED( i ) ) { + Com_Error( ERR_DROP, "Unsupported Q2PRO protocol version %d.\n" "Current client version is %d.", i, PROTOCOL_VERSION_Q2PRO_CURRENT ); - } + } cls.protocolVersion = i; - cl.gametype = MSG_ReadByte(); - cl.pmp.strafeHack = MSG_ReadByte(); - cl.pmp.qwmod = MSG_ReadByte(); //atu QWMod - cl.pmp.speedMultiplier = 2; + cl.gametype = MSG_ReadByte(); + cl.pmp.strafeHack = MSG_ReadByte(); + cl.pmp.qwmod = MSG_ReadByte(); //atu QWMod + cl.pmp.speedMultiplier = 2; cl.pmp.flyfix = qtrue; cl.pmp.flyfriction = 4; - if( cl.pmp.strafeHack ) { - Com_DPrintf( "Q2PRO strafeHack enabled\n" ); - } - if( cl.pmp.qwmod ) { - Com_DPrintf( "Q2PRO QWMod enabled\n" ); - - cl.pmp.maxspeed = 320; - //cl.pmp.upspeed = ((cl.pmp.qwmod == 2) ? 310 : 350); - cl.pmp.friction = 4; - cl.pmp.waterfriction = 4; - cl.pmp.airaccelerate = qtrue; - } - } - - if( cl.clientNum == -1 ) { - // tell the server to advance to the next map / cinematic - CL_ClientCommand( va( "nextserver %i\n", cl.servercount ) ); - } else { - // seperate the printfs so the server message can have a color - Con_Printf( "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n" ); - Con_Printf( S_COLOR_ALT "%s\n\n", str ); + if( cl.pmp.strafeHack ) { + Com_DPrintf( "Q2PRO strafeHack enabled\n" ); + } + if( cl.pmp.qwmod ) { + Com_DPrintf( "Q2PRO QWMod enabled\n" ); + + cl.pmp.maxspeed = 320; + //cl.pmp.upspeed = ((cl.pmp.qwmod == 2) ? 310 : 350); + cl.pmp.friction = 4; + cl.pmp.waterfriction = 4; + cl.pmp.airaccelerate = qtrue; + } + } + + if( cl.clientNum == -1 ) { + // tell the server to advance to the next map / cinematic + CL_ClientCommand( va( "nextserver %i\n", cl.servercount ) ); + } else { + // seperate the printfs so the server message can have a color + Con_Printf( "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n" ); + Con_Printf( S_COLOR_ALT "%s\n\n", str ); Sys_Printf( "\n\n%s\n", str ); @@ -902,7 +888,7 @@ static void CL_ParseServerData( void ) { if( cl.clientNum < 0 || cl.clientNum >= MAX_CLIENTS ) { cl.clientNum = CLIENTNUM_NONE; } - } + } } @@ -912,14 +898,14 @@ CL_ParseBaseline ================== */ static void CL_ParseBaseline( void ) { - int bits; - int newnum; - - newnum = MSG_ParseEntityBits( &bits ); - if( newnum < 1 || newnum >= MAX_EDICTS ) { - Com_Error( ERR_DROP, "CL_ParseBaseline: bad entity number %i", newnum ); - } - MSG_ParseDeltaEntity( NULL, &cl.baselines[newnum], newnum, bits ); + int bits; + int newnum; + + newnum = MSG_ParseEntityBits( &bits ); + if( newnum < 1 || newnum >= MAX_EDICTS ) { + Com_Error( ERR_DROP, "CL_ParseBaseline: bad entity number %i", newnum ); + } + MSG_ParseDeltaEntity( NULL, &cl.baselines[newnum], newnum, bits ); } /* @@ -929,22 +915,22 @@ CL_LoadClientinfo ================ */ void CL_LoadClientinfo( clientinfo_t *ci, const char *s ) { - int i; - char *t; - char model_name[MAX_QPATH]; - char skin_name[MAX_QPATH]; - char model_filename[MAX_QPATH]; - char skin_filename[MAX_QPATH]; - char weapon_filename[MAX_QPATH]; - char icon_filename[MAX_QPATH]; - - // isolate the player's name - strcpy( ci->name, s ); - t = strchr( s, '\\' ); - if( t ) { - ci->name[ t - s ] = 0; - s = t + 1; - } + int i; + char *t; + char model_name[MAX_QPATH]; + char skin_name[MAX_QPATH]; + char model_filename[MAX_QPATH]; + char skin_filename[MAX_QPATH]; + char weapon_filename[MAX_QPATH]; + char icon_filename[MAX_QPATH]; + + // isolate the player's name + strcpy( ci->name, s ); + t = strchr( s, '\\' ); + if( t ) { + ci->name[ t - s ] = 0; + s = t + 1; + } strcpy( model_name, s ); @@ -1040,15 +1026,15 @@ void CL_LoadClientinfo( clientinfo_t *ci, const char *s ) { strcpy( ci->model_name, model_name ); strcpy( ci->skin_name, skin_name ); - // must have loaded all data types to be valid - if( !ci->skin || !ci->icon || !ci->model || !ci->weaponmodel[0] ) { - ci->skin = 0; - ci->icon = 0; - ci->model = 0; - ci->weaponmodel[0] = 0; + // must have loaded all data types to be valid + if( !ci->skin || !ci->icon || !ci->model || !ci->weaponmodel[0] ) { + ci->skin = 0; + ci->icon = 0; + ci->model = 0; + ci->weaponmodel[0] = 0; ci->model_name[0] = 0; ci->skin_name[0] = 0; - } + } } @@ -1058,21 +1044,21 @@ CL_ParseConfigString ================ */ static void CL_ParseConfigString (void) { - int i; - char *s; + int i; + char *s; size_t length; - i = MSG_ReadShort (); - if (i < 0 || i >= MAX_CONFIGSTRINGS) - Com_Error( ERR_DROP, "%s: bad index: %d", __func__, i ); + i = MSG_ReadShort (); + if (i < 0 || i >= MAX_CONFIGSTRINGS) + Com_Error( ERR_DROP, "%s: bad index: %d", __func__, i ); - s = MSG_ReadStringLength( &length ); + s = MSG_ReadStringLength( &length ); - if( cl_shownet->integer > 2 ) { - Com_Printf( " %i \"%s\"\n", i, Q_FormatString( s ) ); - } + if( cl_shownet->integer > 2 ) { + Com_Printf( " %i \"%s\"\n", i, Q_FormatString( s ) ); + } - if( cls.demorecording && cls.demopaused ) { + if( cls.demo.recording && cls.demo.paused ) { Q_SetBit( cl.dcs, i ); } @@ -1095,73 +1081,73 @@ CL_ParseStartSoundPacket */ static void CL_ParseStartSoundPacket( void ) { vec3_t pos_v; - float *pos; - int channel, ent; - int sound_num; - float volume; - float attenuation; - int flags; - float ofs; - - flags = MSG_ReadByte(); - sound_num = MSG_ReadByte(); - if( sound_num == -1 ) { - Com_Error( ERR_DROP, "%s: read past end of message", __func__ ); - } + float *pos; + int channel, ent; + int sound_num; + float volume; + float attenuation; + int flags; + float ofs; + + flags = MSG_ReadByte(); + sound_num = MSG_ReadByte(); + if( sound_num == -1 ) { + Com_Error( ERR_DROP, "%s: read past end of message", __func__ ); + } if( flags & SND_VOLUME ) - volume = MSG_ReadByte() / 255.0; - else - volume = DEFAULT_SOUND_PACKET_VOLUME; - + volume = MSG_ReadByte() / 255.0; + else + volume = DEFAULT_SOUND_PACKET_VOLUME; + if( flags & SND_ATTENUATION ) - attenuation = MSG_ReadByte() / 64.0; - else - attenuation = DEFAULT_SOUND_PACKET_ATTENUATION; + attenuation = MSG_ReadByte() / 64.0; + else + attenuation = DEFAULT_SOUND_PACKET_ATTENUATION; if( flags & SND_OFFSET ) - ofs = MSG_ReadByte() / 1000.0; - else - ofs = 0; - - if( flags & SND_ENT ) { - // entity relative - channel = MSG_ReadShort(); - ent = channel >> 3; - if( ent < 0 || ent >= MAX_EDICTS ) - Com_Error( ERR_DROP, "%s: bad ent: %d", __func__, ent ); - channel &= 7; - } else { - ent = 0; - channel = 0; - } - - if( flags & SND_POS ) { - // positioned in space - MSG_ReadPos( pos_v ); - pos = pos_v; - } else { - if( !( flags & SND_ENT ) ) { - Com_Error( ERR_DROP, "%s: neither SND_ENT nor SND_POS set", __func__ ); - } + ofs = MSG_ReadByte() / 1000.0; + else + ofs = 0; + + if( flags & SND_ENT ) { + // entity relative + channel = MSG_ReadShort(); + ent = channel >> 3; + if( ent < 0 || ent >= MAX_EDICTS ) + Com_Error( ERR_DROP, "%s: bad ent: %d", __func__, ent ); + channel &= 7; + } else { + ent = 0; + channel = 0; + } + + if( flags & SND_POS ) { + // positioned in space + MSG_ReadPos( pos_v ); + pos = pos_v; + } else { + if( !( flags & SND_ENT ) ) { + Com_Error( ERR_DROP, "%s: neither SND_ENT nor SND_POS set", __func__ ); + } if( cl_entities[ent].serverframe != cl.frame.number ) { if( cl_entities[ent].serverframe ) { - Com_DPrintf( "BUG: sound on entity %d last seen %d frames ago\n", + Com_DPrintf( "SERVER BUG: sound on entity %d last seen %d frames ago\n", ent, cl.frame.number - cl_entities[ent].serverframe ); } else { - Com_DPrintf( "BUG: sound on entity %d we have never seen\n", ent ); + Com_DPrintf( "SERVER BUG: sound on entity %d we have never seen\n", ent ); } } - // use entity number - pos = NULL; - } + // use entity number + pos = NULL; + } - if( cl_shownet->integer > 2 ) { - Com_Printf( " %s\n", cl.configstrings[CS_SOUNDS+sound_num] ); - } + if( cl_shownet->integer > 2 ) { + Com_Printf( " %s\n", cl.configstrings[CS_SOUNDS+sound_num] ); + } - if( cl.sound_precache[sound_num] ) { - S_StartSound( pos, ent, channel, cl.sound_precache[sound_num], + if( cl.sound_precache[sound_num] ) { + S_StartSound( pos, ent, channel, cl.sound_precache[sound_num], volume, attenuation, ofs ); } } @@ -1172,30 +1158,28 @@ CL_ParseReconnect ===================== */ static void CL_ParseReconnect( void ) { - if( cls.demoplayback ) { - return; - } + if( cls.demo.playback ) { + return; + } S_StopAllSounds(); - if ( cls.demorecording ) + if( cls.demo.recording ) CL_Stop_f(); - Com_Printf( "Server disconnected, reconnecting\n" ); - if( cls.download ) { - FS_FCloseFile( cls.download ); - cls.download = 0; - } + Com_Printf( "Server disconnected, reconnecting\n" ); - EXEC_TRIGGER( cl_changemapcmd ); + if( cls.download.file ) { + FS_FCloseFile( cls.download.file ); + } + memset( &cls.download, 0, sizeof( cls.download ) ); - cls.downloadtempname[0] = 0; - cls.downloadname[0] = 0; + EXEC_TRIGGER( cl_changemapcmd ); - CL_ClearState(); - cls.state = ca_challenging; + CL_ClearState(); + cls.state = ca_challenging; cls.connect_time = cls.realtime - CONNECT_DELAY; - cls.connect_count = 0; + cls.connect_count = 0; } #if USE_AUTOREPLY @@ -1207,10 +1191,6 @@ CL_CheckForVersion static void CL_CheckForVersion( const char *string ) { char *p; - if( cls.demoplayback ) { - return; - } - p = strstr( string, ": " ); if( !p ) { return; @@ -1236,29 +1216,31 @@ CL_ParsePrint ===================== */ static void CL_ParsePrint( void ) { - int level; - char *string; + int level; + char *string; - level = MSG_ReadByte(); - string = MSG_ReadString(); + level = MSG_ReadByte(); + string = MSG_ReadString(); - if( cl_shownet->integer > 2 ) { - Com_Printf( " %i \"%s\"\n", level, Q_FormatString( string ) ); - } + if( cl_shownet->integer > 2 ) { + Com_Printf( " %i \"%s\"\n", level, Q_FormatString( string ) ); + } - if( level != PRINT_CHAT ) { - Com_Printf( "%s", string ); - return; - } + if( level != PRINT_CHAT ) { + Com_Printf( "%s", string ); + return; + } #if USE_AUTOREPLY - CL_CheckForVersion( string ); + if( !cls.demo.playback ) { + CL_CheckForVersion( string ); + } #endif - // disable notify - if( !cl_chat_notify->integer ) { - Con_SkipNotify( qtrue ); - } + // disable notify + if( !cl_chat_notify->integer ) { + Con_SkipNotify( qtrue ); + } // filter text if( cl_chat_filter->integer ) { @@ -1266,19 +1248,19 @@ static void CL_ParsePrint( void ) { string[len] = '\n'; } - Com_Printf( S_COLOR_ALT "%s", string ); + Com_Printf( S_COLOR_ALT "%s", string ); - Con_SkipNotify( qfalse ); + Con_SkipNotify( qfalse ); #if USE_CHATHUD - SCR_AddToChatHUD( string ); + SCR_AddToChatHUD( string ); #endif // play sound - if( cl_chat_sound->string[0] ) { - S_StartLocalSound_( cl_chat_sound->string ); - } - + if( cl_chat_sound->string[0] ) { + S_StartLocalSound_( cl_chat_sound->string ); + } + } /* @@ -1287,13 +1269,13 @@ CL_ParseCenterPrint ===================== */ static void CL_ParseCenterPrint( void ) { - char *s; + char *s; - s = MSG_ReadString(); + s = MSG_ReadString(); - if( cl_shownet->integer > 2 ) { - Com_Printf( " \"%s\"\n", Q_FormatString( s ) ); - } + if( cl_shownet->integer > 2 ) { + Com_Printf( " \"%s\"\n", Q_FormatString( s ) ); + } SCR_CenterPrint( s ); } @@ -1304,29 +1286,29 @@ CL_ParseStuffText ===================== */ static void CL_ParseStuffText( void ) { - char *s, *p; + char *s, *p; - s = MSG_ReadString(); + s = MSG_ReadString(); - //if( cl_shownet->integer > 2 ) { - // Com_Printf( " \"%s\"\n", Q_FormatString( s ) ); - //} + //if( cl_shownet->integer > 2 ) { + // Com_Printf( " \"%s\"\n", Q_FormatString( s ) ); + //} // FIXME: this is uuugly... - if( cls.demoplayback && + if( cls.demo.playback && strcmp( s, "precache\n" ) && strcmp( s, "changing\n" ) && ( strncmp( s, "play ", 5 ) || !( p = strchr( s, '\n' ) ) || p[1] || strchr( s, ';' ) || strchr( s, '$' ) ) && strcmp( s, "reconnect\n" ) ) { - Com_DPrintf( "ignored stufftext: %s\n", s ); - return; - } + Com_DPrintf( "ignored stufftext: %s\n", s ); + return; + } - Com_DPrintf( "stufftext: %s\n", Q_FormatString( s ) ); + Com_DPrintf( "stufftext: %s\n", Q_FormatString( s ) ); - Cbuf_AddText( s ); + Cbuf_AddText( s ); } /* @@ -1335,15 +1317,15 @@ CL_ParseLayout ===================== */ static void CL_ParseLayout( void ) { - char *s; + char *s; - s = MSG_ReadString(); + s = MSG_ReadString(); - if( cl_shownet->integer > 2 ) { - Com_Printf( " \"%s\"\n", Q_FormatString( s ) ); - } + if( cl_shownet->integer > 2 ) { + Com_Printf( " \"%s\"\n", Q_FormatString( s ) ); + } - Q_strncpyz( cl.layout, s, sizeof( cl.layout ) ); + Q_strncpyz( cl.layout, s, sizeof( cl.layout ) ); cl.putaway = qfalse; } @@ -1353,32 +1335,32 @@ CL_ParseInventory ================ */ static void CL_ParseInventory( void ) { - int i; + int i; - for( i = 0; i < MAX_ITEMS; i++ ) { - cl.inventory[i] = MSG_ReadShort(); - } + for( i = 0; i < MAX_ITEMS; i++ ) { + cl.inventory[i] = MSG_ReadShort(); + } cl.putaway = qfalse; } static void CL_ParseZPacket( void ) { #if USE_ZLIB - sizebuf_t temp; - byte buffer[MAX_MSGLEN]; - unsigned inlen, outlen; + sizebuf_t temp; + byte buffer[MAX_MSGLEN]; + unsigned inlen, outlen; - if( msg_read.data != msg_read_buffer ) { - Com_Error( ERR_DROP, "%s: recursively entered", __func__ ); - } + if( msg_read.data != msg_read_buffer ) { + Com_Error( ERR_DROP, "%s: recursively entered", __func__ ); + } - inlen = MSG_ReadShort(); + inlen = MSG_ReadShort(); if( msg_read.readcount + inlen > msg_read.cursize ) { - Com_Error( ERR_DROP, "%s: read past end of message", __func__ ); + Com_Error( ERR_DROP, "%s: read past end of message", __func__ ); } - outlen = MSG_ReadShort(); + outlen = MSG_ReadShort(); if( outlen > MAX_MSGLEN ) { - Com_Error( ERR_DROP, "%s: invalid output length", __func__ ); + Com_Error( ERR_DROP, "%s: invalid output length", __func__ ); } inflateReset( &cls.z ); @@ -1387,30 +1369,30 @@ static void CL_ParseZPacket( void ) { cls.z.avail_in = inlen; cls.z.next_out = buffer; cls.z.avail_out = outlen; - if( inflate( &cls.z, Z_FINISH ) != Z_STREAM_END ) { - Com_Error( ERR_DROP, "%s: inflate() failed: %s", __func__, cls.z.msg ); + if( inflate( &cls.z, Z_FINISH ) != Z_STREAM_END ) { + Com_Error( ERR_DROP, "%s: inflate() failed: %s", __func__, cls.z.msg ); } - msg_read.readcount += inlen; + msg_read.readcount += inlen; - temp = msg_read; + temp = msg_read; SZ_Init( &msg_read, buffer, outlen ); msg_read.cursize = outlen; CL_ParseServerMessage(); - msg_read = temp; + msg_read = temp; #else - Com_Error( ERR_DROP, "Compressed server packet received, " + Com_Error( ERR_DROP, "Compressed server packet received, " "but no zlib support linked in." ); #endif } static void CL_ParseSetting( void ) { - uint32_t index, value; + uint32_t index, value; - index = MSG_ReadLong(); - value = MSG_ReadLong(); + index = MSG_ReadLong(); + value = MSG_ReadLong(); switch( index ) { case SVS_FPS: @@ -1431,147 +1413,147 @@ CL_ParseServerMessage ===================== */ void CL_ParseServerMessage( void ) { - int cmd, extrabits; - size_t readcount; + int cmd, extrabits; + size_t readcount; - if( cl_shownet->integer == 1 ) { - Com_Printf( "%"PRIz" ", msg_read.cursize ); - } else if( cl_shownet->integer > 1 ) { - Com_Printf( "------------------\n" ); - } + if( cl_shownet->integer == 1 ) { + Com_Printf( "%"PRIz" ", msg_read.cursize ); + } else if( cl_shownet->integer > 1 ) { + Com_Printf( "------------------\n" ); + } // // parse the message // - while( 1 ) { - if( msg_read.readcount > msg_read.cursize ) { - Com_Error( ERR_DROP, "%s: read past end of server message", __func__ ); - } + while( 1 ) { + if( msg_read.readcount > msg_read.cursize ) { + Com_Error( ERR_DROP, "%s: read past end of server message", __func__ ); + } readcount = msg_read.readcount; - if( ( cmd = MSG_ReadByte() ) == -1 ) { - if( cl_shownet->integer > 1 ) { - Com_Printf( "%3"PRIz":END OF MESSAGE\n", msg_read.readcount - 1 ); - } - break; - } - - extrabits = cmd >> SVCMD_BITS; - cmd &= SVCMD_MASK; - - if( cl_shownet->integer > 1 ) { - MSG_ShowSVC( cmd ); - } - - // other commands - switch( cmd ) { - default: + if( ( cmd = MSG_ReadByte() ) == -1 ) { + if( cl_shownet->integer > 1 ) { + Com_Printf( "%3"PRIz":END OF MESSAGE\n", msg_read.readcount - 1 ); + } + break; + } + + extrabits = cmd >> SVCMD_BITS; + cmd &= SVCMD_MASK; + + if( cl_shownet->integer > 1 ) { + MSG_ShowSVC( cmd ); + } + + // other commands + switch( cmd ) { + default: badbyte: - Com_Error( ERR_DROP, "%s: illegible server message: %d", __func__, cmd ); - break; - - case svc_nop: - break; - - case svc_disconnect: - Com_Error( ERR_DISCONNECT, "Server disconnected" ); - break; - - case svc_reconnect: - CL_ParseReconnect(); - return; - - case svc_print: - CL_ParsePrint(); - break; - - case svc_centerprint: - CL_ParseCenterPrint(); - break; - - case svc_stufftext: - CL_ParseStuffText(); - break; - - case svc_serverdata: - CL_ParseServerData(); - break; - - case svc_configstring: - CL_ParseConfigString(); - break; - - case svc_sound: - CL_ParseStartSoundPacket(); - break; - - case svc_spawnbaseline: - CL_ParseBaseline(); - break; - - case svc_temp_entity: - CL_ParseTEnt(); - break; - - case svc_muzzleflash: - CL_ParseMuzzleFlash(); - break; - - case svc_muzzleflash2: - CL_ParseMuzzleFlash2(); - break; - - case svc_download: - CL_ParseDownload(); - continue; - - case svc_frame: - CL_ParseFrame( extrabits ); - continue; - - case svc_inventory: - CL_ParseInventory(); - break; - - case svc_layout: - CL_ParseLayout(); - break; - - case svc_zpacket: + Com_Error( ERR_DROP, "%s: illegible server message: %d", __func__, cmd ); + break; + + case svc_nop: + break; + + case svc_disconnect: + Com_Error( ERR_DISCONNECT, "Server disconnected" ); + break; + + case svc_reconnect: + CL_ParseReconnect(); + return; + + case svc_print: + CL_ParsePrint(); + break; + + case svc_centerprint: + CL_ParseCenterPrint(); + break; + + case svc_stufftext: + CL_ParseStuffText(); + break; + + case svc_serverdata: + CL_ParseServerData(); + break; + + case svc_configstring: + CL_ParseConfigString(); + break; + + case svc_sound: + CL_ParseStartSoundPacket(); + break; + + case svc_spawnbaseline: + CL_ParseBaseline(); + break; + + case svc_temp_entity: + CL_ParseTEnt(); + break; + + case svc_muzzleflash: + CL_ParseMuzzleFlash(); + break; + + case svc_muzzleflash2: + CL_ParseMuzzleFlash2(); + break; + + case svc_download: + CL_ParseDownload(); + continue; + + case svc_frame: + CL_ParseFrame( extrabits ); + continue; + + case svc_inventory: + CL_ParseInventory(); + break; + + case svc_layout: + CL_ParseLayout(); + break; + + case svc_zpacket: if( cls.serverProtocol < PROTOCOL_VERSION_R1Q2 ) { goto badbyte; } - CL_ParseZPacket(); - continue; + CL_ParseZPacket(); + continue; - case svc_gamestate: + case svc_gamestate: if( cls.serverProtocol != PROTOCOL_VERSION_Q2PRO ) { goto badbyte; } - CL_ParseGamestate(); - continue; + CL_ParseGamestate(); + continue; - case svc_setting: + case svc_setting: if( cls.serverProtocol < PROTOCOL_VERSION_R1Q2 ) { goto badbyte; } - CL_ParseSetting(); - continue; - } + CL_ParseSetting(); + continue; + } // copy protocol invariant stuff - if( cls.demorecording && !cls.demopaused ) { - SZ_Write( &cls.demobuff, msg_read.data + readcount, + if( cls.demo.recording && !cls.demo.paused ) { + SZ_Write( &cls.demo.buffer, msg_read.data + readcount, msg_read.readcount - readcount ); } - } + } // // if recording demos, write the message out // - if( cls.demorecording && !cls.demopaused ) { - CL_WriteDemoMessage( &cls.demobuff ); + if( cls.demo.recording && !cls.demo.paused ) { + CL_WriteDemoMessage( &cls.demo.buffer ); } } diff --git a/source/cl_pred.c b/source/cl_pred.c index f79d3de..5b56a9f 100644 --- a/source/cl_pred.c +++ b/source/cl_pred.c @@ -209,7 +209,7 @@ void CL_PredictMovement( void ) { return; } - if( cls.demoplayback ) { + if( cls.demo.playback ) { return; } diff --git a/source/cl_public.h b/source/cl_public.h index b3d3a23..0f43f16 100644 --- a/source/cl_public.h +++ b/source/cl_public.h @@ -33,14 +33,6 @@ typedef enum { ca_active // game views should be displayed } connstate_t; -typedef enum { - dl_none, - dl_model, - dl_sound, - dl_skin, - dl_single -} dltype_t; // download type - typedef struct { char name[MAX_CLIENT_NAME]; int ping; diff --git a/source/cl_scrn.c b/source/cl_scrn.c index 5b71f9f..00882ff 100644 --- a/source/cl_scrn.c +++ b/source/cl_scrn.c @@ -211,9 +211,9 @@ static void SCR_DrawDemoBar( void ) { return; } - if( cls.demoplayback ) { - if( cls.demofileSize ) { - SCR_DrawPercentBar( cls.demofilePercent ); + if( cls.demo.playback ) { + if( cls.demo.file_size ) { + SCR_DrawPercentBar( cls.demo.file_percent ); } return; } diff --git a/source/cvar.c b/source/cvar.c index a301f98..c7f8fe6 100644 --- a/source/cvar.c +++ b/source/cvar.c @@ -206,10 +206,10 @@ static void Cvar_EngineGet( cvar_t *var, const char *var_value, int flags ) { // optionally reset cvar back to default value if( ( ( flags & CVAR_ROM ) || - ( ( flags & CVAR_NOSET ) && com_initialized ) || - ( ( flags & CVAR_CHEAT ) && !CL_CheatsOK() ) || - ( var->flags & CVAR_VOLATILE ) ) - && strcmp( var_value, var->string ) ) + ( ( flags & CVAR_NOSET ) && com_initialized ) || + ( ( flags & CVAR_CHEAT ) && !CL_CheatsOK() ) || + ( var->flags & CVAR_VOLATILE ) ) && + strcmp( var_value, var->string ) ) { Cvar_ChangeString( var, var_value, CVAR_SET_DIRECT ); } diff --git a/source/q_shared.h b/source/q_shared.h index 9a4bf6f..d3f1765 100644 --- a/source/q_shared.h +++ b/source/q_shared.h @@ -311,8 +311,9 @@ void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, int DirToByte( const vec3_t dir ); void ByteToDir( int index, vec3_t dir ); -#define clamp(a,b,c) ((b)>=(c)?(a)=(b):(a)<(b)?(a)=(b):(a)>(c)?(a)=(c):(a)) - +#define clamp(a,b,c) ((a)<(b)?(a)=(b):(a)>(c)?(a)=(c):(a)) +#define cclamp(a,b,c) ((b)>(c)?clamp(a,c,b):clamp(a,b,c)) + #ifndef max #define max(a,b) ((a)>(b)?(a):(b)) #endif diff --git a/source/ui_local.h b/source/ui_local.h index 859c018..5617caa 100644 --- a/source/ui_local.h +++ b/source/ui_local.h @@ -28,10 +28,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "ui_public.h" #define UI_Malloc( s ) Z_TagMalloc( s, TAG_UI ) -#define UI_Mallocz( s ) Z_TagMallocz( s, TAG_UI ) -#define UI_CopyString( s ) Z_TagCopyString( s, TAG_UI ) +#define UI_Mallocz( s ) Z_TagMallocz( s, TAG_UI ) +#define UI_CopyString( s ) Z_TagCopyString( s, TAG_UI ) -#define MAXMENUITEMS 64 +#define MAXMENUITEMS 64 typedef enum { MTYPE_BAD, @@ -50,13 +50,13 @@ typedef enum { MTYPE_KEYBIND } menuType_t; -#define QMF_LEFT_JUSTIFY 0x00000001 -#define QMF_GRAYED 0x00000002 -#define QMF_NUMBERSONLY 0x00000004 -#define QMF_HASFOCUS 0x00000008 -#define QMF_HIDDEN 0x00000010 -#define QMF_DISABLED 0x00000020 -#define QMF_CUSTOM_COLOR 0x00000040 +#define QMF_LEFT_JUSTIFY 0x00000001 +#define QMF_GRAYED 0x00000002 +#define QMF_NUMBERSONLY 0x00000004 +#define QMF_HASFOCUS 0x00000008 +#define QMF_HIDDEN 0x00000010 +#define QMF_DISABLED 0x00000020 +#define QMF_CUSTOM_COLOR 0x00000040 typedef enum { QMS_NOTHANDLED, @@ -70,27 +70,27 @@ typedef enum { #define RCOLUMN_OFFSET 16 #define LCOLUMN_OFFSET -16 -#define MENU_SPACING 12 +#define MENU_SPACING 12 -#define DOUBLE_CLICK_DELAY 300 +#define DOUBLE_CLICK_DELAY 300 #define UI_IsItemSelectable( item ) \ - ( (item)->type != MTYPE_SEPARATOR && \ - (item)->type != MTYPE_STATIC && \ - !( (item)->flags & (QMF_GRAYED|QMF_HIDDEN|QMF_DISABLED) ) ) + ( (item)->type != MTYPE_SEPARATOR && \ + (item)->type != MTYPE_STATIC && \ + !( (item)->flags & (QMF_GRAYED|QMF_HIDDEN|QMF_DISABLED) ) ) typedef void (*confirmAction_t)( qboolean ); typedef struct menuFrameWork_s { list_t entry; - char *name, *title, *status; + char *name, *title, *status; - int nitems; - void *items[MAXMENUITEMS]; + int nitems; + void *items[MAXMENUITEMS]; - qboolean transparent; - qboolean keywait; + qboolean transparent; + qboolean keywait; qhandle_t image; color_t color; @@ -106,19 +106,19 @@ typedef struct menuFrameWork_s { } menuFrameWork_t; typedef struct menuCommon_s { - menuType_t type; - int id; - char *name; - menuFrameWork_t *parent; - color_t color; - vrect_t rect; + menuType_t type; + int id; + char *name; + menuFrameWork_t *parent; + color_t color; + vrect_t rect; char *status; - int x, y; - int width, height; + int x, y; + int width, height; - int flags; - int uiFlags; + int flags; + int uiFlags; menuSound_t (*activate)( struct menuCommon_s * ); menuSound_t (*change)( struct menuCommon_s * ); @@ -127,188 +127,188 @@ typedef struct menuCommon_s { } menuCommon_t; typedef struct menuField_s { - menuCommon_t generic; - inputField_t field; + menuCommon_t generic; + inputField_t field; cvar_t *cvar; int width; } menuField_t; +#define SLIDER_RANGE 10 + typedef struct menuSlider_s { - menuCommon_t generic; + menuCommon_t generic; cvar_t *cvar; - float minvalue; - float maxvalue; - float curvalue; - - float mul, add; - - float range; + float minvalue; + float maxvalue; + float curvalue; + float step; } menuSlider_t; -#define MAX_COLUMNS 8 -#define MLIST_SPACING 10 -#define MLIST_BORDER_WIDTH 1 -#define MLIST_SCROLLBAR_WIDTH 10 -#define MLIST_PRESTEP 3 +#define MAX_COLUMNS 8 + +#define MLIST_SPACING 10 +#define MLIST_BORDER_WIDTH 1 +#define MLIST_SCROLLBAR_WIDTH 10 +#define MLIST_PRESTEP 3 typedef enum { - MLF_NOSELECT = ( 1 << 0 ), - MLF_HIDE_SCROLLBAR = ( 1 << 1 ), - MLF_HIDE_SCROLLBAR_EMPTY = ( 1 << 2 ), - MLF_HIDE_BACKGROUND = ( 1 << 3 ), - MLF_HIDE_HEADER = ( 1 << 4 ) + MLF_NOSELECT = ( 1 << 0 ), + MLF_HIDE_SCROLLBAR = ( 1 << 1 ), + MLF_HIDE_SCROLLBAR_EMPTY = ( 1 << 2 ), + MLF_HIDE_BACKGROUND = ( 1 << 3 ), + MLF_HIDE_HEADER = ( 1 << 4 ) } menuListFlags_t; typedef struct menuListColumn_s { - char *name; - int width; - int uiFlags; + char *name; + int width; + int uiFlags; } menuListColumn_t; typedef struct menuList_s { - menuCommon_t generic; + menuCommon_t generic; - void **items; - int numItems; - int maxItems; - menuListFlags_t mlFlags; + void **items; + int numItems; + int maxItems; + menuListFlags_t mlFlags; int extrasize; - int prestep; - int curvalue; - int clickTime; + int prestep; + int curvalue; + int clickTime; char scratch[8]; int scratchCount; int scratchTime; - menuListColumn_t columns[MAX_COLUMNS]; - int numcolumns; + menuListColumn_t columns[MAX_COLUMNS]; + int numcolumns; int sortdir, sortcol; menuSound_t (*sort)( struct menuList_s *, int column ); } menuList_t; typedef struct menuSpinControl_s { - menuCommon_t generic; + menuCommon_t generic; cvar_t *cvar; - char **itemnames; - char **itemvalues; - int numItems; - int curvalue; + char **itemnames; + char **itemvalues; + int numItems; + int curvalue; - int mask; + int mask; qboolean negate; } menuSpinControl_t; typedef struct menuAction_s { - menuCommon_t generic; + menuCommon_t generic; char *cmd; } menuAction_t; typedef struct menuSeparator_s { - menuCommon_t generic; + menuCommon_t generic; } menuSeparator_t; typedef struct menuStatic_s { - menuCommon_t generic; - int maxChars; + menuCommon_t generic; + int maxChars; } menuStatic_t; typedef struct menuKeybind_s { - menuCommon_t generic; - char binding[32]; - char altbinding[32]; + menuCommon_t generic; + char binding[32]; + char altbinding[32]; char *cmd; } menuKeybind_t; #define MAX_PLAYERMODELS 32 typedef struct playerModelInfo_s { - int nskins; - char **skindisplaynames; - char **weaponNames; - int numWeapons; - char directory[MAX_QPATH]; + int nskins; + char **skindisplaynames; + char **weaponNames; + int numWeapons; + char directory[MAX_QPATH]; } playerModelInfo_t; void PlayerModel_Load( void ); void PlayerModel_Free( void ); -#define MAX_MENU_DEPTH 8 +#define MAX_MENU_DEPTH 8 typedef struct uiStatic_s { qboolean initialized; - int realtime; - glconfig_t glconfig; + int realtime; + glconfig_t glconfig; clipRect_t clipRect; int width, height; // scaled float scale; - int menuDepth; - menuFrameWork_t *layers[MAX_MENU_DEPTH]; - menuFrameWork_t *activeMenu; - int mouseCoords[2]; - qboolean entersound; // play after drawing a frame, so caching - // won't disrupt the sound - qboolean transparent; - int numPlayerModels; - playerModelInfo_t pmi[MAX_PLAYERMODELS]; - - qhandle_t backgroundHandle; - qhandle_t fontHandle; - qhandle_t cursorHandle; - int cursorWidth, cursorHeight; - - char m_demos_browse[MAX_OSPATH]; - int m_demos_selection; + int menuDepth; + menuFrameWork_t *layers[MAX_MENU_DEPTH]; + menuFrameWork_t *activeMenu; + int mouseCoords[2]; + qboolean entersound; // play after drawing a frame, so caching + // won't disrupt the sound + qboolean transparent; + int numPlayerModels; + playerModelInfo_t pmi[MAX_PLAYERMODELS]; + + qhandle_t backgroundHandle; + qhandle_t fontHandle; + qhandle_t cursorHandle; + int cursorWidth, cursorHeight; + + char m_demos_browse[MAX_OSPATH]; + int m_demos_selection; } uiStatic_t; -extern uiStatic_t uis; +extern uiStatic_t uis; extern list_t ui_menus; -extern cvar_t *ui_debug; +extern cvar_t *ui_debug; void UI_PushMenu( menuFrameWork_t *menu ); -void UI_ForceMenuOff( void ); -void UI_PopMenu( void ); -qboolean UI_DoHitTest( void ); -qboolean UI_CursorInRect( vrect_t *rect ); -void *UI_FormatColumns( int extrasize, ... ) q_sentinel; +void UI_ForceMenuOff( void ); +void UI_PopMenu( void ); +qboolean UI_DoHitTest( void ); +qboolean UI_CursorInRect( vrect_t *rect ); +void *UI_FormatColumns( int extrasize, ... ) q_sentinel; char *UI_GetColumn( char *s, int n ); -void UI_AddToServerList( const serverStatus_t *status ); -void UI_DrawLoading( int realtime ); -void UI_SetupDefaultBanner( menuStatic_t *banner, const char *name ); -void UI_DrawString( int x, int y, const color_t color, int flags, const char *string ); -void UI_DrawChar( int x, int y, int flags, int ch ); +void UI_AddToServerList( const serverStatus_t *status ); +void UI_DrawLoading( int realtime ); +void UI_SetupDefaultBanner( menuStatic_t *banner, const char *name ); +void UI_DrawString( int x, int y, const color_t color, int flags, const char *string ); +void UI_DrawChar( int x, int y, int flags, int ch ); void UI_DrawRect( const vrect_t *rect, int border, int color ); void UI_DrawRectEx( const vrect_t *rect, int border, const color_t color ); -void UI_StringDimensions( vrect_t *rc, int flags, const char *string ); +void UI_StringDimensions( vrect_t *rc, int flags, const char *string ); void UI_LoadStript( void ); void UI_FreeStript( void ); menuFrameWork_t *UI_FindMenu( const char *name ); -void Menu_Init( menuFrameWork_t *menu ); +void Menu_Init( menuFrameWork_t *menu ); void Menu_Size( menuFrameWork_t *menu ); -void Menu_Draw( menuFrameWork_t *menu ); -void Menu_AddItem( menuFrameWork_t *menu, void *item ); -menuSound_t Menu_SelectItem( menuFrameWork_t *menu ); -menuSound_t Menu_SlideItem( menuFrameWork_t *menu, int dir ); -menuSound_t Menu_KeyEvent( menuCommon_t *item, int key ); -menuSound_t Menu_CharEvent( menuCommon_t *item, int key ); +void Menu_Draw( menuFrameWork_t *menu ); +void Menu_AddItem( menuFrameWork_t *menu, void *item ); +menuSound_t Menu_SelectItem( menuFrameWork_t *menu ); +menuSound_t Menu_SlideItem( menuFrameWork_t *menu, int dir ); +menuSound_t Menu_KeyEvent( menuCommon_t *item, int key ); +menuSound_t Menu_CharEvent( menuCommon_t *item, int key ); menuSound_t Menu_MouseMove( menuCommon_t *item ); menuSound_t Menu_Keydown( menuFrameWork_t *menu, int key ); -void Menu_SetFocus( menuCommon_t *item ); -menuSound_t Menu_AdjustCursor( menuFrameWork_t *menu, int dir ); -menuCommon_t *Menu_ItemAtCursor( menuFrameWork_t *menu ); -menuCommon_t *Menu_HitTest( menuFrameWork_t *menu ); -void MenuList_Init( menuList_t *l ); -void MenuList_SetValue( menuList_t *l, int value ); +void Menu_SetFocus( menuCommon_t *item ); +menuSound_t Menu_AdjustCursor( menuFrameWork_t *menu, int dir ); +menuCommon_t *Menu_ItemAtCursor( menuFrameWork_t *menu ); +menuCommon_t *Menu_HitTest( menuFrameWork_t *menu ); +void MenuList_Init( menuList_t *l ); +void MenuList_SetValue( menuList_t *l, int value ); void MenuList_Sort( menuList_t *l, int offset, - int (*cmpfunc)( const void *, const void * ) ); + int (*cmpfunc)( const void *, const void * ) ); qboolean Menu_Push( menuFrameWork_t *menu ); void Menu_Pop( menuFrameWork_t *menu ); void Menu_Free( menuFrameWork_t *menu ); diff --git a/source/ui_menu.c b/source/ui_menu.c index 56efc79..e9bc3cd 100644 --- a/source/ui_menu.c +++ b/source/ui_menu.c @@ -1109,17 +1109,13 @@ SLIDER CONTROL =================================================================== */ -#define SLIDER_RANGE 10 - static void Slider_Push( menuSlider_t *s ) { - int val = ( s->cvar->value + s->add ) * s->mul; - clamp( val, s->minvalue, s->maxvalue ); - s->curvalue = val; + s->curvalue = s->cvar->value; + cclamp( s->curvalue, s->minvalue, s->maxvalue ); } void Slider_Pop( menuSlider_t *s ) { - float val = s->curvalue / s->mul - s->add; - Cvar_SetValue( s->cvar, val, CVAR_SET_CONSOLE ); + Cvar_SetValue( s->cvar, s->curvalue, CVAR_SET_CONSOLE ); } static void Slider_Free( menuSlider_t *s ) { @@ -1133,13 +1129,9 @@ static void Slider_Init( menuSlider_t *s ) { s->generic.rect.x = s->generic.x + LCOLUMN_OFFSET - len; s->generic.rect.y = s->generic.y; - s->generic.rect.width = 32 + len + ( SLIDER_RANGE + 2 ) * CHAR_WIDTH; + s->generic.rect.width = ( RCOLUMN_OFFSET - LCOLUMN_OFFSET ) + + len + ( SLIDER_RANGE + 2 ) * CHAR_WIDTH; s->generic.rect.height = CHAR_HEIGHT; - - if( s->curvalue > s->maxvalue ) - s->curvalue = s->maxvalue; - else if( s->curvalue < s->minvalue ) - s->curvalue = s->minvalue; } static int Slider_Key( menuSlider_t *s, int key ) { @@ -1162,12 +1154,9 @@ Slider_DoSlide ================= */ static int Slider_DoSlide( menuSlider_t *s, int dir ) { - s->curvalue += dir; + s->curvalue += dir * s->step; - if( s->curvalue > s->maxvalue ) - s->curvalue = s->maxvalue; - else if( s->curvalue < s->minvalue ) - s->curvalue = s->minvalue; + cclamp( s->curvalue, s->minvalue, s->maxvalue ); if( s->generic.change ) { menuSound_t sound = s->generic.change( &s->generic ); @@ -1206,13 +1195,8 @@ static void Slider_Draw( menuSlider_t *s ) { UI_DrawChar( RCOLUMN_OFFSET + s->generic.x + i * CHAR_WIDTH + CHAR_WIDTH, s->generic.y, flags | UI_LEFT, 130 ); - if( s->maxvalue <= s->minvalue ) { - pos = 0; - } else { - pos = ( s->curvalue - s->minvalue ) / - ( float )( s->maxvalue - s->minvalue ); - clamp( pos, 0, 1 ); - } + pos = ( s->curvalue - s->minvalue ) / ( s->maxvalue - s->minvalue ); + clamp( pos, 0, 1 ); UI_DrawChar( CHAR_WIDTH + RCOLUMN_OFFSET + s->generic.x + ( SLIDER_RANGE - 1 ) * CHAR_WIDTH * pos, s->generic.y, flags | UI_LEFT, 131 ); } diff --git a/source/ui_script.c b/source/ui_script.c index 6f51e12..7958cc5 100644 --- a/source/ui_script.c +++ b/source/ui_script.c @@ -80,8 +80,8 @@ static void Parse_Pairs( menuFrameWork_t *menu ) { static void Parse_Range( menuFrameWork_t *menu ) { menuSlider_t *s; - if( Cmd_Argc() < 7 ) { - Com_Printf( "Usage: %s <name> <cvar> <add> <mul> <min> <max>\n", Cmd_Argv( 0 ) ); + if( Cmd_Argc() < 5 ) { + Com_Printf( "Usage: %s <name> <cvar> <min> <max> [step]\n", Cmd_Argv( 0 ) ); return; } @@ -89,10 +89,13 @@ static void Parse_Range( menuFrameWork_t *menu ) { s->generic.type = MTYPE_SLIDER; s->generic.name = UI_CopyString( Cmd_Argv( 1 ) ); s->cvar = Cvar_Ref( Cmd_Argv( 2 ) ); - s->add = atof( Cmd_Argv( 3 ) ); - s->mul = atof( Cmd_Argv( 4 ) ); - s->minvalue = atoi( Cmd_Argv( 5 ) ); - s->maxvalue = atoi( Cmd_Argv( 6 ) ); + s->minvalue = atof( Cmd_Argv( 3 ) ); + s->maxvalue = atof( Cmd_Argv( 4 ) ); + if( Cmd_Argc() > 5 ) { + s->step = atof( Cmd_Argv( 5 ) ); + } else { + s->step = ( s->maxvalue - s->minvalue ) / SLIDER_RANGE; + } Menu_AddItem( menu, s ); } @@ -195,12 +198,14 @@ static void Parse_Toggle( menuFrameWork_t *menu ) { static void Parse_Field( menuFrameWork_t *menu ) { static const cmd_option_t o_field[] = { + { "c", "center" }, { "i", "integer" }, { "s:", "status" }, { "w:", "width" }, { NULL } }; menuField_t *f; + qboolean center = qfalse; int flags = 0; char *status = NULL; int width = 16; @@ -208,6 +213,9 @@ static void Parse_Field( menuFrameWork_t *menu ) { while( ( c = Cmd_ParseOptions( o_field ) ) != -1 ) { switch( c ) { + case 'c': + center = qtrue; + break; case 'i': flags |= QMF_NUMBERSONLY; break; @@ -228,10 +236,10 @@ static void Parse_Field( menuFrameWork_t *menu ) { f = UI_Mallocz( sizeof( *f ) ); f->generic.type = MTYPE_FIELD; - f->generic.name = UI_CopyString( Cmd_Argv( cmd_optind ) ); + f->generic.name = center ? NULL : UI_CopyString( Cmd_Argv( cmd_optind ) ); f->generic.status = UI_CopyString( status ); f->generic.flags = flags; - f->cvar = Cvar_Ref( Cmd_Argv( cmd_optind + 1 ) ); + f->cvar = Cvar_Ref( Cmd_Argv( center ? cmd_optind : cmd_optind + 1 ) ); f->width = width; Menu_AddItem( menu, f ); diff --git a/wiki/doc/client.mdwn b/wiki/doc/client.mdwn index 4bfbd18..afcc2ec 100644 --- a/wiki/doc/client.mdwn +++ b/wiki/doc/client.mdwn @@ -96,7 +96,7 @@ refresh library. In software mode original particle based effect is used unconditionally. - `set cl_railtrail_type 0` (integer) -Defines which type of effect to use: +Defines which type of rail trail effect to use: - 0 - use original effect - 1 - use alternative effect, draw rail core only - 2 - use alternative effect, draw rail core and spiral @@ -104,17 +104,14 @@ Defines which type of effect to use: - `set cl_railtrail_time 1.0` (float) Time, in seconds, for the rail trail to be visible. -- `set cl_railtrail_alpha 1.0` (float) -Initial opacity of the rail trail as it linearly fades to zero. - -- `set cl_railcore_color 0xFF0000` (integer) -Color of the rail core beam in the hexadecimal `0xRRGGBB` format. +- `set cl_railcore_color "red"` (color) +Color of the rail core beam. - `set cl_railcore_width 3` (integer) Width of the rail core beam. -- `set cl_railspiral_color 0x0000FF` (integer) -Color of the rail spiral in the hexadecimal `0xRRGGBB` format. +- `set cl_railspiral_color "blue"` (color) +Color of the rail spiral. - `set cl_railspiral_radius 3` Radius of the rail spiral. @@ -131,8 +128,11 @@ Disables rendering of animated models for the following effects: - 1 - grenade explosions - 2 - rocket explosions -- `set s_ambient 1` (boolean) -Specifies whether ambient sounds are played or not. +- `set s_ambient 1` (integer) +Specifies if ambient sounds are played: + - 0 - all ambient sounds are disabled + - 1 - all ambient sounds are enabled + - 2 - only ambient sounds from player entity are enabled Console @@ -203,16 +203,14 @@ Video ---------- Hard coded list of the fullscreen video modes is gone from Q2PRO, you can -(and should) specify your own list in your configuration files. Vertical -refresh frequency `freq` and bit depth `bpp` can be specified individually -for each mode. +specify your own list in configuration files. Vertical refresh frequency `freq` +and bit depth `bpp` can be specified individually for each mode. Changing video modes no longer requires `vid_restart`, and is literally instant -on some setups (e.g. X11 w/ LCD monitor). In windowed mode, size and position -of the main window can be changed freely, by dragging window borders with -mouse cursor or whatever. +on some setups (e.g. X11 w/ LCD monitor). In windowed mode, size as well as +position of the main window can be changed freely. -- `set vid_modelist "640x480"` (string) +- `set vid_modelist "640x480 800x600 1024x768"` (string) List of the fullscreen video modes. Full syntax is: `WxH[@freq][:bpp] [...]`. - `set vid_fullscreen 0` (integer) @@ -220,8 +218,9 @@ If set to default (zero), run in windowed mode. If set to non zero _value_, run in the specified fullscreen mode. This way, _value_ acts as index into the list of video modes specified by `vid_modelist`. -- `set vid_placement "640x480"` (string) -Placement of the main window on your virtual desktop. Full syntax is: `WxH[+X+Y]`. +- `set vid_geometry "640x480"` (string) +Size and optional position of the main window on virtual desktop. +Full syntax is: `WxH[+X+Y]`. For example, `set vid_modelist "640x480@75 800x600@75:32"`, followed by `set vid_fullscreen 2` selects 800x600 video mode at 75 Hz vertical refresh @@ -231,17 +230,17 @@ OpenGL renderer ---------- - `set gl_gamma_scale_pics 0` (boolean) -Apply gamma scaling not only for textures and skins, but for all images. +Apply gamma scaling not only to textures and skins, but to HUD pics too. - `set gl_noscrap 0` (boolean) -By default, OpenGL renderer combines small pics into single large texture called -scrap. This cvar disables this optimization. +By default, OpenGL renderer combines small HUD pics into single large +texture called scrap. This cvar disables this optimization. - `set gl_bilerp_chars 0` (boolean) Enable bilinear interpolation of charset images. -- `set gl_fastsky 0` (boolean) -Skip skybox rendering and fill sky with solid color instead. +- `set gl_drawsky 1` (boolean) +When disabled, sky box is drawn in solid black color. - `set gl_partscale 1.5` (float) Specifies minimum size of particles. @@ -267,7 +266,7 @@ lightmaps. - `set gl_fragment_program 0` (boolean) Enables `GL_ARB_fragment_program` extension, if supported by video drivers. -Currently this extension is used for warping liquid surfaces only. +Currently this extension is used only for warping effect on liquid surfaces. - `set gl_vertex_buffer_object 0` (boolean) Enables `GL_ARB_vertex_buffer_object` extension, if supported by video drivers. @@ -275,14 +274,23 @@ This extension allows uploading vertex data at map load time into the special static memory area. Depending on your OpenGL implementation, this may speed up rendering. +- `set r_override_textures 1` (boolean) +Enables automatic overriding of palettized textures (in WAL or PCX format) +with truecolor replacements (in PNG, JPEG or TGA format). + +- `set r_override_models 0` (boolean) +Enables automatic overriding of MD2 models with MD3 replacements. + +- `set r_texture_formats "pjt"` (string) +Specifies the order in which truecolor texture replacements are searched. +Default value means to try \*.png first, then \*.jpg, then \*.tga. + Misc ---------- -- `set in_driver ""` -Specifies which non-keyboard (typically mouse) input driver to use: - - "video" or "" - input facilities provided by the window system - - "dinput" - DirectInput version 7 and higher - - "evdev" - native Linux kernel input device interface +- `set in_direct 1` (boolean) +Enables direct mouse input if supported on your platform. Otherwise, +standard input facilities provided by the window system are used. - `set cl_chat_notify 1` (boolean) Specifies whether to display chat lines in the notify area. @@ -295,6 +303,12 @@ Set this to empty string to disable chat sound. Specifies whether to filter out unprintable characters from incoming chat messages. +- `set cl_noskins 0` (integer) +Restricts which models and skins players can use: + - 0 - no restrictions, if skins exists, it will be loaded + - 1 - do not allow any skins except of `male/grunt` + - 2 - do not allow any skins except of `male/grunt` and `female/athena` + - `set ui_open 1` (boolean) When enabled, menu is automatically opened on startup, instead of full screen console. @@ -377,7 +391,7 @@ specified and supports filename autocompletion on TAB. Loads file from `demos/` unless slash is prepended to _filename_, otherwise loads from the root of VFS. -- `draw <name> <x> <y>` +- `draw <name> <x> <y> [color]` Add console variable or macro identified by _name_ (without the `$` prefix) to the list of objects drawn on the screen. By default, text is positioned relative to the top left corner of the screen. Use negative values to align diff --git a/wiki/doc/q2pro.menu b/wiki/doc/q2pro.menu index b371ecb..1f6cb8f 100644 --- a/wiki/doc/q2pro.menu +++ b/wiki/doc/q2pro.menu @@ -20,7 +20,7 @@ * begin <menuname> * title <menutitle> * -* range <name> <cvar> <add> <mul> <min> <max> +* range <name> <cvar> <min> <max> [step] * * pairs <name> <cvar> <string1> <value1> [...] * values <name> <cvar> <string1> [...] @@ -40,19 +40,19 @@ begin video title "Video Setup" - range "screen size" viewsize 0 0.1 4 10 - range "gamma" vid_gamma -1.8 -10 5 13 + range "screen size" viewsize 40 100 10 + range "gamma" vid_gamma 1.3 0.3 toggle "hardware gamma" vid_hwgamma values "video mode" vid_fullscreen windowed $vid_modelist - range "texture quality" gl_picmip 3 -1 0 3 + range "texture quality" gl_picmip 3 0 -1 pairs "texture filter" gl_texturemode \ nearest GL_NEAREST \ linear GL_LINEAR \ bilinear GL_LINEAR_MIPMAP_NEAREST \ trilinear GL_LINEAR_MIPMAP_LINEAR toggle "vertical sync" gl_swapinterval - range "texture saturation" gl_saturation 0 10 0 10 - range "lightmap saturation" gl_coloredlightmaps 0 10 0 10 + range "texture saturation" gl_saturation 0 1 + range "lightmap saturation" gl_coloredlightmaps 0 1 toggle "override textures" r_override_textures toggle "override models" r_override_models end @@ -65,12 +65,13 @@ begin options action "Video" pushmenu video action "Sound" pushmenu sound action "Downloads" pushmenu downloads + action "Address Book" pushmenu addressbook end begin sound title "Sound Setup" values "hardware access" s_direct "max compatibility" "max performance" - range "effects volume" s_volume 0 10 0 10 + range "effects volume" s_volume 0 1 values "ambient sounds" s_ambient "no" "yes" "only player's own" pairs "chat beep" cl_chat_sound \ disabled "" \ @@ -136,6 +137,26 @@ begin game action "Quit" quit end +begin addressbook + title "Address Book" + field --width 32 --center adr0 + field --width 32 --center adr1 + field --width 32 --center adr2 + field --width 32 --center adr3 + field --width 32 --center adr4 + field --width 32 --center adr5 + field --width 32 --center adr6 + field --width 32 --center adr7 + field --width 32 --center adr8 + field --width 32 --center adr9 + field --width 32 --center adr10 + field --width 32 --center adr11 + field --width 32 --center adr12 + field --width 32 --center adr13 + field --width 32 --center adr14 + field --width 32 --center adr15 +end + begin keys title "Key Bindings" bind "attack" +attack |