From e78997fdfd963ca9b382a949d71056ccaef8f0eb Mon Sep 17 00:00:00 2001 From: peter1138 Date: Thu, 19 Jan 2006 17:50:40 +0000 Subject: (svn r3409) - Change the server advertisement interval to use the frame counter instead of game days. This allows a paused server to continue to advertise itself. This also fixes advertising for games that start before 1922. --- network_udp.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'network_udp.c') diff --git a/network_udp.c b/network_udp.c index c229d3dcc..b4087c1e6 100644 --- a/network_udp.c +++ b/network_udp.c @@ -35,9 +35,9 @@ typedef enum { } PacketUDPType; enum { - ADVERTISE_NORMAL_INTERVAL = 450, // interval between advertising in days - ADVERTISE_RETRY_INTERVAL = 5, // readvertise when no response after this amount of days - ADVERTISE_RETRY_TIMES = 3 // give up readvertising after this much failed retries + ADVERTISE_NORMAL_INTERVAL = 30000, // interval between advertising in ticks (15 minutes) + ADVERTISE_RETRY_INTERVAL = 300, // readvertise when no response after this many ticks (9 seconds) + ADVERTISE_RETRY_TIMES = 3 // give up readvertising after this much failed retries }; #define DEF_UDP_RECEIVE_COMMAND(type) void NetworkPacketReceive_ ## type ## _command(Packet *p, struct sockaddr_in *client_addr) @@ -611,18 +611,23 @@ void NetworkUDPAdvertise(void) if (!NetworkUDPListen(&_udp_master_socket, _network_server_bind_ip, 0, false)) return; - /* Only send once in the 450 game-days (about 15 minutes) */ - if (_network_advertise_retries == 0) { - if ( (_network_last_advertise_date + ADVERTISE_NORMAL_INTERVAL) > _date) - return; + if (_network_need_advertise) { + _network_need_advertise = false; _network_advertise_retries = ADVERTISE_RETRY_TIMES; - } + } else { + /* Only send once every ADVERTISE_NORMAL_INTERVAL ticks */ + if (_network_advertise_retries == 0) { + if ((_network_last_advertise_frame + ADVERTISE_NORMAL_INTERVAL) > _frame_counter) + return; + _network_advertise_retries = ADVERTISE_RETRY_TIMES; + } - if ( (_network_last_advertise_date + ADVERTISE_RETRY_INTERVAL) > _date) - return; + if ((_network_last_advertise_frame + ADVERTISE_RETRY_INTERVAL) > _frame_counter) + return; + } _network_advertise_retries--; - _network_last_advertise_date = _date; + _network_last_advertise_frame = _frame_counter; /* Find somewhere to send */ out_addr.sin_family = AF_INET; -- cgit v1.2.3-70-g09d2