From 11fac4da39de226ed073b34e1fde247689d5b5cf Mon Sep 17 00:00:00 2001 From: TimePath Date: Wed, 9 Dec 2015 08:58:10 +1100 Subject: [PATCH] Impulses: fix recursive `use` alias --- qcsrc/common/impulses/all.qh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/qcsrc/common/impulses/all.qh b/qcsrc/common/impulses/all.qh index a42c0b05d..7f277b63b 100644 --- a/qcsrc/common/impulses/all.qh +++ b/qcsrc/common/impulses/all.qh @@ -13,7 +13,7 @@ REGISTRY_CHECK(IMPULSES) .void(entity this) impulse_handle; #if defined(CSQC) -#define IMPULSE_ALIAS(alias, id) localcmd("\nalias " #alias " \"" id "\"\n") +#define IMPULSE_ALIAS(alias, id) localcmd("\nalias " #alias " \"", id ,"\"\n") #else #define IMPULSE_ALIAS(alias, id) #endif @@ -27,8 +27,14 @@ REGISTRY_CHECK(IMPULSES) IMPULSE_ALIAS(alias, "impulse " #n); \ } +#define LEGACY_IMPULSE_ID(alias, id) LEGACY_IMPULSE(alias, id, sprintf("impulse %d", IMP_##alias.impulse)) + #define LEGACY_IMPULSE(alias, id, new) \ - STATIC_INIT(legacy_##alias) { IMPULSE_ALIAS(alias, new); } \ + STATIC_INIT(legacy_##alias) { \ + string s = new; \ + if (s == #alias) LOG_FATALF("LEGACY_IMPULSE: would define a recursive alias for '%s', use LEGACY_IMPULSE_ID instead", s); \ + IMPULSE_ALIAS(alias, s); \ + } \ SHUTDOWN(legacy_##alias) { IMPULSE_ALIAS(alias, "impulse " #id); } #define X(slot, imp) \ @@ -144,7 +150,7 @@ REGISTER_IMPULSE(weapon_reload, 20) LEGACY_IMPULSE(reload, 20, "weapon_reload") REGISTER_IMPULSE(use, 21) -LEGACY_IMPULSE(use, 21, "use") +LEGACY_IMPULSE_ID(use, 21) REGISTER_IMPULSE(waypoint_personal_here, 30) LEGACY_IMPULSE(g_waypointsprite_personal, 30, "waypoint_personal_here") -- 2.39.2