From: bones_was_here Date: Sat, 13 Apr 2024 09:53:51 +0000 (+1000) Subject: Clean up droptofloor() macro hacks and clarify naming X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5c03681717992f42086878681377b1bc2f9c6cc8;p=xonotic%2Fxonotic-data.pk3dir.git Clean up droptofloor() macro hacks and clarify naming It wasn't clear at call sites that this had been changed to a delayed function (in SVQC only), and that the return value was no longer available. We can just use different names for the QC implementation, with different names for delayed and direct calls, and leave the original name for calling the builtin if required. The builtin's wrapper macro for changing the self global to a parameter is retained and it now works the same in SVQC and CSQC. Removes another case of cc83c39c27ea0757cf169562428e443c5ab60fdc --- diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 4bea0edf4..747dbe88c 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc @@ -1387,7 +1387,7 @@ void ctf_FlagSetup(int teamnum, entity flag) // called when spawning a flag enti else // drop to floor, automatically find a platform and set that as spawn origin { flag.noalign = false; - droptofloor(flag); + DropToFloor_QC_DelayedInit(flag); set_movetype(flag, MOVETYPE_NONE); } diff --git a/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc b/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc index 728915555..e245ff92f 100644 --- a/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc +++ b/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc @@ -299,7 +299,7 @@ void dom_controlpoint_setup(entity this) this.flags = FL_ITEM; setsize(this, '-48 -48 -32', '48 48 32'); // 0.8.6 used '-32 -32 -32', '32 32 32' with sv_legacy_bbox_expand 1 and FL_ITEM setorigin(this, this.origin + '0 0 20'); - droptofloor(this); + DropToFloor_QC_DelayedInit(this); waypoint_spawnforitem(this); WaypointSprite_SpawnFixed(WP_DomNeut, this.origin + '0 0 32', this, sprite, RADARICON_DOMPOINT); diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index 370fda29d..8d9ad2e11 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -804,7 +804,7 @@ void ons_ControlPoint_Setup(entity cp) { setorigin(cp, cp.origin + '0 0 20'); cp.noalign = false; - droptofloor(cp); + DropToFloor_QC_DelayedInit(cp); set_movetype(cp, MOVETYPE_TOSS); } @@ -1104,7 +1104,7 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o gen.colormap = 1024 + (teamnum - 1) * 17; // generator placement - droptofloor(gen); + DropToFloor_QC_DelayedInit(gen); // waypointsprites WaypointSprite_SpawnFixed(WP_Null, gen.origin + CPGEN_WAYPOINT_OFFSET, gen, sprite, RADARICON_NONE); diff --git a/qcsrc/common/mapobjects/misc/keys.qc b/qcsrc/common/mapobjects/misc/keys.qc index df80bc03c..6c52e6a1e 100644 --- a/qcsrc/common/mapobjects/misc/keys.qc +++ b/qcsrc/common/mapobjects/misc/keys.qc @@ -126,7 +126,7 @@ void spawn_item_key(entity this) // NOTE: this isn't an FL_ITEM so it doesn't get the special treatment in DropToFloor_QC() if (!this.noalign) - droptofloor(this); + DropToFloor_QC_DelayedInit(this); settouch(this, item_key_touch); } diff --git a/qcsrc/common/mutators/mutator/physical_items/sv_physical_items.qc b/qcsrc/common/mutators/mutator/physical_items/sv_physical_items.qc index 328f79ac8..30f6a2808 100644 --- a/qcsrc/common/mutators/mutator/physical_items/sv_physical_items.qc +++ b/qcsrc/common/mutators/mutator/physical_items/sv_physical_items.qc @@ -124,11 +124,7 @@ MUTATOR_HOOKFUNCTION(physical_items, Item_Spawn) wep.event_damage = physical_item_damage; if(!wep.cnt) - { - // fix the spawn origin - setorigin(wep, wep.origin + '0 0 1'); - droptofloor(wep); - } + DropToFloor_QC_DelayedInit(wep); wep.spawn_origin = wep.origin; wep.spawn_angles = item.angles; diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index a42005f32..4c7ce5ab4 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -1299,7 +1299,7 @@ bool turret_initialize(entity this, Turret tur) } if(!(this.spawnflags & TSF_SUSPENDED)) - droptofloor(this); + DropToFloor_QC_DelayedInit(this); this.netname = tur.netname; load_unit_settings(this, 0); diff --git a/qcsrc/lib/self.qh b/qcsrc/lib/self.qh index b057faee5..13f705794 100644 --- a/qcsrc/lib/self.qh +++ b/qcsrc/lib/self.qh @@ -99,9 +99,7 @@ SELFWRAP(SendEntity, bool, (entity to, int sendflags), (entity this, entity to, #define ChangeYaw(e, ...) (__self = (e), builtin_ChangeYaw(__VA_ARGS__)) #define checkclient(e, ...) (__self = (e), builtin_checkclient(__VA_ARGS__)) -#ifndef SVQC - #define droptofloor(e, ...) (__self = (e), builtin_droptofloor(__VA_ARGS__)) -#endif +#define droptofloor(e, ...) (__self = (e), builtin_droptofloor(__VA_ARGS__)) #define error(...) (__self = (NULL), builtin_error(__VA_ARGS__)) #define movetogoal(e, ...) (__self = (e), builtin_movetogoal(__VA_ARGS__)) #define walkmove(e, ...) (__self = (e), builtin_walkmove(__VA_ARGS__)) diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index b0b68fd92..825f003a5 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -1125,9 +1125,8 @@ void StartItem(entity this, entity def) // do item filtering according to game mode and other things if (this.noalign <= 0) { - // note droptofloor returns false if stuck/or would fall too far if (!this.noalign) - droptofloor(this); + DropToFloor_QC_DelayedInit(this); waypoint_spawnforitem(this); } diff --git a/qcsrc/server/sys-post.qh b/qcsrc/server/sys-post.qh index 2d92f5dfe..c4ff0fa58 100644 --- a/qcsrc/server/sys-post.qh +++ b/qcsrc/server/sys-post.qh @@ -1,6 +1,5 @@ #pragma once -#undef droptofloor #undef sound var void delete_fn(entity e); diff --git a/qcsrc/server/sys-pre.qh b/qcsrc/server/sys-pre.qh index 7e5e10421..a00a1ac0a 100644 --- a/qcsrc/server/sys-pre.qh +++ b/qcsrc/server/sys-pre.qh @@ -1,7 +1,5 @@ #pragma once -#define droptofloor builtin_droptofloor - #define IT_SHOTGUN _IT_SHOTGUN /* BIT(0) */ #define IT_SUPER_SHOTGUN _IT_SUPER_SHOTGUN /* BIT(1) */ #define IT_NAILGUN _IT_NAILGUN /* BIT(2) */ diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index 6d173d797..4ce29a707 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -2414,7 +2414,7 @@ void DropToFloor_QC(entity this) setorigin(this, this.dropped_origin = this.origin); } -void droptofloor(entity this) +void DropToFloor_QC_DelayedInit(entity this) { InitializeEntity(this, DropToFloor_QC, INITPRIO_DROPTOFLOOR); } diff --git a/qcsrc/server/world.qh b/qcsrc/server/world.qh index 09ee564cf..d76169e2d 100644 --- a/qcsrc/server/world.qh +++ b/qcsrc/server/world.qh @@ -161,7 +161,7 @@ void readplayerstartcvars(); void readlevelcvars(); .vector dropped_origin; -void droptofloor(entity this); +void DropToFloor_QC_DelayedInit(entity this); IntrusiveList g_moveables; STATIC_INIT(g_moveables) { g_moveables = IL_NEW(); }