]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Impulses: fix recursive `use` alias
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 8 Dec 2015 21:58:10 +0000 (08:58 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 8 Dec 2015 21:58:10 +0000 (08:58 +1100)
qcsrc/common/impulses/all.qh

index a42c0b05da9f9509cee5d6c38b198abbd76d279b..7f277b63b32fe5c261318856e47d72d4aa87f9b6 100644 (file)
@@ -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")