]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - netconn.c
add a "freeslots" field to the host cache
[xonotic/darkplaces.git] / netconn.c
index a37505ca0128ca366eca08c410d3d56cf9e6831b..8513eafe2c62fd9b4b884cc3ef4a3f1b0e0cd069 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define DPMASTER_PORT 27950
 
 // note this defaults on for dedicated servers, off for listen servers
-cvar_t sv_public = {0, "sv_public", "0", "advertises this server on the master server (so that players can find it in the server browser)"};
+cvar_t sv_public = {0, "sv_public", "0", "1: advertises this server on the master server (so that players can find it in the server browser); 0: allow direct queries only; -1: do not respond to direct queries; -2: do not allow anyone to connect"};
 static cvar_t sv_heartbeatperiod = {CVAR_SAVE, "sv_heartbeatperiod", "120", "how often to send heartbeat in seconds (only used if sv_public is 1)"};
 
 static cvar_t sv_masters [] =
@@ -38,8 +38,7 @@ static cvar_t sv_masters [] =
        {CVAR_SAVE, "sv_master4", "", "user-chosen master server 4"},
        {0, "sv_masterextra1", "ghdigital.com", "default master server 1 (admin: LordHavoc)"}, // admin: LordHavoc
        {0, "sv_masterextra2", "dpmaster.deathmask.net", "default master server 2 (admin: Willis)"}, // admin: Willis
-       {0, "sv_masterextra3", "12.166.196.192", "default master server 3 (admin: Venim)"}, // admin: Venim
-       {0, "sv_masterextra4", "excalibur.nvg.ntnu.no", "default master server 4 (admin: tChr)"}, // admin: tChr
+       {0, "sv_masterextra3", "excalibur.nvg.ntnu.no", "default master server 3 (admin: tChr)"}, // admin: tChr
        {0, NULL, NULL, NULL}
 };
 
@@ -71,13 +70,14 @@ sizebuf_t net_message;
 static unsigned char net_message_buf[NET_MAXMESSAGE];
 
 cvar_t net_messagetimeout = {0, "net_messagetimeout","300", "drops players who have not sent any packets for this many seconds"};
-cvar_t net_messagerejointimeout = {0, "net_messagerejointimeout","10", "give a player this much time in seconds to rejoin and continue playing (not losing frags and such)"};
 cvar_t net_connecttimeout = {0, "net_connecttimeout","10", "after requesting a connection, the client must reply within this many seconds or be dropped (cuts down on connect floods)"};
+cvar_t net_connectfloodblockingtimeout = {0, "net_connectfloodblockingtimeout", "5", "when a connection packet is received, it will block all future connect packets from that IP address for this many seconds (cuts down on connect floods)"};
 cvar_t hostname = {CVAR_SAVE, "hostname", "UNNAMED", "server message to show in server browser"};
 cvar_t developer_networking = {0, "developer_networking", "0", "prints all received and sent packets (recommended only for debugging)"};
 
 cvar_t cl_netlocalping = {0, "cl_netlocalping","0", "lags local loopback connection by this much ping time (useful to play more fairly on your own server with people with higher pings)"};
-static cvar_t cl_netpacketloss = {0, "cl_netpacketloss","0", "drops this percentage of packets (incoming and outgoing), useful for testing network protocol robustness (effects failing to start, sounds failing to play, etc)"};
+static cvar_t cl_netpacketloss_send = {0, "cl_netpacketloss_send","0", "drops this percentage of outgoing packets, useful for testing network protocol robustness (jerky movement, prediction errors, etc)"};
+static cvar_t cl_netpacketloss_receive = {0, "cl_netpacketloss_receive","0", "drops this percentage of incoming packets, useful for testing network protocol robustness (jerky movement, effects failing to start, sounds failing to play, etc)"};
 static cvar_t net_slist_queriespersecond = {0, "net_slist_queriespersecond", "20", "how many server information requests to send per second"};
 static cvar_t net_slist_queriesperframe = {0, "net_slist_queriesperframe", "4", "maximum number of server information requests to send each rendered frame (guards against low framerates causing problems)"};
 static cvar_t net_slist_timeout = {0, "net_slist_timeout", "4", "how long to listen for a server information response before giving up"};
