]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Add cvars that disable linking of SOLID_NOT entities: [cl|sv]_areagrid_link_SOLID_NOT
authorbones_was_here <bones_was_here@xonotic.au>
Tue, 21 Feb 2023 16:22:37 +0000 (02:22 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Tue, 21 Feb 2023 16:22:37 +0000 (02:22 +1000)
This also removes the partial solution added in b1d6f1dfb96bedba50fbe394ca3f0c710f99381b https://gitlab.com/xonotic/darkplaces/-/merge_requests/78

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 files changed:
cl_collision.c
cl_main.c
client.h
clvm_cmds.c
csprogs.c
server.h
sv_main.c
sv_phys.c
sv_save.c
svvm_cmds.c
world.c
world.h

index ad6e560080465835819e577095bbf67b4a54f45e..2ba9dc499a8b65f9a8e078d59b85b70d0e62ef3a 100644 (file)
@@ -169,7 +169,7 @@ void CL_LinkEdict(prvm_edict_t *ent)
        VectorCopy(mins, PRVM_clientedictvector(ent, absmin));
        VectorCopy(maxs, PRVM_clientedictvector(ent, absmax));
 
-       World_LinkEdict(&cl.world, ent, mins, maxs);
+       World_LinkEdict(&cl.world, ent, mins, maxs, cl_areagrid_link_SOLID_NOT.integer);
 }
 
 int CL_GenericHitSuperContentsMask(const prvm_edict_t *passedict)
index a403f3e6ba377a081bdb91a359a715834c830c03..c114156382440d2141c3ff6aaf4fa59442317802 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -107,6 +107,8 @@ cvar_t cl_maxfps = {CF_CLIENT | CF_ARCHIVE, "cl_maxfps", "0", "maximum fps cap,
 cvar_t cl_maxfps_alwayssleep = {CF_CLIENT | CF_ARCHIVE, "cl_maxfps_alwayssleep","1", "gives up some processing time to other applications each frame, value in milliseconds, disabled if cl_maxfps is 0"};
 cvar_t cl_maxidlefps = {CF_CLIENT | CF_ARCHIVE, "cl_maxidlefps", "20", "maximum fps cap when the game is not the active window (makes cpu time available to other programs"};
 
+cvar_t cl_areagrid_link_SOLID_NOT = {CF_CLIENT, "cl_areagrid_link_SOLID_NOT", "1", "set to 0 to prevent SOLID_NOT entities from being linked to the area grid, and unlink any that are already linked (in the code paths that would otherwise link them), for better performance"};
+
 client_static_t        cls;
 client_state_t cl;
 
@@ -3134,6 +3136,8 @@ void CL_Init (void)
                Cvar_RegisterVariable (&cl_maxfps_alwayssleep);
                Cvar_RegisterVariable (&cl_maxidlefps);
 
+               Cvar_RegisterVariable (&cl_areagrid_link_SOLID_NOT);
+
                CL_Parse_Init();
                CL_Particles_Init();
                CL_Screen_Init();
index 2006e61fa8cbfa4f78daec849660494d12fd3468..313ba97c2ded7716d4556dbd36ca4c8d5ab991de 100644 (file)
--- a/client.h
+++ b/client.h
@@ -1201,6 +1201,8 @@ extern cvar_t cl_prydoncursor_notrace;
 
 extern cvar_t cl_locs_enable;
 
+extern cvar_t cl_areagrid_link_SOLID_NOT;
+
 extern client_state_t cl;
 
 extern void CL_AllocLightFlash (entity_render_t *ent, matrix4x4_t *matrix, float radius, float red, float green, float blue, float decay, float lifetime, char *cubemapname, int style, int shadowenable, vec_t corona, vec_t coronasizescale, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int flags);
index 44e62aee30ceaad7241fffb4f17d89e2dff85552..6778f274208f6eee921907647e062ed530e4030c 100644 (file)
@@ -2641,8 +2641,6 @@ static void VM_CL_copyentity (prvm_prog_t *prog)
        }
        memcpy(out->fields.fp, in->fields.fp, prog->entityfields * sizeof(prvm_vec_t));
 
