]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/self.qh
hud: correctly identify icon_right_align as an int
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / self.qh
1 #pragma once
2
3 // Transition from global 'self' to local 'this'
4
5 // Step 1: auto oldself
6 #if 1
7     #define SELFPARAM() noref const entity this = self
8 #endif
9
10 // Step 2: const self
11 #if 1
12     #define self (0, self)
13     [[alias("self")]] entity __self;
14     #define setself(s) (__self = s)
15     #define WITHSELF(value, block) WITH(entity, __self, value, (0, block))
16 #endif
17
18 // Step 3: propagate SELFPARAM()
19 #if 1
20     #undef self
21     #define self (this, self)
22 #endif
23
24 // Step 4: kill unstructured setself
25 #if 0
26     #undef setself
27 #endif
28
29 // Step 5: this should work
30 #if 0
31     #define self (0, this)
32 #endif
33
34 // Step 6: Remove SELFPARAM in favor of a parameter
35
36 .void(entity this) selftouch;
37 void touch_self() { SELFPARAM(); this.selftouch(this); }
38 #define settouch(e, f) (e.touch = touch_self, e.selftouch = f)
39
40 .void(entity this) selfuse;
41 void use_self() { SELFPARAM(); this.selfuse(this); }
42 #define setuse(e, f) (e.use = use_self, e.selfuse = f)
43
44 .void(entity this) selfthink;
45 void think_self() { SELFPARAM(); this.selfthink(this); }
46 #define setthink(e, f) (e.think = think_self, e.selfthink = f)