Xonotic
all.qh
Go to the documentation of this file.
1 #pragma once
2 
3 REGISTRY(IMPULSES, 255)
4 REGISTER_REGISTRY(IMPULSES)
5 REGISTRY_SORT(IMPULSES)
6 
7 REGISTRY_DEFINE_GET(IMPULSES, NULL)
8 STATIC_INIT(IMPULSES_renumber)
9 {
10  FOREACH(IMPULSES, true, it.m_id = i);
11 }
12 REGISTRY_CHECK(IMPULSES)
13 
14 .void(entity this) impulse_handle;
15 
16 #if defined(CSQC)
17 #define IMPULSE_ALIAS(alias, id) localcmd("\nalias " #alias " \"", id ,"\"\n")
18 #else
19 #define IMPULSE_ALIAS(alias, id)
20 #endif
21 
22 #define REGISTER_IMPULSE(id, n) _REGISTER_IMPULSE(IMP_##id, id, n)
23 #define _REGISTER_IMPULSE(id, alias, n) \
24  REGISTER(IMPULSES, id, m_id, new_pure(Impulse)) \
25  { \
26  this.impulse = n; \
27  IMPULSE_ALIAS(alias, "impulse " #n); \
28  }
29 
30 #define LEGACY_IMPULSE_ID(alias, id) LEGACY_IMPULSE(alias, id, sprintf("impulse %d", IMP_##alias.impulse))
31 
32 void _impCheck(string s, string alias)
33 {
34  // this is inside a function to avoid expanding it on compilation everytime
35  if (s == alias)
36  LOG_FATALF("LEGACY_IMPULSE: would define a recursive alias for '%s', use LEGACY_IMPULSE_ID instead", s);
37 }
38 
39 #define LEGACY_IMPULSE(alias, id, new) \
40  STATIC_INIT(legacy_##alias) { \
41  string s = new; \
42  _impCheck(s, #alias); \
43  IMPULSE_ALIAS(alias, s); \
44  } \
45  SHUTDOWN(legacy_##alias) { IMPULSE_ALIAS(alias, "impulse " #id); }
46 
47 #define X(slot, imp) \
48  REGISTER_IMPULSE(weapon_group_##slot, imp) \
49  LEGACY_IMPULSE(weapon_group_##slot, imp, "impulse " #imp)
50 X(1, 1)
51 X(2, 2)
52 X(3, 3)
53 X(4, 4)
54 X(5, 5)
55 X(6, 6)
56 X(7, 7)
57 X(8, 8)
58 X(9, 9)
59 X(0, 14)
60 #undef X
61 
62 #define X(slot, dir, imp) \
63  REGISTER_IMPULSE(weapon_priority_##slot##_##dir, imp) \
64  LEGACY_IMPULSE(weapon_priority_##slot##_##dir, imp, "impulse " #imp)
65 X(0, prev, 200)
66 X(1, prev, 201)
67 X(2, prev, 202)
68 X(3, prev, 203)
69 X(4, prev, 204)
70 X(5, prev, 205)
71 X(6, prev, 206)
72 X(7, prev, 207)
73 X(8, prev, 208)
74 X(9, prev, 209)
75 
76 X(0, best, 210)
77 X(1, best, 211)
78 X(2, best, 212)
79 X(3, best, 213)
80 X(4, best, 214)
81 X(5, best, 215)
82 X(6, best, 216)
83 X(7, best, 217)
84 X(8, best, 218)
85 X(9, best, 219)
86 
87 X(0, next, 220)
88 X(1, next, 221)
89 X(2, next, 222)
90 X(3, next, 223)
91 X(4, next, 224)
92 X(5, next, 225)
93 X(6, next, 226)
94 X(7, next, 227)
95 X(8, next, 228)
96 X(9, next, 229)
97 #undef X
98 
99 // direct weapons
100 
101 #define X(i, imp) \
102  REGISTER_IMPULSE(weapon_byid_##i, imp)
103 X(0, 230)
104 X(1, 231)
105 X(2, 232)
106 X(3, 233)
107 X(4, 234)
108 X(5, 235)
109 X(6, 236)
110 X(7, 237)
111 X(8, 238)
112 X(9, 239)
113 X(10, 240)
114 X(11, 241)
115 X(12, 242)
116 X(13, 243)
117 X(14, 244)
118 X(15, 245)
119 X(16, 246)
120 X(17, 247)
121 X(18, 248)
122 X(19, 249)
123 X(20, 250)
124 X(21, 251)
125 X(22, 252)
126 X(23, 253)
127 #undef X
128 
129 REGISTER_IMPULSE(weapon_next_byid, 10)
130 LEGACY_IMPULSE(_weapnext_2, 10, "weapon_next_byid")
131 
132 REGISTER_IMPULSE(weapon_prev_byid, 12)
133 LEGACY_IMPULSE(_weapprev_2, 12, "weapon_prev_byid")
134 
135 REGISTER_IMPULSE(weapon_next_bygroup, 18)
136 LEGACY_IMPULSE(_weapnext_0, 18, "weapon_next_bygroup")
137 
138 REGISTER_IMPULSE(weapon_prev_bygroup, 19)
139 LEGACY_IMPULSE(_weapprev_0, 19, "weapon_prev_bygroup")
140 
141 REGISTER_IMPULSE(weapon_next_bypriority, 15)
142 LEGACY_IMPULSE(_weapnext_1, 15, "weapon_next_bypriority")
143 
144 REGISTER_IMPULSE(weapon_prev_bypriority, 16)
145 LEGACY_IMPULSE(_weapprev_1, 16, "weapon_prev_bypriority")
146 
147 REGISTER_IMPULSE(weapon_last, 11)
148 LEGACY_IMPULSE(weaplast, 11, "weapon_last")
149 
150 REGISTER_IMPULSE(weapon_best, 13)
151 LEGACY_IMPULSE(weapbest, 13, "weapon_best")
152 
153 REGISTER_IMPULSE(weapon_drop, 17)
154 LEGACY_IMPULSE(dropweapon, 17, "weapon_drop")
155 
156 REGISTER_IMPULSE(weapon_reload, 20)
157 LEGACY_IMPULSE(reload, 20, "weapon_reload")
158 
160 LEGACY_IMPULSE_ID(use, 21)
161 
162 REGISTER_IMPULSE(waypoint_personal_here, 30)
163 LEGACY_IMPULSE(g_waypointsprite_personal, 30, "waypoint_personal_here")
164 
165 REGISTER_IMPULSE(waypoint_personal_crosshair, 31)
166 LEGACY_IMPULSE(g_waypointsprite_personal_p, 31, "waypoint_personal_crosshair")
167 
168 REGISTER_IMPULSE(waypoint_personal_death, 32)
169 LEGACY_IMPULSE(g_waypointsprite_personal_d, 32, "waypoint_personal_death")
170 
171 REGISTER_IMPULSE(waypoint_here_follow, 33)
172 LEGACY_IMPULSE(g_waypointsprite_team_helpme, 33, "waypoint_here_follow")
173 
174 REGISTER_IMPULSE(waypoint_here_here, 34)
175 LEGACY_IMPULSE(g_waypointsprite_team_here, 34, "waypoint_here_here")
176 
177 REGISTER_IMPULSE(waypoint_here_crosshair, 35)
178 LEGACY_IMPULSE(g_waypointsprite_team_here_p, 35, "waypoint_here_crosshair")
179 
180 REGISTER_IMPULSE(waypoint_here_death, 36)
181 LEGACY_IMPULSE(g_waypointsprite_team_here_d, 36, "waypoint_here_death")
182 
183 REGISTER_IMPULSE(waypoint_danger_here, 37)
184 LEGACY_IMPULSE(g_waypointsprite_team_danger, 37, "waypoint_danger_here")
185 
186 REGISTER_IMPULSE(waypoint_danger_crosshair, 38)
187 LEGACY_IMPULSE(g_waypointsprite_team_danger_p, 38, "waypoint_danger_crosshair")
188 
189 REGISTER_IMPULSE(waypoint_danger_death, 39)
190 LEGACY_IMPULSE(g_waypointsprite_team_danger_d, 39, "waypoint_danger_death")
191 
192 REGISTER_IMPULSE(waypoint_clear_personal, 47)
193 LEGACY_IMPULSE(g_waypointsprite_clear_personal, 47, "waypoint_clear_personal")
194 
195 REGISTER_IMPULSE(waypoint_clear, 48)
196 LEGACY_IMPULSE(g_waypointsprite_clear, 48, "waypoint_clear")
197 
198 
199 #define CHIMPULSE(id, n) _CHIMPULSE(CHIMPULSE_##id, n)
200 #define _CHIMPULSE(id, n) \
201  REGISTER(IMPULSES, id, m_id, new_pure(Impulse)) \
202  { \
203  this.impulse = n; \
204  }
205 
206 CHIMPULSE(SPEEDRUN_INIT, 30)
207 CHIMPULSE(GIVE_ALL, 99)
208 CHIMPULSE(CLONE_MOVING, 140)
209 CHIMPULSE(SPEEDRUN, 141)
210 CHIMPULSE(CLONE_STANDING, 142)
211 CHIMPULSE(TELEPORT, 143)
212 CHIMPULSE(R00T, 148)
REGISTRY(Weapons, 72) STATIC_INIT(WeaponPickup)
Definition: all.qh:28
void _impCheck(string s, string alias)
Definition: all.qh:32
REGISTRY_SORT(Notifications)
#define CHIMPULSE(id, n)
Definition: all.qh:199
entity() spawn
prev
Definition: all.qh:66
#define REGISTRY_CHECK(id)
Definition: registry.qh:175
#define REGISTER_IMPULSE(id, n)
Definition: all.qh:22
#define REGISTER_REGISTRY(id)
Definition: registry.qh:212
#define REGISTRY_DEFINE_GET(id, null)
Definition: registry.qh:40
#define NULL
Definition: post.qh:17
next
Definition: all.qh:88
#define LEGACY_IMPULSE_ID(alias, id)
Definition: all.qh:30
#define LEGACY_IMPULSE(alias, id, new)
Definition: all.qh:39
#define X(slot, imp)
Definition: all.qh:101
STATIC_INIT(IMPULSES_renumber)
Definition: all.qh:8
#define LOG_FATALF(...)
Definition: log.qh:59
#define use
Definition: csprogsdefs.qh:50
best
Definition: all.qh:77
#define FOREACH(list, cond, body)
Definition: iter.qh:19