]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_main.c
(Round 5) Break up host_cmd.c
[xonotic/darkplaces.git] / cl_main.c
index b0c913d054fa1e0092262e219ba89f46c56b8664..77467bfbce3285e5a0d9651cb5ea99360ed29398 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "r_shadow.h"
 #include "libcurl.h"
 #include "snd_main.h"
+#include "cdaudio.h"
 
 // we need to declare some mouse variables here, because the menu system
 // references them even when on a unix system.
@@ -35,6 +36,7 @@ cvar_t csqc_progname = {CVAR_CLIENT | CVAR_SERVER, "csqc_progname","csprogs.dat"
 cvar_t csqc_progcrc = {CVAR_CLIENT | CVAR_READONLY, "csqc_progcrc","-1","CRC of csprogs.dat file to load (-1 is none), only used during level changes and then reset to -1"};
 cvar_t csqc_progsize = {CVAR_CLIENT | CVAR_READONLY, "csqc_progsize","-1","file size of csprogs.dat file to load (-1 is none), only used during level changes and then reset to -1"};
 cvar_t csqc_usedemoprogs = {CVAR_CLIENT, "csqc_usedemoprogs","1","use csprogs stored in demos"};
+cvar_t csqc_polygons_defaultmaterial_nocullface = {CVAR_CLIENT, "csqc_polygons_defaultmaterial_nocullface", "0", "use 'cull none' behavior in the default shader for rendering R_PolygonBegin - warning: enabling this is not consistent with FTEQW behavior on this feature"};
 
 cvar_t cl_shownet = {CVAR_CLIENT, "cl_shownet","0","1 = print packet size, 2 = print packet message list"};
 cvar_t cl_nolerp = {CVAR_CLIENT, "cl_nolerp", "0","network update smoothing"};
@@ -207,6 +209,9 @@ void CL_ClearState(void)
        CL_Screen_NewMap();
 }
 
+extern cvar_t topcolor;
+extern cvar_t bottomcolor;
+
 void CL_SetInfo(const char *key, const char *value, qboolean send, qboolean allowstarkey, qboolean allowmodel, qboolean quiet)
 {
        int i;
@@ -253,11 +258,13 @@ void CL_SetInfo(const char *key, const char *value, qboolean send, qboolean allo
                }
                else if (!strcasecmp(key, "topcolor"))
                {
-                       // don't send anything, the combined color code will be updated manually
+                       MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
+                       MSG_WriteString(&cls.netcon->message, va(vabuf, sizeof(vabuf), "color %i %i", atoi(value), bottomcolor.integer));
                }
                else if (!strcasecmp(key, "bottomcolor"))
                {
-                       // don't send anything, the combined color code will be updated manually
+                       MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
+                       MSG_WriteString(&cls.netcon->message, va(vabuf, sizeof(vabuf), "color %i %i", topcolor.integer, atoi(value)));
                }
                else if (!strcasecmp(key, "rate"))
                {
@@ -321,6 +328,8 @@ void CL_ExpandCSQCRenderEntities(int num)
        }
 }
 
