diff --git a/engine/client/cl_debug.c b/engine/client/cl_debug.c index 03eabddb..4e1c4059 100644 --- a/engine/client/cl_debug.c +++ b/engine/client/cl_debug.c @@ -198,3 +198,44 @@ void CL_WriteMessageHistory( void ) CL_WriteErrorMessage( old->starting_offset, msg ); cls_message_debug.parsing = false; } + +void CL_ReplayBufferDat_f( void ) +{ + file_t *f = FS_Open( Cmd_Argv( 1 ), "rb", true ); + sizebuf_t msg; + char buffer[NET_MAX_MESSAGE]; + int starting_count, current_count, protocol; + fs_offset_t len; + + if( !f ) + return; + + FS_Read( f, &starting_count, sizeof( starting_count )); + FS_Read( f, ¤t_count, sizeof( current_count )); + FS_Read( f, &protocol, sizeof( protocol )); + + cls.legacymode = protocol; + + len = FS_Read( f, buffer, sizeof( buffer )); + FS_Close( f ); + + MSG_Init( &msg, __func__, buffer, len ); + + Delta_Shutdown(); + Delta_Init(); + + clgame.maxEntities = MAX_EDICTS; + clgame.entities = Mem_Calloc( clgame.mempool, sizeof( *clgame.entities ) * clgame.maxEntities ); + + // ad-hoc implement +#if 0 + { + const int message_pos = 12; // put real number here + MSG_SeekToBit( &msg, ( message_pos - 12 + 1 ) << 3, SEEK_SET ); + + CL_ParseYourMom( &msg, protocol ); + } +#endif + + Sys_Quit( __func__ ); +} diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 428b6a79..7b0e54dc 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -3489,6 +3489,8 @@ static void CL_InitLocal( void ) Cmd_AddCommand ("fullserverinfo", CL_FullServerinfo_f, "sent by server when serverinfo changes" ); Cmd_AddCommand ("upload", CL_BeginUpload_f, "uploading file to the server" ); + Cmd_AddRestrictedCommand( "replaybufferdat", CL_ReplayBufferDat_f, "development and debugging tool" ); + Cmd_AddRestrictedCommand ("quit", CL_Quit_f, "quit from game" ); Cmd_AddRestrictedCommand ("exit", CL_Quit_f, "quit from game" ); diff --git a/engine/client/client.h b/engine/client/client.h index 09beb724..a5b49d4a 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -737,6 +737,7 @@ void CL_ClearResourceLists( void ); // // cl_debug.c // +void CL_ReplayBufferDat_f( void ); void CL_Parse_Debug( qboolean enable ); void CL_Parse_RecordCommand( int cmd, int startoffset ); void CL_ResetFrame( frame_t *frame );