-       if (VectorCompare(PRVM_clientedictvector(out, absmin), PRVM_clientedictvector(out, absmax)))
-               return;
        CL_LinkEdict(out);
 }
 
index 4bacb5632e8a595d00d98ed5962766a128b7a67a..20c318a848fa3ae76d51b9ddac22a2368b47845d 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -883,7 +883,7 @@ static void CLVM_end_increase_edicts(prvm_prog_t *prog)
 
        // link every entity except world
        for (i = 1, ent = prog->edicts;i < prog->num_edicts;i++, ent++)
-               if (!ent->free && !VectorCompare(PRVM_clientedictvector(ent, absmin), PRVM_clientedictvector(ent, absmax)))
+               if (!ent->free)
                        CL_LinkEdict(ent);
 }
 
index 9b97054a18773bd6aaead2a9dbd4010b176c71d5..635eb72b29124dc199cfc0b51056ef5c7ebe8db4 100644 (file)
--- a/server.h
+++ b/server.h
@@ -415,6 +415,7 @@ extern cvar_t sv_allowdownloads_archive;
 extern cvar_t sv_allowdownloads_config;
 extern cvar_t sv_allowdownloads_dlcache;
 extern cvar_t sv_allowdownloads_inarchive;
+extern cvar_t sv_areagrid_link_SOLID_NOT;
 extern cvar_t sv_areagrid_mingridsize;
 extern cvar_t sv_checkforpacketsduringsleep;
 extern cvar_t sv_clmovement_enable;
index fd6a624b4bbcd16672fed76bf6a48dd767788098..16fd612b9af1fa942b8bec6658ed556ce8daaba7 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -72,6 +72,7 @@ cvar_t sv_allowdownloads_archive = {CF_SERVER, "sv_allowdownloads_archive", "0",
 cvar_t sv_allowdownloads_config = {CF_SERVER, "sv_allowdownloads_config", "0", "whether to allow downloads of config files (cfg)"};
 cvar_t sv_allowdownloads_dlcache = {CF_SERVER, "sv_allowdownloads_dlcache", "0", "whether to allow downloads of dlcache files (dlcache/)"};
 cvar_t sv_allowdownloads_inarchive = {CF_SERVER, "sv_allowdownloads_inarchive", "0", "whether to allow downloads from archives (pak/pk3)"};
+cvar_t sv_areagrid_link_SOLID_NOT = {CF_SERVER | CF_NOTIFY, "sv_areagrid_link_SOLID_NOT", "1", "set to 0 to prevent SOLID_NOT entities from being linked to the area grid, and unlink any that are already linked (in the code paths that would otherwise link them), for better performance"};
 cvar_t sv_areagrid_mingridsize = {CF_SERVER | CF_NOTIFY, "sv_areagrid_mingridsize", "128", "minimum areagrid cell size, smaller values work better for lots of small objects, higher values for large objects"};
 cvar_t sv_checkforpacketsduringsleep = {CF_SERVER, "sv_checkforpacketsduringsleep", "0", "uses select() function to wait between frames which can be interrupted by packets being received, instead of Sleep()/usleep()/SDL_Sleep() functions which do not check for packets"};
 cvar_t sv_clmovement_enable = {CF_SERVER, "sv_clmovement_enable", "1", "whether to allow clients to use cl_movement prediction, which can cause choppy movement on the server which may annoy other players"};
@@ -551,6 +552,7 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_allowdownloads_config);
        Cvar_RegisterVariable (&sv_allowdownloads_dlcache);
        Cvar_RegisterVariable (&sv_allowdownloads_inarchive);
+       Cvar_RegisterVariable (&sv_areagrid_link_SOLID_NOT);
        Cvar_RegisterVariable (&sv_areagrid_mingridsize);
        Cvar_RegisterVariable (&sv_checkforpacketsduringsleep);
        Cvar_RegisterVariable (&sv_clmovement_enable);
@@ -2155,7 +2157,7 @@ static void SVVM_end_increase_edicts(prvm_prog_t *prog)
 
        // link every entity except world
        for (i = 1, ent = prog->edicts;i < prog->num_edicts;i++, ent++)
