… | |
… | |
47 | if (destroyed ()) |
47 | if (destroyed ()) |
48 | return; |
48 | return; |
49 | |
49 | |
50 | #if HAVE_TCP_INFO |
50 | #if HAVE_TCP_INFO |
51 | // check about once per second, spread evenly over all clients |
51 | // check about once per second, spread evenly over all clients |
52 | if (!((pticks + fd) & 7)) |
52 | // do this only when player is active |
|
|
53 | if (!((pticks + fd) & 7) && pl && pl->active) |
53 | { |
54 | { |
54 | // check time of last ack, and, if too old, kill connection |
55 | // check time of last ack, and, if too old, kill connection |
55 | struct tcp_info tcpi; |
56 | struct tcp_info tcpi; |
56 | socklen_t len = sizeof (tcpi); |
57 | socklen_t len = sizeof (tcpi); |
57 | |
58 | |
… | |
… | |
84 | */ |
85 | */ |
85 | |
86 | |
86 | // write a nop to the socket at least every IDLE_NOP seconds. |
87 | // write a nop to the socket at least every IDLE_NOP seconds. |
87 | if (!outputbuffer.len) |
88 | if (!outputbuffer.len) |
88 | { |
89 | { |
89 | if (last_send + IDLE_PING <= NOW) |
90 | if (last_send + IDLE_PING <= NOW && pl && pl->active) |
90 | { |
91 | { |
91 | // this is a bit ugly, but map1/map1a seem to be the only |
92 | // this is a bit ugly, but map1/map1a seem to be the only |
92 | // nop'able commands and they are quite small. |
93 | // nop'able commands and they are quite small. |
93 | packet sl (mapmode == Map1Cmd ? "map1" : "map1a"); |
94 | packet sl (mapmode == Map1Cmd ? "map1" : "map1a"); |
94 | send_packet (sl); |
95 | send_packet (sl); |