From: bones_was_here Date: Sat, 22 Jul 2023 08:10:33 +0000 (+1000) Subject: Add engine extension checks at VM startup and a nudgeoutofsolid fallback X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=db92f976f517632b7feb1bce79137322f58f3240;p=xonotic%2Fxonotic-data.pk3dir.git Add engine extension checks at VM startup and a nudgeoutofsolid fallback 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. --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 9e2145510..e30f9bbcb 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,8 @@ void CSQC_Init() LOG_TRACEF("^4CSQC Build information: ^1%s", WATERMARK); #endif + CheckEngineExtensions(); + { int i = 0; for ( ; i < 255; ++i) diff --git a/qcsrc/common/_all.inc b/qcsrc/common/_all.inc index 0a2cca157..b775b9686 100644 --- a/qcsrc/common/_all.inc +++ b/qcsrc/common/_all.inc @@ -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 index 000000000..4906f8468 --- /dev/null +++ b/qcsrc/common/checkextension.qc @@ -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 index 000000000..c00cad839 --- /dev/null +++ b/qcsrc/common/checkextension.qh @@ -0,0 +1,3 @@ +#pragma once + +void CheckEngineExtensions(void); diff --git a/qcsrc/lib/warpzone/common.qc b/qcsrc/lib/warpzone/common.qc index d9a12517d..ba9d77ee6 100644 --- a/qcsrc/lib/warpzone/common.qc +++ b/qcsrc/lib/warpzone/common.qc @@ -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 } diff --git a/qcsrc/lib/warpzone/common.qh b/qcsrc/lib/warpzone/common.qh index f73d07979..f80b5a638 100644 --- a/qcsrc/lib/warpzone/common.qh +++ b/qcsrc/lib/warpzone/common.qh @@ -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); diff --git a/qcsrc/lib/warpzone/util_server.qh b/qcsrc/lib/warpzone/util_server.qh index fe5bf07d4..567d17941 100644 --- a/qcsrc/lib/warpzone/util_server.qh +++ b/qcsrc/lib/warpzone/util_server.qh @@ -1,6 +1,5 @@ #pragma once -bool WarpZoneLib_MoveOutOfSolid(entity e); #ifdef SVQC void WarpZoneLib_ExactTrigger_Init(entity this, bool unsetmodel); #endif diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 7796cbcca..1edf6bfba 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -17,6 +17,7 @@ #include "xonotic/util.qh" +#include #include #include #include @@ -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) { diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index 7bbbfa0dd..32b1ca328 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -1,5 +1,6 @@ #include "world.qh" +#include #include #include #include @@ -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")));