mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-01-22 07:51:20 +00:00
make qf-server REALY sleep when there are no clients currently connected
This commit is contained in:
parent
c71fc78360
commit
73980fe852
3 changed files with 12 additions and 4 deletions
|
@ -256,6 +256,7 @@ typedef struct
|
|||
int spawncount; // number of servers spawned since start,
|
||||
// used to check late spawns
|
||||
client_t clients[MAX_CLIENTS];
|
||||
int num_clients;
|
||||
int serverflags; // episode completion information
|
||||
|
||||
double last_heartbeat;
|
||||
|
|
|
@ -813,6 +813,7 @@ SVC_DirectConnect (void)
|
|||
Netchan_Setup (&newcl->netchan, adr, qport);
|
||||
|
||||
newcl->state = cs_connected;
|
||||
svs.num_clients++;
|
||||
|
||||
newcl->datagram.allowoverflow = true;
|
||||
newcl->datagram.data = newcl->datagram_buf;
|
||||
|
@ -1341,11 +1342,13 @@ SV_CheckTimeouts (void)
|
|||
SV_BroadcastPrintf (PRINT_HIGH, "%s timed out\n", cl->name);
|
||||
SV_DropClient (cl);
|
||||
cl->state = cs_free; // don't bother with zombie state
|
||||
svs.num_clients--;
|
||||
}
|
||||
}
|
||||
if (cl->state == cs_zombie &&
|
||||
realtime - cl->connection_started > zombietime->value) {
|
||||
cl->state = cs_free; // can now be reused
|
||||
svs.num_clients--;
|
||||
}
|
||||
}
|
||||
if (sv.paused && !nclients) {
|
||||
|
|
|
@ -168,12 +168,15 @@ main
|
|||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
static struct timeval _timeout;
|
||||
double time, oldtime, newtime;
|
||||
fd_set fdset;
|
||||
extern int net_socket;
|
||||
struct timeval timeout;
|
||||
int j;
|
||||
|
||||
_timeout.tv_sec = 1;
|
||||
_timeout.tv_usec = 0;
|
||||
|
||||
memset (&host_parms, 0, sizeof (host_parms));
|
||||
|
||||
COM_InitArgv (argc, argv);
|
||||
|
@ -198,6 +201,7 @@ main (int argc, char *argv[])
|
|||
//
|
||||
oldtime = Sys_DoubleTime () - 0.1;
|
||||
while (1) {
|
||||
struct timeval *timeout = 0;
|
||||
// select on the net socket and stdin
|
||||
// the only reason we have a timeout at all is so that if the last
|
||||
// connected client times out, the message would not otherwise
|
||||
|
@ -206,9 +210,9 @@ main (int argc, char *argv[])
|
|||
if (do_stdin)
|
||||
FD_SET (0, &fdset);
|
||||
FD_SET (net_socket, &fdset);
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
if (select (net_socket + 1, &fdset, NULL, NULL, &timeout) == -1)
|
||||
if (svs.num_clients)
|
||||
timeout = &_timeout;
|
||||
if (select (net_socket + 1, &fdset, NULL, NULL, timeout) == -1)
|
||||
continue;
|
||||
stdin_ready = FD_ISSET (0, &fdset);
|
||||
|
||||
|
|
Loading…
Reference in a new issue