]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - netconn.c
cmd: Rename cbuf_cmd_t to cmd_input_t to clarify its purpose and make it generic
[xonotic/darkplaces.git] / netconn.c
index eb61cfed12019e41bc601b9e729a0930332633f7..b53877d7d7808b0aa50281a66d665f1ac2f3f8e9 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -93,7 +93,7 @@ static cvar_t net_slist_queriesperframe = {CVAR_CLIENT, "net_slist_queriesperfra
 static cvar_t net_slist_timeout = {CVAR_CLIENT, "net_slist_timeout", "4", "how long to listen for a server information response before giving up"};
 static cvar_t net_slist_pause = {CVAR_CLIENT, "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 = {CVAR_CLIENT, "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 net_slist_favorites = {CVAR_CLIENT | CVAR_SAVE | CVAR_NQUSERINFOHACK, "net_slist_favorites", "", "contains a list of IP addresses and ports to always query explicitly"};
+static cvar_t net_slist_favorites = {CVAR_CLIENT | CVAR_SAVE, "net_slist_favorites", "", "contains a list of IP addresses and ports to always query explicitly"};
 static cvar_t net_tos_dscp = {CVAR_CLIENT | CVAR_SAVE, "net_tos_dscp", "32", "DiffServ Codepoint for network sockets (may need game restart to apply)"};
 static cvar_t gameversion = {CVAR_SERVER, "gameversion", "0", "version of game data (mod-specific) to be sent to querying clients"};
 static cvar_t gameversion_min = {CVAR_CLIENT | CVAR_SERVER, "gameversion_min", "-1", "minimum version of game data (mod-specific), when client and server gameversion mismatch in the server browser the server is shown as incompatible; if -1, gameversion is used alone"};
@@ -166,12 +166,12 @@ static lhnetaddress_t favorites[MAX_FAVORITESERVERS];
 static int nFavorites_idfp = 0;
 static char favorites_idfp[MAX_FAVORITESERVERS][FP64_SIZE+1];
 
-void NetConn_UpdateFavorites(void)
+void NetConn_UpdateFavorites_c(cvar_t *var)
 {
        const char *p;
        nFavorites = 0;
        nFavorites_idfp = 0;
-       p = net_slist_favorites.string;
+       p = var->string;
        while((size_t) nFavorites < sizeof(favorites) / sizeof(*favorites) && COM_ParseToken_Console(&p))
        {
                if(com_token[0] != '[' && strlen(com_token) == FP64_SIZE && !strchr(com_token, '.'))
@@ -970,11 +970,11 @@ static void NetConn_OpenClientPort(const char *addressstring, lhnetaddresstype_t
                else
                {
                        LHNETADDRESS_ToString(&address, addressstring2, sizeof(addressstring2), true);
-                       Con_Errorf("Client failed to open a socket on address %s\n", addressstring2);
+                       Con_Printf(CON_ERROR "Client failed to open a socket on address %s\n", addressstring2);
                }
        }
        else
-               Con_Errorf("Client unable to parse address %s\n", addressstring);
+               Con_Printf(CON_ERROR "Client unable to parse address %s\n", addressstring);
 }
 
 void NetConn_OpenClientPorts(void)
@@ -1034,12 +1034,12 @@ static qboolean NetConn_OpenServerPort(const char *addressstring, lhnetaddressty
                        else
                        {
                                LHNETADDRESS_ToString(&address, addressstring2, sizeof(addressstring2), true);
-                               Con_Errorf("Server failed to open socket on address %s\n", addressstring2);
+                               Con_Printf(CON_ERROR "Server failed to open socket on address %s\n", addressstring2);
                        }
                }
                else
                {
-                       Con_Errorf("Server unable to parse address %s\n", addressstring);
+                       Con_Printf(CON_ERROR "Server unable to parse address %s\n", addressstring);
                        // if it cant parse one address, it wont be able to parse another for sure
                        return false;
                }
@@ -1060,7 +1060,6 @@ void NetConn_OpenServerPorts(int opennetports)
        port = bound(0, sv_netport.integer, 65535);
        if (port == 0)
                port = 26000;
-       Con_Printf("Server using port %i\n", port);
        if (sv_netport.integer != port)
                Cvar_SetValueQuick(&sv_netport, port);
        if (cls.state != ca_dedicated)
@@ -1549,7 +1548,7 @@ static void NetConn_ConnectionEstablished(lhnetsocket_t *mysocket, lhnetaddress_
        // reset move sequence numbering on this new connection
        cls.servermovesequence = 0;
        if (cls.protocol == PROTOCOL_QUAKEWORLD)
-               Cmd_ForwardStringToServer("new");
+               CL_ForwardToServer("new");
        if (cls.protocol == PROTOCOL_QUAKE)
        {
                // write a keepalive (clc_nop) as it seems to greatly improve the
@@ -2740,7 +2739,7 @@ static qboolean hmac_mdfour_time_matching(lhnetaddress_t *peeraddress, const cha
        long t1, t2;
 
        if (!password[0]) {
-               Con_Error("LOGIC ERROR: RCon_Authenticate should never call the comparator with an empty password. Please report.\n");
+               Con_Print(CON_ERROR "LOGIC ERROR: RCon_Authenticate should never call the comparator with an empty password. Please report.\n");
                return false;
        }
 
@@ -2761,7 +2760,7 @@ static qboolean hmac_mdfour_challenge_matching(lhnetaddress_t *peeraddress, cons
        int i;
 
        if (!password[0]) {
-               Con_Error("LOGIC ERROR: RCon_Authenticate should never call the comparator with an empty password. Please report.\n");
+               Con_Print(CON_ERROR "LOGIC ERROR: RCon_Authenticate should never call the comparator with an empty password. Please report.\n");
                return false;
        }
 
@@ -2792,7 +2791,7 @@ static qboolean hmac_mdfour_challenge_matching(lhnetaddress_t *peeraddress, cons
 static qboolean plaintext_matching(lhnetaddress_t *peeraddress, const char *password, const char *hash, const char *s, int slen)
 {
        if (!password[0]) {
-               Con_Error("LOGIC ERROR: RCon_Authenticate should never call the comparator with an empty password. Please report.\n");
+               Con_Print(CON_ERROR "LOGIC ERROR: RCon_Authenticate should never call the comparator with an empty password. Please report.\n");
                return false;
        }
 
@@ -2922,7 +2921,7 @@ static void RCon_Execute(lhnetsocket_t *mysocket, lhnetaddress_t *peeraddress, c
                        if(l)
                        {
                                client_t *host_client_save = host_client;
-                               Cmd_ExecuteString(&cmd_server, s, src_command, true);
+                               Cmd_ExecuteString(&cmd_server, s, src_local, true);
                                host_client = host_client_save;
                                // in case it is a command that changes host_client (like restart)
                        }
@@ -3757,7 +3756,7 @@ void NetConn_QueryMasters(qboolean querydp, qboolean queryqw)
        }
        if (!masterquerycount)
        {
-               Con_Error("Unable to query master servers, no suitable network sockets active.\n");
+               Con_Print(CON_ERROR "Unable to query master servers, no suitable network sockets active.\n");
                M_Update_Return_Reason("No network");
        }
 }
@@ -3889,6 +3888,9 @@ void NetConn_Init(void)
        Cvar_RegisterVariable(&net_slist_timeout);
        Cvar_RegisterVariable(&net_slist_maxtries);
        Cvar_RegisterVariable(&net_slist_favorites);
+#ifdef CONFIG_MENU
+       Cvar_RegisterCallback(&net_slist_favorites, NetConn_UpdateFavorites_c);
+#endif
        Cvar_RegisterVariable(&net_slist_pause);
        if(LHNET_DefaultDSCP(-1) >= 0) // register cvar only if supported
                Cvar_RegisterVariable(&net_tos_dscp);
@@ -3919,7 +3921,7 @@ void NetConn_Init(void)
        Cvar_RegisterVariable(&gameversion_min);
        Cvar_RegisterVariable(&gameversion_max);
 // COMMANDLINEOPTION: Server: -ip <ipaddress> sets the ip address of this machine for purposes of networking (default 0.0.0.0 also known as INADDR_ANY), use only if you have multiple network adapters and need to choose one specifically.
-       if ((i = COM_CheckParm("-ip")) && i + 1 < sys.argc)
+       if ((i = Sys_CheckParm("-ip")) && i + 1 < sys.argc)
        {
                if (LHNETADDRESS_FromString(&tempaddress, sys.argv[i + 1], 0) == 1)
                {
@@ -3927,10 +3929,10 @@ void NetConn_Init(void)
                        Cvar_SetQuick(&net_address, sys.argv[i + 1]);
                }
                else
-                       Con_Errorf("-ip option used, but unable to parse the address \"%s\"\n", sys.argv[i + 1]);
+                       Con_Printf(CON_ERROR "-ip option used, but unable to parse the address \"%s\"\n", sys.argv[i + 1]);
        }
 // COMMANDLINEOPTION: Server: -port <portnumber> sets the port to use for a server (default 26000, the same port as QUAKE itself), useful if you host multiple servers on your machine
-       if (((i = COM_CheckParm("-port")) || (i = COM_CheckParm("-ipport")) || (i = COM_CheckParm("-udpport"))) && i + 1 < sys.argc)
+       if (((i = Sys_CheckParm("-port")) || (i = Sys_CheckParm("-ipport")) || (i = Sys_CheckParm("-udpport"))) && i + 1 < sys.argc)
        {
                i = atoi(sys.argv[i + 1]);
                if (i >= 0 && i < 65536)
@@ -3939,7 +3941,7 @@ void NetConn_Init(void)
                        Cvar_SetValueQuick(&sv_netport, i);
                }
                else
-                       Con_Errorf("-port option used, but %i is not a valid port number\n", i);
+                       Con_Printf(CON_ERROR "-port option used, but %i is not a valid port number\n", i);
        }
        cl_numsockets = 0;
        sv_numsockets = 0;