]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_main.c
added arg: connect-userinfo; works like this: "connect server password foobar" will...
[xonotic/darkplaces.git] / cl_main.c
index 6553fce1806d3b95090d239355643801a6fd8bca..f005cafdb37778ec1759f58e53086cb978088356 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -57,6 +57,7 @@ cvar_t freelook = {CVAR_SAVE, "freelook", "1","mouse controls pitch instead of f
 
 cvar_t cl_autodemo = {CVAR_SAVE, "cl_autodemo", "0", "records every game played, using the date/time and map name to name the demo file" };
 cvar_t cl_autodemo_nameformat = {CVAR_SAVE, "cl_autodemo_nameformat", "autodemos/%Y-%m-%d_%H-%M", "The format of the cl_autodemo filename, followed by the map name (the date is encoded using strftime escapes)" };
+cvar_t cl_autodemo_delete = {0, "cl_autodemo_delete", "0", "Delete demos after recording.  This is a bitmask, bit 1 gives the default, bit 0 the value for the current demo.  Thus, the values are: 0 = disabled; 1 = delete current demo only; 2 = delete all demos except the current demo; 3 = delete all demos from now on" };
 
 cvar_t r_draweffects = {0, "r_draweffects", "1","renders temporary sprite effects"};
 
@@ -84,6 +85,7 @@ cvar_t cl_dlights_decaybrightness = {CVAR_SAVE, "cl_dlights_decaybrightness", "1
 cvar_t qport = {0, "qport", "0", "identification key for playing on qw servers (allows you to maintain a connection to a quakeworld server even if your port changes)"};
 
 cvar_t cl_prydoncursor = {0, "cl_prydoncursor", "0", "enables a mouse pointer which is able to click on entities in the world, useful for point and click mods, see PRYDON_CLIENTCURSOR extension in dpextensions.qc"};
+cvar_t cl_prydoncursor_notrace = {0, "cl_prydoncursor_notrace", "0", "disables traceline used in prydon cursor reporting to the game, saving some cpu time"};
 
 cvar_t cl_deathnoviewmodel = {0, "cl_deathnoviewmodel", "1", "hides gun model when dead"};
 
@@ -120,7 +122,7 @@ void CL_ClearState(void)
        cl.sensitivityscale = 1.0f;
 
        // enable rendering of the world and such
-       cl.csqc_vidvars.drawworld = true;
+       cl.csqc_vidvars.drawworld = r_drawworld.integer != 0;
        cl.csqc_vidvars.drawenginesbar = true;
        cl.csqc_vidvars.drawcrosshair = true;
 
@@ -405,7 +407,7 @@ CL_EstablishConnection
 Host should be either "local" or a net address
 =====================
 */
-void CL_EstablishConnection(const char *host)
+void CL_EstablishConnection(const char *host, int firstarg)
 {
        if (cls.state == ca_dedicated)
                return;
@@ -432,7 +434,24 @@ void CL_EstablishConnection(const char *host)
                cls.connect_trying = true;
                cls.connect_remainingtries = 3;
                cls.connect_nextsendtime = 0;
+
+               // only NOW, set connect_userinfo
+               if(firstarg >= 0)
+               {
+                       int i;
+                       *cls.connect_userinfo = 0;
+                       for(i = firstarg; i+2 <= Cmd_Argc(); i += 2)
+                               InfoString_SetValue(cls.connect_userinfo, sizeof(cls.connect_userinfo), Cmd_Argv(i), Cmd_Argv(i+1));
+               }
+               else if(firstarg < -1)
+               {
+                       // -1: keep as is (reconnect)
+                       // -2: clear
+                       *cls.connect_userinfo = 0;
+               }
+
                M_Update_Return_Reason("Trying to connect...");
+
                // run several network frames to jump into the game quickly
                //if (sv.active)
                //{
@@ -1163,9 +1182,9 @@ void CL_UpdateNetworkEntityTrail(entity_t *e)
                                CL_EntityParticles(e);
                }
                if (e->render.effects & EF_FLAME)
-                       CL_ParticleTrail(EFFECT_EF_FLAME, bound(0, cl.time - cl.oldtime, 0.1), origin, origin, vec3_origin, vec3_origin, NULL, 0, false, true);
+                       CL_ParticleTrail(EFFECT_EF_FLAME, bound(0, cl.time - cl.oldtime, 0.1), origin, origin, vec3_origin, vec3_origin, NULL, 0, false, true, NULL, NULL);
                if (e->render.effects & EF_STARDUST)
-                       CL_ParticleTrail(EFFECT_EF_STARDUST, bound(0, cl.time - cl.oldtime, 0.1), origin, origin, vec3_origin, vec3_origin, NULL, 0, false, true);
+                       CL_ParticleTrail(EFFECT_EF_STARDUST, bound(0, cl.time - cl.oldtime, 0.1), origin, origin, vec3_origin, vec3_origin, NULL, 0, false, true, NULL, NULL);
        }
        if (e->render.internaleffects & (INTEF_FLAG1QW | INTEF_FLAG2QW))
        {
@@ -1209,7 +1228,7 @@ void CL_UpdateNetworkEntityTrail(entity_t *e)
                if (len > 0)
                        len = 1.0f / len;
                VectorScale(vel, len, vel);
-               CL_ParticleTrail(trailtype, 1, e->persistent.trail_origin, origin, vel, vel, e, e->state_current.glowcolor, false, true);
+               CL_ParticleTrail(trailtype, 1, e->persistent.trail_origin, origin, vel, vel, e, e->state_current.glowcolor, false, true, NULL, NULL);
        }
        // now that the entity has survived one trail update it is allowed to
        // leave a real trail on later frames
@@ -1409,9 +1428,9 @@ void CL_LinkNetworkEntity(entity_t *e)
                        dlightcolor[2] += 1.50f;
                }
                if (e->render.effects & EF_FLAME)
