]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/func/train.qc
Fix the use of self, activator and other globals in .use
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / train.qc
index e02b917d1cc118cfc73c0cffea72f60790f3ee29..2a5a702117afc5be5d2abf9268416e46d7f3c87e 100644 (file)
@@ -1,8 +1,11 @@
 .float train_wait_turning;
 void() train_next;
+#ifdef SVQC
+void train_use(entity this, entity actor, entity trigger);
+#endif
 void train_wait()
 {SELFPARAM();
-       WITH(entity, self, self.enemy, SUB_UseTargets());
+       SUB_UseTargets(this.enemy, NULL, NULL);
        self.enemy = world;
 
        // if turning is enabled, the train will turn toward the next point while waiting
@@ -36,7 +39,17 @@ void train_wait()
                stopsoundto(MSG_BROADCAST, self, CH_TRIGGER_SINGLE); // send this as unreliable only, as the train will resume operation shortly anyway
 #endif
 
-       if(self.wait < 0 || self.train_wait_turning) // no waiting or we already waited while turning
+#ifdef SVQC
+       entity tg = find(world, targetname, self.target);
+       if(tg.spawnflags & 4)
+       {
+               self.use1 = train_use;
+               self.SUB_THINK = func_null;
+               self.SUB_NEXTTHINK = 0;
+       }
+       else
+#endif
+            if(self.wait < 0 || self.train_wait_turning) // no waiting or we already waited while turning
        {
                self.train_wait_turning = false;
                train_next();
@@ -163,11 +176,11 @@ void train_link()
        //Net_LinkEntity(self, 0, false, train_send);
 }
 
-void train_use()
+void train_use(entity this, entity actor, entity trigger)
 {
-       self.SUB_NEXTTHINK = self.SUB_LTIME + 1;
-       self.SUB_THINK = train_next;
-       self.use = func_null; // not again
+       this.SUB_NEXTTHINK = this.SUB_LTIME + 1;
+       this.SUB_THINK = train_next;
+       this.use1 = func_null; // not again
 }
 
 void func_train_find()
@@ -211,7 +224,7 @@ spawnfunc(func_train)
        self.effects |= EF_LOWPRECISION;
 
        if(self.spawnflags & 4)
-               self.use = train_use;
+               self.use1 = train_use;
 
        if (self.spawnflags & 2)
        {