diff options
-rw-r--r-- | source/com_local.h | 5 | ||||
-rw-r--r-- | source/common.c | 13 | ||||
-rw-r--r-- | source/mvd_client.c | 16 | ||||
-rw-r--r-- | source/mvd_local.h | 7 | ||||
-rw-r--r-- | source/sv_ac.c | 96 | ||||
-rw-r--r-- | source/sv_local.h | 1 | ||||
-rw-r--r-- | source/sv_main.c | 9 | ||||
-rw-r--r-- | source/sv_send.c | 4 |
8 files changed, 97 insertions, 54 deletions
diff --git a/source/com_local.h b/source/com_local.h index 10df295..2037969 100644 --- a/source/com_local.h +++ b/source/com_local.h @@ -904,6 +904,11 @@ static inline const ucmd_t *Com_Find( const ucmd_t *u, const char *c ) { return NULL; } +typedef struct string_entry_s { + struct string_entry_s *next; + char string[1]; +} string_entry_t; + typedef void (*rdflush_t)( int target, char *buffer, int length ); void Com_BeginRedirect (int target, char *buffer, int buffersize, rdflush_t flush); diff --git a/source/common.c b/source/common.c index fc06ef5..61f33b5 100644 --- a/source/common.c +++ b/source/common.c @@ -88,14 +88,13 @@ static int rd_length; static rdflush_t rd_flush; void Com_BeginRedirect( int target, char *buffer, int buffersize, rdflush_t flush ) { - if( !target || !buffer || buffersize < 1 || !flush ) + if( rd_target || !target || !buffer || buffersize < 1 || !flush ) { return; + } rd_target = target; rd_buffer = buffer; rd_buffersize = buffersize; rd_flush = flush; - - *rd_buffer = 0; rd_length = 0; } @@ -104,16 +103,19 @@ static void Com_AbortRedirect( void ) { rd_buffer = NULL; rd_buffersize = 0; rd_flush = NULL; + rd_length = 0; } void Com_EndRedirect( void ) { + if( !rd_target ) { + return; + } rd_flush( rd_target, rd_buffer, rd_length ); - rd_length = 0; - rd_target = 0; rd_buffer = NULL; rd_buffersize = 0; rd_flush = NULL; + rd_length = 0; } static void Com_Redirect( const char *msg, int total ) { @@ -126,7 +128,6 @@ static void Com_Redirect( const char *msg, int total ) { } if( rd_length + length > rd_buffersize ) { rd_flush( rd_target, rd_buffer, rd_length ); - *rd_buffer = 0; rd_length = 0; } memcpy( rd_buffer + rd_length, msg, length ); diff --git a/source/mvd_client.c b/source/mvd_client.c index e1ae2c6..2f4690e 100644 --- a/source/mvd_client.c +++ b/source/mvd_client.c @@ -467,7 +467,7 @@ void MVD_ChangeLevel( mvd_t *mvd ) { SV_SendAsyncPackets(); } -static void MVD_PlayNext( mvd_t *mvd, demoentry_t *entry ) { +static void MVD_PlayNext( mvd_t *mvd, string_entry_t *entry ) { uint32 magic = 0; if( !entry ) { @@ -485,23 +485,23 @@ static void MVD_PlayNext( mvd_t *mvd, demoentry_t *entry ) { mvd->demofile = 0; } - FS_FOpenFile( entry->path, &mvd->demofile, FS_MODE_READ ); + FS_FOpenFile( entry->string, &mvd->demofile, FS_MODE_READ ); if( !mvd->demofile ) { - MVD_Dropf( mvd, "Couldn't reopen %s", entry->path ); + MVD_Dropf( mvd, "Couldn't reopen %s", entry->string ); } FS_Read( &magic, 4, mvd->demofile ); if( magic != MVD_MAGIC ) { - MVD_Dropf( mvd, "%s is not a MVD2 file", entry->path ); + MVD_Dropf( mvd, "%s is not a MVD2 file", entry->string ); } - Com_Printf( "[%s] Reading from %s\n", mvd->name, entry->path ); + Com_Printf( "[%s] Reading from %s\n", mvd->name, entry->string ); // reset state mvd->demoentry = entry; // set channel address - Q_strncpyz( mvd->address, COM_SkipPath( entry->path ), sizeof( mvd->address ) ); + Q_strncpyz( mvd->address, COM_SkipPath( entry->string ), sizeof( mvd->address ) ); } @@ -1152,7 +1152,7 @@ void MVD_Play_f( void ) { int loop = 1, len; mvd_t *mvd; int c, argc; - demoentry_t *entry, *head; + string_entry_t *entry, *head; int i; while( ( c = Cmd_ParseOptions( options ) ) != -1 ) { @@ -1203,7 +1203,7 @@ void MVD_Play_f( void ) { len = strlen( buffer ) + 1; entry = Z_Malloc( sizeof( *entry ) + len ); - memcpy( entry->path, buffer, len ); + memcpy( entry->string, buffer, len ); entry->next = head; head = entry; } diff --git a/source/mvd_local.h b/source/mvd_local.h index 8e2ef97..00fdbb7 100644 --- a/source/mvd_local.h +++ b/source/mvd_local.h @@ -97,11 +97,6 @@ typedef struct { short delta_angles[3]; } udpClient_t; -typedef struct demoentry_s { - struct demoentry_s *next; - char path[1]; -} demoentry_t; - typedef struct mvd_s { list_t entry; list_t ready; @@ -114,7 +109,7 @@ typedef struct mvd_s { qboolean demoplayback; qboolean demorecording; int demoloop; - demoentry_t *demohead, *demoentry; + string_entry_t *demohead, *demoentry; // connection variables mvdState_t state; diff --git a/source/sv_ac.c b/source/sv_ac.c index 25cbbaf..168774c 100644 --- a/source/sv_ac.c +++ b/source/sv_ac.c @@ -501,10 +501,9 @@ static void AC_Announce( client_t *client, const char *fmt, ... ) { MSG_WriteByte( svc_print ); MSG_WriteByte( PRINT_HIGH ); + MSG_WriteData( AC_MESSAGE, sizeof( AC_MESSAGE ) - 1 ); MSG_WriteData( string, length + 1 ); - Com_Printf( "%s", string ); - if( client->state == cs_spawned ) { FOR_EACH_CLIENT( client ) { if( client->state == cs_spawned ) { @@ -629,10 +628,10 @@ static void AC_ParseClientAck( void ) { } static void AC_ParseFileViolation( void ) { - //linkednamelist_t *bad; + string_entry_t *bad; client_t *cl; char *path, *hash; - int action; + int action, pathlen; ac_file_t *f; cl = AC_ParseClient(); @@ -640,7 +639,7 @@ static void AC_ParseFileViolation( void ) { return; } - path = MSG_ReadString(); + path = MSG_ReadStringLength( &pathlen ); if( msg_read.readcount < msg_read.cursize ) hash = MSG_ReadString(); else @@ -665,8 +664,8 @@ static void AC_ParseFileViolation( void ) { AC_Announce( cl, "%s was kicked for modified %s\n", cl->name, path ); break; case 1: - SV_ClientPrintf( cl, PRINT_HIGH, - "WARNING: Your file %s has been modified. " + SV_ClientPrintf( cl, PRINT_HIGH, AC_MESSAGE + "Your file %s has been modified. " "Please replace it with a known valid copy.\n", path ); break; case 2: @@ -691,16 +690,10 @@ static void AC_ParseFileViolation( void ) { return; } - /* - bad = &cl->anticheat_bad_files; - while (bad->next) - bad = bad->next; - - bad->next = Z_TagMalloc (sizeof(*bad), TAGMALLOC_ANTICHEAT); - bad = bad->next; - bad->name = CopyString (quakePath, TAGMALLOC_ANTICHEAT); - bad->next = NULL; - */ + bad = SV_Malloc( sizeof( *bad ) + pathlen ); + memcpy( bad->string, path, pathlen + 1 ); + bad->next = cl->ac_bad_files; + cl->ac_bad_files = bad; } static void AC_ParseReady( void ) { @@ -1365,8 +1358,10 @@ void AC_List_f( void ) { } void AC_Info_f( void ) { - //client_t *cl; - //linkednamelist_t *bad; + client_t *cl; + string_entry_t *bad; + char *substring, *filesubstring; + int clientID; if( !svs.initialized ) { Com_Printf( "No server running.\n" ); @@ -1380,22 +1375,57 @@ void AC_Info_f( void ) { } if( Cmd_Argc() == 1 ) { - Com_Printf( "Usage: %s [substring|id]\n", Cmd_Argv( 0 ) ); - return; + if( !sv_client ) { + Com_Printf( "Usage: %s [substring|id] [filesubstring]\n", Cmd_Argv( 0 ) ); + return; + } + cl = sv_client; + filesubstring = ""; + } else { + substring = Cmd_Argv( 1 ); + filesubstring = Cmd_Argv( 2 ); + + if( COM_IsNumeric( substring ) ) { + clientID = atoi( substring ); + if( clientID < 0 || clientID >= sv_maxclients->integer ) { + Com_Printf( "Invalid client ID.\n" ); + return; + } + cl = &svs.clientpool[clientID]; + if( cl->state < cs_spawned ) { + Com_Printf( "Player is not active.\n" ); + return; + } + } else { + FOR_EACH_CLIENT( cl ) { + if( cl->state < cs_spawned ) { + continue; + } + if( strstr( cl->name, substring ) ) { + goto found; + } + } + Com_Printf( "Player not found.\n" ); + return; + } } - //SV_SetPlayer(); - - /* - bad = &cl->anticheat_bad_files; - - Com_Printf ("File check failures for %s:\n", LOG_GENERAL, cl->name); - while (bad->next) - { - bad = bad->next; - if (!filesubstring[0] || strstr (bad->name, filesubstring)) - Com_Printf ("%s\n", LOG_GENERAL, bad->name); - }*/ +found: + if( !cl->ac_valid ) { + Com_Printf( "%s is not using anticheat.\n", cl->name ); + return; + } + + if( cl->ac_bad_files ) { + Com_Printf( "File check failures for %s:\n", cl->name ); + for( bad = cl->ac_bad_files; bad; bad = bad->next ) { + if( !filesubstring[0] || strstr( bad->string, filesubstring ) ) { + Com_Printf( "%s\n", bad->string ); + } + } + } else { + Com_Printf( "%s has no file check failures.\n", cl->name ); + } } static void AC_Invalidate_f( void ) { diff --git a/source/sv_local.h b/source/sv_local.h index aa68f73..ff70573 100644 --- a/source/sv_local.h +++ b/source/sv_local.h @@ -229,6 +229,7 @@ typedef struct client_s { int ac_file_failures; unsigned ac_query_time; int ac_client_type; + string_entry_t *ac_bad_files; #endif } client_t; diff --git a/source/sv_main.c b/source/sv_main.c index 486c5ce..c5fb882 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -123,6 +123,15 @@ void SV_RemoveClient( client_t *client ) { void SV_CleanClient( client_t *client ) { int i; +#if USE_ANTICHEAT & 2 + string_entry_t *bad, *next; + + for( bad = client->ac_bad_files; bad; bad = next ) { + next = bad->next; + Z_Free( bad ); + } + client->ac_bad_files = NULL; +#endif if( client->download ) { FS_FreeFile( client->download ); diff --git a/source/sv_send.c b/source/sv_send.c index 1e981a3..fe433b8 100644 --- a/source/sv_send.c +++ b/source/sv_send.c @@ -42,7 +42,9 @@ void SV_FlushRedirect( int redirected, char *outputbuf, int length ) { } else if( redirected == RD_CLIENT ) { MSG_WriteByte( svc_print ); MSG_WriteByte( PRINT_HIGH ); - MSG_WriteData( outputbuf, length + 1 ); + MSG_WriteData( outputbuf, length ); + MSG_WriteByte( 0 ); + //Sys_Printf("redirect: %d bytes: %s", outputbuf); SV_ClientAddMessage( sv_client, MSG_RELIABLE|MSG_CLEAR ); } } |