]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add engine extension checks at VM startup and a nudgeoutofsolid fallback
authorbones_was_here <bones_was_here@xonotic.au>
Sat, 22 Jul 2023 08:10:33 +0000 (18:10 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Tue, 12 Mar 2024 01:59:41 +0000 (11:59 +1000)
This allows printing proper messages immediately rather than crashing
later or silently failing to download maps or support player IDs, which
may prevent broken 3rd party packages.

Implements a fallback to WarpZoneLib_MoveOutOfSolid() for when the new
DP_QC_NUDGEOUTOFSOLID isn't available.  Adds a "wasn't-stuck" `-1`
result to WarpZoneLib_MoveOutOfSolid(), to prevent warning spam in the
fallback path.

qcsrc/client/main.qc
qcsrc/common/_all.inc
qcsrc/common/checkextension.qc [new file with mode: 0644]
qcsrc/common/checkextension.qh [new file with mode: 0644]
qcsrc/lib/warpzone/common.qc
qcsrc/lib/warpzone/common.qh
qcsrc/lib/warpzone/util_server.qh
qcsrc/menu/menu.qc
qcsrc/server/world.qc

index 9e214551097dd0dc60e5d3431cbfd4df32b43ecc..e30f9bbcb21d481cbbfe9cb156bf8332f1a3b3cf 100644 (file)
@@ -13,6 +13,7 @@
 #include <client/shownames.qh>
 #include <client/view.qh>
 #include <client/weapons/projectile.qh>
+#include <common/checkextension.qh>
 #include <common/deathtypes/all.qh>
 #include <common/effects/all.inc>
 #include <common/effects/all.qh>
@@ -50,6 +51,8 @@ void CSQC_Init()
        LOG_TRACEF("^4CSQC Build information: ^1%s", WATERMARK);
 #endif
 
+       CheckEngineExtensions();
+
        {
                int i = 0;
                for ( ; i < 255; ++i)
index 0a2cca157e65e54bd9bd3d9fb45b64a2dfdc4eba..b775b9686af21c166eaccff8b3da1688cba3d83c 100644 (file)
@@ -1,5 +1,7 @@
 noref float autocvar_net_connecttimeout = 30;
 
+#include "checkextension.qc"
+
 #ifdef GAMEQC
 #include "anim.qc"
 #include "animdecide.qc"
diff --git a/qcsrc/common/checkextension.qc b/qcsrc/common/checkextension.qc
new file mode 100644 (file)
index 0000000..4906f84
--- /dev/null
@@ -0,0 +1,24 @@
+#include "checkextension.qh"
+
+void CheckEngineExtensions(void)
+{
+       if (!cvar("pr_checkextension"))
+               LOG_FATAL("Engine lacks the QC extension system.");
+
+       if (!checkextension("DP_QC_URI_GET") || !checkextension("DP_QC_URI_POST"))
+               LOG_WARN("Engine lacks HTTP support, XonStat and map downloads are unavailable.");
+
+       if (!checkextension("DP_CRYPTO"))
+               LOG_WARN("Engine lacks DP_CRYPTO, Player IDs (required for XonStat and CTS/CTF records) are unavailable.");
+
+#ifdef SVQC // change to GAMEQC if/when we use nudgeoutofsolid in CSQC
+       if (!checkextension("DP_QC_NUDGEOUTOFSOLID"))
+       {
+               LOG_WARN("Engine lacks DP_QC_NUDGEOUTOFSOLID, falling back to WarpZoneLib_MoveOutOfSolid().");
+               // DP_QC_NUDGEOUTOFSOLID fixes many cases WarpZoneLib_MoveOutOfSolid() can't, usually in less CPU time
+               nudgeoutofsolid = WarpZoneLib_MoveOutOfSolid;
+       }
+#endif
+
+       // TODO: add proper warns/errors for other extensions we depend on
+}
diff --git a/qcsrc/common/checkextension.qh b/qcsrc/common/checkextension.qh
new file mode 100644 (file)
index 0000000..c00cad8
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+void CheckEngineExtensions(void);
index d9a12517d1512efa663e3d5234eae467156edaf8..ba9d77ee61223e4db474d15f0bebf61c10087d06 100644 (file)
@@ -841,16 +841,16 @@ void WarpZoneLib_MoveOutOfSolid_Expand(entity e, vector by)
        }
 }
 
-bool WarpZoneLib_MoveOutOfSolid(entity e)
+int WarpZoneLib_MoveOutOfSolid(entity e)
 {
        vector o = e.origin;
        traceline(o, o, MOVE_WORLDONLY, e);
        if (trace_startsolid)
-               return false;
+               return 0; // too stuck, giving up
 
        tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
        if (!trace_startsolid)
-               return true;
+               return -1; // wasn't stuck
 
        vector m0 = e.mins;
        vector m1 = e.maxs;
@@ -868,8 +868,8 @@ bool WarpZoneLib_MoveOutOfSolid(entity e)
        if (trace_startsolid)
        {
                setorigin(e, o);
-               return false;
+               return 0; // can't fix
        }
 
-       return true;
+       return 1; // was stuck but is fixed now
 }
index f73d079792af9f663775cb4b5294718a16bba03d..f80b5a63873325d50fd67799ad8cb50634df92ea 100644 (file)
@@ -106,7 +106,7 @@ entity WarpZone_RefSys_SpawnSameRefSys(entity me); // spawn().R = me.R
 #ifndef BITXOR_ASSIGN
 # define BITXOR_ASSIGN(a,b) ((a) = ((a) | (b)) - ((a) & (b)))
 #endif
-bool WarpZoneLib_MoveOutOfSolid(entity e);
+int WarpZoneLib_MoveOutOfSolid(entity e);
 #define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e)
 
 bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher, bool touchfunc);
index fe5bf07d43654e9f8867913696490dcfce75ca10..567d17941e45d9610102c45fac5e5bae04acabd5 100644 (file)
@@ -1,6 +1,5 @@
 #pragma once
 
-bool WarpZoneLib_MoveOutOfSolid(entity e);
 #ifdef SVQC
 void WarpZoneLib_ExactTrigger_Init(entity this, bool unsetmodel);
 #endif
index 7796cbccaa1de271031755ca8f1d7a6316aaa647..1edf6bfbaf261fbc59a3ba57dbe72d61bceba507 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "xonotic/util.qh"
 
+#include <common/checkextension.qh>
 #include <common/items/_mod.qh>
 #include <common/weapons/_all.qh>
 #include <common/mapinfo.qh>
@@ -76,6 +77,8 @@ void m_init()
                LOG_TRACEF("^4MQC Build information: ^1%s", WATERMARK);
 #endif
 
+       CheckEngineExtensions();
+
        // list all game dirs (TEST)
        if (cvar("developer") > 0)
        {
index 7bbbfa0dd7d9152f8e096f3a778ee0639059bfde..32b1ca3285a1aaedf86894276d2ebde23477c43a 100644 (file)
@@ -1,5 +1,6 @@
 #include "world.qh"
 
+#include <common/checkextension.qh>
 #include <common/constants.qh>
 #include <common/deathtypes/all.qh>
 #include <common/gamemodes/_mod.qh>
@@ -746,6 +747,8 @@ void InitGameplayMode()
 bool world_already_spawned;
 spawnfunc(worldspawn)
 {
+       CheckEngineExtensions();
+
        cvar_set("_endmatch", "0");
        server_is_dedicated = boolean(stof(cvar_defstring("is_dedicated")));