]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - netconn.c
Merge branch 'master' into Cloudwalk/Host_Init-overhaul
[xonotic/darkplaces.git] / netconn.c
index 1b48ac691764de43cc3e0a79bc44bd9d50e281c9..9a4094592fd0fb5494cab2229a977f28c671ec50 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -3863,6 +3863,45 @@ void NetConn_Init(void)
        int i;
        lhnetaddress_t tempaddress;
        netconn_mempool = Mem_AllocPool("network connections", 0, NULL);
+
+// 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 = Sys_CheckParm("-ip")) && i + 1 < sys.argc)
+       {
+               if (LHNETADDRESS_FromString(&tempaddress, sys.argv[i + 1], 0) == 1)
+               {
+                       Con_Printf("-ip option used, setting net_address to \"%s\"\n", sys.argv[i + 1]);
+                       Cvar_SetQuick(&net_address, sys.argv[i + 1]);
+               }
+               else
+                       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 = 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)
+               {
+                       Con_Printf("-port option used, setting port cvar to %i\n", i);
+                       Cvar_SetValueQuick(&sv_netport, i);
+               }
+               else
+                       Con_Printf(CON_ERROR "-port option used, but %i is not a valid port number\n", i);
+       }
+       cl_numsockets = 0;
+       sv_numsockets = 0;
+       cl_message.data = cl_message_buf;
+       cl_message.maxsize = sizeof(cl_message_buf);
+       cl_message.cursize = 0;
+       sv_message.data = sv_message_buf;
+       sv_message.maxsize = sizeof(sv_message_buf);
+       sv_message.cursize = 0;
+       LHNET_Init();
+       if (Thread_HasThreads())
+               netconn_mutex = Thread_CreateMutex();
+}
+
+void NetConn_Init_Commands(void)
+{
        Cmd_AddCommand(CF_SHARED, "net_stats", Net_Stats_f, "print network statistics");
 #ifdef CONFIG_MENU
        Cmd_AddCommand(CF_CLIENT, "net_slist", Net_Slist_f, "query dp master servers and print all server information");
@@ -3908,45 +3947,11 @@ void NetConn_Init(void)
        Cvar_RegisterVariable(&sv_public);
        Cvar_RegisterVariable(&sv_public_rejectreason);
        Cvar_RegisterVariable(&sv_heartbeatperiod);
-       for (i = 0;sv_masters[i].name;i++)
+       for (int i = 0;sv_masters[i].name;i++)
                Cvar_RegisterVariable(&sv_masters[i]);
        Cvar_RegisterVariable(&gameversion);
        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 = Sys_CheckParm("-ip")) && i + 1 < sys.argc)
-       {
-               if (LHNETADDRESS_FromString(&tempaddress, sys.argv[i + 1], 0) == 1)
-               {
-                       Con_Printf("-ip option used, setting net_address to \"%s\"\n", sys.argv[i + 1]);
-                       Cvar_SetQuick(&net_address, sys.argv[i + 1]);
-               }
-               else
-                       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 = 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)
-               {
-                       Con_Printf("-port option used, setting port cvar to %i\n", i);
-                       Cvar_SetValueQuick(&sv_netport, i);
-               }
-               else
-                       Con_Printf(CON_ERROR "-port option used, but %i is not a valid port number\n", i);
-       }
-       cl_numsockets = 0;
-       sv_numsockets = 0;
-       cl_message.data = cl_message_buf;
-       cl_message.maxsize = sizeof(cl_message_buf);
-       cl_message.cursize = 0;
-       sv_message.data = sv_message_buf;
-       sv_message.maxsize = sizeof(sv_message_buf);
-       sv_message.cursize = 0;
-       LHNET_Init();
-       if (Thread_HasThreads())
-               netconn_mutex = Thread_CreateMutex();
 }
 
 void NetConn_Shutdown(void)