From: TimePath Date: Sun, 22 May 2016 07:47:45 +0000 (+1000) Subject: Cleanup self wrappers X-Git-Tag: xonotic-v0.8.2~900 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c028ea62161e048d7a12774786d587604319e290;p=xonotic%2Fxonotic-data.pk3dir.git Cleanup self wrappers --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 7cbe6e125..4fc67a63d 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -379,19 +379,6 @@ float CSQC_InputEvent(int bInputType, float nPrimary, float nSecondary) // -------------------------------------------------------------------------- // BEGIN OPTIONAL CSQC FUNCTIONS -.void(entity) predraw_qc; -void PreDraw_self() -{ - SELFPARAM(); - if (this.predraw_qc) this.predraw_qc(this); -} - -void setpredraw(entity this, void(entity) pdfunc) -{ - this.predraw = PreDraw_self; - this.predraw_qc = pdfunc; -} - void Ent_Remove(entity this); void Ent_RemovePlayerScore(entity this) diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 9d7c40689..8601d26b5 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -6,8 +6,6 @@ // -------------------------------------------------------------------------- // MENU Functionality -void setpredraw(entity this, void(entity) pdfunc); - // -------------------------------------------------------------------------- // Onslaught diff --git a/qcsrc/lib/self.qh b/qcsrc/lib/self.qh index 7822eefe3..ecb1d6fe5 100644 --- a/qcsrc/lib/self.qh +++ b/qcsrc/lib/self.qh @@ -45,14 +45,20 @@ #define WITHSELF(value, block) block #endif -.void(entity this) selftouch; -void touch_self() { SELFPARAM(); this.selftouch(this); } -#define settouch(e, f) (e.touch = touch_self, e.selftouch = f) +#define SELFWRAP(T, R) \ + [[alias(#T)]] .R() __##T; \ + .R(entity this) self##T; \ + R T##_self() { SELFPARAM(); return this.self##T(this); } -//.void(entity this) selfuse; -//void use_self() { SELFPARAM(); this.selfuse(this); } -//#define setuse(e, f) (e.use = use_self, e.selfuse = f) +noref entity _selftemp; +#define SELFWRAP_SET(T, e, f) \ + (_selftemp = (e), _selftemp.__##T = T##_self, _selftemp.self##T = f) -.void(entity this) selfthink; -void think_self() { SELFPARAM(); this.selfthink(this); } -#define setthink(e, f) (e.think = think_self, e.selfthink = f) +SELFWRAP(think, void) +#define setthink(e, f) SELFWRAP_SET(think, e, f) + +SELFWRAP(touch, void) +#define settouch(e, f) SELFWRAP_SET(touch, e, f) + +SELFWRAP(predraw, void) +#define setpredraw(e, f) SELFWRAP_SET(predraw, e, f)