X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fimpulses%2Fall.qh;h=d870e6d2c232cf7825a94f46711831e96afc4320;hp=7f277b63b32fe5c261318856e47d72d4aa87f9b6;hb=HEAD;hpb=11fac4da39de226ed073b34e1fde247689d5b5cf diff --git a/qcsrc/common/impulses/all.qh b/qcsrc/common/impulses/all.qh index 7f277b63b3..da13ee4aa4 100644 --- a/qcsrc/common/impulses/all.qh +++ b/qcsrc/common/impulses/all.qh @@ -1,18 +1,24 @@ -#ifndef IMPULSES_ALL_H -#define IMPULSES_ALL_H +#pragma once REGISTRY(IMPULSES, 255) REGISTER_REGISTRY(IMPULSES) REGISTRY_SORT(IMPULSES) + +REGISTRY_DEFINE_GET(IMPULSES, NULL) STATIC_INIT(IMPULSES_renumber) { - FOREACH(IMPULSES, true, LAMBDA(it.m_id = i)); + FOREACH(IMPULSES, true, it.m_id = i); } REGISTRY_CHECK(IMPULSES) .void(entity this) impulse_handle; #if defined(CSQC) +void Impulse_Send(entity imp) +{ + localcmd(sprintf("\nimpulse %d\n", imp.impulse)); +} + #define IMPULSE_ALIAS(alias, id) localcmd("\nalias " #alias " \"", id ,"\"\n") #else #define IMPULSE_ALIAS(alias, id) @@ -20,19 +26,25 @@ REGISTRY_CHECK(IMPULSES) #define REGISTER_IMPULSE(id, n) _REGISTER_IMPULSE(IMP_##id, id, n) #define _REGISTER_IMPULSE(id, alias, n) \ - REGISTER(IMPULSES, id, m_id, new(Impulse)) \ + REGISTER(IMPULSES, id, m_id, new_pure(Impulse)) \ { \ - make_pure(this); \ this.impulse = n; \ IMPULSE_ALIAS(alias, "impulse " #n); \ } #define LEGACY_IMPULSE_ID(alias, id) LEGACY_IMPULSE(alias, id, sprintf("impulse %d", IMP_##alias.impulse)) +void _impCheck(string s, string alias) +{ + // this is inside a function to avoid expanding it on compilation everytime + if (s == alias) + LOG_FATALF("LEGACY_IMPULSE: would define a recursive alias for '%s', use LEGACY_IMPULSE_ID instead", s); +} + #define LEGACY_IMPULSE(alias, id, 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); \ + _impCheck(s, #alias); \ IMPULSE_ALIAS(alias, s); \ } \ SHUTDOWN(legacy_##alias) { IMPULSE_ALIAS(alias, "impulse " #id); } @@ -188,26 +200,11 @@ LEGACY_IMPULSE(g_waypointsprite_clear_personal, 47, "waypoint_clear_personal") REGISTER_IMPULSE(waypoint_clear, 48) LEGACY_IMPULSE(g_waypointsprite_clear, 48, "waypoint_clear") -REGISTER_IMPULSE(navwaypoint_spawn, 103) -LEGACY_IMPULSE(g_waypointeditor_spawn, 103, "navwaypoint_spawn") - -REGISTER_IMPULSE(navwaypoint_remove, 104) -LEGACY_IMPULSE(g_waypointeditor_remove, 104, "navwaypoint_remove") - -REGISTER_IMPULSE(navwaypoint_relink, 105) -LEGACY_IMPULSE(g_waypointeditor_relinkall, 105, "navwaypoint_relink") - -REGISTER_IMPULSE(navwaypoint_save, 106) -LEGACY_IMPULSE(g_waypointeditor_saveall, 106, "navwaypoint_save") - -REGISTER_IMPULSE(navwaypoint_unreachable, 107) -LEGACY_IMPULSE(g_waypointeditor_unreachable, 107, "navwaypoint_unreachable") #define CHIMPULSE(id, n) _CHIMPULSE(CHIMPULSE_##id, n) #define _CHIMPULSE(id, n) \ - REGISTER(IMPULSES, id, m_id, new(Impulse)) \ + REGISTER(IMPULSES, id, m_id, new_pure(Impulse)) \ { \ - make_pure(this); \ this.impulse = n; \ } @@ -218,5 +215,3 @@ CHIMPULSE(SPEEDRUN, 141) CHIMPULSE(CLONE_STANDING, 142) CHIMPULSE(TELEPORT, 143) CHIMPULSE(R00T, 148) - -#endif