From 0d0c36e4cfae2432ce75dc8d08398ae2b620c45d Mon Sep 17 00:00:00 2001 From: TimePath Date: Thu, 9 Jun 2016 22:12:59 +1000 Subject: [PATCH] Re-number mutator args to be more like varargs --- qcsrc/client/mutators/events.qh | 2 +- qcsrc/client/view.qc | 2 +- qcsrc/common/mutators/events.qh | 15 +++++++++++---- qcsrc/common/mutators/mutator/buffs/module.inc | 8 ++++---- .../mutators/mutator/damagetext/damagetext.qc | 10 +++++----- qcsrc/common/mutators/mutator/nades/nades.qc | 4 ++-- qcsrc/common/mutators/mutator/nades/nades.qh | 8 ++++---- qcsrc/common/mutators/mutator/overkill/hmg.qc | 4 ++-- .../common/mutators/mutator/overkill/overkill.qc | 4 ++-- .../mutators/mutator/waypoints/waypointsprites.qc | 4 ++-- qcsrc/server/mutators/events.qh | 8 ++++---- 11 files changed, 38 insertions(+), 31 deletions(-) diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index f86ef5333..4cdba48cf 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -103,7 +103,7 @@ MUTATOR_HOOKABLE(Ent_Init, EV_NO_ARGS); #define EV_HUD_Draw_overlay(i, o) \ /**/ o(vector, MUTATOR_ARGV_0_vector) \ - /**/ o(float, MUTATOR_ARGV_0_float) \ + /**/ o(float, MUTATOR_ARGV_1_float) \ /**/ MUTATOR_HOOKABLE(HUD_Draw_overlay, EV_HUD_Draw_overlay); diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index dadb8d41d..125a25709 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1321,7 +1321,7 @@ void HUD_Draw(entity this) if(!intermission) if (MUTATOR_CALLHOOK(HUD_Draw_overlay)) { - drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, MUTATOR_ARGV(0, vector), autocvar_hud_colorflash_alpha * MUTATOR_ARGV(0, float), DRAWFLAG_ADDITIVE); + drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, M_ARGV(0, vector), autocvar_hud_colorflash_alpha * M_ARGV(1, float), DRAWFLAG_ADDITIVE); } else if(STAT(FROZEN)) { diff --git a/qcsrc/common/mutators/events.qh b/qcsrc/common/mutators/events.qh index 1258b6ff8..58f9c43d0 100644 --- a/qcsrc/common/mutators/events.qh +++ b/qcsrc/common/mutators/events.qh @@ -15,12 +15,19 @@ string ret_string; _(x, string) \ /**/ -#define MUTATOR_ARGV(x, type) MUTATOR_ARGV_##x##_##type +// TODO: migrate to arrays some day when no other globals are used +#define M_ARGV(x, type) MUTATOR_ARGV_##x##_##type #define MUTATOR_NEWGLOBAL(x, type) type MUTATOR_ARGV_##x##_##type; MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 0) MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 1) MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 2) +MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 3) +MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 4) +MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 5) +MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 6) +MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 7) +MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 8) #undef MUTATOR_TYPES #undef MUTATOR_NEWGLOBAL @@ -55,9 +62,9 @@ MUTATOR_HOOKABLE(IsFlying, EV_IsFlying); #define EV_WP_Format(i, o) \ /**/ i(entity, MUTATOR_ARGV_0_entity) \ - /**/ i(string, MUTATOR_ARGV_0_string) \ - /**/ o(vector, MUTATOR_ARGV_0_vector) \ - /**/ o(string, MUTATOR_ARGV_0_string) \ + /**/ i(string, MUTATOR_ARGV_1_string) \ + /**/ o(vector, MUTATOR_ARGV_2_vector) \ + /**/ o(string, MUTATOR_ARGV_3_string) \ /**/ MUTATOR_HOOKABLE(WP_Format, EV_WP_Format); diff --git a/qcsrc/common/mutators/mutator/buffs/module.inc b/qcsrc/common/mutators/mutator/buffs/module.inc index 0d6e97cbb..c24892836 100644 --- a/qcsrc/common/mutators/mutator/buffs/module.inc +++ b/qcsrc/common/mutators/mutator/buffs/module.inc @@ -31,13 +31,13 @@ MUTATOR_HOOKFUNCTION(cl_buffs, HUD_Powerups_add) } MUTATOR_HOOKFUNCTION(cl_buffs, WP_Format) { - entity this = MUTATOR_ARGV(0, entity); - string s = MUTATOR_ARGV(0, string); + entity this = M_ARGV(0, entity); + string s = M_ARGV(1, string); if (s == WP_Buff.netname || s == RADARICON_Buff.netname) { Buff b = Buffs_from(this.wp_extra); - MUTATOR_ARGV(0, vector) = b.m_color; - MUTATOR_ARGV(0, string) = b.m_prettyName; + M_ARGV(2, vector) = b.m_color; + M_ARGV(3, string) = b.m_prettyName; return true; } } diff --git a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc index 0d9cb73e9..2a1795d63 100644 --- a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc @@ -89,11 +89,11 @@ AUTOCVAR(sv_damagetext, int, 2, _("<= 0: disabled, >= 1: spectators, >= 2: playe #define SV_DAMAGETEXT_ALL() (autocvar_sv_damagetext >= 3 /* all players */) MUTATOR_HOOKFUNCTION(damagetext, PlayerDamaged) { if (SV_DAMAGETEXT_DISABLED()) return; - const entity attacker = MUTATOR_ARGV(0, entity); - const entity hit = MUTATOR_ARGV(1, entity); if (hit == attacker) return; - const int health = MUTATOR_ARGV(0, int); - const int armor = MUTATOR_ARGV(1, int); - const int deathtype = MUTATOR_ARGV(2, int); + const entity attacker = M_ARGV(0, entity); + const entity hit = M_ARGV(1, entity); if (hit == attacker) return; + const int health = M_ARGV(2, int); + const int armor = M_ARGV(3, int); + const int deathtype = M_ARGV(5, int); const vector location = hit.origin; FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA( if ( diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 6fca6178f..d2f90091f 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -39,8 +39,8 @@ REGISTER_MUTATOR(cl_nades, true); MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay) { if (STAT(HEALING_ORB) <= time) return false; - MUTATOR_ARGV(0, vector) = NADE_TYPE_HEAL.m_color; - MUTATOR_ARGV(0, float) = STAT(HEALING_ORB_ALPHA); + M_ARGV(0, vector) = NADE_TYPE_HEAL.m_color; + M_ARGV(1, float) = STAT(HEALING_ORB_ALPHA); return true; } MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile) diff --git a/qcsrc/common/mutators/mutator/nades/nades.qh b/qcsrc/common/mutators/mutator/nades/nades.qh index da80327bb..d89cd462d 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qh +++ b/qcsrc/common/mutators/mutator/nades/nades.qh @@ -91,10 +91,10 @@ void(entity player, float score) nades_GiveBonus; */ #define EV_Nade_Damage(i, o) \ /** weapon */ i(entity, MUTATOR_ARGV_0_entity) \ - /** force */ i(vector, MUTATOR_ARGV_0_vector) \ - /**/ o(vector, MUTATOR_ARGV_0_vector) \ - /** damage */ i(float, MUTATOR_ARGV_0_float) \ - /**/ o(float, MUTATOR_ARGV_0_float) \ + /** force */ i(vector, MUTATOR_ARGV_1_vector) \ + /**/ o(vector, MUTATOR_ARGV_1_vector) \ + /** damage */ i(float, MUTATOR_ARGV_2_float) \ + /**/ o(float, MUTATOR_ARGV_2_float) \ /**/ MUTATOR_HOOKABLE(Nade_Damage, EV_Nade_Damage); diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qc b/qcsrc/common/mutators/mutator/overkill/hmg.qc index 419123e10..0d14164d1 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qc @@ -48,9 +48,9 @@ REGISTER_MUTATOR(hmg_nadesupport, true); MUTATOR_HOOKFUNCTION(hmg_nadesupport, Nade_Damage) { SELFPARAM(); - if (MUTATOR_ARGV(0, entity) != WEP_HMG) return; + if (M_ARGV(0, entity) != WEP_HMG) return; return = true; - MUTATOR_ARGV(0, float) /* damage */ = self.max_health * 0.1; + M_ARGV(2, float) /* damage */ = self.max_health * 0.1; } spawnfunc(weapon_hmg) { weapon_defaultspawnfunc(this, WEP_HMG); } diff --git a/qcsrc/common/mutators/mutator/overkill/overkill.qc b/qcsrc/common/mutators/mutator/overkill/overkill.qc index c670879e3..c5c876742 100644 --- a/qcsrc/common/mutators/mutator/overkill/overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/overkill.qc @@ -41,7 +41,7 @@ REGISTER_MUTATOR(ok, cvar("g_overkill") && !cvar("g_instagib") && !g_nexball && MUTATOR_HOOKFUNCTION(ok, W_DecreaseAmmo) { - entity actor = MUTATOR_ARGV(0, entity); + entity actor = M_ARGV(0, entity); if (actor.ok_use_ammocharge) { ok_DecreaseCharge(actor, PS(actor).m_weapon.m_id); @@ -51,7 +51,7 @@ MUTATOR_HOOKFUNCTION(ok, W_DecreaseAmmo) MUTATOR_HOOKFUNCTION(ok, W_Reload) { - entity actor = MUTATOR_ARGV(0, entity); + entity actor = M_ARGV(0, entity); return actor.ok_use_ammocharge; } diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index 55136ddc5..e208811ef 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -235,7 +235,7 @@ vector spritelookupcolor(entity this, string s, vector def) if (s == WP_Item.netname || s == RADARICON_Item.netname) return Items_from(this.wp_extra).m_color; if (MUTATOR_CALLHOOK(WP_Format, this, s)) { - return MUTATOR_ARGV(0, vector); + return M_ARGV(2, vector); } return def; } @@ -248,7 +248,7 @@ string spritelookuptext(entity this, string s) if (s == WP_Monster.netname) return get_monsterinfo(this.wp_extra).monster_name; if (MUTATOR_CALLHOOK(WP_Format, this, s)) { - return MUTATOR_ARGV(0, string); + return M_ARGV(3, string); } // need to loop, as our netname could be one of three diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index bfec6f219..7221bcb4c 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -332,10 +332,10 @@ MUTATOR_HOOKABLE(PlayerDamage_Calculate, EV_PlayerDamage_Calculate); #define EV_PlayerDamaged(i, o) \ /** attacker */ i(entity, MUTATOR_ARGV_0_entity) \ /** target */ i(entity, MUTATOR_ARGV_1_entity) \ - /** health */ i(int, MUTATOR_ARGV_0_int) \ - /** armor */ i(int, MUTATOR_ARGV_1_int) \ - /** location */ i(vector, MUTATOR_ARGV_0_vector) \ - /** deathtype */ i(int, MUTATOR_ARGV_2_int) \ + /** health */ i(int, MUTATOR_ARGV_2_int) \ + /** armor */ i(int, MUTATOR_ARGV_3_int) \ + /** location */ i(vector, MUTATOR_ARGV_4_vector) \ + /** deathtype */ i(int, MUTATOR_ARGV_5_int) \ /**/ MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged); -- 2.39.2