-               if (!ent->free && !VectorCompare(PRVM_serveredictvector(ent, absmin), PRVM_serveredictvector(ent, absmax)))
+               if (!ent->free)
                        SV_LinkEdict(ent);
 }
 
index 562c0ea902f9bb902de4a6363b22c6f8b31c99bb..3e1e2749d4f26d01f8e23f082e73488a71b4de1e 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -904,7 +904,7 @@ void SV_LinkEdict (prvm_edict_t *ent)
        VectorCopy(mins, PRVM_serveredictvector(ent, absmin));
        VectorCopy(maxs, PRVM_serveredictvector(ent, absmax));
 
-       World_LinkEdict(&sv.world, ent, mins, maxs);
+       World_LinkEdict(&sv.world, ent, mins, maxs, sv_areagrid_link_SOLID_NOT.integer);
 }
 
 /*
index b90f748775029e8b2ff0b9640fdfef52bd768961..4c0eca7d3958f1185464c80efb84863967ffb3ac 100644 (file)
--- a/sv_save.c
+++ b/sv_save.c
@@ -437,7 +437,7 @@ void SV_Loadgame_f(cmd_state_t *cmd)
                        PRVM_ED_ParseEdict (prog, start, ent);
 
                        // link it into the bsp tree
-                       if (!ent->free && !VectorCompare(PRVM_serveredictvector(ent, absmin), PRVM_serveredictvector(ent, absmax)))
+                       if (!ent->free)
                                SV_LinkEdict(ent);
                }
 
index e77f965079b79d70760fe9eec548ffa509175543..a8ed38364c90edd124866c53106fd9f6ff09ba77 100644 (file)
@@ -1790,8 +1790,7 @@ static void VM_SV_copyentity(prvm_prog_t *prog)
                return;
        }
        memcpy(out->fields.fp, in->fields.fp, prog->entityfields * sizeof(prvm_vec_t));
-       if (VectorCompare(PRVM_serveredictvector(out, absmin), PRVM_serveredictvector(out, absmax)))
-               return;
+
        SV_LinkEdict(out);
 }
 
diff --git a/world.c b/world.c
index 4f7cb48c5ed99f41cb83c4d226d2cfd251f465bd..229fbe7e544c0d1d998a1bf6e146fe06b68981ec 100644 (file)
--- a/world.c
+++ b/world.c
@@ -317,13 +317,17 @@ World_LinkEdict
 
 ===============
 */
-void World_LinkEdict(world_t *world, prvm_edict_t *ent, const vec3_t mins, const vec3_t maxs)
+void World_LinkEdict(world_t *world, prvm_edict_t *ent, const vec3_t mins, const vec3_t maxs, qbool link_solid_not)
 {
        prvm_prog_t *prog = world->prog;
        // unlink from old position first
        if (ent->priv.server->areagrid[0].list.prev)
                World_UnlinkEdict(ent);
 
+       // some games don't want SOLID_NOT entities linked
+       if (!link_solid_not && PRVM_serveredictfloat(ent, solid) == SOLID_NOT)
+               return;
+
        // don't add the world
        if (ent == prog->edicts)
                return;
diff --git a/world.h b/world.h
index 1b60ac6c2b48cbd74db530237db1db418e98ec4d..9e0e01010aa18089ea5ac68a9e07258d0692109e 100644 (file)
--- a/world.h
+++ b/world.h
@@ -112,7 +112,7 @@ void World_PrintAreaStats(world_t *world, const char *worldname);
 void World_UnlinkEdict(struct prvm_edict_s *ent);
 
 /// Needs to be called any time an entity changes origin, mins, maxs
-void World_LinkEdict(world_t *world, struct prvm_edict_s *ent, const vec3_t mins, const vec3_t maxs);
+void World_LinkEdict(world_t *world, struct prvm_edict_s *ent, const vec3_t mins, const vec3_t maxs, qbool link_solid_not);
 
 /// \returns list of entities touching a box
 int World_EntitiesInBox(world_t *world, const vec3_t mins, const vec3_t maxs, int maxlist, struct prvm_edict_s **list);