]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/func/train.qc
Add missing SELFPARAM()
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / train.qc
index 65414548b2e27f3926e41d5d4c3ad6416db7c568..77bb7b87090b4e093180c0b1ec0cf2cb2fa205c1 100644 (file)
@@ -1,5 +1,8 @@
 .float train_wait_turning;
 void() train_next;
+#ifdef SVQC
+void train_use();
+#endif
 void train_wait()
 {SELFPARAM();
        WITH(entity, self, self.enemy, SUB_UseTargets());
@@ -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.use = 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();
@@ -101,10 +114,12 @@ void train_next()
                _sound(self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE);
 }
 
+REGISTER_NET_LINKED(ENT_CLIENT_TRAIN)
+
 #ifdef SVQC
 float train_send(entity to, float sf)
 {SELFPARAM();
-       WriteByte(MSG_ENTITY, ENT_CLIENT_TRAIN);
+       WriteHeader(MSG_ENTITY, ENT_CLIENT_TRAIN);
        WriteByte(MSG_ENTITY, sf);
 
        if(sf & SF_TRIGGER_INIT)
@@ -115,7 +130,7 @@ float train_send(entity to, float sf)
 
                WriteString(MSG_ENTITY, self.model);
 
-               trigger_common_write(true);
+               trigger_common_write(self, true);
 
                WriteString(MSG_ENTITY, self.curvetarget);
 
@@ -163,6 +178,7 @@ void train_link()
 
 void train_use()
 {
+    SELFPARAM();
        self.SUB_NEXTTHINK = self.SUB_LTIME + 1;
        self.SUB_THINK = train_next;
        self.use = func_null; // not again
@@ -242,11 +258,11 @@ spawnfunc(func_train)
 void train_draw(entity this)
 {
        //Movetype_Physics_NoMatchServer();
-       Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
+       Movetype_Physics_MatchServer(this, autocvar_cl_projectiles_sloppy);
 }
 
-void ent_train()
-{SELFPARAM();
+NET_HANDLE(ENT_CLIENT_TRAIN, bool isnew)
+{
        float sf = ReadByte();
 
        if(sf & SF_TRIGGER_INIT)
@@ -321,6 +337,8 @@ void ent_train()
        {
                // TODO: make a reset function for trains
        }
+
+       return true;
 }
 
 #endif