From: Rudolf Polzer Date: Sun, 3 Nov 2024 12:14:44 +0000 (-0500) Subject: Remove reliance of gmqcc allowing to overwrite builtin. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a3ddf6e8f1c88bdc775ede7544171f12963cc009;p=xonotic%2Fxonotic-data.pk3dir.git Remove reliance of gmqcc allowing to overwrite builtin. Allows https://github.com/graphitemaster/gmqcc/issues/211 to be fixed. --- diff --git a/qcsrc/common/checkextension.qc b/qcsrc/common/checkextension.qc index 9e5315957..a7325134d 100644 --- a/qcsrc/common/checkextension.qc +++ b/qcsrc/common/checkextension.qc @@ -39,7 +39,11 @@ void CheckEngineExtensions(void) 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")) + if (checkextension("DP_QC_NUDGEOUTOFSOLID")) + { + nudgeoutofsolid_CheckedEngineExtensions_usebuiltin(); + } + else { 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 @@ -51,7 +55,12 @@ void CheckEngineExtensions(void) #endif #ifdef GAMEQC - if (!checkextension("DP_QC_FINDBOX")) + if (checkextension("DP_QC_FINDBOX")) + { + findbox_CheckedEngineExtensions_usebuiltin(); + findbox_tofield_CheckedEngineExtensions_usebuiltin(); + } + else { LOG_WARN("Engine lacks DP_QC_FINDBOX, performance will be suboptimal."); findbox = findbox_Fallback; diff --git a/qcsrc/common/checkextension.qh b/qcsrc/common/checkextension.qh index 4d42e27e2..e39dcc75b 100644 --- a/qcsrc/common/checkextension.qh +++ b/qcsrc/common/checkextension.qh @@ -1,21 +1,31 @@ #pragma once -// For some reason, GMQCC _requires_ this code to overwrite builtin globals, -// while FTEQCC bans the same. Fine... -#ifndef GMQCC +// TODO: when https://github.com/graphitemaster/gmqcc/issues/211 is fixed, +// remove the _usebuiltin functions and pre-initialize the variables directly. +// Doing so already works in FTEQCC but not in GMQCC. +// +// The _usebuiltin functions are declared here so that the preprocessors based +// remapping does not impact them yet. #ifdef GAMEQC -var entity(vector mins, vector maxs, .entity tofield) findbox_tofield_CheckedEngineExtensions = findbox_tofield; +var entity(vector mins, vector maxs, .entity tofield) findbox_tofield_CheckedEngineExtensions; +void findbox_tofield_CheckedEngineExtensions_usebuiltin() { + findbox_tofield_CheckedEngineExtensions = findbox_tofield; +} #define findbox_tofield findbox_tofield_CheckedEngineExtensions -var entity(vector mins, vector maxs) findbox_CheckedEngineExtensions = findbox; +var entity(vector mins, vector maxs) findbox_CheckedEngineExtensions; +void findbox_CheckedEngineExtensions_usebuiltin() { + findbox_CheckedEngineExtensions = findbox; +} #define findbox findbox_CheckedEngineExtensions #endif #ifdef SVQC // change to GAMEQC if/when we use nudgeoutofsolid in CSQC -var float(entity ent) nudgeoutofsolid_CheckedEngineExtensions = nudgeoutofsolid; +var float(entity ent) nudgeoutofsolid_CheckedEngineExtensions; +void nudgeoutofsolid_CheckedEngineExtensions_usebuiltin() { + nudgeoutofsolid_CheckedEngineExtensions = nudgeoutofsolid; +} #define nudgeoutofsolid nudgeoutofsolid_CheckedEngineExtensions #endif -#endif - void CheckEngineExtensions(void);