Merge MR 'Make trace entity culling optional for spectators'
authorbones_was_here <bones_was_here@xa.org.au>
Thu, 13 Jan 2022 04:29:57 +0000 (14:29 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Thu, 13 Jan 2022 04:31:00 +0000 (14:31 +1000)
https://gitlab.com/xonotic/darkplaces/-/merge_requests/115
https://github.com/DarkPlacesEngine/darkplaces/pull/13

branch: bones_was_here/trace
commits: 2c1140a494598d75a12c01f82d7c9accff974fbb

Signed-off-by: bones_was_here <bones_was_here@xa.org.au>
server.h
sv_ents.c
sv_main.c
sv_send.c

index 02d3786bb6319ec8450539e9695b7d15f69bb472..5ae7befde0f911157127168a7305f1f8d6db6a0d 100644 (file)
--- a/server.h
+++ b/server.h
@@ -581,7 +581,7 @@ int SV_EntitiesInBox(const vec3_t mins, const vec3_t maxs, int maxedicts, prvm_e
 
 qbool SV_CanSeeBox(int numsamples, vec_t eyejitter, vec_t enlarge, vec_t entboxexpand, vec3_t eye, vec3_t entboxmins, vec3_t entboxmaxs);
 
-void SV_MarkWriteEntityStateToClient(entity_state_t *s);
+void SV_MarkWriteEntityStateToClient(entity_state_t *s, client_t *client);
 
 void SV_SendServerinfo(client_t *client);
 void SV_WriteEntitiesToClient(client_t *client, prvm_edict_t *clent, sizebuf_t *msg, int maxsize);
index 8dd9db4d944c5307f585d5248ffe2254fee091cc..895601fa77a63178316c6139f788f8e2a47d7112 100644 (file)
--- a/sv_ents.c
+++ b/sv_ents.c
@@ -395,7 +395,7 @@ void SV_WriteEntitiesToClient(client_t *client, prvm_edict_t *clent, sizebuf_t *
        sv.sententitiesmark++;
 
        for (i = 0;i < sv.numsendentities;i++)
-               SV_MarkWriteEntityStateToClient(sv.sendentities + i);
+               SV_MarkWriteEntityStateToClient(sv.sendentities + i, client);
 
        numsendstates = 0;
        numcsqcsendstates = 0;
index ba0c5d525e3416d05719684870a7120802f7e0a7..8c10fcb042d48cfd0596caa5eb2c403ceb6b7e6c 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -93,6 +93,7 @@ cvar_t sv_cullentities_trace_entityocclusion = {CF_SERVER, "sv_cullentities_trac
 cvar_t sv_cullentities_trace_samples = {CF_SERVER, "sv_cullentities_trace_samples", "2", "number of samples to test for entity culling"};
 cvar_t sv_cullentities_trace_samples_extra = {CF_SERVER, "sv_cullentities_trace_samples_extra", "2", "number of samples to test for entity culling when the entity affects its surroundings by e.g. dlight"};
 cvar_t sv_cullentities_trace_samples_players = {CF_SERVER, "sv_cullentities_trace_samples_players", "8", "number of samples to test for entity culling when the entity is a player entity"};
+cvar_t sv_cullentities_trace_spectators = {CF_SERVER, "sv_cullentities_trace_spectators", "0", "enables trace entity culling for clients that are spectating"};
 cvar_t sv_debugmove = {CF_SERVER | CF_NOTIFY, "sv_debugmove", "0", "disables collision detection optimizations for debugging purposes"};
 cvar_t sv_echobprint = {CF_SERVER | CF_ARCHIVE, "sv_echobprint", "1", "prints gamecode bprint() calls to server console"};
 cvar_t sv_edgefriction = {CF_SERVER, "edgefriction", "1", "how much you slow down when nearing a ledge you might fall off, multiplier of sv_friction (Quake used 2, QuakeWorld used 1 due to a bug in physics code)"};
@@ -570,6 +571,7 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_cullentities_trace_samples);
        Cvar_RegisterVariable (&sv_cullentities_trace_samples_extra);
        Cvar_RegisterVariable (&sv_cullentities_trace_samples_players);
+       Cvar_RegisterVariable (&sv_cullentities_trace_spectators);
        Cvar_RegisterVariable (&sv_debugmove);
        Cvar_RegisterVariable (&sv_echobprint);
        Cvar_RegisterVariable (&sv_edgefriction);
index a1ee1050ab3cb69b14251c0be1bdc3b7ef165e27..3e125f3a58560589759d398858a43608d280f3e7 100644 (file)
--- a/sv_send.c
+++ b/sv_send.c
@@ -34,6 +34,7 @@ extern cvar_t sv_cullentities_trace_samples_players;
 extern cvar_t sv_cullentities_trace_eyejitter;
 extern cvar_t sv_cullentities_trace_expand;
 extern cvar_t sv_cullentities_trace_delay_players;
+extern cvar_t sv_cullentities_trace_spectators;
 
 /*
 =============================================================================
@@ -859,7 +860,7 @@ qbool SV_CanSeeBox(int numtraces, vec_t eyejitter, vec_t enlarge, vec_t entboxex
        return false;
 }
 
-void SV_MarkWriteEntityStateToClient(entity_state_t *s)
+void SV_MarkWriteEntityStateToClient(entity_state_t *s, client_t *client)
 {
        prvm_prog_t *prog = SVVM_prog;
        int isbmodel;
@@ -906,7 +907,7 @@ void SV_MarkWriteEntityStateToClient(entity_state_t *s)
                        // tag attached entities simply check their parent
                        if (!sv.sendentitiesindex[s->tagentity])
                                return;
-                       SV_MarkWriteEntityStateToClient(sv.sendentitiesindex[s->tagentity]);
+                       SV_MarkWriteEntityStateToClient(sv.sendentitiesindex[s->tagentity], client);
                        if (sv.sententities[s->tagentity] != sv.sententitiesmark)
                                return;
                }
@@ -946,7 +947,7 @@ void SV_MarkWriteEntityStateToClient(entity_state_t *s)
                        }
 
                        // or not seen by random tracelines
-                       if (sv_cullentities_trace.integer && !isbmodel && sv.worldmodel && sv.worldmodel->brush.TraceLineOfSight && !r_trippy.integer)
+                       if (sv_cullentities_trace.integer && !isbmodel && sv.worldmodel && sv.worldmodel->brush.TraceLineOfSight && !r_trippy.integer && (client->frags != -666 || sv_cullentities_trace_spectators.integer))
                        {
                                int samples =
                                        s->number <= svs.maxclients