From: Rudolf Polzer Date: Wed, 22 Jan 2025 15:36:01 +0000 (+0000) Subject: Remove reliance of gmqcc allowing to overwrite builtin. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a7dac5764bd330154e2e6d51fc2280294ff5eb24;p=xonotic%2Fxonotic-data.pk3dir.git Remove reliance of gmqcc allowing to overwrite builtin. --- diff --git a/qcsrc/common/checkextension.qc b/qcsrc/common/checkextension.qc index 9e5315957..9f10501ef 100644 --- a/qcsrc/common/checkextension.qc +++ b/qcsrc/common/checkextension.qc @@ -39,11 +39,15 @@ 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_OrFallback = nudgeoutofsolid; + } + 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 - nudgeoutofsolid = WarpZoneLib_MoveOutOfSolid; + nudgeoutofsolid_OrFallback = WarpZoneLib_MoveOutOfSolid; } if (!world.fullspawndata) @@ -51,11 +55,16 @@ void CheckEngineExtensions(void) #endif #ifdef GAMEQC - if (!checkextension("DP_QC_FINDBOX")) + if (checkextension("DP_QC_FINDBOX")) + { + findbox_OrFallback = findbox; + findbox_tofield_OrFallback = findbox_tofield; + } + else { LOG_WARN("Engine lacks DP_QC_FINDBOX, performance will be suboptimal."); - findbox = findbox_Fallback; - findbox_tofield = findbox_tofield_Fallback; + findbox_OrFallback = findbox_Fallback; + findbox_tofield_OrFallback = findbox_tofield_Fallback; } #endif diff --git a/qcsrc/common/checkextension.qh b/qcsrc/common/checkextension.qh index 4d42e27e2..0cdec8c92 100644 --- a/qcsrc/common/checkextension.qh +++ b/qcsrc/common/checkextension.qh @@ -1,21 +1,12 @@ #pragma once -// For some reason, GMQCC _requires_ this code to overwrite builtin globals, -// while FTEQCC bans the same. Fine... -#ifndef GMQCC - #ifdef GAMEQC -var entity(vector mins, vector maxs, .entity tofield) findbox_tofield_CheckedEngineExtensions = findbox_tofield; -#define findbox_tofield findbox_tofield_CheckedEngineExtensions -var entity(vector mins, vector maxs) findbox_CheckedEngineExtensions = findbox; -#define findbox findbox_CheckedEngineExtensions +var entity(vector mins, vector maxs, .entity tofield) findbox_tofield_OrFallback = nil; +var entity(vector mins, vector maxs) findbox_OrFallback = nil; #endif #ifdef SVQC // change to GAMEQC if/when we use nudgeoutofsolid in CSQC -var float(entity ent) nudgeoutofsolid_CheckedEngineExtensions = nudgeoutofsolid; -#define nudgeoutofsolid nudgeoutofsolid_CheckedEngineExtensions -#endif - +var float(entity ent) nudgeoutofsolid_OrFallback = nil; #endif void CheckEngineExtensions(void); diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 48657df2e..2bd0bab23 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc @@ -1,5 +1,6 @@ #include "sv_ctf.qh" +#include #include #include #include @@ -500,7 +501,7 @@ void ctf_Handle_Throw(entity player, entity receiver, int droptype) tracebox(player.origin - FLAG_DROP_OFFSET, flag.m_mins, flag.m_maxs, player.origin + FLAG_DROP_OFFSET, MOVE_NOMONSTERS, flag); flag.solid = SOLID_TRIGGER; // before setorigin to ensure area grid linking setorigin(flag, trace_endpos); - if (trace_startsolid && !nudgeoutofsolid(flag)) // TODO: trace_allsolid would perform better but isn't 100% reliable yet + if (trace_startsolid && !nudgeoutofsolid_OrFallback(flag)) // TODO: trace_allsolid would perform better but isn't 100% reliable yet { // the flag's bbox doesn't fit but we can assume the player's current bbox does tracebox(player.origin - FLAG_DROP_OFFSET, player.mins, player.maxs, player.origin + FLAG_DROP_OFFSET, MOVE_NOMONSTERS, flag); diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc index cdb56060d..32be3c74d 100644 --- a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc +++ b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc @@ -1,5 +1,6 @@ #include "sv_keepaway.qh" +#include #include #include #include @@ -202,7 +203,7 @@ void ka_DropEvent(entity player) // runs any time that a player is supposed to l IL_PUSH(g_damagedbycontents, ball); ball.effects &= ~EF_NODRAW; setorigin(ball, player.origin + '0 0 10'); - nudgeoutofsolid(ball); // a ball has a horizontally bigger bbox than a player + nudgeoutofsolid_OrFallback(ball); // a ball has a horizontally bigger bbox than a player ball.velocity = '0 0 200' + '0 100 0'*crandom() + '100 0 0'*crandom(); ball.owner = NULL; navigation_dynamicgoal_set(ball, player); diff --git a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc index d9dda802c..89997b8bd 100644 --- a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc +++ b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc @@ -1,5 +1,6 @@ #include "sv_keyhunt.qh" +#include #include #include #include @@ -291,7 +292,7 @@ void kh_Key_Detach(entity key) // runs every time a key is dropped or lost. Runs if(!IL_CONTAINS(g_items, key)) IL_PUSH(g_items, key); set_movetype(key, MOVETYPE_TOSS); - nudgeoutofsolid(key); // a key has a bigger bbox than a player + nudgeoutofsolid_OrFallback(key); // a key has a bigger bbox than a player key.pain_finished = time + autocvar_g_balance_keyhunt_delay_return; key.damageforcescale = autocvar_g_balance_keyhunt_damageforcescale; key.takedamage = DAMAGE_YES; diff --git a/qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc b/qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc index e0c4647c5..43685ca06 100644 --- a/qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc +++ b/qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc @@ -1,5 +1,6 @@ #include "sv_tka.qh" +#include #include .entity ballcarried; @@ -183,7 +184,7 @@ void tka_DropEvent(entity player) // runs any time that a player is supposed to ball.takedamage = DAMAGE_YES; ball.effects &= ~EF_NODRAW; setorigin(ball, player.origin + '0 0 10'); - nudgeoutofsolid(ball); // a ball has a horizontally bigger bbox than a player + nudgeoutofsolid_OrFallback(ball); // a ball has a horizontally bigger bbox than a player ball.velocity = '0 0 200' + '0 100 0'*crandom() + '100 0 0'*crandom(); ball.owner = NULL; navigation_dynamicgoal_set(ball, player); diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index cae2085d8..03de664bc 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -1,5 +1,6 @@ #include "sv_monsters.qh" +#include #include #include #include @@ -1543,7 +1544,7 @@ bool Monster_Spawn(entity this, bool check_appear, Monster mon) setorigin(this, trace_endpos); } - if (!nudgeoutofsolid(this)) + if (!nudgeoutofsolid_OrFallback(this)) { // Stuck and not fixable Monster_Remove(this); diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index ef5c5d778..9c961d750 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -1,5 +1,7 @@ #include "porto.qh" +#include + #ifdef CSQC STATIC_INIT(Porto) @@ -124,7 +126,7 @@ void W_Porto_Fail(entity this, float failhard) // FIXME: item properties should be obtained from the registry setsize(this, ITEM_D_MINS, ITEM_D_MAXS); setorigin(this, this.origin + trace_plane_normal); - if(nudgeoutofsolid(this)) + if(nudgeoutofsolid_OrFallback(this)) { this.flags = FL_ITEM; IL_PUSH(g_items, this); diff --git a/qcsrc/lib/warpzone/common.qc b/qcsrc/lib/warpzone/common.qc index 65625a877..8ab954ea1 100644 --- a/qcsrc/lib/warpzone/common.qc +++ b/qcsrc/lib/warpzone/common.qc @@ -1,5 +1,7 @@ #include "common.qh" +#include + #if defined(CSQC) #include #elif defined(MENUQC) @@ -134,7 +136,7 @@ float WarpZoneLib_BoxTouchesBrush_Recurse(vector mi, vector ma, entity e, entity float WarpZoneLib_BoxTouchesBrush(vector mi, vector ma, entity e, entity ig) { - // bones_was_here: TODO: when findbox() builtin is available, use it to + // bones_was_here: TODO: when findbox_OrFallback() is available, use it to // optimise this into a single non-recursive function that only calls tracebox once float f, s; diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index ebe9212d5..6b9b4c41e 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -1,5 +1,6 @@ #include "items.qh" +#include #include #include #include @@ -1081,7 +1082,7 @@ void StartItem(entity this, entity def) } // most loot items have a bigger horizontal size than a player - nudgeoutofsolid(this); + nudgeoutofsolid_OrFallback(this); // don't drop if in a NODROP zone (such as lava) traceline(this.origin, this.origin, MOVE_NORMAL, this); diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index 9f87ee28f..dbd8c23df 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -2337,12 +2337,12 @@ void DropToFloor_QC(entity this) return; } - /* Prior to sv_legacy_bbox_expand 0, both droptofloor and nudgeoutofsolid were done for items + /* Prior to sv_legacy_bbox_expand 0, both droptofloor and nudgeoutofsolid_OrFallback were done for items * using box '-16 -16 0' '16 16 48' (without the FL_ITEM expansion applied), * which often resulted in bboxes partially in solids once expansion was applied. * We don't want bboxes in solids (bad for gameplay and culling), * but we also don't want items to land on a "skirting board" or the base of a sloping wall. - * For initial nudgeoutofsolid and droptofloor stages we use a small box + * For initial nudgeoutofsolid_OrFallback and droptofloor stages we use a small box * so they fall as far and in the same place as they traditionally would, * then we nudge the full size box out of solid, in a direction appropriate for the plane(s). */ @@ -2366,7 +2366,7 @@ void DropToFloor_QC(entity this) */ if(!Q3COMPAT_COMMON && autocvar_sv_mapformat_is_quake3) // Xonotic, Nexuiz { - nudgeresult = nudgeoutofsolid(this); + nudgeresult = nudgeoutofsolid_OrFallback(this); if (!nudgeresult) LOG_WARNF("DropToFloor_QC at \"%v\": COULD NOT FIX badly placed entity \"%s\" before drop", this.origin, this.classname); else if (nudgeresult > 0) @@ -2432,12 +2432,12 @@ void DropToFloor_QC(entity this) // A side effect of using a small box to drop items (and do the initial nudge) is // the full size box can end up in collision with a sloping floor or terrain model. - nudgeresult = nudgeoutofsolid(this); + nudgeresult = nudgeoutofsolid_OrFallback(this); // No warns for successful nudge because it would spam about items on slopes/terrain. } else if (trace_allsolid && trace_fraction) // dropped using "proper" bbox but never left solid { - nudgeresult = nudgeoutofsolid(this); + nudgeresult = nudgeoutofsolid_OrFallback(this); if (nudgeresult > 0) LOG_WARNF("DropToFloor_QC at \"%v\": FIXED badly placed entity \"%s\" after drop", this.origin, this.classname); }