]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Self removal kit: update plan
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 26 Mar 2016 15:13:13 +0000 (02:13 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 26 Mar 2016 15:22:31 +0000 (02:22 +1100)
qcsrc/common/triggers/target/music.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/lib/misc.qh
qcsrc/lib/self.qh
qcsrc/server/cl_client.qc
qcsrc/server/g_lights.qc
qcsrc/server/spawnpoints.qc

index 7083fcccd1fdd9ede7566056af52d9eee02887f0..5a4e86c48b370d0dd65baa1f0553abfc433eefb0 100644 (file)
@@ -38,12 +38,10 @@ void target_music_kill()
 {
        FOREACH_ENTITY_CLASS("target_music", true, {
                it.volume = 0;
-               WITHSELF(it, {
-            if (it.targetname == "")
-                target_music_sendto(MSG_ALL, 1);
-            else
-                target_music_sendto(MSG_ALL, 0);
-               });
+        if (it.targetname == "")
+            WITHSELF(it, target_music_sendto(MSG_ALL, 1));
+        else
+            WITHSELF(it, target_music_sendto(MSG_ALL, 0));
        });
 }
 void target_music_use()
index f99d7622f5a500dae872c2f8ef283bc3f45c002d..ccda73209095ba3158535e6527623b97933b4aad 100644 (file)
@@ -953,6 +953,7 @@ bool vehicle_impulse(entity this, int imp)
 
 void vehicles_enter(entity pl, entity veh)
 {
+    SELFPARAM();
        entity oldself = self;
 
    // Remove this when bots know how to use vehicles
index dfabebeeb549923efa956428313c9dd898c65abd..950000f04756ac028e77b1b2859c0fa63dcad215 100644 (file)
@@ -45,5 +45,3 @@
                LAMBDA(block) \
                name = __with_save; \
        } MACRO_END
-
-#define WITHSELF(value, block) WITH(entity, __self, value, block)
index 01dd638c8115a067afac8debceb9aecb51daa033..5d53694c72294ed2c5b077f586ad1ee0e0ad422e 100644 (file)
@@ -2,40 +2,33 @@
 
 // Transition from global 'self' to local 'this'
 
-[[alias("self")]] entity __self;
-
 // Step 1: auto oldself
 #if 1
-#if NDEBUG
-       #define SELFPARAM() noref entity this = __self
-       #define setself(s) (__self = s)
-       #define self __self
-#else
-    noref string self_str;
-       #define SELFPARAM() self_str = "self"; noref entity this = __self
-       #define setself(s) (self_str = #s, __self = s)
-       #define self (print(__SOURCELOC__, ": ", self_str, "\n"), __self)
+    #define SELFPARAM() noref const entity this = self
 #endif
+
+// Step 2: const self
+#if 1
+    #define self (0, self)
+    [[alias("self")]] entity __self;
+    #define setself(s) (__self = s)
+    #define WITHSELF(value, block) WITH(entity, __self, value, (0, block))
 #endif
 
-// Step 2: check SELFPARAM() is present for functions that use self
-#if 0
-       #define SELFPARAM() [[alias("__self")]] noref entity this = __self
-       #define setself(s) (__self = s)
-       #define self this
+// Step 3: propagate SELFPARAM()
+#if 1
+    #undef self
+    #define self (this, self)
 #endif
 
-// Step 3: const self
+// Step 4: kill unstructured setself
 #if 0
-       #define SELFPARAM() noref const entity this = __self
-       entity setself(entity e) { return self = e; }
-       entity getself() { return self; }
-       #define self getself()
+    #undef setself
 #endif
 
-// Step 4: enable when possible
-// TODO: Remove SELFPARAM in favor of a parameter
+// Step 5: this should work
 #if 0
-       #define SELFPARAM() noref const entity this = __self
-       #define self this
+    #define self (0, this)
 #endif
+
+// Step 6: Remove SELFPARAM in favor of a parameter
index 6b99bc4a5cdb74647bc4104c3e07a57e1e5dbccc..9edcf8d5f0806097e3ea7b058d28e4f4c8e662ad 100644 (file)
@@ -68,7 +68,8 @@ void ClientDisconnect();
 STATIC_METHOD(Client, Remove, void(Client this))
 {
     TRANSMUTE(Observer, this);
-    WITHSELF(this, PutClientInServer(); ClientDisconnect());
+    WITHSELF(this, PutClientInServer());
+    WITHSELF(this, ClientDisconnect());
 }
 
 void send_CSQC_teamnagger() {
index 37177326f077e888cb864140679891086f3a6ff9..74e03b7a0d6c3f4a133f8dd6b6593e47819eed47 100644 (file)
@@ -36,6 +36,7 @@ flags:
 */
 void dynlight_think()
 {
+    SELFPARAM();
        if(!self.owner)
                remove(self);
 
@@ -43,6 +44,7 @@ void dynlight_think()
 }
 void dynlight_find_aiment()
 {
+    SELFPARAM();
        entity targ;
        if (!self.target)
                objerror ("dynlight: no target to follow");
@@ -59,6 +61,7 @@ void dynlight_find_aiment()
 }
 void dynlight_find_path()
 {
+    SELFPARAM();
        entity targ;
        if (!self.target)
                objerror ("dynlight: no target to follow");
@@ -71,6 +74,7 @@ void dynlight_find_path()
 }
 void dynlight_find_target()
 {
+    SELFPARAM();
        entity targ;
        if (!self.target)
                objerror ("dynlight: no target to follow");
@@ -83,6 +87,7 @@ void dynlight_find_target()
 }
 void dynlight_use()
 {
+    SELFPARAM();
        if (self.light_lev == 0)
                self.light_lev = self.lefty;
        else
index 4e7cf0f5d1daa634efdb6ad72140cedb89a6b7a3..51af4d16e311e4857e84e1572f2acd6acc2e8c39 100644 (file)
@@ -261,9 +261,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                        ++found;
                        if(ent.spawn_evalfunc)
                        {
-                               WITHSELF(ent, {
-                                       spawn_score = ent.spawn_evalfunc(this, spot, spawn_score);
-                               });
+                               WITHSELF(ent, spawn_score = ent.spawn_evalfunc(this, spot, spawn_score));
                                if(spawn_score.x < 0)
                                        return spawn_score;
                        }