Skip to content

Commit

Permalink
engine: client: add command replaybufferdat to aid in debugging proto…
Browse files Browse the repository at this point in the history
…col errors by parsing buffer.dat
  • Loading branch information
a1batross committed Feb 2, 2025
1 parent 1abec80 commit 95af635
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
41 changes: 41 additions & 0 deletions engine/client/cl_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, &current_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__ );
}
2 changes: 2 additions & 0 deletions engine/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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" );

Expand Down
1 change: 1 addition & 0 deletions engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 95af635

Please sign in to comment.