]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Remove reliance of gmqcc allowing to overwrite builtin.
authorRudolf Polzer <divVerent@gmail.com>
Sun, 3 Nov 2024 12:14:44 +0000 (07:14 -0500)
committerRudolf Polzer <divVerent@gmail.com>
Sun, 3 Nov 2024 12:19:11 +0000 (07:19 -0500)
Allows https://github.com/graphitemaster/gmqcc/issues/211 to be fixed.

qcsrc/common/checkextension.qc
qcsrc/common/checkextension.qh

index 9e53159578ef9f1c2fcf042732ed10cc7422e07c..a7325134d4b46f4f0210e03011aedb88ff8dc337 100644 (file)
@@ -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;
index 4d42e27e2f61d67c0e87751e46a787c82b7705bf..e39dcc75b94c388ad1f0b2a63321b98bbd6ed6f3 100644 (file)
@@ -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);