From 74b30af1a9d287fdfa2896af3235769621c1cada Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Tue, 20 Sep 2022 03:13:15 +0300 Subject: [PATCH 1/9] Remove dead assignment. --- src/client/tent.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/client/tent.c b/src/client/tent.c index 527f7703e..8495922cd 100644 --- a/src/client/tent.c +++ b/src/client/tent.c @@ -556,7 +556,6 @@ static void CL_ParsePlayerBeam(qhandle_t model) // override any beam with the same entity for (i = 0, b = cl_playerbeams; i < MAX_BEAMS; i++, b++) { if (b->entity == te.entity1) { - b->entity = te.entity1; b->model = model; b->endtime = cl.time + 200; VectorCopy(te.pos1, b->start); @@ -578,7 +577,6 @@ static void CL_ParsePlayerBeam(qhandle_t model) return; } } - } /* From 4621ece8fe3c0dabb3199d82681c3d83b7260485 Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Tue, 20 Sep 2022 03:13:41 +0300 Subject: [PATCH 2/9] Merge identical switch cases. --- src/client/tent.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/client/tent.c b/src/client/tent.c index 8495922cd..f3b6ca9e3 100644 --- a/src/client/tent.c +++ b/src/client/tent.c @@ -1226,12 +1226,6 @@ void CL_ParseTEnt(void) S_StartSound(te.pos1, 0, 0, cl_sfx_grenexp, 1, ATTN_NORM, 0); break; - case TE_PLASMA_EXPLOSION: - CL_PlainExplosion(false); - CL_ExplosionParticles(te.pos1); - S_StartSound(te.pos1, 0, 0, cl_sfx_rockexp, 1, ATTN_NORM, 0); - break; - case TE_ROCKET_EXPLOSION: case TE_ROCKET_EXPLOSION_WATER: ex = CL_PlainExplosion(false); @@ -1251,6 +1245,7 @@ void CL_ParseTEnt(void) break; case TE_EXPLOSION1: + case TE_PLASMA_EXPLOSION: CL_PlainExplosion(false); CL_ExplosionParticles(te.pos1); S_StartSound(te.pos1, 0, 0, cl_sfx_rockexp, 1, ATTN_NORM, 0); From a5d13c5e1e99d1cd1c48722d9db8f7efc5767cea Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Sat, 14 Jan 2023 16:35:27 +0300 Subject: [PATCH 3/9] Change CL_ParseLaser() argument to unsigned. --- src/client/tent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/tent.c b/src/client/tent.c index f3b6ca9e3..3f28d2940 100644 --- a/src/client/tent.c +++ b/src/client/tent.c @@ -479,7 +479,7 @@ static void CL_AddLasers(void) } } -static void CL_ParseLaser(int colors) +static void CL_ParseLaser(unsigned colors) { laser_t *l; From 7037b32912f7b307c2164c514015fbe55e7109c7 Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Sat, 14 Jan 2023 16:38:19 +0300 Subject: [PATCH 4/9] Avoid adding dummy lasers at very first frame. --- src/client/tent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/tent.c b/src/client/tent.c index 3f28d2940..b59df108d 100644 --- a/src/client/tent.c +++ b/src/client/tent.c @@ -458,7 +458,7 @@ static void CL_AddLasers(void) for (i = 0, l = cl_lasers; i < MAX_LASERS; i++, l++) { time = l->lifetime - (cl.time - l->starttime); - if (time < 0) { + if (time <= 0) { continue; } From c3286d075db2d35ddf97ae173e468be19a296087 Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Sat, 14 Jan 2023 16:52:15 +0300 Subject: [PATCH 5/9] Use VectorSet() to set lightcolor. --- src/client/tent.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/client/tent.c b/src/client/tent.c index b59df108d..4e6cfacdf 100644 --- a/src/client/tent.c +++ b/src/client/tent.c @@ -1159,9 +1159,7 @@ void CL_ParseTEnt(void) case TE_FLECHETTE: CL_BlasterParticles2(te.pos1, te.dir, 0x6f); // 75 ex->ent.skinnum = 2; - ex->lightcolor[0] = 0.19f; - ex->lightcolor[1] = 0.41f; - ex->lightcolor[2] = 0.75f; + VectorSet(ex->lightcolor, 0.19f, 0.41f, 0.75f); break; case TE_FLARE: CL_BlasterParticles2(te.pos1, te.dir, 0xd0); @@ -1268,9 +1266,7 @@ void CL_ParseTEnt(void) ex->ent.flags = RF_FULLBRIGHT; ex->start = cl.servertime - CL_FRAMETIME; ex->light = 350; - ex->lightcolor[0] = 0.0f; - ex->lightcolor[1] = 1.0f; - ex->lightcolor[2] = 0.0f; + VectorSet(ex->lightcolor, 0.0f, 1.0f, 0.0f); ex->ent.model = cl_mod_bfg_explo; ex->ent.flags |= RF_TRANSLUCENT; ex->ent.alpha = 0.80; @@ -1317,9 +1313,7 @@ void CL_ParseTEnt(void) ex->ent.flags = RF_BEAM; ex->start = cl.servertime - CL_FRAMETIME; ex->light = 100 + (Q_rand() % 75); - ex->lightcolor[0] = 1.0f; - ex->lightcolor[1] = 1.0f; - ex->lightcolor[2] = 0.3f; + VectorSet(ex->lightcolor, 1.0f, 1.0f, 0.3f); ex->ent.model = cl_mod_flash; ex->frames = 2; break; From b46b07bb45245c52a566103d2f8e410fa843a7e8 Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Sat, 14 Jan 2023 20:53:18 +0300 Subject: [PATCH 6/9] Simplify setting rail color. --- src/client/tent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/tent.c b/src/client/tent.c index 4e6cfacdf..a5a639bac 100644 --- a/src/client/tent.c +++ b/src/client/tent.c @@ -923,7 +923,7 @@ static void CL_RailCore(void) l->color = -1; l->lifetime = cl_railtrail_time->integer; l->width = cl_railcore_width->integer; - l->rgba.u32 = railcore_color.u32; + l->rgba = railcore_color; } static void CL_RailSpiral(void) @@ -962,7 +962,7 @@ static void CL_RailSpiral(void) p->alpha = 1.0f; p->alphavel = -1.0f / (cl_railtrail_time->value + frand() * 0.2f); p->color = -1; - p->rgba.u32 = railspiral_color.u32; + p->rgba = railspiral_color; p->brightness = cvar_pt_particle_emissive->value; for (j = 0; j < 3; j++) { p->org[j] = move[j] + dir[j] * cl_railspiral_radius->value; From fc7d0d7550e395c588be178d3d62649b252067ad Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Mon, 4 Sep 2023 22:21:11 +0300 Subject: [PATCH 7/9] Avoid division by zero in CL_Add(Player)Beams(). --- src/client/tent.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/client/tent.c b/src/client/tent.c index a5a639bac..d3bac9cb1 100644 --- a/src/client/tent.c +++ b/src/client/tent.c @@ -586,13 +586,13 @@ CL_AddBeams */ static void CL_AddBeams(void) { - int i, j; + int i, j, steps; beam_t *b; vec3_t dist, org; float d; entity_t ent; vec3_t angles; - float len, steps; + float len; float model_length; // update beams @@ -618,8 +618,7 @@ static void CL_AddBeams(void) } else { model_length = 30.0f; } - steps = ceil(d / model_length); - len = (d - model_length) / (steps - 1); + steps = ceilf(d / model_length); memset(&ent, 0, sizeof(ent)); ent.model = b->model; @@ -627,7 +626,7 @@ static void CL_AddBeams(void) // PMM - special case for lightning model .. if the real length is shorter than the model, // flip it around & draw it from the end to the start. This prevents the model from going // through the tesla mine (instead it goes through the target) - if ((b->model == cl_mod_lightning) && (d <= model_length)) { + if ((b->model == cl_mod_lightning) && (steps <= 1)) { VectorCopy(b->end, ent.origin); ent.flags = RF_FULLBRIGHT; ent.angles[0] = angles[0]; @@ -637,8 +636,13 @@ static void CL_AddBeams(void) return; } - while (d > 0) { - VectorCopy(org, ent.origin); + if (steps > 1) { + len = (d - model_length) / (steps - 1); + VectorScale(dist, len, dist); + } + + VectorCopy(org, ent.origin); + for (j = 0; i < steps; j++) { if (b->model == cl_mod_lightning) { ent.flags = RF_FULLBRIGHT; ent.angles[0] = -angles[0]; @@ -651,10 +655,7 @@ static void CL_AddBeams(void) } V_AddEntity(&ent); - - for (j = 0; j < 3; j++) - org[j] += dist[j] * len; - d -= model_length; + VectorAdd(ent.origin, dist, ent.origin); } } } @@ -668,13 +669,13 @@ Draw player locked beams. Currently only used by the plasma beam. */ static void CL_AddPlayerBeams(void) { - int i, j; + int i, j, steps; beam_t *b; vec3_t dist, org; float d; entity_t ent; vec3_t angles; - float len, steps; + float len; int framenum; float model_length; float hand_multiplier; @@ -757,8 +758,11 @@ static void CL_AddPlayerBeams(void) // add new entities for the beams d = VectorNormalize(dist); model_length = 32.0f; - steps = ceil(d / model_length); - len = (d - model_length) / (steps - 1); + steps = ceilf(d / model_length); + if (steps > 1) { + len = (d - model_length) / (steps - 1); + VectorScale(dist, len, dist); + } memset(&ent, 0, sizeof(ent)); ent.model = b->model; @@ -768,14 +772,10 @@ static void CL_AddPlayerBeams(void) ent.angles[1] = angles[1] + 180.0f; ent.angles[2] = cl.time % 360; - while (d > 0) { - VectorCopy(org, ent.origin); - + VectorCopy(org, ent.origin); + for (j = 0; j < steps; j++) { V_AddEntity(&ent); - - for (j = 0; j < 3; j++) - org[j] += dist[j] * len; - d -= model_length; + VectorAdd(ent.origin, dist, ent.origin); } } } From eb8eec8d3432a97f0286cafd942db32224a28f4b Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Thu, 7 Sep 2023 15:44:11 +0300 Subject: [PATCH 8/9] Fix loop variable. --- src/client/tent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/tent.c b/src/client/tent.c index d3bac9cb1..bf2ed1670 100644 --- a/src/client/tent.c +++ b/src/client/tent.c @@ -642,7 +642,7 @@ static void CL_AddBeams(void) } VectorCopy(org, ent.origin); - for (j = 0; i < steps; j++) { + for (j = 0; j < steps; j++) { if (b->model == cl_mod_lightning) { ent.flags = RF_FULLBRIGHT; ent.angles[0] = -angles[0]; From 9077df07a70d6bee079e4a6cd2603a54f992bb09 Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Wed, 13 Sep 2023 20:37:10 +0300 Subject: [PATCH 9/9] Put back pitch angle negation in CL_AddPlayerBeams(). It was there in original code and was somehow lost. Likely it doesn't matter, that code is awful anyway. --- src/client/tent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/tent.c b/src/client/tent.c index bf2ed1670..34af59f8e 100644 --- a/src/client/tent.c +++ b/src/client/tent.c @@ -739,7 +739,7 @@ static void CL_AddPlayerBeams(void) if (!VectorEmpty(b->offset)) { vec3_t tmp, f, r, u; - tmp[0] = angles[0]; + tmp[0] = -angles[0]; tmp[1] = angles[1] + 180.0f; tmp[2] = 0; AngleVectors(tmp, f, r, u);