From 6b00ed85cd2c8a78ce87772731d575745ae74865 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sun, 8 Sep 2024 19:08:25 +0300 Subject: [PATCH] client: reuse combined colors in CL_ParticleEffect --- src/client/cl_effects.c | 20 ++++++++++---------- src/client/cl_particles.c | 12 ++++++------ src/client/cl_tempentities.c | 32 ++++++++++++++++++-------------- src/client/header/client.h | 8 +++++--- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/client/cl_effects.c b/src/client/cl_effects.c index 99fba188..6411cc95 100644 --- a/src/client/cl_effects.c +++ b/src/client/cl_effects.c @@ -384,7 +384,7 @@ CL_AddMuzzleFlash2(void) dl->color[0] = 1; dl->color[1] = 1; dl->color[2] = 0; - CL_ParticleEffect(origin, vec3_origin, 0, 40); + CL_ParticleEffect(origin, vec3_origin, 0xff000000, 0xff6b6b6b, 40); CL_SmokeAndFlash(origin); S_StartSound(NULL, ent, CHAN_WEAPON, S_RegisterSound("infantry/infatck1.wav"), 1, ATTN_NORM, 0); @@ -401,7 +401,7 @@ CL_AddMuzzleFlash2(void) dl->color[0] = 1; dl->color[1] = 1; dl->color[2] = 0; - CL_ParticleEffect(origin, vec3_origin, 0, 40); + CL_ParticleEffect(origin, vec3_origin, 0xff000000, 0xff6b6b6b, 40); CL_SmokeAndFlash(origin); S_StartSound(NULL, ent, CHAN_WEAPON, S_RegisterSound("soldier/solatck3.wav"), 1, ATTN_NORM, 0); @@ -418,7 +418,7 @@ CL_AddMuzzleFlash2(void) dl->color[0] = 1; dl->color[1] = 1; dl->color[2] = 0; - CL_ParticleEffect(origin, vec3_origin, 0, 40); + CL_ParticleEffect(origin, vec3_origin, 0xff000000, 0xff6b6b6b, 40); CL_SmokeAndFlash(origin); S_StartSound(NULL, ent, CHAN_WEAPON, S_RegisterSound("gunner/gunatck2.wav"), 1, ATTN_NORM, 0); @@ -436,7 +436,7 @@ CL_AddMuzzleFlash2(void) dl->color[1] = 1; dl->color[2] = 0; - CL_ParticleEffect(origin, vec3_origin, 0, 40); + CL_ParticleEffect(origin, vec3_origin, 0xff000000, 0xff6b6b6b, 40); CL_SmokeAndFlash(origin); S_StartSound(NULL, ent, CHAN_WEAPON, S_RegisterSound("infantry/infatck1.wav"), 1, ATTN_NORM, 0); @@ -453,7 +453,7 @@ CL_AddMuzzleFlash2(void) dl->color[1] = 1; dl->color[2] = 0; - CL_ParticleEffect(origin, vec3_origin, 0, 40); + CL_ParticleEffect(origin, vec3_origin, 0xff000000, 0xff6b6b6b, 40); CL_SmokeAndFlash(origin); S_StartSound(NULL, ent, CHAN_WEAPON, S_RegisterSound("infantry/infatck1.wav"), 1, ATTN_NONE, 0); @@ -556,7 +556,7 @@ CL_AddMuzzleFlash2(void) dl->color[0] = 1; dl->color[1] = 1; dl->color[2] = 0; - CL_ParticleEffect(origin, vec3_origin, 0, 40); + CL_ParticleEffect(origin, vec3_origin, 0xff000000, 0xff6b6b6b, 40); CL_SmokeAndFlash(origin); Com_sprintf(soundname, sizeof(soundname), "tank/tnkatk2%c.wav", 'a' + (char)(randk() % 5)); @@ -656,7 +656,7 @@ CL_AddMuzzleFlash2(void) dl->color[0] = 1; dl->color[1] = 1; dl->color[2] = 0; - CL_ParticleEffect(origin, vec3_origin, 0, 40); + CL_ParticleEffect(origin, vec3_origin, 0xff000000, 0xff6b6b6b, 40); CL_SmokeAndFlash(origin); S_StartSound(NULL, ent, CHAN_WEAPON, S_RegisterSound("boss3/xfire.wav"), 1, ATTN_NORM, 0); @@ -671,7 +671,7 @@ CL_AddMuzzleFlash2(void) dl->color[0] = 1; dl->color[1] = 1; dl->color[2] = 0; - CL_ParticleEffect(origin, vec3_origin, 0, 40); + CL_ParticleEffect(origin, vec3_origin, 0xff000000, 0xff6b6b6b, 40); CL_SmokeAndFlash(origin); break; @@ -693,7 +693,7 @@ CL_AddMuzzleFlash2(void) dl->color[1] = 1; dl->color[2] = 0; - CL_ParticleEffect(origin, vec3_origin, 0, 40); + CL_ParticleEffect(origin, vec3_origin, 0xff000000, 0xff6b6b6b, 40); CL_SmokeAndFlash(origin); break; @@ -2951,7 +2951,7 @@ CL_BlasterParticles2(vec3_t org, vec3_t dir, unsigned int basecolor, unsigned in p->time = time; d = (float)(randk() & 15); - p->color = CL_CombineColors(basecolor, finalcolor, d / 15.0); + p->color = CL_CombineColors(basecolor, finalcolor, (float)(randk() & 7) / 7.0); for (j = 0; j < 3; j++) { diff --git a/src/client/cl_particles.c b/src/client/cl_particles.c index fd8f5a30..4a2c9745 100644 --- a/src/client/cl_particles.c +++ b/src/client/cl_particles.c @@ -50,7 +50,7 @@ CL_ClearParticles(void) } void -CL_ParticleEffect(vec3_t org, vec3_t dir, int color, int count) +CL_ParticleEffect(vec3_t org, vec3_t dir, unsigned int basecolor, unsigned int finalcolor, int count) { int i, j; cparticle_t *p; @@ -69,7 +69,7 @@ CL_ParticleEffect(vec3_t org, vec3_t dir, int color, int count) active_particles = p; p->time = cl.time; - p->color = VID_PaletteColor(color + (randk() & 7)); + p->color = CL_CombineColors(basecolor, finalcolor, (float)(randk() & 7) / 7.0); d = randk() & 31; for (j = 0; j < 3; j++) @@ -87,7 +87,7 @@ CL_ParticleEffect(vec3_t org, vec3_t dir, int color, int count) } void -CL_ParticleEffect2(vec3_t org, vec3_t dir, int color, int count) +CL_ParticleEffect2(vec3_t org, vec3_t dir, unsigned int basecolor, unsigned int finalcolor, int count) { int i, j; cparticle_t *p; @@ -109,7 +109,7 @@ CL_ParticleEffect2(vec3_t org, vec3_t dir, int color, int count) active_particles = p; p->time = time; - p->color = VID_PaletteColor(color + (randk() & 7)); + p->color = CL_CombineColors(basecolor, finalcolor, (float)(randk() & 7) / 7.0); d = randk() & 7; @@ -128,7 +128,7 @@ CL_ParticleEffect2(vec3_t org, vec3_t dir, int color, int count) } void -CL_ParticleEffect3(vec3_t org, vec3_t dir, int color, int count) +CL_ParticleEffect3(vec3_t org, vec3_t dir, unsigned int color, int count) { int i, j; cparticle_t *p; @@ -150,7 +150,7 @@ CL_ParticleEffect3(vec3_t org, vec3_t dir, int color, int count) active_particles = p; p->time = time; - p->color = VID_PaletteColor(color); + p->color = color; d = randk() & 7; diff --git a/src/client/cl_tempentities.c b/src/client/cl_tempentities.c index 1ba1d3d6..0026cb61 100644 --- a/src/client/cl_tempentities.c +++ b/src/client/cl_tempentities.c @@ -259,7 +259,8 @@ CL_ParseParticles(void) count = MSG_ReadByte(&net_message); - CL_ParticleEffect(pos, dir, color, count); + CL_ParticleEffect(pos, dir, + VID_PaletteColor(color), VID_PaletteColor(color + 7), count); } void @@ -669,7 +670,7 @@ CL_ParseTEnt(void) case TE_BLOOD: /* bullet hitting flesh */ MSG_ReadPos(&net_message, pos); MSG_ReadDir(&net_message, dir); - CL_ParticleEffect(pos, dir, 0xe8, 60); + CL_ParticleEffect(pos, dir, 0xff001f9b, 0xff00001b, 60); break; case TE_GUNSHOT: /* bullet hitting wall */ @@ -680,11 +681,11 @@ CL_ParseTEnt(void) if (type == TE_GUNSHOT) { - CL_ParticleEffect(pos, dir, 0, 40); + CL_ParticleEffect(pos, dir, 0xff000000, 0xff6b6b6b, 40); } else { - CL_ParticleEffect(pos, dir, 0xe0, 6); + CL_ParticleEffect(pos, dir, 0xff07abff, 0xff002bab, 6); } if (type != TE_SPARKS) @@ -716,12 +717,12 @@ CL_ParseTEnt(void) if (type == TE_SCREEN_SPARKS) { - CL_ParticleEffect(pos, dir, 0xd0, 40); + CL_ParticleEffect(pos, dir, 0xff00ff00, 0xffffffff, 40); } else { - CL_ParticleEffect(pos, dir, 0xb0, 40); + CL_ParticleEffect(pos, dir, 0xffcf7b77, 0xff734747, 40); } if (cl_limitsparksounds->value) @@ -761,7 +762,7 @@ CL_ParseTEnt(void) case TE_SHOTGUN: /* bullet hitting wall */ MSG_ReadPos(&net_message, pos); MSG_ReadDir(&net_message, dir); - CL_ParticleEffect(pos, dir, 0, 20); + CL_ParticleEffect(pos, dir, 0xff000000, 0xff6b6b6b, 20); CL_SmokeAndFlash(pos); break; @@ -780,7 +781,8 @@ CL_ParseTEnt(void) color = splash_color[r]; } - CL_ParticleEffect(pos, dir, color, cnt); + CL_ParticleEffect(pos, dir, + VID_PaletteColor(color), VID_PaletteColor(color + 7), cnt); if (r == SPLASH_SPARKS) { @@ -807,7 +809,8 @@ CL_ParseTEnt(void) MSG_ReadPos(&net_message, pos); MSG_ReadDir(&net_message, dir); color = MSG_ReadByte(&net_message); - CL_ParticleEffect2(pos, dir, color, cnt); + CL_ParticleEffect2(pos, dir, + VID_PaletteColor(color), VID_PaletteColor(color + 7), cnt); break; case TE_BLUEHYPERBLASTER: @@ -1017,7 +1020,8 @@ CL_ParseTEnt(void) MSG_ReadPos(&net_message, pos); MSG_ReadDir(&net_message, dir); color = MSG_ReadByte(&net_message); - CL_ParticleEffect2(pos, dir, color, cnt); + CL_ParticleEffect2(pos, dir, + VID_PaletteColor(color), VID_PaletteColor(color + 7), cnt); ex = CL_AllocExplosion(); VectorCopy(pos, ex->ent.origin); @@ -1035,7 +1039,7 @@ CL_ParseTEnt(void) case TE_GREENBLOOD: MSG_ReadPos(&net_message, pos); MSG_ReadDir(&net_message, dir); - CL_ParticleEffect2(pos, dir, 0xdf, 30); + CL_ParticleEffect2(pos, dir, 0xff0fbfff, 0xff003bb7, 30); break; case TE_TUNNEL_SPARKS: @@ -1043,7 +1047,7 @@ CL_ParseTEnt(void) MSG_ReadPos(&net_message, pos); MSG_ReadDir(&net_message, dir); color = MSG_ReadByte(&net_message); - CL_ParticleEffect3(pos, dir, color, cnt); + CL_ParticleEffect3(pos, dir, VID_PaletteColor(color), cnt); break; case TE_BLASTER2: @@ -1208,7 +1212,7 @@ CL_ParseTEnt(void) case TE_MOREBLOOD: MSG_ReadPos(&net_message, pos); MSG_ReadDir(&net_message, dir); - CL_ParticleEffect(pos, dir, 0xe8, 250); + CL_ParticleEffect(pos, dir, 0xff001f9b, 0xff00001b, 250); break; case TE_CHAINFIST_SMOKE: @@ -1222,7 +1226,7 @@ CL_ParseTEnt(void) case TE_ELECTRIC_SPARKS: MSG_ReadPos(&net_message, pos); MSG_ReadDir(&net_message, dir); - CL_ParticleEffect(pos, dir, 0x75, 40); + CL_ParticleEffect(pos, dir, 0xff5b430f, 0xff1f1700, 40); S_StartSound(pos, 0, 0, cl_sfx_lashit, 1, ATTN_NORM, 0); break; diff --git a/src/client/header/client.h b/src/client/header/client.h index ac02b017..90aba2e6 100644 --- a/src/client/header/client.h +++ b/src/client/header/client.h @@ -364,10 +364,12 @@ typedef struct cl_sustain void CL_ParticleSteamEffect2(cl_sustain_t *self); void CL_TeleporterParticles (entity_state_t *ent); -void CL_ParticleEffect (vec3_t org, vec3_t dir, int color, int count); -void CL_ParticleEffect2 (vec3_t org, vec3_t dir, int color, int count); +void CL_ParticleEffect (vec3_t org, vec3_t dir, unsigned int basecolor, unsigned int finalcolor, + int count); +void CL_ParticleEffect2 (vec3_t org, vec3_t dir, unsigned int basecolor, unsigned int finalcolor, + int count); -void CL_ParticleEffect3 (vec3_t org, vec3_t dir, int color, int count); +void CL_ParticleEffect3 (vec3_t org, vec3_t dir, unsigned int color, int count); typedef struct particle_s