Add drawonlytoclient, nodrawtoclient, and customizeentityforclient extensions.

This commit is contained in:
Shpoike 2023-07-10 06:31:35 +01:00
parent 8b08262ffb
commit 7435cdd414
2 changed files with 46 additions and 0 deletions

View file

@ -303,6 +303,9 @@ struct pr_extfields_s
QCEXTFIELD(movement, ".vector") /*vector*/ \ QCEXTFIELD(movement, ".vector") /*vector*/ \
QCEXTFIELD(viewmodelforclient, ".entity") /*entity*/ \ QCEXTFIELD(viewmodelforclient, ".entity") /*entity*/ \
QCEXTFIELD(exteriormodeltoclient, ".entity") /*entity*/ \ QCEXTFIELD(exteriormodeltoclient, ".entity") /*entity*/ \
QCEXTFIELD(nodrawtoclient, ".entity") \
QCEXTFIELD(drawonlytoclient, ".entity") \
QCEXTFIELD(customizeentityforclient,".float()") \
QCEXTFIELD(traileffectnum, ".float") /*float*/ \ QCEXTFIELD(traileffectnum, ".float") /*float*/ \
QCEXTFIELD(emiteffectnum, ".float") /*float*/ \ QCEXTFIELD(emiteffectnum, ".float") /*float*/ \
QCEXTFIELD(button3, ".float") /*float*/ \ QCEXTFIELD(button3, ".float") /*float*/ \

View file

@ -1207,6 +1207,18 @@ static void SVFTE_BuildSnapshotForClient (client_t *client)
ent = NEXT_EDICT(qcvm->edicts); ent = NEXT_EDICT(qcvm->edicts);
for (e=1 ; e<maxentities ; e++, ent = NEXT_EDICT(ent)) for (e=1 ; e<maxentities ; e++, ent = NEXT_EDICT(ent))
{ {
if (ent->free)
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; eflags = 0;
emiteffect = GetEdictFieldValue(ent, qcvm->extfields.emiteffectnum)->_float; emiteffect = GetEdictFieldValue(ent, qcvm->extfields.emiteffectnum)->_float;
iscsqc = cancsqc && GetEdictFieldEval(ent, SendEntity)->function; 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. //okay, we care about this entity.
if (iscsqc) if (iscsqc)
@ -2437,6 +2456,17 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg)
ent = NEXT_EDICT(qcvm->edicts); ent = NEXT_EDICT(qcvm->edicts);
for (e=1 ; e<maxedict ; e++, ent = NEXT_EDICT(ent)) for (e=1 ; e<maxedict ; e++, ent = NEXT_EDICT(ent))
{ {
if (ent->free)
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 if (ent != clent) // clent is ALLWAYS sent
{ {
@ -2463,6 +2493,19 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg)
continue; // not visible 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 // 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. // assumed here. And, for protocol 85 the max size is actually 24 bytes.
// For float coords and angles the limit is 40. // For float coords and angles the limit is 40.