-                       CL_ParticleTrail(EFFECT_EF_FLAME, 0, origin, origin, vec3_origin, vec3_origin, NULL, 0, true, false);
+                       CL_ParticleTrail(EFFECT_EF_FLAME, 1, origin, origin, vec3_origin, vec3_origin, NULL, 0, true, false, NULL, NULL);
                if (e->render.effects & EF_STARDUST)
-                       CL_ParticleTrail(EFFECT_EF_STARDUST, 0, origin, origin, vec3_origin, vec3_origin, NULL, 0, true, false);
+                       CL_ParticleTrail(EFFECT_EF_STARDUST, 1, origin, origin, vec3_origin, vec3_origin, NULL, 0, true, false, NULL, NULL);
        }
        // muzzleflash fades over time, and is offset a bit
        if (e->persistent.muzzleflash > 0 && r_refdef.scene.numlights < MAX_DLIGHTS)
@@ -1491,12 +1510,8 @@ void CL_LinkNetworkEntity(entity_t *e)
        if (e->render.flags & RENDER_GLOWTRAIL)
                trailtype = EFFECT_TR_GLOWTRAIL;
        if (trailtype)
-               CL_ParticleTrail(trailtype, 0, origin, origin, vec3_origin, vec3_origin, NULL, e->state_current.glowcolor, true, false);
+               CL_ParticleTrail(trailtype, 1, origin, origin, vec3_origin, vec3_origin, NULL, e->state_current.glowcolor, true, false, NULL, NULL);
 
-       // don't show viewmodels in certain situations
-       if (e->render.flags & RENDER_VIEWMODEL)
-               if (!r_drawviewmodel.integer || chase_active.integer || r_refdef.envmap)
-                       return;
        // don't show entities with no modelindex (note: this still shows
        // entities which have a modelindex that resolved to a NULL model)
        if (e->render.model && !(e->render.effects & EF_NODRAW) && r_refdef.scene.numentities < r_refdef.scene.maxentities)
@@ -1928,6 +1943,32 @@ static void CL_Fog_f (void)
                r_refdef.fog_fadedepth = atof(Cmd_Argv(9));
 }
 
