From 548a919ea379a3b9d1d9e41cf4dad6b4779fd3e6 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sun, 10 Feb 2008 21:54:52 +0000 Subject: merged 0.3.4 changes to trunk --- src/mastersrv/mastersrv.cpp | 28 ++++++++++++++++++++++++++++ src/mastersrv/mastersrv.h | 3 +++ 2 files changed, 31 insertions(+) (limited to 'src/mastersrv') diff --git a/src/mastersrv/mastersrv.cpp b/src/mastersrv/mastersrv.cpp index aa799919..b83330a5 100644 --- a/src/mastersrv/mastersrv.cpp +++ b/src/mastersrv/mastersrv.cpp @@ -27,6 +27,14 @@ static struct packet_data unsigned char header[sizeof(SERVERBROWSE_LIST)]; NETADDR4 servers[MAX_SERVERS]; } data; + +static struct count_packet_data +{ + unsigned char header[sizeof(SERVERBROWSE_COUNT)]; + unsigned char high; + unsigned char low; +} count_data; + static int64 server_expire[MAX_SERVERS]; static int num_servers = 0; @@ -41,6 +49,9 @@ void send_ok(NETADDR4 *addr) p.flags = PACKETFLAG_CONNLESS; p.data_size = sizeof(SERVERBROWSE_FWOK); p.data = SERVERBROWSE_FWOK; + + // send on both to be sure + net_checker.send(&p); net_op.send(&p); } @@ -183,6 +194,8 @@ int main(int argc, char **argv) // TODO: check socket for errors mem_copy(data.header, SERVERBROWSE_LIST, sizeof(SERVERBROWSE_LIST)); + mem_copy(count_data.header, SERVERBROWSE_COUNT, sizeof(SERVERBROWSE_COUNT)); + dbg_msg("mastersrv", "started"); while(1) @@ -207,6 +220,21 @@ int main(int argc, char **argv) // add it add_checkserver(&packet.address, &alt); } + else if(packet.data_size == sizeof(SERVERBROWSE_GETCOUNT) && + memcmp(packet.data, SERVERBROWSE_GETCOUNT, sizeof(SERVERBROWSE_GETCOUNT)) == 0) + { + dbg_msg("mastersrv", "count requested, responding with %d", num_servers); + + NETPACKET p; + p.client_id = -1; + p.address = packet.address; + p.flags = PACKETFLAG_CONNLESS; + p.data_size = sizeof(count_data); + p.data = &count_data; + count_data.high = (num_servers>>8)&0xff; + count_data.low = num_servers&0xff; + net_op.send(&p); + } else if(packet.data_size == sizeof(SERVERBROWSE_GETLIST) && memcmp(packet.data, SERVERBROWSE_GETLIST, sizeof(SERVERBROWSE_GETLIST)) == 0) { diff --git a/src/mastersrv/mastersrv.h b/src/mastersrv/mastersrv.h index 1de5b9ef..b5347914 100644 --- a/src/mastersrv/mastersrv.h +++ b/src/mastersrv/mastersrv.h @@ -10,6 +10,9 @@ static const unsigned char SERVERBROWSE_HEARTBEAT[] = {255, 255, 255, 255, 'b', static const unsigned char SERVERBROWSE_GETLIST[] = {255, 255, 255, 255, 'r', 'e', 'q', 't'}; static const unsigned char SERVERBROWSE_LIST[] = {255, 255, 255, 255, 'l', 'i', 's', 't'}; +static const unsigned char SERVERBROWSE_GETCOUNT[] = {255, 255, 255, 255, 'c', 'o', 'u', 'n'}; +static const unsigned char SERVERBROWSE_COUNT[] = {255, 255, 255, 255, 's', 'i', 'z', 'e'}; + static const unsigned char SERVERBROWSE_GETINFO[] = {255, 255, 255, 255, 'g', 'i', 'e', 'f'}; static const unsigned char SERVERBROWSE_INFO[] = {255, 255, 255, 255, 'i', 'n', 'f', 'o'}; -- cgit 1.4.1