]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/func/conveyor.qc
Merge branch 'master' into Mario/hagar_notfixed
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / conveyor.qc
index 05f0fa09347e31734fb80b793681f0e1f9fc7c11..583c737438ac3fae10131e2497018df65789ca38 100644 (file)
@@ -1,5 +1,7 @@
+REGISTER_NET_LINKED(ENT_CLIENT_CONVEYOR)
+
 void conveyor_think()
-{
+{SELFPARAM();
 #ifdef CSQC
        // TODO: check if this is what is causing the glitchiness when switching between them
        float dt = time - self.move_time;
@@ -57,22 +59,22 @@ void conveyor_think()
 #ifdef SVQC
 
 void conveyor_use()
-{
+{SELFPARAM();
        self.state = !self.state;
 
        self.SendFlags |= 2;
 }
 
-void conveyor_reset()
+void conveyor_reset(entity this)
 {
-       self.state = (self.spawnflags & 1);
+       this.state = (this.spawnflags & 1);
 
-       self.SendFlags |= 2;
+       this.SendFlags |= 2;
 }
 
-float conveyor_send(entity to, float sf)
+bool conveyor_send(entity this, entity to, int sf)
 {
-       WriteByte(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
+       WriteHeader(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
        WriteByte(MSG_ENTITY, sf);
 
        if(sf & 1)
@@ -107,38 +109,37 @@ float conveyor_send(entity to, float sf)
 }
 
 void conveyor_init()
-{
-       if (!self.speed)
-               self.speed = 200;
-       self.movedir = self.movedir * self.speed;
-       self.think = conveyor_think;
-       self.nextthink = time;
+{SELFPARAM();
+       if (!this.speed) this.speed = 200;
+       this.movedir *= this.speed;
+       this.think = conveyor_think;
+       this.nextthink = time;
        IFTARGETED
        {
-               self.use = conveyor_use;
-               self.reset = conveyor_reset;
-               conveyor_reset();
+               this.use = conveyor_use;
+               this.reset = conveyor_reset;
+               this.reset(this);
        }
        else
-               self.state = 1;
+               this.state = 1;
 
-       FixSize(self);
+       FixSize(this);
 
-       Net_LinkEntity(self, 0, false, conveyor_send);
+       Net_LinkEntity(this, 0, false, conveyor_send);
 
-       self.SendFlags |= 1;
+       this.SendFlags |= 1;
 }
 
-void spawnfunc_trigger_conveyor()
+spawnfunc(trigger_conveyor)
 {
-       SetMovedir();
+       SetMovedir(self);
        EXACTTRIGGER_INIT;
        conveyor_init();
 }
 
-void spawnfunc_func_conveyor()
+spawnfunc(func_conveyor)
 {
-       SetMovedir();
+       SetMovedir(self);
        InitMovingBrushTrigger();
        self.movetype = MOVETYPE_NONE;
        conveyor_init();
@@ -146,9 +147,11 @@ void spawnfunc_func_conveyor()
 
 #elif defined(CSQC)
 
+void conveyor_draw(entity this) { WITHSELF(this, conveyor_think()); }
+
 void conveyor_init()
-{
-       self.draw = conveyor_think;
+{SELFPARAM();
+       self.draw = conveyor_draw;
        self.drawmask = MASK_NORMAL;
 
        self.movetype = MOVETYPE_NONE;
@@ -158,7 +161,7 @@ void conveyor_init()
        self.move_time = time;
 }
 
-void ent_conveyor()
+NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
 {
        float sf = ReadByte();
 
@@ -193,5 +196,7 @@ void ent_conveyor()
 
        if(sf & 2)
                self.state = ReadByte();
+
+       return true;
 }
 #endif