Skip to content

Commit 1ddc203

Browse files
committed
SSR: Add initial server-side recording system
1 parent e7884db commit 1ddc203

20 files changed

+3827
-0
lines changed

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,11 @@ Q3OBJ = \
10581058
$(B)/client/sv_init.o \
10591059
$(B)/client/sv_main.o \
10601060
$(B)/client/sv_net_chan.o \
1061+
$(B)/client/sv_record_common.o \
1062+
$(B)/client/sv_record_convert.o \
1063+
$(B)/client/sv_record_main.o \
1064+
$(B)/client/sv_record_spectator.o \
1065+
$(B)/client/sv_record_writer.o \
10611066
$(B)/client/sv_snapshot.o \
10621067
$(B)/client/sv_world.o \
10631068
\
@@ -1256,6 +1261,11 @@ Q3DOBJ = \
12561261
$(B)/ded/sv_init.o \
12571262
$(B)/ded/sv_main.o \
12581263
$(B)/ded/sv_net_chan.o \
1264+
$(B)/ded/sv_record_common.o \
1265+
$(B)/ded/sv_record_convert.o \
1266+
$(B)/ded/sv_record_main.o \
1267+
$(B)/ded/sv_record_spectator.o \
1268+
$(B)/ded/sv_record_writer.o \
12591269
$(B)/ded/sv_snapshot.o \
12601270
$(B)/ded/sv_world.o \
12611271
\

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ Performance is usually greater or equal to other opengl1 renderers
7272

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

75+
## Server Side Recording
76+
77+
Enabled by `sv_recordAutoRecording 1` to record all matches on the server to records directory.
78+
79+
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.
80+
81+
To view available clients and instances for a record file, use `record_scan <filename>` command.
82+
83+
## Admin Spectator
84+
85+
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.
86+
7587
## [Build Instructions](BUILD.md)
7688

7789
## Contacts

code/server/server.h

+13
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,16 @@ void SV_LoadFilters( const char *filename );
489489
const char *SV_RunFilters( const char *userinfo, const netadr_t *addr );
490490
void SV_AddFilter_f( void );
491491
void SV_AddFilterCmd_f( void );
492+
493+
//
494+
// sv_record_main.c
495+
//
496+
void Record_Initialize( void );
497+
void Record_ProcessUsercmd( int clientNum, usercmd_t *usercmd );
498+
void Record_ProcessConfigstring( int index, const char *value );
499+
void Record_ProcessServercmd( int clientNum, const char *value );
500+
void Record_ProcessMapLoaded( void );
501+
void Record_ProcessSnapshot( void );
502+
void Record_ProcessGameShutdown( void );
503+
qboolean Record_ProcessClientConnect( const netadr_t *address, const char *userinfo, int challenge, int qport, qboolean compat );
504+
qboolean Record_ProcessPacketEvent( const netadr_t *address, msg_t *msg, int qport );

code/server/sv_client.c

+6
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,10 @@ void SV_DirectConnect( const netadr_t *from ) {
595595
return;
596596
}
597597

598+
if ( Record_ProcessClientConnect( from, userinfo, challenge, qport, compat ) ) {
599+
return;
600+
}
601+
598602
// run userinfo filter
599603
SV_SetTLD( tld, from, Sys_IsLANAddress( from ) );
600604
Info_SetValueForKey( userinfo, "tld", tld );
@@ -2021,6 +2025,8 @@ void SV_ClientThink (client_t *cl, usercmd_t *cmd) {
20212025
return; // may have been kicked during the last usercmd
20222026
}
20232027

2028+
Record_ProcessUsercmd( cl - svs.clients, cmd );
2029+
20242030
VM_Call( gvm, 1, GAME_CLIENT_THINK, cl - svs.clients );
20252031
}
20262032

code/server/sv_game.c

+1
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,7 @@ Called every time a map changes
993993
===============
994994
*/
995995
void SV_ShutdownGameProgs( void ) {
996+
Record_ProcessGameShutdown();
996997
if ( !gvm ) {
997998
return;
998999
}

code/server/sv_init.c

+4
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ void SV_SetConfigstring (int index, const char *val) {
143143
SV_SendConfigstring(client, index);
144144
}
145145
}
146+
Record_ProcessConfigstring( index, val );
146147
}
147148

148149

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

670671
Hunk_SetMark();
671672

673+
Record_ProcessMapLoaded();
674+
672675
Com_Printf ("-----------------------------------\n");
673676

674677
Sys_SetStatus( "Running map %s", mapname );
@@ -812,6 +815,7 @@ void SV_Init( void )
812815
SV_TrackCvarChanges();
813816

814817
SV_InitChallenger();
818+
Record_Initialize();
815819
}
816820

817821

code/server/sv_main.c

+3
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ void SV_AddServerCommand( client_t *client, const char *cmd ) {
152152
if ( client->state < CS_PRIMED )
153153
return;
154154

155+
Record_ProcessServercmd( client - svs.clients, cmd );
156+
155157
client->reliableSequence++;
156158
// if we would be losing an old command that hasn't been acknowledged,
157159
// we must drop the connection
@@ -1027,6 +1029,7 @@ void SV_PacketEvent( const netadr_t *from, msg_t *msg ) {
10271029
return;
10281030
}
10291031
}
1032+
Record_ProcessPacketEvent( from, msg, qport );
10301033
}
10311034

10321035

0 commit comments

Comments
 (0)