+extern cvar_t rcon_secure;
+
 /*
 =====================
 CL_Disconnect
@@ -389,19 +398,99 @@ void CL_Disconnect(void)
                NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000, 0, false);
                NetConn_Close(cls.netcon);
                cls.netcon = NULL;
+               Con_Printf("Disconnected\n");
        }
        cls.state = ca_disconnected;
        cl.islocalgame = false;
 
        cls.demoplayback = cls.timedemo = false;
        cls.signon = 0;
+
+       // If we're dropped mid-connection attempt, it won't clear otherwise.
+       SCR_ClearLoadingScreen(false);
+}
+
+/*
+==================
+CL_Reconnect_f
+
+This command causes the client to wait for the signon messages again.
+This is sent just before a server changes levels
+==================
+*/
+void CL_Reconnect_f(cmd_state_t *cmd)
+{
+       char temp[128];
+       // if not connected, reconnect to the most recent server
+       if (!cls.netcon)
+       {
+               // if we have connected to a server recently, the userinfo
+               // will still contain its IP address, so get the address...
+               InfoString_GetValue(cls.userinfo, "*ip", temp, sizeof(temp));
+               if (temp[0])
+                       CL_EstablishConnection(temp, -1);
+               else
+                       Con_Printf("Reconnect to what server?  (you have not connected to a server yet)\n");
+               return;
+       }
+       // if connected, do something based on protocol
+       if (cls.protocol == PROTOCOL_QUAKEWORLD)
+       {
+               // quakeworld can just re-login
+               if (cls.qw_downloadmemory)  // don't change when downloading
+                       return;
+
+               S_StopAllSounds();
+
+               if (cls.state == ca_connected)
+               {
+                       Con_Printf("Server is changing level...\n");
+                       MSG_WriteChar(&cls.netcon->message, qw_clc_stringcmd);
+                       MSG_WriteString(&cls.netcon->message, "new");
+               }
+       }
+       else
+       {
+               // netquake uses reconnect on level changes (silly)
+               if (Cmd_Argc(cmd) != 1)
+               {
+                       Con_Print("reconnect : wait for signon messages again\n");
+                       return;
+               }
+               if (!cls.signon)
+               {
+                       Con_Print("reconnect: no signon, ignoring reconnect\n");
+                       return;
+               }
+               cls.signon = 0;         // need new connection messages
+       }
+}
+
+/*
+=====================
+CL_Connect_f
+
+User command to connect to server
+=====================
+*/
+static void CL_Connect_f(cmd_state_t *cmd)
+{
+       if (Cmd_Argc(cmd) < 2)
+       {
+               Con_Print("connect <serveraddress> [<key> <value> ...]: connect to a multiplayer game\n");
+               return;
+       }
+       // clear the rcon password, to prevent vulnerability by stuffcmd-ing a connect command
+       if(rcon_secure.integer <= 0)
+               Cvar_SetQuick(&rcon_password, "");
+       CL_EstablishConnection(Cmd_Argv(cmd, 1), 2);
 }
 
 void CL_Disconnect_f(cmd_state_t *cmd)
 {
        CL_Disconnect ();
        if (sv.active)
-               Host_ShutdownServer ();
+               SV_Shutdown ();
 }
 
 
@@ -428,9 +517,6 @@ void CL_EstablishConnection(const char *host, int firstarg)
        M_Update_Return_Reason("");
 #endif
 
-       // if downloads are running, cancel their finishing action
-       Curl_Clear_forthismap();
-
        // Disconnect from the current server, or stop a running demo.
        CL_Disconnect();
 
@@ -699,7 +785,7 @@ void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float
        }
 }
 
