Skip to content

Commit

Permalink
Add initial server-side recording system
Browse files Browse the repository at this point in the history
  • Loading branch information
Chomenor committed Nov 3, 2023
1 parent 914fc40 commit e810eb0
Show file tree
Hide file tree
Showing 20 changed files with 3,827 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,11 @@ Q3OBJ = \
$(B)/client/sv_init.o \
$(B)/client/sv_main.o \
$(B)/client/sv_net_chan.o \
$(B)/client/sv_record_common.o \
$(B)/client/sv_record_convert.o \
$(B)/client/sv_record_main.o \
$(B)/client/sv_record_spectator.o \
$(B)/client/sv_record_writer.o \
$(B)/client/sv_snapshot.o \
$(B)/client/sv_world.o \
\
Expand Down Expand Up @@ -1256,6 +1261,11 @@ Q3DOBJ = \
$(B)/ded/sv_init.o \
$(B)/ded/sv_main.o \
$(B)/ded/sv_net_chan.o \
$(B)/ded/sv_record_common.o \
$(B)/ded/sv_record_convert.o \
$(B)/ded/sv_record_main.o \
$(B)/ded/sv_record_spectator.o \
$(B)/ded/sv_record_writer.o \
$(B)/ded/sv_snapshot.o \
$(B)/ded/sv_world.o \
\
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ Performance is usually greater or equal to other opengl1 renderers

Original ioquake3 renderer, performance is very poor on non-nvidia systems, unmaintained

## Server Side Recording

Enabled by `sv_recordAutoRecording 1` to record all matches on the server to records directory.

To convert recorded file to demo format for playback, use `record_convert <filename> <clientnum> <instance>` command, where filename is the path to the .rec file within the records directory, clientnum is the client perspective to view, and instance differentiates multiple clients or reconnections with the same client number.

To view available clients and instances for a record file, use `record_scan <filename>` command.

## Admin Spectator

Allows admins to spectate players on the server without joining (useful to monitor for cheating). To enable, set `sv_adminSpectatorPassword` on the server to a password of your choosing. To join the server in spectator mode, set password on the client to `spect_` plus the server password.

## [Build Instructions](BUILD.md)

## Contacts
Expand Down
13 changes: 13 additions & 0 deletions code/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,16 @@ void SV_LoadFilters( const char *filename );
const char *SV_RunFilters( const char *userinfo, const netadr_t *addr );
void SV_AddFilter_f( void );
void SV_AddFilterCmd_f( void );

//
// sv_record_main.c
//
void Record_Initialize( void );
void Record_ProcessUsercmd( int clientNum, usercmd_t *usercmd );
void Record_ProcessConfigstring( int index, const char *value );
void Record_ProcessServercmd( int clientNum, const char *value );
void Record_ProcessMapLoaded( void );
void Record_ProcessSnapshot( void );
void Record_ProcessGameShutdown( void );
qboolean Record_ProcessClientConnect( const netadr_t *address, const char *userinfo, int challenge, int qport, qboolean compat );
qboolean Record_ProcessPacketEvent( const netadr_t *address, msg_t *msg, int qport );
6 changes: 6 additions & 0 deletions code/server/sv_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ void SV_DirectConnect( const netadr_t *from ) {
return;
}

if ( Record_ProcessClientConnect( from, userinfo, challenge, qport, compat ) ) {
return;
}

// run userinfo filter
SV_SetTLD( tld, from, Sys_IsLANAddress( from ) );
Info_SetValueForKey( userinfo, "tld", tld );
Expand Down Expand Up @@ -2021,6 +2025,8 @@ void SV_ClientThink (client_t *cl, usercmd_t *cmd) {
return; // may have been kicked during the last usercmd
}

Record_ProcessUsercmd( cl - svs.clients, cmd );

VM_Call( gvm, 1, GAME_CLIENT_THINK, cl - svs.clients );
}

Expand Down
1 change: 1 addition & 0 deletions code/server/sv_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ Called every time a map changes
===============
*/
void SV_ShutdownGameProgs( void ) {
Record_ProcessGameShutdown();
if ( !gvm ) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions code/server/sv_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ void SV_SetConfigstring (int index, const char *val) {
SV_SendConfigstring(client, index);
}
}
Record_ProcessConfigstring( index, val );
}


Expand Down Expand Up @@ -669,6 +670,8 @@ void SV_SpawnServer( const char *mapname, qboolean killBots ) {

Hunk_SetMark();

Record_ProcessMapLoaded();

Com_Printf ("-----------------------------------\n");

Sys_SetStatus( "Running map %s", mapname );
Expand Down Expand Up @@ -812,6 +815,7 @@ void SV_Init( void )
SV_TrackCvarChanges();

SV_InitChallenger();
Record_Initialize();
}


Expand Down
3 changes: 3 additions & 0 deletions code/server/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ void SV_AddServerCommand( client_t *client, const char *cmd ) {
if ( client->state < CS_PRIMED )
return;

Record_ProcessServercmd( client - svs.clients, cmd );

client->reliableSequence++;
// if we would be losing an old command that hasn't been acknowledged,
// we must drop the connection
Expand Down Expand Up @@ -1027,6 +1029,7 @@ void SV_PacketEvent( const netadr_t *from, msg_t *msg ) {
return;
}
}
Record_ProcessPacketEvent( from, msg, qport );
}


Expand Down
Loading

0 comments on commit e810eb0

Please sign in to comment.