+/*
+======================
+CL_FogHeightTexture_f
+======================
+*/
+static void CL_Fog_HeightTexture_f (void)
+{
+       if (Cmd_Argc () < 11)
+       {
+               Con_Printf("\"fog_heighttexture\" is \"%f %f %f %f %f %f %f %f %f %s\"\n", r_refdef.fog_density, r_refdef.fog_red, r_refdef.fog_green, r_refdef.fog_blue, r_refdef.fog_alpha, r_refdef.fog_start, r_refdef.fog_end, r_refdef.fog_height, r_refdef.fog_fadedepth, r_refdef.fog_height_texturename);
+               return;
+       }
+       FOG_clear(); // so missing values get good defaults
+       r_refdef.fog_density = atof(Cmd_Argv(1));
+       r_refdef.fog_red = atof(Cmd_Argv(2));
+       r_refdef.fog_green = atof(Cmd_Argv(3));
+       r_refdef.fog_blue = atof(Cmd_Argv(4));
+       r_refdef.fog_alpha = atof(Cmd_Argv(5));
+       r_refdef.fog_start = atof(Cmd_Argv(6));
+       r_refdef.fog_end = atof(Cmd_Argv(7));
+       r_refdef.fog_height = atof(Cmd_Argv(8));
+       r_refdef.fog_fadedepth = atof(Cmd_Argv(9));
+       strlcpy(r_refdef.fog_height_texturename, Cmd_Argv(10), sizeof(r_refdef.fog_height_texturename));
+}
+
+
 /*
 ====================
 CL_TimeRefresh_f
@@ -2082,8 +2123,7 @@ void CL_Locs_Save_f(void)
                Con_Printf("No level loaded!\n");
                return;
        }
-       FS_StripExtension(cl.worldmodel->name, locfilename, sizeof(locfilename));
-       strlcat(locfilename, ".loc", sizeof(locfilename));
+       dpsnprintf(locfilename, sizeof(locfilename), "%s.loc", cl.worldnamenoextension);
 
        outfile = FS_OpenRealFile(locfilename, "w", false);
        if (!outfile)
@@ -2160,14 +2200,12 @@ void CL_Locs_Reload_f(void)
        CL_Locs_Clear_f();
 
        // try maps/something.loc first (LordHavoc: where I think they should be)
-       FS_StripExtension(cl.worldmodel->name, locfilename, sizeof(locfilename));
-       strlcat(locfilename, ".loc", sizeof(locfilename));
+       dpsnprintf(locfilename, sizeof(locfilename), "%s.loc", cl.worldnamenoextension);
        filedata = (char *)FS_LoadFile(locfilename, cls.levelmempool, false, &filesize);
        if (!filedata)
        {
                // try proquake name as well (LordHavoc: I hate path mangling)
-               FS_StripExtension(va("locs/%s", FS_FileWithoutPath(cl.worldmodel->name)), locfilename, sizeof(locfilename));
-               strlcat(locfilename, ".loc", sizeof(locfilename));
+               dpsnprintf(locfilename, sizeof(locfilename), "locs/%s.loc", cl.worldbasename);
                filedata = (char *)FS_LoadFile(locfilename, cls.levelmempool, false, &filesize);
                if (!filedata)
                        return;
@@ -2357,8 +2395,10 @@ void CL_Init (void)
 
        Cvar_RegisterVariable (&cl_autodemo);
        Cvar_RegisterVariable (&cl_autodemo_nameformat);
+       Cvar_RegisterVariable (&cl_autodemo_delete);
 
-       Cmd_AddCommand ("fog", CL_Fog_f, "set global fog parameters (density red green blue [alpha [mindist maxdist]])");
+       Cmd_AddCommand ("fog", CL_Fog_f, "set global fog parameters (density red green blue [alpha [mindist [maxdist [top [fadedepth]]]]])");
+       Cmd_AddCommand ("fog_heighttexture", CL_Fog_HeightTexture_f, "set global fog parameters (density red green blue alpha mindist maxdist top depth textures/mapname/fogheight.tga)");
 
        // LordHavoc: added pausedemo
        Cmd_AddCommand ("pausedemo", CL_PauseDemo_f, "pause demo playback (can also safely pause demo recording if using QUAKE, QUAKEDP or NEHAHRAMOVIE protocol, useful for making movies)");
@@ -2382,6 +2422,7 @@ void CL_Init (void)
        Cvar_RegisterVariable(&cl_dlights_decaybrightness);
 
        Cvar_RegisterVariable(&cl_prydoncursor);
+       Cvar_RegisterVariable(&cl_prydoncursor_notrace);
 
        Cvar_RegisterVariable(&cl_deathnoviewmodel);