now shows status messages in join game menu when a server is typed in manually (it...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 15 Oct 2004 07:08:12 +0000 (07:08 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 15 Oct 2004 07:08:12 +0000 (07:08 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4631 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
menu.c
menu.h
netconn.c
todo

index 6151d01..d32ac54 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -224,7 +224,7 @@ void CL_EstablishConnection(const char *host)
                return;
 
        // clear menu's connect error message
-       m_return_reason[0] = 0;
+       M_Update_Return_Reason("");
        cls.demonum = -1;
 
        // stop demo loop in case this fails
@@ -237,6 +237,7 @@ void CL_EstablishConnection(const char *host)
                cls.connect_trying = true;
                cls.connect_remainingtries = 3;
                cls.connect_nextsendtime = 0;
+               M_Update_Return_Reason("Trying to connect...");
                if (sv.active)
                {
                        NetConn_ClientFrame();
@@ -252,7 +253,7 @@ void CL_EstablishConnection(const char *host)
        else
        {
                Con_Print("Unable to find a suitable network socket to connect to server.\n");
-               strcpy(m_return_reason, "No network");
+               M_Update_Return_Reason("No network");
        }
 }
 
diff --git a/menu.c b/menu.c
index e99bf9c..d1acd80 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -94,6 +94,13 @@ qboolean     m_entersound;           // play after drawing a frame, so caching
 
 char           m_return_reason [32];
 
+void M_Update_Return_Reason(char *s)
+{
+       strlcpy(m_return_reason, s, sizeof(m_return_reason));
+       if (s)
+               Con_Printf("%s\n", s);
+}
+
 #define StartingGame   (m_multiplayer_cursor == 1)
 #define JoiningGame            (m_multiplayer_cursor == 0)
 
@@ -2806,7 +2813,7 @@ void M_Menu_LanConfig_f (void)
        lanConfig_port = 26000;
        sprintf(lanConfig_portname, "%u", lanConfig_port);
 
-       m_return_reason[0] = 0;
+       M_Update_Return_Reason("");
 }
 
 
@@ -3729,7 +3736,7 @@ void M_Menu_ServerList_f (void)
        m_state = m_slist;
        m_entersound = true;
        slist_cursor = 0;
-       m_return_reason[0] = 0;
+       M_Update_Return_Reason("");
        Net_Slist_f();
 }
 
diff --git a/menu.h b/menu.h
index 1dd8e17..7374b01 100644 (file)
--- a/menu.h
+++ b/menu.h
@@ -50,6 +50,7 @@ enum m_state_e {
 
 extern enum m_state_e m_state;
 extern char m_return_reason[32];
+void M_Update_Return_Reason(char *s);
 
 /*
 // hard-coded menus
index c3b43d1..2c7f0ca 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -604,6 +604,7 @@ int NetConn_ReceivedMessage(netconn_t *conn, qbyte *data, int length)
 void NetConn_ConnectionEstablished(lhnetsocket_t *mysocket, lhnetaddress_t *peeraddress)
 {
        cls.connect_trying = false;
+       M_Update_Return_Reason("");
        // the connection request succeeded, stop current connection and set up a new connection
        CL_Disconnect();
        cls.netcon = NetConn_Open(mysocket, peeraddress);
@@ -661,22 +662,25 @@ int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length,
                {
                        LHNETADDRESS_ToString(peeraddress, addressstring2, sizeof(addressstring2), true);
                        Con_Printf("\"%s\" received, sending connect request back to %s\n", string, addressstring2);
+                       M_Update_Return_Reason("Got challenge response");
                        NetConn_WriteString(mysocket, va("\377\377\377\377connect\\protocol\\darkplaces 3\\challenge\\%s", string + 10), peeraddress);
                        return true;
                }
                if (length == 6 && !memcmp(string, "accept", 6) && cls.connect_trying)
                {
+                       M_Update_Return_Reason("Accepted");
                        NetConn_ConnectionEstablished(mysocket, peeraddress);
                        return true;
                }
                if (length > 7 && !memcmp(string, "reject ", 7) && cls.connect_trying)
                {
+                       char rejectreason[32];
                        cls.connect_trying = false;
                        string += 7;
-                       length = max(length - 7, (int)sizeof(m_return_reason) - 1);
-                       memcpy(m_return_reason, string, length);
-                       m_return_reason[length] = 0;
-                       Con_Printf("%s\n", m_return_reason);
+                       length = max(length - 7, (int)sizeof(rejectreason) - 1);
+                       memcpy(rejectreason, string, length);
+                       rejectreason[length] = 0;
+                       M_Update_Return_Reason(rejectreason);
                        return true;
                }
                if (length >= 13 && !memcmp(string, "infoResponse\x0A", 13))
@@ -855,14 +859,15 @@ int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length,
                                        length -= 4;
                                        LHNETADDRESS_SetPort(&clientportaddress, port);
                                }
+                               M_Update_Return_Reason("Accepted");
                                NetConn_ConnectionEstablished(mysocket, &clientportaddress);
                        }
                        break;
                case CCREP_REJECT:
                        if (developer.integer)
                                Con_Printf("Datagram_ParseConnectionless: received CCREP_REJECT from %s.\n", addressstring2);
-                       Con_Printf("%s\n", data);
-                       strlcpy (m_return_reason, data, sizeof (m_return_reason));
+                       cls.connect_trying = false;
+                       M_Update_Return_Reason(data);
                        break;
 #if 0
                case CCREP_SERVER_INFO:
@@ -934,26 +939,9 @@ void NetConn_ClientFrame(void)
                if (cls.connect_remainingtries == 0)
                {
                        cls.connect_trying = false;
-                       if (m_state == m_slist)
-                               strcpy (m_return_reason, "Connect: Failed");
-                       else
-                               Con_Print("Connect failed\n");
+                       M_Update_Return_Reason("Connect: Failed");
                        return;
                }
-               if (cls.connect_nextsendtime)
-               {
-                       if (m_state == m_slist)
-                               strcpy (m_return_reason, "Connect: Still trying");
-                       else
-                               Con_Print("Still trying...\n");
-               }
-               else
-               {
-                       if (m_state == m_slist)
-                               strcpy (m_return_reason, "Connect: Trying");
-                       else
-                               Con_Print("Trying...\n");
-               }
                cls.connect_nextsendtime = realtime + 1;
                cls.connect_remainingtries--;
                // try challenge first (newer server)
@@ -1456,7 +1444,7 @@ void NetConn_QueryMasters(void)
        if (!masterquerycount)
        {
                Con_Print("Unable to query master servers, no suitable network sockets active.\n");
-               strcpy(m_return_reason, "No network");
+               M_Update_Return_Reason("No network");
        }
 }
 
diff --git a/todo b/todo
index b041248..68bd668 100644 (file)
--- a/todo
+++ b/todo
 1 hmap2: add .mip loading support
 1 hmap: qbsp dies from runaway allocations if a duplicate plane is found on a brush (Tomaz)
 1 lhfire: add percentage and estimated time reporting to console output (daniel_hansson@telia.com)
+-(RenegadeC) d darkplaces client: make sure the join game menu shows status on a connection attempt, such as connecting or failed (RenegadeC)
 1 lhfire: get lhfire_gui build from Tomaz.
 1 lhfire: post lhfire_gui build.
 1 lhfire: prepare example scripts for release.