From 7435cdd414b0c76a0a1beefe49a4e237cf9eeee9 Mon Sep 17 00:00:00 2001 From: Shpoike Date: Mon, 10 Jul 2023 06:31:35 +0100 Subject: [PATCH] Add drawonlytoclient, nodrawtoclient, and customizeentityforclient extensions. --- Quake/progs.h | 3 +++ Quake/sv_main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/Quake/progs.h b/Quake/progs.h index 240bc287..38917d7e 100644 --- a/Quake/progs.h +++ b/Quake/progs.h @@ -303,6 +303,9 @@ struct pr_extfields_s QCEXTFIELD(movement, ".vector") /*vector*/ \ QCEXTFIELD(viewmodelforclient, ".entity") /*entity*/ \ QCEXTFIELD(exteriormodeltoclient, ".entity") /*entity*/ \ + QCEXTFIELD(nodrawtoclient, ".entity") \ + QCEXTFIELD(drawonlytoclient, ".entity") \ + QCEXTFIELD(customizeentityforclient,".float()") \ QCEXTFIELD(traileffectnum, ".float") /*float*/ \ QCEXTFIELD(emiteffectnum, ".float") /*float*/ \ QCEXTFIELD(button3, ".float") /*float*/ \ diff --git a/Quake/sv_main.c b/Quake/sv_main.c index 6b45c0c5..1dcfeb84 100644 --- a/Quake/sv_main.c +++ b/Quake/sv_main.c @@ -1207,6 +1207,18 @@ static void SVFTE_BuildSnapshotForClient (client_t *client) ent = NEXT_EDICT(qcvm->edicts); for (e=1 ; efree) + goto invisible; + val = GetEdictFieldValue(ent, qcvm->extfields.customizeentityforclient); + if (val && val->function) + { + pr_global_struct->self = EDICT_TO_PROG(ent); //ent being customised + pr_global_struct->other = proged; //player they're being customised for + PR_ExecuteProgram(val->function); + if (!G_FLOAT(OFS_RETURN)) + goto invisible; + } + eflags = 0; emiteffect = GetEdictFieldValue(ent, qcvm->extfields.emiteffectnum)->_float; iscsqc = cancsqc && GetEdictFieldEval(ent, SendEntity)->function; @@ -1251,6 +1263,13 @@ invisible: } } + val = GetEdictFieldValue(ent, qcvm->extfields.nodrawtoclient); + if (val && val->edict == proged) + goto invisible; + val = GetEdictFieldValue(ent, qcvm->extfields.drawonlytoclient); + if (val && val->edict && val->edict != proged) + goto invisible; + //okay, we care about this entity. if (iscsqc) @@ -2437,6 +2456,17 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg) ent = NEXT_EDICT(qcvm->edicts); for (e=1 ; efree) + continue; + val = GetEdictFieldValue(ent, qcvm->extfields.customizeentityforclient); + if (val && val->function) + { + pr_global_struct->self = EDICT_TO_PROG(ent); //ent being customised + pr_global_struct->other = EDICT_TO_PROG(client);//player they're being customised for + PR_ExecuteProgram(val->function); + if (!G_FLOAT(OFS_RETURN)) + continue; + } if (ent != clent) // clent is ALLWAYS sent { @@ -2463,6 +2493,19 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg) continue; // not visible } + val = GetEdictFieldValue(ent, qcvm->extfields.nodrawtoclient); + if (val && val->edict == EDICT_TO_PROG(client)) + continue; + val = GetEdictFieldValue(ent, qcvm->extfields.drawonlytoclient); + if (val && val->edict && val->edict != EDICT_TO_PROG(client)) + continue; + val = GetEdictFieldValue(ent, qcvm->extfields.viewmodelforclient); + if (val && val->edict) //can't handle this this for this player. can't cleanly attach it to their view so don't even treat it like drawonlytoclient. + continue; + val = GetEdictFieldValue(ent, qcvm->extfields.exteriormodeltoclient); + if (val && val->edict == EDICT_TO_PROG(client)) //can't handle this for this player. pretend its nodrawtoclient. + continue; + // johnfitz -- max size for protocol 15 is 18 bytes, not 16 as originally // assumed here. And, for protocol 85 the max size is actually 24 bytes. // For float coords and angles the limit is 40.