]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Add cvar sv_legacy_bbox_expand for disabling Quake entity bbox expansion
authorbones_was_here <bones_was_here@xonotic.au>
Fri, 3 Feb 2023 04:51:14 +0000 (14:51 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Fri, 3 Feb 2023 04:51:14 +0000 (14:51 +1000)
This avoids obscure bugs and awkward workarounds especially with CSQC player prediction.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
dpdefs/progsdefs.qc
server.h
sv_main.c
sv_phys.c

index 68f161ce289f47e4dc805e01c84a9d04820b9d52..e0a9acd160868b6df356f9309872e3930a77c0d9 100644 (file)
@@ -236,7 +236,7 @@ float       FL_INWATER                              = 16;   // for enter / leave water splash
 float  FL_MONSTER                              = 32;
 float  FL_GODMODE                              = 64;   // player cheat
 float  FL_NOTARGET                             = 128;  // player cheat
-float  FL_ITEM                                 = 256;  // extra wide size for bonus items
+float  FL_ITEM                                 = 256;  // extra wide size for bonus items IF sv_legacy_bbox_expand is 1
 float  FL_ONGROUND                             = 512;  // standing on something
 float  FL_PARTIALGROUND                = 1024; // not all corners are valid
 float  FL_WATERJUMP                    = 2048; // player jumping out of water
index 5ae7befde0f911157127168a7305f1f8d6db6a0d..9b97054a18773bd6aaead2a9dbd4010b176c71d5 100644 (file)
--- a/server.h
+++ b/server.h
@@ -469,6 +469,7 @@ extern cvar_t sv_gravity;
 extern cvar_t sv_idealpitchscale;
 extern cvar_t sv_jumpstep;
 extern cvar_t sv_jumpvelocity;
+extern cvar_t sv_legacy_bbox_expand;
 extern cvar_t sv_maxairspeed;
 extern cvar_t sv_maxrate;
 extern cvar_t sv_maxspeed;
index 1c3c6f816b3a91b0201e30b77f4f17638786fddc..fd6a624b4bbcd16672fed76bf6a48dd767788098 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -134,6 +134,7 @@ cvar_t sv_init_frame_count = {CF_SERVER, "sv_init_frame_count", "2", "number of
 cvar_t sv_idealpitchscale = {CF_SERVER, "sv_idealpitchscale","0.8", "how much to look up/down slopes and stairs when not using freelook"};
 cvar_t sv_jumpstep = {CF_SERVER | CF_NOTIFY, "sv_jumpstep", "0", "whether you can step up while jumping"};
 cvar_t sv_jumpvelocity = {CF_SERVER, "sv_jumpvelocity", "270", "cvar that can be used by QuakeC code for jump velocity"};
+cvar_t sv_legacy_bbox_expand = {CF_SERVER, "sv_legacy_bbox_expand", "1", "before linking an entity to the area grid, decrease its mins and increase its maxs by '1 1 1', or '15 15 1' if it has flag FL_ITEM (this is the Quake/QuakeWorld behaviour); disable to make SVQC bboxes consistent with CSQC which never does this expansion"};
 cvar_t sv_maxairspeed = {CF_SERVER, "sv_maxairspeed", "30", "maximum speed a player can accelerate to when airborn (note that it is possible to completely stop by moving the opposite direction)"};
 cvar_t sv_maxrate = {CF_SERVER | CF_ARCHIVE | CF_NOTIFY, "sv_maxrate", "1000000", "upper limit on client rate cvar, should reflect your network connection quality"};
 cvar_t sv_maxspeed = {CF_SERVER | CF_NOTIFY, "sv_maxspeed", "320", "maximum speed a player can accelerate to when on ground (can be exceeded by tricks)"};
@@ -612,6 +613,7 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_idealpitchscale);
        Cvar_RegisterVariable (&sv_jumpstep);
        Cvar_RegisterVariable (&sv_jumpvelocity);
+       Cvar_RegisterVariable (&sv_legacy_bbox_expand);
        Cvar_RegisterVariable (&sv_maxairspeed);
        Cvar_RegisterVariable (&sv_maxrate);
        Cvar_RegisterVariable (&sv_maxspeed);
index f2b515935fd2fd7707da4327e2fb9c4af32c35d3..562c0ea902f9bb902de4a6363b22c6f8b31c99bb 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -875,29 +875,30 @@ void SV_LinkEdict (prvm_edict_t *ent)
                VectorAdd(PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, maxs), maxs);
        }
 
-//
-// to make items easier to pick up and allow them to be grabbed off
-// of shelves, the abs sizes are expanded
-//
-       if ((int)PRVM_serveredictfloat(ent, flags) & FL_ITEM)
-       {
-               mins[0] -= 15;
-               mins[1] -= 15;
-               mins[2] -= 1;
-               maxs[0] += 15;
-               maxs[1] += 15;
-               maxs[2] += 1;
-       }
-       else
+       if (sv_legacy_bbox_expand.integer)
        {
-               // because movement is clipped an epsilon away from an actual edge,
-               // we must fully check even when bounding boxes don't quite touch
-               mins[0] -= 1;
-               mins[1] -= 1;
-               mins[2] -= 1;
-               maxs[0] += 1;
-               maxs[1] += 1;
-               maxs[2] += 1;
+               if ((int)PRVM_serveredictfloat(ent, flags) & FL_ITEM)
+               {
+                       // to make items easier to pick up and allow them to be grabbed off
+                       // of shelves, the abs sizes are expanded
+                       mins[0] -= 15;
+                       mins[1] -= 15;
+                       mins[2] -= 1;
+                       maxs[0] += 15;
+                       maxs[1] += 15;
+                       maxs[2] += 1;
+               }
+               else
+               {
+                       // because movement is clipped an epsilon away from an actual edge,
+                       // we must fully check even when bounding boxes don't quite touch
+                       mins[0] -= 1;
+                       mins[1] -= 1;
+                       mins[2] -= 1;
+                       maxs[0] += 1;
+                       maxs[1] += 1;
+                       maxs[2] += 1;
+               }
        }
 
        VectorCopy(mins, PRVM_serveredictvector(ent, absmin));