X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=cl_main.c;h=26bac7799dc0fdeae9b421ccc8b1bf0e4ae0cc36;hb=2e7cb61671ac916469ea6b800eb585b8f7f2c762;hp=6553fce1806d3b95090d239355643801a6fd8bca;hpb=b2980c1b70bd2c5a643d704a68a4868a06dbcaf6;p=xonotic%2Fdarkplaces.git diff --git a/cl_main.c b/cl_main.c index 6553fce1..26bac779 100644 --- 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; @@ -169,7 +171,7 @@ void CL_ClearState(void) cl.entities[i].state_current = defaultstate; } - if (gamemode == GAME_NEXUIZ) + if (gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) { VectorSet(cl.playerstandmins, -16, -16, -24); VectorSet(cl.playerstandmaxs, 16, 16, 45); @@ -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) //{ @@ -903,6 +922,7 @@ void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit, qboolean interpolat int frame; float origin[3], angles[3], lerp; entity_t *t; + entity_render_t *r; //entity_persistent_t *p = &e->persistent; //entity_render_t *r = &e->render; // skip inactive entities and world @@ -935,22 +955,33 @@ void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit, qboolean interpolat return; t = cl.entities + e->state_current.tagentity; // if the tag entity is inactive, skip it - if (!t->state_current.active) - return; - // update the parent first - CL_UpdateNetworkEntity(t, recursionlimit - 1, interpolate); + if (t->state_current.active) + { + // update the parent first + CL_UpdateNetworkEntity(t, recursionlimit - 1, interpolate); + r = &t->render; + } + else + { + // it may still be a CSQC entity... trying to use its + // info from last render frame (better than nothing) + if(!cl.csqc_server2csqcentitynumber[e->state_current.tagentity]) + return; + r = cl.csqcrenderentities + cl.csqc_server2csqcentitynumber[e->state_current.tagentity]; + if(!r->entitynumber) + return; // neither CSQC nor legacy entity... can't attach + } // make relative to the entity - matrix = &t->render.matrix; + matrix = &r->matrix; // some properties of the tag entity carry over - e->render.flags |= t->render.flags & (RENDER_EXTERIORMODEL | RENDER_VIEWMODEL); + e->render.flags |= r->flags & (RENDER_EXTERIORMODEL | RENDER_VIEWMODEL); // if a valid tagindex is used, make it relative to that tag instead - // FIXME: use a model function to get tag info (need to handle skeletal) - if (e->state_current.tagentity && e->state_current.tagindex >= 1 && t->render.model) + if (e->state_current.tagentity && e->state_current.tagindex >= 1 && r->model) { - if(!Mod_Alias_GetTagMatrix(t->render.model, t->render.frameblend, t->render.skeleton, e->state_current.tagindex - 1, &blendmatrix)) // i.e. no error + if(!Mod_Alias_GetTagMatrix(r->model, r->frameblend, r->skeleton, e->state_current.tagindex - 1, &blendmatrix)) // i.e. no error { // concat the tag matrices onto the entity matrix - Matrix4x4_Concat(&tempmatrix, &t->render.matrix, &blendmatrix); + Matrix4x4_Concat(&tempmatrix, &r->matrix, &blendmatrix); // use the constructed tag matrix matrix = &tempmatrix; } @@ -1157,15 +1188,15 @@ void CL_UpdateNetworkEntityTrail(entity_t *e) { if (e->render.effects & EF_BRIGHTFIELD) { - if (gamemode == GAME_NEXUIZ) + if (gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) trailtype = EFFECT_TR_NEXUIZPLASMA; else 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 +1240,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 @@ -1353,7 +1384,13 @@ void CL_LinkNetworkEntity(entity_t *e) return; // if the tag entity is inactive, skip it if (!cl.entities[e->state_current.tagentity].state_current.active) - return; + { + if(!cl.csqc_server2csqcentitynumber[e->state_current.tagentity]) + return; + if(!cl.csqcrenderentities[cl.csqc_server2csqcentitynumber[e->state_current.tagentity]].entitynumber) + return; + // if we get here, it's properly csqc networked and attached + } } // create entity dlights associated with this entity @@ -1376,7 +1413,7 @@ void CL_LinkNetworkEntity(entity_t *e) { if (e->render.effects & EF_BRIGHTFIELD) { - if (gamemode == GAME_NEXUIZ) + if (gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) trailtype = EFFECT_TR_NEXUIZPLASMA; } if (e->render.effects & EF_DIMLIGHT) @@ -1409,9 +1446,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 +1528,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 +1961,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 +2141,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 +2218,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 +2413,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 +2440,7 @@ void CL_Init (void) Cvar_RegisterVariable(&cl_dlights_decaybrightness); Cvar_RegisterVariable(&cl_prydoncursor); + Cvar_RegisterVariable(&cl_prydoncursor_notrace); Cvar_RegisterVariable(&cl_deathnoviewmodel);