]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/self.qh
Delete unused SELFPARAM
[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     #undef SELFPARAM
23     #define SELFPARAM() const entity this = __self
24 #endif
25
26 // Step 4: kill unstructured setself
27 #if 0
28     #undef setself
29 #endif
30
31 // Step 5: this should work
32 #if 0
33     #define self (0, this)
34 #endif
35
36 // Step 6: Remove SELFPARAM in favor of a parameter
37
38 .void(entity this) selftouch;
39 void touch_self() { SELFPARAM(); this.selftouch(this); }
40 #define settouch(e, f) (e.touch = touch_self, e.selftouch = f)
41
42 //.void(entity this) selfuse;
43 //void use_self() { SELFPARAM(); this.selfuse(this); }
44 //#define setuse(e, f) (e.use = use_self, e.selfuse = f)
45
46 .void(entity this) selfthink;
47 void think_self() { SELFPARAM(); this.selfthink(this); }
48 #define setthink(e, f) (e.think = think_self, e.selfthink = f)