]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - netconn.c
edu2p game: change 2nd game dir to 'edu2'
[xonotic/darkplaces.git] / netconn.c
index 7784d310827fed8bb9ffadb3c3ecf9e926bec2e7..27f16c1d8c5f21f6547e733b2c08689a7a3111ba 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -73,6 +73,7 @@ static cvar_t cl_netpacketloss_receive = {0, "cl_netpacketloss_receive","0", "dr
 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"};
+static cvar_t net_slist_pause = {0, "net_slist_pause", "0", "when set to 1, the server list won't update until it is set back to 0"};
 static cvar_t net_slist_maxtries = {0, "net_slist_maxtries", "3", "how many times to ask the same server for information (more times gives better ping reports but takes longer)"};
 
 static cvar_t gameversion = {0, "gameversion", "0", "version of game data (mod-specific), when client and server gameversion mismatch in the server browser the server is shown as incompatible"};
@@ -99,6 +100,7 @@ int serverreplycount = 0;
 
 // this is only false if there are still servers left to query
 static qboolean serverlist_querysleep = true;
+static qboolean serverlist_paused = false;
 // this is pushed a second or two ahead of realtime whenever a master server
 // reply is received, to avoid issuing queries while master replies are still
 // flooding in (which would make a mess of the ping times)
@@ -195,16 +197,16 @@ static qboolean _ServerList_Entry_Compare( serverlist_entry_t *A, serverlist_ent
                        result = strcmp( B->info.cname, A->info.cname );
                        break;
                case SLIF_GAME:
-                       result = strcmp( B->info.game, A->info.game );
+                       result = strcasecmp( B->info.game, A->info.game );
                        break;
                case SLIF_MAP:
-                       result = strcmp( B->info.map, A->info.map );
+                       result = strcasecmp( B->info.map, A->info.map );
                        break;
                case SLIF_MOD:
-                       result = strcmp( B->info.mod, A->info.mod );
+                       result = strcasecmp( B->info.mod, A->info.mod );
                        break;
                case SLIF_NAME:
-                       result = strcmp( B->info.name, A->info.name );
+                       result = strcasecmp( B->info.name, A->info.name );
                        break;
                default:
                        Con_DPrint( "_ServerList_Entry_Compare: Bad serverlist_sortbyfield!\n" );
@@ -565,18 +567,18 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers
                        sendreliable = true;
                }
                // outgoing unreliable packet number, and outgoing reliable packet number (0 or 1)
-               *((int *)(sendbuffer + 0)) = LittleLong((unsigned int)conn->qw.outgoing_sequence | ((unsigned int)sendreliable<<31));
+               *((int *)(sendbuffer + 0)) = LittleLong((unsigned int)conn->outgoing_unreliable_sequence | ((unsigned int)sendreliable<<31));
                // last received unreliable packet number, and last received reliable packet number (0 or 1)
                *((int *)(sendbuffer + 4)) = LittleLong((unsigned int)conn->qw.incoming_sequence | ((unsigned int)conn->qw.incoming_reliable_sequence<<31));
                packetLen = 8;
-               conn->qw.outgoing_sequence++;
+               conn->outgoing_unreliable_sequence++;
                // client sends qport in every packet
                if (conn == cls.netcon)
                {
                        *((short *)(sendbuffer + 8)) = LittleShort(cls.qw_qport);
                        packetLen += 2;
                        // also update cls.qw_outgoing_sequence
-                       cls.qw_outgoing_sequence = conn->qw.outgoing_sequence;
+                       cls.qw_outgoing_sequence = conn->outgoing_unreliable_sequence;
                }
                if (packetLen + (sendreliable ? conn->sendMessageLength : 0) > 1400)
                {
@@ -592,7 +594,7 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers
                        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;
+                       conn->qw.last_reliable_sequence = conn->outgoing_unreliable_sequence;
                }
 
                // add the unreliable message if possible
@@ -713,10 +715,10 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers
 
                        header = (unsigned int *)sendbuffer;
                        header[0] = BigLong(packetLen | NETFLAG_UNRELIABLE);
-                       header[1] = BigLong(conn->nq.unreliableSendSequence);
+                       header[1] = BigLong(conn->outgoing_unreliable_sequence);
                        memcpy(sendbuffer + NET_HEADERSIZE, data->data, data->cursize);
 
-                       conn->nq.unreliableSendSequence++;
+                       conn->outgoing_unreliable_sequence++;
 
                        conn->outgoing_unreliablesize[conn->outgoing_packetcounter] += packetLen;
 
@@ -786,7 +788,10 @@ void NetConn_OpenClientPorts(void)
        port = bound(0, cl_netport.integer, 65535);
        if (cl_netport.integer != port)
                Cvar_SetValueQuick(&cl_netport, port);
-       Con_Printf("Client using port %i\n", port);
+       if(port == 0)
+               Con_Printf("Client using an automatically assigned port\n");
+       else
+               Con_Printf("Client using port %i\n", port);
        NetConn_OpenClientPort("local:2", 0);
        NetConn_OpenClientPort(net_address.string, port);
        //NetConn_OpenClientPort(net_address_ipv6.string, port);
@@ -1203,7 +1208,6 @@ void NetConn_ConnectionEstablished(lhnetsocket_t *mysocket, lhnetaddress_t *peer
        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");
@@ -1287,12 +1291,16 @@ static void NetConn_ClientParsePacket_ServerList_UpdateCache(int n)
        dpsnprintf(entry->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(entry->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 (entry->query == SQS_QUERIED)
-               ServerList_ViewList_Remove(entry);
+       {
+               if(!serverlist_paused)
+                       ServerList_ViewList_Remove(entry);
+       }
        // if not in the slist menu we should print the server to console (if wanted)
        else if( serverlist_consoleoutput )
                Con_Printf("%s\n%s\n", serverlist_cache[n].line1, serverlist_cache[n].line2);
        // and finally, update the view set
-       ServerList_ViewList_Insert( entry );
+       if(!serverlist_paused)
+               ServerList_ViewList_Insert( entry );
        //      update the entry's state
        serverlist_cache[n].query = SQS_QUERIED;
 }
@@ -1676,6 +1684,10 @@ void NetConn_QueryQueueFrame(void)
        double timeouttime;
        static double querycounter = 0;
 
+       if(!net_slist_pause.integer && serverlist_paused)
+               ServerList_RebuildViewList();
+       serverlist_paused = net_slist_pause.integer;
+
        if (serverlist_querysleep)
                return;
 
@@ -1745,7 +1757,8 @@ void NetConn_QueryQueueFrame(void)
                        if( entry->query == SQS_REFRESHING ) {
                                // yes, so update the reply count (since its not responding anymore)
                                serverreplycount--;
-                               ServerList_ViewList_Remove(entry);
+                               if(!serverlist_paused)
+                                       ServerList_ViewList_Remove(entry);
                        }
                        entry->query = SQS_TIMEDOUT;
                }
@@ -2643,7 +2656,7 @@ static void Net_Heartbeat_f(void)
 void PrintStats(netconn_t *conn)
 {
        if ((cls.state == ca_connected && cls.protocol == PROTOCOL_QUAKEWORLD) || (sv.active && sv.protocol == PROTOCOL_QUAKEWORLD))
-               Con_Printf("address=%21s canSend=%u sendSeq=%6u recvSeq=%6u\n", conn->address, !conn->sendMessageLength, conn->qw.outgoing_sequence, conn->qw.incoming_sequence);
+               Con_Printf("address=%21s canSend=%u sendSeq=%6u recvSeq=%6u\n", conn->address, !conn->sendMessageLength, conn->outgoing_unreliable_sequence, conn->qw.incoming_sequence);
        else
                Con_Printf("address=%21s canSend=%u sendSeq=%6u recvSeq=%6u\n", conn->address, !conn->sendMessageLength, conn->nq.sendSequence, conn->nq.receiveSequence);
 }
@@ -2718,6 +2731,7 @@ void NetConn_Init(void)
        Cvar_RegisterVariable(&net_slist_queriesperframe);
        Cvar_RegisterVariable(&net_slist_timeout);
        Cvar_RegisterVariable(&net_slist_maxtries);
+       Cvar_RegisterVariable(&net_slist_pause);
        Cvar_RegisterVariable(&net_messagetimeout);
        Cvar_RegisterVariable(&net_connecttimeout);
        Cvar_RegisterVariable(&net_connectfloodblockingtimeout);