Skip to content

Commit

Permalink
SERVER: Restart Dedicated Server when party is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
MotoLegacy committed Dec 27, 2024
1 parent c780582 commit 2cc0ca7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions source/server/player/player_core.qc
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,12 @@ void() PutClientInServer =
GameRestart_ResetPerkaColas();
};

void() RestartDedicatedServer =
{
bprint(PRINT_HIGH, "[INFO]: Issuing server restart as player is connecting to an empty server.\n");
localcmd("restart\n");
}

//called when client disconnects from the server
void() ClientDisconnect =
{
Expand Down Expand Up @@ -1079,6 +1085,18 @@ void() ClientDisconnect =
self.is_in_menu = 0;

#endif // FTE

// We can encounter a player count of zero if we are in a dedicated
// server. If this is the case we should restart the current level
// to prevent issues with a player joining mid-match stuck in spectator
// mode, or spawning in at a high round not able to progress.
if (player_count == 0) {
// We need to use a temp entity for this to add a delay, else this
// will interfere with SP games.
entity tempe = spawn();
tempe.think = RestartDedicatedServer;
tempe.nextthink = time + 0.25;
}
};


Expand Down

0 comments on commit 2cc0ca7

Please sign in to comment.