@@ -126,6 +126,10 @@ cvar_t sv_netport = {0, "port", "26000", "server port for players to connect to"
 cvar_t net_address = {0, "net_address", "0.0.0.0", "network address to open ports on"};
 //cvar_t net_netaddress_ipv6 = {0, "net_address_ipv6", "[0:0:0:0:0:0:0:0]", "network address to open ipv6 ports on"};
 
+char net_extresponse[NET_EXTRESPONSE_MAX][1400];
+int net_extresponse_count = 0;
+int net_extresponse_last = 0;
+
 // ServerList interface
 serverlist_mask_t serverlist_andmasks[SERVERLIST_ANDMASKCOUNT];
 serverlist_mask_t serverlist_ormasks[SERVERLIST_ORMASKCOUNT];
@@ -181,6 +185,15 @@ static qboolean _ServerList_Entry_Compare( serverlist_entry_t *A, serverlist_ent
                case SLIF_NUMPLAYERS:
                        result = A->info.numplayers - B->info.numplayers;
                        break;
+               case SLIF_NUMBOTS:
+                       result = A->info.numbots - B->info.numbots;
+                       break;
+               case SLIF_NUMHUMANS:
+                       result = A->info.numhumans - B->info.numhumans;
+                       break;
+               case SLIF_FREESLOTS:
+                       result = A->info.freeslots - B->info.freeslots;
+                       break;
                case SLIF_PROTOCOL:
                        result = A->info.protocol - B->info.protocol;
                        break;
@@ -282,6 +295,12 @@ static qboolean _ServerList_Entry_Mask( serverlist_mask_t *mask, serverlist_info
                return false;
        if( !_ServerList_CompareInt( info->numplayers, mask->tests[SLIF_NUMPLAYERS], mask->info.numplayers ) )
                return false;
+       if( !_ServerList_CompareInt( info->numbots, mask->tests[SLIF_NUMBOTS], mask->info.numbots ) )
+               return false;
+       if( !_ServerList_CompareInt( info->numhumans, mask->tests[SLIF_NUMHUMANS], mask->info.numhumans ) )
+               return false;
+       if( !_ServerList_CompareInt( info->freeslots, mask->tests[SLIF_FREESLOTS], mask->info.freeslots ) )
+               return false;
        if( !_ServerList_CompareInt( info->protocol, mask->tests[SLIF_PROTOCOL], mask->info.protocol ))
                return false;
        if( *mask->info.cname
@@ -379,8 +398,15 @@ void ServerList_RebuildViewList(void)
 
 void ServerList_ResetMasks(void)
 {
+       int i;
+
        memset( &serverlist_andmasks, 0, sizeof( serverlist_andmasks ) );
        memset( &serverlist_ormasks, 0, sizeof( serverlist_ormasks ) );
+       // numbots needs to be compared to -1 to always succeed
+       for(i = 0; i < SERVERLIST_ANDMASKCOUNT; ++i)
+               serverlist_andmasks[i].info.numbots = -1;
+       for(i = 0; i < SERVERLIST_ORMASKCOUNT; ++i)
+               serverlist_ormasks[i].info.numbots = -1;
 }
 
 #if 0
@@ -401,8 +427,7 @@ static void _ServerList_Test(void)
 
 void ServerList_QueryList(qboolean querydp, qboolean queryqw)
 {
-       //masterquerytime = realtime;
-       masterquerytime = Sys_DoubleTime();
+       masterquerytime = realtime;
        masterquerycount = 0;
        masterreplycount = 0;
        serverquerycount = 0;
@@ -424,9 +449,9 @@ int NetConn_Read(lhnetsocket_t *mysocket, void *data, int maxlength, lhnetaddres
        int i;
        if (length == 0)
                return 0;
-       if (cl_netpacketloss.integer)
+       if (cl_netpacketloss_receive.integer)
                for (i = 0;i < cl_numsockets;i++)
-                       if (cl_sockets[i] == mysocket && (rand() % 100) < cl_netpacketloss.integer)
+                       if (cl_sockets[i] == mysocket && (rand() % 100) < cl_netpacketloss_receive.integer)
                                return 0;
        if (developer_networking.integer)
        {
@@ -448,9 +473,9 @@ int NetConn_Write(lhnetsocket_t *mysocket, const void *data, int length, const l
 {
        int ret;
        int i;
-       if (cl_netpacketloss.integer)
+       if (cl_netpacketloss_send.integer)
                for (i = 0;i < cl_numsockets;i++)
-                       if (cl_sockets[i] == mysocket && (rand() % 100) < cl_netpacketloss.integer)
+                       if (cl_sockets[i] == mysocket && (rand() % 100) < cl_netpacketloss_send.integer)
                                return length;
        ret = LHNET_Write(mysocket, data, length, peeraddress);
        if (developer_networking.integer)
@@ -470,8 +495,31 @@ int NetConn_WriteString(lhnetsocket_t *mysocket, const char *string, const lhnet
        return NetConn_Write(mysocket, string, (int)strlen(string), peeraddress);
 }
 
-int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolversion_t protocol)
+qboolean NetConn_CanSend(netconn_t *conn)
+{
+       conn->outgoing_packetcounter = (conn->outgoing_packetcounter + 1) % NETGRAPH_PACKETS;
+       conn->outgoing_unreliablesize[conn->outgoing_packetcounter] = NETGRAPH_NOPACKET;
+       conn->outgoing_reliablesize[conn->outgoing_packetcounter] = NETGRAPH_NOPACKET;
+       conn->outgoing_acksize[conn->outgoing_packetcounter] = NETGRAPH_NOPACKET;
+       if (realtime > conn->cleartime)
+               return true;
+       else
+       {
+               conn->outgoing_unreliablesize[conn->outgoing_packetcounter] = NETGRAPH_CHOKEDPACKET;
+               return false;
+       }
+}
+
+int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolversion_t protocol, int rate, qboolean quakesignon_suppressreliables)
 {
+       int totallen = 0;
+
+       // if this packet was supposedly choked, but we find ourselves sending one
+       // anyway, make sure the size counting starts at zero
+       // (this mostly happens on level changes and disconnects and such)
+       if (conn->outgoing_unreliablesize[conn->outgoing_packetcounter] == NETGRAPH_CHOKEDPACKET)
+               conn->outgoing_unreliablesize[conn->outgoing_packetcounter] = NETGRAPH_NOPACKET;
+
        if (protocol == PROTOCOL_QUAKEWORLD)
        {
                int packetLen;
@@ -512,16 +560,22 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers
                        Con_Printf ("NetConn_SendUnreliableMessage: reliable message too big %u\n", data->cursize);
                        return -1;
                }
+
+               conn->outgoing_unreliablesize[conn->outgoing_packetcounter] += packetLen;
+
                // add the reliable message if there is one
                if (sendreliable)
                {
+                       conn->outgoing_reliablesize[conn->outgoing_packetcounter] += conn->sendMessageLength;
                        memcpy(sendbuffer + packetLen, conn->sendMessage, conn->sendMessageLength);
                        packetLen += conn->sendMessageLength;
                        conn->qw.last_reliable_sequence = conn->qw.outgoing_sequence;
                }
+
                // add the unreliable message if possible
                if (packetLen + data->cursize <= 1400)
                {
+                       conn->outgoing_unreliablesize[conn->outgoing_packetcounter] += data->cursize;
                        memcpy(sendbuffer + packetLen, data->data, data->cursize);
                        packetLen += data->cursize;
                }
@@ -531,10 +585,7 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers
                packetsSent++;
                unreliableMessagesSent++;
 
-               // delay later packets to obey rate limit
-               conn->qw.cleartime = max(conn->qw.cleartime, realtime) + packetLen * conn->qw.rate;
-
-               return 0;
+               totallen += packetLen + 28;
        }
        else
        {
@@ -564,19 +615,23 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers
                        header[1] = BigLong(conn->nq.sendSequence - 1);
                        memcpy(sendbuffer + NET_HEADERSIZE, conn->sendMessage, dataLen);
 
+                       conn->outgoing_reliablesize[conn->outgoing_packetcounter] += packetLen;
+
                        if (NetConn_Write(conn->mysocket, (void *)&sendbuffer, packetLen, &conn->peeraddress) == (int)packetLen)
                        {
                                conn->lastSendTime = realtime;
                                packetsReSent++;
                        }
+
+                       totallen += packetLen + 28;
                }
 
                // if we have a new reliable message to send, do so
-               if (!conn->sendMessageLength && conn->message.cursize)
+               if (!conn->sendMessageLength && conn->message.cursize && !quakesignon_suppressreliables)
                {
                        if (conn->message.cursize > (int)sizeof(conn->sendMessage))
                        {
-                               Con_Printf("NetConn_SendUnreliableMessage: reliable message too big (%u > %u)\n", conn->message.cursize, sizeof(conn->sendMessage));
+                               Con_Printf("NetConn_SendUnreliableMessage: reliable message too big (%u > %u)\n", conn->message.cursize, (int)sizeof(conn->sendMessage));
                                conn->message.overflowed = true;
                                return -1;
                        }
@@ -611,11 +666,15 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers
 
                        conn->nq.sendSequence++;
 
+                       conn->outgoing_reliablesize[conn->outgoing_packetcounter] += packetLen;
+
                        NetConn_Write(conn->mysocket, (void *)&sendbuffer, packetLen, &conn->peeraddress);
 
                        conn->lastSendTime = realtime;
                        packetsSent++;
                        reliableMessagesSent++;
+
+                       totallen += packetLen + 28;
                }
 
                // if we have an unreliable message to send, do so
@@ -636,13 +695,35 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers
 
                        conn->nq.unreliableSendSequence++;
 
+                       conn->outgoing_unreliablesize[conn->outgoing_packetcounter] += packetLen;
+
                        NetConn_Write(conn->mysocket, (void *)&sendbuffer, packetLen, &conn->peeraddress);
 
                        packetsSent++;
                        unreliableMessagesSent++;
+
+                       totallen += packetLen + 28;
                }
-               return 0;
        }
+
+       // delay later packets to obey rate limit
+       if (conn->cleartime < realtime - 0.1)
+               conn->cleartime = realtime - 0.1;
+       conn->cleartime = conn->cleartime + (double)totallen / (double)rate;
+       if (conn->cleartime < realtime)
+               conn->cleartime = realtime;
+
+       return 0;
+}
+
+qboolean NetConn_HaveClientPorts(void)
+{
+       return !!cl_numsockets;
+}
+
+qboolean NetConn_HaveServerPorts(void)
+{
+       return !!sv_numsockets;
 }
 
 void NetConn_CloseClientPorts(void)
@@ -787,10 +868,15 @@ netconn_t *NetConn_Open(lhnetsocket_t *mysocket, lhnetaddress_t *peeraddress)
        return conn;
 }
 
+void NetConn_ClearConnectFlood(lhnetaddress_t *peeraddress);
 void NetConn_Close(netconn_t *conn)
 {
        netconn_t *c;
        // remove connection from list
+
+       // allow the client to reconnect immediately
+       NetConn_ClearConnectFlood(&(conn->peeraddress));
+
        if (conn == netconn_list)
                netconn_list = conn->next;
        else
@@ -841,8 +927,9 @@ void NetConn_UpdateSockets(void)
        }
 }
 
-static int NetConn_ReceivedMessage(netconn_t *conn, unsigned char *data, int length, protocolversion_t protocol)
+static int NetConn_ReceivedMessage(netconn_t *conn, unsigned char *data, int length, protocolversion_t protocol, double newtimeout)
 {
+       int originallength = length;
        if (length < 8)
                return 0;
 
@@ -876,15 +963,26 @@ static int NetConn_ReceivedMessage(netconn_t *conn, unsigned char *data, int len
                sequence_ack &= ~(1<<31);
                if (sequence <= conn->qw.incoming_sequence)
                {
-                       Con_DPrint("Got a stale datagram\n");
+                       //Con_DPrint("Got a stale datagram\n");
                        return 0;
                }
                count = sequence - (conn->qw.incoming_sequence + 1);
                if (count > 0)
                {
                        droppedDatagrams += count;
-                       Con_DPrintf("Dropped %u datagram(s)\n", count);
+                       //Con_DPrintf("Dropped %u datagram(s)\n", count);
+                       while (count--)
+                       {
+                               conn->incoming_packetcounter = (conn->incoming_packetcounter + 1) % NETGRAPH_PACKETS;
+                               conn->incoming_unreliablesize[conn->incoming_packetcounter] = NETGRAPH_LOSTPACKET;
+                               conn->incoming_reliablesize[conn->incoming_packetcounter] = NETGRAPH_NOPACKET;
+                               conn->incoming_acksize[conn->incoming_packetcounter] = NETGRAPH_NOPACKET;
+                       }
                }
+               conn->incoming_packetcounter = (conn->incoming_packetcounter + 1) % NETGRAPH_PACKETS;
+               conn->incoming_unreliablesize[conn->incoming_packetcounter] = originallength;
+               conn->incoming_reliablesize[conn->incoming_packetcounter] = NETGRAPH_NOPACKET;
+               conn->incoming_acksize[conn->incoming_packetcounter] = NETGRAPH_NOPACKET;
                if (reliable_ack == conn->qw.reliable_sequence)
                {
                        // received, now we will be able to send another reliable message
@@ -899,7 +997,7 @@ static int NetConn_ReceivedMessage(netconn_t *conn, unsigned char *data, int len
                if (reliable_message)
                        conn->qw.incoming_reliable_sequence ^= 1;
                conn->lastMessageTime = realtime;
-               conn->timeout = realtime + net_messagetimeout.value;
+               conn->timeout = realtime + newtimeout;
                unreliableMessagesReceived++;
                SZ_Clear(&net_message);
                SZ_Write(&net_message, data, length);
@@ -931,11 +1029,22 @@ static int NetConn_ReceivedMessage(netconn_t *conn, unsigned char *data, int len
                                        {
                                                count = sequence - conn->nq.unreliableReceiveSequence;
                                                droppedDatagrams += count;
-                                               Con_DPrintf("Dropped %u datagram(s)\n", count);
+                                               //Con_DPrintf("Dropped %u datagram(s)\n", count);
+                                               while (count--)
+                                               {
+                                                       conn->incoming_packetcounter = (conn->incoming_packetcounter + 1) % NETGRAPH_PACKETS;
+                                                       conn->incoming_unreliablesize[conn->incoming_packetcounter] = NETGRAPH_LOSTPACKET;
+                                                       conn->incoming_reliablesize[conn->incoming_packetcounter] = NETGRAPH_NOPACKET;
+                                                       conn->incoming_acksize[conn->incoming_packetcounter] = NETGRAPH_NOPACKET;
+                                               }
                                        }
+                                       conn->incoming_packetcounter = (conn->incoming_packetcounter + 1) % NETGRAPH_PACKETS;
+                                       conn->incoming_unreliablesize[conn->incoming_packetcounter] = originallength;
+                                       conn->incoming_reliablesize[conn->incoming_packetcounter] = NETGRAPH_NOPACKET;
+                                       conn->incoming_acksize[conn->incoming_packetcounter] = NETGRAPH_NOPACKET;
                                        conn->nq.unreliableReceiveSequence = sequence + 1;
                                        conn->lastMessageTime = realtime;
-                                       conn->timeout = realtime + net_messagetimeout.value;
+                                       conn->timeout = realtime + newtimeout;
                                        unreliableMessagesReceived++;
                                        if (length > 0)
                                        {
@@ -945,12 +1054,13 @@ static int NetConn_ReceivedMessage(netconn_t *conn, unsigned char *data, int len
                                                return 2;
                                        }
                                }
-                               else
-                                       Con_DPrint("Got a stale datagram\n");
+                               //else
+                               //      Con_DPrint("Got a stale datagram\n");
                                return 1;
                        }
                        else if (flags & NETFLAG_ACK)
                        {
+                               conn->incoming_acksize[conn->incoming_packetcounter] += originallength;
                                if (sequence == (conn->nq.sendSequence - 1))
                                {
                                        if (sequence == conn->nq.ackSequence)
@@ -959,7 +1069,7 @@ static int NetConn_ReceivedMessage(netconn_t *conn, unsigned char *data, int len
                                                if (conn->nq.ackSequence != conn->nq.sendSequence)
                                                        Con_DPrint("ack sequencing error\n");
                                                conn->lastMessageTime = realtime;
-                                               conn->timeout = realtime + net_messagetimeout.value;
+                                               conn->timeout = realtime + newtimeout;
                                                if (conn->sendMessageLength > MAX_PACKETFRAGMENT)
                                                {
                                                        unsigned int packetLen;
@@ -999,23 +1109,25 @@ static int NetConn_ReceivedMessage(netconn_t *conn, unsigned char *data, int len
                                                else
                                                        conn->sendMessageLength = 0;
                                        }
-                                       else
-                                               Con_DPrint("Duplicate ACK received\n");
+                                       //else
+                                       //      Con_DPrint("Duplicate ACK received\n");
                                }
-                               else
-                                       Con_DPrint("Stale ACK received\n");
+                               //else
+                               //      Con_DPrint("Stale ACK received\n");
                                return 1;
                        }
                        else if (flags & NETFLAG_DATA)
                        {
                                unsigned int temppacket[2];
+                               conn->incoming_reliablesize[conn->incoming_packetcounter] += originallength;
+                               conn->outgoing_acksize[conn->outgoing_packetcounter] += 8;
                                temppacket[0] = BigLong(8 | NETFLAG_ACK);
                                temppacket[1] = BigLong(sequence);
                                NetConn_Write(conn->mysocket, (unsigned char *)temppacket, 8, &conn->peeraddress);
                                if (sequence == conn->nq.receiveSequence)
                                {
                                        conn->lastMessageTime = realtime;
-                                       conn->timeout = realtime + net_messagetimeout.value;
+                                       conn->timeout = realtime + newtimeout;
                                        conn->nq.receiveSequence++;
                                        if( conn->receiveMessageLength + length <= (int)sizeof( conn->receiveMessage ) ) {
                                                memcpy(conn->receiveMessage + conn->receiveMessageLength, data, length);
@@ -1067,8 +1179,23 @@ void NetConn_ConnectionEstablished(lhnetsocket_t *mysocket, lhnetaddress_t *peer
        cls.state = ca_connected;
        cls.signon = 0;                         // need all the signon messages before playing
        cls.protocol = initialprotocol;
+       // reset move sequence numbering on this new connection
+       cls.movesequence = 1;
+       cls.servermovesequence = 0;
        if (cls.protocol == PROTOCOL_QUAKEWORLD)
                Cmd_ForwardStringToServer("new");
+       if (cls.protocol == PROTOCOL_QUAKE)
+       {
+               // write a keepalive (clc_nop) as it seems to greatly improve the
+               // chances of connecting to a netquake server
+               sizebuf_t msg;
+               unsigned char buf[4];
+               memset(&msg, 0, sizeof(msg));
+               msg.data = buf;
+               msg.maxsize = sizeof(buf);
+               MSG_WriteChar(&msg, clc_nop);
+               NetConn_SendUnreliableMessage(cls.netcon, &msg, cls.protocol, 10000, false);
+       }
 }
 
 int NetConn_IsLocalGame(void)
@@ -1099,8 +1226,7 @@ static int NetConn_ClientParsePacket_ServerList_ProcessReply(const char *address
                // store the data the engine cares about (address and ping)
                strlcpy(serverlist_cache[serverlist_cachecount].info.cname, addressstring, sizeof(serverlist_cache[serverlist_cachecount].info.cname));
                serverlist_cache[serverlist_cachecount].info.ping = 100000;
-               //serverlist_cache[serverlist_cachecount].querytime = realtime;
-               serverlist_cache[serverlist_cachecount].querytime = Sys_DoubleTime();
+               serverlist_cache[serverlist_cachecount].querytime = realtime;
                // if not in the slist menu we should print the server to console
                if (serverlist_consoleoutput)
                        Con_Printf("querying %s\n", addressstring);
@@ -1109,7 +1235,7 @@ static int NetConn_ClientParsePacket_ServerList_ProcessReply(const char *address
        // if this is the first reply from this server, count it as having replied
        if (serverlist_cache[n].info.ping == 100000)
                serverreplycount++;
-       pingtime = (int)((Sys_DoubleTime() - serverlist_cache[n].querytime) * 1000.0 + 0.5);
+       pingtime = (int)((realtime - serverlist_cache[n].querytime) * 1000.0 + 0.5);
        pingtime = bound(0, pingtime, 9999);
        // update the ping
        serverlist_cache[n].info.ping = min(serverlist_cache[n].info.ping, pingtime);
@@ -1121,7 +1247,7 @@ static void NetConn_ClientParsePacket_ServerList_UpdateCache(int n)
 {
        serverlist_info_t *info = &serverlist_cache[n].info;
        // update description strings for engine menu and console output
-       dpsnprintf(serverlist_cache[n].line1, sizeof(serverlist_cache[n].line1), "^%c%5d^7 ^%c%3u^7/%3u %-65.65s", info->ping >= 300 ? '1' : (info->ping >= 200 ? '3' : '7'), (int)info->ping, ((info->numplayers > 0 && info->numplayers < info->maxplayers) ? (info->numplayers >= 4 ? '7' : '3') : '1'), info->numplayers, info->maxplayers, info->name);
+       dpsnprintf(serverlist_cache[n].line1, sizeof(serverlist_cache[n].line1), "^%c%5d^7 ^%c%3u^7/%3u %-65.65s", info->ping >= 300 ? '1' : (info->ping >= 200 ? '3' : '7'), (int)info->ping, ((info->numhumans > 0 && info->numhumans < info->maxplayers) ? (info->numhumans >= 4 ? '7' : '3') : '1'), info->numplayers, info->maxplayers, info->name);
        dpsnprintf(serverlist_cache[n].line2, sizeof(serverlist_cache[n].line2), "^4%-21.21s %-19.19s ^%c%-17.17s^4 %-20.20s", info->cname, info->game, (info->gameversion != gameversion.integer) ? '1' : '4', info->mod, info->map);
        if (serverlist_cache[n].query == SQS_QUERIED)
                ServerList_ViewList_Remove(&serverlist_cache[n]);
@@ -1207,14 +1333,26 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                                return true;
 
                        info = &serverlist_cache[n].info;
-                       if ((s = SearchInfostring(string, "gamename"     )) != NULL) strlcpy(info->game, s, sizeof (info->game));else info->game[0] = 0;
-                       if ((s = SearchInfostring(string, "modname"      )) != NULL) strlcpy(info->mod , s, sizeof (info->mod ));else info->mod[0]  = 0;
-                       if ((s = SearchInfostring(string, "mapname"      )) != NULL) strlcpy(info->map , s, sizeof (info->map ));else info->map[0]  = 0;
-                       if ((s = SearchInfostring(string, "hostname"     )) != NULL) strlcpy(info->name, s, sizeof (info->name));else info->name[0] = 0;
-                       if ((s = SearchInfostring(string, "protocol"     )) != NULL) info->protocol = atoi(s);else info->protocol = -1;
-                       if ((s = SearchInfostring(string, "clients"      )) != NULL) info->numplayers = atoi(s);else info->numplayers = 0;
-                       if ((s = SearchInfostring(string, "sv_maxclients")) != NULL) info->maxplayers = atoi(s);else info->maxplayers  = 0;
-                       if ((s = SearchInfostring(string, "gameversion"  )) != NULL) info->gameversion = atoi(s);else info->gameversion = 0;
+                       info->game[0] = 0;
+                       info->mod[0]  = 0;
+                       info->map[0]  = 0;
+                       info->name[0] = 0;
+                       info->protocol = -1;
+                       info->numplayers = 0;
+                       info->numbots = -1;
+                       info->maxplayers  = 0;
+                       info->gameversion = 0;
+                       if ((s = SearchInfostring(string, "gamename"     )) != NULL) strlcpy(info->game, s, sizeof (info->game));
+                       if ((s = SearchInfostring(string, "modname"      )) != NULL) strlcpy(info->mod , s, sizeof (info->mod ));
+                       if ((s = SearchInfostring(string, "mapname"      )) != NULL) strlcpy(info->map , s, sizeof (info->map ));
+                       if ((s = SearchInfostring(string, "hostname"     )) != NULL) strlcpy(info->name, s, sizeof (info->name));
+                       if ((s = SearchInfostring(string, "protocol"     )) != NULL) info->protocol = atoi(s);
+                       if ((s = SearchInfostring(string, "clients"      )) != NULL) info->numplayers = atoi(s);
+                       if ((s = SearchInfostring(string, "bots"         )) != NULL) info->numbots = atoi(s);
+                       if ((s = SearchInfostring(string, "sv_maxclients")) != NULL) info->maxplayers = atoi(s);
+                       if ((s = SearchInfostring(string, "gameversion"  )) != NULL) info->gameversion = atoi(s);
+                       info->numhumans = info->numplayers - max(0, info->numbots);
+                       info->freeslots = info->maxplayers - info->numplayers;
 
                        NetConn_ClientParsePacket_ServerList_UpdateCache(n);
 
@@ -1310,6 +1448,15 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                        serverlist_querywaittime = realtime + 3;
                        return true;
                }
+               if (!strncmp(string, "extResponse ", 12))
+               {
+                       ++net_extresponse_count;
+                       if(net_extresponse_count > NET_EXTRESPONSE_MAX)
+                               net_extresponse_count = NET_EXTRESPONSE_MAX;
+                       net_extresponse_last = (net_extresponse_last + 1) % NET_EXTRESPONSE_MAX;
+                       dpsnprintf(net_extresponse[net_extresponse_last], sizeof(net_extresponse[net_extresponse_last]), "'%s' %s", addressstring2, string + 12);
+                       return true;
+               }
                if (!strncmp(string, "ping", 4))
                {
                        if (developer.integer >= 10)
@@ -1394,7 +1541,7 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                return true;
        }
        // quakeworld ingame packet
-       if (fromserver && cls.protocol == PROTOCOL_QUAKEWORLD && length >= 8 && (ret = NetConn_ReceivedMessage(cls.netcon, data, length, cls.protocol)) == 2)
+       if (fromserver && cls.protocol == PROTOCOL_QUAKEWORLD && length >= 8 && (ret = NetConn_ReceivedMessage(cls.netcon, data, length, cls.protocol, net_messagetimeout.value)) == 2)
        {
                ret = 0;
                CL_ParseServerMessage();
@@ -1406,9 +1553,12 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                int n;
                serverlist_info_t *info;
 
-               c = data[4];
-               data += 5;
-               length -= 5;
+               data += 4;
+               length -= 4;
+               SZ_Clear(&net_message);
+               SZ_Write(&net_message, data, length);
+               MSG_BeginReading();
+               c = MSG_ReadByte();
                switch (c)
                {
                case CCREP_ACCEPT:
@@ -1418,16 +1568,10 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                        {
                                lhnetaddress_t clientportaddress;
                                clientportaddress = *peeraddress;
-                               if (length >= 4)
-                               {
-                                       unsigned int port = (data[0] << 0) | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
-                                       data += 4;
-                                       length -= 4;
-                                       LHNETADDRESS_SetPort(&clientportaddress, port);
-                               }
-                               M_Update_Return_Reason("Accepted");
+                               LHNETADDRESS_SetPort(&clientportaddress, MSG_ReadLong());
                                // update the server IP in the userinfo (QW servers expect this, and it is used by the reconnect command)
                                InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "*ip", addressstring2);
+                               M_Update_Return_Reason("Accepted");
                                NetConn_ConnectionEstablished(mysocket, &clientportaddress, PROTOCOL_QUAKE);
                        }
                        break;
@@ -1435,9 +1579,8 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                        if (developer.integer >= 10)
                                Con_Printf("Datagram_ParseConnectionless: received CCREP_REJECT from %s.\n", addressstring2);
                        cls.connect_trying = false;
-                       M_Update_Return_Reason((char *)data);
+                       M_Update_Return_Reason((char *)MSG_ReadString());
                        break;
-               // TODO: fix this code so that lan searches for quake servers will work
                case CCREP_SERVER_INFO:
                        if (developer.integer >= 10)
                                Con_Printf("Datagram_ParseConnectionless: received CCREP_SERVER_INFO from %s.\n", addressstring2);
@@ -1474,12 +1617,13 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                default:
                        break;
                }
+               SZ_Clear(&net_message);
                // we may not have liked the packet, but it was a valid control
                // packet, so we're done processing this packet now
                return true;
        }
        ret = 0;
-       if (fromserver && length >= (int)NET_HEADERSIZE && (ret = NetConn_ReceivedMessage(cls.netcon, data, length, cls.protocol)) == 2)
+       if (fromserver && length >= (int)NET_HEADERSIZE && (ret = NetConn_ReceivedMessage(cls.netcon, data, length, cls.protocol, net_messagetimeout.value)) == 2)
                CL_ParseServerMessage();
        return ret;
 }
@@ -1545,8 +1689,7 @@ void NetConn_QueryQueueFrame(void)
                                        NetConn_WriteString(cl_sockets[socket], "\377\377\377\377getinfo", &address);
                        }
 
-                       //entry->querytime = realtime;
-                       entry->querytime = Sys_DoubleTime();
+                       entry->querytime = realtime;
                        entry->querycounter++;
 
                        // if not in the slist menu we should print the server to console
@@ -1596,7 +1739,7 @@ void NetConn_ClientFrame(void)
                while (cl_sockets[i] && (length = NetConn_Read(cl_sockets[i], readbuffer, sizeof(readbuffer), &peeraddress)) > 0)
                        NetConn_ClientParsePacket(cl_sockets[i], readbuffer, length, &peeraddress);
        NetConn_QueryQueueFrame();
-       if (cls.netcon && realtime > cls.netcon->timeout)
+       if (cls.netcon && realtime > cls.netcon->timeout && !sv.active)
        {
                Con_Print("Connection timed out\n");
                CL_Disconnect();
@@ -1630,24 +1773,30 @@ static void NetConn_BuildChallengeString(char *buffer, int bufferlength)
 
 static qboolean NetConn_BuildStatusResponse(const char* challenge, char* out_msg, size_t out_size, qboolean fullstatus)
 {
-       unsigned int nb_clients = 0, i;
+       unsigned int nb_clients = 0, nb_bots = 0, i;
        int length;
 
        // How many clients are there?
        for (i = 0;i < (unsigned int)svs.maxclients;i++)
+       {
                if (svs.clients[i].active)
+               {
                        nb_clients++;
+                       if (!svs.clients[i].netconnection)
+                               nb_bots++;
+               }
+       }
 
        // TODO: we should add more information for the full status string
        length = dpsnprintf(out_msg, out_size,
                                                "\377\377\377\377%s\x0A"
                                                "\\gamename\\%s\\modname\\%s\\gameversion\\%d\\sv_maxclients\\%d"
-                                               "\\clients\\%d\\mapname\\%s\\hostname\\%s\\protocol\\%d"
+                                               "\\clients\\%d\\bots\\%d\\mapname\\%s\\hostname\\%s\\protocol\\%d"
                                                "%s%s"
                                                "%s",
                                                fullstatus ? "statusResponse" : "infoResponse",
                                                gamename, com_modname, gameversion.integer, svs.maxclients,
-                                               nb_clients, sv.name, hostname.string, NET_PROTOCOL_VERSION,
+                                               nb_clients, nb_bots, sv.name, hostname.string, NET_PROTOCOL_VERSION,
                                                challenge ? "\\challenge\\" : "", challenge ? challenge : "",
                                                fullstatus ? "\n" : "");
 
@@ -1668,7 +1817,7 @@ static qboolean NetConn_BuildStatusResponse(const char* challenge, char* out_msg
                        client_t *cl = &svs.clients[i];
                        if (cl->active)
                        {
-                               int nameind, cleanind;
+                               int nameind, cleanind, pingvalue;
                                char curchar;
                                char cleanname [sizeof(cl->name)];
 
@@ -1686,9 +1835,14 @@ static qboolean NetConn_BuildStatusResponse(const char* challenge, char* out_msg
                                        }
                                } while (curchar != '\0');
 
+                               pingvalue = (int)(cl->ping * 1000.0f);
+                               if(cl->netconnection)
+                                       pingvalue = bound(1, pingvalue, 9999);
+                               else
+                                       pingvalue = 0;
                                length = dpsnprintf(ptr, left, "%d %d \"%s\"\n",
                                                                        cl->frags,
-                                                                       (int)(cl->ping * 1000.0f),
+                                                                       pingvalue,
                                                                        cleanname);
                                if(length < 0)
                                        return false;
@@ -1701,14 +1855,74 @@ static qboolean NetConn_BuildStatusResponse(const char* challenge, char* out_msg
        return true;
 }
 
+static qboolean NetConn_PreventConnectFlood(lhnetaddress_t *peeraddress)
+{
+       int floodslotnum, bestfloodslotnum;
+       double bestfloodtime;
+       lhnetaddress_t noportpeeraddress;
+       // see if this is a connect flood
+       noportpeeraddress = *peeraddress;
+       LHNETADDRESS_SetPort(&noportpeeraddress, 0);
+       bestfloodslotnum = 0;
+       bestfloodtime = sv.connectfloodaddresses[bestfloodslotnum].lasttime;
+       for (floodslotnum = 0;floodslotnum < MAX_CONNECTFLOODADDRESSES;floodslotnum++)
+       {
+               if (bestfloodtime >= sv.connectfloodaddresses[floodslotnum].lasttime)
+               {
+                       bestfloodtime = sv.connectfloodaddresses[floodslotnum].lasttime;
+                       bestfloodslotnum = floodslotnum;
+               }
+               if (sv.connectfloodaddresses[floodslotnum].lasttime && LHNETADDRESS_Compare(&noportpeeraddress, &sv.connectfloodaddresses[floodslotnum].address) == 0)
+               {
+                       // this address matches an ongoing flood address
+                       if (realtime < sv.connectfloodaddresses[floodslotnum].lasttime + net_connectfloodblockingtimeout.value)
+                       {
+                               // renew the ban on this address so it does not expire
+                               // until the flood has subsided
+                               sv.connectfloodaddresses[floodslotnum].lasttime = realtime;
+                               //Con_Printf("Flood detected!\n");
+                               return true;
+                       }
+                       // the flood appears to have subsided, so allow this
+                       bestfloodslotnum = floodslotnum; // reuse the same slot
+                       break;
+               }
+       }
+       // begin a new timeout on this address
+       sv.connectfloodaddresses[bestfloodslotnum].address = noportpeeraddress;
+       sv.connectfloodaddresses[bestfloodslotnum].lasttime = realtime;
+       //Con_Printf("Flood detection initiated!\n");
+       return false;
+}
+
+void NetConn_ClearConnectFlood(lhnetaddress_t *peeraddress)
+{
+       int floodslotnum;
+       lhnetaddress_t noportpeeraddress;
+       // see if this is a connect flood
+       noportpeeraddress = *peeraddress;
+       LHNETADDRESS_SetPort(&noportpeeraddress, 0);
+       for (floodslotnum = 0;floodslotnum < MAX_CONNECTFLOODADDRESSES;floodslotnum++)
+       {
+               if (sv.connectfloodaddresses[floodslotnum].lasttime && LHNETADDRESS_Compare(&noportpeeraddress, &sv.connectfloodaddresses[floodslotnum].address) == 0)
+               {
+                       // this address matches an ongoing flood address
+                       // remove the ban
+                       sv.connectfloodaddresses[floodslotnum].address.addresstype = LHNETADDRESSTYPE_NONE;
+                       sv.connectfloodaddresses[floodslotnum].lasttime = 0;
+                       //Con_Printf("Flood cleared!\n");
+               }
+       }
+}
+
 extern void SV_SendServerinfo (client_t *client);
 static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *data, int length, lhnetaddress_t *peeraddress)
 {
        int i, ret, clientnum, best;
        double besttime;
        client_t *client;
-       netconn_t *conn;
        char *s, *string, response[1400], addressstring2[128], stringbuf[16384];
+       qboolean islocal = (LHNETADDRESS_GetAddressType(peeraddress) == LHNETADDRESSTYPE_LOOP);
 
        if (!sv.active)
                return false;
@@ -1742,7 +1956,7 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                        Com_HexDumpToConsole(data, length);
                }
 
-               if (length >= 12 && !memcmp(string, "getchallenge", 12))
+               if (length >= 12 && !memcmp(string, "getchallenge", 12) && (islocal || sv_public.integer > -2))
                {
                        for (i = 0, best = 0, besttime = realtime;i < MAX_CHALLENGES;i++)
                        {
@@ -1764,88 +1978,90 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                        NetConn_WriteString(mysocket, va("\377\377\377\377challenge %s", challenge[i].string), peeraddress);
                        return true;
                }
-               if (length > 8 && !memcmp(string, "connect\\", 8))
+               if (length > 8 && !memcmp(string, "connect\\", 8) && (islocal || sv_public.integer > -2))
                {
                        string += 7;
                        length -= 7;
-                       if ((s = SearchInfostring(string, "challenge")))
+
+                       if (!(s = SearchInfostring(string, "challenge")))
+                               return true;
+                       // validate the challenge
+                       for (i = 0;i < MAX_CHALLENGES;i++)
+                               if (!LHNETADDRESS_Compare(peeraddress, &challenge[i].address) && !strcmp(challenge[i].string, s))
+                                       break;
+                       // if the challenge is not recognized, drop the packet
+                       if (i == MAX_CHALLENGES)
+                               return true;
+
+                       // check engine protocol
+                       if (strcmp(SearchInfostring(string, "protocol"), "darkplaces 3"))
                        {
-                               // validate the challenge
-                               for (i = 0;i < MAX_CHALLENGES;i++)
-                                       if (!LHNETADDRESS_Compare(peeraddress, &challenge[i].address) && !strcmp(challenge[i].string, s))
-                                               break;
-                               if (i < MAX_CHALLENGES)
+                               if (developer.integer >= 10)
+                                       Con_Printf("Datagram_ParseConnectionless: sending \"reject Wrong game protocol.\" to %s.\n", addressstring2);
+                               NetConn_WriteString(mysocket, "\377\377\377\377reject Wrong game protocol.", peeraddress);
+                               return true;
+                       }
+
+                       // see if this is a duplicate connection request or a disconnected
+                       // client who is rejoining to the same client slot
+                       for (clientnum = 0, client = svs.clients;clientnum < svs.maxclients;clientnum++, client++)
+                       {
+                               if (client->netconnection && LHNETADDRESS_Compare(peeraddress, &client->netconnection->peeraddress) == 0)
                                {
-                                       // check engine protocol
-                                       if (strcmp(SearchInfostring(string, "protocol"), "darkplaces 3"))
+                                       // this is a known client...
+                                       if (client->spawned)
                                        {
+                                               // client crashed and is coming back,
+                                               // keep their stuff intact
                                                if (developer.integer >= 10)
-                                                       Con_Printf("Datagram_ParseConnectionless: sending \"reject Wrong game protocol.\" to %s.\n", addressstring2);
-                                               NetConn_WriteString(mysocket, "\377\377\377\377reject Wrong game protocol.", peeraddress);
+                                                       Con_Printf("Datagram_ParseConnectionless: sending \"accept\" to %s.\n", addressstring2);
+                                               NetConn_WriteString(mysocket, "\377\377\377\377accept", peeraddress);
+                                               SV_VM_Begin();
+                                               SV_SendServerinfo(client);
+                                               SV_VM_End();
                                        }
                                        else
                                        {
-                                               // see if this is a duplicate connection request
-                                               for (clientnum = 0, client = svs.clients;clientnum < svs.maxclients;clientnum++, client++)
-                                                       if (client->netconnection && LHNETADDRESS_Compare(peeraddress, &client->netconnection->peeraddress) == 0)
-                                                               break;
-                                               if (clientnum < svs.maxclients && realtime - client->connecttime < net_messagerejointimeout.value)
-                                               {
-                                                       // client is still trying to connect,
-                                                       // so we send a duplicate reply
-                                                       if (developer.integer >= 10)
-                                                               Con_Printf("Datagram_ParseConnectionless: sending duplicate accept to %s.\n", addressstring2);
-                                                       NetConn_WriteString(mysocket, "\377\377\377\377accept", peeraddress);
-                                               }
-#if 0
-                                               else if (clientnum < svs.maxclients)
-                                               {
-                                                       if (realtime - client->netconnection->lastMessageTime >= net_messagerejointimeout.value)
-                                                       {
-                                                               // client crashed and is coming back, keep their stuff intact
-                                                               SV_SendServerinfo(client);
-                                                               //host_client = client;
-                                                               //SV_DropClient (true);
-                                                       }
-                                                       // else ignore them
-                                               }
-#endif
-                                               else
-                                               {
-                                                       // this is a new client, find a slot
-                                                       for (clientnum = 0, client = svs.clients;clientnum < svs.maxclients;clientnum++, client++)
-                                                               if (!client->active)
-                                                                       break;
-                                                       if (clientnum < svs.maxclients)
-                                                       {
-                                                               // prepare the client struct
-                                                               if ((conn = NetConn_Open(mysocket, peeraddress)))
-                                                               {
-                                                                       // allocated connection
-                                                                       if (developer.integer >= 10)
-                                                                               Con_Printf("Datagram_ParseConnectionless: sending \"accept\" to %s.\n", conn->address);
-                                                                       NetConn_WriteString(mysocket, "\377\377\377\377accept", peeraddress);
-                                                                       // now set up the client
-                                                                       SV_VM_Begin();
-                                                                       SV_ConnectClient(clientnum, conn);
-                                                                       SV_VM_End();
-                                                                       NetConn_Heartbeat(1);
-                                                               }
-                                                       }
-                                                       else
-                                                       {
-                                                               // server is full
-                                                               if (developer.integer >= 10)
-                                                                       Con_Printf("Datagram_ParseConnectionless: sending \"reject Server is full.\" to %s.\n", addressstring2);
-                                                               NetConn_WriteString(mysocket, "\377\377\377\377reject Server is full.", peeraddress);
-                                                       }
-                                               }
+                                               // client is still trying to connect,
+                                               // so we send a duplicate reply
+                                               if (developer.integer >= 10)
+                                                       Con_Printf("Datagram_ParseConnectionless: sending duplicate accept to %s.\n", addressstring2);
+                                               NetConn_WriteString(mysocket, "\377\377\377\377accept", peeraddress);
                                        }
+                                       return true;
+                               }
+                       }
+
+                       if (NetConn_PreventConnectFlood(peeraddress))
+                               return true;
+
+                       // find an empty client slot for this new client
+                       for (clientnum = 0, client = svs.clients;clientnum < svs.maxclients;clientnum++, client++)
+                       {
+                               netconn_t *conn;
+                               if (!client->active && (conn = NetConn_Open(mysocket, peeraddress)))
+                               {
+                                       // allocated connection
+                                       if (developer.integer >= 10)
+                                               Con_Printf("Datagram_ParseConnectionless: sending \"accept\" to %s.\n", conn->address);
+                                       NetConn_WriteString(mysocket, "\377\377\377\377accept", peeraddress);
+                                       // now set up the client
+                                       SV_VM_Begin();
+                                       SV_ConnectClient(clientnum, conn);
+                                       SV_VM_End();
+                                       NetConn_Heartbeat(1);
+                                       return true;
                                }
                        }
+
+                       // no empty slots found - server is full
+                       if (developer.integer >= 10)
+                               Con_Printf("Datagram_ParseConnectionless: sending \"reject Server is full.\" to %s.\n", addressstring2);
+                       NetConn_WriteString(mysocket, "\377\377\377\377reject Server is full.", peeraddress);
+
                        return true;
                }
-               if (length >= 7 && !memcmp(string, "getinfo", 7))
+               if (length >= 7 && !memcmp(string, "getinfo", 7) && (islocal || sv_public.integer > -1))
                {
                        const char *challenge = NULL;
 
@@ -1861,7 +2077,7 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                        }
                        return true;
                }
-               if (length >= 9 && !memcmp(string, "getstatus", 9))
+               if (length >= 9 && !memcmp(string, "getstatus", 9) && (islocal || sv_public.integer > -1))
                {
                        const char *challenge = NULL;
 
@@ -1881,18 +2097,36 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                {
                        int i;
                        char *s = string + 5;
+                       char *endpos = string + length + 1; // one behind the NUL, so adding strlen+1 will eventually reach it
                        char password[64];
                        for (i = 0;*s > ' ';s++)
                                if (i < (int)sizeof(password) - 1)
                                        password[i++] = *s;
+                       if(*s <= ' ' && s != endpos) // skip leading ugly space
+                               ++s;
                        password[i] = 0;
                        if (password[0] > ' ' && !strcmp(rcon_password.string, password))
                        {
                                // looks like a legitimate rcon command with the correct password
-                               Con_Printf("server received rcon command from %s:\n%s\n", host_client ? host_client->name : addressstring2, s);
+                               char *s_ptr = s;
+                               Con_Printf("server received rcon command from %s:\n", host_client ? host_client->name : addressstring2);
+                               while(s_ptr != endpos)
+                               {
+                                       size_t l = strlen(s_ptr);
+                                       if(l)
+                                               Con_Printf(" %s;", s_ptr);
+                                       s_ptr += l + 1;
+                               }
+                               Con_Printf("\n");
                                rcon_redirect = true;
                                rcon_redirect_bufferpos = 0;
-                               Cmd_ExecuteString(s, src_command);
+                               while(s != endpos)
+                               {
+                                       size_t l = strlen(s);
+                                       if(l)
+                                               Cmd_ExecuteString(s, src_command);
+                                       s += l + 1;
+                               }
                                rcon_redirect_buffer[rcon_redirect_bufferpos] = 0;
                                rcon_redirect = false;
                                // print resulting text to client
@@ -1930,213 +2164,229 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                // we're done processing this packet now
                return true;
        }
-       // LordHavoc: disabled netquake control packet support in server
-#if 0
+       // netquake control packets, supported for compatibility only, and only
+       // when running game protocols that are normally served via this connection
+       // protocol
+       // (this protects more modern protocols against being used for
+       //  Quake packet flood Denial Of Service attacks)
+       if (length >= 5 && (i = BigLong(*((int *)data))) && (i & (~NETFLAG_LENGTH_MASK)) == (int)NETFLAG_CTL && (i & NETFLAG_LENGTH_MASK) == length && (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_NEHAHRABJP || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3 || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3))
        {
-               int c, control;
-               // netquake control packets, supported for compatibility only
-               if (length >= 5 && (control = BigLong(*((int *)data))) && (control & (~NETFLAG_LENGTH_MASK)) == (int)NETFLAG_CTL && (control & NETFLAG_LENGTH_MASK) == length)
+               int c;
+               int protocolnumber;
+               const char *protocolname;
+               data += 4;
+               length -= 4;
+               SZ_Clear(&net_message);
+               SZ_Write(&net_message, data, length);
+               MSG_BeginReading();
+               c = MSG_ReadByte();
+               switch (c)
                {
-                       c = data[4];
-                       data += 5;
-                       length -= 5;
-                       switch (c)
+               case CCREQ_CONNECT:
+                       if (developer.integer >= 10)
+                               Con_Printf("Datagram_ParseConnectionless: received CCREQ_CONNECT from %s.\n", addressstring2);
+                       if(!islocal && sv_public.integer <= -2)
+                               break;
+
+                       protocolname = MSG_ReadString();
+                       protocolnumber = MSG_ReadByte();
+                       if (strcmp(protocolname, "QUAKE") || protocolnumber != NET_PROTOCOL_VERSION)
                        {
-                       case CCREQ_CONNECT:
                                if (developer.integer >= 10)
-                                       Con_Printf("Datagram_ParseConnectionless: received CCREQ_CONNECT from %s.\n", addressstring2);
-                               if (length >= (int)strlen("QUAKE") + 1 + 1)
+                                       Con_Printf("Datagram_ParseConnectionless: sending CCREP_REJECT \"Incompatible version.\" to %s.\n", addressstring2);
+                               SZ_Clear(&net_message);
+                               // save space for the header, filled in later
+                               MSG_WriteLong(&net_message, 0);
+                               MSG_WriteByte(&net_message, CCREP_REJECT);
+                               MSG_WriteString(&net_message, "Incompatible version.\n");
+                               *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
+                               NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
+                               SZ_Clear(&net_message);
+                               break;
+                       }
+
+                       // see if this connect request comes from a known client
+                       for (clientnum = 0, client = svs.clients;clientnum < svs.maxclients;clientnum++, client++)
+                       {
+                               if (client->netconnection && LHNETADDRESS_Compare(peeraddress, &client->netconnection->peeraddress) == 0)
                                {
-                                       if (memcmp(data, "QUAKE", strlen("QUAKE") + 1) != 0 || (int)data[strlen("QUAKE") + 1] != NET_PROTOCOL_VERSION)
-                                       {
-                                               if (developer.integer >= 10)
-                                                       Con_Printf("Datagram_ParseConnectionless: sending CCREP_REJECT \"Incompatible version.\" to %s.\n", addressstring2);
-                                               SZ_Clear(&net_message);
-                                               // save space for the header, filled in later
-                                               MSG_WriteLong(&net_message, 0);
-                                               MSG_WriteByte(&net_message, CCREP_REJECT);
-                                               MSG_WriteString(&net_message, "Incompatible version.\n");
-                                               *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
-                                               NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
-                                               SZ_Clear(&net_message);
-                                       }
-                                       else
+                                       // this is either a duplicate connection request
+                                       // or coming back from a timeout
+                                       // (if so, keep their stuff intact)
+
+                                       // send a reply
+                                       if (developer.integer >= 10)
+                                               Con_Printf("Datagram_ParseConnectionless: sending duplicate CCREP_ACCEPT to %s.\n", addressstring2);
+                                       SZ_Clear(&net_message);
+                                       // save space for the header, filled in later
+                                       MSG_WriteLong(&net_message, 0);
+                                       MSG_WriteByte(&net_message, CCREP_ACCEPT);
+                                       MSG_WriteLong(&net_message, LHNETADDRESS_GetPort(LHNET_AddressFromSocket(client->netconnection->mysocket)));
+                                       *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
+                                       NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
+                                       SZ_Clear(&net_message);
+
+                                       // if client is already spawned, re-send the
+                                       // serverinfo message as they'll need it to play
+                                       if (client->spawned)
                                        {
-                                               // see if this is a duplicate connection request
-                                               for (clientnum = 0, client = svs.clients;clientnum < svs.maxclients;clientnum++, client++)
-                                                       if (client->netconnection && LHNETADDRESS_Compare(peeraddress, &client->netconnection->peeraddress) == 0)
-                                                               break;
-                                               if (clientnum < svs.maxclients)
-                                               {
-                                                       // duplicate connection request
-                                                       if (realtime - client->connecttime < 2.0)
-                                                       {
-                                                               // client is still trying to connect,
-                                                               // so we send a duplicate reply
-                                                               if (developer.integer >= 10)
-                                                                       Con_Printf("Datagram_ParseConnectionless: sending duplicate CCREP_ACCEPT to %s.\n", addressstring2);
-                                                               SZ_Clear(&net_message);
-                                                               // save space for the header, filled in later
-                                                               MSG_WriteLong(&net_message, 0);
-                                                               MSG_WriteByte(&net_message, CCREP_ACCEPT);
-                                                               MSG_WriteLong(&net_message, LHNETADDRESS_GetPort(LHNET_AddressFromSocket(client->netconnection->mysocket)));
-                                                               *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
-                                                               NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
-                                                               SZ_Clear(&net_message);
-                                                       }
-#if 0
-                                                       else if (realtime - client->netconnection->lastMessageTime >= net_messagerejointimeout.value)
-                                                       {
-                                                               SV_SendServerinfo(client);
-                                                               // the old client hasn't sent us anything
-                                                               // in quite a while, so kick off and let
-                                                               // the retry take care of it...
-                                                               //host_client = client;
-                                                               //SV_DropClient (true);
-                                                       }
-#endif
-                                               }
-                                               else
-                                               {
-                                                       // this is a new client, find a slot
-                                                       for (clientnum = 0, client = svs.clients;clientnum < svs.maxclients;clientnum++, client++)
-                                                               if (!client->active)
-                                                                       break;
-                                                       if (clientnum < svs.maxclients && (client->netconnection = conn = NetConn_Open(mysocket, peeraddress)) != NULL)
-                                                       {
-                                                               // connect to the client
-                                                               // everything is allocated, just fill in the details
-                                                               strlcpy (conn->address, addressstring2, sizeof (conn->address));
-                                                               if (developer.integer >= 10)
-                                                                       Con_Printf("Datagram_ParseConnectionless: sending CCREP_ACCEPT to %s.\n", addressstring2);
-                                                               // send back the info about the server connection
-                                                               SZ_Clear(&net_message);
-                                                               // save space for the header, filled in later
-                                                               MSG_WriteLong(&net_message, 0);
-                                                               MSG_WriteByte(&net_message, CCREP_ACCEPT);
-                                                               MSG_WriteLong(&net_message, LHNETADDRESS_GetPort(LHNET_AddressFromSocket(conn->mysocket)));
-                                                               *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
-                                                               NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
-                                                               SZ_Clear(&net_message);
-                                                               // now set up the client struct
-                                                               SV_VM_Begin();
-                                                               SV_ConnectClient(clientnum, conn);
-                                                               SV_VM_End();
-                                                               NetConn_Heartbeat(1);
-                                                       }
-                                                       else
-                                                       {
-                                                               if (developer.integer >= 10)
-                                                                       Con_Printf("Datagram_ParseConnectionless: sending CCREP_REJECT \"Server is full.\" to %s.\n", addressstring2);
-                                                               // no room; try to let player know
-                                                               SZ_Clear(&net_message);
-                                                               // save space for the header, filled in later
-                                                               MSG_WriteLong(&net_message, 0);
-                                                               MSG_WriteByte(&net_message, CCREP_REJECT);
-                                                               MSG_WriteString(&net_message, "Server is full.\n");
-                                                               *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
-                                                               NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
-                                                               SZ_Clear(&net_message);
-                                                       }
-                                               }
+                                               SV_VM_Begin();
+                                               SV_SendServerinfo(client);
+                                               SV_VM_End();
                                        }
+                                       return true;
                                }
+                       }
+
+                       // this is a new client, check for connection flood
+                       if (NetConn_PreventConnectFlood(peeraddress))
                                break;
-#if 0
-                       case CCREQ_SERVER_INFO:
-                               if (developer.integer >= 10)
-                                       Con_Printf("Datagram_ParseConnectionless: received CCREQ_SERVER_INFO from %s.\n", addressstring2);
-                               if (sv.active && !strcmp(MSG_ReadString(), "QUAKE"))
+
+                       // find a slot for the new client
+                       for (clientnum = 0, client = svs.clients;clientnum < svs.maxclients;clientnum++, client++)
+                       {
+                               netconn_t *conn;
+                               if (!client->active && (client->netconnection = conn = NetConn_Open(mysocket, peeraddress)) != NULL)
                                {
+                                       // connect to the client
+                                       // everything is allocated, just fill in the details
+                                       strlcpy (conn->address, addressstring2, sizeof (conn->address));
                                        if (developer.integer >= 10)
-                                               Con_Printf("Datagram_ParseConnectionless: sending CCREP_SERVER_INFO to %s.\n", addressstring2);
+                                               Con_Printf("Datagram_ParseConnectionless: sending CCREP_ACCEPT to %s.\n", addressstring2);
+                                       // send back the info about the server connection
                                        SZ_Clear(&net_message);
                                        // save space for the header, filled in later
                                        MSG_WriteLong(&net_message, 0);
-                                       MSG_WriteByte(&net_message, CCREP_SERVER_INFO);
-                                       UDP_GetSocketAddr(UDP_acceptSock, &newaddr);
-                                       MSG_WriteString(&net_message, UDP_AddrToString(&newaddr));
-                                       MSG_WriteString(&net_message, hostname.string);
-                                       MSG_WriteString(&net_message, sv.name);
-                                       MSG_WriteByte(&net_message, net_activeconnections);
-                                       MSG_WriteByte(&net_message, svs.maxclients);
-                                       MSG_WriteByte(&net_message, NET_PROTOCOL_VERSION);
+                                       MSG_WriteByte(&net_message, CCREP_ACCEPT);
+                                       MSG_WriteLong(&net_message, LHNETADDRESS_GetPort(LHNET_AddressFromSocket(conn->mysocket)));
                                        *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
                                        NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
                                        SZ_Clear(&net_message);
+                                       // now set up the client struct
+                                       SV_VM_Begin();
+                                       SV_ConnectClient(clientnum, conn);
+                                       SV_VM_End();
+                                       NetConn_Heartbeat(1);
+                                       return true;
                                }
-                               break;
-                       case CCREQ_PLAYER_INFO:
-                               if (developer.integer >= 10)
-                                       Con_Printf("Datagram_ParseConnectionless: received CCREQ_PLAYER_INFO from %s.\n", addressstring2);
-                               if (sv.active)
-                               {
-                                       int playerNumber, activeNumber, clientNumber;
-                                       client_t *client;
+                       }
 
-                                       playerNumber = MSG_ReadByte();
-                                       activeNumber = -1;
-                                       for (clientNumber = 0, client = svs.clients; clientNumber < svs.maxclients; clientNumber++, client++)
-                                               if (client->active && ++activeNumber == playerNumber)
-                                                       break;
-                                       if (clientNumber != svs.maxclients)
-                                       {
-                                               SZ_Clear(&net_message);
-                                               // save space for the header, filled in later
-                                               MSG_WriteLong(&net_message, 0);
-                                               MSG_WriteByte(&net_message, CCREP_PLAYER_INFO);
-                                               MSG_WriteByte(&net_message, playerNumber);
-                                               MSG_WriteString(&net_message, client->name);
-                                               MSG_WriteLong(&net_message, client->colors);
-                                               MSG_WriteLong(&net_message, (int)client->edict->fields.server->frags);
-                                               MSG_WriteLong(&net_message, (int)(realtime - client->connecttime));
-                                               MSG_WriteString(&net_message, client->netconnection ? client->netconnection->address : "botclient");
-                                               *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
-                                               NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
-                                               SZ_Clear(&net_message);
-                                       }
-                               }
+                       if (developer.integer >= 10)
+                               Con_Printf("Datagram_ParseConnectionless: sending CCREP_REJECT \"Server is full.\" to %s.\n", addressstring2);
+                       // no room; try to let player know
+                       SZ_Clear(&net_message);
+                       // save space for the header, filled in later
+                       MSG_WriteLong(&net_message, 0);
+                       MSG_WriteByte(&net_message, CCREP_REJECT);
+                       MSG_WriteString(&net_message, "Server is full.\n");
+                       *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
+                       NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
+                       SZ_Clear(&net_message);
+                       break;
+               case CCREQ_SERVER_INFO:
+                       if (developer.integer >= 10)
+                               Con_Printf("Datagram_ParseConnectionless: received CCREQ_SERVER_INFO from %s.\n", addressstring2);
+                       if(!islocal && sv_public.integer <= -1)
                                break;
-                       case CCREQ_RULE_INFO:
+                       if (sv.active && !strcmp(MSG_ReadString(), "QUAKE"))
+                       {
+                               int numclients;
+                               char myaddressstring[128];
                                if (developer.integer >= 10)
-                                       Con_Printf("Datagram_ParseConnectionless: received CCREQ_RULE_INFO from %s.\n", addressstring2);
-                               if (sv.active)
-                               {
-                                       char *prevCvarName;
-                                       cvar_t *var;
-
-                                       // find the search start location
-                                       prevCvarName = MSG_ReadString();
-                                       var = Cvar_FindVarAfter(prevCvarName, CVAR_NOTIFY);
+                                       Con_Printf("Datagram_ParseConnectionless: sending CCREP_SERVER_INFO to %s.\n", addressstring2);
+                               SZ_Clear(&net_message);
+                               // save space for the header, filled in later
+                               MSG_WriteLong(&net_message, 0);
+                               MSG_WriteByte(&net_message, CCREP_SERVER_INFO);
+                               LHNETADDRESS_ToString(LHNET_AddressFromSocket(mysocket), myaddressstring, sizeof(myaddressstring), true);
+                               MSG_WriteString(&net_message, myaddressstring);
+                               MSG_WriteString(&net_message, hostname.string);
+                               MSG_WriteString(&net_message, sv.name);
+                               // How many clients are there?
+                               for (i = 0, numclients = 0;i < svs.maxclients;i++)
+                                       if (svs.clients[i].active)
+                                               numclients++;
+                               MSG_WriteByte(&net_message, numclients);
+                               MSG_WriteByte(&net_message, svs.maxclients);
+                               MSG_WriteByte(&net_message, NET_PROTOCOL_VERSION);
+                               *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
+                               NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
+                               SZ_Clear(&net_message);
+                       }
+                       break;
+               case CCREQ_PLAYER_INFO:
+                       if (developer.integer >= 10)
+                               Con_Printf("Datagram_ParseConnectionless: received CCREQ_PLAYER_INFO from %s.\n", addressstring2);
+                       if(!islocal && sv_public.integer <= -1)
+                               break;
+                       if (sv.active)
+                       {
+                               int playerNumber, activeNumber, clientNumber;
+                               client_t *client;
 
-                                       // send the response
+                               playerNumber = MSG_ReadByte();
+                               activeNumber = -1;
+                               for (clientNumber = 0, client = svs.clients; clientNumber < svs.maxclients; clientNumber++, client++)
+                                       if (client->active && ++activeNumber == playerNumber)
+                                               break;
+                               if (clientNumber != svs.maxclients)
+                               {
                                        SZ_Clear(&net_message);
                                        // save space for the header, filled in later
                                        MSG_WriteLong(&net_message, 0);
-                                       MSG_WriteByte(&net_message, CCREP_RULE_INFO);
-                                       if (var)
-                                       {
-                                               MSG_WriteString(&net_message, var->name);
-                                               MSG_WriteString(&net_message, var->string);
-                                       }
+                                       MSG_WriteByte(&net_message, CCREP_PLAYER_INFO);
+                                       MSG_WriteByte(&net_message, playerNumber);
+                                       MSG_WriteString(&net_message, client->name);
+                                       MSG_WriteLong(&net_message, client->colors);
+                                       MSG_WriteLong(&net_message, client->frags);
+                                       MSG_WriteLong(&net_message, (int)(realtime - client->connecttime));
+                                       MSG_WriteString(&net_message, client->netconnection ? client->netconnection->address : "botclient");
                                        *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
                                        NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
                                        SZ_Clear(&net_message);
                                }
+                       }
+                       break;
+               case CCREQ_RULE_INFO:
+                       if (developer.integer >= 10)
+                               Con_Printf("Datagram_ParseConnectionless: received CCREQ_RULE_INFO from %s.\n", addressstring2);
+                       if(!islocal && sv_public.integer <= -1)
                                break;
-#endif
-                       default:
-                               break;
+                       if (sv.active)
+                       {
+                               char *prevCvarName;
+                               cvar_t *var;
+
+                               // find the search start location
+                               prevCvarName = MSG_ReadString();
+                               var = Cvar_FindVarAfter(prevCvarName, CVAR_NOTIFY);
+
+                               // send the response
+                               SZ_Clear(&net_message);
+                               // save space for the header, filled in later
+                               MSG_WriteLong(&net_message, 0);
+                               MSG_WriteByte(&net_message, CCREP_RULE_INFO);
+                               if (var)
+                               {
+                                       MSG_WriteString(&net_message, var->name);
+                                       MSG_WriteString(&net_message, var->string);
+                               }
+                               *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
+                               NetConn_Write(mysocket, net_message.data, net_message.cursize, peeraddress);
+                               SZ_Clear(&net_message);
                        }
-                       // we may not have liked the packet, but it was a valid control
-                       // packet, so we're done processing this packet now
-                       return true;
+                       break;
+               default:
+                       break;
                }
+               SZ_Clear(&net_message);
+               // we may not have liked the packet, but it was a valid control
+               // packet, so we're done processing this packet now
+               return true;
        }
-#endif
        if (host_client)
        {
-               if ((ret = NetConn_ReceivedMessage(host_client->netconnection, data, length, sv.protocol)) == 2)
+               if ((ret = NetConn_ReceivedMessage(host_client->netconnection, data, length, sv.protocol, host_client->spawned ? net_messagetimeout.value : net_connecttimeout.value)) == 2)
                {
                        SV_VM_Begin();
                        SV_ReadClientMessage();
@@ -2167,6 +2417,11 @@ void NetConn_ServerFrame(void)
        }
 }
 
+void NetConn_SleepMicroseconds(int microseconds)
+{
+       LHNET_SleepUntilPacket_Microseconds(microseconds);
+}
+
 void NetConn_QueryMasters(qboolean querydp, qboolean queryqw)
 {
        int i;
@@ -2280,7 +2535,7 @@ void NetConn_Heartbeat(int priority)
 
        // make advertising optional and don't advertise singleplayer games, and
        // only send a heartbeat as often as the admin wants
-       if (sv.active && sv_public.integer && svs.maxclients >= 2 && (priority > 1 || realtime > nextheartbeattime))
+       if (sv.active && sv_public.integer > 0 && svs.maxclients >= 2 && (priority > 1 || realtime > nextheartbeattime))
        {
                nextheartbeattime = realtime + sv_heartbeatperiod.value;
                for (masternum = 0;sv_masters[masternum].name;masternum++)
@@ -2364,10 +2619,11 @@ void NetConn_Init(void)
        Cvar_RegisterVariable(&net_slist_timeout);
        Cvar_RegisterVariable(&net_slist_maxtries);
        Cvar_RegisterVariable(&net_messagetimeout);
-       Cvar_RegisterVariable(&net_messagerejointimeout);
        Cvar_RegisterVariable(&net_connecttimeout);
+       Cvar_RegisterVariable(&net_connectfloodblockingtimeout);
        Cvar_RegisterVariable(&cl_netlocalping);
-       Cvar_RegisterVariable(&cl_netpacketloss);
+       Cvar_RegisterVariable(&cl_netpacketloss_send);
+       Cvar_RegisterVariable(&cl_netpacketloss_receive);
        Cvar_RegisterVariable(&hostname);
        Cvar_RegisterVariable(&developer_networking);
        Cvar_RegisterVariable(&cl_netport);
@@ -2384,7 +2640,7 @@ void NetConn_Init(void)
        {
                if (LHNETADDRESS_FromString(&tempaddress, com_argv[i + 1], 0) == 1)
                {
-                       Con_Printf("-ip option used, setting net_address to \"%s\"\n");
+                       Con_Printf("-ip option used, setting net_address to \"%s\"\n", com_argv[i + 1]);
                        Cvar_SetQuick(&net_address, com_argv[i + 1]);
                }
                else