-void CL_AllocLightFlash(entity_render_t *ent, matrix4x4_t *matrix, float radius, float red, float green, float blue, float decay, float lifetime, int cubemapnum, int style, int shadowenable, vec_t corona, vec_t coronasizescale, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int flags)
+void CL_AllocLightFlash(entity_render_t *ent, matrix4x4_t *matrix, float radius, float red, float green, float blue, float decay, float lifetime, char *cubemapname, int style, int shadowenable, vec_t corona, vec_t coronasizescale, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int flags)
 {
        int i;
        dlight_t *dl;
@@ -736,10 +822,9 @@ void CL_AllocLightFlash(entity_render_t *ent, matrix4x4_t *matrix, float radius,
                dl->die = cl.time + lifetime;
        else
                dl->die = 0;
-       if (cubemapnum > 0)
-               dpsnprintf(dl->cubemapname, sizeof(dl->cubemapname), "cubemaps/%i", cubemapnum);
-       else
-               dl->cubemapname[0] = 0;
+       dl->cubemapname[0] = 0;
+       if (cubemapname && cubemapname[0])
+               strlcpy(dl->cubemapname, cubemapname, sizeof(dl->cubemapname));
        dl->style = style;
        dl->shadow = shadowenable;
        dl->corona = corona;
@@ -1872,6 +1957,8 @@ void CSQC_RelinkAllEntities (int drawmask)
 {
        // link stuff
        CL_RelinkWorld();
+       // the scene mesh is added first for easier debugging (consistent spot in render entities list)
+       CL_MeshEntities_Scene_AddRenderEntity();
        CL_RelinkStaticEntities();
        CL_RelinkBeams();
        CL_RelinkEffects();
@@ -1888,8 +1975,6 @@ void CSQC_RelinkAllEntities (int drawmask)
 
        // update view blend
        V_CalcViewBlend();
-
-       CL_MeshEntities_AddToScene();
 }
 
 /*
@@ -1940,7 +2025,12 @@ void CL_UpdateWorld(void)
 
                // when csqc is loaded, it will call this in CSQC_UpdateView
                if (!cl.csqc_loaded)
+               {
+                       // clear the CL_Mesh_Scene() used for some engine effects
+                       CL_MeshEntities_Scene_Clear();
+                       // add engine entities and effects
                        CSQC_RelinkAllEntities(ENTMASK_ENGINE | ENTMASK_ENGINEVIEWMODELS);
+               }
 
                // decals, particles, and explosions will be updated during rneder
        }
@@ -1948,16 +2038,6 @@ void CL_UpdateWorld(void)
        r_refdef.scene.time = cl.time;
 }
 
-// LadyHavoc: pausedemo command
-static void CL_PauseDemo_f(cmd_state_t *cmd)
-{
-       cls.demopaused = !cls.demopaused;
-       if (cls.demopaused)
-               Con_Print("Demo paused\n");
-       else
-               Con_Print("Demo unpaused\n");
-}
-
 /*
 ======================
 CL_Fog_f
@@ -2188,7 +2268,7 @@ static void CL_Locs_Save_f(cmd_state_t *cmd)
                        if (VectorCompare(loc->mins, loc->maxs))
                                break;
                if (loc)
-                       Con_Printf("Warning: writing loc file containing a mixture of qizmo-style points and proquake-style boxes may not work in qizmo or proquake!\n");
+                       Con_Warnf("Warning: writing loc file containing a mixture of qizmo-style points and proquake-style boxes may not work in qizmo or proquake!\n");
        }
        for (loc = cl.locnodes;loc;loc = loc->next)
        {
@@ -2369,9 +2449,7 @@ entity_t cl_meshentities[NUM_MESHENTITIES];
 dp_model_t cl_meshentitymodels[NUM_MESHENTITIES];
 const char *cl_meshentitynames[NUM_MESHENTITIES] =
 {
-       "MESH_DEBUG",
-       "MESH_CSQC_POLYGONS",
-       "MESH_PARTICLES",
+       "MESH_SCENE",
        "MESH_UI",
 };
 
@@ -2395,7 +2473,8 @@ static void CL_MeshEntities_Init(void)
                ent = cl_meshentities + i;
                ent->state_current.active = true;
                ent->render.model = cl_meshentitymodels + i;
-               ent->render.alpha = 0.999999f; // not quite 1 so that MATERIALFLAG_ALPHA is always set.
+               Mod_Mesh_Create(ent->render.model, cl_meshentitynames[i]);      
+               ent->render.alpha = 1;
                ent->render.flags = RENDER_SHADOW | RENDER_LIGHT;
                ent->render.framegroupblend[0].lerp = 1;
                ent->render.frameblend[0].lerp = 1;
@@ -2423,31 +2502,23 @@ static void CL_MeshEntities_Init(void)
        R_RegisterModule("cl_meshentities", CL_MeshEntities_Restart, CL_MeshEntities_Restart, CL_MeshEntities_Restart, CL_MeshEntities_Restart, CL_MeshEntities_Restart);
 }
 
-void CL_MeshEntities_AddToScene(void)
+void CL_MeshEntities_Scene_Clear(void)
 {
-       int i;
-       entity_t *ent;
-       for (i = 0; i < NUM_MESHENTITIES && r_refdef.scene.numentities < r_refdef.scene.maxentities; i++)
-       {
-               ent = cl_meshentities + i;
-               if (ent->render.model->num_surfaces == 0)
-                       continue;
-               Mod_Mesh_Finalize(ent->render.model);
-               VectorCopy(ent->render.model->normalmins, ent->render.mins);
-               VectorCopy(ent->render.model->normalmaxs, ent->render.maxs);
-               r_refdef.scene.entities[r_refdef.scene.numentities++] = &ent->render;
-       }
+       Mod_Mesh_Reset(CL_Mesh_Scene());
 }
 
-void CL_MeshEntities_Reset(void)
+void CL_MeshEntities_Scene_AddRenderEntity(void)
 {
-       int i;
-       entity_t *ent;
-       for (i = 0; i < NUM_MESHENTITIES && r_refdef.scene.numentities < r_refdef.scene.maxentities; i++)
-       {
-               ent = cl_meshentities + i;
-               Mod_Mesh_Reset(ent->render.model);
-       }
+       entity_t* ent = &cl_meshentities[MESH_SCENE];
+       r_refdef.scene.entities[r_refdef.scene.numentities++] = &ent->render;
+}
+
+void CL_MeshEntities_Scene_FinalizeRenderEntity(void)
+{
+       entity_t *ent = &cl_meshentities[MESH_SCENE];
+       Mod_Mesh_Finalize(ent->render.model);
+       VectorCopy(ent->render.model->normalmins, ent->render.mins);
+       VectorCopy(ent->render.model->normalmaxs, ent->render.maxs);
 }
 
 static void CL_MeshEntities_Shutdown(void)
@@ -2491,6 +2562,7 @@ static void CL_UpdateEntityShading_Entity(entity_render_t *ent)
        for (q = 0; q < 3; q++)
                a[q] = c[q] = dir[q] = 0;
 
+       ent->render_lightgrid = false;
        ent->render_modellight_forced = false;
        ent->render_rtlight_disabled = false;
 
@@ -2571,6 +2643,12 @@ static void CL_UpdateEntityShading_Entity(entity_render_t *ent)
                        ent->render_modellight_forced = true;
                        ent->render_rtlight_disabled = true;
                }
+               else if (((ent->model && !ent->model->lit) || (ent->model == r_refdef.scene.worldmodel ? mod_q3bsp_lightgrid_world_surfaces.integer : mod_q3bsp_lightgrid_bsp_surfaces.integer))
+                       && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->lit && r_refdef.scene.worldmodel->brushq3.lightgridtexture && mod_q3bsp_lightgrid_texture.integer)
+               {
+                       ent->render_lightgrid = true;
+                       // no need to call R_CompleteLightPoint as we base it on render_lightmap_*
+               }
                else if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->lit && r_refdef.scene.worldmodel->brush.LightPoint)
                        R_CompleteLightPoint(a, c, dir, shadingorigin, LP_LIGHTMAP, r_refdef.scene.lightmapintensity, r_refdef.scene.ambientintensity);
                else if (r_fullbright_directed.integer)
@@ -2639,114 +2717,134 @@ CL_Init
 */
 void CL_Init (void)
 {
+       if (cls.state == ca_dedicated)
+       {
+               Cmd_AddCommand(CMD_SERVER, "disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
+       }
+       else
+       {
+               Con_DPrintf("Initializing client\n");
 
-       cls.levelmempool = Mem_AllocPool("client (per-level memory)", 0, NULL);
-       cls.permanentmempool = Mem_AllocPool("client (long term memory)", 0, NULL);
-
-       memset(&r_refdef, 0, sizeof(r_refdef));
-       // max entities sent to renderer per frame
-       r_refdef.scene.maxentities = MAX_EDICTS + 256 + 512;
-       r_refdef.scene.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * r_refdef.scene.maxentities);
-
-       // max temp entities
-       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 ();
-
-//
-// register our commands
-//
-       Cvar_RegisterVariable (&cl_upspeed);
-       Cvar_RegisterVariable (&cl_forwardspeed);
-       Cvar_RegisterVariable (&cl_backspeed);
-       Cvar_RegisterVariable (&cl_sidespeed);
-       Cvar_RegisterVariable (&cl_movespeedkey);
-       Cvar_RegisterVariable (&cl_yawspeed);
-       Cvar_RegisterVariable (&cl_pitchspeed);
-       Cvar_RegisterVariable (&cl_anglespeedkey);
-       Cvar_RegisterVariable (&cl_shownet);
-       Cvar_RegisterVariable (&cl_nolerp);
-       Cvar_RegisterVariable (&cl_lerpexcess);
-       Cvar_RegisterVariable (&cl_lerpanim_maxdelta_server);
-       Cvar_RegisterVariable (&cl_lerpanim_maxdelta_framegroups);
-       Cvar_RegisterVariable (&cl_deathfade);
-       Cvar_RegisterVariable (&lookspring);
-       Cvar_RegisterVariable (&lookstrafe);
-       Cvar_RegisterVariable (&sensitivity);
-       Cvar_RegisterVariable (&freelook);
-
-       Cvar_RegisterVariable (&m_pitch);
-       Cvar_RegisterVariable (&m_yaw);
-       Cvar_RegisterVariable (&m_forward);
-       Cvar_RegisterVariable (&m_side);
-
-       Cvar_RegisterVariable (&cl_itembobspeed);
-       Cvar_RegisterVariable (&cl_itembobheight);
-
-       Cmd_AddCommand(&cmd_client, "entities", CL_PrintEntities_f, "print information on network entities known to client");
-       Cmd_AddCommand(&cmd_client, "disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
-       Cmd_AddCommand(&cmd_client, "record", CL_Record_f, "record a demo");
-       Cmd_AddCommand(&cmd_client, "stop", CL_Stop_f, "stop recording or playing a demo");
-       Cmd_AddCommand(&cmd_client, "playdemo", CL_PlayDemo_f, "watch a demo file");
-       Cmd_AddCommand(&cmd_client, "timedemo", CL_TimeDemo_f, "play back a demo as fast as possible and save statistics to benchmark.log");
-
-       // Support Client-side Model Index List
-       Cmd_AddCommand(&cmd_client, "cl_modelindexlist", CL_ModelIndexList_f, "list information on all models in the client modelindex");
-       // Support Client-side Sound Index List
-       Cmd_AddCommand(&cmd_client, "cl_soundindexlist", CL_SoundIndexList_f, "list all sounds in the client soundindex");
-
-       Cvar_RegisterVariable (&cl_autodemo);
-       Cvar_RegisterVariable (&cl_autodemo_nameformat);
-       Cvar_RegisterVariable (&cl_autodemo_delete);
-
-       Cmd_AddCommand(&cmd_client, "fog", CL_Fog_f, "set global fog parameters (density red green blue [alpha [mindist [maxdist [top [fadedepth]]]]])");
-       Cmd_AddCommand(&cmd_client, "fog_heighttexture", CL_Fog_HeightTexture_f, "set global fog parameters (density red green blue alpha mindist maxdist top depth textures/mapname/fogheight.tga)");
-
-       // LadyHavoc: added pausedemo
-       Cmd_AddCommand(&cmd_client, "pausedemo", CL_PauseDemo_f, "pause demo playback (can also safely pause demo recording if using QUAKE, QUAKEDP or NEHAHRAMOVIE protocol, useful for making movies)");
-
-       Cmd_AddCommand(&cmd_client, "cl_areastats", CL_AreaStats_f, "prints statistics on entity culling during collision traces");
-
-       Cvar_RegisterVariable(&r_draweffects);
-       Cvar_RegisterVariable(&cl_explosions_alpha_start);
-       Cvar_RegisterVariable(&cl_explosions_alpha_end);
-       Cvar_RegisterVariable(&cl_explosions_size_start);
-       Cvar_RegisterVariable(&cl_explosions_size_end);
-       Cvar_RegisterVariable(&cl_explosions_lifetime);
-       Cvar_RegisterVariable(&cl_stainmaps);
-       Cvar_RegisterVariable(&cl_stainmaps_clearonload);
-       Cvar_RegisterVariable(&cl_beams_polygons);
-       Cvar_RegisterVariable(&cl_beams_quakepositionhack);
-       Cvar_RegisterVariable(&cl_beams_instantaimhack);
-       Cvar_RegisterVariable(&cl_beams_lightatend);
-       Cvar_RegisterVariable(&cl_noplayershadow);
-       Cvar_RegisterVariable(&cl_dlights_decayradius);
-       Cvar_RegisterVariable(&cl_dlights_decaybrightness);
-
-       Cvar_RegisterVariable(&cl_prydoncursor);
-       Cvar_RegisterVariable(&cl_prydoncursor_notrace);
-
-       Cvar_RegisterVariable(&cl_deathnoviewmodel);
-
-       // for QW connections
-       Cvar_RegisterVariable(&qport);
-       Cvar_SetValueQuick(&qport, (rand() * RAND_MAX + rand()) & 0xffff);
-
-       Cmd_AddCommand(&cmd_client, "timerefresh", CL_TimeRefresh_f, "turn quickly and print rendering statistcs");
-
-       Cvar_RegisterVariable(&cl_locs_enable);
-       Cvar_RegisterVariable(&cl_locs_show);
-       Cmd_AddCommand(&cmd_client, "locs_add", CL_Locs_Add_f, "add a point or box location (usage: x y z[ x y z] \"name\", if two sets of xyz are supplied it is a box, otherwise point)");
-       Cmd_AddCommand(&cmd_client, "locs_removenearest", CL_Locs_RemoveNearest_f, "remove the nearest point or box (note: you need to be very near a box to remove it)");
-       Cmd_AddCommand(&cmd_client, "locs_clear", CL_Locs_Clear_f, "remove all loc points/boxes");
-       Cmd_AddCommand(&cmd_client, "locs_reload", CL_Locs_Reload_f, "reload .loc file for this map");
-       Cmd_AddCommand(&cmd_client, "locs_save", CL_Locs_Save_f, "save .loc file for this map containing currently defined points and boxes");
-
-       CL_Parse_Init();
-       CL_Particles_Init();
-       CL_Screen_Init();
-       CL_MeshEntities_Init();
-
-       CL_Video_Init();
+               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();
+
+
+               cls.levelmempool = Mem_AllocPool("client (per-level memory)", 0, NULL);
+               cls.permanentmempool = Mem_AllocPool("client (long term memory)", 0, NULL);
+
+               memset(&r_refdef, 0, sizeof(r_refdef));
+               // max entities sent to renderer per frame
+               r_refdef.scene.maxentities = MAX_EDICTS + 256 + 512;
+               r_refdef.scene.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * r_refdef.scene.maxentities);
+
+               // max temp entities
+               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 ();
+
+       //
+       // register our commands
+       //
+               Cvar_RegisterVariable (&cl_upspeed);
+               Cvar_RegisterVariable (&cl_forwardspeed);
+               Cvar_RegisterVariable (&cl_backspeed);
+               Cvar_RegisterVariable (&cl_sidespeed);
+               Cvar_RegisterVariable (&cl_movespeedkey);
+               Cvar_RegisterVariable (&cl_yawspeed);
+               Cvar_RegisterVariable (&cl_pitchspeed);
+               Cvar_RegisterVariable (&cl_anglespeedkey);
+               Cvar_RegisterVariable (&cl_shownet);
+               Cvar_RegisterVariable (&cl_nolerp);
+               Cvar_RegisterVariable (&cl_lerpexcess);
+               Cvar_RegisterVariable (&cl_lerpanim_maxdelta_server);
+               Cvar_RegisterVariable (&cl_lerpanim_maxdelta_framegroups);
+               Cvar_RegisterVariable (&cl_deathfade);
+               Cvar_RegisterVariable (&lookspring);
+               Cvar_RegisterVariable (&lookstrafe);
+               Cvar_RegisterVariable (&sensitivity);
+               Cvar_RegisterVariable (&freelook);
+
+               Cvar_RegisterVariable (&m_pitch);
+               Cvar_RegisterVariable (&m_yaw);
+               Cvar_RegisterVariable (&m_forward);
+               Cvar_RegisterVariable (&m_side);
+
+               Cvar_RegisterVariable (&cl_itembobspeed);
+               Cvar_RegisterVariable (&cl_itembobheight);
+
+               CL_Demo_Init();
+
+               Cmd_AddCommand(CMD_CLIENT, "entities", CL_PrintEntities_f, "print information on network entities known to client");
+               Cmd_AddCommand(CMD_CLIENT, "disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
+               Cmd_AddCommand(CMD_CLIENT, "connect", CL_Connect_f, "connect to a server by IP address or hostname");
+               Cmd_AddCommand(CMD_CLIENT | CMD_CLIENT_FROM_SERVER, "reconnect", CL_Reconnect_f, "reconnect to the last server you were on, or resets a quakeworld connection (do not use if currently playing on a netquake server)");
+
+               // Support Client-side Model Index List
+               Cmd_AddCommand(CMD_CLIENT, "cl_modelindexlist", CL_ModelIndexList_f, "list information on all models in the client modelindex");
+               // Support Client-side Sound Index List
+               Cmd_AddCommand(CMD_CLIENT, "cl_soundindexlist", CL_SoundIndexList_f, "list all sounds in the client soundindex");
+
+               Cmd_AddCommand(CMD_CLIENT, "fog", CL_Fog_f, "set global fog parameters (density red green blue [alpha [mindist [maxdist [top [fadedepth]]]]])");
+               Cmd_AddCommand(CMD_CLIENT, "fog_heighttexture", CL_Fog_HeightTexture_f, "set global fog parameters (density red green blue alpha mindist maxdist top depth textures/mapname/fogheight.tga)");
+
+               Cmd_AddCommand(CMD_CLIENT, "cl_areastats", CL_AreaStats_f, "prints statistics on entity culling during collision traces");
+
+               Cvar_RegisterVariable(&r_draweffects);
+               Cvar_RegisterVariable(&cl_explosions_alpha_start);
+               Cvar_RegisterVariable(&cl_explosions_alpha_end);
+               Cvar_RegisterVariable(&cl_explosions_size_start);
+               Cvar_RegisterVariable(&cl_explosions_size_end);
+               Cvar_RegisterVariable(&cl_explosions_lifetime);
+               Cvar_RegisterVariable(&cl_stainmaps);
+               Cvar_RegisterVariable(&cl_stainmaps_clearonload);
+               Cvar_RegisterVariable(&cl_beams_polygons);
+               Cvar_RegisterVariable(&cl_beams_quakepositionhack);
+               Cvar_RegisterVariable(&cl_beams_instantaimhack);
+               Cvar_RegisterVariable(&cl_beams_lightatend);
+               Cvar_RegisterVariable(&cl_noplayershadow);
+               Cvar_RegisterVariable(&cl_dlights_decayradius);
+               Cvar_RegisterVariable(&cl_dlights_decaybrightness);
+
+               Cvar_RegisterVariable(&cl_prydoncursor);
+               Cvar_RegisterVariable(&cl_prydoncursor_notrace);
+
+               Cvar_RegisterVariable(&cl_deathnoviewmodel);
+
+               // for QW connections
+               Cvar_RegisterVariable(&qport);
+               Cvar_SetValueQuick(&qport, (rand() * RAND_MAX + rand()) & 0xffff);
+
+               Cmd_AddCommand(CMD_CLIENT, "timerefresh", CL_TimeRefresh_f, "turn quickly and print rendering statistcs");
+
+               Cvar_RegisterVariable(&cl_locs_enable);
+               Cvar_RegisterVariable(&cl_locs_show);
+               Cmd_AddCommand(CMD_CLIENT, "locs_add", CL_Locs_Add_f, "add a point or box location (usage: x y z[ x y z] \"name\", if two sets of xyz are supplied it is a box, otherwise point)");
+               Cmd_AddCommand(CMD_CLIENT, "locs_removenearest", CL_Locs_RemoveNearest_f, "remove the nearest point or box (note: you need to be very near a box to remove it)");
+               Cmd_AddCommand(CMD_CLIENT, "locs_clear", CL_Locs_Clear_f, "remove all loc points/boxes");
+               Cmd_AddCommand(CMD_CLIENT, "locs_reload", CL_Locs_Reload_f, "reload .loc file for this map");
+               Cmd_AddCommand(CMD_CLIENT, "locs_save", CL_Locs_Save_f, "save .loc file for this map containing currently defined points and boxes");
+
+               Cvar_RegisterVariable(&csqc_polygons_defaultmaterial_nocullface);
+
+               CL_Parse_Init();
+               CL_Particles_Init();
+               CL_Screen_Init();
+               CL_MeshEntities_Init();
+
+               CL_Video_Init();
+
+               #ifdef CONFIG_MENU
+               Cbuf_InsertText(&cmd_client,"menu_start\n");
+               #endif
+       }
 }