]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_main.c
Merge branch 'master' into Cloudwalk/Host_Init-overhaul
[xonotic/darkplaces.git] / cl_main.c
index 2a2b9976d204dd82cc6e41bf67c9c3e1b1e6cf50..d5551891b9e7454a37924646ffe32965f1377715 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -2943,27 +2943,21 @@ CL_Init
 void CL_Init (void)
 {
        if (cls.state == ca_dedicated)
-       {
-               Cmd_AddCommand(CF_SERVER, "disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
-       }
+               return;
        else
        {
                Con_Printf("Initializing client\n");
 
                Cvar_SetValueQuick(&host_isclient, 1);
 
-               R_Modules_Init();
                Palette_Init();
-#ifdef CONFIG_MENU
-               MR_Init_Commands();
-#endif
+
                VID_Shared_Init();
                VID_Init();
                Render_Init();
                S_Init();
                CDAudio_Init();
                Key_Init();
-               V_Init();
 
                cls.levelmempool = Mem_AllocPool("client (per-level memory)", 0, NULL);
                cls.permanentmempool = Mem_AllocPool("client (long term memory)", 0, NULL);
@@ -2977,12 +2971,53 @@ void CL_Init (void)
                r_refdef.scene.maxtempentities = MAX_TEMPENTITIES;
                r_refdef.scene.tempentities = (entity_render_t *)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t) * r_refdef.scene.maxtempentities);
 
-               CL_InitInput ();
+               Cvar_SetValueQuick(&qport, (rand() * RAND_MAX + rand()) & 0xffff);
+
+               CL_Screen_Init();
+               CL_MeshEntities_Init();
+
+               CL_Video_Init();
+
+               host.hook.ConnectLocal = CL_EstablishConnection_Local;
+               host.hook.ConnectLocal = CL_EstablishConnection_Local;
+               host.hook.Disconnect = CL_Disconnect;
+               host.hook.CL_Intermission = CL_Intermission;
+               host.hook.ToggleMenu = CL_ToggleMenu_Hook;
+       }
+}
+
+void CL_Init_Commands(void)
+{
+       if (cls.state == ca_dedicated)
+       {
+               Cmd_AddCommand(CF_SERVER, "disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
+       }
+       else
+       {
+               //
+               // register our commands
+               //
+               R_Modules_Init();
+               Palette_Init_Commands();
+#ifdef CONFIG_MENU
+               MR_Init_Commands();
+#endif
+               VID_Shared_Init_Commands();
+               VID_Init_Commands();
+               Render_Init_Commands();
+               S_Init_Commands();
+               CDAudio_Init_Commands();
+               Key_Init_Commands();
+               V_Init();
+
+               CL_InitInput();
+               CL_Demo_Init();
+               CL_Parse_Init();
+               CL_Particles_Init();
+               CL_Screen_Init_Commands();
+               CL_Video_Init_Commands();
 
-       //
-       // register our commands
-       //
-               CL_InitCommands();
+               CL_InitServer_Commands();
 
                Cvar_RegisterVariable (&cl_upspeed);
                Cvar_RegisterVariable (&cl_forwardspeed);
@@ -3010,9 +3045,6 @@ void CL_Init (void)
 
                Cvar_RegisterVariable (&cl_itembobspeed);
                Cvar_RegisterVariable (&cl_itembobheight);
-
-               CL_Demo_Init();
-
                Cmd_AddCommand(CF_CLIENT, "entities", CL_PrintEntities_f, "print information on network entities known to client");
                Cmd_AddCommand(CF_CLIENT, "disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
                Cmd_AddCommand(CF_CLIENT, "connect", CL_Connect_f, "connect to a server by IP address or hostname");
@@ -3051,7 +3083,6 @@ void CL_Init (void)
 
                // for QW connections
                Cvar_RegisterVariable(&qport);
-               Cvar_SetValueQuick(&qport, (rand() * RAND_MAX + rand()) & 0xffff);
 
                Cmd_AddCommand(CF_CLIENT, "timerefresh", CL_TimeRefresh_f, "turn quickly and print rendering statistcs");
 
@@ -3076,17 +3107,5 @@ void CL_Init (void)
                Cvar_RegisterVariable (&cl_maxfps);
                Cvar_RegisterVariable (&cl_maxfps_alwayssleep);
                Cvar_RegisterVariable (&cl_maxidlefps);
-
-               CL_Parse_Init();
-               CL_Particles_Init();
-               CL_Screen_Init();
-               CL_MeshEntities_Init();
-
-               CL_Video_Init();
-
-               host.hook.ConnectLocal = CL_EstablishConnection_Local;
-               host.hook.Disconnect = CL_Disconnect;
-               host.hook.CL_Intermission = CL_Intermission;
-               host.hook.ToggleMenu = CL_ToggleMenu_Hook;
        }
-}
+}
\ No newline at end of file