]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - netconn.c
the record command now disconnects you if starting a new map, this fixes a crash...
[xonotic/darkplaces.git] / netconn.c
index 586507ac58fe4d15bd874611e4aeb6a19005b8ed..eec93bcc8ee109f50bef3c2b10daf1095bc21eb9 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -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];
@@ -576,7 +580,7 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers
                {
                        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;
                        }
@@ -1343,6 +1347,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)
@@ -1700,7 +1713,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)];
 
@@ -1718,9 +1731,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;
@@ -2191,7 +2209,7 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                                        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, 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));
@@ -2486,7 +2504,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