Skip to content

Commit

Permalink
Prevent SV_DropClient() from being called recursively if the client i…
Browse files Browse the repository at this point in the history
…s dropped by a kick or timeout and has too many reliable commands
  • Loading branch information
smallmodel committed Oct 11, 2024
1 parent 009f520 commit f3084d2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions code/server/sv_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,16 @@ void SV_DropClient( client_t *drop, const char *reason ) {
// Free all allocated data on the client structure
SV_FreeClient(drop);

// Reset the reliable sequence to the currently acknowledged command
// This prevents SV_AddServerCommand() from making another recursive call to SV_DropClient()
// if the client lacks sufficient space for another reliable command
// it also guarantees that the client receives both the print and disconnect commands
drop->reliableSequence = drop->reliableAcknowledge;
// Setting the gamestate message number to -1 ensures that SV_AddServerCommand()
// will not call SV_DropClient() again, even though it is unlikely the client
// will receive many server commands during the drop
drop->gamestateMessageNum = -1;

// tell everyone why they got dropped
SV_SendServerCommand( NULL, "print \"%s" S_COLOR_WHITE " %s\n\"", drop->name, reason );

Expand Down

0 comments on commit f3084d2

Please sign in to comment.