From 065c1582548dd8e25f5102882d5293d5a6cb7add Mon Sep 17 00:00:00 2001 From: Andrei Drexler Date: Fri, 11 Mar 2022 23:55:10 +0300 Subject: [PATCH] Quad/pentagram dlights for 2021 rerelease --- Quake/cl_main.c | 20 ++++++++++++++++++++ Quake/gl_model.h | 3 +++ Quake/pr_edict.c | 34 ++++++++++++++++++++++++++++++++++ Quake/sv_main.c | 7 ++++--- 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/Quake/cl_main.c b/Quake/cl_main.c index 5d870bd9..a707b249 100644 --- a/Quake/cl_main.c +++ b/Quake/cl_main.c @@ -548,6 +548,26 @@ void CL_RelinkEntities (void) dl->radius = 200 + (rand()&31); dl->die = cl.time + 0.001; } + if (ent->effects & EF_QEX_QUADLIGHT) + { + dl = CL_AllocDlight (i); + VectorCopy (ent->origin, dl->origin); + dl->radius = 200 + (rand()&31); + dl->die = cl.time + 0.001; + dl->color[0] = 0.25f; + dl->color[1] = 0.25f; + dl->color[2] = 1.0f; + } + if (ent->effects & EF_QEX_PENTALIGHT) + { + dl = CL_AllocDlight (i); + VectorCopy (ent->origin, dl->origin); + dl->radius = 200 + (rand()&31); + dl->die = cl.time + 0.001; + dl->color[0] = 1.0f; + dl->color[1] = 0.25f; + dl->color[2] = 0.25f; + } if (ent->model->flags & EF_GIB) R_RocketTrail (oldorg, ent->origin, 2); diff --git a/Quake/gl_model.h b/Quake/gl_model.h index 4aebd1d0..5076e521 100644 --- a/Quake/gl_model.h +++ b/Quake/gl_model.h @@ -39,6 +39,9 @@ m*_t structures are in-memory #define EF_MUZZLEFLASH 2 #define EF_BRIGHTLIGHT 4 #define EF_DIMLIGHT 8 +#define EF_QEX_QUADLIGHT 16 // 2021 rerelease +#define EF_QEX_PENTALIGHT 32 // 2021 rerelease +#define EF_QEX_CANDLELIGHT 64 // 2021 rerelease /* diff --git a/Quake/pr_edict.c b/Quake/pr_edict.c index c52f7c0e..1ce58f18 100644 --- a/Quake/pr_edict.c +++ b/Quake/pr_edict.c @@ -35,6 +35,7 @@ static ddef_t *pr_fielddefs; static ddef_t *pr_globaldefs; qboolean pr_alpha_supported; //johnfitz +int pr_effects_mask; // only enable 2021 rerelease quad/penta dlights when applicable dstatement_t *pr_statements; globalvars_t *pr_global_struct; @@ -1041,6 +1042,37 @@ void ED_LoadFromFile (const char *data) } +/* +=============== +PR_HasGlobal +=============== +*/ +static qboolean PR_HasGlobal (const char *name, float value) +{ + ddef_t *g = ED_FindGlobal (name); + return g && (g->type & ~DEF_SAVEGLOBAL) == ev_float && G_FLOAT (g->ofs) == value; +} + + +/* +=============== +PR_FindSupportedEffects + +Checks for the presence of Quake 2021 release effects flags and returns a mask +with the correspondings bits either on or off depending on the result, in order +to avoid conflicts (e.g. Arcane Dimensions uses bit 32 for its explosions) +=============== +*/ +static int PR_FindSupportedEffects (void) +{ + qboolean isqex = + PR_HasGlobal ("EF_QUADLIGHT", EF_QEX_QUADLIGHT) && + (PR_HasGlobal ("EF_PENTLIGHT", EF_QEX_PENTALIGHT) || PR_HasGlobal ("EF_PENTALIGHT", EF_QEX_PENTALIGHT)) + ; + return isqex ? -1 : -1 & ~(EF_QEX_QUADLIGHT|EF_QEX_PENTALIGHT|EF_QEX_CANDLELIGHT); +} + + /* =============== PR_LoadProgs @@ -1145,6 +1177,8 @@ void PR_LoadProgs (void) // properly aligned pr_edict_size += sizeof(void *) - 1; pr_edict_size &= ~(sizeof(void *) - 1); + + pr_effects_mask = PR_FindSupportedEffects (); } diff --git a/Quake/sv_main.c b/Quake/sv_main.c index 07f07d3b..5e43d4af 100644 --- a/Quake/sv_main.c +++ b/Quake/sv_main.c @@ -31,6 +31,7 @@ static char localmodels[MAX_MODELS][8]; // inline model names for precache int sv_protocol = PROTOCOL_FITZQUAKE; //johnfitz extern qboolean pr_alpha_supported; //johnfitz +extern int pr_effects_mask; //============================================================================ @@ -644,7 +645,7 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) if (ent->baseline.frame != ent->v.frame) bits |= U_FRAME; - if (ent->baseline.effects != ent->v.effects) + if ((ent->baseline.effects ^ (int)ent->v.effects) & pr_effects_mask) bits |= U_EFFECTS; if (ent->baseline.modelindex != ent->v.modelindex) @@ -661,7 +662,7 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) } //don't send invisible entities unless they have effects - if (ent->alpha == ENTALPHA_ZERO && !ent->v.effects) + if (ent->alpha == ENTALPHA_ZERO && !((int)ent->v.effects & pr_effects_mask)) continue; //johnfitz @@ -713,7 +714,7 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) if (bits & U_SKIN) MSG_WriteByte (msg, ent->v.skin); if (bits & U_EFFECTS) - MSG_WriteByte (msg, ent->v.effects); + MSG_WriteByte (msg, (int)ent->v.effects & pr_effects_mask); if (bits & U_ORIGIN1) MSG_WriteCoord (msg, ent->v.origin[0], sv.protocolflags); if (bits & U_ANGLE1)