From: TimePath Date: Tue, 8 Dec 2015 21:58:10 +0000 (+1100) Subject: Impulses: fix recursive `use` alias X-Git-Tag: xonotic-v0.8.2~1529 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=11fac4da39de226ed073b34e1fde247689d5b5cf;p=xonotic%2Fxonotic-data.pk3dir.git Impulses: fix recursive `use` alias --- 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")